vnic_devcmd.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. /*
  2. * Copyright 2008-2010 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. #ifndef _VNIC_DEVCMD_H_
  20. #define _VNIC_DEVCMD_H_
  21. #define _CMD_NBITS 14
  22. #define _CMD_VTYPEBITS 10
  23. #define _CMD_FLAGSBITS 6
  24. #define _CMD_DIRBITS 2
  25. #define _CMD_NMASK ((1 << _CMD_NBITS)-1)
  26. #define _CMD_VTYPEMASK ((1 << _CMD_VTYPEBITS)-1)
  27. #define _CMD_FLAGSMASK ((1 << _CMD_FLAGSBITS)-1)
  28. #define _CMD_DIRMASK ((1 << _CMD_DIRBITS)-1)
  29. #define _CMD_NSHIFT 0
  30. #define _CMD_VTYPESHIFT (_CMD_NSHIFT+_CMD_NBITS)
  31. #define _CMD_FLAGSSHIFT (_CMD_VTYPESHIFT+_CMD_VTYPEBITS)
  32. #define _CMD_DIRSHIFT (_CMD_FLAGSSHIFT+_CMD_FLAGSBITS)
  33. /*
  34. * Direction bits (from host perspective).
  35. */
  36. #define _CMD_DIR_NONE 0U
  37. #define _CMD_DIR_WRITE 1U
  38. #define _CMD_DIR_READ 2U
  39. #define _CMD_DIR_RW (_CMD_DIR_WRITE | _CMD_DIR_READ)
  40. /*
  41. * Flag bits.
  42. */
  43. #define _CMD_FLAGS_NONE 0U
  44. #define _CMD_FLAGS_NOWAIT 1U
  45. /*
  46. * vNIC type bits.
  47. */
  48. #define _CMD_VTYPE_NONE 0U
  49. #define _CMD_VTYPE_ENET 1U
  50. #define _CMD_VTYPE_FC 2U
  51. #define _CMD_VTYPE_SCSI 4U
  52. #define _CMD_VTYPE_ALL (_CMD_VTYPE_ENET | _CMD_VTYPE_FC | _CMD_VTYPE_SCSI)
  53. /*
  54. * Used to create cmds..
  55. */
  56. #define _CMDCF(dir, flags, vtype, nr) \
  57. (((dir) << _CMD_DIRSHIFT) | \
  58. ((flags) << _CMD_FLAGSSHIFT) | \
  59. ((vtype) << _CMD_VTYPESHIFT) | \
  60. ((nr) << _CMD_NSHIFT))
  61. #define _CMDC(dir, vtype, nr) _CMDCF(dir, 0, vtype, nr)
  62. #define _CMDCNW(dir, vtype, nr) _CMDCF(dir, _CMD_FLAGS_NOWAIT, vtype, nr)
  63. /*
  64. * Used to decode cmds..
  65. */
  66. #define _CMD_DIR(cmd) (((cmd) >> _CMD_DIRSHIFT) & _CMD_DIRMASK)
  67. #define _CMD_FLAGS(cmd) (((cmd) >> _CMD_FLAGSSHIFT) & _CMD_FLAGSMASK)
  68. #define _CMD_VTYPE(cmd) (((cmd) >> _CMD_VTYPESHIFT) & _CMD_VTYPEMASK)
  69. #define _CMD_N(cmd) (((cmd) >> _CMD_NSHIFT) & _CMD_NMASK)
  70. enum vnic_devcmd_cmd {
  71. CMD_NONE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_NONE, 0),
  72. /*
  73. * mcpu fw info in mem:
  74. * in:
  75. * (u64)a0=paddr to struct vnic_devcmd_fw_info
  76. * action:
  77. * Fills in struct vnic_devcmd_fw_info (128 bytes)
  78. * note:
  79. * An old definition of CMD_MCPU_FW_INFO
  80. */
  81. CMD_MCPU_FW_INFO_OLD = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 1),
  82. /*
  83. * mcpu fw info in mem:
  84. * in:
  85. * (u64)a0=paddr to struct vnic_devcmd_fw_info
  86. * (u16)a1=size of the structure
  87. * out:
  88. * (u16)a1=0 for in:a1 = 0,
  89. * data size actually written for other values.
  90. * action:
  91. * Fills in first 128 bytes of vnic_devcmd_fw_info for in:a1 = 0,
  92. * first in:a1 bytes for 0 < in:a1 <= 132,
  93. * 132 bytes for other values of in:a1.
  94. * note:
  95. * CMD_MCPU_FW_INFO and CMD_MCPU_FW_INFO_OLD have the same enum 1
  96. * for source compatibility.
  97. */
  98. CMD_MCPU_FW_INFO = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 1),
  99. /* dev-specific block member:
  100. * in: (u16)a0=offset,(u8)a1=size
  101. * out: a0=value */
  102. CMD_DEV_SPEC = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 2),
  103. /* stats clear */
  104. CMD_STATS_CLEAR = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 3),
  105. /* stats dump in mem: (u64)a0=paddr to stats area,
  106. * (u16)a1=sizeof stats area */
  107. CMD_STATS_DUMP = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 4),
  108. /* set Rx packet filter: (u32)a0=filters (see CMD_PFILTER_*) */
  109. CMD_PACKET_FILTER = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 7),
  110. /* set Rx packet filter for all: (u32)a0=filters (see CMD_PFILTER_*) */
  111. CMD_PACKET_FILTER_ALL = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 7),
  112. /* hang detection notification */
  113. CMD_HANG_NOTIFY = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 8),
  114. /* MAC address in (u48)a0 */
  115. CMD_GET_MAC_ADDR = _CMDC(_CMD_DIR_READ,
  116. _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 9),
  117. /* add addr from (u48)a0 */
  118. CMD_ADDR_ADD = _CMDCNW(_CMD_DIR_WRITE,
  119. _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 12),
  120. /* del addr from (u48)a0 */
  121. CMD_ADDR_DEL = _CMDCNW(_CMD_DIR_WRITE,
  122. _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 13),
  123. /* add VLAN id in (u16)a0 */
  124. CMD_VLAN_ADD = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 14),
  125. /* del VLAN id in (u16)a0 */
  126. CMD_VLAN_DEL = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 15),
  127. /* nic_cfg in (u32)a0 */
  128. CMD_NIC_CFG = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 16),
  129. /* union vnic_rss_key in mem: (u64)a0=paddr, (u16)a1=len */
  130. CMD_RSS_KEY = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 17),
  131. /* union vnic_rss_cpu in mem: (u64)a0=paddr, (u16)a1=len */
  132. CMD_RSS_CPU = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 18),
  133. /* initiate softreset */
  134. CMD_SOFT_RESET = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 19),
  135. /* softreset status:
  136. * out: a0=0 reset complete, a0=1 reset in progress */
  137. CMD_SOFT_RESET_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 20),
  138. /* set struct vnic_devcmd_notify buffer in mem:
  139. * in:
  140. * (u64)a0=paddr to notify (set paddr=0 to unset)
  141. * (u32)a1 & 0x00000000ffffffff=sizeof(struct vnic_devcmd_notify)
  142. * (u16)a1 & 0x0000ffff00000000=intr num (-1 for no intr)
  143. * out:
  144. * (u32)a1 = effective size
  145. */
  146. CMD_NOTIFY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 21),
  147. /* UNDI API: (u64)a0=paddr to s_PXENV_UNDI_ struct,
  148. * (u8)a1=PXENV_UNDI_xxx */
  149. CMD_UNDI = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 22),
  150. /* initiate open sequence (u32)a0=flags (see CMD_OPENF_*) */
  151. CMD_OPEN = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 23),
  152. /* open status:
  153. * out: a0=0 open complete, a0=1 open in progress */
  154. CMD_OPEN_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 24),
  155. /* close vnic */
  156. CMD_CLOSE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 25),
  157. /* initialize virtual link: (u32)a0=flags (see CMD_INITF_*) */
  158. /***** Replaced by CMD_INIT *****/
  159. CMD_INIT_v1 = _CMDCNW(_CMD_DIR_READ, _CMD_VTYPE_ALL, 26),
  160. /* variant of CMD_INIT, with provisioning info
  161. * (u64)a0=paddr of vnic_devcmd_provinfo
  162. * (u32)a1=sizeof provision info */
  163. CMD_INIT_PROV_INFO = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 27),
  164. /* enable virtual link */
  165. CMD_ENABLE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28),
  166. /* enable virtual link, waiting variant. */
  167. CMD_ENABLE_WAIT = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28),
  168. /* disable virtual link */
  169. CMD_DISABLE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 29),
  170. /* stats dump sum of all vnic stats on same uplink in mem:
  171. * (u64)a0=paddr
  172. * (u16)a1=sizeof stats area */
  173. CMD_STATS_DUMP_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 30),
  174. /* init status:
  175. * out: a0=0 init complete, a0=1 init in progress
  176. * if a0=0, a1=errno */
  177. CMD_INIT_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 31),
  178. /* INT13 API: (u64)a0=paddr to vnic_int13_params struct
  179. * (u32)a1=INT13_CMD_xxx */
  180. CMD_INT13 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_FC, 32),
  181. /* logical uplink enable/disable: (u64)a0: 0/1=disable/enable */
  182. CMD_LOGICAL_UPLINK = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 33),
  183. /* undo initialize of virtual link */
  184. CMD_DEINIT = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 34),
  185. /* initialize virtual link: (u32)a0=flags (see CMD_INITF_*) */
  186. CMD_INIT = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 35),
  187. /* check fw capability of a cmd:
  188. * in: (u32)a0=cmd
  189. * out: (u32)a0=errno, 0:valid cmd, a1=supported VNIC_STF_* bits */
  190. CMD_CAPABILITY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 36),
  191. /* persistent binding info
  192. * in: (u64)a0=paddr of arg
  193. * (u32)a1=CMD_PERBI_XXX */
  194. CMD_PERBI = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_FC, 37),
  195. /* Interrupt Assert Register functionality
  196. * in: (u16)a0=interrupt number to assert
  197. */
  198. CMD_IAR = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 38),
  199. /* initiate hangreset, like softreset after hang detected */
  200. CMD_HANG_RESET = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 39),
  201. /* hangreset status:
  202. * out: a0=0 reset complete, a0=1 reset in progress */
  203. CMD_HANG_RESET_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 40),
  204. /*
  205. * Set hw ingress packet vlan rewrite mode:
  206. * in: (u32)a0=new vlan rewrite mode
  207. * out: (u32)a0=old vlan rewrite mode */
  208. CMD_IG_VLAN_REWRITE_MODE = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 41),
  209. /*
  210. * in: (u16)a0=bdf of target vnic
  211. * (u32)a1=cmd to proxy
  212. * a2-a15=args to cmd in a1
  213. * out: (u32)a0=status of proxied cmd
  214. * a1-a15=out args of proxied cmd */
  215. CMD_PROXY_BY_BDF = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 42),
  216. /*
  217. * As for BY_BDF except a0 is index of hvnlink subordinate vnic
  218. * or SR-IOV virtual vnic
  219. */
  220. CMD_PROXY_BY_INDEX = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 43),
  221. /*
  222. * For HPP toggle:
  223. * adapter-info-get
  224. * in: (u64)a0=phsical address of buffer passed in from caller.
  225. * (u16)a1=size of buffer specified in a0.
  226. * out: (u64)a0=phsical address of buffer passed in from caller.
  227. * (u16)a1=actual bytes from VIF-CONFIG-INFO TLV, or
  228. * 0 if no VIF-CONFIG-INFO TLV was ever received. */
  229. CMD_CONFIG_INFO_GET = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 44),
  230. /* INT13 API: (u64)a0=paddr to vnic_int13_params struct
  231. * (u32)a1=INT13_CMD_xxx
  232. */
  233. CMD_INT13_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 45),
  234. /* Set default vlan:
  235. * in: (u16)a0=new default vlan
  236. * (u16)a1=zero for overriding vlan with param a0,
  237. * non-zero for resetting vlan to the default
  238. * out: (u16)a0=old default vlan
  239. */
  240. CMD_SET_DEFAULT_VLAN = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 46),
  241. /* init_prov_info2:
  242. * Variant of CMD_INIT_PROV_INFO, where it will not try to enable
  243. * the vnic until CMD_ENABLE2 is issued.
  244. * (u64)a0=paddr of vnic_devcmd_provinfo
  245. * (u32)a1=sizeof provision info
  246. */
  247. CMD_INIT_PROV_INFO2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 47),
  248. /* enable2:
  249. * (u32)a0=0 ==> standby
  250. * =CMD_ENABLE2_ACTIVE ==> active
  251. */
  252. CMD_ENABLE2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 48),
  253. /*
  254. * cmd_status:
  255. * Returns the status of the specified command
  256. * Input:
  257. * a0 = command for which status is being queried.
  258. * Possible values are:
  259. * CMD_SOFT_RESET
  260. * CMD_HANG_RESET
  261. * CMD_OPEN
  262. * CMD_INIT
  263. * CMD_INIT_PROV_INFO
  264. * CMD_DEINIT
  265. * CMD_INIT_PROV_INFO2
  266. * CMD_ENABLE2
  267. * Output:
  268. * if status == STAT_ERROR
  269. * a0 = ERR_ENOTSUPPORTED - status for command in a0 is
  270. * not supported
  271. * if status == STAT_NONE
  272. * a0 = status of the devcmd specified in a0 as follows.
  273. * ERR_SUCCESS - command in a0 completed successfully
  274. * ERR_EINPROGRESS - command in a0 is still in progress
  275. */
  276. CMD_STATUS = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 49),
  277. /*
  278. * Returns interrupt coalescing timer conversion factors.
  279. * After calling this devcmd, ENIC driver can convert
  280. * interrupt coalescing timer in usec into CPU cycles as follows:
  281. *
  282. * intr_timer_cycles = intr_timer_usec * multiplier / divisor
  283. *
  284. * Interrupt coalescing timer in usecs can be obtained from
  285. * CPU cycles as follows:
  286. *
  287. * intr_timer_usec = intr_timer_cycles * divisor / multiplier
  288. *
  289. * in: none
  290. * out: (u32)a0 = multiplier
  291. * (u32)a1 = divisor
  292. * (u32)a2 = maximum timer value in usec
  293. */
  294. CMD_INTR_COAL_CONVERT = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 50),
  295. /*
  296. * Set the predefined mac address as default
  297. * in:
  298. * (u48)a0 = mac addr
  299. */
  300. CMD_SET_MAC_ADDR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 55),
  301. /* Update the provisioning info of the given VIF
  302. * (u64)a0=paddr of vnic_devcmd_provinfo
  303. * (u32)a1=sizeof provision info
  304. */
  305. CMD_PROV_INFO_UPDATE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 56),
  306. /* Initialization for the devcmd2 interface.
  307. * in: (u64) a0 = host result buffer physical address
  308. * in: (u16) a1 = number of entries in result buffer
  309. */
  310. CMD_INITIALIZE_DEVCMD2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 57),
  311. /* Add a filter.
  312. * in: (u64) a0= filter address
  313. * (u32) a1= size of filter
  314. * out: (u32) a0=filter identifier
  315. */
  316. CMD_ADD_FILTER = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 58),
  317. /* Delete a filter.
  318. * in: (u32) a0=filter identifier
  319. */
  320. CMD_DEL_FILTER = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 59),
  321. /* Enable a Queue Pair in User space NIC
  322. * in: (u32) a0=Queue Pair number
  323. * (u32) a1= command
  324. */
  325. CMD_QP_ENABLE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 60),
  326. /* Disable a Queue Pair in User space NIC
  327. * in: (u32) a0=Queue Pair number
  328. * (u32) a1= command
  329. */
  330. CMD_QP_DISABLE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 61),
  331. /* Stats dump Queue Pair in User space NIC
  332. * in: (u32) a0=Queue Pair number
  333. * (u64) a1=host buffer addr for status dump
  334. * (u32) a2=length of the buffer
  335. */
  336. CMD_QP_STATS_DUMP = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 62),
  337. /* Clear stats for Queue Pair in User space NIC
  338. * in: (u32) a0=Queue Pair number
  339. */
  340. CMD_QP_STATS_CLEAR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 63),
  341. };
  342. /* CMD_ENABLE2 flags */
  343. #define CMD_ENABLE2_STANDBY 0x0
  344. #define CMD_ENABLE2_ACTIVE 0x1
  345. /* flags for CMD_OPEN */
  346. #define CMD_OPENF_OPROM 0x1 /* open coming from option rom */
  347. /* flags for CMD_INIT */
  348. #define CMD_INITF_DEFAULT_MAC 0x1 /* init with default mac addr */
  349. /* flags for CMD_PACKET_FILTER */
  350. #define CMD_PFILTER_DIRECTED 0x01
  351. #define CMD_PFILTER_MULTICAST 0x02
  352. #define CMD_PFILTER_BROADCAST 0x04
  353. #define CMD_PFILTER_PROMISCUOUS 0x08
  354. #define CMD_PFILTER_ALL_MULTICAST 0x10
  355. /* Commands for CMD_QP_ENABLE/CM_QP_DISABLE */
  356. #define CMD_QP_RQWQ 0x0
  357. /* rewrite modes for CMD_IG_VLAN_REWRITE_MODE */
  358. #define IG_VLAN_REWRITE_MODE_DEFAULT_TRUNK 0
  359. #define IG_VLAN_REWRITE_MODE_UNTAG_DEFAULT_VLAN 1
  360. #define IG_VLAN_REWRITE_MODE_PRIORITY_TAG_DEFAULT_VLAN 2
  361. #define IG_VLAN_REWRITE_MODE_PASS_THRU 3
  362. enum vnic_devcmd_status {
  363. STAT_NONE = 0,
  364. STAT_BUSY = 1 << 0, /* cmd in progress */
  365. STAT_ERROR = 1 << 1, /* last cmd caused error (code in a0) */
  366. };
  367. enum vnic_devcmd_error {
  368. ERR_SUCCESS = 0,
  369. ERR_EINVAL = 1,
  370. ERR_EFAULT = 2,
  371. ERR_EPERM = 3,
  372. ERR_EBUSY = 4,
  373. ERR_ECMDUNKNOWN = 5,
  374. ERR_EBADSTATE = 6,
  375. ERR_ENOMEM = 7,
  376. ERR_ETIMEDOUT = 8,
  377. ERR_ELINKDOWN = 9,
  378. ERR_EMAXRES = 10,
  379. ERR_ENOTSUPPORTED = 11,
  380. ERR_EINPROGRESS = 12,
  381. ERR_MAX
  382. };
  383. /*
  384. * note: hw_version and asic_rev refer to the same thing,
  385. * but have different formats. hw_version is
  386. * a 32-byte string (e.g. "A2") and asic_rev is
  387. * a 16-bit integer (e.g. 0xA2).
  388. */
  389. struct vnic_devcmd_fw_info {
  390. char fw_version[32];
  391. char fw_build[32];
  392. char hw_version[32];
  393. char hw_serial_number[32];
  394. u16 asic_type;
  395. u16 asic_rev;
  396. };
  397. struct vnic_devcmd_notify {
  398. u32 csum; /* checksum over following words */
  399. u32 link_state; /* link up == 1 */
  400. u32 port_speed; /* effective port speed (rate limit) */
  401. u32 mtu; /* MTU */
  402. u32 msglvl; /* requested driver msg lvl */
  403. u32 uif; /* uplink interface */
  404. u32 status; /* status bits (see VNIC_STF_*) */
  405. u32 error; /* error code (see ERR_*) for first ERR */
  406. u32 link_down_cnt; /* running count of link down transitions */
  407. u32 perbi_rebuild_cnt; /* running count of perbi rebuilds */
  408. };
  409. #define VNIC_STF_FATAL_ERR 0x0001 /* fatal fw error */
  410. #define VNIC_STF_STD_PAUSE 0x0002 /* standard link-level pause on */
  411. #define VNIC_STF_PFC_PAUSE 0x0004 /* priority flow control pause on */
  412. /* all supported status flags */
  413. #define VNIC_STF_ALL (VNIC_STF_FATAL_ERR |\
  414. VNIC_STF_STD_PAUSE |\
  415. VNIC_STF_PFC_PAUSE |\
  416. 0)
  417. struct vnic_devcmd_provinfo {
  418. u8 oui[3];
  419. u8 type;
  420. u8 data[0];
  421. };
  422. /* These are used in flags field of different filters to denote
  423. * valid fields used.
  424. */
  425. #define FILTER_FIELD_VALID(fld) (1 << (fld - 1))
  426. #define FILTER_FIELDS_USNIC ( \
  427. FILTER_FIELD_VALID(1) | \
  428. FILTER_FIELD_VALID(2) | \
  429. FILTER_FIELD_VALID(3) | \
  430. FILTER_FIELD_VALID(4))
  431. #define FILTER_FIELDS_IPV4_5TUPLE ( \
  432. FILTER_FIELD_VALID(1) | \
  433. FILTER_FIELD_VALID(2) | \
  434. FILTER_FIELD_VALID(3) | \
  435. FILTER_FIELD_VALID(4) | \
  436. FILTER_FIELD_VALID(5))
  437. #define FILTER_FIELDS_MAC_VLAN ( \
  438. FILTER_FIELD_VALID(1) | \
  439. FILTER_FIELD_VALID(2))
  440. #define FILTER_FIELD_USNIC_VLAN FILTER_FIELD_VALID(1)
  441. #define FILTER_FIELD_USNIC_ETHTYPE FILTER_FIELD_VALID(2)
  442. #define FILTER_FIELD_USNIC_PROTO FILTER_FIELD_VALID(3)
  443. #define FILTER_FIELD_USNIC_ID FILTER_FIELD_VALID(4)
  444. struct filter_usnic_id {
  445. u32 flags;
  446. u16 vlan;
  447. u16 ethtype;
  448. u8 proto_version;
  449. u32 usnic_id;
  450. } __packed;
  451. #define FILTER_FIELD_5TUP_PROTO FILTER_FIELD_VALID(1)
  452. #define FILTER_FIELD_5TUP_SRC_AD FILTER_FIELD_VALID(2)
  453. #define FILTER_FIELD_5TUP_DST_AD FILTER_FIELD_VALID(3)
  454. #define FILTER_FIELD_5TUP_SRC_PT FILTER_FIELD_VALID(4)
  455. #define FILTER_FIELD_5TUP_DST_PT FILTER_FIELD_VALID(5)
  456. /* Enums for the protocol field. */
  457. enum protocol_e {
  458. PROTO_UDP = 0,
  459. PROTO_TCP = 1,
  460. };
  461. struct filter_ipv4_5tuple {
  462. u32 flags;
  463. u32 protocol;
  464. u32 src_addr;
  465. u32 dst_addr;
  466. u16 src_port;
  467. u16 dst_port;
  468. } __packed;
  469. #define FILTER_FIELD_VMQ_VLAN FILTER_FIELD_VALID(1)
  470. #define FILTER_FIELD_VMQ_MAC FILTER_FIELD_VALID(2)
  471. struct filter_mac_vlan {
  472. u32 flags;
  473. u16 vlan;
  474. u8 mac_addr[6];
  475. } __packed;
  476. /* Specifies the filter_action type. */
  477. enum {
  478. FILTER_ACTION_RQ_STEERING = 0,
  479. FILTER_ACTION_MAX
  480. };
  481. struct filter_action {
  482. u32 type;
  483. union {
  484. u32 rq_idx;
  485. } u;
  486. } __packed;
  487. /* Specifies the filter type. */
  488. enum filter_type {
  489. FILTER_USNIC_ID = 0,
  490. FILTER_IPV4_5TUPLE = 1,
  491. FILTER_MAC_VLAN = 2,
  492. FILTER_MAX
  493. };
  494. struct filter {
  495. u32 type;
  496. union {
  497. struct filter_usnic_id usnic;
  498. struct filter_ipv4_5tuple ipv4;
  499. struct filter_mac_vlan mac_vlan;
  500. } u;
  501. } __packed;
  502. enum {
  503. CLSF_TLV_FILTER = 0,
  504. CLSF_TLV_ACTION = 1,
  505. };
  506. /* Maximum size of buffer to CMD_ADD_FILTER */
  507. #define FILTER_MAX_BUF_SIZE 100
  508. struct filter_tlv {
  509. u_int32_t type;
  510. u_int32_t length;
  511. u_int32_t val[0];
  512. };
  513. enum {
  514. CLSF_ADD = 0,
  515. CLSF_DEL = 1,
  516. };
  517. /*
  518. * Writing cmd register causes STAT_BUSY to get set in status register.
  519. * When cmd completes, STAT_BUSY will be cleared.
  520. *
  521. * If cmd completed successfully STAT_ERROR will be clear
  522. * and args registers contain cmd-specific results.
  523. *
  524. * If cmd error, STAT_ERROR will be set and args[0] contains error code.
  525. *
  526. * status register is read-only. While STAT_BUSY is set,
  527. * all other register contents are read-only.
  528. */
  529. /* Make sizeof(vnic_devcmd) a power-of-2 for I/O BAR. */
  530. #define VNIC_DEVCMD_NARGS 15
  531. struct vnic_devcmd {
  532. u32 status; /* RO */
  533. u32 cmd; /* RW */
  534. u64 args[VNIC_DEVCMD_NARGS]; /* RW cmd args (little-endian) */
  535. };
  536. #define DEVCMD2_FNORESULT 0x1 /* Don't copy result to host */
  537. #define VNIC_DEVCMD2_NARGS VNIC_DEVCMD_NARGS
  538. struct vnic_devcmd2 {
  539. u16 pad;
  540. u16 flags;
  541. u32 cmd;
  542. u64 args[VNIC_DEVCMD2_NARGS];
  543. };
  544. #define VNIC_DEVCMD2_NRESULTS VNIC_DEVCMD_NARGS
  545. struct devcmd2_result {
  546. u64 results[VNIC_DEVCMD2_NRESULTS];
  547. u32 pad;
  548. u16 completed_index;
  549. u8 error;
  550. u8 color;
  551. };
  552. #define DEVCMD2_RING_SIZE 32
  553. #define DEVCMD2_DESC_SIZE 128
  554. #endif /* _VNIC_DEVCMD_H_ */