1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Cavium, Inc
5 #include <rte_ethdev.h>
6 #include <rte_ethdev_pci.h>
7 #include <rte_cycles.h>
8 #include <rte_malloc.h>
10 #include <rte_ether.h>
13 #include "lio_23xx_vf.h"
14 #include "lio_ethdev.h"
17 /* Default RSS key in use */
18 static uint8_t lio_rss_key[40] = {
19 0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2,
20 0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0,
21 0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4,
22 0x77, 0xCB, 0x2D, 0xA3, 0x80, 0x30, 0xF2, 0x0C,
23 0x6A, 0x42, 0xB7, 0x3B, 0xBE, 0xAC, 0x01, 0xFA,
26 static const struct rte_eth_desc_lim lio_rx_desc_lim = {
27 .nb_max = CN23XX_MAX_OQ_DESCRIPTORS,
28 .nb_min = CN23XX_MIN_OQ_DESCRIPTORS,
32 static const struct rte_eth_desc_lim lio_tx_desc_lim = {
33 .nb_max = CN23XX_MAX_IQ_DESCRIPTORS,
34 .nb_min = CN23XX_MIN_IQ_DESCRIPTORS,
38 /* Wait for control command to reach nic. */
40 lio_wait_for_ctrl_cmd(struct lio_device *lio_dev,
41 struct lio_dev_ctrl_cmd *ctrl_cmd)
43 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
45 while ((ctrl_cmd->cond == 0) && --timeout) {
46 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
54 * \brief Send Rx control command
55 * @param eth_dev Pointer to the structure rte_eth_dev
56 * @param start_stop whether to start or stop
59 lio_send_rx_ctrl_cmd(struct rte_eth_dev *eth_dev, int start_stop)
61 struct lio_device *lio_dev = LIO_DEV(eth_dev);
62 struct lio_dev_ctrl_cmd ctrl_cmd;
63 struct lio_ctrl_pkt ctrl_pkt;
65 /* flush added to prevent cmd failure
66 * incase the queue is full
68 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
70 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
71 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
73 ctrl_cmd.eth_dev = eth_dev;
76 ctrl_pkt.ncmd.s.cmd = LIO_CMD_RX_CTL;
77 ctrl_pkt.ncmd.s.param1 = start_stop;
78 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
80 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
81 lio_dev_err(lio_dev, "Failed to send RX Control message\n");
85 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
86 lio_dev_err(lio_dev, "RX Control command timed out\n");
93 /* store statistics names and its offset in stats structure */
94 struct rte_lio_xstats_name_off {
95 char name[RTE_ETH_XSTATS_NAME_SIZE];
99 static const struct rte_lio_xstats_name_off rte_lio_stats_strings[] = {
100 {"rx_pkts", offsetof(struct octeon_rx_stats, total_rcvd)},
101 {"rx_bytes", offsetof(struct octeon_rx_stats, bytes_rcvd)},
102 {"rx_broadcast_pkts", offsetof(struct octeon_rx_stats, total_bcst)},
103 {"rx_multicast_pkts", offsetof(struct octeon_rx_stats, total_mcst)},
104 {"rx_flow_ctrl_pkts", offsetof(struct octeon_rx_stats, ctl_rcvd)},
105 {"rx_fifo_err", offsetof(struct octeon_rx_stats, fifo_err)},
106 {"rx_dmac_drop", offsetof(struct octeon_rx_stats, dmac_drop)},
107 {"rx_fcs_err", offsetof(struct octeon_rx_stats, fcs_err)},
108 {"rx_jabber_err", offsetof(struct octeon_rx_stats, jabber_err)},
109 {"rx_l2_err", offsetof(struct octeon_rx_stats, l2_err)},
110 {"rx_vxlan_pkts", offsetof(struct octeon_rx_stats, fw_rx_vxlan)},
111 {"rx_vxlan_err", offsetof(struct octeon_rx_stats, fw_rx_vxlan_err)},
112 {"rx_lro_pkts", offsetof(struct octeon_rx_stats, fw_lro_pkts)},
113 {"tx_pkts", (offsetof(struct octeon_tx_stats, total_pkts_sent)) +
114 sizeof(struct octeon_rx_stats)},
115 {"tx_bytes", (offsetof(struct octeon_tx_stats, total_bytes_sent)) +
116 sizeof(struct octeon_rx_stats)},
117 {"tx_broadcast_pkts",
118 (offsetof(struct octeon_tx_stats, bcast_pkts_sent)) +
119 sizeof(struct octeon_rx_stats)},
120 {"tx_multicast_pkts",
121 (offsetof(struct octeon_tx_stats, mcast_pkts_sent)) +
122 sizeof(struct octeon_rx_stats)},
123 {"tx_flow_ctrl_pkts", (offsetof(struct octeon_tx_stats, ctl_sent)) +
124 sizeof(struct octeon_rx_stats)},
125 {"tx_fifo_err", (offsetof(struct octeon_tx_stats, fifo_err)) +
126 sizeof(struct octeon_rx_stats)},
127 {"tx_total_collisions", (offsetof(struct octeon_tx_stats,
129 sizeof(struct octeon_rx_stats)},
130 {"tx_tso", (offsetof(struct octeon_tx_stats, fw_tso)) +
131 sizeof(struct octeon_rx_stats)},
132 {"tx_vxlan_pkts", (offsetof(struct octeon_tx_stats, fw_tx_vxlan)) +
133 sizeof(struct octeon_rx_stats)},
136 #define LIO_NB_XSTATS RTE_DIM(rte_lio_stats_strings)
138 /* Get hw stats of the port */
140 lio_dev_xstats_get(struct rte_eth_dev *eth_dev, struct rte_eth_xstat *xstats,
143 struct lio_device *lio_dev = LIO_DEV(eth_dev);
144 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
145 struct octeon_link_stats *hw_stats;
146 struct lio_link_stats_resp *resp;
147 struct lio_soft_command *sc;
152 if (!lio_dev->intf_open) {
153 lio_dev_err(lio_dev, "Port %d down\n",
158 if (n < LIO_NB_XSTATS)
159 return LIO_NB_XSTATS;
161 resp_size = sizeof(struct lio_link_stats_resp);
162 sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
166 resp = (struct lio_link_stats_resp *)sc->virtrptr;
167 lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
168 LIO_OPCODE_PORT_STATS, 0, 0, 0);
170 /* Setting wait time in seconds */
171 sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
173 retval = lio_send_soft_command(lio_dev, sc);
174 if (retval == LIO_IQ_SEND_FAILED) {
175 lio_dev_err(lio_dev, "failed to get port stats from firmware. status: %x\n",
180 while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
181 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
182 lio_process_ordered_list(lio_dev);
186 retval = resp->status;
188 lio_dev_err(lio_dev, "failed to get port stats from firmware\n");
192 lio_swap_8B_data((uint64_t *)(&resp->link_stats),
193 sizeof(struct octeon_link_stats) >> 3);
195 hw_stats = &resp->link_stats;
197 for (i = 0; i < LIO_NB_XSTATS; i++) {
200 *(uint64_t *)(((char *)hw_stats) +
201 rte_lio_stats_strings[i].offset);
204 lio_free_soft_command(sc);
206 return LIO_NB_XSTATS;
209 lio_free_soft_command(sc);
215 lio_dev_xstats_get_names(struct rte_eth_dev *eth_dev,
216 struct rte_eth_xstat_name *xstats_names,
217 unsigned limit __rte_unused)
219 struct lio_device *lio_dev = LIO_DEV(eth_dev);
222 if (!lio_dev->intf_open) {
223 lio_dev_err(lio_dev, "Port %d down\n",
228 if (xstats_names == NULL)
229 return LIO_NB_XSTATS;
231 /* Note: limit checked in rte_eth_xstats_names() */
233 for (i = 0; i < LIO_NB_XSTATS; i++) {
234 snprintf(xstats_names[i].name, sizeof(xstats_names[i].name),
235 "%s", rte_lio_stats_strings[i].name);
238 return LIO_NB_XSTATS;
241 /* Reset hw stats for the port */
243 lio_dev_xstats_reset(struct rte_eth_dev *eth_dev)
245 struct lio_device *lio_dev = LIO_DEV(eth_dev);
246 struct lio_dev_ctrl_cmd ctrl_cmd;
247 struct lio_ctrl_pkt ctrl_pkt;
249 if (!lio_dev->intf_open) {
250 lio_dev_err(lio_dev, "Port %d down\n",
255 /* flush added to prevent cmd failure
256 * incase the queue is full
258 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
260 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
261 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
263 ctrl_cmd.eth_dev = eth_dev;
266 ctrl_pkt.ncmd.s.cmd = LIO_CMD_CLEAR_STATS;
267 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
269 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
270 lio_dev_err(lio_dev, "Failed to send clear stats command\n");
274 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
275 lio_dev_err(lio_dev, "Clear stats command timed out\n");
279 /* clear stored per queue stats */
280 RTE_FUNC_PTR_OR_RET(*eth_dev->dev_ops->stats_reset);
281 (*eth_dev->dev_ops->stats_reset)(eth_dev);
284 /* Retrieve the device statistics (# packets in/out, # bytes in/out, etc */
286 lio_dev_stats_get(struct rte_eth_dev *eth_dev,
287 struct rte_eth_stats *stats)
289 struct lio_device *lio_dev = LIO_DEV(eth_dev);
290 struct lio_droq_stats *oq_stats;
291 struct lio_iq_stats *iq_stats;
292 struct lio_instr_queue *txq;
293 struct lio_droq *droq;
299 for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
300 iq_no = lio_dev->linfo.txpciq[i].s.q_no;
301 txq = lio_dev->instr_queue[iq_no];
303 iq_stats = &txq->stats;
304 pkts += iq_stats->tx_done;
305 drop += iq_stats->tx_dropped;
306 bytes += iq_stats->tx_tot_bytes;
310 stats->opackets = pkts;
311 stats->obytes = bytes;
312 stats->oerrors = drop;
318 for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
319 oq_no = lio_dev->linfo.rxpciq[i].s.q_no;
320 droq = lio_dev->droq[oq_no];
322 oq_stats = &droq->stats;
323 pkts += oq_stats->rx_pkts_received;
324 drop += (oq_stats->rx_dropped +
325 oq_stats->dropped_toomany +
326 oq_stats->dropped_nomem);
327 bytes += oq_stats->rx_bytes_received;
330 stats->ibytes = bytes;
331 stats->ipackets = pkts;
332 stats->ierrors = drop;
338 lio_dev_stats_reset(struct rte_eth_dev *eth_dev)
340 struct lio_device *lio_dev = LIO_DEV(eth_dev);
341 struct lio_droq_stats *oq_stats;
342 struct lio_iq_stats *iq_stats;
343 struct lio_instr_queue *txq;
344 struct lio_droq *droq;
347 for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
348 iq_no = lio_dev->linfo.txpciq[i].s.q_no;
349 txq = lio_dev->instr_queue[iq_no];
351 iq_stats = &txq->stats;
352 memset(iq_stats, 0, sizeof(struct lio_iq_stats));
356 for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
357 oq_no = lio_dev->linfo.rxpciq[i].s.q_no;
358 droq = lio_dev->droq[oq_no];
360 oq_stats = &droq->stats;
361 memset(oq_stats, 0, sizeof(struct lio_droq_stats));
367 lio_dev_info_get(struct rte_eth_dev *eth_dev,
368 struct rte_eth_dev_info *devinfo)
370 struct lio_device *lio_dev = LIO_DEV(eth_dev);
371 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
373 devinfo->pci_dev = pci_dev;
375 switch (pci_dev->id.subsystem_device_id) {
376 /* CN23xx 10G cards */
377 case PCI_SUBSYS_DEV_ID_CN2350_210:
378 case PCI_SUBSYS_DEV_ID_CN2360_210:
379 case PCI_SUBSYS_DEV_ID_CN2350_210SVPN3:
380 case PCI_SUBSYS_DEV_ID_CN2360_210SVPN3:
381 case PCI_SUBSYS_DEV_ID_CN2350_210SVPT:
382 case PCI_SUBSYS_DEV_ID_CN2360_210SVPT:
383 devinfo->speed_capa = ETH_LINK_SPEED_10G;
385 /* CN23xx 25G cards */
386 case PCI_SUBSYS_DEV_ID_CN2350_225:
387 case PCI_SUBSYS_DEV_ID_CN2360_225:
388 devinfo->speed_capa = ETH_LINK_SPEED_25G;
391 devinfo->speed_capa = ETH_LINK_SPEED_10G;
393 "Unknown CN23XX subsystem device id. Setting 10G as default link speed.\n");
396 devinfo->max_rx_queues = lio_dev->max_rx_queues;
397 devinfo->max_tx_queues = lio_dev->max_tx_queues;
399 devinfo->min_rx_bufsize = LIO_MIN_RX_BUF_SIZE;
400 devinfo->max_rx_pktlen = LIO_MAX_RX_PKTLEN;
402 devinfo->max_mac_addrs = 1;
404 devinfo->rx_offload_capa = (DEV_RX_OFFLOAD_IPV4_CKSUM |
405 DEV_RX_OFFLOAD_UDP_CKSUM |
406 DEV_RX_OFFLOAD_TCP_CKSUM |
407 DEV_RX_OFFLOAD_VLAN_STRIP);
408 devinfo->tx_offload_capa = (DEV_TX_OFFLOAD_IPV4_CKSUM |
409 DEV_TX_OFFLOAD_UDP_CKSUM |
410 DEV_TX_OFFLOAD_TCP_CKSUM |
411 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM);
413 devinfo->rx_desc_lim = lio_rx_desc_lim;
414 devinfo->tx_desc_lim = lio_tx_desc_lim;
416 devinfo->reta_size = LIO_RSS_MAX_TABLE_SZ;
417 devinfo->hash_key_size = LIO_RSS_MAX_KEY_SZ;
418 devinfo->flow_type_rss_offloads = (ETH_RSS_IPV4 |
419 ETH_RSS_NONFRAG_IPV4_TCP |
421 ETH_RSS_NONFRAG_IPV6_TCP |
423 ETH_RSS_IPV6_TCP_EX);
427 lio_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu)
429 struct lio_device *lio_dev = LIO_DEV(eth_dev);
430 uint16_t pf_mtu = lio_dev->linfo.link.s.mtu;
431 uint32_t frame_len = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
432 struct lio_dev_ctrl_cmd ctrl_cmd;
433 struct lio_ctrl_pkt ctrl_pkt;
435 PMD_INIT_FUNC_TRACE();
437 if (!lio_dev->intf_open) {
438 lio_dev_err(lio_dev, "Port %d down, can't set MTU\n",
443 /* check if VF MTU is within allowed range.
444 * New value should not exceed PF MTU.
446 if ((mtu < ETHER_MIN_MTU) || (mtu > pf_mtu)) {
447 lio_dev_err(lio_dev, "VF MTU should be >= %d and <= %d\n",
448 ETHER_MIN_MTU, pf_mtu);
452 /* flush added to prevent cmd failure
453 * incase the queue is full
455 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
457 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
458 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
460 ctrl_cmd.eth_dev = eth_dev;
463 ctrl_pkt.ncmd.s.cmd = LIO_CMD_CHANGE_MTU;
464 ctrl_pkt.ncmd.s.param1 = mtu;
465 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
467 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
468 lio_dev_err(lio_dev, "Failed to send command to change MTU\n");
472 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
473 lio_dev_err(lio_dev, "Command to change MTU timed out\n");
477 if (frame_len > ETHER_MAX_LEN)
478 eth_dev->data->dev_conf.rxmode.jumbo_frame = 1;
480 eth_dev->data->dev_conf.rxmode.jumbo_frame = 0;
482 eth_dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_len;
483 eth_dev->data->mtu = mtu;
489 lio_dev_rss_reta_update(struct rte_eth_dev *eth_dev,
490 struct rte_eth_rss_reta_entry64 *reta_conf,
493 struct lio_device *lio_dev = LIO_DEV(eth_dev);
494 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
495 struct lio_rss_set *rss_param;
496 struct lio_dev_ctrl_cmd ctrl_cmd;
497 struct lio_ctrl_pkt ctrl_pkt;
500 if (!lio_dev->intf_open) {
501 lio_dev_err(lio_dev, "Port %d down, can't update reta\n",
506 if (reta_size != LIO_RSS_MAX_TABLE_SZ) {
508 "The size of hash lookup table configured (%d) doesn't match the number hardware can supported (%d)\n",
509 reta_size, LIO_RSS_MAX_TABLE_SZ);
513 /* flush added to prevent cmd failure
514 * incase the queue is full
516 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
518 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
519 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
521 rss_param = (struct lio_rss_set *)&ctrl_pkt.udd[0];
523 ctrl_cmd.eth_dev = eth_dev;
526 ctrl_pkt.ncmd.s.cmd = LIO_CMD_SET_RSS;
527 ctrl_pkt.ncmd.s.more = sizeof(struct lio_rss_set) >> 3;
528 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
530 rss_param->param.flags = 0xF;
531 rss_param->param.flags &= ~LIO_RSS_PARAM_ITABLE_UNCHANGED;
532 rss_param->param.itablesize = LIO_RSS_MAX_TABLE_SZ;
534 for (i = 0; i < (reta_size / RTE_RETA_GROUP_SIZE); i++) {
535 for (j = 0; j < RTE_RETA_GROUP_SIZE; j++) {
536 if ((reta_conf[i].mask) & ((uint64_t)1 << j)) {
537 index = (i * RTE_RETA_GROUP_SIZE) + j;
538 rss_state->itable[index] = reta_conf[i].reta[j];
543 rss_state->itable_size = LIO_RSS_MAX_TABLE_SZ;
544 memcpy(rss_param->itable, rss_state->itable, rss_state->itable_size);
546 lio_swap_8B_data((uint64_t *)rss_param, LIO_RSS_PARAM_SIZE >> 3);
548 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
549 lio_dev_err(lio_dev, "Failed to set rss hash\n");
553 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
554 lio_dev_err(lio_dev, "Set rss hash timed out\n");
562 lio_dev_rss_reta_query(struct rte_eth_dev *eth_dev,
563 struct rte_eth_rss_reta_entry64 *reta_conf,
566 struct lio_device *lio_dev = LIO_DEV(eth_dev);
567 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
570 if (reta_size != LIO_RSS_MAX_TABLE_SZ) {
572 "The size of hash lookup table configured (%d) doesn't match the number hardware can supported (%d)\n",
573 reta_size, LIO_RSS_MAX_TABLE_SZ);
577 num = reta_size / RTE_RETA_GROUP_SIZE;
579 for (i = 0; i < num; i++) {
580 memcpy(reta_conf->reta,
581 &rss_state->itable[i * RTE_RETA_GROUP_SIZE],
582 RTE_RETA_GROUP_SIZE);
590 lio_dev_rss_hash_conf_get(struct rte_eth_dev *eth_dev,
591 struct rte_eth_rss_conf *rss_conf)
593 struct lio_device *lio_dev = LIO_DEV(eth_dev);
594 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
595 uint8_t *hash_key = NULL;
598 if (rss_state->hash_disable) {
599 lio_dev_info(lio_dev, "RSS disabled in nic\n");
600 rss_conf->rss_hf = 0;
605 hash_key = rss_conf->rss_key;
606 if (hash_key != NULL)
607 memcpy(hash_key, rss_state->hash_key, rss_state->hash_key_size);
610 rss_hf |= ETH_RSS_IPV4;
611 if (rss_state->tcp_hash)
612 rss_hf |= ETH_RSS_NONFRAG_IPV4_TCP;
614 rss_hf |= ETH_RSS_IPV6;
615 if (rss_state->ipv6_tcp_hash)
616 rss_hf |= ETH_RSS_NONFRAG_IPV6_TCP;
617 if (rss_state->ipv6_ex)
618 rss_hf |= ETH_RSS_IPV6_EX;
619 if (rss_state->ipv6_tcp_ex_hash)
620 rss_hf |= ETH_RSS_IPV6_TCP_EX;
622 rss_conf->rss_hf = rss_hf;
628 lio_dev_rss_hash_update(struct rte_eth_dev *eth_dev,
629 struct rte_eth_rss_conf *rss_conf)
631 struct lio_device *lio_dev = LIO_DEV(eth_dev);
632 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
633 struct lio_rss_set *rss_param;
634 struct lio_dev_ctrl_cmd ctrl_cmd;
635 struct lio_ctrl_pkt ctrl_pkt;
637 if (!lio_dev->intf_open) {
638 lio_dev_err(lio_dev, "Port %d down, can't update hash\n",
643 /* flush added to prevent cmd failure
644 * incase the queue is full
646 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
648 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
649 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
651 rss_param = (struct lio_rss_set *)&ctrl_pkt.udd[0];
653 ctrl_cmd.eth_dev = eth_dev;
656 ctrl_pkt.ncmd.s.cmd = LIO_CMD_SET_RSS;
657 ctrl_pkt.ncmd.s.more = sizeof(struct lio_rss_set) >> 3;
658 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
660 rss_param->param.flags = 0xF;
662 if (rss_conf->rss_key) {
663 rss_param->param.flags &= ~LIO_RSS_PARAM_HASH_KEY_UNCHANGED;
664 rss_state->hash_key_size = LIO_RSS_MAX_KEY_SZ;
665 rss_param->param.hashkeysize = LIO_RSS_MAX_KEY_SZ;
666 memcpy(rss_state->hash_key, rss_conf->rss_key,
667 rss_state->hash_key_size);
668 memcpy(rss_param->key, rss_state->hash_key,
669 rss_state->hash_key_size);
672 if ((rss_conf->rss_hf & LIO_RSS_OFFLOAD_ALL) == 0) {
673 /* Can't disable rss through hash flags,
674 * if it is enabled by default during init
676 if (!rss_state->hash_disable)
679 /* This is for --disable-rss during testpmd launch */
680 rss_param->param.flags |= LIO_RSS_PARAM_DISABLE_RSS;
682 uint32_t hashinfo = 0;
684 /* Can't enable rss if disabled by default during init */
685 if (rss_state->hash_disable)
688 if (rss_conf->rss_hf & ETH_RSS_IPV4) {
689 hashinfo |= LIO_RSS_HASH_IPV4;
695 if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV4_TCP) {
696 hashinfo |= LIO_RSS_HASH_TCP_IPV4;
697 rss_state->tcp_hash = 1;
699 rss_state->tcp_hash = 0;
702 if (rss_conf->rss_hf & ETH_RSS_IPV6) {
703 hashinfo |= LIO_RSS_HASH_IPV6;
709 if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV6_TCP) {
710 hashinfo |= LIO_RSS_HASH_TCP_IPV6;
711 rss_state->ipv6_tcp_hash = 1;
713 rss_state->ipv6_tcp_hash = 0;
716 if (rss_conf->rss_hf & ETH_RSS_IPV6_EX) {
717 hashinfo |= LIO_RSS_HASH_IPV6_EX;
718 rss_state->ipv6_ex = 1;
720 rss_state->ipv6_ex = 0;
723 if (rss_conf->rss_hf & ETH_RSS_IPV6_TCP_EX) {
724 hashinfo |= LIO_RSS_HASH_TCP_IPV6_EX;
725 rss_state->ipv6_tcp_ex_hash = 1;
727 rss_state->ipv6_tcp_ex_hash = 0;
730 rss_param->param.flags &= ~LIO_RSS_PARAM_HASH_INFO_UNCHANGED;
731 rss_param->param.hashinfo = hashinfo;
734 lio_swap_8B_data((uint64_t *)rss_param, LIO_RSS_PARAM_SIZE >> 3);
736 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
737 lio_dev_err(lio_dev, "Failed to set rss hash\n");
741 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
742 lio_dev_err(lio_dev, "Set rss hash timed out\n");
750 * Add vxlan dest udp port for an interface.
753 * Pointer to the structure rte_eth_dev
758 * On success return 0
759 * On failure return -1
762 lio_dev_udp_tunnel_add(struct rte_eth_dev *eth_dev,
763 struct rte_eth_udp_tunnel *udp_tnl)
765 struct lio_device *lio_dev = LIO_DEV(eth_dev);
766 struct lio_dev_ctrl_cmd ctrl_cmd;
767 struct lio_ctrl_pkt ctrl_pkt;
772 if (udp_tnl->prot_type != RTE_TUNNEL_TYPE_VXLAN) {
773 lio_dev_err(lio_dev, "Unsupported tunnel type\n");
777 /* flush added to prevent cmd failure
778 * incase the queue is full
780 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
782 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
783 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
785 ctrl_cmd.eth_dev = eth_dev;
788 ctrl_pkt.ncmd.s.cmd = LIO_CMD_VXLAN_PORT_CONFIG;
789 ctrl_pkt.ncmd.s.param1 = udp_tnl->udp_port;
790 ctrl_pkt.ncmd.s.more = LIO_CMD_VXLAN_PORT_ADD;
791 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
793 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
794 lio_dev_err(lio_dev, "Failed to send VXLAN_PORT_ADD command\n");
798 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
799 lio_dev_err(lio_dev, "VXLAN_PORT_ADD command timed out\n");
807 * Remove vxlan dest udp port for an interface.
810 * Pointer to the structure rte_eth_dev
815 * On success return 0
816 * On failure return -1
819 lio_dev_udp_tunnel_del(struct rte_eth_dev *eth_dev,
820 struct rte_eth_udp_tunnel *udp_tnl)
822 struct lio_device *lio_dev = LIO_DEV(eth_dev);
823 struct lio_dev_ctrl_cmd ctrl_cmd;
824 struct lio_ctrl_pkt ctrl_pkt;
829 if (udp_tnl->prot_type != RTE_TUNNEL_TYPE_VXLAN) {
830 lio_dev_err(lio_dev, "Unsupported tunnel type\n");
834 /* flush added to prevent cmd failure
835 * incase the queue is full
837 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
839 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
840 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
842 ctrl_cmd.eth_dev = eth_dev;
845 ctrl_pkt.ncmd.s.cmd = LIO_CMD_VXLAN_PORT_CONFIG;
846 ctrl_pkt.ncmd.s.param1 = udp_tnl->udp_port;
847 ctrl_pkt.ncmd.s.more = LIO_CMD_VXLAN_PORT_DEL;
848 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
850 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
851 lio_dev_err(lio_dev, "Failed to send VXLAN_PORT_DEL command\n");
855 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
856 lio_dev_err(lio_dev, "VXLAN_PORT_DEL command timed out\n");
864 lio_dev_vlan_filter_set(struct rte_eth_dev *eth_dev, uint16_t vlan_id, int on)
866 struct lio_device *lio_dev = LIO_DEV(eth_dev);
867 struct lio_dev_ctrl_cmd ctrl_cmd;
868 struct lio_ctrl_pkt ctrl_pkt;
870 if (lio_dev->linfo.vlan_is_admin_assigned)
873 /* flush added to prevent cmd failure
874 * incase the queue is full
876 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
878 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
879 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
881 ctrl_cmd.eth_dev = eth_dev;
884 ctrl_pkt.ncmd.s.cmd = on ?
885 LIO_CMD_ADD_VLAN_FILTER : LIO_CMD_DEL_VLAN_FILTER;
886 ctrl_pkt.ncmd.s.param1 = vlan_id;
887 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
889 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
890 lio_dev_err(lio_dev, "Failed to %s VLAN port\n",
891 on ? "add" : "remove");
895 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
896 lio_dev_err(lio_dev, "Command to %s VLAN port timed out\n",
897 on ? "add" : "remove");
905 * Atomically writes the link status information into global
906 * structure rte_eth_dev.
909 * - Pointer to the structure rte_eth_dev to read from.
910 * - Pointer to the buffer to be saved with the link status.
913 * - On success, zero.
914 * - On failure, negative value.
917 lio_dev_atomic_write_link_status(struct rte_eth_dev *eth_dev,
918 struct rte_eth_link *link)
920 struct rte_eth_link *dst = ð_dev->data->dev_link;
921 struct rte_eth_link *src = link;
923 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
924 *(uint64_t *)src) == 0)
931 lio_hweight64(uint64_t w)
933 uint64_t res = w - ((w >> 1) & 0x5555555555555555ul);
936 (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul);
937 res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful;
938 res = res + (res >> 8);
939 res = res + (res >> 16);
941 return (res + (res >> 32)) & 0x00000000000000FFul;
945 lio_dev_link_update(struct rte_eth_dev *eth_dev,
946 int wait_to_complete __rte_unused)
948 struct lio_device *lio_dev = LIO_DEV(eth_dev);
949 struct rte_eth_link link, old;
952 link.link_status = ETH_LINK_DOWN;
953 link.link_speed = ETH_SPEED_NUM_NONE;
954 link.link_duplex = ETH_LINK_HALF_DUPLEX;
955 link.link_autoneg = ETH_LINK_AUTONEG;
956 memset(&old, 0, sizeof(old));
958 /* Return what we found */
959 if (lio_dev->linfo.link.s.link_up == 0) {
960 /* Interface is down */
961 if (lio_dev_atomic_write_link_status(eth_dev, &link))
963 if (link.link_status == old.link_status)
968 link.link_status = ETH_LINK_UP; /* Interface is up */
969 link.link_duplex = ETH_LINK_FULL_DUPLEX;
970 switch (lio_dev->linfo.link.s.speed) {
971 case LIO_LINK_SPEED_10000:
972 link.link_speed = ETH_SPEED_NUM_10G;
974 case LIO_LINK_SPEED_25000:
975 link.link_speed = ETH_SPEED_NUM_25G;
978 link.link_speed = ETH_SPEED_NUM_NONE;
979 link.link_duplex = ETH_LINK_HALF_DUPLEX;
982 if (lio_dev_atomic_write_link_status(eth_dev, &link))
985 if (link.link_status == old.link_status)
992 * \brief Net device enable, disable allmulticast
993 * @param eth_dev Pointer to the structure rte_eth_dev
996 lio_change_dev_flag(struct rte_eth_dev *eth_dev)
998 struct lio_device *lio_dev = LIO_DEV(eth_dev);
999 struct lio_dev_ctrl_cmd ctrl_cmd;
1000 struct lio_ctrl_pkt ctrl_pkt;
1002 /* flush added to prevent cmd failure
1003 * incase the queue is full
1005 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1007 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1008 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1010 ctrl_cmd.eth_dev = eth_dev;
1013 /* Create a ctrl pkt command to be sent to core app. */
1014 ctrl_pkt.ncmd.s.cmd = LIO_CMD_CHANGE_DEVFLAGS;
1015 ctrl_pkt.ncmd.s.param1 = lio_dev->ifflags;
1016 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1018 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1019 lio_dev_err(lio_dev, "Failed to send change flag message\n");
1023 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd))
1024 lio_dev_err(lio_dev, "Change dev flag command timed out\n");
1028 lio_dev_promiscuous_enable(struct rte_eth_dev *eth_dev)
1030 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1032 if (strcmp(lio_dev->firmware_version, LIO_VF_TRUST_MIN_VERSION) < 0) {
1033 lio_dev_err(lio_dev, "Require firmware version >= %s\n",
1034 LIO_VF_TRUST_MIN_VERSION);
1038 if (!lio_dev->intf_open) {
1039 lio_dev_err(lio_dev, "Port %d down, can't enable promiscuous\n",
1044 lio_dev->ifflags |= LIO_IFFLAG_PROMISC;
1045 lio_change_dev_flag(eth_dev);
1049 lio_dev_promiscuous_disable(struct rte_eth_dev *eth_dev)
1051 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1053 if (strcmp(lio_dev->firmware_version, LIO_VF_TRUST_MIN_VERSION) < 0) {
1054 lio_dev_err(lio_dev, "Require firmware version >= %s\n",
1055 LIO_VF_TRUST_MIN_VERSION);
1059 if (!lio_dev->intf_open) {
1060 lio_dev_err(lio_dev, "Port %d down, can't disable promiscuous\n",
1065 lio_dev->ifflags &= ~LIO_IFFLAG_PROMISC;
1066 lio_change_dev_flag(eth_dev);
1070 lio_dev_allmulticast_enable(struct rte_eth_dev *eth_dev)
1072 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1074 if (!lio_dev->intf_open) {
1075 lio_dev_err(lio_dev, "Port %d down, can't enable multicast\n",
1080 lio_dev->ifflags |= LIO_IFFLAG_ALLMULTI;
1081 lio_change_dev_flag(eth_dev);
1085 lio_dev_allmulticast_disable(struct rte_eth_dev *eth_dev)
1087 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1089 if (!lio_dev->intf_open) {
1090 lio_dev_err(lio_dev, "Port %d down, can't disable multicast\n",
1095 lio_dev->ifflags &= ~LIO_IFFLAG_ALLMULTI;
1096 lio_change_dev_flag(eth_dev);
1100 lio_dev_rss_configure(struct rte_eth_dev *eth_dev)
1102 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1103 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
1104 struct rte_eth_rss_reta_entry64 reta_conf[8];
1105 struct rte_eth_rss_conf rss_conf;
1108 /* Configure the RSS key and the RSS protocols used to compute
1109 * the RSS hash of input packets.
1111 rss_conf = eth_dev->data->dev_conf.rx_adv_conf.rss_conf;
1112 if ((rss_conf.rss_hf & LIO_RSS_OFFLOAD_ALL) == 0) {
1113 rss_state->hash_disable = 1;
1114 lio_dev_rss_hash_update(eth_dev, &rss_conf);
1118 if (rss_conf.rss_key == NULL)
1119 rss_conf.rss_key = lio_rss_key; /* Default hash key */
1121 lio_dev_rss_hash_update(eth_dev, &rss_conf);
1123 memset(reta_conf, 0, sizeof(reta_conf));
1124 for (i = 0; i < LIO_RSS_MAX_TABLE_SZ; i++) {
1125 uint8_t q_idx, conf_idx, reta_idx;
1127 q_idx = (uint8_t)((eth_dev->data->nb_rx_queues > 1) ?
1128 i % eth_dev->data->nb_rx_queues : 0);
1129 conf_idx = i / RTE_RETA_GROUP_SIZE;
1130 reta_idx = i % RTE_RETA_GROUP_SIZE;
1131 reta_conf[conf_idx].reta[reta_idx] = q_idx;
1132 reta_conf[conf_idx].mask |= ((uint64_t)1 << reta_idx);
1135 lio_dev_rss_reta_update(eth_dev, reta_conf, LIO_RSS_MAX_TABLE_SZ);
1139 lio_dev_mq_rx_configure(struct rte_eth_dev *eth_dev)
1141 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1142 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
1143 struct rte_eth_rss_conf rss_conf;
1145 switch (eth_dev->data->dev_conf.rxmode.mq_mode) {
1147 lio_dev_rss_configure(eth_dev);
1149 case ETH_MQ_RX_NONE:
1150 /* if mq_mode is none, disable rss mode. */
1152 memset(&rss_conf, 0, sizeof(rss_conf));
1153 rss_state->hash_disable = 1;
1154 lio_dev_rss_hash_update(eth_dev, &rss_conf);
1159 * Setup our receive queue/ringbuffer. This is the
1160 * queue the Octeon uses to send us packets and
1161 * responses. We are given a memory pool for our
1162 * packet buffers that are used to populate the receive
1166 * Pointer to the structure rte_eth_dev
1169 * @param num_rx_descs
1170 * Number of entries in the queue
1172 * Where to allocate memory
1174 * Pointer to the struction rte_eth_rxconf
1176 * Pointer to the packet pool
1179 * - On success, return 0
1180 * - On failure, return -1
1183 lio_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t q_no,
1184 uint16_t num_rx_descs, unsigned int socket_id,
1185 const struct rte_eth_rxconf *rx_conf __rte_unused,
1186 struct rte_mempool *mp)
1188 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1189 struct rte_pktmbuf_pool_private *mbp_priv;
1190 uint32_t fw_mapped_oq;
1193 if (q_no >= lio_dev->nb_rx_queues) {
1194 lio_dev_err(lio_dev, "Invalid rx queue number %u\n", q_no);
1198 lio_dev_dbg(lio_dev, "setting up rx queue %u\n", q_no);
1200 fw_mapped_oq = lio_dev->linfo.rxpciq[q_no].s.q_no;
1202 if ((lio_dev->droq[fw_mapped_oq]) &&
1203 (num_rx_descs != lio_dev->droq[fw_mapped_oq]->max_count)) {
1204 lio_dev_err(lio_dev,
1205 "Reconfiguring Rx descs not supported. Configure descs to same value %u or restart application\n",
1206 lio_dev->droq[fw_mapped_oq]->max_count);
1210 mbp_priv = rte_mempool_get_priv(mp);
1211 buf_size = mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM;
1213 if (lio_setup_droq(lio_dev, fw_mapped_oq, num_rx_descs, buf_size, mp,
1215 lio_dev_err(lio_dev, "droq allocation failed\n");
1219 eth_dev->data->rx_queues[q_no] = lio_dev->droq[fw_mapped_oq];
1225 * Release the receive queue/ringbuffer. Called by
1229 * Opaque pointer to the receive queue to release
1235 lio_dev_rx_queue_release(void *rxq)
1237 struct lio_droq *droq = rxq;
1241 /* Run time queue deletion not supported */
1242 if (droq->lio_dev->port_configured)
1246 lio_delete_droq_queue(droq->lio_dev, oq_no);
1251 * Allocate and initialize SW ring. Initialize associated HW registers.
1254 * Pointer to structure rte_eth_dev
1259 * @param num_tx_descs
1260 * Number of ringbuffer descriptors
1263 * NUMA socket id, used for memory allocations
1266 * Pointer to the structure rte_eth_txconf
1269 * - On success, return 0
1270 * - On failure, return -errno value
1273 lio_dev_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t q_no,
1274 uint16_t num_tx_descs, unsigned int socket_id,
1275 const struct rte_eth_txconf *tx_conf __rte_unused)
1277 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1278 int fw_mapped_iq = lio_dev->linfo.txpciq[q_no].s.q_no;
1281 if (q_no >= lio_dev->nb_tx_queues) {
1282 lio_dev_err(lio_dev, "Invalid tx queue number %u\n", q_no);
1286 lio_dev_dbg(lio_dev, "setting up tx queue %u\n", q_no);
1288 if ((lio_dev->instr_queue[fw_mapped_iq] != NULL) &&
1289 (num_tx_descs != lio_dev->instr_queue[fw_mapped_iq]->max_count)) {
1290 lio_dev_err(lio_dev,
1291 "Reconfiguring Tx descs not supported. Configure descs to same value %u or restart application\n",
1292 lio_dev->instr_queue[fw_mapped_iq]->max_count);
1296 retval = lio_setup_iq(lio_dev, q_no, lio_dev->linfo.txpciq[q_no],
1297 num_tx_descs, lio_dev, socket_id);
1300 lio_dev_err(lio_dev, "Runtime IQ(TxQ) creation failed.\n");
1304 retval = lio_setup_sglists(lio_dev, q_no, fw_mapped_iq,
1305 lio_dev->instr_queue[fw_mapped_iq]->max_count,
1309 lio_delete_instruction_queue(lio_dev, fw_mapped_iq);
1313 eth_dev->data->tx_queues[q_no] = lio_dev->instr_queue[fw_mapped_iq];
1319 * Release the transmit queue/ringbuffer. Called by
1323 * Opaque pointer to the transmit queue to release
1329 lio_dev_tx_queue_release(void *txq)
1331 struct lio_instr_queue *tq = txq;
1332 uint32_t fw_mapped_iq_no;
1336 /* Run time queue deletion not supported */
1337 if (tq->lio_dev->port_configured)
1341 lio_delete_sglist(tq);
1343 fw_mapped_iq_no = tq->txpciq.s.q_no;
1344 lio_delete_instruction_queue(tq->lio_dev, fw_mapped_iq_no);
1349 * Api to check link state.
1352 lio_dev_get_link_status(struct rte_eth_dev *eth_dev)
1354 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1355 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1356 struct lio_link_status_resp *resp;
1357 union octeon_link_status *ls;
1358 struct lio_soft_command *sc;
1361 if (!lio_dev->intf_open)
1364 resp_size = sizeof(struct lio_link_status_resp);
1365 sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
1369 resp = (struct lio_link_status_resp *)sc->virtrptr;
1370 lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
1371 LIO_OPCODE_INFO, 0, 0, 0);
1373 /* Setting wait time in seconds */
1374 sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
1376 if (lio_send_soft_command(lio_dev, sc) == LIO_IQ_SEND_FAILED)
1377 goto get_status_fail;
1379 while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
1380 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
1385 goto get_status_fail;
1387 ls = &resp->link_info.link;
1389 lio_swap_8B_data((uint64_t *)ls, sizeof(union octeon_link_status) >> 3);
1391 if (lio_dev->linfo.link.link_status64 != ls->link_status64) {
1392 if (ls->s.mtu < eth_dev->data->mtu) {
1393 lio_dev_info(lio_dev, "Lowered VF MTU to %d as PF MTU dropped\n",
1395 eth_dev->data->mtu = ls->s.mtu;
1397 lio_dev->linfo.link.link_status64 = ls->link_status64;
1398 lio_dev_link_update(eth_dev, 0);
1401 lio_free_soft_command(sc);
1406 lio_free_soft_command(sc);
1409 /* This function will be invoked every LSC_TIMEOUT ns (100ms)
1410 * and will update link state if it changes.
1413 lio_sync_link_state_check(void *eth_dev)
1415 struct lio_device *lio_dev =
1416 (((struct rte_eth_dev *)eth_dev)->data->dev_private);
1418 if (lio_dev->port_configured)
1419 lio_dev_get_link_status(eth_dev);
1421 /* Schedule periodic link status check.
1422 * Stop check if interface is close and start again while opening.
1424 if (lio_dev->intf_open)
1425 rte_eal_alarm_set(LIO_LSC_TIMEOUT, lio_sync_link_state_check,
1430 lio_dev_start(struct rte_eth_dev *eth_dev)
1433 uint32_t frame_len = eth_dev->data->dev_conf.rxmode.max_rx_pkt_len;
1434 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1435 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1438 lio_dev_info(lio_dev, "Starting port %d\n", eth_dev->data->port_id);
1440 if (lio_dev->fn_list.enable_io_queues(lio_dev))
1443 if (lio_send_rx_ctrl_cmd(eth_dev, 1))
1446 /* Ready for link status updates */
1447 lio_dev->intf_open = 1;
1450 /* Configure RSS if device configured with multiple RX queues. */
1451 lio_dev_mq_rx_configure(eth_dev);
1453 /* start polling for lsc */
1454 ret = rte_eal_alarm_set(LIO_LSC_TIMEOUT,
1455 lio_sync_link_state_check,
1458 lio_dev_err(lio_dev,
1459 "link state check handler creation failed\n");
1460 goto dev_lsc_handle_error;
1463 while ((lio_dev->linfo.link.link_status64 == 0) && (--timeout))
1466 if (lio_dev->linfo.link.link_status64 == 0) {
1468 goto dev_mtu_set_error;
1471 mtu = (uint16_t)(frame_len - ETHER_HDR_LEN - ETHER_CRC_LEN);
1472 if (mtu < ETHER_MIN_MTU)
1473 mtu = ETHER_MIN_MTU;
1475 if (eth_dev->data->mtu != mtu) {
1476 ret = lio_dev_mtu_set(eth_dev, mtu);
1478 goto dev_mtu_set_error;
1484 rte_eal_alarm_cancel(lio_sync_link_state_check, eth_dev);
1486 dev_lsc_handle_error:
1487 lio_dev->intf_open = 0;
1488 lio_send_rx_ctrl_cmd(eth_dev, 0);
1493 /* Stop device and disable input/output functions */
1495 lio_dev_stop(struct rte_eth_dev *eth_dev)
1497 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1499 lio_dev_info(lio_dev, "Stopping port %d\n", eth_dev->data->port_id);
1500 lio_dev->intf_open = 0;
1503 /* Cancel callback if still running. */
1504 rte_eal_alarm_cancel(lio_sync_link_state_check, eth_dev);
1506 lio_send_rx_ctrl_cmd(eth_dev, 0);
1508 /* Clear recorded link status */
1509 lio_dev->linfo.link.link_status64 = 0;
1513 lio_dev_set_link_up(struct rte_eth_dev *eth_dev)
1515 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1517 if (!lio_dev->intf_open) {
1518 lio_dev_info(lio_dev, "Port is stopped, Start the port first\n");
1522 if (lio_dev->linfo.link.s.link_up) {
1523 lio_dev_info(lio_dev, "Link is already UP\n");
1527 if (lio_send_rx_ctrl_cmd(eth_dev, 1)) {
1528 lio_dev_err(lio_dev, "Unable to set Link UP\n");
1532 lio_dev->linfo.link.s.link_up = 1;
1533 eth_dev->data->dev_link.link_status = ETH_LINK_UP;
1539 lio_dev_set_link_down(struct rte_eth_dev *eth_dev)
1541 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1543 if (!lio_dev->intf_open) {
1544 lio_dev_info(lio_dev, "Port is stopped, Start the port first\n");
1548 if (!lio_dev->linfo.link.s.link_up) {
1549 lio_dev_info(lio_dev, "Link is already DOWN\n");
1553 lio_dev->linfo.link.s.link_up = 0;
1554 eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
1556 if (lio_send_rx_ctrl_cmd(eth_dev, 0)) {
1557 lio_dev->linfo.link.s.link_up = 1;
1558 eth_dev->data->dev_link.link_status = ETH_LINK_UP;
1559 lio_dev_err(lio_dev, "Unable to set Link Down\n");
1567 * Reset and stop the device. This occurs on the first
1568 * call to this routine. Subsequent calls will simply
1569 * return. NB: This will require the NIC to be rebooted.
1572 * Pointer to the structure rte_eth_dev
1578 lio_dev_close(struct rte_eth_dev *eth_dev)
1580 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1583 lio_dev_info(lio_dev, "closing port %d\n", eth_dev->data->port_id);
1585 if (lio_dev->intf_open)
1586 lio_dev_stop(eth_dev);
1588 lio_wait_for_instr_fetch(lio_dev);
1590 lio_dev->fn_list.disable_io_queues(lio_dev);
1592 cn23xx_vf_set_io_queues_off(lio_dev);
1594 /* Reset iq regs (IQ_DBELL).
1595 * Clear sli_pktx_cnts (OQ_PKTS_SENT).
1597 for (i = 0; i < lio_dev->nb_rx_queues; i++) {
1598 struct lio_droq *droq = lio_dev->droq[i];
1603 uint32_t pkt_count = rte_read32(droq->pkts_sent_reg);
1605 lio_dev_dbg(lio_dev,
1606 "pending oq count %u\n", pkt_count);
1607 rte_write32(pkt_count, droq->pkts_sent_reg);
1610 if (lio_dev->pci_dev->kdrv == RTE_KDRV_IGB_UIO) {
1611 cn23xx_vf_ask_pf_to_do_flr(lio_dev);
1612 rte_delay_ms(LIO_PCI_FLR_WAIT);
1616 lio_dev->fn_list.free_mbox(lio_dev);
1618 /* Free glist resources */
1619 rte_free(lio_dev->glist_head);
1620 rte_free(lio_dev->glist_lock);
1621 lio_dev->glist_head = NULL;
1622 lio_dev->glist_lock = NULL;
1624 lio_dev->port_configured = 0;
1626 /* Delete all queues */
1627 lio_dev_clear_queues(eth_dev);
1631 * Enable tunnel rx checksum verification from firmware.
1634 lio_enable_hw_tunnel_rx_checksum(struct rte_eth_dev *eth_dev)
1636 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1637 struct lio_dev_ctrl_cmd ctrl_cmd;
1638 struct lio_ctrl_pkt ctrl_pkt;
1640 /* flush added to prevent cmd failure
1641 * incase the queue is full
1643 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1645 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1646 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1648 ctrl_cmd.eth_dev = eth_dev;
1651 ctrl_pkt.ncmd.s.cmd = LIO_CMD_TNL_RX_CSUM_CTL;
1652 ctrl_pkt.ncmd.s.param1 = LIO_CMD_RXCSUM_ENABLE;
1653 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1655 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1656 lio_dev_err(lio_dev, "Failed to send TNL_RX_CSUM command\n");
1660 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd))
1661 lio_dev_err(lio_dev, "TNL_RX_CSUM command timed out\n");
1665 * Enable checksum calculation for inner packet in a tunnel.
1668 lio_enable_hw_tunnel_tx_checksum(struct rte_eth_dev *eth_dev)
1670 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1671 struct lio_dev_ctrl_cmd ctrl_cmd;
1672 struct lio_ctrl_pkt ctrl_pkt;
1674 /* flush added to prevent cmd failure
1675 * incase the queue is full
1677 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1679 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1680 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1682 ctrl_cmd.eth_dev = eth_dev;
1685 ctrl_pkt.ncmd.s.cmd = LIO_CMD_TNL_TX_CSUM_CTL;
1686 ctrl_pkt.ncmd.s.param1 = LIO_CMD_TXCSUM_ENABLE;
1687 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1689 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1690 lio_dev_err(lio_dev, "Failed to send TNL_TX_CSUM command\n");
1694 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd))
1695 lio_dev_err(lio_dev, "TNL_TX_CSUM command timed out\n");
1698 static int lio_dev_configure(struct rte_eth_dev *eth_dev)
1700 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1701 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1702 int retval, num_iqueues, num_oqueues;
1703 uint8_t mac[ETHER_ADDR_LEN], i;
1704 struct lio_if_cfg_resp *resp;
1705 struct lio_soft_command *sc;
1706 union lio_if_cfg if_cfg;
1709 PMD_INIT_FUNC_TRACE();
1711 /* Re-configuring firmware not supported.
1712 * Can't change tx/rx queues per port from initial value.
1714 if (lio_dev->port_configured) {
1715 if ((lio_dev->nb_rx_queues != eth_dev->data->nb_rx_queues) ||
1716 (lio_dev->nb_tx_queues != eth_dev->data->nb_tx_queues)) {
1717 lio_dev_err(lio_dev,
1718 "rxq/txq re-conf not supported. Restart application with new value.\n");
1724 lio_dev->nb_rx_queues = eth_dev->data->nb_rx_queues;
1725 lio_dev->nb_tx_queues = eth_dev->data->nb_tx_queues;
1727 resp_size = sizeof(struct lio_if_cfg_resp);
1728 sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
1732 resp = (struct lio_if_cfg_resp *)sc->virtrptr;
1734 /* Firmware doesn't have capability to reconfigure the queues,
1735 * Claim all queues, and use as many required
1737 if_cfg.if_cfg64 = 0;
1738 if_cfg.s.num_iqueues = lio_dev->nb_tx_queues;
1739 if_cfg.s.num_oqueues = lio_dev->nb_rx_queues;
1740 if_cfg.s.base_queue = 0;
1742 if_cfg.s.gmx_port_id = lio_dev->pf_num;
1744 lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
1745 LIO_OPCODE_IF_CFG, 0,
1746 if_cfg.if_cfg64, 0);
1748 /* Setting wait time in seconds */
1749 sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
1751 retval = lio_send_soft_command(lio_dev, sc);
1752 if (retval == LIO_IQ_SEND_FAILED) {
1753 lio_dev_err(lio_dev, "iq/oq config failed status: %x\n",
1755 /* Soft instr is freed by driver in case of failure. */
1756 goto nic_config_fail;
1759 /* Sleep on a wait queue till the cond flag indicates that the
1760 * response arrived or timed-out.
1762 while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
1763 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
1764 lio_process_ordered_list(lio_dev);
1768 retval = resp->status;
1770 lio_dev_err(lio_dev, "iq/oq config failed\n");
1771 goto nic_config_fail;
1774 snprintf(lio_dev->firmware_version, LIO_FW_VERSION_LENGTH, "%s",
1775 resp->cfg_info.lio_firmware_version);
1777 lio_swap_8B_data((uint64_t *)(&resp->cfg_info),
1778 sizeof(struct octeon_if_cfg_info) >> 3);
1780 num_iqueues = lio_hweight64(resp->cfg_info.iqmask);
1781 num_oqueues = lio_hweight64(resp->cfg_info.oqmask);
1783 if (!(num_iqueues) || !(num_oqueues)) {
1784 lio_dev_err(lio_dev,
1785 "Got bad iqueues (%016lx) or oqueues (%016lx) from firmware.\n",
1786 (unsigned long)resp->cfg_info.iqmask,
1787 (unsigned long)resp->cfg_info.oqmask);
1788 goto nic_config_fail;
1791 lio_dev_dbg(lio_dev,
1792 "interface %d, iqmask %016lx, oqmask %016lx, numiqueues %d, numoqueues %d\n",
1793 eth_dev->data->port_id,
1794 (unsigned long)resp->cfg_info.iqmask,
1795 (unsigned long)resp->cfg_info.oqmask,
1796 num_iqueues, num_oqueues);
1798 lio_dev->linfo.num_rxpciq = num_oqueues;
1799 lio_dev->linfo.num_txpciq = num_iqueues;
1801 for (i = 0; i < num_oqueues; i++) {
1802 lio_dev->linfo.rxpciq[i].rxpciq64 =
1803 resp->cfg_info.linfo.rxpciq[i].rxpciq64;
1804 lio_dev_dbg(lio_dev, "index %d OQ %d\n",
1805 i, lio_dev->linfo.rxpciq[i].s.q_no);
1808 for (i = 0; i < num_iqueues; i++) {
1809 lio_dev->linfo.txpciq[i].txpciq64 =
1810 resp->cfg_info.linfo.txpciq[i].txpciq64;
1811 lio_dev_dbg(lio_dev, "index %d IQ %d\n",
1812 i, lio_dev->linfo.txpciq[i].s.q_no);
1815 lio_dev->linfo.hw_addr = resp->cfg_info.linfo.hw_addr;
1816 lio_dev->linfo.gmxport = resp->cfg_info.linfo.gmxport;
1817 lio_dev->linfo.link.link_status64 =
1818 resp->cfg_info.linfo.link.link_status64;
1820 /* 64-bit swap required on LE machines */
1821 lio_swap_8B_data(&lio_dev->linfo.hw_addr, 1);
1822 for (i = 0; i < ETHER_ADDR_LEN; i++)
1823 mac[i] = *((uint8_t *)(((uint8_t *)&lio_dev->linfo.hw_addr) +
1826 /* Copy the permanent MAC address */
1827 ether_addr_copy((struct ether_addr *)mac, ð_dev->data->mac_addrs[0]);
1829 /* enable firmware checksum support for tunnel packets */
1830 lio_enable_hw_tunnel_rx_checksum(eth_dev);
1831 lio_enable_hw_tunnel_tx_checksum(eth_dev);
1833 lio_dev->glist_lock =
1834 rte_zmalloc(NULL, sizeof(*lio_dev->glist_lock) * num_iqueues, 0);
1835 if (lio_dev->glist_lock == NULL)
1838 lio_dev->glist_head =
1839 rte_zmalloc(NULL, sizeof(*lio_dev->glist_head) * num_iqueues,
1841 if (lio_dev->glist_head == NULL) {
1842 rte_free(lio_dev->glist_lock);
1843 lio_dev->glist_lock = NULL;
1847 lio_dev_link_update(eth_dev, 0);
1849 lio_dev->port_configured = 1;
1851 lio_free_soft_command(sc);
1853 /* Disable iq_0 for reconf */
1854 lio_dev->fn_list.disable_io_queues(lio_dev);
1856 /* Reset ioq regs */
1857 lio_dev->fn_list.setup_device_regs(lio_dev);
1859 /* Free iq_0 used during init */
1860 lio_free_instr_queue0(lio_dev);
1865 lio_dev_err(lio_dev, "Failed retval %d\n", retval);
1866 lio_free_soft_command(sc);
1867 lio_free_instr_queue0(lio_dev);
1872 /* Define our ethernet definitions */
1873 static const struct eth_dev_ops liovf_eth_dev_ops = {
1874 .dev_configure = lio_dev_configure,
1875 .dev_start = lio_dev_start,
1876 .dev_stop = lio_dev_stop,
1877 .dev_set_link_up = lio_dev_set_link_up,
1878 .dev_set_link_down = lio_dev_set_link_down,
1879 .dev_close = lio_dev_close,
1880 .promiscuous_enable = lio_dev_promiscuous_enable,
1881 .promiscuous_disable = lio_dev_promiscuous_disable,
1882 .allmulticast_enable = lio_dev_allmulticast_enable,
1883 .allmulticast_disable = lio_dev_allmulticast_disable,
1884 .link_update = lio_dev_link_update,
1885 .stats_get = lio_dev_stats_get,
1886 .xstats_get = lio_dev_xstats_get,
1887 .xstats_get_names = lio_dev_xstats_get_names,
1888 .stats_reset = lio_dev_stats_reset,
1889 .xstats_reset = lio_dev_xstats_reset,
1890 .dev_infos_get = lio_dev_info_get,
1891 .vlan_filter_set = lio_dev_vlan_filter_set,
1892 .rx_queue_setup = lio_dev_rx_queue_setup,
1893 .rx_queue_release = lio_dev_rx_queue_release,
1894 .tx_queue_setup = lio_dev_tx_queue_setup,
1895 .tx_queue_release = lio_dev_tx_queue_release,
1896 .reta_update = lio_dev_rss_reta_update,
1897 .reta_query = lio_dev_rss_reta_query,
1898 .rss_hash_conf_get = lio_dev_rss_hash_conf_get,
1899 .rss_hash_update = lio_dev_rss_hash_update,
1900 .udp_tunnel_port_add = lio_dev_udp_tunnel_add,
1901 .udp_tunnel_port_del = lio_dev_udp_tunnel_del,
1902 .mtu_set = lio_dev_mtu_set,
1906 lio_check_pf_hs_response(void *lio_dev)
1908 struct lio_device *dev = lio_dev;
1910 /* check till response arrives */
1911 if (dev->pfvf_hsword.coproc_tics_per_us)
1914 cn23xx_vf_handle_mbox(dev);
1916 rte_eal_alarm_set(1, lio_check_pf_hs_response, lio_dev);
1920 * \brief Identify the LIO device and to map the BAR address space
1921 * @param lio_dev lio device
1924 lio_chip_specific_setup(struct lio_device *lio_dev)
1926 struct rte_pci_device *pdev = lio_dev->pci_dev;
1927 uint32_t dev_id = pdev->id.device_id;
1932 case LIO_CN23XX_VF_VID:
1933 lio_dev->chip_id = LIO_CN23XX_VF_VID;
1934 ret = cn23xx_vf_setup_device(lio_dev);
1939 lio_dev_err(lio_dev, "Unsupported Chip\n");
1943 lio_dev_info(lio_dev, "DEVICE : %s\n", s);
1949 lio_first_time_init(struct lio_device *lio_dev,
1950 struct rte_pci_device *pdev)
1954 PMD_INIT_FUNC_TRACE();
1956 /* set dpdk specific pci device pointer */
1957 lio_dev->pci_dev = pdev;
1959 /* Identify the LIO type and set device ops */
1960 if (lio_chip_specific_setup(lio_dev)) {
1961 lio_dev_err(lio_dev, "Chip specific setup failed\n");
1965 /* Initialize soft command buffer pool */
1966 if (lio_setup_sc_buffer_pool(lio_dev)) {
1967 lio_dev_err(lio_dev, "sc buffer pool allocation failed\n");
1971 /* Initialize lists to manage the requests of different types that
1972 * arrive from applications for this lio device.
1974 lio_setup_response_list(lio_dev);
1976 if (lio_dev->fn_list.setup_mbox(lio_dev)) {
1977 lio_dev_err(lio_dev, "Mailbox setup failed\n");
1981 /* Check PF response */
1982 lio_check_pf_hs_response((void *)lio_dev);
1984 /* Do handshake and exit if incompatible PF driver */
1985 if (cn23xx_pfvf_handshake(lio_dev))
1988 /* Request and wait for device reset. */
1989 if (pdev->kdrv == RTE_KDRV_IGB_UIO) {
1990 cn23xx_vf_ask_pf_to_do_flr(lio_dev);
1991 /* FLR wait time doubled as a precaution. */
1992 rte_delay_ms(LIO_PCI_FLR_WAIT * 2);
1995 if (cn23xx_vf_set_io_queues_off(lio_dev)) {
1996 lio_dev_err(lio_dev, "Setting io queues off failed\n");
2000 if (lio_dev->fn_list.setup_device_regs(lio_dev)) {
2001 lio_dev_err(lio_dev, "Failed to configure device registers\n");
2005 if (lio_setup_instr_queue0(lio_dev)) {
2006 lio_dev_err(lio_dev, "Failed to setup instruction queue 0\n");
2010 dpdk_queues = (int)lio_dev->sriov_info.rings_per_vf;
2012 lio_dev->max_tx_queues = dpdk_queues;
2013 lio_dev->max_rx_queues = dpdk_queues;
2015 /* Enable input and output queues for this device */
2016 if (lio_dev->fn_list.enable_io_queues(lio_dev))
2022 lio_free_sc_buffer_pool(lio_dev);
2023 if (lio_dev->mbox[0])
2024 lio_dev->fn_list.free_mbox(lio_dev);
2025 if (lio_dev->instr_queue[0])
2026 lio_free_instr_queue0(lio_dev);
2032 lio_eth_dev_uninit(struct rte_eth_dev *eth_dev)
2034 struct lio_device *lio_dev = LIO_DEV(eth_dev);
2036 PMD_INIT_FUNC_TRACE();
2038 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
2041 /* lio_free_sc_buffer_pool */
2042 lio_free_sc_buffer_pool(lio_dev);
2044 rte_free(eth_dev->data->mac_addrs);
2045 eth_dev->data->mac_addrs = NULL;
2047 eth_dev->dev_ops = NULL;
2048 eth_dev->rx_pkt_burst = NULL;
2049 eth_dev->tx_pkt_burst = NULL;
2055 lio_eth_dev_init(struct rte_eth_dev *eth_dev)
2057 struct rte_pci_device *pdev = RTE_ETH_DEV_TO_PCI(eth_dev);
2058 struct lio_device *lio_dev = LIO_DEV(eth_dev);
2060 PMD_INIT_FUNC_TRACE();
2062 eth_dev->rx_pkt_burst = &lio_dev_recv_pkts;
2063 eth_dev->tx_pkt_burst = &lio_dev_xmit_pkts;
2065 /* Primary does the initialization. */
2066 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
2069 rte_eth_copy_pci_info(eth_dev, pdev);
2071 if (pdev->mem_resource[0].addr) {
2072 lio_dev->hw_addr = pdev->mem_resource[0].addr;
2074 PMD_INIT_LOG(ERR, "ERROR: Failed to map BAR0\n");
2078 lio_dev->eth_dev = eth_dev;
2079 /* set lio device print string */
2080 snprintf(lio_dev->dev_string, sizeof(lio_dev->dev_string),
2081 "%s[%02x:%02x.%x]", pdev->driver->driver.name,
2082 pdev->addr.bus, pdev->addr.devid, pdev->addr.function);
2084 lio_dev->port_id = eth_dev->data->port_id;
2086 if (lio_first_time_init(lio_dev, pdev)) {
2087 lio_dev_err(lio_dev, "Device init failed\n");
2091 eth_dev->dev_ops = &liovf_eth_dev_ops;
2092 eth_dev->data->mac_addrs = rte_zmalloc("lio", ETHER_ADDR_LEN, 0);
2093 if (eth_dev->data->mac_addrs == NULL) {
2094 lio_dev_err(lio_dev,
2095 "MAC addresses memory allocation failed\n");
2096 eth_dev->dev_ops = NULL;
2097 eth_dev->rx_pkt_burst = NULL;
2098 eth_dev->tx_pkt_burst = NULL;
2102 rte_atomic64_set(&lio_dev->status, LIO_DEV_RUNNING);
2105 lio_dev->port_configured = 0;
2106 /* Always allow unicast packets */
2107 lio_dev->ifflags |= LIO_IFFLAG_UNICAST;
2113 lio_eth_dev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
2114 struct rte_pci_device *pci_dev)
2116 struct rte_eth_dev *eth_dev;
2119 eth_dev = rte_eth_dev_pci_allocate(pci_dev,
2120 sizeof(struct lio_device));
2121 if (eth_dev == NULL)
2124 ret = lio_eth_dev_init(eth_dev);
2126 rte_eth_dev_pci_release(eth_dev);
2132 lio_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
2134 return rte_eth_dev_pci_generic_remove(pci_dev,
2135 lio_eth_dev_uninit);
2138 /* Set of PCI devices this driver supports */
2139 static const struct rte_pci_id pci_id_liovf_map[] = {
2140 { RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_VF_VID) },
2141 { .vendor_id = 0, /* sentinel */ }
2144 static struct rte_pci_driver rte_liovf_pmd = {
2145 .id_table = pci_id_liovf_map,
2146 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
2147 .probe = lio_eth_dev_pci_probe,
2148 .remove = lio_eth_dev_pci_remove,
2151 RTE_PMD_REGISTER_PCI(net_liovf, rte_liovf_pmd);
2152 RTE_PMD_REGISTER_PCI_TABLE(net_liovf, pci_id_liovf_map);
2153 RTE_PMD_REGISTER_KMOD_DEP(net_liovf, "* igb_uio | vfio-pci");