net/cnxk: add Rx metadata negotiate operation
[dpdk.git] / drivers / net / cnxk / cn10k_ethdev.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2021 Marvell.
3  */
4 #include "cn10k_ethdev.h"
5 #include "cn10k_flow.h"
6 #include "cn10k_rx.h"
7 #include "cn10k_tx.h"
8
9 static uint16_t
10 nix_rx_offload_flags(struct rte_eth_dev *eth_dev)
11 {
12         struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
13         struct rte_eth_dev_data *data = eth_dev->data;
14         struct rte_eth_conf *conf = &data->dev_conf;
15         struct rte_eth_rxmode *rxmode = &conf->rxmode;
16         uint16_t flags = 0;
17
18         if (rxmode->mq_mode == RTE_ETH_MQ_RX_RSS &&
19             (dev->rx_offloads & RTE_ETH_RX_OFFLOAD_RSS_HASH))
20                 flags |= NIX_RX_OFFLOAD_RSS_F;
21
22         if (dev->rx_offloads &
23             (RTE_ETH_RX_OFFLOAD_TCP_CKSUM | RTE_ETH_RX_OFFLOAD_UDP_CKSUM))
24                 flags |= NIX_RX_OFFLOAD_CHECKSUM_F;
25
26         if (dev->rx_offloads &
27             (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM))
28                 flags |= NIX_RX_OFFLOAD_CHECKSUM_F;
29
30         if (dev->rx_offloads & RTE_ETH_RX_OFFLOAD_SCATTER)
31                 flags |= NIX_RX_MULTI_SEG_F;
32
33         if ((dev->rx_offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP))
34                 flags |= NIX_RX_OFFLOAD_TSTAMP_F;
35
36         if (!dev->ptype_disable)
37                 flags |= NIX_RX_OFFLOAD_PTYPE_F;
38
39         if (dev->rx_offloads & RTE_ETH_RX_OFFLOAD_SECURITY)
40                 flags |= NIX_RX_OFFLOAD_SECURITY_F;
41
42         if (dev->rx_mark_update)
43                 flags |= NIX_RX_OFFLOAD_MARK_UPDATE_F;
44
45         return flags;
46 }
47
48 static uint16_t
49 nix_tx_offload_flags(struct rte_eth_dev *eth_dev)
50 {
51         struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
52         uint64_t conf = dev->tx_offloads;
53         uint16_t flags = 0;
54
55         /* Fastpath is dependent on these enums */
56         RTE_BUILD_BUG_ON(RTE_MBUF_F_TX_TCP_CKSUM != (1ULL << 52));
57         RTE_BUILD_BUG_ON(RTE_MBUF_F_TX_SCTP_CKSUM != (2ULL << 52));
58         RTE_BUILD_BUG_ON(RTE_MBUF_F_TX_UDP_CKSUM != (3ULL << 52));
59         RTE_BUILD_BUG_ON(RTE_MBUF_F_TX_IP_CKSUM != (1ULL << 54));
60         RTE_BUILD_BUG_ON(RTE_MBUF_F_TX_IPV4 != (1ULL << 55));
61         RTE_BUILD_BUG_ON(RTE_MBUF_F_TX_OUTER_IP_CKSUM != (1ULL << 58));
62         RTE_BUILD_BUG_ON(RTE_MBUF_F_TX_OUTER_IPV4 != (1ULL << 59));
63         RTE_BUILD_BUG_ON(RTE_MBUF_F_TX_OUTER_IPV6 != (1ULL << 60));
64         RTE_BUILD_BUG_ON(RTE_MBUF_F_TX_OUTER_UDP_CKSUM != (1ULL << 41));
65         RTE_BUILD_BUG_ON(RTE_MBUF_L2_LEN_BITS != 7);
66         RTE_BUILD_BUG_ON(RTE_MBUF_L3_LEN_BITS != 9);
67         RTE_BUILD_BUG_ON(RTE_MBUF_OUTL2_LEN_BITS != 7);
68         RTE_BUILD_BUG_ON(RTE_MBUF_OUTL3_LEN_BITS != 9);
69         RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_off) !=
70                          offsetof(struct rte_mbuf, buf_iova) + 8);
71         RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
72                          offsetof(struct rte_mbuf, buf_iova) + 16);
73         RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) !=
74                          offsetof(struct rte_mbuf, ol_flags) + 12);
75         RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, tx_offload) !=
76                          offsetof(struct rte_mbuf, pool) + 2 * sizeof(void *));
77
78         if (conf & RTE_ETH_TX_OFFLOAD_VLAN_INSERT ||
79             conf & RTE_ETH_TX_OFFLOAD_QINQ_INSERT)
80                 flags |= NIX_TX_OFFLOAD_VLAN_QINQ_F;
81
82         if (conf & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM ||
83             conf & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
84                 flags |= NIX_TX_OFFLOAD_OL3_OL4_CSUM_F;
85
86         if (conf & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ||
87             conf & RTE_ETH_TX_OFFLOAD_TCP_CKSUM ||
88             conf & RTE_ETH_TX_OFFLOAD_UDP_CKSUM || conf & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)
89                 flags |= NIX_TX_OFFLOAD_L3_L4_CSUM_F;
90
91         if (!(conf & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE))
92                 flags |= NIX_TX_OFFLOAD_MBUF_NOFF_F;
93
94         if (conf & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)
95                 flags |= NIX_TX_MULTI_SEG_F;
96
97         /* Enable Inner checksum for TSO */
98         if (conf & RTE_ETH_TX_OFFLOAD_TCP_TSO)
99                 flags |= (NIX_TX_OFFLOAD_TSO_F | NIX_TX_OFFLOAD_L3_L4_CSUM_F);
100
101         /* Enable Inner and Outer checksum for Tunnel TSO */
102         if (conf & (RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
103                     RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO | RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
104                 flags |= (NIX_TX_OFFLOAD_TSO_F | NIX_TX_OFFLOAD_OL3_OL4_CSUM_F |
105                           NIX_TX_OFFLOAD_L3_L4_CSUM_F);
106
107         if ((dev->rx_offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP))
108                 flags |= NIX_TX_OFFLOAD_TSTAMP_F;
109
110         if (conf & RTE_ETH_TX_OFFLOAD_SECURITY)
111                 flags |= NIX_TX_OFFLOAD_SECURITY_F;
112
113         return flags;
114 }
115
116 static int
117 cn10k_nix_ptypes_set(struct rte_eth_dev *eth_dev, uint32_t ptype_mask)
118 {
119         struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
120
121         if (ptype_mask) {
122                 dev->rx_offload_flags |= NIX_RX_OFFLOAD_PTYPE_F;
123                 dev->ptype_disable = 0;
124         } else {
125                 dev->rx_offload_flags &= ~NIX_RX_OFFLOAD_PTYPE_F;
126                 dev->ptype_disable = 1;
127         }
128
129         cn10k_eth_set_rx_function(eth_dev);
130         return 0;
131 }
132
133 static void
134 nix_form_default_desc(struct cnxk_eth_dev *dev, struct cn10k_eth_txq *txq,
135                       uint16_t qid)
136 {
137         union nix_send_hdr_w0_u send_hdr_w0;
138
139         /* Initialize the fields based on basic single segment packet */
140         send_hdr_w0.u = 0;
141         if (dev->tx_offload_flags & NIX_TX_NEED_EXT_HDR) {
142                 /* 2(HDR) + 2(EXT_HDR) + 1(SG) + 1(IOVA) = 6/2 - 1 = 2 */
143                 send_hdr_w0.sizem1 = 2;
144                 if (dev->tx_offload_flags & NIX_TX_OFFLOAD_TSTAMP_F) {
145                         /* Default: one seg packet would have:
146                          * 2(HDR) + 2(EXT) + 1(SG) + 1(IOVA) + 2(MEM)
147                          * => 8/2 - 1 = 3
148                          */
149                         send_hdr_w0.sizem1 = 3;
150
151                         /* To calculate the offset for send_mem,
152                          * send_hdr->w0.sizem1 * 2
153                          */
154                         txq->ts_mem = dev->tstamp.tx_tstamp_iova;
155                 }
156         } else {
157                 /* 2(HDR) + 1(SG) + 1(IOVA) = 4/2 - 1 = 1 */
158                 send_hdr_w0.sizem1 = 1;
159         }
160         send_hdr_w0.sq = qid;
161         txq->send_hdr_w0 = send_hdr_w0.u;
162         rte_wmb();
163 }
164
165 static int
166 cn10k_nix_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t qid,
167                          uint16_t nb_desc, unsigned int socket,
168                          const struct rte_eth_txconf *tx_conf)
169 {
170         struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
171         struct roc_nix *nix = &dev->nix;
172         struct roc_cpt_lf *inl_lf;
173         struct cn10k_eth_txq *txq;
174         struct roc_nix_sq *sq;
175         uint16_t crypto_qid;
176         int rc;
177
178         RTE_SET_USED(socket);
179
180         /* Common Tx queue setup */
181         rc = cnxk_nix_tx_queue_setup(eth_dev, qid, nb_desc,
182                                      sizeof(struct cn10k_eth_txq), tx_conf);
183         if (rc)
184                 return rc;
185
186         sq = &dev->sqs[qid];
187         /* Update fast path queue */
188         txq = eth_dev->data->tx_queues[qid];
189         txq->fc_mem = sq->fc;
190         /* Store lmt base in tx queue for easy access */
191         txq->lmt_base = nix->lmt_base;
192         txq->io_addr = sq->io_addr;
193         txq->nb_sqb_bufs_adj = sq->nb_sqb_bufs_adj;
194         txq->sqes_per_sqb_log2 = sq->sqes_per_sqb_log2;
195
196         /* Fetch CPT LF info for outbound if present */
197         if (dev->outb.lf_base) {
198                 crypto_qid = qid % dev->outb.nb_crypto_qs;
199                 inl_lf = dev->outb.lf_base + crypto_qid;
200
201                 txq->cpt_io_addr = inl_lf->io_addr;
202                 txq->cpt_fc = inl_lf->fc_addr;
203                 txq->cpt_desc = inl_lf->nb_desc * 0.7;
204                 txq->sa_base = (uint64_t)dev->outb.sa_base;
205                 txq->sa_base |= eth_dev->data->port_id;
206                 PLT_STATIC_ASSERT(ROC_NIX_INL_SA_BASE_ALIGN == BIT_ULL(16));
207         }
208
209         nix_form_default_desc(dev, txq, qid);
210         txq->lso_tun_fmt = dev->lso_tun_fmt;
211         return 0;
212 }
213
214 static int
215 cn10k_nix_rx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t qid,
216                          uint16_t nb_desc, unsigned int socket,
217                          const struct rte_eth_rxconf *rx_conf,
218                          struct rte_mempool *mp)
219 {
220         struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
221         struct cnxk_eth_rxq_sp *rxq_sp;
222         struct cn10k_eth_rxq *rxq;
223         struct roc_nix_rq *rq;
224         struct roc_nix_cq *cq;
225         int rc;
226
227         RTE_SET_USED(socket);
228
229         /* CQ Errata needs min 4K ring */
230         if (dev->cq_min_4k && nb_desc < 4096)
231                 nb_desc = 4096;
232
233         /* Common Rx queue setup */
234         rc = cnxk_nix_rx_queue_setup(eth_dev, qid, nb_desc,
235                                      sizeof(struct cn10k_eth_rxq), rx_conf, mp);
236         if (rc)
237                 return rc;
238
239         rq = &dev->rqs[qid];
240         cq = &dev->cqs[qid];
241
242         /* Update fast path queue */
243         rxq = eth_dev->data->rx_queues[qid];
244         rxq->rq = qid;
245         rxq->desc = (uintptr_t)cq->desc_base;
246         rxq->cq_door = cq->door;
247         rxq->cq_status = cq->status;
248         rxq->wdata = cq->wdata;
249         rxq->head = cq->head;
250         rxq->qmask = cq->qmask;
251         rxq->tstamp = &dev->tstamp;
252
253         /* Data offset from data to start of mbuf is first_skip */
254         rxq->data_off = rq->first_skip;
255         rxq->mbuf_initializer = cnxk_nix_rxq_mbuf_setup(dev);
256
257         /* Setup security related info */
258         if (dev->rx_offload_flags & NIX_RX_OFFLOAD_SECURITY_F) {
259                 rxq->lmt_base = dev->nix.lmt_base;
260                 rxq->sa_base = roc_nix_inl_inb_sa_base_get(&dev->nix,
261                                                            dev->inb.inl_dev);
262         }
263         rxq_sp = cnxk_eth_rxq_to_sp(rxq);
264         rxq->aura_handle = rxq_sp->qconf.mp->pool_id;
265
266         /* Lookup mem */
267         rxq->lookup_mem = cnxk_nix_fastpath_lookup_mem_get();
268         return 0;
269 }
270
271 static int
272 cn10k_nix_tx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t qidx)
273 {
274         struct cn10k_eth_txq *txq = eth_dev->data->tx_queues[qidx];
275         int rc;
276
277         rc = cnxk_nix_tx_queue_stop(eth_dev, qidx);
278         if (rc)
279                 return rc;
280
281         /* Clear fc cache pkts to trigger worker stop */
282         txq->fc_cache_pkts = 0;
283         return 0;
284 }
285
286 static int
287 cn10k_nix_configure(struct rte_eth_dev *eth_dev)
288 {
289         struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
290         int rc;
291
292         /* Common nix configure */
293         rc = cnxk_nix_configure(eth_dev);
294         if (rc)
295                 return rc;
296
297         /* Update offload flags */
298         dev->rx_offload_flags = nix_rx_offload_flags(eth_dev);
299         dev->tx_offload_flags = nix_tx_offload_flags(eth_dev);
300
301         plt_nix_dbg("Configured port%d platform specific rx_offload_flags=%x"
302                     " tx_offload_flags=0x%x",
303                     eth_dev->data->port_id, dev->rx_offload_flags,
304                     dev->tx_offload_flags);
305         return 0;
306 }
307
308 /* Function to enable ptp config for VFs */
309 static void
310 nix_ptp_enable_vf(struct rte_eth_dev *eth_dev)
311 {
312         struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
313
314         if (nix_recalc_mtu(eth_dev))
315                 plt_err("Failed to set MTU size for ptp");
316
317         dev->rx_offload_flags |= NIX_RX_OFFLOAD_TSTAMP_F;
318
319         /* Setting up the function pointers as per new offload flags */
320         cn10k_eth_set_rx_function(eth_dev);
321         cn10k_eth_set_tx_function(eth_dev);
322 }
323
324 static uint16_t
325 nix_ptp_vf_burst(void *queue, struct rte_mbuf **mbufs, uint16_t pkts)
326 {
327         struct cn10k_eth_rxq *rxq = queue;
328         struct cnxk_eth_rxq_sp *rxq_sp;
329         struct rte_eth_dev *eth_dev;
330
331         RTE_SET_USED(mbufs);
332         RTE_SET_USED(pkts);
333
334         rxq_sp = cnxk_eth_rxq_to_sp(rxq);
335         eth_dev = rxq_sp->dev->eth_dev;
336         nix_ptp_enable_vf(eth_dev);
337
338         return 0;
339 }
340
341 static int
342 cn10k_nix_ptp_info_update_cb(struct roc_nix *nix, bool ptp_en)
343 {
344         struct cnxk_eth_dev *dev = (struct cnxk_eth_dev *)nix;
345         struct rte_eth_dev *eth_dev;
346         struct cn10k_eth_rxq *rxq;
347         int i;
348
349         if (!dev)
350                 return -EINVAL;
351
352         eth_dev = dev->eth_dev;
353         if (!eth_dev)
354                 return -EINVAL;
355
356         dev->ptp_en = ptp_en;
357
358         for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
359                 rxq = eth_dev->data->rx_queues[i];
360                 rxq->mbuf_initializer = cnxk_nix_rxq_mbuf_setup(dev);
361         }
362
363         if (roc_nix_is_vf_or_sdp(nix) && !(roc_nix_is_sdp(nix)) &&
364             !(roc_nix_is_lbk(nix))) {
365                 /* In case of VF, setting of MTU cannot be done directly in this
366                  * function as this is running as part of MBOX request(PF->VF)
367                  * and MTU setting also requires MBOX message to be
368                  * sent(VF->PF)
369                  */
370                 eth_dev->rx_pkt_burst = nix_ptp_vf_burst;
371                 rte_mb();
372         }
373
374         return 0;
375 }
376
377 static int
378 cn10k_nix_timesync_enable(struct rte_eth_dev *eth_dev)
379 {
380         struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
381         int i, rc;
382
383         rc = cnxk_nix_timesync_enable(eth_dev);
384         if (rc)
385                 return rc;
386
387         dev->rx_offload_flags |= NIX_RX_OFFLOAD_TSTAMP_F;
388         dev->tx_offload_flags |= NIX_TX_OFFLOAD_TSTAMP_F;
389
390         for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
391                 nix_form_default_desc(dev, eth_dev->data->tx_queues[i], i);
392
393         /* Setting up the rx[tx]_offload_flags due to change
394          * in rx[tx]_offloads.
395          */
396         cn10k_eth_set_rx_function(eth_dev);
397         cn10k_eth_set_tx_function(eth_dev);
398         return 0;
399 }
400
401 static int
402 cn10k_nix_timesync_disable(struct rte_eth_dev *eth_dev)
403 {
404         struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
405         int i, rc;
406
407         rc = cnxk_nix_timesync_disable(eth_dev);
408         if (rc)
409                 return rc;
410
411         dev->rx_offload_flags &= ~NIX_RX_OFFLOAD_TSTAMP_F;
412         dev->tx_offload_flags &= ~NIX_TX_OFFLOAD_TSTAMP_F;
413
414         for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
415                 nix_form_default_desc(dev, eth_dev->data->tx_queues[i], i);
416
417         /* Setting up the rx[tx]_offload_flags due to change
418          * in rx[tx]_offloads.
419          */
420         cn10k_eth_set_rx_function(eth_dev);
421         cn10k_eth_set_tx_function(eth_dev);
422         return 0;
423 }
424
425 static int
426 cn10k_nix_dev_start(struct rte_eth_dev *eth_dev)
427 {
428         struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
429         struct roc_nix *nix = &dev->nix;
430         int rc;
431
432         /* Common eth dev start */
433         rc = cnxk_nix_dev_start(eth_dev);
434         if (rc)
435                 return rc;
436
437         /* Update VF about data off shifted by 8 bytes if PTP already
438          * enabled in PF owning this VF
439          */
440         if (dev->ptp_en && (!roc_nix_is_pf(nix) && (!roc_nix_is_sdp(nix))))
441                 nix_ptp_enable_vf(eth_dev);
442
443         /* Setting up the rx[tx]_offload_flags due to change
444          * in rx[tx]_offloads.
445          */
446         dev->rx_offload_flags |= nix_rx_offload_flags(eth_dev);
447         dev->tx_offload_flags |= nix_tx_offload_flags(eth_dev);
448
449         cn10k_eth_set_tx_function(eth_dev);
450         cn10k_eth_set_rx_function(eth_dev);
451         return 0;
452 }
453
454 static int
455 cn10k_nix_rx_metadata_negotiate(struct rte_eth_dev *eth_dev, uint64_t *features)
456 {
457         struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
458
459         *features &=
460                 (RTE_ETH_RX_METADATA_USER_FLAG | RTE_ETH_RX_METADATA_USER_MARK);
461
462         if (*features) {
463                 dev->rx_offload_flags |= NIX_RX_OFFLOAD_MARK_UPDATE_F;
464                 dev->rx_mark_update = true;
465         } else {
466                 dev->rx_offload_flags &= ~NIX_RX_OFFLOAD_MARK_UPDATE_F;
467                 dev->rx_mark_update = false;
468         }
469
470         cn10k_eth_set_rx_function(eth_dev);
471
472         return 0;
473 }
474
475 /* Update platform specific eth dev ops */
476 static void
477 nix_eth_dev_ops_override(void)
478 {
479         static int init_once;
480
481         if (init_once)
482                 return;
483         init_once = 1;
484
485         /* Update platform specific ops */
486         cnxk_eth_dev_ops.dev_configure = cn10k_nix_configure;
487         cnxk_eth_dev_ops.tx_queue_setup = cn10k_nix_tx_queue_setup;
488         cnxk_eth_dev_ops.rx_queue_setup = cn10k_nix_rx_queue_setup;
489         cnxk_eth_dev_ops.tx_queue_stop = cn10k_nix_tx_queue_stop;
490         cnxk_eth_dev_ops.dev_start = cn10k_nix_dev_start;
491         cnxk_eth_dev_ops.dev_ptypes_set = cn10k_nix_ptypes_set;
492         cnxk_eth_dev_ops.timesync_enable = cn10k_nix_timesync_enable;
493         cnxk_eth_dev_ops.timesync_disable = cn10k_nix_timesync_disable;
494         cnxk_eth_dev_ops.rx_metadata_negotiate =
495                 cn10k_nix_rx_metadata_negotiate;
496 }
497
498 static void
499 npc_flow_ops_override(void)
500 {
501         static int init_once;
502
503         if (init_once)
504                 return;
505         init_once = 1;
506
507         /* Update platform specific ops */
508         cnxk_flow_ops.create = cn10k_flow_create;
509         cnxk_flow_ops.destroy = cn10k_flow_destroy;
510 }
511
512 static int
513 cn10k_nix_remove(struct rte_pci_device *pci_dev)
514 {
515         return cnxk_nix_remove(pci_dev);
516 }
517
518 static int
519 cn10k_nix_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
520 {
521         struct rte_eth_dev *eth_dev;
522         struct cnxk_eth_dev *dev;
523         int rc;
524
525         if (RTE_CACHE_LINE_SIZE != 64) {
526                 plt_err("Driver not compiled for CN10K");
527                 return -EFAULT;
528         }
529
530         rc = roc_plt_init();
531         if (rc) {
532                 plt_err("Failed to initialize platform model, rc=%d", rc);
533                 return rc;
534         }
535
536         nix_eth_dev_ops_override();
537         npc_flow_ops_override();
538
539         cn10k_eth_sec_ops_override();
540
541         /* Common probe */
542         rc = cnxk_nix_probe(pci_drv, pci_dev);
543         if (rc)
544                 return rc;
545
546         /* Find eth dev allocated */
547         eth_dev = rte_eth_dev_allocated(pci_dev->device.name);
548         if (!eth_dev)
549                 return -ENOENT;
550
551         if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
552                 /* Setup callbacks for secondary process */
553                 cn10k_eth_set_tx_function(eth_dev);
554                 cn10k_eth_set_rx_function(eth_dev);
555                 return 0;
556         }
557
558         dev = cnxk_eth_pmd_priv(eth_dev);
559
560         /* DROP_RE is not supported with inline IPSec for CN10K A0 and
561          * when vector mode is enabled.
562          */
563         if ((roc_model_is_cn10ka_a0() || roc_model_is_cnf10ka_a0() ||
564              roc_model_is_cnf10kb_a0()) &&
565             !roc_env_is_asim()) {
566                 dev->ipsecd_drop_re_dis = 1;
567                 dev->vec_drop_re_dis = 1;
568         }
569
570         /* Register up msg callbacks for PTP information */
571         roc_nix_ptp_info_cb_register(&dev->nix, cn10k_nix_ptp_info_update_cb);
572
573         return 0;
574 }
575
576 static const struct rte_pci_id cn10k_pci_nix_map[] = {
577         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KA, PCI_DEVID_CNXK_RVU_PF),
578         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KAS, PCI_DEVID_CNXK_RVU_PF),
579         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF10KA, PCI_DEVID_CNXK_RVU_PF),
580         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KA, PCI_DEVID_CNXK_RVU_VF),
581         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KAS, PCI_DEVID_CNXK_RVU_VF),
582         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF10KA, PCI_DEVID_CNXK_RVU_VF),
583         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KA, PCI_DEVID_CNXK_RVU_AF_VF),
584         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KAS, PCI_DEVID_CNXK_RVU_AF_VF),
585         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF10KA, PCI_DEVID_CNXK_RVU_AF_VF),
586         {
587                 .vendor_id = 0,
588         },
589 };
590
591 static struct rte_pci_driver cn10k_pci_nix = {
592         .id_table = cn10k_pci_nix_map,
593         .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_NEED_IOVA_AS_VA |
594                      RTE_PCI_DRV_INTR_LSC,
595         .probe = cn10k_nix_probe,
596         .remove = cn10k_nix_remove,
597 };
598
599 RTE_PMD_REGISTER_PCI(net_cn10k, cn10k_pci_nix);
600 RTE_PMD_REGISTER_PCI_TABLE(net_cn10k, cn10k_pci_nix_map);
601 RTE_PMD_REGISTER_KMOD_DEP(net_cn10k, "vfio-pci");