Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vnic_devcmd.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Cisco Systems, Inc. All rights reserved.
3  * Copyright 2007 Nuova Systems, Inc. All rights reserved.
4  *
5  * This program is free software; you may redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; version 2 of the License.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
10  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
12  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
13  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
14  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
15  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16  * SOFTWARE.
17  */
18 #ifndef _VNIC_DEVCMD_H_
19 #define _VNIC_DEVCMD_H_
20 
21 #define _CMD_NBITS 14
22 #define _CMD_VTYPEBITS 10
23 #define _CMD_FLAGSBITS 6
24 #define _CMD_DIRBITS 2
25 
26 #define _CMD_NMASK ((1 << _CMD_NBITS)-1)
27 #define _CMD_VTYPEMASK ((1 << _CMD_VTYPEBITS)-1)
28 #define _CMD_FLAGSMASK ((1 << _CMD_FLAGSBITS)-1)
29 #define _CMD_DIRMASK ((1 << _CMD_DIRBITS)-1)
30 
31 #define _CMD_NSHIFT 0
32 #define _CMD_VTYPESHIFT (_CMD_NSHIFT+_CMD_NBITS)
33 #define _CMD_FLAGSSHIFT (_CMD_VTYPESHIFT+_CMD_VTYPEBITS)
34 #define _CMD_DIRSHIFT (_CMD_FLAGSSHIFT+_CMD_FLAGSBITS)
35 
36 /*
37  * Direction bits (from host perspective).
38  */
39 #define _CMD_DIR_NONE 0U
40 #define _CMD_DIR_WRITE 1U
41 #define _CMD_DIR_READ 2U
42 #define _CMD_DIR_RW (_CMD_DIR_WRITE | _CMD_DIR_READ)
43 
44 /*
45  * Flag bits.
46  */
47 #define _CMD_FLAGS_NONE 0U
48 #define _CMD_FLAGS_NOWAIT 1U
49 
50 /*
51  * vNIC type bits.
52  */
53 #define _CMD_VTYPE_NONE 0U
54 #define _CMD_VTYPE_ENET 1U
55 #define _CMD_VTYPE_FC 2U
56 #define _CMD_VTYPE_SCSI 4U
57 #define _CMD_VTYPE_ALL (_CMD_VTYPE_ENET | _CMD_VTYPE_FC | _CMD_VTYPE_SCSI)
58 
59 /*
60  * Used to create cmds..
61 */
62 #define _CMDCF(dir, flags, vtype, nr) \
63  (((dir) << _CMD_DIRSHIFT) | \
64  ((flags) << _CMD_FLAGSSHIFT) | \
65  ((vtype) << _CMD_VTYPESHIFT) | \
66  ((nr) << _CMD_NSHIFT))
67 #define _CMDC(dir, vtype, nr) _CMDCF(dir, 0, vtype, nr)
68 #define _CMDCNW(dir, vtype, nr) _CMDCF(dir, _CMD_FLAGS_NOWAIT, vtype, nr)
69 
70 /*
71  * Used to decode cmds..
72 */
73 #define _CMD_DIR(cmd) (((cmd) >> _CMD_DIRSHIFT) & _CMD_DIRMASK)
74 #define _CMD_FLAGS(cmd) (((cmd) >> _CMD_FLAGSSHIFT) & _CMD_FLAGSMASK)
75 #define _CMD_VTYPE(cmd) (((cmd) >> _CMD_VTYPESHIFT) & _CMD_VTYPEMASK)
76 #define _CMD_N(cmd) (((cmd) >> _CMD_NSHIFT) & _CMD_NMASK)
77 
80 
81  /* mcpu fw info in mem: (u64)a0=paddr to struct vnic_devcmd_fw_info */
83 
84  /* dev-specific block member:
85  * in: (u16)a0=offset,(u8)a1=size
86  * out: a0=value */
88 
89  /* stats clear */
91 
92  /* stats dump in mem: (u64)a0=paddr to stats area,
93  * (u16)a1=sizeof stats area */
95 
96  /* set Rx packet filter: (u32)a0=filters (see CMD_PFILTER_*) */
98 
99  /* hang detection notification */
101 
102  /* MAC address in (u48)a0 */
105 
106  /* disable/enable promisc mode: (u8)a0=0/1 */
107 /***** XXX DEPRECATED *****/
109 
110  /* disable/enable all-multi mode: (u8)a0=0/1 */
111 /***** XXX DEPRECATED *****/
113 
114  /* add addr from (u48)a0 */
117 
118  /* del addr from (u48)a0 */
121 
122  /* add VLAN id in (u16)a0 */
124 
125  /* del VLAN id in (u16)a0 */
127 
128  /* nic_cfg in (u32)a0 */
130 
131  /* union vnic_rss_key in mem: (u64)a0=paddr, (u16)a1=len */
133 
134  /* union vnic_rss_cpu in mem: (u64)a0=paddr, (u16)a1=len */
136 
137  /* initiate softreset */
139 
140  /* softreset status:
141  * out: a0=0 reset complete, a0=1 reset in progress */
143 
144  /* set struct vnic_devcmd_notify buffer in mem:
145  * in:
146  * (u64)a0=paddr to notify (set paddr=0 to unset)
147  * (u32)a1 & 0x00000000ffffffff=sizeof(struct vnic_devcmd_notify)
148  * (u16)a1 & 0x0000ffff00000000=intr num (-1 for no intr)
149  * out:
150  * (u32)a1 = effective size
151  */
153 
154  /* UNDI API: (u64)a0=paddr to s_PXENV_UNDI_ struct,
155  * (u8)a1=PXENV_UNDI_xxx */
157 
158  /* initiate open sequence (u32)a0=flags (see CMD_OPENF_*) */
160 
161  /* open status:
162  * out: a0=0 open complete, a0=1 open in progress */
164 
165  /* close vnic */
167 
168  /* initialize virtual link: (u32)a0=flags (see CMD_INITF_*) */
170 
171  /* variant of CMD_INIT, with provisioning info
172  * (u64)a0=paddr of vnic_devcmd_provinfo
173  * (u32)a1=sizeof provision info */
175 
176  /* enable virtual link */
178 
179  /* disable virtual link */
181 
182  /* stats dump all vnics on uplink in mem: (u64)a0=paddr (u32)a1=uif */
184 
185  /* init status:
186  * out: a0=0 init complete, a0=1 init in progress
187  * if a0=0, a1=errno */
189 
190  /* INT13 API: (u64)a0=paddr to vnic_int13_params struct
191  * (u8)a1=INT13_CMD_xxx */
193 
194  /* logical uplink enable/disable: (u64)a0: 0/1=disable/enable */
196 
197  /* undo initialize of virtual link */
199 };
200 
201 /* flags for CMD_OPEN */
202 #define CMD_OPENF_OPROM 0x1 /* open coming from option rom */
203 
204 /* flags for CMD_INIT */
205 #define CMD_INITF_DEFAULT_MAC 0x1 /* init with default mac addr */
206 
207 /* flags for CMD_PACKET_FILTER */
208 #define CMD_PFILTER_DIRECTED 0x01
209 #define CMD_PFILTER_MULTICAST 0x02
210 #define CMD_PFILTER_BROADCAST 0x04
211 #define CMD_PFILTER_PROMISCUOUS 0x08
212 #define CMD_PFILTER_ALL_MULTICAST 0x10
213 
216  STAT_BUSY = 1 << 0, /* cmd in progress */
217  STAT_ERROR = 1 << 1, /* last cmd caused error (code in a0) */
218 };
219 
231 };
232 
233 struct vnic_devcmd_fw_info {
234  char fw_version[32];
235  char fw_build[32];
236  char hw_version[32];
237  char hw_serial_number[32];
238 };
239 
240 struct vnic_devcmd_notify {
241  u32 csum; /* checksum over following words */
242 
243  u32 link_state; /* link up == 1 */
244  u32 port_speed; /* effective port speed (rate limit) */
245  u32 mtu; /* MTU */
246  u32 msglvl; /* requested driver msg lvl */
247  u32 uif; /* uplink interface */
248  u32 status; /* status bits (see VNIC_STF_*) */
249  u32 error; /* error code (see ERR_*) for first ERR */
250  u32 link_down_cnt; /* running count of link down transitions */
251 };
252 #define VNIC_STF_FATAL_ERR 0x0001 /* fatal fw error */
253 
254 struct vnic_devcmd_provinfo {
255  u8 oui[3];
256  u8 type;
257  u8 data[0];
258 };
259 
260 /*
261  * Writing cmd register causes STAT_BUSY to get set in status register.
262  * When cmd completes, STAT_BUSY will be cleared.
263  *
264  * If cmd completed successfully STAT_ERROR will be clear
265  * and args registers contain cmd-specific results.
266  *
267  * If cmd error, STAT_ERROR will be set and args[0] contains error code.
268  *
269  * status register is read-only. While STAT_BUSY is set,
270  * all other register contents are read-only.
271  */
272 
273 /* Make sizeof(vnic_devcmd) a power-of-2 for I/O BAR. */
274 #define VNIC_DEVCMD_NARGS 15
275 struct vnic_devcmd {
276  u32 status; /* RO */
277  u32 cmd; /* RW */
278  u64 args[VNIC_DEVCMD_NARGS]; /* RW cmd args (little-endian) */
279 };
280 
281 #endif /* _VNIC_DEVCMD_H_ */