diff options
author | Scott Feldman <scofeldm@cisco.com> | 2008-09-15 12:17:11 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-09-18 11:34:53 -0400 |
commit | 01f2e4ead2c51226ed1283ef6a8388ca6f4cff8f (patch) | |
tree | b1cc2ef1a191a3bf00f371d5dbc2028e1fee01c5 /drivers/net/enic/vnic_devcmd.h | |
parent | 452c1ce218a68b5dbd626397ecfc65ca89dd3cbb (diff) |
enic: add Cisco 10G Ethernet NIC driver
Signed-off-by: Scott Feldman <scofeldm@cisco.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/enic/vnic_devcmd.h')
-rw-r--r-- | drivers/net/enic/vnic_devcmd.h | 282 |
1 files changed, 282 insertions, 0 deletions
diff --git a/drivers/net/enic/vnic_devcmd.h b/drivers/net/enic/vnic_devcmd.h new file mode 100644 index 000000000000..d8617a3373b1 --- /dev/null +++ b/drivers/net/enic/vnic_devcmd.h | |||
@@ -0,0 +1,282 @@ | |||
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 | */ | ||
19 | |||
20 | #ifndef _VNIC_DEVCMD_H_ | ||
21 | #define _VNIC_DEVCMD_H_ | ||
22 | |||
23 | #define _CMD_NBITS 14 | ||
24 | #define _CMD_VTYPEBITS 10 | ||
25 | #define _CMD_FLAGSBITS 6 | ||
26 | #define _CMD_DIRBITS 2 | ||
27 | |||
28 | #define _CMD_NMASK ((1 << _CMD_NBITS)-1) | ||
29 | #define _CMD_VTYPEMASK ((1 << _CMD_VTYPEBITS)-1) | ||
30 | #define _CMD_FLAGSMASK ((1 << _CMD_FLAGSBITS)-1) | ||
31 | #define _CMD_DIRMASK ((1 << _CMD_DIRBITS)-1) | ||
32 | |||
33 | #define _CMD_NSHIFT 0 | ||
34 | #define _CMD_VTYPESHIFT (_CMD_NSHIFT+_CMD_NBITS) | ||
35 | #define _CMD_FLAGSSHIFT (_CMD_VTYPESHIFT+_CMD_VTYPEBITS) | ||
36 | #define _CMD_DIRSHIFT (_CMD_FLAGSSHIFT+_CMD_FLAGSBITS) | ||
37 | |||
38 | /* | ||
39 | * Direction bits (from host perspective). | ||
40 | */ | ||
41 | #define _CMD_DIR_NONE 0U | ||
42 | #define _CMD_DIR_WRITE 1U | ||
43 | #define _CMD_DIR_READ 2U | ||
44 | #define _CMD_DIR_RW (_CMD_DIR_WRITE | _CMD_DIR_READ) | ||
45 | |||
46 | /* | ||
47 | * Flag bits. | ||
48 | */ | ||
49 | #define _CMD_FLAGS_NONE 0U | ||
50 | #define _CMD_FLAGS_NOWAIT 1U | ||
51 | |||
52 | /* | ||
53 | * vNIC type bits. | ||
54 | */ | ||
55 | #define _CMD_VTYPE_NONE 0U | ||
56 | #define _CMD_VTYPE_ENET 1U | ||
57 | #define _CMD_VTYPE_FC 2U | ||
58 | #define _CMD_VTYPE_SCSI 4U | ||
59 | #define _CMD_VTYPE_ALL (_CMD_VTYPE_ENET | _CMD_VTYPE_FC | _CMD_VTYPE_SCSI) | ||
60 | |||
61 | /* | ||
62 | * Used to create cmds.. | ||
63 | */ | ||
64 | #define _CMDCF(dir, flags, vtype, nr) \ | ||
65 | (((dir) << _CMD_DIRSHIFT) | \ | ||
66 | ((flags) << _CMD_FLAGSSHIFT) | \ | ||
67 | ((vtype) << _CMD_VTYPESHIFT) | \ | ||
68 | ((nr) << _CMD_NSHIFT)) | ||
69 | #define _CMDC(dir, vtype, nr) _CMDCF(dir, 0, vtype, nr) | ||
70 | #define _CMDCNW(dir, vtype, nr) _CMDCF(dir, _CMD_FLAGS_NOWAIT, vtype, nr) | ||
71 | |||
72 | /* | ||
73 | * Used to decode cmds.. | ||
74 | */ | ||
75 | #define _CMD_DIR(cmd) (((cmd) >> _CMD_DIRSHIFT) & _CMD_DIRMASK) | ||
76 | #define _CMD_FLAGS(cmd) (((cmd) >> _CMD_FLAGSSHIFT) & _CMD_FLAGSMASK) | ||
77 | #define _CMD_VTYPE(cmd) (((cmd) >> _CMD_VTYPESHIFT) & _CMD_VTYPEMASK) | ||
78 | #define _CMD_N(cmd) (((cmd) >> _CMD_NSHIFT) & _CMD_NMASK) | ||
79 | |||
80 | enum vnic_devcmd_cmd { | ||
81 | CMD_NONE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_NONE, 0), | ||
82 | |||
83 | /* mcpu fw info in mem: (u64)a0=paddr to struct vnic_devcmd_fw_info */ | ||
84 | CMD_MCPU_FW_INFO = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 1), | ||
85 | |||
86 | /* dev-specific block member: | ||
87 | * in: (u16)a0=offset,(u8)a1=size | ||
88 | * out: a0=value */ | ||
89 | CMD_DEV_SPEC = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 2), | ||
90 | |||
91 | /* stats clear */ | ||
92 | CMD_STATS_CLEAR = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 3), | ||
93 | |||
94 | /* stats dump in mem: (u64)a0=paddr to stats area, | ||
95 | * (u16)a1=sizeof stats area */ | ||
96 | CMD_STATS_DUMP = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 4), | ||
97 | |||
98 | /* set Rx packet filter: (u32)a0=filters (see CMD_PFILTER_*) */ | ||
99 | CMD_PACKET_FILTER = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 7), | ||
100 | |||
101 | /* hang detection notification */ | ||
102 | CMD_HANG_NOTIFY = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 8), | ||
103 | |||
104 | /* MAC address in (u48)a0 */ | ||
105 | CMD_MAC_ADDR = _CMDC(_CMD_DIR_READ, | ||
106 | _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 9), | ||
107 | |||
108 | /* disable/enable promisc mode: (u8)a0=0/1 */ | ||
109 | /***** XXX DEPRECATED *****/ | ||
110 | CMD_PROMISC_MODE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 10), | ||
111 | |||
112 | /* disable/enable all-multi mode: (u8)a0=0/1 */ | ||
113 | /***** XXX DEPRECATED *****/ | ||
114 | CMD_ALLMULTI_MODE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 11), | ||
115 | |||
116 | /* add addr from (u48)a0 */ | ||
117 | CMD_ADDR_ADD = _CMDCNW(_CMD_DIR_WRITE, | ||
118 | _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 12), | ||
119 | |||
120 | /* del addr from (u48)a0 */ | ||
121 | CMD_ADDR_DEL = _CMDCNW(_CMD_DIR_WRITE, | ||
122 | _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 13), | ||
123 | |||
124 | /* add VLAN id in (u16)a0 */ | ||
125 | CMD_VLAN_ADD = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 14), | ||
126 | |||
127 | /* del VLAN id in (u16)a0 */ | ||
128 | CMD_VLAN_DEL = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 15), | ||
129 | |||
130 | /* nic_cfg in (u32)a0 */ | ||
131 | CMD_NIC_CFG = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 16), | ||
132 | |||
133 | /* union vnic_rss_key in mem: (u64)a0=paddr, (u16)a1=len */ | ||
134 | CMD_RSS_KEY = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 17), | ||
135 | |||
136 | /* union vnic_rss_cpu in mem: (u64)a0=paddr, (u16)a1=len */ | ||
137 | CMD_RSS_CPU = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 18), | ||
138 | |||
139 | /* initiate softreset */ | ||
140 | CMD_SOFT_RESET = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 19), | ||
141 | |||
142 | /* softreset status: | ||
143 | * out: a0=0 reset complete, a0=1 reset in progress */ | ||
144 | CMD_SOFT_RESET_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 20), | ||
145 | |||
146 | /* set struct vnic_devcmd_notify buffer in mem: | ||
147 | * in: | ||
148 | * (u64)a0=paddr to notify (set paddr=0 to unset) | ||
149 | * (u32)a1 & 0x00000000ffffffff=sizeof(struct vnic_devcmd_notify) | ||
150 | * (u16)a1 & 0x0000ffff00000000=intr num (-1 for no intr) | ||
151 | * out: | ||
152 | * (u32)a1 = effective size | ||
153 | */ | ||
154 | CMD_NOTIFY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 21), | ||
155 | |||
156 | /* UNDI API: (u64)a0=paddr to s_PXENV_UNDI_ struct, | ||
157 | * (u8)a1=PXENV_UNDI_xxx */ | ||
158 | CMD_UNDI = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 22), | ||
159 | |||
160 | /* initiate open sequence (u32)a0=flags (see CMD_OPENF_*) */ | ||
161 | CMD_OPEN = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 23), | ||
162 | |||
163 | /* open status: | ||
164 | * out: a0=0 open complete, a0=1 open in progress */ | ||
165 | CMD_OPEN_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 24), | ||
166 | |||
167 | /* close vnic */ | ||
168 | CMD_CLOSE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 25), | ||
169 | |||
170 | /* initialize virtual link: (u32)a0=flags (see CMD_INITF_*) */ | ||
171 | CMD_INIT = _CMDCNW(_CMD_DIR_READ, _CMD_VTYPE_ALL, 26), | ||
172 | |||
173 | /* variant of CMD_INIT, with provisioning info | ||
174 | * (u64)a0=paddr of vnic_devcmd_provinfo | ||
175 | * (u32)a1=sizeof provision info */ | ||
176 | CMD_INIT_PROV_INFO = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 27), | ||
177 | |||
178 | /* enable virtual link */ | ||
179 | CMD_ENABLE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28), | ||
180 | |||
181 | /* disable virtual link */ | ||
182 | CMD_DISABLE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 29), | ||
183 | |||
184 | /* stats dump all vnics on uplink in mem: (u64)a0=paddr (u32)a1=uif */ | ||
185 | CMD_STATS_DUMP_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 30), | ||
186 | |||
187 | /* init status: | ||
188 | * out: a0=0 init complete, a0=1 init in progress | ||
189 | * if a0=0, a1=errno */ | ||
190 | CMD_INIT_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 31), | ||
191 | |||
192 | /* INT13 API: (u64)a0=paddr to vnic_int13_params struct | ||
193 | * (u8)a1=INT13_CMD_xxx */ | ||
194 | CMD_INT13 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_FC, 32), | ||
195 | |||
196 | /* logical uplink enable/disable: (u64)a0: 0/1=disable/enable */ | ||
197 | CMD_LOGICAL_UPLINK = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 33), | ||
198 | |||
199 | /* undo initialize of virtual link */ | ||
200 | CMD_DEINIT = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 34), | ||
201 | }; | ||
202 | |||
203 | /* flags for CMD_OPEN */ | ||
204 | #define CMD_OPENF_OPROM 0x1 /* open coming from option rom */ | ||
205 | |||
206 | /* flags for CMD_INIT */ | ||
207 | #define CMD_INITF_DEFAULT_MAC 0x1 /* init with default mac addr */ | ||
208 | |||
209 | /* flags for CMD_PACKET_FILTER */ | ||
210 | #define CMD_PFILTER_DIRECTED 0x01 | ||
211 | #define CMD_PFILTER_MULTICAST 0x02 | ||
212 | #define CMD_PFILTER_BROADCAST 0x04 | ||
213 | #define CMD_PFILTER_PROMISCUOUS 0x08 | ||
214 | #define CMD_PFILTER_ALL_MULTICAST 0x10 | ||
215 | |||
216 | enum vnic_devcmd_status { | ||
217 | STAT_NONE = 0, | ||
218 | STAT_BUSY = 1 << 0, /* cmd in progress */ | ||
219 | STAT_ERROR = 1 << 1, /* last cmd caused error (code in a0) */ | ||
220 | }; | ||
221 | |||
222 | enum vnic_devcmd_error { | ||
223 | ERR_SUCCESS = 0, | ||
224 | ERR_EINVAL = 1, | ||
225 | ERR_EFAULT = 2, | ||
226 | ERR_EPERM = 3, | ||
227 | ERR_EBUSY = 4, | ||
228 | ERR_ECMDUNKNOWN = 5, | ||
229 | ERR_EBADSTATE = 6, | ||
230 | ERR_ENOMEM = 7, | ||
231 | ERR_ETIMEDOUT = 8, | ||
232 | ERR_ELINKDOWN = 9, | ||
233 | }; | ||
234 | |||
235 | struct vnic_devcmd_fw_info { | ||
236 | char fw_version[32]; | ||
237 | char fw_build[32]; | ||
238 | char hw_version[32]; | ||
239 | char hw_serial_number[32]; | ||
240 | }; | ||
241 | |||
242 | struct vnic_devcmd_notify { | ||
243 | u32 csum; /* checksum over following words */ | ||
244 | |||
245 | u32 link_state; /* link up == 1 */ | ||
246 | u32 port_speed; /* effective port speed (rate limit) */ | ||
247 | u32 mtu; /* MTU */ | ||
248 | u32 msglvl; /* requested driver msg lvl */ | ||
249 | u32 uif; /* uplink interface */ | ||
250 | u32 status; /* status bits (see VNIC_STF_*) */ | ||
251 | u32 error; /* error code (see ERR_*) for first ERR */ | ||
252 | }; | ||
253 | #define VNIC_STF_FATAL_ERR 0x0001 /* fatal fw error */ | ||
254 | |||
255 | struct vnic_devcmd_provinfo { | ||
256 | u8 oui[3]; | ||
257 | u8 type; | ||
258 | u8 data[0]; | ||
259 | }; | ||
260 | |||
261 | /* | ||
262 | * Writing cmd register causes STAT_BUSY to get set in status register. | ||
263 | * When cmd completes, STAT_BUSY will be cleared. | ||
264 | * | ||
265 | * If cmd completed successfully STAT_ERROR will be clear | ||
266 | * and args registers contain cmd-specific results. | ||
267 | * | ||
268 | * If cmd error, STAT_ERROR will be set and args[0] contains error code. | ||
269 | * | ||
270 | * status register is read-only. While STAT_BUSY is set, | ||
271 | * all other register contents are read-only. | ||
272 | */ | ||
273 | |||
274 | /* Make sizeof(vnic_devcmd) a power-of-2 for I/O BAR. */ | ||
275 | #define VNIC_DEVCMD_NARGS 15 | ||
276 | struct vnic_devcmd { | ||
277 | u32 status; /* RO */ | ||
278 | u32 cmd; /* RW */ | ||
279 | u64 args[VNIC_DEVCMD_NARGS]; /* RW cmd args (little-endian) */ | ||
280 | }; | ||
281 | |||
282 | #endif /* _VNIC_DEVCMD_H_ */ | ||