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

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