1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2021 Marvell.
4 #ifndef __CNXK_ETHDEV_H__
5 #define __CNXK_ETHDEV_H__
10 #include <ethdev_driver.h>
11 #include <ethdev_pci.h>
12 #include <rte_kvargs.h>
14 #include <rte_mbuf_pool_ops.h>
15 #include <rte_mempool.h>
16 #include <rte_mtr_driver.h>
17 #include <rte_security.h>
18 #include <rte_security_driver.h>
19 #include <rte_tailq.h>
21 #include <rte_tm_driver.h>
25 #define CNXK_ETH_DEV_PMD_VERSION "1.0"
27 /* Used for struct cnxk_eth_dev::flags */
28 #define CNXK_LINK_CFG_IN_PROGRESS_F BIT_ULL(0)
30 /* VLAN tag inserted by NIX_TX_VTAG_ACTION.
31 * In Tx space is always reserved for this in FRS.
33 #define CNXK_NIX_MAX_VTAG_INS 2
34 #define CNXK_NIX_MAX_VTAG_ACT_SIZE (4 * CNXK_NIX_MAX_VTAG_INS)
36 /* ETH_HLEN+ETH_FCS+2*VLAN_HLEN */
37 #define CNXK_NIX_L2_OVERHEAD (RTE_ETHER_HDR_LEN + \
39 CNXK_NIX_MAX_VTAG_ACT_SIZE)
41 #define CNXK_NIX_RX_MIN_DESC 16
42 #define CNXK_NIX_RX_MIN_DESC_ALIGN 16
43 #define CNXK_NIX_RX_NB_SEG_MAX 6
44 #define CNXK_NIX_RX_DEFAULT_RING_SZ 4096
45 /* Max supported SQB count */
46 #define CNXK_NIX_TX_MAX_SQB 512
48 /* If PTP is enabled additional SEND MEM DESC is required which
49 * takes 2 words, hence max 7 iova address are possible
51 #if defined(RTE_LIBRTE_IEEE1588)
52 #define CNXK_NIX_TX_NB_SEG_MAX 7
54 #define CNXK_NIX_TX_NB_SEG_MAX 9
57 #define CNXK_NIX_TX_MSEG_SG_DWORDS \
58 ((RTE_ALIGN_MUL_CEIL(CNXK_NIX_TX_NB_SEG_MAX, 3) / 3) + \
59 CNXK_NIX_TX_NB_SEG_MAX)
61 #define CNXK_NIX_RSS_L3_L4_SRC_DST \
62 (RTE_ETH_RSS_L3_SRC_ONLY | RTE_ETH_RSS_L3_DST_ONLY | \
63 RTE_ETH_RSS_L4_SRC_ONLY | RTE_ETH_RSS_L4_DST_ONLY)
65 #define CNXK_NIX_RSS_OFFLOAD \
66 (RTE_ETH_RSS_PORT | RTE_ETH_RSS_IP | RTE_ETH_RSS_UDP | \
67 RTE_ETH_RSS_TCP | RTE_ETH_RSS_SCTP | RTE_ETH_RSS_TUNNEL | \
68 RTE_ETH_RSS_L2_PAYLOAD | CNXK_NIX_RSS_L3_L4_SRC_DST | \
69 RTE_ETH_RSS_LEVEL_MASK | RTE_ETH_RSS_C_VLAN)
71 #define CNXK_NIX_TX_OFFLOAD_CAPA \
72 (RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE | RTE_ETH_TX_OFFLOAD_MT_LOCKFREE | \
73 RTE_ETH_TX_OFFLOAD_VLAN_INSERT | RTE_ETH_TX_OFFLOAD_QINQ_INSERT | \
74 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM | RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM | \
75 RTE_ETH_TX_OFFLOAD_TCP_CKSUM | RTE_ETH_TX_OFFLOAD_UDP_CKSUM | \
76 RTE_ETH_TX_OFFLOAD_SCTP_CKSUM | RTE_ETH_TX_OFFLOAD_TCP_TSO | \
77 RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO | RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO | \
78 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO | RTE_ETH_TX_OFFLOAD_MULTI_SEGS | \
79 RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | RTE_ETH_TX_OFFLOAD_SECURITY)
81 #define CNXK_NIX_RX_OFFLOAD_CAPA \
82 (RTE_ETH_RX_OFFLOAD_CHECKSUM | RTE_ETH_RX_OFFLOAD_SCTP_CKSUM | \
83 RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM | RTE_ETH_RX_OFFLOAD_SCATTER | \
84 RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM | RTE_ETH_RX_OFFLOAD_RSS_HASH | \
85 RTE_ETH_RX_OFFLOAD_TIMESTAMP | RTE_ETH_RX_OFFLOAD_VLAN_STRIP | \
86 RTE_ETH_RX_OFFLOAD_SECURITY)
88 #define RSS_IPV4_ENABLE \
89 (RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_FRAG_IPV4 | \
90 RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
91 RTE_ETH_RSS_NONFRAG_IPV4_SCTP)
93 #define RSS_IPV6_ENABLE \
94 (RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_FRAG_IPV6 | \
95 RTE_ETH_RSS_NONFRAG_IPV6_UDP | RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
96 RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
98 #define RSS_IPV6_EX_ENABLE \
99 (RTE_ETH_RSS_IPV6_EX | RTE_ETH_RSS_IPV6_TCP_EX | RTE_ETH_RSS_IPV6_UDP_EX)
101 #define RSS_MAX_LEVELS 3
103 #define RSS_IPV4_INDEX 0
104 #define RSS_IPV6_INDEX 1
105 #define RSS_TCP_INDEX 2
106 #define RSS_UDP_INDEX 3
107 #define RSS_SCTP_INDEX 4
108 #define RSS_DMAC_INDEX 5
110 /* Default mark value used when none is provided. */
111 #define CNXK_FLOW_ACTION_FLAG_DEFAULT 0xffff
113 /* Default cycle counter mask */
114 #define CNXK_CYCLECOUNTER_MASK 0xffffffffffffffffULL
115 #define CNXK_NIX_TIMESYNC_RX_OFFSET 8
117 #define PTYPE_NON_TUNNEL_WIDTH 16
118 #define PTYPE_TUNNEL_WIDTH 12
119 #define PTYPE_NON_TUNNEL_ARRAY_SZ BIT(PTYPE_NON_TUNNEL_WIDTH)
120 #define PTYPE_TUNNEL_ARRAY_SZ BIT(PTYPE_TUNNEL_WIDTH)
121 #define PTYPE_ARRAY_SZ \
122 ((PTYPE_NON_TUNNEL_ARRAY_SZ + PTYPE_TUNNEL_ARRAY_SZ) * sizeof(uint16_t))
124 /* NIX_RX_PARSE_S's ERRCODE + ERRLEV (12 bits) */
125 #define ERRCODE_ERRLEN_WIDTH 12
126 #define ERR_ARRAY_SZ ((BIT(ERRCODE_ERRLEN_WIDTH)) * sizeof(uint32_t))
128 /* Fastpath lookup */
129 #define CNXK_NIX_FASTPATH_LOOKUP_MEM "cnxk_nix_fastpath_lookup_mem"
131 #define CNXK_NIX_UDP_TUN_BITMASK \
132 ((1ull << (RTE_MBUF_F_TX_TUNNEL_VXLAN >> 45)) | \
133 (1ull << (RTE_MBUF_F_TX_TUNNEL_GENEVE >> 45)))
135 /* Subtype from inline outbound error event */
136 #define CNXK_ETHDEV_SEC_OUTB_EV_SUB 0xFFUL
138 /* SPI will be in 20 bits of tag */
139 #define CNXK_ETHDEV_SPI_TAG_MASK 0xFFFFFUL
141 #define CNXK_NIX_PFC_CHAN_COUNT 16
143 #define CNXK_TM_MARK_VLAN_DEI BIT_ULL(0)
144 #define CNXK_TM_MARK_IP_DSCP BIT_ULL(1)
145 #define CNXK_TM_MARK_IP_ECN BIT_ULL(2)
147 #define CNXK_TM_MARK_MASK \
148 (CNXK_TM_MARK_VLAN_DEI | CNXK_TM_MARK_IP_DSCP | CNXK_TM_MARK_IP_ECN)
150 #define CNXK_TX_MARK_FMT_MASK (0xFFFFFFFFFFFFull)
153 enum rte_eth_fc_mode mode;
158 struct cnxk_pfc_cfg {
159 struct cnxk_fc_cfg fc_cfg;
168 struct cnxk_eth_qconf {
170 struct rte_eth_txconf tx;
171 struct rte_eth_rxconf rx;
173 struct rte_mempool *mp;
178 struct cnxk_timesync_info {
181 uint64_t rx_tstamp_dynflag;
182 int tstamp_dynfield_offset;
183 rte_iova_t tx_tstamp_iova;
185 } __plt_cache_aligned;
187 struct cnxk_meter_node {
188 #define MAX_PRV_MTR_NODES 10
189 TAILQ_ENTRY(cnxk_meter_node) next;
190 /**< Pointer to the next flow meter structure. */
191 uint32_t id; /**< Usr mtr id. */
192 struct cnxk_mtr_profile_node *profile;
193 struct cnxk_mtr_policy_node *policy;
194 uint32_t bpf_id; /**< Hw mtr id. */
198 uint32_t prev_id[MAX_PRV_MTR_NODES]; /**< Prev mtr id for chaining */
200 uint32_t next_id; /**< Next mtr id for chaining */
203 struct rte_mtr_params params;
204 struct roc_nix_bpf_objs profs;
210 enum rte_eth_hash_function func;
219 struct policy_actions {
220 uint32_t action_fate;
224 struct action_rss *rss_desc;
228 struct cnxk_mtr_policy_node {
229 TAILQ_ENTRY(cnxk_mtr_policy_node) next;
230 /**< Pointer to the next flow meter structure. */
231 uint32_t id; /**< Policy id */
232 uint32_t mtr_id; /** Meter id */
233 struct rte_mtr_meter_policy_params policy;
234 struct policy_actions actions[RTE_COLORS];
238 struct cnxk_mtr_profile_node {
239 TAILQ_ENTRY(cnxk_mtr_profile_node) next;
240 struct rte_mtr_meter_profile profile; /**< Profile detail. */
241 uint32_t ref_cnt; /**< Use count. */
242 uint32_t id; /**< Profile id. */
245 TAILQ_HEAD(cnxk_mtr_profiles, cnxk_mtr_profile_node);
246 TAILQ_HEAD(cnxk_mtr_policy, cnxk_mtr_policy_node);
247 TAILQ_HEAD(cnxk_mtr, cnxk_meter_node);
249 /* Security session private data */
250 struct cnxk_eth_sec_sess {
252 TAILQ_ENTRY(cnxk_eth_sec_sess) entry;
254 /* Inbound SA is from NIX_RX_IPSEC_SA_BASE or
255 * Outbound SA from roc_nix_inl_outb_sa_base_get()
265 /* Back pointer to session */
266 struct rte_security_session *sess;
271 /* Inbound session on inl dev */
275 TAILQ_HEAD(cnxk_eth_sec_sess_list, cnxk_eth_sec_sess);
277 /* Inbound security data */
278 struct cnxk_eth_dev_sec_inb {
279 /* IPSec inbound max SPI */
282 /* Using inbound with inline device */
285 /* Device argument to disable inline device usage for inb */
288 /* Active sessions */
291 /* List of sessions */
292 struct cnxk_eth_sec_sess_list list;
294 /* DPTR for WRITE_SA microcode op */
297 /* Lock to synchronize sa setup/release */
301 /* Outbound security data */
302 struct cnxk_eth_dev_sec_outb {
303 /* IPSec outbound max SA */
306 /* Per CPT LF descriptor count */
310 struct plt_bitmap *sa_bmap;
312 /* SA bitmap memory */
319 struct roc_cpt_lf *lf_base;
321 /* Crypto queues => CPT lf count */
322 uint16_t nb_crypto_qs;
327 /* Active sessions */
330 /* List of sessions */
331 struct cnxk_eth_sec_sess_list list;
333 /* DPTR for WRITE_SA microcode op */
336 /* Lock to synchronize sa setup/release */
340 struct cnxk_eth_dev {
347 /* ROC RQs, SQs and CQs */
348 struct roc_nix_rq *rqs;
349 struct roc_nix_sq *sqs;
350 struct roc_nix_cq *cqs;
352 /* Configured queue count */
358 /* Max macfilter entries */
359 uint8_t dmac_filter_count;
360 uint8_t max_mac_entries;
361 bool dmac_filter_enable;
364 uint8_t ptype_disable;
368 bool rx_mark_update; /* Enable/Disable mark update to mbuf */
370 /* Pointer back to rte */
371 struct rte_eth_dev *eth_dev;
373 /* HW capabilities / Limitations */
376 uint64_t cq_min_4k : 1;
377 uint64_t ipsecd_drop_re_dis : 1;
378 uint64_t vec_drop_re_dis : 1;
383 /* Rx and Tx offload capabilities */
384 uint64_t rx_offload_capa;
385 uint64_t tx_offload_capa;
387 /* Configured Rx and Tx offloads */
388 uint64_t rx_offloads;
389 uint64_t tx_offloads;
390 /* Platform specific offload flags */
391 uint16_t rx_offload_flags;
392 uint16_t tx_offload_flags;
394 /* ETHDEV RSS HF bitmask */
395 uint64_t ethdev_rss_hf;
397 /* Saved qconf before lf realloc */
398 struct cnxk_eth_qconf *tx_qconf;
399 struct cnxk_eth_qconf *rx_qconf;
401 /* Flow control configuration */
402 uint16_t pfc_tc_sq_map[CNXK_NIX_PFC_CHAN_COUNT];
403 struct cnxk_pfc_cfg pfc_cfg;
404 struct cnxk_fc_cfg fc_cfg;
407 struct cnxk_timesync_info tstamp;
408 struct rte_timecounter systime_tc;
409 struct rte_timecounter rx_tstamp_tc;
410 struct rte_timecounter tx_tstamp_tc;
411 double clk_freq_mult;
414 /* Ingress policer */
415 enum roc_nix_bpf_color precolor_tbl[ROC_NIX_BPF_PRE_COLOR_MAX];
416 struct cnxk_mtr_profiles mtr_profiles;
417 struct cnxk_mtr_policy mtr_policy;
420 /* Rx burst for cleanup(Only Primary) */
421 eth_rx_burst_t rx_pkt_burst_no_offload;
423 /* Default mac address */
424 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
426 /* LSO Tunnel format indices */
427 uint64_t lso_tun_fmt;
429 /* Per queue statistics counters */
430 uint32_t txq_stat_map[RTE_ETHDEV_QUEUE_STAT_CNTRS];
431 uint32_t rxq_stat_map[RTE_ETHDEV_QUEUE_STAT_CNTRS];
434 struct cnxk_eth_dev_sec_inb inb;
435 struct cnxk_eth_dev_sec_outb outb;
437 /* Reassembly dynfield/flag offsets */
438 int reass_dynfield_off;
439 int reass_dynflag_bit;
442 struct cnxk_eth_rxq_sp {
443 struct cnxk_eth_dev *dev;
444 struct cnxk_eth_qconf qconf;
446 } __plt_cache_aligned;
448 struct cnxk_eth_txq_sp {
449 struct cnxk_eth_dev *dev;
450 struct cnxk_eth_qconf qconf;
452 } __plt_cache_aligned;
454 static inline struct cnxk_eth_dev *
455 cnxk_eth_pmd_priv(const struct rte_eth_dev *eth_dev)
457 return eth_dev->data->dev_private;
460 static inline struct cnxk_eth_rxq_sp *
461 cnxk_eth_rxq_to_sp(void *__rxq)
463 return ((struct cnxk_eth_rxq_sp *)__rxq) - 1;
466 static inline struct cnxk_eth_txq_sp *
467 cnxk_eth_txq_to_sp(void *__txq)
469 return ((struct cnxk_eth_txq_sp *)__txq) - 1;
472 /* Common ethdev ops */
473 extern struct eth_dev_ops cnxk_eth_dev_ops;
475 /* Common flow ops */
476 extern struct rte_flow_ops cnxk_flow_ops;
478 /* Common security ops */
479 extern struct rte_security_ops cnxk_eth_sec_ops;
482 extern struct rte_tm_ops cnxk_tm_ops;
485 int cnxk_nix_probe(struct rte_pci_driver *pci_drv,
486 struct rte_pci_device *pci_dev);
487 int cnxk_nix_remove(struct rte_pci_device *pci_dev);
488 int cnxk_nix_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu);
489 int cnxk_nix_mc_addr_list_configure(struct rte_eth_dev *eth_dev,
490 struct rte_ether_addr *mc_addr_set,
491 uint32_t nb_mc_addr);
492 int cnxk_nix_mac_addr_add(struct rte_eth_dev *eth_dev,
493 struct rte_ether_addr *addr, uint32_t index,
495 void cnxk_nix_mac_addr_del(struct rte_eth_dev *eth_dev, uint32_t index);
496 int cnxk_nix_mac_addr_set(struct rte_eth_dev *eth_dev,
497 struct rte_ether_addr *addr);
498 int cnxk_nix_promisc_enable(struct rte_eth_dev *eth_dev);
499 int cnxk_nix_promisc_disable(struct rte_eth_dev *eth_dev);
500 int cnxk_nix_allmulticast_enable(struct rte_eth_dev *eth_dev);
501 int cnxk_nix_allmulticast_disable(struct rte_eth_dev *eth_dev);
502 int cnxk_nix_info_get(struct rte_eth_dev *eth_dev,
503 struct rte_eth_dev_info *dev_info);
504 int cnxk_nix_rx_burst_mode_get(struct rte_eth_dev *eth_dev, uint16_t queue_id,
505 struct rte_eth_burst_mode *mode);
506 int cnxk_nix_tx_burst_mode_get(struct rte_eth_dev *eth_dev, uint16_t queue_id,
507 struct rte_eth_burst_mode *mode);
508 int cnxk_nix_flow_ctrl_set(struct rte_eth_dev *eth_dev,
509 struct rte_eth_fc_conf *fc_conf);
510 int cnxk_nix_flow_ctrl_get(struct rte_eth_dev *eth_dev,
511 struct rte_eth_fc_conf *fc_conf);
512 int cnxk_nix_priority_flow_ctrl_queue_config(struct rte_eth_dev *eth_dev,
513 struct rte_eth_pfc_queue_conf *pfc_conf);
514 int cnxk_nix_priority_flow_ctrl_queue_info_get(struct rte_eth_dev *eth_dev,
515 struct rte_eth_pfc_queue_info *pfc_info);
516 int cnxk_nix_set_link_up(struct rte_eth_dev *eth_dev);
517 int cnxk_nix_set_link_down(struct rte_eth_dev *eth_dev);
518 int cnxk_nix_get_module_info(struct rte_eth_dev *eth_dev,
519 struct rte_eth_dev_module_info *modinfo);
520 int cnxk_nix_get_module_eeprom(struct rte_eth_dev *eth_dev,
521 struct rte_dev_eeprom_info *info);
522 int cnxk_nix_rx_queue_intr_enable(struct rte_eth_dev *eth_dev,
523 uint16_t rx_queue_id);
524 int cnxk_nix_rx_queue_intr_disable(struct rte_eth_dev *eth_dev,
525 uint16_t rx_queue_id);
526 int cnxk_nix_pool_ops_supported(struct rte_eth_dev *eth_dev, const char *pool);
527 int cnxk_nix_tx_done_cleanup(void *txq, uint32_t free_cnt);
528 int cnxk_nix_flow_ops_get(struct rte_eth_dev *eth_dev,
529 const struct rte_flow_ops **ops);
530 int cnxk_nix_configure(struct rte_eth_dev *eth_dev);
531 int cnxk_nix_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t qid,
532 uint16_t nb_desc, uint16_t fp_tx_q_sz,
533 const struct rte_eth_txconf *tx_conf);
534 int cnxk_nix_rx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t qid,
535 uint16_t nb_desc, uint16_t fp_rx_q_sz,
536 const struct rte_eth_rxconf *rx_conf,
537 struct rte_mempool *mp);
538 int cnxk_nix_tx_queue_start(struct rte_eth_dev *eth_dev, uint16_t qid);
539 int cnxk_nix_tx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t qid);
540 int cnxk_nix_dev_start(struct rte_eth_dev *eth_dev);
541 int cnxk_nix_timesync_enable(struct rte_eth_dev *eth_dev);
542 int cnxk_nix_timesync_disable(struct rte_eth_dev *eth_dev);
543 int cnxk_nix_timesync_read_rx_timestamp(struct rte_eth_dev *eth_dev,
544 struct timespec *timestamp,
546 int cnxk_nix_timesync_read_tx_timestamp(struct rte_eth_dev *eth_dev,
547 struct timespec *timestamp);
548 int cnxk_nix_timesync_read_time(struct rte_eth_dev *eth_dev,
549 struct timespec *ts);
550 int cnxk_nix_timesync_write_time(struct rte_eth_dev *eth_dev,
551 const struct timespec *ts);
552 int cnxk_nix_timesync_adjust_time(struct rte_eth_dev *eth_dev, int64_t delta);
553 int cnxk_nix_tsc_convert(struct cnxk_eth_dev *dev);
554 int cnxk_nix_read_clock(struct rte_eth_dev *eth_dev, uint64_t *clock);
556 uint64_t cnxk_nix_rxq_mbuf_setup(struct cnxk_eth_dev *dev);
557 int cnxk_nix_tm_ops_get(struct rte_eth_dev *eth_dev, void *ops);
558 int cnxk_nix_tm_set_queue_rate_limit(struct rte_eth_dev *eth_dev,
559 uint16_t queue_idx, uint16_t tx_rate);
560 int cnxk_nix_tm_mark_vlan_dei(struct rte_eth_dev *eth_dev, int mark_green,
561 int mark_yellow, int mark_red,
562 struct rte_tm_error *error);
563 int cnxk_nix_tm_mark_ip_ecn(struct rte_eth_dev *eth_dev, int mark_green,
564 int mark_yellow, int mark_red,
565 struct rte_tm_error *error);
566 int cnxk_nix_tm_mark_ip_dscp(struct rte_eth_dev *eth_dev, int mark_green,
567 int mark_yellow, int mark_red,
568 struct rte_tm_error *error);
571 int cnxk_nix_mtr_ops_get(struct rte_eth_dev *dev, void *ops);
574 uint32_t cnxk_rss_ethdev_to_nix(struct cnxk_eth_dev *dev, uint64_t ethdev_rss,
576 int cnxk_nix_reta_update(struct rte_eth_dev *eth_dev,
577 struct rte_eth_rss_reta_entry64 *reta_conf,
579 int cnxk_nix_reta_query(struct rte_eth_dev *eth_dev,
580 struct rte_eth_rss_reta_entry64 *reta_conf,
582 int cnxk_nix_rss_hash_update(struct rte_eth_dev *eth_dev,
583 struct rte_eth_rss_conf *rss_conf);
584 int cnxk_nix_rss_hash_conf_get(struct rte_eth_dev *eth_dev,
585 struct rte_eth_rss_conf *rss_conf);
588 void cnxk_nix_toggle_flag_link_cfg(struct cnxk_eth_dev *dev, bool set);
589 void cnxk_eth_dev_link_status_cb(struct roc_nix *nix,
590 struct roc_nix_link_info *link);
591 void cnxk_eth_dev_link_status_get_cb(struct roc_nix *nix,
592 struct roc_nix_link_info *link);
593 int cnxk_nix_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete);
594 int cnxk_nix_queue_stats_mapping(struct rte_eth_dev *dev, uint16_t queue_id,
595 uint8_t stat_idx, uint8_t is_rx);
596 int cnxk_nix_stats_reset(struct rte_eth_dev *dev);
597 int cnxk_nix_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats);
598 int cnxk_nix_xstats_get(struct rte_eth_dev *eth_dev,
599 struct rte_eth_xstat *xstats, unsigned int n);
600 int cnxk_nix_xstats_get_names(struct rte_eth_dev *eth_dev,
601 struct rte_eth_xstat_name *xstats_names,
603 int cnxk_nix_xstats_get_names_by_id(struct rte_eth_dev *eth_dev,
605 struct rte_eth_xstat_name *xstats_names,
607 int cnxk_nix_xstats_get_by_id(struct rte_eth_dev *eth_dev, const uint64_t *ids,
608 uint64_t *values, unsigned int n);
609 int cnxk_nix_xstats_reset(struct rte_eth_dev *eth_dev);
610 int cnxk_nix_fw_version_get(struct rte_eth_dev *eth_dev, char *fw_version,
612 void cnxk_nix_rxq_info_get(struct rte_eth_dev *eth_dev, uint16_t qid,
613 struct rte_eth_rxq_info *qinfo);
614 void cnxk_nix_txq_info_get(struct rte_eth_dev *eth_dev, uint16_t qid,
615 struct rte_eth_txq_info *qinfo);
618 int cnxk_nix_rx_descriptor_status(void *rxq, uint16_t offset);
619 int cnxk_nix_tx_descriptor_status(void *txq, uint16_t offset);
620 uint32_t cnxk_nix_rx_queue_count(void *rxq);
622 /* Lookup configuration */
623 const uint32_t *cnxk_nix_supported_ptypes_get(struct rte_eth_dev *eth_dev);
624 void *cnxk_nix_fastpath_lookup_mem_get(void);
627 int cnxk_ethdev_parse_devargs(struct rte_devargs *devargs,
628 struct cnxk_eth_dev *dev);
631 int cnxk_nix_dev_get_reg(struct rte_eth_dev *eth_dev,
632 struct rte_dev_reg_info *regs);
634 int cnxk_eth_outb_sa_idx_get(struct cnxk_eth_dev *dev, uint32_t *idx_p,
636 int cnxk_eth_outb_sa_idx_put(struct cnxk_eth_dev *dev, uint32_t idx);
637 int cnxk_nix_lookup_mem_sa_base_set(struct cnxk_eth_dev *dev);
638 int cnxk_nix_lookup_mem_sa_base_clear(struct cnxk_eth_dev *dev);
640 int cnxk_nix_inb_mode_set(struct cnxk_eth_dev *dev, bool use_inl_dev);
641 struct cnxk_eth_sec_sess *cnxk_eth_sec_sess_get_by_spi(struct cnxk_eth_dev *dev,
642 uint32_t spi, bool inb);
643 struct cnxk_eth_sec_sess *
644 cnxk_eth_sec_sess_get_by_sess(struct cnxk_eth_dev *dev,
645 struct rte_security_session *sess);
647 /* Other private functions */
648 int nix_recalc_mtu(struct rte_eth_dev *eth_dev);
649 int nix_mtr_validate(struct rte_eth_dev *dev, uint32_t id);
650 int nix_mtr_policy_act_get(struct rte_eth_dev *eth_dev, uint32_t id,
651 struct cnxk_mtr_policy_node **policy);
652 int nix_mtr_rq_update(struct rte_eth_dev *eth_dev, uint32_t id,
653 uint32_t queue_num, const uint16_t *queue);
654 int nix_mtr_chain_update(struct rte_eth_dev *eth_dev, uint32_t cur_id,
655 uint32_t prev_id, uint32_t next_id);
656 int nix_mtr_chain_reset(struct rte_eth_dev *eth_dev, uint32_t cur_id);
657 struct cnxk_meter_node *nix_get_mtr(struct rte_eth_dev *eth_dev,
659 int nix_mtr_level_update(struct rte_eth_dev *eth_dev, uint32_t id,
661 int nix_mtr_capabilities_init(struct rte_eth_dev *eth_dev);
662 int nix_mtr_configure(struct rte_eth_dev *eth_dev, uint32_t id);
663 int nix_mtr_connect(struct rte_eth_dev *eth_dev, uint32_t id);
664 int nix_mtr_destroy(struct rte_eth_dev *eth_dev, uint32_t id,
665 struct rte_mtr_error *error);
666 int nix_mtr_color_action_validate(struct rte_eth_dev *eth_dev, uint32_t id,
667 uint32_t *prev_id, uint32_t *next_id,
668 struct cnxk_mtr_policy_node *policy,
670 int nix_priority_flow_ctrl_configure(struct rte_eth_dev *eth_dev,
671 struct cnxk_pfc_cfg *conf);
674 static __rte_always_inline uint64_t
675 cnxk_pktmbuf_detach(struct rte_mbuf *m)
677 struct rte_mempool *mp = m->pool;
678 uint32_t mbuf_size, buf_len;
683 /* Update refcount of direct mbuf */
684 md = rte_mbuf_from_indirect(m);
685 refcount = rte_mbuf_refcnt_update(md, -1);
687 priv_size = rte_pktmbuf_priv_size(mp);
688 mbuf_size = (uint32_t)(sizeof(struct rte_mbuf) + priv_size);
689 buf_len = rte_pktmbuf_data_room_size(mp);
691 m->priv_size = priv_size;
692 m->buf_addr = (char *)m + mbuf_size;
693 m->buf_iova = rte_mempool_virt2iova(m) + mbuf_size;
694 m->buf_len = (uint16_t)buf_len;
695 rte_pktmbuf_reset_headroom(m);
701 /* Now indirect mbuf is safe to free */
705 rte_mbuf_refcnt_set(md, 1);
716 static __rte_always_inline uint64_t
717 cnxk_nix_prefree_seg(struct rte_mbuf *m)
719 if (likely(rte_mbuf_refcnt_read(m) == 1)) {
720 if (!RTE_MBUF_DIRECT(m))
721 return cnxk_pktmbuf_detach(m);
726 } else if (rte_mbuf_refcnt_update(m, -1) == 0) {
727 if (!RTE_MBUF_DIRECT(m))
728 return cnxk_pktmbuf_detach(m);
730 rte_mbuf_refcnt_set(m, 1);
736 /* Mbuf is having refcount more than 1 so need not to be freed */
740 static inline rte_mbuf_timestamp_t *
741 cnxk_nix_timestamp_dynfield(struct rte_mbuf *mbuf,
742 struct cnxk_timesync_info *info)
744 return RTE_MBUF_DYNFIELD(mbuf, info->tstamp_dynfield_offset,
745 rte_mbuf_timestamp_t *);
748 static __rte_always_inline uintptr_t
749 cnxk_nix_sa_base_get(uint16_t port, const void *lookup_mem)
751 uintptr_t sa_base_tbl;
753 sa_base_tbl = (uintptr_t)lookup_mem;
754 sa_base_tbl += PTYPE_ARRAY_SZ + ERR_ARRAY_SZ;
755 return *((const uintptr_t *)sa_base_tbl + port);
758 #endif /* __CNXK_ETHDEV_H__ */