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