7b73817e579cb81eef5ff7cbc20cef9cafacd60d
[dpdk.git] / drivers / net / octeontx / octeontx_ethdev.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Cavium, Inc
3  */
4
5 #include <stdio.h>
6 #include <stdarg.h>
7 #include <stdbool.h>
8 #include <stdint.h>
9 #include <string.h>
10 #include <unistd.h>
11
12 #include <rte_alarm.h>
13 #include <rte_branch_prediction.h>
14 #include <rte_debug.h>
15 #include <rte_devargs.h>
16 #include <rte_dev.h>
17 #include <rte_kvargs.h>
18 #include <rte_malloc.h>
19 #include <rte_prefetch.h>
20 #include <rte_bus_vdev.h>
21
22 #include "octeontx_ethdev.h"
23 #include "octeontx_rxtx.h"
24 #include "octeontx_logs.h"
25
26 struct octeontx_vdev_init_params {
27         uint8_t nr_port;
28 };
29
30 enum octeontx_link_speed {
31         OCTEONTX_LINK_SPEED_SGMII,
32         OCTEONTX_LINK_SPEED_XAUI,
33         OCTEONTX_LINK_SPEED_RXAUI,
34         OCTEONTX_LINK_SPEED_10G_R,
35         OCTEONTX_LINK_SPEED_40G_R,
36         OCTEONTX_LINK_SPEED_RESERVE1,
37         OCTEONTX_LINK_SPEED_QSGMII,
38         OCTEONTX_LINK_SPEED_RESERVE2
39 };
40
41 int otx_net_logtype_mbox;
42 int otx_net_logtype_init;
43 int otx_net_logtype_driver;
44
45 RTE_INIT(otx_net_init_log);
46 static void
47 otx_net_init_log(void)
48 {
49         otx_net_logtype_mbox = rte_log_register("pmd.otx.ethdev.mbox");
50         if (otx_net_logtype_mbox >= 0)
51                 rte_log_set_level(otx_net_logtype_mbox, RTE_LOG_NOTICE);
52
53         otx_net_logtype_init = rte_log_register("pmd.otx.ethdev.init");
54         if (otx_net_logtype_init >= 0)
55                 rte_log_set_level(otx_net_logtype_init, RTE_LOG_NOTICE);
56
57         otx_net_logtype_driver = rte_log_register("pmd.otx.ethdev.driver");
58         if (otx_net_logtype_driver >= 0)
59                 rte_log_set_level(otx_net_logtype_driver, RTE_LOG_NOTICE);
60 }
61
62 /* Parse integer from integer argument */
63 static int
64 parse_integer_arg(const char *key __rte_unused,
65                 const char *value, void *extra_args)
66 {
67         int *i = (int *)extra_args;
68
69         *i = atoi(value);
70         if (*i < 0) {
71                 octeontx_log_err("argument has to be positive.");
72                 return -1;
73         }
74
75         return 0;
76 }
77
78 static int
79 octeontx_parse_vdev_init_params(struct octeontx_vdev_init_params *params,
80                                 struct rte_vdev_device *dev)
81 {
82         struct rte_kvargs *kvlist = NULL;
83         int ret = 0;
84
85         static const char * const octeontx_vdev_valid_params[] = {
86                 OCTEONTX_VDEV_NR_PORT_ARG,
87                 NULL
88         };
89
90         const char *input_args = rte_vdev_device_args(dev);
91         if (params == NULL)
92                 return -EINVAL;
93
94
95         if (input_args) {
96                 kvlist = rte_kvargs_parse(input_args,
97                                 octeontx_vdev_valid_params);
98                 if (kvlist == NULL)
99                         return -1;
100
101                 ret = rte_kvargs_process(kvlist,
102                                         OCTEONTX_VDEV_NR_PORT_ARG,
103                                         &parse_integer_arg,
104                                         &params->nr_port);
105                 if (ret < 0)
106                         goto free_kvlist;
107         }
108
109 free_kvlist:
110         rte_kvargs_free(kvlist);
111         return ret;
112 }
113
114 static int
115 octeontx_port_open(struct octeontx_nic *nic)
116 {
117         octeontx_mbox_bgx_port_conf_t bgx_port_conf;
118         int res;
119
120         res = 0;
121
122         PMD_INIT_FUNC_TRACE();
123
124         res = octeontx_bgx_port_open(nic->port_id, &bgx_port_conf);
125         if (res < 0) {
126                 octeontx_log_err("failed to open port %d", res);
127                 return res;
128         }
129
130         nic->node = bgx_port_conf.node;
131         nic->port_ena = bgx_port_conf.enable;
132         nic->base_ichan = bgx_port_conf.base_chan;
133         nic->base_ochan = bgx_port_conf.base_chan;
134         nic->num_ichans = bgx_port_conf.num_chans;
135         nic->num_ochans = bgx_port_conf.num_chans;
136         nic->mtu = bgx_port_conf.mtu;
137         nic->bpen = bgx_port_conf.bpen;
138         nic->fcs_strip = bgx_port_conf.fcs_strip;
139         nic->bcast_mode = bgx_port_conf.bcast_mode;
140         nic->mcast_mode = bgx_port_conf.mcast_mode;
141         nic->speed      = bgx_port_conf.mode;
142
143         memcpy(&nic->mac_addr[0], &bgx_port_conf.macaddr[0], ETHER_ADDR_LEN);
144
145         octeontx_log_dbg("port opened %d", nic->port_id);
146         return res;
147 }
148
149 static void
150 octeontx_port_close(struct octeontx_nic *nic)
151 {
152         PMD_INIT_FUNC_TRACE();
153
154         octeontx_bgx_port_close(nic->port_id);
155         octeontx_log_dbg("port closed %d", nic->port_id);
156 }
157
158 static int
159 octeontx_port_start(struct octeontx_nic *nic)
160 {
161         PMD_INIT_FUNC_TRACE();
162
163         return octeontx_bgx_port_start(nic->port_id);
164 }
165
166 static int
167 octeontx_port_stop(struct octeontx_nic *nic)
168 {
169         PMD_INIT_FUNC_TRACE();
170
171         return octeontx_bgx_port_stop(nic->port_id);
172 }
173
174 static void
175 octeontx_port_promisc_set(struct octeontx_nic *nic, int en)
176 {
177         struct rte_eth_dev *dev;
178         int res;
179
180         res = 0;
181         PMD_INIT_FUNC_TRACE();
182         dev = nic->dev;
183
184         res = octeontx_bgx_port_promisc_set(nic->port_id, en);
185         if (res < 0)
186                 octeontx_log_err("failed to set promiscuous mode %d",
187                                 nic->port_id);
188
189         /* Set proper flag for the mode */
190         dev->data->promiscuous = (en != 0) ? 1 : 0;
191
192         octeontx_log_dbg("port %d : promiscuous mode %s",
193                         nic->port_id, en ? "set" : "unset");
194 }
195
196 static int
197 octeontx_port_stats(struct octeontx_nic *nic, struct rte_eth_stats *stats)
198 {
199         octeontx_mbox_bgx_port_stats_t bgx_stats;
200         int res;
201
202         PMD_INIT_FUNC_TRACE();
203
204         res = octeontx_bgx_port_stats(nic->port_id, &bgx_stats);
205         if (res < 0) {
206                 octeontx_log_err("failed to get port stats %d", nic->port_id);
207                 return res;
208         }
209
210         stats->ipackets = bgx_stats.rx_packets;
211         stats->ibytes = bgx_stats.rx_bytes;
212         stats->imissed = bgx_stats.rx_dropped;
213         stats->ierrors = bgx_stats.rx_errors;
214         stats->opackets = bgx_stats.tx_packets;
215         stats->obytes = bgx_stats.tx_bytes;
216         stats->oerrors = bgx_stats.tx_errors;
217
218         octeontx_log_dbg("port%d stats inpkts=%" PRIx64 " outpkts=%" PRIx64 "",
219                         nic->port_id, stats->ipackets, stats->opackets);
220
221         return 0;
222 }
223
224 static void
225 octeontx_port_stats_clr(struct octeontx_nic *nic)
226 {
227         PMD_INIT_FUNC_TRACE();
228
229         octeontx_bgx_port_stats_clr(nic->port_id);
230 }
231
232 static inline void
233 devconf_set_default_sane_values(struct rte_event_dev_config *dev_conf,
234                                 struct rte_event_dev_info *info)
235 {
236         memset(dev_conf, 0, sizeof(struct rte_event_dev_config));
237         dev_conf->dequeue_timeout_ns = info->min_dequeue_timeout_ns;
238
239         dev_conf->nb_event_ports = info->max_event_ports;
240         dev_conf->nb_event_queues = info->max_event_queues;
241
242         dev_conf->nb_event_queue_flows = info->max_event_queue_flows;
243         dev_conf->nb_event_port_dequeue_depth =
244                         info->max_event_port_dequeue_depth;
245         dev_conf->nb_event_port_enqueue_depth =
246                         info->max_event_port_enqueue_depth;
247         dev_conf->nb_event_port_enqueue_depth =
248                         info->max_event_port_enqueue_depth;
249         dev_conf->nb_events_limit =
250                         info->max_num_events;
251 }
252
253 static int
254 octeontx_dev_configure(struct rte_eth_dev *dev)
255 {
256         struct rte_eth_dev_data *data = dev->data;
257         struct rte_eth_conf *conf = &data->dev_conf;
258         struct rte_eth_rxmode *rxmode = &conf->rxmode;
259         struct rte_eth_txmode *txmode = &conf->txmode;
260         struct octeontx_nic *nic = octeontx_pmd_priv(dev);
261         int ret;
262
263         PMD_INIT_FUNC_TRACE();
264         RTE_SET_USED(conf);
265
266         if (!rte_eal_has_hugepages()) {
267                 octeontx_log_err("huge page is not configured");
268                 return -EINVAL;
269         }
270
271         if (txmode->mq_mode) {
272                 octeontx_log_err("tx mq_mode DCB or VMDq not supported");
273                 return -EINVAL;
274         }
275
276         if (rxmode->mq_mode != ETH_MQ_RX_NONE &&
277                 rxmode->mq_mode != ETH_MQ_RX_RSS) {
278                 octeontx_log_err("unsupported rx qmode %d", rxmode->mq_mode);
279                 return -EINVAL;
280         }
281
282         if (!rxmode->hw_strip_crc) {
283                 PMD_INIT_LOG(NOTICE, "can't disable hw crc strip");
284                 rxmode->hw_strip_crc = 1;
285         }
286
287         if (rxmode->hw_ip_checksum) {
288                 PMD_INIT_LOG(NOTICE, "rxcksum not supported");
289                 rxmode->hw_ip_checksum = 0;
290         }
291
292         if (rxmode->split_hdr_size) {
293                 octeontx_log_err("rxmode does not support split header");
294                 return -EINVAL;
295         }
296
297         if (rxmode->hw_vlan_filter) {
298                 octeontx_log_err("VLAN filter not supported");
299                 return -EINVAL;
300         }
301
302         if (rxmode->hw_vlan_extend) {
303                 octeontx_log_err("VLAN extended not supported");
304                 return -EINVAL;
305         }
306
307         if (rxmode->enable_lro) {
308                 octeontx_log_err("LRO not supported");
309                 return -EINVAL;
310         }
311
312         if (conf->link_speeds & ETH_LINK_SPEED_FIXED) {
313                 octeontx_log_err("setting link speed/duplex not supported");
314                 return -EINVAL;
315         }
316
317         if (conf->dcb_capability_en) {
318                 octeontx_log_err("DCB enable not supported");
319                 return -EINVAL;
320         }
321
322         if (conf->fdir_conf.mode != RTE_FDIR_MODE_NONE) {
323                 octeontx_log_err("flow director not supported");
324                 return -EINVAL;
325         }
326
327         nic->num_tx_queues = dev->data->nb_tx_queues;
328
329         ret = octeontx_pko_channel_open(nic->port_id * PKO_VF_NUM_DQ,
330                                         nic->num_tx_queues,
331                                         nic->base_ochan);
332         if (ret) {
333                 octeontx_log_err("failed to open channel %d no-of-txq %d",
334                            nic->base_ochan, nic->num_tx_queues);
335                 return -EFAULT;
336         }
337
338         nic->pki.classifier_enable = false;
339         nic->pki.hash_enable = true;
340         nic->pki.initialized = false;
341
342         return 0;
343 }
344
345 static void
346 octeontx_dev_close(struct rte_eth_dev *dev)
347 {
348         struct octeontx_txq *txq = NULL;
349         struct octeontx_nic *nic = octeontx_pmd_priv(dev);
350         unsigned int i;
351         int ret;
352
353         PMD_INIT_FUNC_TRACE();
354
355         rte_event_dev_close(nic->evdev);
356
357         ret = octeontx_pko_channel_close(nic->base_ochan);
358         if (ret < 0) {
359                 octeontx_log_err("failed to close channel %d VF%d %d %d",
360                              nic->base_ochan, nic->port_id, nic->num_tx_queues,
361                              ret);
362         }
363         /* Free txq resources for this port */
364         for (i = 0; i < nic->num_tx_queues; i++) {
365                 txq = dev->data->tx_queues[i];
366                 if (!txq)
367                         continue;
368
369                 rte_free(txq);
370         }
371 }
372
373 static int
374 octeontx_dev_start(struct rte_eth_dev *dev)
375 {
376         struct octeontx_nic *nic = octeontx_pmd_priv(dev);
377         int ret;
378
379         ret = 0;
380
381         PMD_INIT_FUNC_TRACE();
382         /*
383          * Tx start
384          */
385         dev->tx_pkt_burst = octeontx_xmit_pkts;
386         ret = octeontx_pko_channel_start(nic->base_ochan);
387         if (ret < 0) {
388                 octeontx_log_err("fail to conf VF%d no. txq %d chan %d ret %d",
389                            nic->port_id, nic->num_tx_queues, nic->base_ochan,
390                            ret);
391                 goto error;
392         }
393
394         /*
395          * Rx start
396          */
397         dev->rx_pkt_burst = octeontx_recv_pkts;
398         ret = octeontx_pki_port_start(nic->port_id);
399         if (ret < 0) {
400                 octeontx_log_err("fail to start Rx on port %d", nic->port_id);
401                 goto channel_stop_error;
402         }
403
404         /*
405          * Start port
406          */
407         ret = octeontx_port_start(nic);
408         if (ret < 0) {
409                 octeontx_log_err("failed start port %d", ret);
410                 goto pki_port_stop_error;
411         }
412
413         PMD_TX_LOG(DEBUG, "pko: start channel %d no.of txq %d port %d",
414                         nic->base_ochan, nic->num_tx_queues, nic->port_id);
415
416         ret = rte_event_dev_start(nic->evdev);
417         if (ret < 0) {
418                 octeontx_log_err("failed to start evdev: ret (%d)", ret);
419                 goto pki_port_stop_error;
420         }
421
422         /* Success */
423         return ret;
424
425 pki_port_stop_error:
426         octeontx_pki_port_stop(nic->port_id);
427 channel_stop_error:
428         octeontx_pko_channel_stop(nic->base_ochan);
429 error:
430         return ret;
431 }
432
433 static void
434 octeontx_dev_stop(struct rte_eth_dev *dev)
435 {
436         struct octeontx_nic *nic = octeontx_pmd_priv(dev);
437         int ret;
438
439         PMD_INIT_FUNC_TRACE();
440
441         rte_event_dev_stop(nic->evdev);
442
443         ret = octeontx_port_stop(nic);
444         if (ret < 0) {
445                 octeontx_log_err("failed to req stop port %d res=%d",
446                                         nic->port_id, ret);
447                 return;
448         }
449
450         ret = octeontx_pki_port_stop(nic->port_id);
451         if (ret < 0) {
452                 octeontx_log_err("failed to stop pki port %d res=%d",
453                                         nic->port_id, ret);
454                 return;
455         }
456
457         ret = octeontx_pko_channel_stop(nic->base_ochan);
458         if (ret < 0) {
459                 octeontx_log_err("failed to stop channel %d VF%d %d %d",
460                              nic->base_ochan, nic->port_id, nic->num_tx_queues,
461                              ret);
462                 return;
463         }
464
465         dev->tx_pkt_burst = NULL;
466         dev->rx_pkt_burst = NULL;
467 }
468
469 static void
470 octeontx_dev_promisc_enable(struct rte_eth_dev *dev)
471 {
472         struct octeontx_nic *nic = octeontx_pmd_priv(dev);
473
474         PMD_INIT_FUNC_TRACE();
475         octeontx_port_promisc_set(nic, 1);
476 }
477
478 static void
479 octeontx_dev_promisc_disable(struct rte_eth_dev *dev)
480 {
481         struct octeontx_nic *nic = octeontx_pmd_priv(dev);
482
483         PMD_INIT_FUNC_TRACE();
484         octeontx_port_promisc_set(nic, 0);
485 }
486
487 static inline int
488 octeontx_atomic_write_link_status(struct rte_eth_dev *dev,
489                                   struct rte_eth_link *link)
490 {
491         struct rte_eth_link *dst = &dev->data->dev_link;
492         struct rte_eth_link *src = link;
493
494         if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
495                 *(uint64_t *)src) == 0)
496                 return -1;
497
498         return 0;
499 }
500
501 static int
502 octeontx_port_link_status(struct octeontx_nic *nic)
503 {
504         int res;
505
506         PMD_INIT_FUNC_TRACE();
507         res = octeontx_bgx_port_link_status(nic->port_id);
508         if (res < 0) {
509                 octeontx_log_err("failed to get port %d link status",
510                                 nic->port_id);
511                 return res;
512         }
513
514         nic->link_up = (uint8_t)res;
515         octeontx_log_dbg("port %d link status %d", nic->port_id, nic->link_up);
516
517         return res;
518 }
519
520 /*
521  * Return 0 means link status changed, -1 means not changed
522  */
523 static int
524 octeontx_dev_link_update(struct rte_eth_dev *dev,
525                          int wait_to_complete __rte_unused)
526 {
527         struct octeontx_nic *nic = octeontx_pmd_priv(dev);
528         struct rte_eth_link link;
529         int res;
530
531         res = 0;
532         PMD_INIT_FUNC_TRACE();
533
534         res = octeontx_port_link_status(nic);
535         if (res < 0) {
536                 octeontx_log_err("failed to request link status %d", res);
537                 return res;
538         }
539
540         link.link_status = nic->link_up;
541
542         switch (nic->speed) {
543         case OCTEONTX_LINK_SPEED_SGMII:
544                 link.link_speed = ETH_SPEED_NUM_1G;
545                 break;
546
547         case OCTEONTX_LINK_SPEED_XAUI:
548                 link.link_speed = ETH_SPEED_NUM_10G;
549                 break;
550
551         case OCTEONTX_LINK_SPEED_RXAUI:
552         case OCTEONTX_LINK_SPEED_10G_R:
553                 link.link_speed = ETH_SPEED_NUM_10G;
554                 break;
555         case OCTEONTX_LINK_SPEED_QSGMII:
556                 link.link_speed = ETH_SPEED_NUM_5G;
557                 break;
558         case OCTEONTX_LINK_SPEED_40G_R:
559                 link.link_speed = ETH_SPEED_NUM_40G;
560                 break;
561
562         case OCTEONTX_LINK_SPEED_RESERVE1:
563         case OCTEONTX_LINK_SPEED_RESERVE2:
564         default:
565                 octeontx_log_err("incorrect link speed %d", nic->speed);
566                 break;
567         }
568
569         link.link_duplex = ETH_LINK_AUTONEG;
570         link.link_autoneg = ETH_LINK_SPEED_AUTONEG;
571
572         return octeontx_atomic_write_link_status(dev, &link);
573 }
574
575 static int
576 octeontx_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
577 {
578         struct octeontx_nic *nic = octeontx_pmd_priv(dev);
579
580         PMD_INIT_FUNC_TRACE();
581         return octeontx_port_stats(nic, stats);
582 }
583
584 static void
585 octeontx_dev_stats_reset(struct rte_eth_dev *dev)
586 {
587         struct octeontx_nic *nic = octeontx_pmd_priv(dev);
588
589         PMD_INIT_FUNC_TRACE();
590         octeontx_port_stats_clr(nic);
591 }
592
593 static void
594 octeontx_dev_default_mac_addr_set(struct rte_eth_dev *dev,
595                                         struct ether_addr *addr)
596 {
597         struct octeontx_nic *nic = octeontx_pmd_priv(dev);
598         int ret;
599
600         ret = octeontx_bgx_port_mac_set(nic->port_id, addr->addr_bytes);
601         if (ret != 0)
602                 octeontx_log_err("failed to set MAC address on port %d",
603                                 nic->port_id);
604 }
605
606 static void
607 octeontx_dev_info(struct rte_eth_dev *dev,
608                 struct rte_eth_dev_info *dev_info)
609 {
610         RTE_SET_USED(dev);
611
612         /* Autonegotiation may be disabled */
613         dev_info->speed_capa = ETH_LINK_SPEED_FIXED;
614         dev_info->speed_capa |= ETH_LINK_SPEED_10M | ETH_LINK_SPEED_100M |
615                         ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G |
616                         ETH_LINK_SPEED_40G;
617
618         dev_info->driver_name = RTE_STR(rte_octeontx_pmd);
619         dev_info->max_mac_addrs = 1;
620         dev_info->max_rx_pktlen = PKI_MAX_PKTLEN;
621         dev_info->max_rx_queues = 1;
622         dev_info->max_tx_queues = PKO_MAX_NUM_DQ;
623         dev_info->min_rx_bufsize = 0;
624         dev_info->pci_dev = NULL;
625
626         dev_info->default_rxconf = (struct rte_eth_rxconf) {
627                 .rx_free_thresh = 0,
628                 .rx_drop_en = 0,
629         };
630
631         dev_info->default_txconf = (struct rte_eth_txconf) {
632                 .tx_free_thresh = 0,
633                 .txq_flags =
634                         ETH_TXQ_FLAGS_NOMULTSEGS |
635                         ETH_TXQ_FLAGS_NOOFFLOADS |
636                         ETH_TXQ_FLAGS_NOXSUMS,
637         };
638
639         dev_info->tx_offload_capa = DEV_TX_OFFLOAD_MT_LOCKFREE;
640 }
641
642 static void
643 octeontx_dq_info_getter(octeontx_dq_t *dq, void *out)
644 {
645         ((octeontx_dq_t *)out)->lmtline_va = dq->lmtline_va;
646         ((octeontx_dq_t *)out)->ioreg_va = dq->ioreg_va;
647         ((octeontx_dq_t *)out)->fc_status_va = dq->fc_status_va;
648 }
649
650 static int
651 octeontx_vf_start_tx_queue(struct rte_eth_dev *dev, struct octeontx_nic *nic,
652                                 uint16_t qidx)
653 {
654         struct octeontx_txq *txq;
655         int res;
656
657         PMD_INIT_FUNC_TRACE();
658
659         if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED)
660                 return 0;
661
662         txq = dev->data->tx_queues[qidx];
663
664         res = octeontx_pko_channel_query_dqs(nic->base_ochan,
665                                                 &txq->dq,
666                                                 sizeof(octeontx_dq_t),
667                                                 txq->queue_id,
668                                                 octeontx_dq_info_getter);
669         if (res < 0) {
670                 res = -EFAULT;
671                 goto close_port;
672         }
673
674         dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
675         return res;
676
677 close_port:
678         (void)octeontx_port_stop(nic);
679         octeontx_pko_channel_stop(nic->base_ochan);
680         octeontx_pko_channel_close(nic->base_ochan);
681         dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
682         return res;
683 }
684
685 static int
686 octeontx_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
687 {
688         struct octeontx_nic *nic = octeontx_pmd_priv(dev);
689
690         PMD_INIT_FUNC_TRACE();
691         qidx = qidx % PKO_VF_NUM_DQ;
692         return octeontx_vf_start_tx_queue(dev, nic, qidx);
693 }
694
695 static inline int
696 octeontx_vf_stop_tx_queue(struct rte_eth_dev *dev, struct octeontx_nic *nic,
697                           uint16_t qidx)
698 {
699         int ret = 0;
700
701         RTE_SET_USED(nic);
702         PMD_INIT_FUNC_TRACE();
703
704         if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED)
705                 return 0;
706
707         dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
708         return ret;
709 }
710
711 static int
712 octeontx_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
713 {
714         struct octeontx_nic *nic = octeontx_pmd_priv(dev);
715
716         PMD_INIT_FUNC_TRACE();
717         qidx = qidx % PKO_VF_NUM_DQ;
718
719         return octeontx_vf_stop_tx_queue(dev, nic, qidx);
720 }
721
722 static void
723 octeontx_dev_tx_queue_release(void *tx_queue)
724 {
725         struct octeontx_txq *txq = tx_queue;
726         int res;
727
728         PMD_INIT_FUNC_TRACE();
729
730         if (txq) {
731                 res = octeontx_dev_tx_queue_stop(txq->eth_dev, txq->queue_id);
732                 if (res < 0)
733                         octeontx_log_err("failed stop tx_queue(%d)\n",
734                                    txq->queue_id);
735
736                 rte_free(txq);
737         }
738 }
739
740 static int
741 octeontx_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
742                             uint16_t nb_desc, unsigned int socket_id,
743                             const struct rte_eth_txconf *tx_conf)
744 {
745         struct octeontx_nic *nic = octeontx_pmd_priv(dev);
746         struct octeontx_txq *txq = NULL;
747         uint16_t dq_num;
748         int res = 0;
749
750         RTE_SET_USED(nb_desc);
751         RTE_SET_USED(socket_id);
752         RTE_SET_USED(tx_conf);
753
754         dq_num = (nic->port_id * PKO_VF_NUM_DQ) + qidx;
755
756         /* Socket id check */
757         if (socket_id != (unsigned int)SOCKET_ID_ANY &&
758                         socket_id != (unsigned int)nic->node)
759                 PMD_TX_LOG(INFO, "socket_id expected %d, configured %d",
760                                                 socket_id, nic->node);
761
762         /* Free memory prior to re-allocation if needed. */
763         if (dev->data->tx_queues[qidx] != NULL) {
764                 PMD_TX_LOG(DEBUG, "freeing memory prior to re-allocation %d",
765                                 qidx);
766                 octeontx_dev_tx_queue_release(dev->data->tx_queues[qidx]);
767                 dev->data->tx_queues[qidx] = NULL;
768         }
769
770         /* Allocating tx queue data structure */
771         txq = rte_zmalloc_socket("ethdev TX queue", sizeof(struct octeontx_txq),
772                                  RTE_CACHE_LINE_SIZE, nic->node);
773         if (txq == NULL) {
774                 octeontx_log_err("failed to allocate txq=%d", qidx);
775                 res = -ENOMEM;
776                 goto err;
777         }
778
779         txq->eth_dev = dev;
780         txq->queue_id = dq_num;
781         dev->data->tx_queues[qidx] = txq;
782         dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
783
784         res = octeontx_pko_channel_query_dqs(nic->base_ochan,
785                                                 &txq->dq,
786                                                 sizeof(octeontx_dq_t),
787                                                 txq->queue_id,
788                                                 octeontx_dq_info_getter);
789         if (res < 0) {
790                 res = -EFAULT;
791                 goto err;
792         }
793
794         PMD_TX_LOG(DEBUG, "[%d]:[%d] txq=%p nb_desc=%d lmtline=%p ioreg_va=%p fc_status_va=%p",
795                         qidx, txq->queue_id, txq, nb_desc, txq->dq.lmtline_va,
796                         txq->dq.ioreg_va,
797                         txq->dq.fc_status_va);
798
799         return res;
800
801 err:
802         if (txq)
803                 rte_free(txq);
804
805         return res;
806 }
807
808 static int
809 octeontx_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
810                                 uint16_t nb_desc, unsigned int socket_id,
811                                 const struct rte_eth_rxconf *rx_conf,
812                                 struct rte_mempool *mb_pool)
813 {
814         struct octeontx_nic *nic = octeontx_pmd_priv(dev);
815         struct rte_mempool_ops *mp_ops = NULL;
816         struct octeontx_rxq *rxq = NULL;
817         pki_pktbuf_cfg_t pktbuf_conf;
818         pki_hash_cfg_t pki_hash;
819         pki_qos_cfg_t pki_qos;
820         uintptr_t pool;
821         int ret, port;
822         uint8_t gaura;
823         unsigned int ev_queues = (nic->ev_queues * nic->port_id) + qidx;
824         unsigned int ev_ports = (nic->ev_ports * nic->port_id) + qidx;
825
826         RTE_SET_USED(nb_desc);
827
828         memset(&pktbuf_conf, 0, sizeof(pktbuf_conf));
829         memset(&pki_hash, 0, sizeof(pki_hash));
830         memset(&pki_qos, 0, sizeof(pki_qos));
831
832         mp_ops = rte_mempool_get_ops(mb_pool->ops_index);
833         if (strcmp(mp_ops->name, "octeontx_fpavf")) {
834                 octeontx_log_err("failed to find octeontx_fpavf mempool");
835                 return -ENOTSUP;
836         }
837
838         /* Handle forbidden configurations */
839         if (nic->pki.classifier_enable) {
840                 octeontx_log_err("cannot setup queue %d. "
841                                         "Classifier option unsupported", qidx);
842                 return -EINVAL;
843         }
844
845         port = nic->port_id;
846
847         /* Rx deferred start is not supported */
848         if (rx_conf->rx_deferred_start) {
849                 octeontx_log_err("rx deferred start not supported");
850                 return -EINVAL;
851         }
852
853         /* Verify queue index */
854         if (qidx >= dev->data->nb_rx_queues) {
855                 octeontx_log_err("QID %d not supporteded (0 - %d available)\n",
856                                 qidx, (dev->data->nb_rx_queues - 1));
857                 return -ENOTSUP;
858         }
859
860         /* Socket id check */
861         if (socket_id != (unsigned int)SOCKET_ID_ANY &&
862                         socket_id != (unsigned int)nic->node)
863                 PMD_RX_LOG(INFO, "socket_id expected %d, configured %d",
864                                                 socket_id, nic->node);
865
866         /* Allocating rx queue data structure */
867         rxq = rte_zmalloc_socket("ethdev RX queue", sizeof(struct octeontx_rxq),
868                                  RTE_CACHE_LINE_SIZE, nic->node);
869         if (rxq == NULL) {
870                 octeontx_log_err("failed to allocate rxq=%d", qidx);
871                 return -ENOMEM;
872         }
873
874         if (!nic->pki.initialized) {
875                 pktbuf_conf.port_type = 0;
876                 pki_hash.port_type = 0;
877                 pki_qos.port_type = 0;
878
879                 pktbuf_conf.mmask.f_wqe_skip = 1;
880                 pktbuf_conf.mmask.f_first_skip = 1;
881                 pktbuf_conf.mmask.f_later_skip = 1;
882                 pktbuf_conf.mmask.f_mbuff_size = 1;
883                 pktbuf_conf.mmask.f_cache_mode = 1;
884
885                 pktbuf_conf.wqe_skip = OCTTX_PACKET_WQE_SKIP;
886                 pktbuf_conf.first_skip = OCTTX_PACKET_FIRST_SKIP;
887                 pktbuf_conf.later_skip = OCTTX_PACKET_LATER_SKIP;
888                 pktbuf_conf.mbuff_size = (mb_pool->elt_size -
889                                         RTE_PKTMBUF_HEADROOM -
890                                         sizeof(struct rte_mbuf));
891
892                 pktbuf_conf.cache_mode = PKI_OPC_MODE_STF2_STT;
893
894                 ret = octeontx_pki_port_pktbuf_config(port, &pktbuf_conf);
895                 if (ret != 0) {
896                         octeontx_log_err("fail to configure pktbuf for port %d",
897                                         port);
898                         rte_free(rxq);
899                         return ret;
900                 }
901                 PMD_RX_LOG(DEBUG, "Port %d Rx pktbuf configured:\n"
902                                 "\tmbuf_size:\t0x%0x\n"
903                                 "\twqe_skip:\t0x%0x\n"
904                                 "\tfirst_skip:\t0x%0x\n"
905                                 "\tlater_skip:\t0x%0x\n"
906                                 "\tcache_mode:\t%s\n",
907                                 port,
908                                 pktbuf_conf.mbuff_size,
909                                 pktbuf_conf.wqe_skip,
910                                 pktbuf_conf.first_skip,
911                                 pktbuf_conf.later_skip,
912                                 (pktbuf_conf.cache_mode ==
913                                                 PKI_OPC_MODE_STT) ?
914                                 "STT" :
915                                 (pktbuf_conf.cache_mode ==
916                                                 PKI_OPC_MODE_STF) ?
917                                 "STF" :
918                                 (pktbuf_conf.cache_mode ==
919                                                 PKI_OPC_MODE_STF1_STT) ?
920                                 "STF1_STT" : "STF2_STT");
921
922                 if (nic->pki.hash_enable) {
923                         pki_hash.tag_dlc = 1;
924                         pki_hash.tag_slc = 1;
925                         pki_hash.tag_dlf = 1;
926                         pki_hash.tag_slf = 1;
927                         pki_hash.tag_prt = 1;
928                         octeontx_pki_port_hash_config(port, &pki_hash);
929                 }
930
931                 pool = (uintptr_t)mb_pool->pool_id;
932
933                 /* Get the gpool Id */
934                 gaura = octeontx_fpa_bufpool_gpool(pool);
935
936                 pki_qos.qpg_qos = PKI_QPG_QOS_NONE;
937                 pki_qos.num_entry = 1;
938                 pki_qos.drop_policy = 0;
939                 pki_qos.tag_type = 0L;
940                 pki_qos.qos_entry[0].port_add = 0;
941                 pki_qos.qos_entry[0].gaura = gaura;
942                 pki_qos.qos_entry[0].ggrp_ok = ev_queues;
943                 pki_qos.qos_entry[0].ggrp_bad = ev_queues;
944                 pki_qos.qos_entry[0].grptag_bad = 0;
945                 pki_qos.qos_entry[0].grptag_ok = 0;
946
947                 ret = octeontx_pki_port_create_qos(port, &pki_qos);
948                 if (ret < 0) {
949                         octeontx_log_err("failed to create QOS port=%d, q=%d",
950                                         port, qidx);
951                         rte_free(rxq);
952                         return ret;
953                 }
954                 nic->pki.initialized = true;
955         }
956
957         rxq->port_id = nic->port_id;
958         rxq->eth_dev = dev;
959         rxq->queue_id = qidx;
960         rxq->evdev = nic->evdev;
961         rxq->ev_queues = ev_queues;
962         rxq->ev_ports = ev_ports;
963
964         dev->data->rx_queues[qidx] = rxq;
965         dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
966         return 0;
967 }
968
969 static void
970 octeontx_dev_rx_queue_release(void *rxq)
971 {
972         rte_free(rxq);
973 }
974
975 static const uint32_t *
976 octeontx_dev_supported_ptypes_get(struct rte_eth_dev *dev)
977 {
978         static const uint32_t ptypes[] = {
979                 RTE_PTYPE_L3_IPV4,
980                 RTE_PTYPE_L3_IPV4_EXT,
981                 RTE_PTYPE_L3_IPV6,
982                 RTE_PTYPE_L3_IPV6_EXT,
983                 RTE_PTYPE_L4_TCP,
984                 RTE_PTYPE_L4_UDP,
985                 RTE_PTYPE_L4_FRAG,
986                 RTE_PTYPE_UNKNOWN
987         };
988
989         if (dev->rx_pkt_burst == octeontx_recv_pkts)
990                 return ptypes;
991
992         return NULL;
993 }
994
995 static int
996 octeontx_pool_ops(struct rte_eth_dev *dev, const char *pool)
997 {
998         RTE_SET_USED(dev);
999
1000         if (!strcmp(pool, "octeontx_fpavf"))
1001                 return 0;
1002
1003         return -ENOTSUP;
1004 }
1005
1006 /* Initialize and register driver with DPDK Application */
1007 static const struct eth_dev_ops octeontx_dev_ops = {
1008         .dev_configure           = octeontx_dev_configure,
1009         .dev_infos_get           = octeontx_dev_info,
1010         .dev_close               = octeontx_dev_close,
1011         .dev_start               = octeontx_dev_start,
1012         .dev_stop                = octeontx_dev_stop,
1013         .promiscuous_enable      = octeontx_dev_promisc_enable,
1014         .promiscuous_disable     = octeontx_dev_promisc_disable,
1015         .link_update             = octeontx_dev_link_update,
1016         .stats_get               = octeontx_dev_stats_get,
1017         .stats_reset             = octeontx_dev_stats_reset,
1018         .mac_addr_set            = octeontx_dev_default_mac_addr_set,
1019         .tx_queue_start          = octeontx_dev_tx_queue_start,
1020         .tx_queue_stop           = octeontx_dev_tx_queue_stop,
1021         .tx_queue_setup          = octeontx_dev_tx_queue_setup,
1022         .tx_queue_release        = octeontx_dev_tx_queue_release,
1023         .rx_queue_setup          = octeontx_dev_rx_queue_setup,
1024         .rx_queue_release        = octeontx_dev_rx_queue_release,
1025         .dev_supported_ptypes_get = octeontx_dev_supported_ptypes_get,
1026         .pool_ops_supported      = octeontx_pool_ops,
1027 };
1028
1029 /* Create Ethdev interface per BGX LMAC ports */
1030 static int
1031 octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
1032                         int socket_id)
1033 {
1034         int res;
1035         char octtx_name[OCTEONTX_MAX_NAME_LEN];
1036         struct octeontx_nic *nic = NULL;
1037         struct rte_eth_dev *eth_dev = NULL;
1038         struct rte_eth_dev_data *data = NULL;
1039         const char *name = rte_vdev_device_name(dev);
1040
1041         PMD_INIT_FUNC_TRACE();
1042
1043         sprintf(octtx_name, "%s_%d", name, port);
1044         if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1045                 eth_dev = rte_eth_dev_attach_secondary(octtx_name);
1046                 if (eth_dev == NULL)
1047                         return -ENODEV;
1048
1049                 eth_dev->tx_pkt_burst = octeontx_xmit_pkts;
1050                 eth_dev->rx_pkt_burst = octeontx_recv_pkts;
1051                 return 0;
1052         }
1053
1054         data = rte_zmalloc_socket(octtx_name, sizeof(*data), 0, socket_id);
1055         if (data == NULL) {
1056                 octeontx_log_err("failed to allocate devdata");
1057                 res = -ENOMEM;
1058                 goto err;
1059         }
1060
1061         nic = rte_zmalloc_socket(octtx_name, sizeof(*nic), 0, socket_id);
1062         if (nic == NULL) {
1063                 octeontx_log_err("failed to allocate nic structure");
1064                 res = -ENOMEM;
1065                 goto err;
1066         }
1067
1068         nic->port_id = port;
1069         nic->evdev = evdev;
1070
1071         res = octeontx_port_open(nic);
1072         if (res < 0)
1073                 goto err;
1074
1075         /* Rx side port configuration */
1076         res = octeontx_pki_port_open(port);
1077         if (res != 0) {
1078                 octeontx_log_err("failed to open PKI port %d", port);
1079                 res = -ENODEV;
1080                 goto err;
1081         }
1082
1083         /* Reserve an ethdev entry */
1084         eth_dev = rte_eth_dev_allocate(octtx_name);
1085         if (eth_dev == NULL) {
1086                 octeontx_log_err("failed to allocate rte_eth_dev");
1087                 res = -ENOMEM;
1088                 goto err;
1089         }
1090
1091         eth_dev->device = &dev->device;
1092         eth_dev->intr_handle = NULL;
1093         eth_dev->data->kdrv = RTE_KDRV_NONE;
1094         eth_dev->data->numa_node = dev->device.numa_node;
1095
1096         rte_memcpy(data, (eth_dev)->data, sizeof(*data));
1097         data->dev_private = nic;
1098
1099         data->port_id = eth_dev->data->port_id;
1100         snprintf(data->name, sizeof(data->name), "%s", eth_dev->data->name);
1101
1102         nic->ev_queues = 1;
1103         nic->ev_ports = 1;
1104
1105         data->dev_link.link_status = ETH_LINK_DOWN;
1106         data->dev_started = 0;
1107         data->promiscuous = 0;
1108         data->all_multicast = 0;
1109         data->scattered_rx = 0;
1110
1111         data->mac_addrs = rte_zmalloc_socket(octtx_name, ETHER_ADDR_LEN, 0,
1112                                                         socket_id);
1113         if (data->mac_addrs == NULL) {
1114                 octeontx_log_err("failed to allocate memory for mac_addrs");
1115                 res = -ENOMEM;
1116                 goto err;
1117         }
1118
1119         eth_dev->data = data;
1120         eth_dev->dev_ops = &octeontx_dev_ops;
1121
1122         /* Finally save ethdev pointer to the NIC structure */
1123         nic->dev = eth_dev;
1124
1125         if (nic->port_id != data->port_id) {
1126                 octeontx_log_err("eth_dev->port_id (%d) is diff to orig (%d)",
1127                                 data->port_id, nic->port_id);
1128                 res = -EINVAL;
1129                 goto err;
1130         }
1131
1132         /* Update port_id mac to eth_dev */
1133         memcpy(data->mac_addrs, nic->mac_addr, ETHER_ADDR_LEN);
1134
1135         PMD_INIT_LOG(DEBUG, "ethdev info: ");
1136         PMD_INIT_LOG(DEBUG, "port %d, port_ena %d ochan %d num_ochan %d tx_q %d",
1137                                 nic->port_id, nic->port_ena,
1138                                 nic->base_ochan, nic->num_ochans,
1139                                 nic->num_tx_queues);
1140         PMD_INIT_LOG(DEBUG, "speed %d mtu %d", nic->speed, nic->mtu);
1141
1142         return data->port_id;
1143
1144 err:
1145         if (port)
1146                 octeontx_port_close(nic);
1147
1148         if (eth_dev != NULL) {
1149                 rte_free(eth_dev->data->mac_addrs);
1150                 rte_free(data);
1151                 rte_free(nic);
1152                 rte_eth_dev_release_port(eth_dev);
1153         }
1154
1155         return res;
1156 }
1157
1158 /* Un initialize octeontx device */
1159 static int
1160 octeontx_remove(struct rte_vdev_device *dev)
1161 {
1162         char octtx_name[OCTEONTX_MAX_NAME_LEN];
1163         struct rte_eth_dev *eth_dev = NULL;
1164         struct octeontx_nic *nic = NULL;
1165         int i;
1166
1167         if (dev == NULL)
1168                 return -EINVAL;
1169
1170         for (i = 0; i < OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT; i++) {
1171                 sprintf(octtx_name, "eth_octeontx_%d", i);
1172
1173                 /* reserve an ethdev entry */
1174                 eth_dev = rte_eth_dev_allocated(octtx_name);
1175                 if (eth_dev == NULL)
1176                         return -ENODEV;
1177
1178                 nic = octeontx_pmd_priv(eth_dev);
1179                 rte_event_dev_stop(nic->evdev);
1180                 PMD_INIT_LOG(INFO, "Closing octeontx device %s", octtx_name);
1181
1182                 rte_free(eth_dev->data->mac_addrs);
1183                 rte_free(eth_dev->data->dev_private);
1184                 rte_free(eth_dev->data);
1185                 rte_eth_dev_release_port(eth_dev);
1186                 rte_event_dev_close(nic->evdev);
1187         }
1188
1189         /* Free FC resource */
1190         octeontx_pko_fc_free();
1191
1192         return 0;
1193 }
1194
1195 /* Initialize octeontx device */
1196 static int
1197 octeontx_probe(struct rte_vdev_device *dev)
1198 {
1199         const char *dev_name;
1200         static int probe_once;
1201         uint8_t socket_id, qlist;
1202         int tx_vfcnt, port_id, evdev, qnum, pnum, res, i;
1203         struct rte_event_dev_config dev_conf;
1204         const char *eventdev_name = "event_octeontx";
1205         struct rte_event_dev_info info;
1206
1207         struct octeontx_vdev_init_params init_params = {
1208                 OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT
1209         };
1210
1211         dev_name = rte_vdev_device_name(dev);
1212         res = octeontx_parse_vdev_init_params(&init_params, dev);
1213         if (res < 0)
1214                 return -EINVAL;
1215
1216         if (init_params.nr_port > OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT) {
1217                 octeontx_log_err("nr_port (%d) > max (%d)", init_params.nr_port,
1218                                 OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT);
1219                 return -ENOTSUP;
1220         }
1221
1222         PMD_INIT_LOG(DEBUG, "initializing %s pmd", dev_name);
1223
1224         socket_id = rte_socket_id();
1225
1226         tx_vfcnt = octeontx_pko_vf_count();
1227
1228         if (tx_vfcnt < init_params.nr_port) {
1229                 octeontx_log_err("not enough PKO (%d) for port number (%d)",
1230                                 tx_vfcnt, init_params.nr_port);
1231                 return -EINVAL;
1232         }
1233         evdev = rte_event_dev_get_dev_id(eventdev_name);
1234         if (evdev < 0) {
1235                 octeontx_log_err("eventdev %s not found", eventdev_name);
1236                 return -ENODEV;
1237         }
1238
1239         res = rte_event_dev_info_get(evdev, &info);
1240         if (res < 0) {
1241                 octeontx_log_err("failed to eventdev info %d", res);
1242                 return -EINVAL;
1243         }
1244
1245         PMD_INIT_LOG(DEBUG, "max_queue %d max_port %d",
1246                         info.max_event_queues, info.max_event_ports);
1247
1248         if (octeontx_pko_init_fc(tx_vfcnt))
1249                 return -ENOMEM;
1250
1251         devconf_set_default_sane_values(&dev_conf, &info);
1252         res = rte_event_dev_configure(evdev, &dev_conf);
1253         if (res < 0)
1254                 goto parse_error;
1255
1256         rte_event_dev_attr_get(evdev, RTE_EVENT_DEV_ATTR_PORT_COUNT,
1257                         (uint32_t *)&pnum);
1258         rte_event_dev_attr_get(evdev, RTE_EVENT_DEV_ATTR_QUEUE_COUNT,
1259                         (uint32_t *)&qnum);
1260         if (pnum < qnum) {
1261                 octeontx_log_err("too few event ports (%d) for event_q(%d)",
1262                                 pnum, qnum);
1263                 res = -EINVAL;
1264                 goto parse_error;
1265         }
1266         if (pnum > qnum) {
1267                 /*
1268                  * We don't poll on event ports
1269                  * that do not have any queues assigned.
1270                  */
1271                 pnum = qnum;
1272                 PMD_INIT_LOG(INFO,
1273                         "reducing number of active event ports to %d", pnum);
1274         }
1275         for (i = 0; i < qnum; i++) {
1276                 res = rte_event_queue_setup(evdev, i, NULL);
1277                 if (res < 0) {
1278                         octeontx_log_err("failed to setup event_q(%d): res %d",
1279                                         i, res);
1280                         goto parse_error;
1281                 }
1282         }
1283
1284         for (i = 0; i < pnum; i++) {
1285                 res = rte_event_port_setup(evdev, i, NULL);
1286                 if (res < 0) {
1287                         res = -ENODEV;
1288                         octeontx_log_err("failed to setup ev port(%d) res=%d",
1289                                                 i, res);
1290                         goto parse_error;
1291                 }
1292                 /* Link one queue to one event port */
1293                 qlist = i;
1294                 res = rte_event_port_link(evdev, i, &qlist, NULL, 1);
1295                 if (res < 0) {
1296                         res = -ENODEV;
1297                         octeontx_log_err("failed to link port (%d): res=%d",
1298                                         i, res);
1299                         goto parse_error;
1300                 }
1301         }
1302
1303         /* Create ethdev interface */
1304         for (i = 0; i < init_params.nr_port; i++) {
1305                 port_id = octeontx_create(dev, i, evdev, socket_id);
1306                 if (port_id < 0) {
1307                         octeontx_log_err("failed to create device %s",
1308                                         dev_name);
1309                         res = -ENODEV;
1310                         goto parse_error;
1311                 }
1312
1313                 PMD_INIT_LOG(INFO, "created ethdev %s for port %d", dev_name,
1314                                         port_id);
1315         }
1316
1317         if (probe_once) {
1318                 octeontx_log_err("interface %s not supported", dev_name);
1319                 octeontx_remove(dev);
1320                 res = -ENOTSUP;
1321                 goto parse_error;
1322         }
1323         probe_once = 1;
1324
1325         return 0;
1326
1327 parse_error:
1328         octeontx_pko_fc_free();
1329         return res;
1330 }
1331
1332 static struct rte_vdev_driver octeontx_pmd_drv = {
1333         .probe = octeontx_probe,
1334         .remove = octeontx_remove,
1335 };
1336
1337 RTE_PMD_REGISTER_VDEV(OCTEONTX_PMD, octeontx_pmd_drv);
1338 RTE_PMD_REGISTER_ALIAS(OCTEONTX_PMD, eth_octeontx);
1339 RTE_PMD_REGISTER_PARAM_STRING(OCTEONTX_PMD, "nr_port=<int> ");