You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nxhal_nic_interface.h 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. FILE_LICENCE ( GPL2_ONLY );
  2. /*
  3. * Data types and structure for HAL - NIC interface.
  4. *
  5. */
  6. #ifndef _NXHAL_NIC_INTERFACE_H_
  7. #define _NXHAL_NIC_INTERFACE_H_
  8. /*****************************************************************************
  9. * Simple Types
  10. *****************************************************************************/
  11. typedef U32 nx_reg_addr_t;
  12. /*****************************************************************************
  13. * Root crb-based firmware commands
  14. *****************************************************************************/
  15. /* CRB Root Command
  16. A single set of crbs is used across all physical/virtual
  17. functions for capability queries, initialization, and
  18. context creation/destruction.
  19. There are 4 CRBS:
  20. Command/Response CRB
  21. Argument1 CRB
  22. Argument2 CRB
  23. Argument3 CRB
  24. Signature CRB
  25. The cmd/rsp crb is always intiated by the host via
  26. a command code and always responded by the card with
  27. a response code. The cmd and rsp codes are disjoint.
  28. The sequence of use is always CMD, RSP, CLEAR CMD.
  29. The arguments are for passing in command specific
  30. and response specific parameters/data.
  31. The signature is composed of a magic value, the
  32. pci function id, and a command sequence id:
  33. [7:0] = pci function
  34. [15:8] = version
  35. [31:16] = magic of 0xcafe
  36. The pci function allows the card to take correct
  37. action for the given particular commands.
  38. The firmware will attempt to detect
  39. an errant driver that has died while holding
  40. the root crb hardware lock. Such an error condition
  41. shows up as the cmd/rsp crb stuck in a non-clear state.
  42. Interface Sequence:
  43. Host always makes requests and firmware always responds.
  44. Note that data field is always set prior to command field.
  45. [READ] CMD/RSP CRB ARGUMENT FIELD
  46. Host grab lock
  47. Host -> CMD optional parameter
  48. FW <- (Good) RSP-OK DATA
  49. FW <- (Fail) RSP-FAIL optional failure code
  50. Host -> CLEAR
  51. Host release lock
  52. [WRITE] CMD/RSP CRB ARGUMENT FIELD
  53. Host grab lock
  54. Host -> CMD DATA
  55. FW <- (Good) RSP-OK optional write status
  56. FW <- (Write) RSP-FAIL optional failure code
  57. Host -> CLEAR
  58. Host release lock
  59. */
  60. /*****************************************************************************
  61. * CMD/RSP
  62. *****************************************************************************/
  63. #define NX_CDRP_SIGNATURE_TO_PCIFN(sign) ((sign) & 0xff)
  64. #define NX_CDRP_SIGNATURE_TO_VERSION(sign) (((sign)>>8) & 0xff)
  65. #define NX_CDRP_SIGNATURE_TO_MAGIC(sign) (((sign)>>16) & 0xffff)
  66. #define NX_CDRP_SIGNATURE_VALID(sign) \
  67. ( NX_CDRP_SIGNATURE_TO_MAGIC(sign) == 0xcafe && \
  68. NX_CDRP_SIGNATURE_TO_PCIFN(sign) < 8)
  69. #define NX_CDRP_SIGNATURE_MAKE(pcifn,version) \
  70. ( ((pcifn) & 0xff) | \
  71. (((version) & 0xff) << 8) | \
  72. (0xcafe << 16) )
  73. #define NX_CDRP_CLEAR 0x00000000
  74. #define NX_CDRP_CMD_BIT 0x80000000
  75. /* All responses must have the NX_CDRP_CMD_BIT cleared
  76. * in the crb NX_CDRP_CRB_OFFSET. */
  77. #define NX_CDRP_FORM_RSP(rsp) (rsp)
  78. #define NX_CDRP_IS_RSP(rsp) (((rsp) & NX_CDRP_CMD_BIT) == 0)
  79. #define NX_CDRP_RSP_OK 0x00000001
  80. #define NX_CDRP_RSP_FAIL 0x00000002
  81. #define NX_CDRP_RSP_TIMEOUT 0x00000003
  82. /* All commands must have the NX_CDRP_CMD_BIT set in
  83. * the crb NX_CDRP_CRB_OFFSET.
  84. * The macros below do not have it explicitly set to
  85. * allow their use in lookup tables */
  86. #define NX_CDRP_FORM_CMD(cmd) (NX_CDRP_CMD_BIT | (cmd))
  87. #define NX_CDRP_IS_CMD(cmd) (((cmd) & NX_CDRP_CMD_BIT) != 0)
  88. /* [CMD] Capability Vector [RSP] Capability Vector */
  89. #define NX_CDRP_CMD_SUBMIT_CAPABILITIES 0x00000001
  90. /* [CMD] - [RSP] Query Value */
  91. #define NX_CDRP_CMD_READ_MAX_RDS_PER_CTX 0x00000002
  92. /* [CMD] - [RSP] Query Value */
  93. #define NX_CDRP_CMD_READ_MAX_SDS_PER_CTX 0x00000003
  94. /* [CMD] - [RSP] Query Value */
  95. #define NX_CDRP_CMD_READ_MAX_RULES_PER_CTX 0x00000004
  96. /* [CMD] - [RSP] Query Value */
  97. #define NX_CDRP_CMD_READ_MAX_RX_CTX 0x00000005
  98. /* [CMD] - [RSP] Query Value */
  99. #define NX_CDRP_CMD_READ_MAX_TX_CTX 0x00000006
  100. /* [CMD] Rx Config DMA Addr [RSP] rcode */
  101. #define NX_CDRP_CMD_CREATE_RX_CTX 0x00000007
  102. /* [CMD] Rx Context Handle, Reset Kind [RSP] rcode */
  103. #define NX_CDRP_CMD_DESTROY_RX_CTX 0x00000008
  104. /* [CMD] Tx Config DMA Addr [RSP] rcode */
  105. #define NX_CDRP_CMD_CREATE_TX_CTX 0x00000009
  106. /* [CMD] Tx Context Handle, Reset Kind [RSP] rcode */
  107. #define NX_CDRP_CMD_DESTROY_TX_CTX 0x0000000a
  108. /* [CMD] Stat setup dma addr - [RSP] Handle, rcode */
  109. #define NX_CDRP_CMD_SETUP_STATISTICS 0x0000000e
  110. /* [CMD] Handle - [RSP] rcode */
  111. #define NX_CDRP_CMD_GET_STATISTICS 0x0000000f
  112. /* [CMD] Handle - [RSP] rcode */
  113. #define NX_CDRP_CMD_DELETE_STATISTICS 0x00000010
  114. #define NX_CDRP_CMD_MAX 0x00000011
  115. /*****************************************************************************
  116. * Capabilities
  117. *****************************************************************************/
  118. #define NX_CAP_BIT(class, bit) (1 << bit)
  119. /* Class 0 (i.e. ARGS 1)
  120. */
  121. #define NX_CAP0_LEGACY_CONTEXT NX_CAP_BIT(0, 0)
  122. #define NX_CAP0_MULTI_CONTEXT NX_CAP_BIT(0, 1)
  123. #define NX_CAP0_LEGACY_MN NX_CAP_BIT(0, 2)
  124. #define NX_CAP0_LEGACY_MS NX_CAP_BIT(0, 3)
  125. #define NX_CAP0_CUT_THROUGH NX_CAP_BIT(0, 4)
  126. #define NX_CAP0_LRO NX_CAP_BIT(0, 5)
  127. #define NX_CAP0_LSO NX_CAP_BIT(0, 6)
  128. /* Class 1 (i.e. ARGS 2)
  129. */
  130. #define NX_CAP1_NIC NX_CAP_BIT(1, 0)
  131. #define NX_CAP1_PXE NX_CAP_BIT(1, 1)
  132. #define NX_CAP1_CHIMNEY NX_CAP_BIT(1, 2)
  133. #define NX_CAP1_LSA NX_CAP_BIT(1, 3)
  134. #define NX_CAP1_RDMA NX_CAP_BIT(1, 4)
  135. #define NX_CAP1_ISCSI NX_CAP_BIT(1, 5)
  136. #define NX_CAP1_FCOE NX_CAP_BIT(1, 6)
  137. /* Class 2 (i.e. ARGS 3)
  138. */
  139. /*****************************************************************************
  140. * Rules
  141. *****************************************************************************/
  142. typedef U32 nx_rx_rule_type_t;
  143. #define NX_RX_RULETYPE_DEFAULT 0
  144. #define NX_RX_RULETYPE_MAC 1
  145. #define NX_RX_RULETYPE_MAC_VLAN 2
  146. #define NX_RX_RULETYPE_MAC_RSS 3
  147. #define NX_RX_RULETYPE_MAC_VLAN_RSS 4
  148. #define NX_RX_RULETYPE_MAX 5
  149. typedef U32 nx_rx_rule_cmd_t;
  150. #define NX_RX_RULECMD_ADD 0
  151. #define NX_RX_RULECMD_REMOVE 1
  152. #define NX_RX_RULECMD_MAX 2
  153. typedef struct nx_rx_rule_arg_s {
  154. union {
  155. struct {
  156. char mac[6];
  157. } m;
  158. struct {
  159. char mac[6];
  160. char vlan;
  161. } mv;
  162. struct {
  163. char mac[6];
  164. } mr;
  165. struct {
  166. char mac[6];
  167. char vlan;
  168. } mvr;
  169. };
  170. /* will be union of all the different args for rules */
  171. U64 data;
  172. } nx_rx_rule_arg_t;
  173. typedef struct nx_rx_rule_s {
  174. U32 id;
  175. U32 active;
  176. nx_rx_rule_arg_t arg;
  177. nx_rx_rule_type_t type;
  178. } nx_rx_rule_t;
  179. /* MSG - REQUIRES TX CONTEXT */
  180. /* The rules can be added/deleted from both the
  181. * host and card sides so rq/rsp are similar.
  182. */
  183. typedef struct nx_hostmsg_rx_rule_s {
  184. nx_rx_rule_cmd_t cmd;
  185. nx_rx_rule_t rule;
  186. } nx_hostmsg_rx_rule_t;
  187. typedef struct nx_cardmsg_rx_rule_s {
  188. nx_rcode_t rcode;
  189. nx_rx_rule_cmd_t cmd;
  190. nx_rx_rule_t rule;
  191. } nx_cardmsg_rx_rule_t;
  192. /*****************************************************************************
  193. * Common to Rx/Tx contexts
  194. *****************************************************************************/
  195. /*
  196. * Context states
  197. */
  198. typedef U32 nx_host_ctx_state_t;
  199. #define NX_HOST_CTX_STATE_FREED 0 /* Invalid state */
  200. #define NX_HOST_CTX_STATE_ALLOCATED 1 /* Not committed */
  201. /* The following states imply FW is aware of context */
  202. #define NX_HOST_CTX_STATE_ACTIVE 2
  203. #define NX_HOST_CTX_STATE_DISABLED 3
  204. #define NX_HOST_CTX_STATE_QUIESCED 4
  205. #define NX_HOST_CTX_STATE_MAX 5
  206. /*
  207. * Interrupt mask crb use must be set identically on the Tx
  208. * and Rx context configs across a pci function
  209. */
  210. /* Rx and Tx have unique interrupt/crb */
  211. #define NX_HOST_INT_CRB_MODE_UNIQUE 0
  212. /* Rx and Tx share a common interrupt/crb */
  213. #define NX_HOST_INT_CRB_MODE_SHARED 1 /* <= LEGACY */
  214. /* Rx does not use a crb */
  215. #define NX_HOST_INT_CRB_MODE_NORX 2
  216. /* Tx does not use a crb */
  217. #define NX_HOST_INT_CRB_MODE_NOTX 3
  218. /* Neither Rx nor Tx use a crb */
  219. #define NX_HOST_INT_CRB_MODE_NORXTX 4
  220. /*
  221. * Destroy Rx/Tx
  222. */
  223. #define NX_DESTROY_CTX_RESET 0
  224. #define NX_DESTROY_CTX_D3_RESET 1
  225. #define NX_DESTROY_CTX_MAX 2
  226. /*****************************************************************************
  227. * Tx
  228. *****************************************************************************/
  229. /*
  230. * Components of the host-request for Tx context creation.
  231. * CRB - DOES NOT REQUIRE Rx/TX CONTEXT
  232. */
  233. typedef struct nx_hostrq_cds_ring_s {
  234. U64 host_phys_addr; /* Ring base addr */
  235. U32 ring_size; /* Ring entries */
  236. U32 rsvd; /* Padding */
  237. } nx_hostrq_cds_ring_t;
  238. typedef struct nx_hostrq_tx_ctx_s {
  239. U64 host_rsp_dma_addr; /* Response dma'd here */
  240. U64 cmd_cons_dma_addr; /* */
  241. U64 dummy_dma_addr; /* */
  242. U32 capabilities[4]; /* Flag bit vector */
  243. U32 host_int_crb_mode; /* Interrupt crb usage */
  244. U32 rsvd1; /* Padding */
  245. U16 rsvd2; /* Padding */
  246. U16 interrupt_ctl;
  247. U16 msi_index;
  248. U16 rsvd3; /* Padding */
  249. nx_hostrq_cds_ring_t cds_ring; /* Desc of cds ring */
  250. U8 reserved[128]; /* future expansion */
  251. } nx_hostrq_tx_ctx_t;
  252. typedef struct nx_cardrsp_cds_ring_s {
  253. U32 host_producer_crb; /* Crb to use */
  254. U32 interrupt_crb; /* Crb to use */
  255. } nx_cardrsp_cds_ring_t;
  256. typedef struct nx_cardrsp_tx_ctx_s {
  257. U32 host_ctx_state; /* Starting state */
  258. U16 context_id; /* Handle for context */
  259. U8 phys_port; /* Physical id of port */
  260. U8 virt_port; /* Virtual/Logical id of port */
  261. nx_cardrsp_cds_ring_t cds_ring; /* Card cds settings */
  262. U8 reserved[128]; /* future expansion */
  263. } nx_cardrsp_tx_ctx_t;
  264. #define SIZEOF_HOSTRQ_TX(HOSTRQ_TX) \
  265. ( sizeof(HOSTRQ_TX))
  266. #define SIZEOF_CARDRSP_TX(CARDRSP_TX) \
  267. ( sizeof(CARDRSP_TX))
  268. /*****************************************************************************
  269. * Rx
  270. *****************************************************************************/
  271. /*
  272. * RDS ring mapping to producer crbs
  273. */
  274. /* Each ring has a unique crb */
  275. #define NX_HOST_RDS_CRB_MODE_UNIQUE 0 /* <= LEGACY */
  276. /* All configured RDS Rings share common crb:
  277. 1 Ring - same as unique
  278. 2 Rings - 16, 16
  279. 3 Rings - 10, 10, 10 */
  280. #define NX_HOST_RDS_CRB_MODE_SHARED 1
  281. /* Bit usage is specified per-ring using the
  282. ring's size. Sum of bit lengths must be <= 32.
  283. Packing is [Ring N] ... [Ring 1][Ring 0] */
  284. #define NX_HOST_RDS_CRB_MODE_CUSTOM 2
  285. #define NX_HOST_RDS_CRB_MODE_MAX 3
  286. /*
  287. * RDS Ting Types
  288. */
  289. #define NX_RDS_RING_TYPE_NORMAL 0
  290. #define NX_RDS_RING_TYPE_JUMBO 1
  291. #define NX_RDS_RING_TYPE_LRO 2
  292. #define NX_RDS_RING_TYPE_MAX 3
  293. /*
  294. * Components of the host-request for Rx context creation.
  295. * CRB - DOES NOT REQUIRE Rx/TX CONTEXT
  296. */
  297. typedef struct nx_hostrq_sds_ring_s {
  298. U64 host_phys_addr; /* Ring base addr */
  299. U32 ring_size; /* Ring entries */
  300. U16 msi_index;
  301. U16 rsvd; /* Padding */
  302. } nx_hostrq_sds_ring_t;
  303. typedef struct nx_hostrq_rds_ring_s {
  304. U64 host_phys_addr; /* Ring base addr */
  305. U64 buff_size; /* Packet buffer size */
  306. U32 ring_size; /* Ring entries */
  307. U32 ring_kind; /* Class of ring */
  308. } nx_hostrq_rds_ring_t;
  309. typedef struct nx_hostrq_rx_ctx_s {
  310. U64 host_rsp_dma_addr; /* Response dma'd here */
  311. U32 capabilities[4]; /* Flag bit vector */
  312. U32 host_int_crb_mode; /* Interrupt crb usage */
  313. U32 host_rds_crb_mode; /* RDS crb usage */
  314. /* These ring offsets are relative to data[0] below */
  315. U32 rds_ring_offset; /* Offset to RDS config */
  316. U32 sds_ring_offset; /* Offset to SDS config */
  317. U16 num_rds_rings; /* Count of RDS rings */
  318. U16 num_sds_rings; /* Count of SDS rings */
  319. U16 rsvd1; /* Padding */
  320. U16 rsvd2; /* Padding */
  321. U8 reserved[128]; /* reserve space for future expansion*/
  322. /* MUST BE 64-bit aligned.
  323. The following is packed:
  324. - N hostrq_rds_rings
  325. - N hostrq_sds_rings */
  326. char data[0];
  327. } nx_hostrq_rx_ctx_t;
  328. typedef struct nx_cardrsp_rds_ring_s {
  329. U32 host_producer_crb; /* Crb to use */
  330. U32 rsvd1; /* Padding */
  331. } nx_cardrsp_rds_ring_t;
  332. typedef struct nx_cardrsp_sds_ring_s {
  333. U32 host_consumer_crb; /* Crb to use */
  334. U32 interrupt_crb; /* Crb to use */
  335. } nx_cardrsp_sds_ring_t;
  336. typedef struct nx_cardrsp_rx_ctx_s {
  337. /* These ring offsets are relative to data[0] below */
  338. U32 rds_ring_offset; /* Offset to RDS config */
  339. U32 sds_ring_offset; /* Offset to SDS config */
  340. U32 host_ctx_state; /* Starting State */
  341. U32 num_fn_per_port; /* How many PCI fn share the port */
  342. U16 num_rds_rings; /* Count of RDS rings */
  343. U16 num_sds_rings; /* Count of SDS rings */
  344. U16 context_id; /* Handle for context */
  345. U8 phys_port; /* Physical id of port */
  346. U8 virt_port; /* Virtual/Logical id of port */
  347. U8 reserved[128]; /* save space for future expansion */
  348. /* MUST BE 64-bit aligned.
  349. The following is packed:
  350. - N cardrsp_rds_rings
  351. - N cardrs_sds_rings */
  352. char data[0];
  353. } nx_cardrsp_rx_ctx_t;
  354. #define SIZEOF_HOSTRQ_RX(HOSTRQ_RX, rds_rings, sds_rings) \
  355. ( sizeof(HOSTRQ_RX) + \
  356. (rds_rings)*(sizeof (nx_hostrq_rds_ring_t)) + \
  357. (sds_rings)*(sizeof (nx_hostrq_sds_ring_t)) )
  358. #define SIZEOF_CARDRSP_RX(CARDRSP_RX, rds_rings, sds_rings) \
  359. ( sizeof(CARDRSP_RX) + \
  360. (rds_rings)*(sizeof (nx_cardrsp_rds_ring_t)) + \
  361. (sds_rings)*(sizeof (nx_cardrsp_sds_ring_t)) )
  362. /*****************************************************************************
  363. * Statistics
  364. *****************************************************************************/
  365. /*
  366. * The model of statistics update to use
  367. */
  368. #define NX_STATISTICS_MODE_INVALID 0
  369. /* Permanent setup; Updates are only sent on explicit request
  370. (NX_CDRP_CMD_GET_STATISTICS) */
  371. #define NX_STATISTICS_MODE_PULL 1
  372. /* Permanent setup; Updates are sent automatically and on
  373. explicit request (NX_CDRP_CMD_GET_STATISTICS) */
  374. #define NX_STATISTICS_MODE_PUSH 2
  375. /* One time stat update. */
  376. #define NX_STATISTICS_MODE_SINGLE_SHOT 3
  377. #define NX_STATISTICS_MODE_MAX 4
  378. /*
  379. * What set of stats
  380. */
  381. #define NX_STATISTICS_TYPE_INVALID 0
  382. #define NX_STATISTICS_TYPE_NIC_RX_CORE 1
  383. #define NX_STATISTICS_TYPE_NIC_TX_CORE 2
  384. #define NX_STATISTICS_TYPE_NIC_RX_ALL 3
  385. #define NX_STATISTICS_TYPE_NIC_TX_ALL 4
  386. #define NX_STATISTICS_TYPE_MAX 5
  387. /*
  388. * Request to setup statistics gathering.
  389. * CRB - DOES NOT REQUIRE Rx/TX CONTEXT
  390. */
  391. typedef struct nx_hostrq_stat_setup_s {
  392. U64 host_stat_buffer; /* Where to dma stats */
  393. U32 host_stat_size; /* Size of stat buffer */
  394. U16 context_id; /* Which context */
  395. U16 stat_type; /* What class of stats */
  396. U16 stat_mode; /* When to update */
  397. U16 stat_interval; /* Frequency of update */
  398. } nx_hostrq_stat_setup_t;
  399. #endif /* _NXHAL_NIC_INTERFACE_H_ */