Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(C) 2021 Marvell.
3 : : */
4 : : #ifndef __CNXK_ETHDEV_H__
5 : : #define __CNXK_ETHDEV_H__
6 : :
7 : : #include <math.h>
8 : : #include <stdint.h>
9 : :
10 : : #include <ethdev_driver.h>
11 : : #include <ethdev_pci.h>
12 : : #include <rte_compat.h>
13 : : #include <rte_kvargs.h>
14 : : #include <rte_mbuf.h>
15 : : #include <rte_mbuf_pool_ops.h>
16 : : #include <rte_mempool.h>
17 : : #include <rte_mtr_driver.h>
18 : : #include <rte_security.h>
19 : : #include <rte_security_driver.h>
20 : : #include <rte_tailq.h>
21 : : #include <rte_time.h>
22 : : #include <rte_tm_driver.h>
23 : :
24 : : #include "roc_api.h"
25 : : #include <cnxk_ethdev_dp.h>
26 : :
27 : : #define CNXK_ETH_DEV_PMD_VERSION "1.0"
28 : :
29 : : /* Macros for packing configuration fields */
30 : : #define CNXK_FIELD_MASK(width) ((1ULL << (width)) - 1)
31 : : #define PACK(val, shift, width) (((uint64_t)((val) & CNXK_FIELD_MASK(width))) << (shift))
32 : :
33 : : /* Used for struct cnxk_eth_dev::flags */
34 : : #define CNXK_LINK_CFG_IN_PROGRESS_F BIT_ULL(0)
35 : :
36 : : /* VLAN tag inserted by NIX_TX_VTAG_ACTION.
37 : : * In Tx space is always reserved for this in FRS.
38 : : */
39 : : #define CNXK_NIX_MAX_VTAG_INS 2
40 : : #define CNXK_NIX_MAX_VTAG_ACT_SIZE (4 * CNXK_NIX_MAX_VTAG_INS)
41 : :
42 : : /* ETH_HLEN+ETH_FCS+2*VLAN_HLEN */
43 : : #define CNXK_NIX_L2_OVERHEAD (RTE_ETHER_HDR_LEN + \
44 : : RTE_ETHER_CRC_LEN + \
45 : : CNXK_NIX_MAX_VTAG_ACT_SIZE)
46 : :
47 : : #define CNXK_NIX_RX_MIN_DESC 16
48 : : #define CNXK_NIX_RX_MIN_DESC_ALIGN 16
49 : : #define CNXK_NIX_RX_NB_SEG_MAX 6
50 : : #define CNXK_NIX_RX_DEFAULT_RING_SZ 4096
51 : : /* Max supported SQB count */
52 : : #define CNXK_NIX_TX_MAX_SQB 512
53 : : /* LPB & SPB */
54 : : #define CNXK_NIX_NUM_POOLS_MAX 2
55 : :
56 : : #define CNXK_NIX_DEF_SQ_COUNT 512
57 : :
58 : : #define CNXK_NIX_RSS_L3_L4_SRC_DST \
59 : : (RTE_ETH_RSS_L3_SRC_ONLY | RTE_ETH_RSS_L3_DST_ONLY | RTE_ETH_RSS_L4_SRC_ONLY | \
60 : : RTE_ETH_RSS_L4_DST_ONLY)
61 : :
62 : : #define CNXK_NIX_RSS_OFFLOAD \
63 : : (RTE_ETH_RSS_PORT | RTE_ETH_RSS_IP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_TCP | \
64 : : RTE_ETH_RSS_SCTP | RTE_ETH_RSS_TUNNEL | RTE_ETH_RSS_L2_PAYLOAD | \
65 : : CNXK_NIX_RSS_L3_L4_SRC_DST | RTE_ETH_RSS_LEVEL_MASK | RTE_ETH_RSS_C_VLAN | \
66 : : RTE_ETH_RSS_ESP | RTE_ETH_RSS_IB_BTH)
67 : :
68 : : #define CNXK_NIX_TX_OFFLOAD_CAPA \
69 : : (RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE | RTE_ETH_TX_OFFLOAD_MT_LOCKFREE | \
70 : : RTE_ETH_TX_OFFLOAD_VLAN_INSERT | RTE_ETH_TX_OFFLOAD_QINQ_INSERT | \
71 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM | RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM | \
72 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM | RTE_ETH_TX_OFFLOAD_UDP_CKSUM | \
73 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM | RTE_ETH_TX_OFFLOAD_TCP_TSO | \
74 : : RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO | RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO | \
75 : : RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO | RTE_ETH_TX_OFFLOAD_MULTI_SEGS | \
76 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | RTE_ETH_TX_OFFLOAD_SECURITY)
77 : :
78 : : #define CNXK_NIX_RX_OFFLOAD_CAPA \
79 : : (RTE_ETH_RX_OFFLOAD_CHECKSUM | RTE_ETH_RX_OFFLOAD_SCTP_CKSUM | \
80 : : RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM | RTE_ETH_RX_OFFLOAD_SCATTER | \
81 : : RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM | RTE_ETH_RX_OFFLOAD_RSS_HASH | \
82 : : RTE_ETH_RX_OFFLOAD_TIMESTAMP | RTE_ETH_RX_OFFLOAD_VLAN_STRIP | \
83 : : RTE_ETH_RX_OFFLOAD_SECURITY)
84 : :
85 : : #define RSS_IPV4_ENABLE \
86 : : (RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
87 : : RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_NONFRAG_IPV4_SCTP)
88 : :
89 : : #define RSS_IPV6_ENABLE \
90 : : (RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_FRAG_IPV6 | RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
91 : : RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
92 : :
93 : : #define RSS_IPV6_EX_ENABLE (RTE_ETH_RSS_IPV6_EX | RTE_ETH_RSS_IPV6_TCP_EX | RTE_ETH_RSS_IPV6_UDP_EX)
94 : :
95 : : #define RSS_MAX_LEVELS 3
96 : :
97 : : #define RSS_IPV4_INDEX 0
98 : : #define RSS_IPV6_INDEX 1
99 : : #define RSS_TCP_INDEX 2
100 : : #define RSS_UDP_INDEX 3
101 : : #define RSS_SCTP_INDEX 4
102 : : #define RSS_DMAC_INDEX 5
103 : :
104 : : /* Default mark value used when none is provided. */
105 : : #define CNXK_NIX_MTR_COUNT_MAX 73 /* 64(leaf) + 8(mid) + 1(top) */
106 : :
107 : : /* Default cycle counter mask */
108 : : #define CNXK_CYCLECOUNTER_MASK 0xffffffffffffffffULL
109 : :
110 : : /* Fastpath lookup */
111 : : #define CNXK_NIX_FASTPATH_LOOKUP_MEM "cnxk_nix_fastpath_lookup_mem"
112 : :
113 : : #define CNXK_NIX_DMAC_IDX_INVALID -1
114 : :
115 : : struct cnxk_fc_cfg {
116 : : enum rte_eth_fc_mode mode;
117 : : uint8_t rx_pause;
118 : : uint8_t tx_pause;
119 : : };
120 : :
121 : : struct cnxk_pfc_cfg {
122 : : uint16_t class_en;
123 : : uint16_t pause_time;
124 : : uint16_t rx_pause_en;
125 : : uint16_t tx_pause_en;
126 : : };
127 : :
128 : : struct cnxk_eth_qconf {
129 : : union {
130 : : struct rte_eth_txconf tx;
131 : : struct rte_eth_rxconf rx;
132 : : } conf;
133 : : struct rte_mempool *mp;
134 : : uint16_t nb_desc;
135 : : uint8_t valid;
136 : : };
137 : :
138 : : struct cnxk_meter_node {
139 : : #define MAX_PRV_MTR_NODES 10
140 : : TAILQ_ENTRY(cnxk_meter_node) next;
141 : : /**< Pointer to the next flow meter structure. */
142 : : uint32_t id; /**< Usr mtr id. */
143 : : struct cnxk_mtr_profile_node *profile;
144 : : struct cnxk_mtr_policy_node *policy;
145 : : uint32_t bpf_id; /**< Hw mtr id. */
146 : : uint32_t rq_num;
147 : : uint32_t *rq_id;
148 : : uint16_t level;
149 : : uint32_t prev_id[MAX_PRV_MTR_NODES]; /**< Prev mtr id for chaining */
150 : : uint32_t prev_cnt;
151 : : uint32_t next_id; /**< Next mtr id for chaining */
152 : : bool is_prev;
153 : : bool is_next;
154 : : struct rte_mtr_params params;
155 : : struct roc_nix_bpf_objs profs;
156 : : bool is_used;
157 : : uint32_t ref_cnt;
158 : : };
159 : :
160 : : struct action_rss {
161 : : enum rte_eth_hash_function func;
162 : : uint32_t level;
163 : : uint64_t types;
164 : : uint32_t key_len;
165 : : uint32_t queue_num;
166 : : uint8_t *key;
167 : : uint16_t *queue;
168 : : };
169 : :
170 : : struct policy_actions {
171 : : uint32_t action_fate;
172 : : union {
173 : : uint16_t queue;
174 : : uint32_t mtr_id;
175 : : struct action_rss *rss_desc;
176 : : bool skip_red;
177 : : };
178 : : };
179 : :
180 : : struct cnxk_mtr_policy_node {
181 : : TAILQ_ENTRY(cnxk_mtr_policy_node) next;
182 : : /**< Pointer to the next flow meter structure. */
183 : : uint32_t id; /**< Policy id */
184 : : uint32_t mtr_id; /** Meter id */
185 : : struct rte_mtr_meter_policy_params policy;
186 : : struct policy_actions actions[RTE_COLORS];
187 : : uint32_t ref_cnt;
188 : : };
189 : :
190 : : struct cnxk_mtr_profile_node {
191 : : TAILQ_ENTRY(cnxk_mtr_profile_node) next;
192 : : struct rte_mtr_meter_profile profile; /**< Profile detail. */
193 : : uint32_t ref_cnt; /**< Use count. */
194 : : uint32_t id; /**< Profile id. */
195 : : };
196 : :
197 : : TAILQ_HEAD(cnxk_mtr_profiles, cnxk_mtr_profile_node);
198 : : TAILQ_HEAD(cnxk_mtr_policy, cnxk_mtr_policy_node);
199 : : TAILQ_HEAD(cnxk_mtr, cnxk_meter_node);
200 : :
201 : : /* Security session private data */
202 : : struct cnxk_eth_sec_sess {
203 : : /* List entry */
204 : : TAILQ_ENTRY(cnxk_eth_sec_sess) entry;
205 : :
206 : : /* Inbound SA is from NIX_RX_IPSEC_SA_BASE or
207 : : * Outbound SA from roc_nix_inl_outb_sa_base_get()
208 : : */
209 : : void *sa;
210 : :
211 : : /* SA index */
212 : : uint32_t sa_idx;
213 : :
214 : : /* SPI */
215 : : uint32_t spi;
216 : :
217 : : /* Back pointer to session */
218 : : struct rte_security_session *sess;
219 : :
220 : : /* Inbound */
221 : : bool inb;
222 : :
223 : : /* Inbound session on inl dev */
224 : : bool inl_dev;
225 : :
226 : : /* Out-Of-Place processing */
227 : : bool inb_oop;
228 : :
229 : : /* Back pointer to eth_dev for port_id derivation in CQ callbacks */
230 : : struct rte_eth_dev *eth_dev;
231 : : };
232 : :
233 : : TAILQ_HEAD(cnxk_eth_sec_sess_list, cnxk_eth_sec_sess);
234 : :
235 : : /* Inbound security data */
236 : : struct cnxk_eth_dev_sec_inb {
237 : : /* IPSec inbound min SPI */
238 : : uint32_t min_spi;
239 : :
240 : : /* IPSec inbound max SPI */
241 : : uint32_t max_spi;
242 : :
243 : : /* Using inbound with inline device */
244 : : bool inl_dev;
245 : :
246 : : /* Device argument to disable inline device usage for inb */
247 : : bool no_inl_dev;
248 : :
249 : : /* Active sessions */
250 : : uint16_t nb_sess;
251 : :
252 : : /* List of sessions */
253 : : struct cnxk_eth_sec_sess_list list;
254 : :
255 : : /* DPTR for WRITE_SA microcode op */
256 : : void *sa_dptr;
257 : :
258 : : /* Number of oop sessions */
259 : : uint16_t nb_oop;
260 : :
261 : : /* Reassembly enabled */
262 : : bool reass_en;
263 : :
264 : : /* Lock to synchronize sa setup/release */
265 : : rte_spinlock_t lock;
266 : :
267 : : /* Disable custom meta aura */
268 : : bool custom_meta_aura_dis;
269 : :
270 : : /* Inline device CPT queue info */
271 : : struct roc_nix_inl_dev_q *inl_dev_q;
272 : : };
273 : :
274 : : /* Outbound security data */
275 : : struct cnxk_eth_dev_sec_outb {
276 : : /* IPSec outbound max SA */
277 : : uint16_t max_sa;
278 : :
279 : : /* Per CPT LF descriptor count */
280 : : uint32_t nb_desc;
281 : :
282 : : /* SA Bitmap */
283 : : struct plt_bitmap *sa_bmap;
284 : :
285 : : /* SA bitmap memory */
286 : : void *sa_bmap_mem;
287 : :
288 : : /* SA base */
289 : : uint64_t sa_base;
290 : :
291 : : /* CPT LF base */
292 : : struct roc_cpt_lf *lf_base;
293 : :
294 : : /* Crypto queues => CPT lf count */
295 : : uint16_t nb_crypto_qs;
296 : :
297 : : /* FC sw mem */
298 : : uint64_t *fc_sw_mem;
299 : :
300 : : /* Active sessions */
301 : : uint16_t nb_sess;
302 : :
303 : : /* List of sessions */
304 : : struct cnxk_eth_sec_sess_list list;
305 : :
306 : : /* DPTR for WRITE_SA microcode op */
307 : : void *sa_dptr;
308 : :
309 : : /* Lock to synchronize sa setup/release */
310 : : rte_spinlock_t lock;
311 : :
312 : : /* Engine caps */
313 : : uint64_t cpt_eng_caps;
314 : : };
315 : :
316 : : /* MACsec session private data */
317 : : struct cnxk_macsec_sess {
318 : : /* List entry */
319 : : TAILQ_ENTRY(cnxk_macsec_sess) entry;
320 : :
321 : : /* Back pointer to session */
322 : : struct rte_security_session *sess;
323 : : enum mcs_direction dir;
324 : : uint64_t sci;
325 : : uint8_t secy_id;
326 : : uint8_t sc_id;
327 : : uint8_t flow_id;
328 : : };
329 : : TAILQ_HEAD(cnxk_macsec_sess_list, cnxk_macsec_sess);
330 : :
331 : : struct cnxk_eth_dev {
332 : : /* ROC NIX */
333 : : struct roc_nix nix;
334 : :
335 : : /* ROC NPC */
336 : : struct roc_npc npc;
337 : :
338 : : /* ROC RQs, SQs and CQs */
339 : : struct roc_nix_rq *rqs;
340 : : struct roc_nix_sq *sqs;
341 : : struct roc_nix_cq *cqs;
342 : :
343 : : /* Configured queue count */
344 : : uint16_t nb_rxq;
345 : : uint16_t nb_txq;
346 : : uint16_t nb_rxq_sso;
347 : : uint8_t configured;
348 : :
349 : : /* Max macfilter entries */
350 : : uint8_t dmac_filter_count;
351 : : uint8_t max_mac_entries;
352 : : bool dmac_filter_enable;
353 : : int *dmac_idx_map;
354 : : struct rte_ether_addr *dmac_addrs;
355 : :
356 : : uint16_t flags;
357 : : uint8_t ptype_disable;
358 : : bool scalar_ena;
359 : : bool tx_compl_ena;
360 : : bool tx_mark;
361 : : bool ptp_en;
362 : :
363 : : /* Pointer back to rte */
364 : : struct rte_eth_dev *eth_dev;
365 : :
366 : : /* HW capabilities / Limitations */
367 : : union {
368 : : struct {
369 : : uint64_t cq_min_4k : 1;
370 : : uint64_t ipsecd_drop_re_dis : 1;
371 : : uint64_t vec_drop_re_dis : 1;
372 : : };
373 : : uint64_t hwcap;
374 : : };
375 : :
376 : : /* Rx and Tx offload capabilities */
377 : : uint64_t rx_offload_capa;
378 : : uint64_t tx_offload_capa;
379 : : uint32_t speed_capa;
380 : : uint8_t link_type;
381 : : /* Configured Rx and Tx offloads */
382 : : uint64_t rx_offloads;
383 : : uint64_t tx_offloads;
384 : : /* Platform specific offload flags */
385 : : uint16_t rx_offload_flags;
386 : : uint16_t tx_offload_flags;
387 : :
388 : : /* ETHDEV RSS HF bitmask */
389 : : uint64_t ethdev_rss_hf;
390 : :
391 : : /* Saved qconf before lf realloc */
392 : : struct cnxk_eth_qconf *tx_qconf;
393 : : struct cnxk_eth_qconf *rx_qconf;
394 : :
395 : : /* Flow control configuration */
396 : : struct cnxk_pfc_cfg pfc_cfg;
397 : : struct cnxk_fc_cfg fc_cfg;
398 : :
399 : : /* PTP Counters */
400 : : struct cnxk_timesync_info tstamp;
401 : : struct rte_timecounter systime_tc;
402 : : struct rte_timecounter rx_tstamp_tc;
403 : : struct rte_timecounter tx_tstamp_tc;
404 : : double clk_freq_mult;
405 : : uint64_t clk_delta;
406 : :
407 : : /* Ingress policer */
408 : : enum roc_nix_bpf_color precolor_tbl[ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP];
409 : : enum rte_mtr_color_in_protocol proto;
410 : : struct cnxk_mtr_profiles mtr_profiles;
411 : : struct cnxk_mtr_policy mtr_policy;
412 : : struct cnxk_mtr mtr;
413 : :
414 : : /* Congestion Management */
415 : : struct rte_eth_cman_config cman_cfg;
416 : :
417 : : /* Rx burst for cleanup(Only Primary) */
418 : : eth_rx_burst_t rx_pkt_burst_no_offload;
419 : :
420 : : /* Default mac address */
421 : : uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
422 : :
423 : : /* LSO Tunnel format indices */
424 : : uint64_t lso_tun_fmt;
425 : :
426 : : /* Per queue statistics counters */
427 : : uint32_t txq_stat_map[RTE_ETHDEV_QUEUE_STAT_CNTRS];
428 : : uint32_t rxq_stat_map[RTE_ETHDEV_QUEUE_STAT_CNTRS];
429 : :
430 : : /* Security data */
431 : : struct cnxk_eth_dev_sec_inb inb;
432 : : struct cnxk_eth_dev_sec_outb outb;
433 : :
434 : : /* Reassembly dynfield/flag offsets */
435 : : int reass_dynfield_off;
436 : : int reass_dynflag_bit;
437 : : uint32_t ip_reass_rule_id;
438 : : bool ip_reass_en;
439 : :
440 : : /* MCS device */
441 : : struct cnxk_mcs_dev *mcs_dev;
442 : : struct cnxk_macsec_sess_list mcs_list;
443 : :
444 : : /* Inject packets */
445 : : struct cnxk_ethdev_inj_cfg inj_cfg;
446 : :
447 : : /* Eswitch domain ID */
448 : : uint16_t switch_domain_id;
449 : :
450 : : /* SSO event dev */
451 : : void *evdev_priv;
452 : :
453 : : /* SSO event dev ptp */
454 : : void (*cnxk_sso_ptp_tstamp_cb)
455 : : (uint16_t port_id, uint16_t flags, bool ptp_en);
456 : : };
457 : :
458 : : struct cnxk_eth_rxq_sp {
459 : : struct cnxk_eth_dev *dev;
460 : : struct cnxk_eth_qconf qconf;
461 : : uint16_t qid;
462 : : uint8_t tx_pause;
463 : : uint8_t tc;
464 : : } __plt_cache_aligned;
465 : :
466 : : struct cnxk_eth_txq_sp {
467 : : struct cnxk_eth_dev *dev;
468 : : struct cnxk_eth_qconf qconf;
469 : : uint16_t qid;
470 : : } __plt_cache_aligned;
471 : :
472 : : static inline struct cnxk_eth_dev *
473 : : cnxk_eth_pmd_priv(const struct rte_eth_dev *eth_dev)
474 : : {
475 [ + - # # : 4 : return eth_dev->data->dev_private;
# # # # #
# # # # #
# # # # #
# # # # #
# # # # ]
476 : : }
477 : :
478 : : static inline struct cnxk_eth_rxq_sp *
479 : : cnxk_eth_rxq_to_sp(void *__rxq)
480 : : {
481 : 0 : return ((struct cnxk_eth_rxq_sp *)__rxq) - 1;
482 : : }
483 : :
484 : : static inline struct cnxk_eth_txq_sp *
485 : : cnxk_eth_txq_to_sp(void *__txq)
486 : : {
487 : 0 : return ((struct cnxk_eth_txq_sp *)__txq) - 1;
488 : : }
489 : :
490 : : static inline int
491 : : cnxk_nix_tx_queue_count(uint64_t *mem, uint16_t sqes_per_sqb_log2)
492 : : {
493 : : uint64_t val;
494 : :
495 : : val = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t)*)mem, rte_memory_order_relaxed);
496 : : val = (val << sqes_per_sqb_log2) - val;
497 : :
498 : : return (val & 0xFFFF);
499 : : }
500 : :
501 : : static inline int
502 : : cnxk_nix_tx_queue_sec_count(uint64_t *mem, uint16_t sqes_per_sqb_log2, uint64_t *sec_fc)
503 : : {
504 : : uint64_t sq_cnt, sec_cnt, val;
505 : :
506 : : sq_cnt = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t)*)mem, rte_memory_order_relaxed);
507 : : sq_cnt = (sq_cnt << sqes_per_sqb_log2) - sq_cnt;
508 : : sec_cnt = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t)*)sec_fc,
509 : : rte_memory_order_relaxed);
510 : : val = RTE_MAX(sq_cnt, sec_cnt);
511 : :
512 : : return (val & 0xFFFF);
513 : : }
514 : :
515 : : static inline int
516 : 0 : cnxk_nix_inl_fc_check(uint64_t __rte_atomic *fc, int32_t *fc_sw, uint32_t nb_desc, uint16_t nb_inst)
517 : : {
518 : : uint8_t retry_count = 32;
519 : : int32_t val, newval;
520 : :
521 : : /* Check if there is any CPT instruction to submit */
522 [ # # ]: 0 : if (!nb_inst)
523 : : return -EINVAL;
524 : :
525 : 0 : retry:
526 : 0 : val = rte_atomic_fetch_sub_explicit((RTE_ATOMIC(int32_t)*)fc_sw, nb_inst,
527 : 0 : rte_memory_order_relaxed) - nb_inst;
528 [ # # ]: 0 : if (likely(val >= 0))
529 : : return 0;
530 : :
531 : 0 : newval = (int64_t)nb_desc - rte_atomic_load_explicit((RTE_ATOMIC(uint64_t)*)fc,
532 : : rte_memory_order_relaxed);
533 : 0 : newval -= nb_inst;
534 : :
535 [ # # ]: 0 : if (!rte_atomic_compare_exchange_strong_explicit((RTE_ATOMIC(int32_t)*)fc_sw, &val, newval,
536 : : rte_memory_order_release,
537 : : rte_memory_order_relaxed)) {
538 [ # # ]: 0 : if (retry_count) {
539 : 0 : retry_count--;
540 : 0 : goto retry;
541 : : } else {
542 : : return -EAGAIN;
543 : : }
544 : : }
545 [ # # ]: 0 : if (unlikely(newval < 0))
546 : 0 : return -EAGAIN;
547 : :
548 : : return 0;
549 : : }
550 : :
551 : : /* Common ethdev ops */
552 : : extern struct eth_dev_ops cnxk_eth_dev_ops;
553 : :
554 : : /* Common flow ops */
555 : : extern struct rte_flow_ops cnxk_flow_ops;
556 : :
557 : : /* Common security ops */
558 : : extern struct rte_security_ops cnxk_eth_sec_ops;
559 : :
560 : : /* Common tm ops */
561 : : extern struct rte_tm_ops cnxk_tm_ops;
562 : :
563 : : /* Platform specific rte pmd cnxk ops */
564 : : typedef uint16_t (*cnxk_inl_dev_submit_cb_t)(struct roc_nix_inl_dev_q *q, void *inst,
565 : : uint16_t nb_inst);
566 : :
567 : : typedef void (*cnxk_ethdev_rx_offload_cb_t)(uint16_t port_id, uint64_t flags);
568 : :
569 : : extern cnxk_ethdev_rx_offload_cb_t cnxk_ethdev_rx_offload_cb;
570 : :
571 : : struct cnxk_ethdev_pmd_ops {
572 : : cnxk_inl_dev_submit_cb_t inl_dev_submit;
573 : : };
574 : : extern struct cnxk_ethdev_pmd_ops cnxk_pmd_ops;
575 : :
576 : : /* Ops */
577 : : int cnxk_nix_probe(struct rte_pci_driver *pci_drv,
578 : : struct rte_pci_device *pci_dev);
579 : : int cnxk_nix_remove(struct rte_pci_device *pci_dev);
580 : : int cnxk_nix_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu);
581 : : int cnxk_nix_sq_flush(struct rte_eth_dev *eth_dev);
582 : : int cnxk_nix_mc_addr_list_configure(struct rte_eth_dev *eth_dev,
583 : : struct rte_ether_addr *mc_addr_set,
584 : : uint32_t nb_mc_addr);
585 : : int cnxk_nix_mac_addr_add(struct rte_eth_dev *eth_dev,
586 : : struct rte_ether_addr *addr, uint32_t index,
587 : : uint32_t pool);
588 : : void cnxk_nix_mac_addr_del(struct rte_eth_dev *eth_dev, uint32_t index);
589 : : int cnxk_nix_mac_addr_set(struct rte_eth_dev *eth_dev,
590 : : struct rte_ether_addr *addr);
591 : : int cnxk_nix_promisc_enable(struct rte_eth_dev *eth_dev);
592 : : int cnxk_nix_promisc_disable(struct rte_eth_dev *eth_dev);
593 : : int cnxk_nix_allmulticast_enable(struct rte_eth_dev *eth_dev);
594 : : int cnxk_nix_allmulticast_disable(struct rte_eth_dev *eth_dev);
595 : : int cnxk_nix_info_get(struct rte_eth_dev *eth_dev,
596 : : struct rte_eth_dev_info *dev_info);
597 : : int cnxk_nix_rx_burst_mode_get(struct rte_eth_dev *eth_dev, uint16_t queue_id,
598 : : struct rte_eth_burst_mode *mode);
599 : : int cnxk_nix_tx_burst_mode_get(struct rte_eth_dev *eth_dev, uint16_t queue_id,
600 : : struct rte_eth_burst_mode *mode);
601 : : int cnxk_nix_flow_ctrl_set(struct rte_eth_dev *eth_dev,
602 : : struct rte_eth_fc_conf *fc_conf);
603 : : int cnxk_nix_flow_ctrl_get(struct rte_eth_dev *eth_dev,
604 : : struct rte_eth_fc_conf *fc_conf);
605 : : int cnxk_nix_priority_flow_ctrl_queue_config(struct rte_eth_dev *eth_dev,
606 : : struct rte_eth_pfc_queue_conf *pfc_conf);
607 : : int cnxk_nix_priority_flow_ctrl_queue_info_get(struct rte_eth_dev *eth_dev,
608 : : struct rte_eth_pfc_queue_info *pfc_info);
609 : : int cnxk_nix_set_link_up(struct rte_eth_dev *eth_dev);
610 : : int cnxk_nix_set_link_down(struct rte_eth_dev *eth_dev);
611 : : int cnxk_nix_get_module_info(struct rte_eth_dev *eth_dev,
612 : : struct rte_eth_dev_module_info *modinfo);
613 : : int cnxk_nix_get_module_eeprom(struct rte_eth_dev *eth_dev,
614 : : struct rte_dev_eeprom_info *info);
615 : : int cnxk_nix_rx_queue_intr_enable(struct rte_eth_dev *eth_dev,
616 : : uint16_t rx_queue_id);
617 : : int cnxk_nix_rx_queue_intr_disable(struct rte_eth_dev *eth_dev,
618 : : uint16_t rx_queue_id);
619 : : int cnxk_nix_pool_ops_supported(struct rte_eth_dev *eth_dev, const char *pool);
620 : : int cnxk_nix_tx_done_cleanup(void *txq, uint32_t free_cnt);
621 : : int cnxk_nix_flow_ops_get(struct rte_eth_dev *eth_dev,
622 : : const struct rte_flow_ops **ops);
623 : : int cnxk_nix_configure(struct rte_eth_dev *eth_dev);
624 : : int cnxk_nix_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t qid,
625 : : uint16_t nb_desc, uint16_t fp_tx_q_sz,
626 : : const struct rte_eth_txconf *tx_conf);
627 : : int cnxk_nix_rx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t qid,
628 : : uint32_t nb_desc, uint16_t fp_rx_q_sz,
629 : : const struct rte_eth_rxconf *rx_conf,
630 : : struct rte_mempool *mp);
631 : : int cnxk_nix_tx_queue_start(struct rte_eth_dev *eth_dev, uint16_t qid);
632 : : void cnxk_nix_tx_queue_release(struct rte_eth_dev *eth_dev, uint16_t qid);
633 : : int cnxk_nix_tx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t qid);
634 : : int cnxk_nix_dev_start(struct rte_eth_dev *eth_dev);
635 : : int cnxk_nix_timesync_enable(struct rte_eth_dev *eth_dev);
636 : : int cnxk_nix_timesync_disable(struct rte_eth_dev *eth_dev);
637 : : int cnxk_nix_timesync_read_rx_timestamp(struct rte_eth_dev *eth_dev,
638 : : struct timespec *timestamp,
639 : : uint32_t flags);
640 : : int cnxk_nix_timesync_read_tx_timestamp(struct rte_eth_dev *eth_dev,
641 : : struct timespec *timestamp);
642 : : int cnxk_nix_timesync_read_time(struct rte_eth_dev *eth_dev,
643 : : struct timespec *ts);
644 : : int cnxk_nix_timesync_write_time(struct rte_eth_dev *eth_dev,
645 : : const struct timespec *ts);
646 : : int cnxk_nix_timesync_adjust_time(struct rte_eth_dev *eth_dev, int64_t delta);
647 : : int cnxk_nix_tsc_convert(struct cnxk_eth_dev *dev);
648 : : int cnxk_nix_read_clock(struct rte_eth_dev *eth_dev, uint64_t *clock);
649 : :
650 : : uint64_t cnxk_nix_rxq_mbuf_setup(struct cnxk_eth_dev *dev);
651 : : int cnxk_nix_tm_ops_get(struct rte_eth_dev *eth_dev, void *ops);
652 : : int cnxk_nix_tm_set_queue_rate_limit(struct rte_eth_dev *eth_dev,
653 : : uint16_t queue_idx, uint32_t tx_rate);
654 : : int cnxk_nix_tm_mark_vlan_dei(struct rte_eth_dev *eth_dev, int mark_green,
655 : : int mark_yellow, int mark_red,
656 : : struct rte_tm_error *error);
657 : : int cnxk_nix_ip_reass_rule_clr(struct rte_eth_dev *eth_dev);
658 : : int cnxk_nix_ip_reass_rule_set(struct rte_eth_dev *eth_dev, uint32_t rq);
659 : : int cnxk_nix_inl_inb_fini(struct cnxk_eth_dev *dev);
660 : :
661 : : int cnxk_nix_tm_mark_ip_ecn(struct rte_eth_dev *eth_dev, int mark_green,
662 : : int mark_yellow, int mark_red,
663 : : struct rte_tm_error *error);
664 : : int cnxk_nix_tm_mark_ip_dscp(struct rte_eth_dev *eth_dev, int mark_green,
665 : : int mark_yellow, int mark_red,
666 : : struct rte_tm_error *error);
667 : : int cnxk_nix_tx_descriptor_dump(const struct rte_eth_dev *eth_dev, uint16_t qid, uint16_t offset,
668 : : uint16_t num, FILE *file);
669 : :
670 : : /* FEC */
671 : : int cnxk_nix_fec_get_capability(struct rte_eth_dev *eth_dev,
672 : : struct rte_eth_fec_capa *speed_fec_capa, unsigned int num);
673 : : int cnxk_nix_fec_get(struct rte_eth_dev *eth_dev, uint32_t *fec_capa);
674 : : int cnxk_nix_fec_set(struct rte_eth_dev *eth_dev, uint32_t fec_capa);
675 : :
676 : : /* MTR */
677 : : int cnxk_nix_mtr_ops_get(struct rte_eth_dev *dev, void *ops);
678 : :
679 : : /* RSS */
680 : : uint32_t cnxk_rss_ethdev_to_nix(struct cnxk_eth_dev *dev, uint64_t ethdev_rss,
681 : : uint8_t rss_level);
682 : : int cnxk_nix_reta_update(struct rte_eth_dev *eth_dev,
683 : : struct rte_eth_rss_reta_entry64 *reta_conf,
684 : : uint16_t reta_size);
685 : : int cnxk_nix_reta_query(struct rte_eth_dev *eth_dev,
686 : : struct rte_eth_rss_reta_entry64 *reta_conf,
687 : : uint16_t reta_size);
688 : : int cnxk_nix_rss_hash_update(struct rte_eth_dev *eth_dev,
689 : : struct rte_eth_rss_conf *rss_conf);
690 : : int cnxk_nix_rss_hash_conf_get(struct rte_eth_dev *eth_dev,
691 : : struct rte_eth_rss_conf *rss_conf);
692 : : int cnxk_nix_eth_dev_priv_dump(struct rte_eth_dev *eth_dev, FILE *file);
693 : :
694 : : /* Link */
695 : : void cnxk_nix_toggle_flag_link_cfg(struct cnxk_eth_dev *dev, bool set);
696 : : void cnxk_eth_dev_link_status_cb(struct roc_nix *nix,
697 : : struct roc_nix_link_info *link);
698 : : void cnxk_eth_dev_link_status_get_cb(struct roc_nix *nix,
699 : : struct roc_nix_link_info *link);
700 : : void cnxk_eth_dev_q_err_cb(struct roc_nix *nix, void *data);
701 : : int cnxk_nix_link_info_configure(struct rte_eth_dev *eth_dev);
702 : : int cnxk_nix_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete);
703 : : int cnxk_nix_queue_stats_mapping(struct rte_eth_dev *dev, uint16_t queue_id,
704 : : uint8_t stat_idx, uint8_t is_rx);
705 : : int cnxk_nix_stats_reset(struct rte_eth_dev *dev);
706 : : int cnxk_nix_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats,
707 : : struct eth_queue_stats *qstats);
708 : : int cnxk_nix_xstats_get(struct rte_eth_dev *eth_dev,
709 : : struct rte_eth_xstat *xstats, unsigned int n);
710 : : int cnxk_nix_xstats_get_names(struct rte_eth_dev *eth_dev,
711 : : struct rte_eth_xstat_name *xstats_names,
712 : : unsigned int limit);
713 : : int cnxk_nix_xstats_get_names_by_id(struct rte_eth_dev *eth_dev,
714 : : const uint64_t *ids,
715 : : struct rte_eth_xstat_name *xstats_names,
716 : : unsigned int limit);
717 : : int cnxk_nix_xstats_get_by_id(struct rte_eth_dev *eth_dev, const uint64_t *ids,
718 : : uint64_t *values, unsigned int n);
719 : : int cnxk_nix_xstats_reset(struct rte_eth_dev *eth_dev);
720 : : int cnxk_nix_fw_version_get(struct rte_eth_dev *eth_dev, char *fw_version,
721 : : size_t fw_size);
722 : : void cnxk_nix_rxq_info_get(struct rte_eth_dev *eth_dev, uint16_t qid,
723 : : struct rte_eth_rxq_info *qinfo);
724 : : void cnxk_nix_txq_info_get(struct rte_eth_dev *eth_dev, uint16_t qid,
725 : : struct rte_eth_txq_info *qinfo);
726 : :
727 : : /* Queue status */
728 : : int cnxk_nix_rx_descriptor_status(void *rxq, uint16_t offset);
729 : : int cnxk_nix_tx_descriptor_status(void *txq, uint16_t offset);
730 : : int cnxk_nix_rx_queue_count(void *rxq);
731 : :
732 : : /* Lookup configuration */
733 : : const uint32_t *cnxk_nix_supported_ptypes_get(struct rte_eth_dev *eth_dev,
734 : : size_t *no_of_elements);
735 : : void *cnxk_nix_fastpath_lookup_mem_get(void);
736 : :
737 : : /* Devargs */
738 : : int cnxk_ethdev_parse_devargs(struct rte_devargs *devargs,
739 : : struct cnxk_eth_dev *dev);
740 : :
741 : : /* Debug */
742 : : int cnxk_nix_dev_get_reg(struct rte_eth_dev *eth_dev,
743 : : struct rte_dev_reg_info *regs);
744 : : /* Security */
745 : : int cnxk_eth_outb_sa_idx_get(struct cnxk_eth_dev *dev, uint32_t *idx_p,
746 : : uint32_t spi);
747 : : int cnxk_eth_outb_sa_idx_put(struct cnxk_eth_dev *dev, uint32_t idx);
748 : : int cnxk_nix_lookup_mem_sa_base_set(struct cnxk_eth_dev *dev);
749 : : int cnxk_nix_lookup_mem_sa_base_clear(struct cnxk_eth_dev *dev);
750 : : int cnxk_nix_lookup_mem_metapool_set(struct cnxk_eth_dev *dev);
751 : : int cnxk_nix_lookup_mem_metapool_clear(struct cnxk_eth_dev *dev);
752 : : int cnxk_nix_lookup_mem_bufsize_set(struct cnxk_eth_dev *dev, uint64_t size);
753 : : int cnxk_nix_lookup_mem_bufsize_clear(struct cnxk_eth_dev *dev);
754 : :
755 : : __rte_internal
756 : : int cnxk_nix_inb_mode_set(struct cnxk_eth_dev *dev, bool use_inl_dev);
757 : :
758 : : __rte_internal
759 : : void cnxk_ethdev_rx_offload_cb_register(cnxk_ethdev_rx_offload_cb_t cb);
760 : :
761 : : int cnxk_nix_inline_inbound_setup(struct cnxk_eth_dev *dev);
762 : : int cnxk_nix_inline_inbound_mode_setup(struct cnxk_eth_dev *dev);
763 : :
764 : : struct cnxk_eth_sec_sess *cnxk_eth_sec_sess_get_by_sa_idx(struct cnxk_eth_dev *dev,
765 : : uint32_t sa_idx, bool inb);
766 : : struct cnxk_eth_sec_sess *cnxk_eth_sec_sess_get_by_sess(struct cnxk_eth_dev *dev,
767 : : const struct rte_security_session *sess);
768 : :
769 : : int cnxk_nix_inl_meta_pool_cb(uint64_t *aura_handle, uintptr_t *mpool, uint32_t buf_sz,
770 : : uint32_t nb_bufs, bool destroy, const char *mempool_name);
771 : : int cnxk_nix_inl_custom_meta_pool_cb(uintptr_t pmpool, uintptr_t *mpool, const char *mempool_name,
772 : : uint64_t *aura_handle, uint32_t buf_sz, uint32_t nb_bufs,
773 : : bool destroy);
774 : :
775 : : /* Congestion Management */
776 : : int cnxk_nix_cman_info_get(struct rte_eth_dev *dev, struct rte_eth_cman_info *info);
777 : :
778 : : int cnxk_nix_cman_config_init(struct rte_eth_dev *dev, struct rte_eth_cman_config *config);
779 : :
780 : : int cnxk_nix_cman_config_set(struct rte_eth_dev *dev, const struct rte_eth_cman_config *config);
781 : :
782 : : int cnxk_nix_cman_config_get(struct rte_eth_dev *dev, struct rte_eth_cman_config *config);
783 : :
784 : : int cnxk_mcs_dev_init(struct cnxk_eth_dev *dev, uint8_t mcs_idx);
785 : : void cnxk_mcs_dev_fini(struct cnxk_eth_dev *dev);
786 : :
787 : : struct cnxk_macsec_sess *cnxk_eth_macsec_sess_get_by_sess(struct cnxk_eth_dev *dev,
788 : : const struct rte_security_session *sess);
789 : : int cnxk_mcs_flow_configure(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
790 : : const struct rte_flow_item pattern[],
791 : : const struct rte_flow_action actions[], struct rte_flow_error *error,
792 : : void **mcs_flow);
793 : : int cnxk_mcs_flow_destroy(struct cnxk_eth_dev *eth_dev, void *mcs_flow);
794 : :
795 : : /* Other private functions */
796 : : int nix_recalc_mtu(struct rte_eth_dev *eth_dev);
797 : : int nix_mtr_validate(struct rte_eth_dev *dev, uint32_t id);
798 : : int nix_mtr_policy_act_get(struct rte_eth_dev *eth_dev, uint32_t id,
799 : : struct cnxk_mtr_policy_node **policy);
800 : : int nix_mtr_rq_update(struct rte_eth_dev *eth_dev, uint32_t id,
801 : : uint32_t queue_num, const uint16_t *queue);
802 : : int nix_mtr_chain_update(struct rte_eth_dev *eth_dev, uint32_t cur_id,
803 : : uint32_t prev_id, uint32_t next_id);
804 : : int nix_mtr_chain_reset(struct rte_eth_dev *eth_dev, uint32_t cur_id);
805 : : struct cnxk_meter_node *nix_get_mtr(struct rte_eth_dev *eth_dev,
806 : : uint32_t cur_id);
807 : : int nix_mtr_level_update(struct rte_eth_dev *eth_dev, uint32_t id,
808 : : uint32_t level);
809 : : int nix_mtr_capabilities_init(struct rte_eth_dev *eth_dev);
810 : : int nix_mtr_configure(struct rte_eth_dev *eth_dev, uint32_t id);
811 : : int nix_mtr_connect(struct rte_eth_dev *eth_dev, uint32_t id);
812 : : int nix_mtr_destroy(struct rte_eth_dev *eth_dev, uint32_t id,
813 : : struct rte_mtr_error *error);
814 : : int nix_mtr_color_action_validate(struct rte_eth_dev *eth_dev, uint32_t id,
815 : : uint32_t *prev_id, uint32_t *next_id,
816 : : struct cnxk_mtr_policy_node *policy,
817 : : int *tree_level);
818 : : int nix_priority_flow_ctrl_rq_conf(struct rte_eth_dev *eth_dev, uint16_t qid,
819 : : uint8_t tx_pause, uint8_t tc);
820 : : int nix_priority_flow_ctrl_sq_conf(struct rte_eth_dev *eth_dev, uint16_t qid,
821 : : uint8_t rx_pause, uint8_t tc);
822 : :
823 : : #endif /* __CNXK_ETHDEV_H__ */
|