mana.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  1. /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
  2. /* Copyright (c) 2021, Microsoft Corporation. */
  3. #ifndef _MANA_H
  4. #define _MANA_H
  5. #include <net/xdp.h>
  6. #include "gdma.h"
  7. #include "hw_channel.h"
  8. /* Microsoft Azure Network Adapter (MANA)'s definitions
  9. *
  10. * Structures labeled with "HW DATA" are exchanged with the hardware. All of
  11. * them are naturally aligned and hence don't need __packed.
  12. */
  13. /* MANA protocol version */
  14. #define MANA_MAJOR_VERSION 0
  15. #define MANA_MINOR_VERSION 1
  16. #define MANA_MICRO_VERSION 1
  17. typedef u64 mana_handle_t;
  18. #define INVALID_MANA_HANDLE ((mana_handle_t)-1)
  19. enum TRI_STATE {
  20. TRI_STATE_UNKNOWN = -1,
  21. TRI_STATE_FALSE = 0,
  22. TRI_STATE_TRUE = 1
  23. };
  24. /* Number of entries for hardware indirection table must be in power of 2 */
  25. #define MANA_INDIRECT_TABLE_MAX_SIZE 512
  26. #define MANA_INDIRECT_TABLE_DEF_SIZE 64
  27. /* The Toeplitz hash key's length in bytes: should be multiple of 8 */
  28. #define MANA_HASH_KEY_SIZE 40
  29. #define COMP_ENTRY_SIZE 64
  30. /* This Max value for RX buffers is derived from __alloc_page()'s max page
  31. * allocation calculation. It allows maximum 2^(MAX_ORDER -1) pages. RX buffer
  32. * size beyond this value gets rejected by __alloc_page() call.
  33. */
  34. #define MAX_RX_BUFFERS_PER_QUEUE 8192
  35. #define DEF_RX_BUFFERS_PER_QUEUE 512
  36. #define MIN_RX_BUFFERS_PER_QUEUE 128
  37. /* This max value for TX buffers is derived as the maximum allocatable
  38. * pages supported on host per guest through testing. TX buffer size beyond
  39. * this value is rejected by the hardware.
  40. */
  41. #define MAX_TX_BUFFERS_PER_QUEUE 16384
  42. #define DEF_TX_BUFFERS_PER_QUEUE 256
  43. #define MIN_TX_BUFFERS_PER_QUEUE 128
  44. #define EQ_SIZE (8 * MANA_PAGE_SIZE)
  45. #define LOG2_EQ_THROTTLE 3
  46. #define MAX_PORTS_IN_MANA_DEV 256
  47. /* Update this count whenever the respective structures are changed */
  48. #define MANA_STATS_RX_COUNT 5
  49. #define MANA_STATS_TX_COUNT 11
  50. struct mana_stats_rx {
  51. u64 packets;
  52. u64 bytes;
  53. u64 xdp_drop;
  54. u64 xdp_tx;
  55. u64 xdp_redirect;
  56. struct u64_stats_sync syncp;
  57. };
  58. struct mana_stats_tx {
  59. u64 packets;
  60. u64 bytes;
  61. u64 xdp_xmit;
  62. u64 tso_packets;
  63. u64 tso_bytes;
  64. u64 tso_inner_packets;
  65. u64 tso_inner_bytes;
  66. u64 short_pkt_fmt;
  67. u64 long_pkt_fmt;
  68. u64 csum_partial;
  69. u64 mana_map_err;
  70. struct u64_stats_sync syncp;
  71. };
  72. struct mana_txq {
  73. struct gdma_queue *gdma_sq;
  74. union {
  75. u32 gdma_txq_id;
  76. struct {
  77. u32 reserved1 : 10;
  78. u32 vsq_frame : 14;
  79. u32 reserved2 : 8;
  80. };
  81. };
  82. u16 vp_offset;
  83. struct net_device *ndev;
  84. /* The SKBs are sent to the HW and we are waiting for the CQEs. */
  85. struct sk_buff_head pending_skbs;
  86. struct netdev_queue *net_txq;
  87. atomic_t pending_sends;
  88. bool napi_initialized;
  89. struct mana_stats_tx stats;
  90. };
  91. /* skb data and frags dma mappings */
  92. struct mana_skb_head {
  93. /* GSO pkts may have 2 SGEs for the linear part*/
  94. dma_addr_t dma_handle[MAX_SKB_FRAGS + 2];
  95. u32 size[MAX_SKB_FRAGS + 2];
  96. };
  97. #define MANA_HEADROOM sizeof(struct mana_skb_head)
  98. enum mana_tx_pkt_format {
  99. MANA_SHORT_PKT_FMT = 0,
  100. MANA_LONG_PKT_FMT = 1,
  101. };
  102. struct mana_tx_short_oob {
  103. u32 pkt_fmt : 2;
  104. u32 is_outer_ipv4 : 1;
  105. u32 is_outer_ipv6 : 1;
  106. u32 comp_iphdr_csum : 1;
  107. u32 comp_tcp_csum : 1;
  108. u32 comp_udp_csum : 1;
  109. u32 supress_txcqe_gen : 1;
  110. u32 vcq_num : 24;
  111. u32 trans_off : 10; /* Transport header offset */
  112. u32 vsq_frame : 14;
  113. u32 short_vp_offset : 8;
  114. }; /* HW DATA */
  115. struct mana_tx_long_oob {
  116. u32 is_encap : 1;
  117. u32 inner_is_ipv6 : 1;
  118. u32 inner_tcp_opt : 1;
  119. u32 inject_vlan_pri_tag : 1;
  120. u32 reserved1 : 12;
  121. u32 pcp : 3; /* 802.1Q */
  122. u32 dei : 1; /* 802.1Q */
  123. u32 vlan_id : 12; /* 802.1Q */
  124. u32 inner_frame_offset : 10;
  125. u32 inner_ip_rel_offset : 6;
  126. u32 long_vp_offset : 12;
  127. u32 reserved2 : 4;
  128. u32 reserved3;
  129. u32 reserved4;
  130. }; /* HW DATA */
  131. struct mana_tx_oob {
  132. struct mana_tx_short_oob s_oob;
  133. struct mana_tx_long_oob l_oob;
  134. }; /* HW DATA */
  135. enum mana_cq_type {
  136. MANA_CQ_TYPE_RX,
  137. MANA_CQ_TYPE_TX,
  138. };
  139. enum mana_cqe_type {
  140. CQE_INVALID = 0,
  141. CQE_RX_OKAY = 1,
  142. CQE_RX_COALESCED_4 = 2,
  143. CQE_RX_OBJECT_FENCE = 3,
  144. CQE_RX_TRUNCATED = 4,
  145. CQE_TX_OKAY = 32,
  146. CQE_TX_SA_DROP = 33,
  147. CQE_TX_MTU_DROP = 34,
  148. CQE_TX_INVALID_OOB = 35,
  149. CQE_TX_INVALID_ETH_TYPE = 36,
  150. CQE_TX_HDR_PROCESSING_ERROR = 37,
  151. CQE_TX_VF_DISABLED = 38,
  152. CQE_TX_VPORT_IDX_OUT_OF_RANGE = 39,
  153. CQE_TX_VPORT_DISABLED = 40,
  154. CQE_TX_VLAN_TAGGING_VIOLATION = 41,
  155. };
  156. #define MANA_CQE_COMPLETION 1
  157. struct mana_cqe_header {
  158. u32 cqe_type : 6;
  159. u32 client_type : 2;
  160. u32 vendor_err : 24;
  161. }; /* HW DATA */
  162. /* NDIS HASH Types */
  163. #define NDIS_HASH_IPV4 BIT(0)
  164. #define NDIS_HASH_TCP_IPV4 BIT(1)
  165. #define NDIS_HASH_UDP_IPV4 BIT(2)
  166. #define NDIS_HASH_IPV6 BIT(3)
  167. #define NDIS_HASH_TCP_IPV6 BIT(4)
  168. #define NDIS_HASH_UDP_IPV6 BIT(5)
  169. #define NDIS_HASH_IPV6_EX BIT(6)
  170. #define NDIS_HASH_TCP_IPV6_EX BIT(7)
  171. #define NDIS_HASH_UDP_IPV6_EX BIT(8)
  172. #define MANA_HASH_L3 (NDIS_HASH_IPV4 | NDIS_HASH_IPV6 | NDIS_HASH_IPV6_EX)
  173. #define MANA_HASH_L4 \
  174. (NDIS_HASH_TCP_IPV4 | NDIS_HASH_UDP_IPV4 | NDIS_HASH_TCP_IPV6 | \
  175. NDIS_HASH_UDP_IPV6 | NDIS_HASH_TCP_IPV6_EX | NDIS_HASH_UDP_IPV6_EX)
  176. struct mana_rxcomp_perpkt_info {
  177. u32 pkt_len : 16;
  178. u32 reserved1 : 16;
  179. u32 reserved2;
  180. u32 pkt_hash;
  181. }; /* HW DATA */
  182. #define MANA_RXCOMP_OOB_NUM_PPI 4
  183. /* Receive completion OOB */
  184. struct mana_rxcomp_oob {
  185. struct mana_cqe_header cqe_hdr;
  186. u32 rx_vlan_id : 12;
  187. u32 rx_vlantag_present : 1;
  188. u32 rx_outer_iphdr_csum_succeed : 1;
  189. u32 rx_outer_iphdr_csum_fail : 1;
  190. u32 reserved1 : 1;
  191. u32 rx_hashtype : 9;
  192. u32 rx_iphdr_csum_succeed : 1;
  193. u32 rx_iphdr_csum_fail : 1;
  194. u32 rx_tcp_csum_succeed : 1;
  195. u32 rx_tcp_csum_fail : 1;
  196. u32 rx_udp_csum_succeed : 1;
  197. u32 rx_udp_csum_fail : 1;
  198. u32 reserved2 : 1;
  199. struct mana_rxcomp_perpkt_info ppi[MANA_RXCOMP_OOB_NUM_PPI];
  200. u32 rx_wqe_offset;
  201. }; /* HW DATA */
  202. struct mana_tx_comp_oob {
  203. struct mana_cqe_header cqe_hdr;
  204. u32 tx_data_offset;
  205. u32 tx_sgl_offset : 5;
  206. u32 tx_wqe_offset : 27;
  207. u32 reserved[12];
  208. }; /* HW DATA */
  209. struct mana_rxq;
  210. #define CQE_POLLING_BUFFER 512
  211. struct mana_cq {
  212. struct gdma_queue *gdma_cq;
  213. /* Cache the CQ id (used to verify if each CQE comes to the right CQ. */
  214. u32 gdma_id;
  215. /* Type of the CQ: TX or RX */
  216. enum mana_cq_type type;
  217. /* Pointer to the mana_rxq that is pushing RX CQEs to the queue.
  218. * Only and must be non-NULL if type is MANA_CQ_TYPE_RX.
  219. */
  220. struct mana_rxq *rxq;
  221. /* Pointer to the mana_txq that is pushing TX CQEs to the queue.
  222. * Only and must be non-NULL if type is MANA_CQ_TYPE_TX.
  223. */
  224. struct mana_txq *txq;
  225. /* Buffer which the CQ handler can copy the CQE's into. */
  226. struct gdma_comp gdma_comp_buf[CQE_POLLING_BUFFER];
  227. /* NAPI data */
  228. struct napi_struct napi;
  229. int work_done;
  230. int work_done_since_doorbell;
  231. int budget;
  232. };
  233. struct mana_recv_buf_oob {
  234. /* A valid GDMA work request representing the data buffer. */
  235. struct gdma_wqe_request wqe_req;
  236. void *buf_va;
  237. bool from_pool; /* allocated from a page pool */
  238. /* SGL of the buffer going to be sent as part of the work request. */
  239. u32 num_sge;
  240. struct gdma_sge sgl[MAX_RX_WQE_SGL_ENTRIES];
  241. /* Required to store the result of mana_gd_post_work_request.
  242. * gdma_posted_wqe_info.wqe_size_in_bu is required for progressing the
  243. * work queue when the WQE is consumed.
  244. */
  245. struct gdma_posted_wqe_info wqe_inf;
  246. };
  247. #define MANA_RXBUF_PAD (SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) \
  248. + ETH_HLEN)
  249. #define MANA_XDP_MTU_MAX (PAGE_SIZE - MANA_RXBUF_PAD - XDP_PACKET_HEADROOM)
  250. struct mana_rxq {
  251. struct gdma_queue *gdma_rq;
  252. /* Cache the gdma receive queue id */
  253. u32 gdma_id;
  254. /* Index of RQ in the vPort, not gdma receive queue id */
  255. u32 rxq_idx;
  256. u32 datasize;
  257. u32 alloc_size;
  258. u32 headroom;
  259. mana_handle_t rxobj;
  260. struct mana_cq rx_cq;
  261. struct completion fence_event;
  262. struct net_device *ndev;
  263. /* Total number of receive buffers to be allocated */
  264. u32 num_rx_buf;
  265. u32 buf_index;
  266. struct mana_stats_rx stats;
  267. struct bpf_prog __rcu *bpf_prog;
  268. struct xdp_rxq_info xdp_rxq;
  269. void *xdp_save_va; /* for reusing */
  270. bool xdp_flush;
  271. int xdp_rc; /* XDP redirect return code */
  272. struct page_pool *page_pool;
  273. /* MUST BE THE LAST MEMBER:
  274. * Each receive buffer has an associated mana_recv_buf_oob.
  275. */
  276. struct mana_recv_buf_oob rx_oobs[] __counted_by(num_rx_buf);
  277. };
  278. struct mana_tx_qp {
  279. struct mana_txq txq;
  280. struct mana_cq tx_cq;
  281. mana_handle_t tx_object;
  282. };
  283. struct mana_ethtool_stats {
  284. u64 stop_queue;
  285. u64 wake_queue;
  286. u64 hc_rx_discards_no_wqe;
  287. u64 hc_rx_err_vport_disabled;
  288. u64 hc_rx_bytes;
  289. u64 hc_rx_ucast_pkts;
  290. u64 hc_rx_ucast_bytes;
  291. u64 hc_rx_bcast_pkts;
  292. u64 hc_rx_bcast_bytes;
  293. u64 hc_rx_mcast_pkts;
  294. u64 hc_rx_mcast_bytes;
  295. u64 hc_tx_err_gf_disabled;
  296. u64 hc_tx_err_vport_disabled;
  297. u64 hc_tx_err_inval_vportoffset_pkt;
  298. u64 hc_tx_err_vlan_enforcement;
  299. u64 hc_tx_err_eth_type_enforcement;
  300. u64 hc_tx_err_sa_enforcement;
  301. u64 hc_tx_err_sqpdid_enforcement;
  302. u64 hc_tx_err_cqpdid_enforcement;
  303. u64 hc_tx_err_mtu_violation;
  304. u64 hc_tx_err_inval_oob;
  305. u64 hc_tx_bytes;
  306. u64 hc_tx_ucast_pkts;
  307. u64 hc_tx_ucast_bytes;
  308. u64 hc_tx_bcast_pkts;
  309. u64 hc_tx_bcast_bytes;
  310. u64 hc_tx_mcast_pkts;
  311. u64 hc_tx_mcast_bytes;
  312. u64 hc_tx_err_gdma;
  313. u64 tx_cqe_err;
  314. u64 tx_cqe_unknown_type;
  315. u64 rx_coalesced_err;
  316. u64 rx_cqe_unknown_type;
  317. };
  318. struct mana_context {
  319. struct gdma_dev *gdma_dev;
  320. u16 num_ports;
  321. struct mana_eq *eqs;
  322. struct net_device *ports[MAX_PORTS_IN_MANA_DEV];
  323. };
  324. struct mana_port_context {
  325. struct mana_context *ac;
  326. struct net_device *ndev;
  327. u8 mac_addr[ETH_ALEN];
  328. enum TRI_STATE rss_state;
  329. mana_handle_t default_rxobj;
  330. bool tx_shortform_allowed;
  331. u16 tx_vp_offset;
  332. struct mana_tx_qp *tx_qp;
  333. /* Indirection Table for RX & TX. The values are queue indexes */
  334. u32 *indir_table;
  335. u32 indir_table_sz;
  336. /* Indirection table containing RxObject Handles */
  337. mana_handle_t *rxobj_table;
  338. /* Hash key used by the NIC */
  339. u8 hashkey[MANA_HASH_KEY_SIZE];
  340. /* This points to an array of num_queues of RQ pointers. */
  341. struct mana_rxq **rxqs;
  342. /* pre-allocated rx buffer array */
  343. void **rxbufs_pre;
  344. dma_addr_t *das_pre;
  345. int rxbpre_total;
  346. u32 rxbpre_datasize;
  347. u32 rxbpre_alloc_size;
  348. u32 rxbpre_headroom;
  349. struct bpf_prog *bpf_prog;
  350. /* Create num_queues EQs, SQs, SQ-CQs, RQs and RQ-CQs, respectively. */
  351. unsigned int max_queues;
  352. unsigned int num_queues;
  353. unsigned int rx_queue_size;
  354. unsigned int tx_queue_size;
  355. mana_handle_t port_handle;
  356. mana_handle_t pf_filter_handle;
  357. /* Mutex for sharing access to vport_use_count */
  358. struct mutex vport_mutex;
  359. int vport_use_count;
  360. u16 port_idx;
  361. bool port_is_up;
  362. bool port_st_save; /* Saved port state */
  363. struct mana_ethtool_stats eth_stats;
  364. };
  365. netdev_tx_t mana_start_xmit(struct sk_buff *skb, struct net_device *ndev);
  366. int mana_config_rss(struct mana_port_context *ac, enum TRI_STATE rx,
  367. bool update_hash, bool update_tab);
  368. int mana_alloc_queues(struct net_device *ndev);
  369. int mana_attach(struct net_device *ndev);
  370. int mana_detach(struct net_device *ndev, bool from_close);
  371. int mana_probe(struct gdma_dev *gd, bool resuming);
  372. void mana_remove(struct gdma_dev *gd, bool suspending);
  373. void mana_xdp_tx(struct sk_buff *skb, struct net_device *ndev);
  374. int mana_xdp_xmit(struct net_device *ndev, int n, struct xdp_frame **frames,
  375. u32 flags);
  376. u32 mana_run_xdp(struct net_device *ndev, struct mana_rxq *rxq,
  377. struct xdp_buff *xdp, void *buf_va, uint pkt_len);
  378. struct bpf_prog *mana_xdp_get(struct mana_port_context *apc);
  379. void mana_chn_setxdp(struct mana_port_context *apc, struct bpf_prog *prog);
  380. int mana_bpf(struct net_device *ndev, struct netdev_bpf *bpf);
  381. void mana_query_gf_stats(struct mana_port_context *apc);
  382. int mana_pre_alloc_rxbufs(struct mana_port_context *apc, int mtu, int num_queues);
  383. void mana_pre_dealloc_rxbufs(struct mana_port_context *apc);
  384. extern const struct ethtool_ops mana_ethtool_ops;
  385. /* A CQ can be created not associated with any EQ */
  386. #define GDMA_CQ_NO_EQ 0xffff
  387. struct mana_obj_spec {
  388. u32 queue_index;
  389. u64 gdma_region;
  390. u32 queue_size;
  391. u32 attached_eq;
  392. u32 modr_ctx_id;
  393. };
  394. enum mana_command_code {
  395. MANA_QUERY_DEV_CONFIG = 0x20001,
  396. MANA_QUERY_GF_STAT = 0x20002,
  397. MANA_CONFIG_VPORT_TX = 0x20003,
  398. MANA_CREATE_WQ_OBJ = 0x20004,
  399. MANA_DESTROY_WQ_OBJ = 0x20005,
  400. MANA_FENCE_RQ = 0x20006,
  401. MANA_CONFIG_VPORT_RX = 0x20007,
  402. MANA_QUERY_VPORT_CONFIG = 0x20008,
  403. /* Privileged commands for the PF mode */
  404. MANA_REGISTER_FILTER = 0x28000,
  405. MANA_DEREGISTER_FILTER = 0x28001,
  406. MANA_REGISTER_HW_PORT = 0x28003,
  407. MANA_DEREGISTER_HW_PORT = 0x28004,
  408. };
  409. /* Query Device Configuration */
  410. struct mana_query_device_cfg_req {
  411. struct gdma_req_hdr hdr;
  412. /* MANA Nic Driver Capability flags */
  413. u64 mn_drv_cap_flags1;
  414. u64 mn_drv_cap_flags2;
  415. u64 mn_drv_cap_flags3;
  416. u64 mn_drv_cap_flags4;
  417. u32 proto_major_ver;
  418. u32 proto_minor_ver;
  419. u32 proto_micro_ver;
  420. u32 reserved;
  421. }; /* HW DATA */
  422. struct mana_query_device_cfg_resp {
  423. struct gdma_resp_hdr hdr;
  424. u64 pf_cap_flags1;
  425. u64 pf_cap_flags2;
  426. u64 pf_cap_flags3;
  427. u64 pf_cap_flags4;
  428. u16 max_num_vports;
  429. u16 reserved;
  430. u32 max_num_eqs;
  431. /* response v2: */
  432. u16 adapter_mtu;
  433. u16 reserved2;
  434. u32 reserved3;
  435. }; /* HW DATA */
  436. /* Query vPort Configuration */
  437. struct mana_query_vport_cfg_req {
  438. struct gdma_req_hdr hdr;
  439. u32 vport_index;
  440. }; /* HW DATA */
  441. struct mana_query_vport_cfg_resp {
  442. struct gdma_resp_hdr hdr;
  443. u32 max_num_sq;
  444. u32 max_num_rq;
  445. u32 num_indirection_ent;
  446. u32 reserved1;
  447. u8 mac_addr[6];
  448. u8 reserved2[2];
  449. mana_handle_t vport;
  450. }; /* HW DATA */
  451. /* Configure vPort */
  452. struct mana_config_vport_req {
  453. struct gdma_req_hdr hdr;
  454. mana_handle_t vport;
  455. u32 pdid;
  456. u32 doorbell_pageid;
  457. }; /* HW DATA */
  458. struct mana_config_vport_resp {
  459. struct gdma_resp_hdr hdr;
  460. u16 tx_vport_offset;
  461. u8 short_form_allowed;
  462. u8 reserved;
  463. }; /* HW DATA */
  464. /* Create WQ Object */
  465. struct mana_create_wqobj_req {
  466. struct gdma_req_hdr hdr;
  467. mana_handle_t vport;
  468. u32 wq_type;
  469. u32 reserved;
  470. u64 wq_gdma_region;
  471. u64 cq_gdma_region;
  472. u32 wq_size;
  473. u32 cq_size;
  474. u32 cq_moderation_ctx_id;
  475. u32 cq_parent_qid;
  476. }; /* HW DATA */
  477. struct mana_create_wqobj_resp {
  478. struct gdma_resp_hdr hdr;
  479. u32 wq_id;
  480. u32 cq_id;
  481. mana_handle_t wq_obj;
  482. }; /* HW DATA */
  483. /* Destroy WQ Object */
  484. struct mana_destroy_wqobj_req {
  485. struct gdma_req_hdr hdr;
  486. u32 wq_type;
  487. u32 reserved;
  488. mana_handle_t wq_obj_handle;
  489. }; /* HW DATA */
  490. struct mana_destroy_wqobj_resp {
  491. struct gdma_resp_hdr hdr;
  492. }; /* HW DATA */
  493. /* Fence RQ */
  494. struct mana_fence_rq_req {
  495. struct gdma_req_hdr hdr;
  496. mana_handle_t wq_obj_handle;
  497. }; /* HW DATA */
  498. struct mana_fence_rq_resp {
  499. struct gdma_resp_hdr hdr;
  500. }; /* HW DATA */
  501. /* Query stats RQ */
  502. struct mana_query_gf_stat_req {
  503. struct gdma_req_hdr hdr;
  504. u64 req_stats;
  505. }; /* HW DATA */
  506. struct mana_query_gf_stat_resp {
  507. struct gdma_resp_hdr hdr;
  508. u64 reported_stats;
  509. /* rx errors/discards */
  510. u64 rx_discards_nowqe;
  511. u64 rx_err_vport_disabled;
  512. /* rx bytes/packets */
  513. u64 hc_rx_bytes;
  514. u64 hc_rx_ucast_pkts;
  515. u64 hc_rx_ucast_bytes;
  516. u64 hc_rx_bcast_pkts;
  517. u64 hc_rx_bcast_bytes;
  518. u64 hc_rx_mcast_pkts;
  519. u64 hc_rx_mcast_bytes;
  520. /* tx errors */
  521. u64 tx_err_gf_disabled;
  522. u64 tx_err_vport_disabled;
  523. u64 tx_err_inval_vport_offset_pkt;
  524. u64 tx_err_vlan_enforcement;
  525. u64 tx_err_ethtype_enforcement;
  526. u64 tx_err_SA_enforcement;
  527. u64 tx_err_SQPDID_enforcement;
  528. u64 tx_err_CQPDID_enforcement;
  529. u64 tx_err_mtu_violation;
  530. u64 tx_err_inval_oob;
  531. /* tx bytes/packets */
  532. u64 hc_tx_bytes;
  533. u64 hc_tx_ucast_pkts;
  534. u64 hc_tx_ucast_bytes;
  535. u64 hc_tx_bcast_pkts;
  536. u64 hc_tx_bcast_bytes;
  537. u64 hc_tx_mcast_pkts;
  538. u64 hc_tx_mcast_bytes;
  539. /* tx error */
  540. u64 tx_err_gdma;
  541. }; /* HW DATA */
  542. /* Configure vPort Rx Steering */
  543. struct mana_cfg_rx_steer_req_v2 {
  544. struct gdma_req_hdr hdr;
  545. mana_handle_t vport;
  546. u16 num_indir_entries;
  547. u16 indir_tab_offset;
  548. u32 rx_enable;
  549. u32 rss_enable;
  550. u8 update_default_rxobj;
  551. u8 update_hashkey;
  552. u8 update_indir_tab;
  553. u8 reserved;
  554. mana_handle_t default_rxobj;
  555. u8 hashkey[MANA_HASH_KEY_SIZE];
  556. u8 cqe_coalescing_enable;
  557. u8 reserved2[7];
  558. mana_handle_t indir_tab[] __counted_by(num_indir_entries);
  559. }; /* HW DATA */
  560. struct mana_cfg_rx_steer_resp {
  561. struct gdma_resp_hdr hdr;
  562. }; /* HW DATA */
  563. /* Register HW vPort */
  564. struct mana_register_hw_vport_req {
  565. struct gdma_req_hdr hdr;
  566. u16 attached_gfid;
  567. u8 is_pf_default_vport;
  568. u8 reserved1;
  569. u8 allow_all_ether_types;
  570. u8 reserved2;
  571. u8 reserved3;
  572. u8 reserved4;
  573. }; /* HW DATA */
  574. struct mana_register_hw_vport_resp {
  575. struct gdma_resp_hdr hdr;
  576. mana_handle_t hw_vport_handle;
  577. }; /* HW DATA */
  578. /* Deregister HW vPort */
  579. struct mana_deregister_hw_vport_req {
  580. struct gdma_req_hdr hdr;
  581. mana_handle_t hw_vport_handle;
  582. }; /* HW DATA */
  583. struct mana_deregister_hw_vport_resp {
  584. struct gdma_resp_hdr hdr;
  585. }; /* HW DATA */
  586. /* Register filter */
  587. struct mana_register_filter_req {
  588. struct gdma_req_hdr hdr;
  589. mana_handle_t vport;
  590. u8 mac_addr[6];
  591. u8 reserved1;
  592. u8 reserved2;
  593. u8 reserved3;
  594. u8 reserved4;
  595. u16 reserved5;
  596. u32 reserved6;
  597. u32 reserved7;
  598. u32 reserved8;
  599. }; /* HW DATA */
  600. struct mana_register_filter_resp {
  601. struct gdma_resp_hdr hdr;
  602. mana_handle_t filter_handle;
  603. }; /* HW DATA */
  604. /* Deregister filter */
  605. struct mana_deregister_filter_req {
  606. struct gdma_req_hdr hdr;
  607. mana_handle_t filter_handle;
  608. }; /* HW DATA */
  609. struct mana_deregister_filter_resp {
  610. struct gdma_resp_hdr hdr;
  611. }; /* HW DATA */
  612. /* Requested GF stats Flags */
  613. /* Rx discards/Errors */
  614. #define STATISTICS_FLAGS_RX_DISCARDS_NO_WQE 0x0000000000000001
  615. #define STATISTICS_FLAGS_RX_ERRORS_VPORT_DISABLED 0x0000000000000002
  616. /* Rx bytes/pkts */
  617. #define STATISTICS_FLAGS_HC_RX_BYTES 0x0000000000000004
  618. #define STATISTICS_FLAGS_HC_RX_UCAST_PACKETS 0x0000000000000008
  619. #define STATISTICS_FLAGS_HC_RX_UCAST_BYTES 0x0000000000000010
  620. #define STATISTICS_FLAGS_HC_RX_MCAST_PACKETS 0x0000000000000020
  621. #define STATISTICS_FLAGS_HC_RX_MCAST_BYTES 0x0000000000000040
  622. #define STATISTICS_FLAGS_HC_RX_BCAST_PACKETS 0x0000000000000080
  623. #define STATISTICS_FLAGS_HC_RX_BCAST_BYTES 0x0000000000000100
  624. /* Tx errors */
  625. #define STATISTICS_FLAGS_TX_ERRORS_GF_DISABLED 0x0000000000000200
  626. #define STATISTICS_FLAGS_TX_ERRORS_VPORT_DISABLED 0x0000000000000400
  627. #define STATISTICS_FLAGS_TX_ERRORS_INVAL_VPORT_OFFSET_PACKETS \
  628. 0x0000000000000800
  629. #define STATISTICS_FLAGS_TX_ERRORS_VLAN_ENFORCEMENT 0x0000000000001000
  630. #define STATISTICS_FLAGS_TX_ERRORS_ETH_TYPE_ENFORCEMENT \
  631. 0x0000000000002000
  632. #define STATISTICS_FLAGS_TX_ERRORS_SA_ENFORCEMENT 0x0000000000004000
  633. #define STATISTICS_FLAGS_TX_ERRORS_SQPDID_ENFORCEMENT 0x0000000000008000
  634. #define STATISTICS_FLAGS_TX_ERRORS_CQPDID_ENFORCEMENT 0x0000000000010000
  635. #define STATISTICS_FLAGS_TX_ERRORS_MTU_VIOLATION 0x0000000000020000
  636. #define STATISTICS_FLAGS_TX_ERRORS_INVALID_OOB 0x0000000000040000
  637. /* Tx bytes/pkts */
  638. #define STATISTICS_FLAGS_HC_TX_BYTES 0x0000000000080000
  639. #define STATISTICS_FLAGS_HC_TX_UCAST_PACKETS 0x0000000000100000
  640. #define STATISTICS_FLAGS_HC_TX_UCAST_BYTES 0x0000000000200000
  641. #define STATISTICS_FLAGS_HC_TX_MCAST_PACKETS 0x0000000000400000
  642. #define STATISTICS_FLAGS_HC_TX_MCAST_BYTES 0x0000000000800000
  643. #define STATISTICS_FLAGS_HC_TX_BCAST_PACKETS 0x0000000001000000
  644. #define STATISTICS_FLAGS_HC_TX_BCAST_BYTES 0x0000000002000000
  645. /* Tx error */
  646. #define STATISTICS_FLAGS_TX_ERRORS_GDMA_ERROR 0x0000000004000000
  647. #define MANA_MAX_NUM_QUEUES 64
  648. #define MANA_SHORT_VPORT_OFFSET_MAX ((1U << 8) - 1)
  649. struct mana_tx_package {
  650. struct gdma_wqe_request wqe_req;
  651. struct gdma_sge sgl_array[5];
  652. struct gdma_sge *sgl_ptr;
  653. struct mana_tx_oob tx_oob;
  654. struct gdma_posted_wqe_info wqe_info;
  655. };
  656. int mana_create_wq_obj(struct mana_port_context *apc,
  657. mana_handle_t vport,
  658. u32 wq_type, struct mana_obj_spec *wq_spec,
  659. struct mana_obj_spec *cq_spec,
  660. mana_handle_t *wq_obj);
  661. void mana_destroy_wq_obj(struct mana_port_context *apc, u32 wq_type,
  662. mana_handle_t wq_obj);
  663. int mana_cfg_vport(struct mana_port_context *apc, u32 protection_dom_id,
  664. u32 doorbell_pg_id);
  665. void mana_uncfg_vport(struct mana_port_context *apc);
  666. struct net_device *mana_get_primary_netdev_rcu(struct mana_context *ac, u32 port_index);
  667. #endif /* _MANA_H */