vnic_devcmd.h 11 KB

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