1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Cavium, Inc
5 #include <rte_string_fns.h>
6 #include <rte_ethdev_driver.h>
7 #include <rte_ethdev_pci.h>
8 #include <rte_cycles.h>
9 #include <rte_malloc.h>
10 #include <rte_alarm.h>
11 #include <rte_ether.h>
14 #include "lio_23xx_vf.h"
15 #include "lio_ethdev.h"
19 int lio_logtype_driver;
21 /* Default RSS key in use */
22 static uint8_t lio_rss_key[40] = {
23 0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2,
24 0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0,
25 0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4,
26 0x77, 0xCB, 0x2D, 0xA3, 0x80, 0x30, 0xF2, 0x0C,
27 0x6A, 0x42, 0xB7, 0x3B, 0xBE, 0xAC, 0x01, 0xFA,
30 static const struct rte_eth_desc_lim lio_rx_desc_lim = {
31 .nb_max = CN23XX_MAX_OQ_DESCRIPTORS,
32 .nb_min = CN23XX_MIN_OQ_DESCRIPTORS,
36 static const struct rte_eth_desc_lim lio_tx_desc_lim = {
37 .nb_max = CN23XX_MAX_IQ_DESCRIPTORS,
38 .nb_min = CN23XX_MIN_IQ_DESCRIPTORS,
42 /* Wait for control command to reach nic. */
44 lio_wait_for_ctrl_cmd(struct lio_device *lio_dev,
45 struct lio_dev_ctrl_cmd *ctrl_cmd)
47 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
49 while ((ctrl_cmd->cond == 0) && --timeout) {
50 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
58 * \brief Send Rx control command
59 * @param eth_dev Pointer to the structure rte_eth_dev
60 * @param start_stop whether to start or stop
63 lio_send_rx_ctrl_cmd(struct rte_eth_dev *eth_dev, int start_stop)
65 struct lio_device *lio_dev = LIO_DEV(eth_dev);
66 struct lio_dev_ctrl_cmd ctrl_cmd;
67 struct lio_ctrl_pkt ctrl_pkt;
69 /* flush added to prevent cmd failure
70 * incase the queue is full
72 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
74 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
75 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
77 ctrl_cmd.eth_dev = eth_dev;
80 ctrl_pkt.ncmd.s.cmd = LIO_CMD_RX_CTL;
81 ctrl_pkt.ncmd.s.param1 = start_stop;
82 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
84 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
85 lio_dev_err(lio_dev, "Failed to send RX Control message\n");
89 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
90 lio_dev_err(lio_dev, "RX Control command timed out\n");
97 /* store statistics names and its offset in stats structure */
98 struct rte_lio_xstats_name_off {
99 char name[RTE_ETH_XSTATS_NAME_SIZE];
103 static const struct rte_lio_xstats_name_off rte_lio_stats_strings[] = {
104 {"rx_pkts", offsetof(struct octeon_rx_stats, total_rcvd)},
105 {"rx_bytes", offsetof(struct octeon_rx_stats, bytes_rcvd)},
106 {"rx_broadcast_pkts", offsetof(struct octeon_rx_stats, total_bcst)},
107 {"rx_multicast_pkts", offsetof(struct octeon_rx_stats, total_mcst)},
108 {"rx_flow_ctrl_pkts", offsetof(struct octeon_rx_stats, ctl_rcvd)},
109 {"rx_fifo_err", offsetof(struct octeon_rx_stats, fifo_err)},
110 {"rx_dmac_drop", offsetof(struct octeon_rx_stats, dmac_drop)},
111 {"rx_fcs_err", offsetof(struct octeon_rx_stats, fcs_err)},
112 {"rx_jabber_err", offsetof(struct octeon_rx_stats, jabber_err)},
113 {"rx_l2_err", offsetof(struct octeon_rx_stats, l2_err)},
114 {"rx_vxlan_pkts", offsetof(struct octeon_rx_stats, fw_rx_vxlan)},
115 {"rx_vxlan_err", offsetof(struct octeon_rx_stats, fw_rx_vxlan_err)},
116 {"rx_lro_pkts", offsetof(struct octeon_rx_stats, fw_lro_pkts)},
117 {"tx_pkts", (offsetof(struct octeon_tx_stats, total_pkts_sent)) +
118 sizeof(struct octeon_rx_stats)},
119 {"tx_bytes", (offsetof(struct octeon_tx_stats, total_bytes_sent)) +
120 sizeof(struct octeon_rx_stats)},
121 {"tx_broadcast_pkts",
122 (offsetof(struct octeon_tx_stats, bcast_pkts_sent)) +
123 sizeof(struct octeon_rx_stats)},
124 {"tx_multicast_pkts",
125 (offsetof(struct octeon_tx_stats, mcast_pkts_sent)) +
126 sizeof(struct octeon_rx_stats)},
127 {"tx_flow_ctrl_pkts", (offsetof(struct octeon_tx_stats, ctl_sent)) +
128 sizeof(struct octeon_rx_stats)},
129 {"tx_fifo_err", (offsetof(struct octeon_tx_stats, fifo_err)) +
130 sizeof(struct octeon_rx_stats)},
131 {"tx_total_collisions", (offsetof(struct octeon_tx_stats,
133 sizeof(struct octeon_rx_stats)},
134 {"tx_tso", (offsetof(struct octeon_tx_stats, fw_tso)) +
135 sizeof(struct octeon_rx_stats)},
136 {"tx_vxlan_pkts", (offsetof(struct octeon_tx_stats, fw_tx_vxlan)) +
137 sizeof(struct octeon_rx_stats)},
140 #define LIO_NB_XSTATS RTE_DIM(rte_lio_stats_strings)
142 /* Get hw stats of the port */
144 lio_dev_xstats_get(struct rte_eth_dev *eth_dev, struct rte_eth_xstat *xstats,
147 struct lio_device *lio_dev = LIO_DEV(eth_dev);
148 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
149 struct octeon_link_stats *hw_stats;
150 struct lio_link_stats_resp *resp;
151 struct lio_soft_command *sc;
156 if (!lio_dev->intf_open) {
157 lio_dev_err(lio_dev, "Port %d down\n",
162 if (n < LIO_NB_XSTATS)
163 return LIO_NB_XSTATS;
165 resp_size = sizeof(struct lio_link_stats_resp);
166 sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
170 resp = (struct lio_link_stats_resp *)sc->virtrptr;
171 lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
172 LIO_OPCODE_PORT_STATS, 0, 0, 0);
174 /* Setting wait time in seconds */
175 sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
177 retval = lio_send_soft_command(lio_dev, sc);
178 if (retval == LIO_IQ_SEND_FAILED) {
179 lio_dev_err(lio_dev, "failed to get port stats from firmware. status: %x\n",
184 while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
185 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
186 lio_process_ordered_list(lio_dev);
190 retval = resp->status;
192 lio_dev_err(lio_dev, "failed to get port stats from firmware\n");
196 lio_swap_8B_data((uint64_t *)(&resp->link_stats),
197 sizeof(struct octeon_link_stats) >> 3);
199 hw_stats = &resp->link_stats;
201 for (i = 0; i < LIO_NB_XSTATS; i++) {
204 *(uint64_t *)(((char *)hw_stats) +
205 rte_lio_stats_strings[i].offset);
208 lio_free_soft_command(sc);
210 return LIO_NB_XSTATS;
213 lio_free_soft_command(sc);
219 lio_dev_xstats_get_names(struct rte_eth_dev *eth_dev,
220 struct rte_eth_xstat_name *xstats_names,
221 unsigned limit __rte_unused)
223 struct lio_device *lio_dev = LIO_DEV(eth_dev);
226 if (!lio_dev->intf_open) {
227 lio_dev_err(lio_dev, "Port %d down\n",
232 if (xstats_names == NULL)
233 return LIO_NB_XSTATS;
235 /* Note: limit checked in rte_eth_xstats_names() */
237 for (i = 0; i < LIO_NB_XSTATS; i++) {
238 snprintf(xstats_names[i].name, sizeof(xstats_names[i].name),
239 "%s", rte_lio_stats_strings[i].name);
242 return LIO_NB_XSTATS;
245 /* Reset hw stats for the port */
247 lio_dev_xstats_reset(struct rte_eth_dev *eth_dev)
249 struct lio_device *lio_dev = LIO_DEV(eth_dev);
250 struct lio_dev_ctrl_cmd ctrl_cmd;
251 struct lio_ctrl_pkt ctrl_pkt;
253 if (!lio_dev->intf_open) {
254 lio_dev_err(lio_dev, "Port %d down\n",
259 /* flush added to prevent cmd failure
260 * incase the queue is full
262 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
264 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
265 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
267 ctrl_cmd.eth_dev = eth_dev;
270 ctrl_pkt.ncmd.s.cmd = LIO_CMD_CLEAR_STATS;
271 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
273 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
274 lio_dev_err(lio_dev, "Failed to send clear stats command\n");
278 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
279 lio_dev_err(lio_dev, "Clear stats command timed out\n");
283 /* clear stored per queue stats */
284 RTE_FUNC_PTR_OR_RET(*eth_dev->dev_ops->stats_reset);
285 (*eth_dev->dev_ops->stats_reset)(eth_dev);
288 /* Retrieve the device statistics (# packets in/out, # bytes in/out, etc */
290 lio_dev_stats_get(struct rte_eth_dev *eth_dev,
291 struct rte_eth_stats *stats)
293 struct lio_device *lio_dev = LIO_DEV(eth_dev);
294 struct lio_droq_stats *oq_stats;
295 struct lio_iq_stats *iq_stats;
296 struct lio_instr_queue *txq;
297 struct lio_droq *droq;
303 for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
304 iq_no = lio_dev->linfo.txpciq[i].s.q_no;
305 txq = lio_dev->instr_queue[iq_no];
307 iq_stats = &txq->stats;
308 pkts += iq_stats->tx_done;
309 drop += iq_stats->tx_dropped;
310 bytes += iq_stats->tx_tot_bytes;
314 stats->opackets = pkts;
315 stats->obytes = bytes;
316 stats->oerrors = drop;
322 for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
323 oq_no = lio_dev->linfo.rxpciq[i].s.q_no;
324 droq = lio_dev->droq[oq_no];
326 oq_stats = &droq->stats;
327 pkts += oq_stats->rx_pkts_received;
328 drop += (oq_stats->rx_dropped +
329 oq_stats->dropped_toomany +
330 oq_stats->dropped_nomem);
331 bytes += oq_stats->rx_bytes_received;
334 stats->ibytes = bytes;
335 stats->ipackets = pkts;
336 stats->ierrors = drop;
342 lio_dev_stats_reset(struct rte_eth_dev *eth_dev)
344 struct lio_device *lio_dev = LIO_DEV(eth_dev);
345 struct lio_droq_stats *oq_stats;
346 struct lio_iq_stats *iq_stats;
347 struct lio_instr_queue *txq;
348 struct lio_droq *droq;
351 for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
352 iq_no = lio_dev->linfo.txpciq[i].s.q_no;
353 txq = lio_dev->instr_queue[iq_no];
355 iq_stats = &txq->stats;
356 memset(iq_stats, 0, sizeof(struct lio_iq_stats));
360 for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
361 oq_no = lio_dev->linfo.rxpciq[i].s.q_no;
362 droq = lio_dev->droq[oq_no];
364 oq_stats = &droq->stats;
365 memset(oq_stats, 0, sizeof(struct lio_droq_stats));
371 lio_dev_info_get(struct rte_eth_dev *eth_dev,
372 struct rte_eth_dev_info *devinfo)
374 struct lio_device *lio_dev = LIO_DEV(eth_dev);
375 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
377 switch (pci_dev->id.subsystem_device_id) {
378 /* CN23xx 10G cards */
379 case PCI_SUBSYS_DEV_ID_CN2350_210:
380 case PCI_SUBSYS_DEV_ID_CN2360_210:
381 case PCI_SUBSYS_DEV_ID_CN2350_210SVPN3:
382 case PCI_SUBSYS_DEV_ID_CN2360_210SVPN3:
383 case PCI_SUBSYS_DEV_ID_CN2350_210SVPT:
384 case PCI_SUBSYS_DEV_ID_CN2360_210SVPT:
385 devinfo->speed_capa = ETH_LINK_SPEED_10G;
387 /* CN23xx 25G cards */
388 case PCI_SUBSYS_DEV_ID_CN2350_225:
389 case PCI_SUBSYS_DEV_ID_CN2360_225:
390 devinfo->speed_capa = ETH_LINK_SPEED_25G;
393 devinfo->speed_capa = ETH_LINK_SPEED_10G;
395 "Unknown CN23XX subsystem device id. Setting 10G as default link speed.\n");
398 devinfo->max_rx_queues = lio_dev->max_rx_queues;
399 devinfo->max_tx_queues = lio_dev->max_tx_queues;
401 devinfo->min_rx_bufsize = LIO_MIN_RX_BUF_SIZE;
402 devinfo->max_rx_pktlen = LIO_MAX_RX_PKTLEN;
404 devinfo->max_mac_addrs = 1;
406 devinfo->rx_offload_capa = (DEV_RX_OFFLOAD_IPV4_CKSUM |
407 DEV_RX_OFFLOAD_UDP_CKSUM |
408 DEV_RX_OFFLOAD_TCP_CKSUM |
409 DEV_RX_OFFLOAD_VLAN_STRIP);
410 devinfo->tx_offload_capa = (DEV_TX_OFFLOAD_IPV4_CKSUM |
411 DEV_TX_OFFLOAD_UDP_CKSUM |
412 DEV_TX_OFFLOAD_TCP_CKSUM |
413 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM);
415 devinfo->rx_desc_lim = lio_rx_desc_lim;
416 devinfo->tx_desc_lim = lio_tx_desc_lim;
418 devinfo->reta_size = LIO_RSS_MAX_TABLE_SZ;
419 devinfo->hash_key_size = LIO_RSS_MAX_KEY_SZ;
420 devinfo->flow_type_rss_offloads = (ETH_RSS_IPV4 |
421 ETH_RSS_NONFRAG_IPV4_TCP |
423 ETH_RSS_NONFRAG_IPV6_TCP |
425 ETH_RSS_IPV6_TCP_EX);
429 lio_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu)
431 struct lio_device *lio_dev = LIO_DEV(eth_dev);
432 uint16_t pf_mtu = lio_dev->linfo.link.s.mtu;
433 uint32_t frame_len = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
434 struct lio_dev_ctrl_cmd ctrl_cmd;
435 struct lio_ctrl_pkt ctrl_pkt;
437 PMD_INIT_FUNC_TRACE();
439 if (!lio_dev->intf_open) {
440 lio_dev_err(lio_dev, "Port %d down, can't set MTU\n",
445 /* check if VF MTU is within allowed range.
446 * New value should not exceed PF MTU.
448 if (mtu < RTE_ETHER_MIN_MTU || mtu > pf_mtu) {
449 lio_dev_err(lio_dev, "VF MTU should be >= %d and <= %d\n",
450 RTE_ETHER_MIN_MTU, pf_mtu);
454 /* flush added to prevent cmd failure
455 * incase the queue is full
457 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
459 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
460 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
462 ctrl_cmd.eth_dev = eth_dev;
465 ctrl_pkt.ncmd.s.cmd = LIO_CMD_CHANGE_MTU;
466 ctrl_pkt.ncmd.s.param1 = mtu;
467 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
469 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
470 lio_dev_err(lio_dev, "Failed to send command to change MTU\n");
474 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
475 lio_dev_err(lio_dev, "Command to change MTU timed out\n");
479 if (frame_len > RTE_ETHER_MAX_LEN)
480 eth_dev->data->dev_conf.rxmode.offloads |=
481 DEV_RX_OFFLOAD_JUMBO_FRAME;
483 eth_dev->data->dev_conf.rxmode.offloads &=
484 ~DEV_RX_OFFLOAD_JUMBO_FRAME;
486 eth_dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_len;
487 eth_dev->data->mtu = mtu;
493 lio_dev_rss_reta_update(struct rte_eth_dev *eth_dev,
494 struct rte_eth_rss_reta_entry64 *reta_conf,
497 struct lio_device *lio_dev = LIO_DEV(eth_dev);
498 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
499 struct lio_rss_set *rss_param;
500 struct lio_dev_ctrl_cmd ctrl_cmd;
501 struct lio_ctrl_pkt ctrl_pkt;
504 if (!lio_dev->intf_open) {
505 lio_dev_err(lio_dev, "Port %d down, can't update reta\n",
510 if (reta_size != LIO_RSS_MAX_TABLE_SZ) {
512 "The size of hash lookup table configured (%d) doesn't match the number hardware can supported (%d)\n",
513 reta_size, LIO_RSS_MAX_TABLE_SZ);
517 /* flush added to prevent cmd failure
518 * incase the queue is full
520 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
522 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
523 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
525 rss_param = (struct lio_rss_set *)&ctrl_pkt.udd[0];
527 ctrl_cmd.eth_dev = eth_dev;
530 ctrl_pkt.ncmd.s.cmd = LIO_CMD_SET_RSS;
531 ctrl_pkt.ncmd.s.more = sizeof(struct lio_rss_set) >> 3;
532 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
534 rss_param->param.flags = 0xF;
535 rss_param->param.flags &= ~LIO_RSS_PARAM_ITABLE_UNCHANGED;
536 rss_param->param.itablesize = LIO_RSS_MAX_TABLE_SZ;
538 for (i = 0; i < (reta_size / RTE_RETA_GROUP_SIZE); i++) {
539 for (j = 0; j < RTE_RETA_GROUP_SIZE; j++) {
540 if ((reta_conf[i].mask) & ((uint64_t)1 << j)) {
541 index = (i * RTE_RETA_GROUP_SIZE) + j;
542 rss_state->itable[index] = reta_conf[i].reta[j];
547 rss_state->itable_size = LIO_RSS_MAX_TABLE_SZ;
548 memcpy(rss_param->itable, rss_state->itable, rss_state->itable_size);
550 lio_swap_8B_data((uint64_t *)rss_param, LIO_RSS_PARAM_SIZE >> 3);
552 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
553 lio_dev_err(lio_dev, "Failed to set rss hash\n");
557 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
558 lio_dev_err(lio_dev, "Set rss hash timed out\n");
566 lio_dev_rss_reta_query(struct rte_eth_dev *eth_dev,
567 struct rte_eth_rss_reta_entry64 *reta_conf,
570 struct lio_device *lio_dev = LIO_DEV(eth_dev);
571 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
574 if (reta_size != LIO_RSS_MAX_TABLE_SZ) {
576 "The size of hash lookup table configured (%d) doesn't match the number hardware can supported (%d)\n",
577 reta_size, LIO_RSS_MAX_TABLE_SZ);
581 num = reta_size / RTE_RETA_GROUP_SIZE;
583 for (i = 0; i < num; i++) {
584 memcpy(reta_conf->reta,
585 &rss_state->itable[i * RTE_RETA_GROUP_SIZE],
586 RTE_RETA_GROUP_SIZE);
594 lio_dev_rss_hash_conf_get(struct rte_eth_dev *eth_dev,
595 struct rte_eth_rss_conf *rss_conf)
597 struct lio_device *lio_dev = LIO_DEV(eth_dev);
598 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
599 uint8_t *hash_key = NULL;
602 if (rss_state->hash_disable) {
603 lio_dev_info(lio_dev, "RSS disabled in nic\n");
604 rss_conf->rss_hf = 0;
609 hash_key = rss_conf->rss_key;
610 if (hash_key != NULL)
611 memcpy(hash_key, rss_state->hash_key, rss_state->hash_key_size);
614 rss_hf |= ETH_RSS_IPV4;
615 if (rss_state->tcp_hash)
616 rss_hf |= ETH_RSS_NONFRAG_IPV4_TCP;
618 rss_hf |= ETH_RSS_IPV6;
619 if (rss_state->ipv6_tcp_hash)
620 rss_hf |= ETH_RSS_NONFRAG_IPV6_TCP;
621 if (rss_state->ipv6_ex)
622 rss_hf |= ETH_RSS_IPV6_EX;
623 if (rss_state->ipv6_tcp_ex_hash)
624 rss_hf |= ETH_RSS_IPV6_TCP_EX;
626 rss_conf->rss_hf = rss_hf;
632 lio_dev_rss_hash_update(struct rte_eth_dev *eth_dev,
633 struct rte_eth_rss_conf *rss_conf)
635 struct lio_device *lio_dev = LIO_DEV(eth_dev);
636 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
637 struct lio_rss_set *rss_param;
638 struct lio_dev_ctrl_cmd ctrl_cmd;
639 struct lio_ctrl_pkt ctrl_pkt;
641 if (!lio_dev->intf_open) {
642 lio_dev_err(lio_dev, "Port %d down, can't update hash\n",
647 /* flush added to prevent cmd failure
648 * incase the queue is full
650 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
652 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
653 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
655 rss_param = (struct lio_rss_set *)&ctrl_pkt.udd[0];
657 ctrl_cmd.eth_dev = eth_dev;
660 ctrl_pkt.ncmd.s.cmd = LIO_CMD_SET_RSS;
661 ctrl_pkt.ncmd.s.more = sizeof(struct lio_rss_set) >> 3;
662 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
664 rss_param->param.flags = 0xF;
666 if (rss_conf->rss_key) {
667 rss_param->param.flags &= ~LIO_RSS_PARAM_HASH_KEY_UNCHANGED;
668 rss_state->hash_key_size = LIO_RSS_MAX_KEY_SZ;
669 rss_param->param.hashkeysize = LIO_RSS_MAX_KEY_SZ;
670 memcpy(rss_state->hash_key, rss_conf->rss_key,
671 rss_state->hash_key_size);
672 memcpy(rss_param->key, rss_state->hash_key,
673 rss_state->hash_key_size);
676 if ((rss_conf->rss_hf & LIO_RSS_OFFLOAD_ALL) == 0) {
677 /* Can't disable rss through hash flags,
678 * if it is enabled by default during init
680 if (!rss_state->hash_disable)
683 /* This is for --disable-rss during testpmd launch */
684 rss_param->param.flags |= LIO_RSS_PARAM_DISABLE_RSS;
686 uint32_t hashinfo = 0;
688 /* Can't enable rss if disabled by default during init */
689 if (rss_state->hash_disable)
692 if (rss_conf->rss_hf & ETH_RSS_IPV4) {
693 hashinfo |= LIO_RSS_HASH_IPV4;
699 if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV4_TCP) {
700 hashinfo |= LIO_RSS_HASH_TCP_IPV4;
701 rss_state->tcp_hash = 1;
703 rss_state->tcp_hash = 0;
706 if (rss_conf->rss_hf & ETH_RSS_IPV6) {
707 hashinfo |= LIO_RSS_HASH_IPV6;
713 if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV6_TCP) {
714 hashinfo |= LIO_RSS_HASH_TCP_IPV6;
715 rss_state->ipv6_tcp_hash = 1;
717 rss_state->ipv6_tcp_hash = 0;
720 if (rss_conf->rss_hf & ETH_RSS_IPV6_EX) {
721 hashinfo |= LIO_RSS_HASH_IPV6_EX;
722 rss_state->ipv6_ex = 1;
724 rss_state->ipv6_ex = 0;
727 if (rss_conf->rss_hf & ETH_RSS_IPV6_TCP_EX) {
728 hashinfo |= LIO_RSS_HASH_TCP_IPV6_EX;
729 rss_state->ipv6_tcp_ex_hash = 1;
731 rss_state->ipv6_tcp_ex_hash = 0;
734 rss_param->param.flags &= ~LIO_RSS_PARAM_HASH_INFO_UNCHANGED;
735 rss_param->param.hashinfo = hashinfo;
738 lio_swap_8B_data((uint64_t *)rss_param, LIO_RSS_PARAM_SIZE >> 3);
740 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
741 lio_dev_err(lio_dev, "Failed to set rss hash\n");
745 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
746 lio_dev_err(lio_dev, "Set rss hash timed out\n");
754 * Add vxlan dest udp port for an interface.
757 * Pointer to the structure rte_eth_dev
762 * On success return 0
763 * On failure return -1
766 lio_dev_udp_tunnel_add(struct rte_eth_dev *eth_dev,
767 struct rte_eth_udp_tunnel *udp_tnl)
769 struct lio_device *lio_dev = LIO_DEV(eth_dev);
770 struct lio_dev_ctrl_cmd ctrl_cmd;
771 struct lio_ctrl_pkt ctrl_pkt;
776 if (udp_tnl->prot_type != RTE_TUNNEL_TYPE_VXLAN) {
777 lio_dev_err(lio_dev, "Unsupported tunnel type\n");
781 /* flush added to prevent cmd failure
782 * incase the queue is full
784 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
786 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
787 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
789 ctrl_cmd.eth_dev = eth_dev;
792 ctrl_pkt.ncmd.s.cmd = LIO_CMD_VXLAN_PORT_CONFIG;
793 ctrl_pkt.ncmd.s.param1 = udp_tnl->udp_port;
794 ctrl_pkt.ncmd.s.more = LIO_CMD_VXLAN_PORT_ADD;
795 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
797 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
798 lio_dev_err(lio_dev, "Failed to send VXLAN_PORT_ADD command\n");
802 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
803 lio_dev_err(lio_dev, "VXLAN_PORT_ADD command timed out\n");
811 * Remove vxlan dest udp port for an interface.
814 * Pointer to the structure rte_eth_dev
819 * On success return 0
820 * On failure return -1
823 lio_dev_udp_tunnel_del(struct rte_eth_dev *eth_dev,
824 struct rte_eth_udp_tunnel *udp_tnl)
826 struct lio_device *lio_dev = LIO_DEV(eth_dev);
827 struct lio_dev_ctrl_cmd ctrl_cmd;
828 struct lio_ctrl_pkt ctrl_pkt;
833 if (udp_tnl->prot_type != RTE_TUNNEL_TYPE_VXLAN) {
834 lio_dev_err(lio_dev, "Unsupported tunnel type\n");
838 /* flush added to prevent cmd failure
839 * incase the queue is full
841 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
843 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
844 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
846 ctrl_cmd.eth_dev = eth_dev;
849 ctrl_pkt.ncmd.s.cmd = LIO_CMD_VXLAN_PORT_CONFIG;
850 ctrl_pkt.ncmd.s.param1 = udp_tnl->udp_port;
851 ctrl_pkt.ncmd.s.more = LIO_CMD_VXLAN_PORT_DEL;
852 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
854 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
855 lio_dev_err(lio_dev, "Failed to send VXLAN_PORT_DEL command\n");
859 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
860 lio_dev_err(lio_dev, "VXLAN_PORT_DEL command timed out\n");
868 lio_dev_vlan_filter_set(struct rte_eth_dev *eth_dev, uint16_t vlan_id, int on)
870 struct lio_device *lio_dev = LIO_DEV(eth_dev);
871 struct lio_dev_ctrl_cmd ctrl_cmd;
872 struct lio_ctrl_pkt ctrl_pkt;
874 if (lio_dev->linfo.vlan_is_admin_assigned)
877 /* flush added to prevent cmd failure
878 * incase the queue is full
880 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
882 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
883 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
885 ctrl_cmd.eth_dev = eth_dev;
888 ctrl_pkt.ncmd.s.cmd = on ?
889 LIO_CMD_ADD_VLAN_FILTER : LIO_CMD_DEL_VLAN_FILTER;
890 ctrl_pkt.ncmd.s.param1 = vlan_id;
891 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
893 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
894 lio_dev_err(lio_dev, "Failed to %s VLAN port\n",
895 on ? "add" : "remove");
899 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
900 lio_dev_err(lio_dev, "Command to %s VLAN port timed out\n",
901 on ? "add" : "remove");
909 lio_hweight64(uint64_t w)
911 uint64_t res = w - ((w >> 1) & 0x5555555555555555ul);
914 (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul);
915 res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful;
916 res = res + (res >> 8);
917 res = res + (res >> 16);
919 return (res + (res >> 32)) & 0x00000000000000FFul;
923 lio_dev_link_update(struct rte_eth_dev *eth_dev,
924 int wait_to_complete __rte_unused)
926 struct lio_device *lio_dev = LIO_DEV(eth_dev);
927 struct rte_eth_link link;
930 memset(&link, 0, sizeof(link));
931 link.link_status = ETH_LINK_DOWN;
932 link.link_speed = ETH_SPEED_NUM_NONE;
933 link.link_duplex = ETH_LINK_HALF_DUPLEX;
934 link.link_autoneg = ETH_LINK_AUTONEG;
936 /* Return what we found */
937 if (lio_dev->linfo.link.s.link_up == 0) {
938 /* Interface is down */
939 return rte_eth_linkstatus_set(eth_dev, &link);
942 link.link_status = ETH_LINK_UP; /* Interface is up */
943 link.link_duplex = ETH_LINK_FULL_DUPLEX;
944 switch (lio_dev->linfo.link.s.speed) {
945 case LIO_LINK_SPEED_10000:
946 link.link_speed = ETH_SPEED_NUM_10G;
948 case LIO_LINK_SPEED_25000:
949 link.link_speed = ETH_SPEED_NUM_25G;
952 link.link_speed = ETH_SPEED_NUM_NONE;
953 link.link_duplex = ETH_LINK_HALF_DUPLEX;
956 return rte_eth_linkstatus_set(eth_dev, &link);
960 * \brief Net device enable, disable allmulticast
961 * @param eth_dev Pointer to the structure rte_eth_dev
964 lio_change_dev_flag(struct rte_eth_dev *eth_dev)
966 struct lio_device *lio_dev = LIO_DEV(eth_dev);
967 struct lio_dev_ctrl_cmd ctrl_cmd;
968 struct lio_ctrl_pkt ctrl_pkt;
970 /* flush added to prevent cmd failure
971 * incase the queue is full
973 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
975 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
976 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
978 ctrl_cmd.eth_dev = eth_dev;
981 /* Create a ctrl pkt command to be sent to core app. */
982 ctrl_pkt.ncmd.s.cmd = LIO_CMD_CHANGE_DEVFLAGS;
983 ctrl_pkt.ncmd.s.param1 = lio_dev->ifflags;
984 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
986 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
987 lio_dev_err(lio_dev, "Failed to send change flag message\n");
991 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd))
992 lio_dev_err(lio_dev, "Change dev flag command timed out\n");
996 lio_dev_promiscuous_enable(struct rte_eth_dev *eth_dev)
998 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1000 if (strcmp(lio_dev->firmware_version, LIO_VF_TRUST_MIN_VERSION) < 0) {
1001 lio_dev_err(lio_dev, "Require firmware version >= %s\n",
1002 LIO_VF_TRUST_MIN_VERSION);
1006 if (!lio_dev->intf_open) {
1007 lio_dev_err(lio_dev, "Port %d down, can't enable promiscuous\n",
1012 lio_dev->ifflags |= LIO_IFFLAG_PROMISC;
1013 lio_change_dev_flag(eth_dev);
1017 lio_dev_promiscuous_disable(struct rte_eth_dev *eth_dev)
1019 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1021 if (strcmp(lio_dev->firmware_version, LIO_VF_TRUST_MIN_VERSION) < 0) {
1022 lio_dev_err(lio_dev, "Require firmware version >= %s\n",
1023 LIO_VF_TRUST_MIN_VERSION);
1027 if (!lio_dev->intf_open) {
1028 lio_dev_err(lio_dev, "Port %d down, can't disable promiscuous\n",
1033 lio_dev->ifflags &= ~LIO_IFFLAG_PROMISC;
1034 lio_change_dev_flag(eth_dev);
1038 lio_dev_allmulticast_enable(struct rte_eth_dev *eth_dev)
1040 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1042 if (!lio_dev->intf_open) {
1043 lio_dev_err(lio_dev, "Port %d down, can't enable multicast\n",
1048 lio_dev->ifflags |= LIO_IFFLAG_ALLMULTI;
1049 lio_change_dev_flag(eth_dev);
1053 lio_dev_allmulticast_disable(struct rte_eth_dev *eth_dev)
1055 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1057 if (!lio_dev->intf_open) {
1058 lio_dev_err(lio_dev, "Port %d down, can't disable multicast\n",
1063 lio_dev->ifflags &= ~LIO_IFFLAG_ALLMULTI;
1064 lio_change_dev_flag(eth_dev);
1068 lio_dev_rss_configure(struct rte_eth_dev *eth_dev)
1070 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1071 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
1072 struct rte_eth_rss_reta_entry64 reta_conf[8];
1073 struct rte_eth_rss_conf rss_conf;
1076 /* Configure the RSS key and the RSS protocols used to compute
1077 * the RSS hash of input packets.
1079 rss_conf = eth_dev->data->dev_conf.rx_adv_conf.rss_conf;
1080 if ((rss_conf.rss_hf & LIO_RSS_OFFLOAD_ALL) == 0) {
1081 rss_state->hash_disable = 1;
1082 lio_dev_rss_hash_update(eth_dev, &rss_conf);
1086 if (rss_conf.rss_key == NULL)
1087 rss_conf.rss_key = lio_rss_key; /* Default hash key */
1089 lio_dev_rss_hash_update(eth_dev, &rss_conf);
1091 memset(reta_conf, 0, sizeof(reta_conf));
1092 for (i = 0; i < LIO_RSS_MAX_TABLE_SZ; i++) {
1093 uint8_t q_idx, conf_idx, reta_idx;
1095 q_idx = (uint8_t)((eth_dev->data->nb_rx_queues > 1) ?
1096 i % eth_dev->data->nb_rx_queues : 0);
1097 conf_idx = i / RTE_RETA_GROUP_SIZE;
1098 reta_idx = i % RTE_RETA_GROUP_SIZE;
1099 reta_conf[conf_idx].reta[reta_idx] = q_idx;
1100 reta_conf[conf_idx].mask |= ((uint64_t)1 << reta_idx);
1103 lio_dev_rss_reta_update(eth_dev, reta_conf, LIO_RSS_MAX_TABLE_SZ);
1107 lio_dev_mq_rx_configure(struct rte_eth_dev *eth_dev)
1109 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1110 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
1111 struct rte_eth_rss_conf rss_conf;
1113 switch (eth_dev->data->dev_conf.rxmode.mq_mode) {
1115 lio_dev_rss_configure(eth_dev);
1117 case ETH_MQ_RX_NONE:
1118 /* if mq_mode is none, disable rss mode. */
1120 memset(&rss_conf, 0, sizeof(rss_conf));
1121 rss_state->hash_disable = 1;
1122 lio_dev_rss_hash_update(eth_dev, &rss_conf);
1127 * Setup our receive queue/ringbuffer. This is the
1128 * queue the Octeon uses to send us packets and
1129 * responses. We are given a memory pool for our
1130 * packet buffers that are used to populate the receive
1134 * Pointer to the structure rte_eth_dev
1137 * @param num_rx_descs
1138 * Number of entries in the queue
1140 * Where to allocate memory
1142 * Pointer to the struction rte_eth_rxconf
1144 * Pointer to the packet pool
1147 * - On success, return 0
1148 * - On failure, return -1
1151 lio_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t q_no,
1152 uint16_t num_rx_descs, unsigned int socket_id,
1153 const struct rte_eth_rxconf *rx_conf __rte_unused,
1154 struct rte_mempool *mp)
1156 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1157 struct rte_pktmbuf_pool_private *mbp_priv;
1158 uint32_t fw_mapped_oq;
1161 if (q_no >= lio_dev->nb_rx_queues) {
1162 lio_dev_err(lio_dev, "Invalid rx queue number %u\n", q_no);
1166 lio_dev_dbg(lio_dev, "setting up rx queue %u\n", q_no);
1168 fw_mapped_oq = lio_dev->linfo.rxpciq[q_no].s.q_no;
1170 /* Free previous allocation if any */
1171 if (eth_dev->data->rx_queues[q_no] != NULL) {
1172 lio_dev_rx_queue_release(eth_dev->data->rx_queues[q_no]);
1173 eth_dev->data->rx_queues[q_no] = NULL;
1176 mbp_priv = rte_mempool_get_priv(mp);
1177 buf_size = mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM;
1179 if (lio_setup_droq(lio_dev, fw_mapped_oq, num_rx_descs, buf_size, mp,
1181 lio_dev_err(lio_dev, "droq allocation failed\n");
1185 eth_dev->data->rx_queues[q_no] = lio_dev->droq[fw_mapped_oq];
1191 * Release the receive queue/ringbuffer. Called by
1195 * Opaque pointer to the receive queue to release
1201 lio_dev_rx_queue_release(void *rxq)
1203 struct lio_droq *droq = rxq;
1208 lio_delete_droq_queue(droq->lio_dev, oq_no);
1213 * Allocate and initialize SW ring. Initialize associated HW registers.
1216 * Pointer to structure rte_eth_dev
1221 * @param num_tx_descs
1222 * Number of ringbuffer descriptors
1225 * NUMA socket id, used for memory allocations
1228 * Pointer to the structure rte_eth_txconf
1231 * - On success, return 0
1232 * - On failure, return -errno value
1235 lio_dev_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t q_no,
1236 uint16_t num_tx_descs, unsigned int socket_id,
1237 const struct rte_eth_txconf *tx_conf __rte_unused)
1239 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1240 int fw_mapped_iq = lio_dev->linfo.txpciq[q_no].s.q_no;
1243 if (q_no >= lio_dev->nb_tx_queues) {
1244 lio_dev_err(lio_dev, "Invalid tx queue number %u\n", q_no);
1248 lio_dev_dbg(lio_dev, "setting up tx queue %u\n", q_no);
1250 /* Free previous allocation if any */
1251 if (eth_dev->data->tx_queues[q_no] != NULL) {
1252 lio_dev_tx_queue_release(eth_dev->data->tx_queues[q_no]);
1253 eth_dev->data->tx_queues[q_no] = NULL;
1256 retval = lio_setup_iq(lio_dev, q_no, lio_dev->linfo.txpciq[q_no],
1257 num_tx_descs, lio_dev, socket_id);
1260 lio_dev_err(lio_dev, "Runtime IQ(TxQ) creation failed.\n");
1264 retval = lio_setup_sglists(lio_dev, q_no, fw_mapped_iq,
1265 lio_dev->instr_queue[fw_mapped_iq]->nb_desc,
1269 lio_delete_instruction_queue(lio_dev, fw_mapped_iq);
1273 eth_dev->data->tx_queues[q_no] = lio_dev->instr_queue[fw_mapped_iq];
1279 * Release the transmit queue/ringbuffer. Called by
1283 * Opaque pointer to the transmit queue to release
1289 lio_dev_tx_queue_release(void *txq)
1291 struct lio_instr_queue *tq = txq;
1292 uint32_t fw_mapped_iq_no;
1297 lio_delete_sglist(tq);
1299 fw_mapped_iq_no = tq->txpciq.s.q_no;
1300 lio_delete_instruction_queue(tq->lio_dev, fw_mapped_iq_no);
1305 * Api to check link state.
1308 lio_dev_get_link_status(struct rte_eth_dev *eth_dev)
1310 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1311 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1312 struct lio_link_status_resp *resp;
1313 union octeon_link_status *ls;
1314 struct lio_soft_command *sc;
1317 if (!lio_dev->intf_open)
1320 resp_size = sizeof(struct lio_link_status_resp);
1321 sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
1325 resp = (struct lio_link_status_resp *)sc->virtrptr;
1326 lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
1327 LIO_OPCODE_INFO, 0, 0, 0);
1329 /* Setting wait time in seconds */
1330 sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
1332 if (lio_send_soft_command(lio_dev, sc) == LIO_IQ_SEND_FAILED)
1333 goto get_status_fail;
1335 while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
1336 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
1341 goto get_status_fail;
1343 ls = &resp->link_info.link;
1345 lio_swap_8B_data((uint64_t *)ls, sizeof(union octeon_link_status) >> 3);
1347 if (lio_dev->linfo.link.link_status64 != ls->link_status64) {
1348 if (ls->s.mtu < eth_dev->data->mtu) {
1349 lio_dev_info(lio_dev, "Lowered VF MTU to %d as PF MTU dropped\n",
1351 eth_dev->data->mtu = ls->s.mtu;
1353 lio_dev->linfo.link.link_status64 = ls->link_status64;
1354 lio_dev_link_update(eth_dev, 0);
1357 lio_free_soft_command(sc);
1362 lio_free_soft_command(sc);
1365 /* This function will be invoked every LSC_TIMEOUT ns (100ms)
1366 * and will update link state if it changes.
1369 lio_sync_link_state_check(void *eth_dev)
1371 struct lio_device *lio_dev =
1372 (((struct rte_eth_dev *)eth_dev)->data->dev_private);
1374 if (lio_dev->port_configured)
1375 lio_dev_get_link_status(eth_dev);
1377 /* Schedule periodic link status check.
1378 * Stop check if interface is close and start again while opening.
1380 if (lio_dev->intf_open)
1381 rte_eal_alarm_set(LIO_LSC_TIMEOUT, lio_sync_link_state_check,
1386 lio_dev_start(struct rte_eth_dev *eth_dev)
1389 uint32_t frame_len = eth_dev->data->dev_conf.rxmode.max_rx_pkt_len;
1390 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1391 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1394 lio_dev_info(lio_dev, "Starting port %d\n", eth_dev->data->port_id);
1396 if (lio_dev->fn_list.enable_io_queues(lio_dev))
1399 if (lio_send_rx_ctrl_cmd(eth_dev, 1))
1402 /* Ready for link status updates */
1403 lio_dev->intf_open = 1;
1406 /* Configure RSS if device configured with multiple RX queues. */
1407 lio_dev_mq_rx_configure(eth_dev);
1409 /* Before update the link info,
1410 * must set linfo.link.link_status64 to 0.
1412 lio_dev->linfo.link.link_status64 = 0;
1414 /* start polling for lsc */
1415 ret = rte_eal_alarm_set(LIO_LSC_TIMEOUT,
1416 lio_sync_link_state_check,
1419 lio_dev_err(lio_dev,
1420 "link state check handler creation failed\n");
1421 goto dev_lsc_handle_error;
1424 while ((lio_dev->linfo.link.link_status64 == 0) && (--timeout))
1427 if (lio_dev->linfo.link.link_status64 == 0) {
1429 goto dev_mtu_set_error;
1432 mtu = (uint16_t)(frame_len - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN);
1433 if (mtu < RTE_ETHER_MIN_MTU)
1434 mtu = RTE_ETHER_MIN_MTU;
1436 if (eth_dev->data->mtu != mtu) {
1437 ret = lio_dev_mtu_set(eth_dev, mtu);
1439 goto dev_mtu_set_error;
1445 rte_eal_alarm_cancel(lio_sync_link_state_check, eth_dev);
1447 dev_lsc_handle_error:
1448 lio_dev->intf_open = 0;
1449 lio_send_rx_ctrl_cmd(eth_dev, 0);
1454 /* Stop device and disable input/output functions */
1456 lio_dev_stop(struct rte_eth_dev *eth_dev)
1458 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1460 lio_dev_info(lio_dev, "Stopping port %d\n", eth_dev->data->port_id);
1461 lio_dev->intf_open = 0;
1464 /* Cancel callback if still running. */
1465 rte_eal_alarm_cancel(lio_sync_link_state_check, eth_dev);
1467 lio_send_rx_ctrl_cmd(eth_dev, 0);
1469 lio_wait_for_instr_fetch(lio_dev);
1471 /* Clear recorded link status */
1472 lio_dev->linfo.link.link_status64 = 0;
1476 lio_dev_set_link_up(struct rte_eth_dev *eth_dev)
1478 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1480 if (!lio_dev->intf_open) {
1481 lio_dev_info(lio_dev, "Port is stopped, Start the port first\n");
1485 if (lio_dev->linfo.link.s.link_up) {
1486 lio_dev_info(lio_dev, "Link is already UP\n");
1490 if (lio_send_rx_ctrl_cmd(eth_dev, 1)) {
1491 lio_dev_err(lio_dev, "Unable to set Link UP\n");
1495 lio_dev->linfo.link.s.link_up = 1;
1496 eth_dev->data->dev_link.link_status = ETH_LINK_UP;
1502 lio_dev_set_link_down(struct rte_eth_dev *eth_dev)
1504 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1506 if (!lio_dev->intf_open) {
1507 lio_dev_info(lio_dev, "Port is stopped, Start the port first\n");
1511 if (!lio_dev->linfo.link.s.link_up) {
1512 lio_dev_info(lio_dev, "Link is already DOWN\n");
1516 lio_dev->linfo.link.s.link_up = 0;
1517 eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
1519 if (lio_send_rx_ctrl_cmd(eth_dev, 0)) {
1520 lio_dev->linfo.link.s.link_up = 1;
1521 eth_dev->data->dev_link.link_status = ETH_LINK_UP;
1522 lio_dev_err(lio_dev, "Unable to set Link Down\n");
1530 * Reset and stop the device. This occurs on the first
1531 * call to this routine. Subsequent calls will simply
1532 * return. NB: This will require the NIC to be rebooted.
1535 * Pointer to the structure rte_eth_dev
1541 lio_dev_close(struct rte_eth_dev *eth_dev)
1543 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1545 lio_dev_info(lio_dev, "closing port %d\n", eth_dev->data->port_id);
1547 if (lio_dev->intf_open)
1548 lio_dev_stop(eth_dev);
1550 /* Reset ioq regs */
1551 lio_dev->fn_list.setup_device_regs(lio_dev);
1553 if (lio_dev->pci_dev->kdrv == RTE_KDRV_IGB_UIO) {
1554 cn23xx_vf_ask_pf_to_do_flr(lio_dev);
1555 rte_delay_ms(LIO_PCI_FLR_WAIT);
1559 lio_dev->fn_list.free_mbox(lio_dev);
1561 /* Free glist resources */
1562 rte_free(lio_dev->glist_head);
1563 rte_free(lio_dev->glist_lock);
1564 lio_dev->glist_head = NULL;
1565 lio_dev->glist_lock = NULL;
1567 lio_dev->port_configured = 0;
1569 /* Delete all queues */
1570 lio_dev_clear_queues(eth_dev);
1574 * Enable tunnel rx checksum verification from firmware.
1577 lio_enable_hw_tunnel_rx_checksum(struct rte_eth_dev *eth_dev)
1579 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1580 struct lio_dev_ctrl_cmd ctrl_cmd;
1581 struct lio_ctrl_pkt ctrl_pkt;
1583 /* flush added to prevent cmd failure
1584 * incase the queue is full
1586 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1588 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1589 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1591 ctrl_cmd.eth_dev = eth_dev;
1594 ctrl_pkt.ncmd.s.cmd = LIO_CMD_TNL_RX_CSUM_CTL;
1595 ctrl_pkt.ncmd.s.param1 = LIO_CMD_RXCSUM_ENABLE;
1596 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1598 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1599 lio_dev_err(lio_dev, "Failed to send TNL_RX_CSUM command\n");
1603 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd))
1604 lio_dev_err(lio_dev, "TNL_RX_CSUM command timed out\n");
1608 * Enable checksum calculation for inner packet in a tunnel.
1611 lio_enable_hw_tunnel_tx_checksum(struct rte_eth_dev *eth_dev)
1613 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1614 struct lio_dev_ctrl_cmd ctrl_cmd;
1615 struct lio_ctrl_pkt ctrl_pkt;
1617 /* flush added to prevent cmd failure
1618 * incase the queue is full
1620 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1622 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1623 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1625 ctrl_cmd.eth_dev = eth_dev;
1628 ctrl_pkt.ncmd.s.cmd = LIO_CMD_TNL_TX_CSUM_CTL;
1629 ctrl_pkt.ncmd.s.param1 = LIO_CMD_TXCSUM_ENABLE;
1630 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1632 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1633 lio_dev_err(lio_dev, "Failed to send TNL_TX_CSUM command\n");
1637 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd))
1638 lio_dev_err(lio_dev, "TNL_TX_CSUM command timed out\n");
1642 lio_send_queue_count_update(struct rte_eth_dev *eth_dev, int num_txq,
1645 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1646 struct lio_dev_ctrl_cmd ctrl_cmd;
1647 struct lio_ctrl_pkt ctrl_pkt;
1649 if (strcmp(lio_dev->firmware_version, LIO_Q_RECONF_MIN_VERSION) < 0) {
1650 lio_dev_err(lio_dev, "Require firmware version >= %s\n",
1651 LIO_Q_RECONF_MIN_VERSION);
1655 /* flush added to prevent cmd failure
1656 * incase the queue is full
1658 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1660 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1661 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1663 ctrl_cmd.eth_dev = eth_dev;
1666 ctrl_pkt.ncmd.s.cmd = LIO_CMD_QUEUE_COUNT_CTL;
1667 ctrl_pkt.ncmd.s.param1 = num_txq;
1668 ctrl_pkt.ncmd.s.param2 = num_rxq;
1669 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1671 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1672 lio_dev_err(lio_dev, "Failed to send queue count control command\n");
1676 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
1677 lio_dev_err(lio_dev, "Queue count control command timed out\n");
1685 lio_reconf_queues(struct rte_eth_dev *eth_dev, int num_txq, int num_rxq)
1687 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1689 if (lio_dev->nb_rx_queues != num_rxq ||
1690 lio_dev->nb_tx_queues != num_txq) {
1691 if (lio_send_queue_count_update(eth_dev, num_txq, num_rxq))
1693 lio_dev->nb_rx_queues = num_rxq;
1694 lio_dev->nb_tx_queues = num_txq;
1697 if (lio_dev->intf_open)
1698 lio_dev_stop(eth_dev);
1700 /* Reset ioq registers */
1701 if (lio_dev->fn_list.setup_device_regs(lio_dev)) {
1702 lio_dev_err(lio_dev, "Failed to configure device registers\n");
1710 lio_dev_configure(struct rte_eth_dev *eth_dev)
1712 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1713 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1714 int retval, num_iqueues, num_oqueues;
1715 uint8_t mac[RTE_ETHER_ADDR_LEN], i;
1716 struct lio_if_cfg_resp *resp;
1717 struct lio_soft_command *sc;
1718 union lio_if_cfg if_cfg;
1721 PMD_INIT_FUNC_TRACE();
1723 /* Inform firmware about change in number of queues to use.
1724 * Disable IO queues and reset registers for re-configuration.
1726 if (lio_dev->port_configured)
1727 return lio_reconf_queues(eth_dev,
1728 eth_dev->data->nb_tx_queues,
1729 eth_dev->data->nb_rx_queues);
1731 lio_dev->nb_rx_queues = eth_dev->data->nb_rx_queues;
1732 lio_dev->nb_tx_queues = eth_dev->data->nb_tx_queues;
1734 /* Set max number of queues which can be re-configured. */
1735 lio_dev->max_rx_queues = eth_dev->data->nb_rx_queues;
1736 lio_dev->max_tx_queues = eth_dev->data->nb_tx_queues;
1738 resp_size = sizeof(struct lio_if_cfg_resp);
1739 sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
1743 resp = (struct lio_if_cfg_resp *)sc->virtrptr;
1745 /* Firmware doesn't have capability to reconfigure the queues,
1746 * Claim all queues, and use as many required
1748 if_cfg.if_cfg64 = 0;
1749 if_cfg.s.num_iqueues = lio_dev->nb_tx_queues;
1750 if_cfg.s.num_oqueues = lio_dev->nb_rx_queues;
1751 if_cfg.s.base_queue = 0;
1753 if_cfg.s.gmx_port_id = lio_dev->pf_num;
1755 lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
1756 LIO_OPCODE_IF_CFG, 0,
1757 if_cfg.if_cfg64, 0);
1759 /* Setting wait time in seconds */
1760 sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
1762 retval = lio_send_soft_command(lio_dev, sc);
1763 if (retval == LIO_IQ_SEND_FAILED) {
1764 lio_dev_err(lio_dev, "iq/oq config failed status: %x\n",
1766 /* Soft instr is freed by driver in case of failure. */
1767 goto nic_config_fail;
1770 /* Sleep on a wait queue till the cond flag indicates that the
1771 * response arrived or timed-out.
1773 while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
1774 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
1775 lio_process_ordered_list(lio_dev);
1779 retval = resp->status;
1781 lio_dev_err(lio_dev, "iq/oq config failed\n");
1782 goto nic_config_fail;
1785 strlcpy(lio_dev->firmware_version,
1786 resp->cfg_info.lio_firmware_version, LIO_FW_VERSION_LENGTH);
1788 lio_swap_8B_data((uint64_t *)(&resp->cfg_info),
1789 sizeof(struct octeon_if_cfg_info) >> 3);
1791 num_iqueues = lio_hweight64(resp->cfg_info.iqmask);
1792 num_oqueues = lio_hweight64(resp->cfg_info.oqmask);
1794 if (!(num_iqueues) || !(num_oqueues)) {
1795 lio_dev_err(lio_dev,
1796 "Got bad iqueues (%016lx) or oqueues (%016lx) from firmware.\n",
1797 (unsigned long)resp->cfg_info.iqmask,
1798 (unsigned long)resp->cfg_info.oqmask);
1799 goto nic_config_fail;
1802 lio_dev_dbg(lio_dev,
1803 "interface %d, iqmask %016lx, oqmask %016lx, numiqueues %d, numoqueues %d\n",
1804 eth_dev->data->port_id,
1805 (unsigned long)resp->cfg_info.iqmask,
1806 (unsigned long)resp->cfg_info.oqmask,
1807 num_iqueues, num_oqueues);
1809 lio_dev->linfo.num_rxpciq = num_oqueues;
1810 lio_dev->linfo.num_txpciq = num_iqueues;
1812 for (i = 0; i < num_oqueues; i++) {
1813 lio_dev->linfo.rxpciq[i].rxpciq64 =
1814 resp->cfg_info.linfo.rxpciq[i].rxpciq64;
1815 lio_dev_dbg(lio_dev, "index %d OQ %d\n",
1816 i, lio_dev->linfo.rxpciq[i].s.q_no);
1819 for (i = 0; i < num_iqueues; i++) {
1820 lio_dev->linfo.txpciq[i].txpciq64 =
1821 resp->cfg_info.linfo.txpciq[i].txpciq64;
1822 lio_dev_dbg(lio_dev, "index %d IQ %d\n",
1823 i, lio_dev->linfo.txpciq[i].s.q_no);
1826 lio_dev->linfo.hw_addr = resp->cfg_info.linfo.hw_addr;
1827 lio_dev->linfo.gmxport = resp->cfg_info.linfo.gmxport;
1828 lio_dev->linfo.link.link_status64 =
1829 resp->cfg_info.linfo.link.link_status64;
1831 /* 64-bit swap required on LE machines */
1832 lio_swap_8B_data(&lio_dev->linfo.hw_addr, 1);
1833 for (i = 0; i < RTE_ETHER_ADDR_LEN; i++)
1834 mac[i] = *((uint8_t *)(((uint8_t *)&lio_dev->linfo.hw_addr) +
1837 /* Copy the permanent MAC address */
1838 rte_ether_addr_copy((struct rte_ether_addr *)mac,
1839 ð_dev->data->mac_addrs[0]);
1841 /* enable firmware checksum support for tunnel packets */
1842 lio_enable_hw_tunnel_rx_checksum(eth_dev);
1843 lio_enable_hw_tunnel_tx_checksum(eth_dev);
1845 lio_dev->glist_lock =
1846 rte_zmalloc(NULL, sizeof(*lio_dev->glist_lock) * num_iqueues, 0);
1847 if (lio_dev->glist_lock == NULL)
1850 lio_dev->glist_head =
1851 rte_zmalloc(NULL, sizeof(*lio_dev->glist_head) * num_iqueues,
1853 if (lio_dev->glist_head == NULL) {
1854 rte_free(lio_dev->glist_lock);
1855 lio_dev->glist_lock = NULL;
1859 lio_dev_link_update(eth_dev, 0);
1861 lio_dev->port_configured = 1;
1863 lio_free_soft_command(sc);
1865 /* Reset ioq regs */
1866 lio_dev->fn_list.setup_device_regs(lio_dev);
1868 /* Free iq_0 used during init */
1869 lio_free_instr_queue0(lio_dev);
1874 lio_dev_err(lio_dev, "Failed retval %d\n", retval);
1875 lio_free_soft_command(sc);
1876 lio_free_instr_queue0(lio_dev);
1881 /* Define our ethernet definitions */
1882 static const struct eth_dev_ops liovf_eth_dev_ops = {
1883 .dev_configure = lio_dev_configure,
1884 .dev_start = lio_dev_start,
1885 .dev_stop = lio_dev_stop,
1886 .dev_set_link_up = lio_dev_set_link_up,
1887 .dev_set_link_down = lio_dev_set_link_down,
1888 .dev_close = lio_dev_close,
1889 .promiscuous_enable = lio_dev_promiscuous_enable,
1890 .promiscuous_disable = lio_dev_promiscuous_disable,
1891 .allmulticast_enable = lio_dev_allmulticast_enable,
1892 .allmulticast_disable = lio_dev_allmulticast_disable,
1893 .link_update = lio_dev_link_update,
1894 .stats_get = lio_dev_stats_get,
1895 .xstats_get = lio_dev_xstats_get,
1896 .xstats_get_names = lio_dev_xstats_get_names,
1897 .stats_reset = lio_dev_stats_reset,
1898 .xstats_reset = lio_dev_xstats_reset,
1899 .dev_infos_get = lio_dev_info_get,
1900 .vlan_filter_set = lio_dev_vlan_filter_set,
1901 .rx_queue_setup = lio_dev_rx_queue_setup,
1902 .rx_queue_release = lio_dev_rx_queue_release,
1903 .tx_queue_setup = lio_dev_tx_queue_setup,
1904 .tx_queue_release = lio_dev_tx_queue_release,
1905 .reta_update = lio_dev_rss_reta_update,
1906 .reta_query = lio_dev_rss_reta_query,
1907 .rss_hash_conf_get = lio_dev_rss_hash_conf_get,
1908 .rss_hash_update = lio_dev_rss_hash_update,
1909 .udp_tunnel_port_add = lio_dev_udp_tunnel_add,
1910 .udp_tunnel_port_del = lio_dev_udp_tunnel_del,
1911 .mtu_set = lio_dev_mtu_set,
1915 lio_check_pf_hs_response(void *lio_dev)
1917 struct lio_device *dev = lio_dev;
1919 /* check till response arrives */
1920 if (dev->pfvf_hsword.coproc_tics_per_us)
1923 cn23xx_vf_handle_mbox(dev);
1925 rte_eal_alarm_set(1, lio_check_pf_hs_response, lio_dev);
1929 * \brief Identify the LIO device and to map the BAR address space
1930 * @param lio_dev lio device
1933 lio_chip_specific_setup(struct lio_device *lio_dev)
1935 struct rte_pci_device *pdev = lio_dev->pci_dev;
1936 uint32_t dev_id = pdev->id.device_id;
1941 case LIO_CN23XX_VF_VID:
1942 lio_dev->chip_id = LIO_CN23XX_VF_VID;
1943 ret = cn23xx_vf_setup_device(lio_dev);
1948 lio_dev_err(lio_dev, "Unsupported Chip\n");
1952 lio_dev_info(lio_dev, "DEVICE : %s\n", s);
1958 lio_first_time_init(struct lio_device *lio_dev,
1959 struct rte_pci_device *pdev)
1963 PMD_INIT_FUNC_TRACE();
1965 /* set dpdk specific pci device pointer */
1966 lio_dev->pci_dev = pdev;
1968 /* Identify the LIO type and set device ops */
1969 if (lio_chip_specific_setup(lio_dev)) {
1970 lio_dev_err(lio_dev, "Chip specific setup failed\n");
1974 /* Initialize soft command buffer pool */
1975 if (lio_setup_sc_buffer_pool(lio_dev)) {
1976 lio_dev_err(lio_dev, "sc buffer pool allocation failed\n");
1980 /* Initialize lists to manage the requests of different types that
1981 * arrive from applications for this lio device.
1983 lio_setup_response_list(lio_dev);
1985 if (lio_dev->fn_list.setup_mbox(lio_dev)) {
1986 lio_dev_err(lio_dev, "Mailbox setup failed\n");
1990 /* Check PF response */
1991 lio_check_pf_hs_response((void *)lio_dev);
1993 /* Do handshake and exit if incompatible PF driver */
1994 if (cn23xx_pfvf_handshake(lio_dev))
1997 /* Request and wait for device reset. */
1998 if (pdev->kdrv == RTE_KDRV_IGB_UIO) {
1999 cn23xx_vf_ask_pf_to_do_flr(lio_dev);
2000 /* FLR wait time doubled as a precaution. */
2001 rte_delay_ms(LIO_PCI_FLR_WAIT * 2);
2004 if (lio_dev->fn_list.setup_device_regs(lio_dev)) {
2005 lio_dev_err(lio_dev, "Failed to configure device registers\n");
2009 if (lio_setup_instr_queue0(lio_dev)) {
2010 lio_dev_err(lio_dev, "Failed to setup instruction queue 0\n");
2014 dpdk_queues = (int)lio_dev->sriov_info.rings_per_vf;
2016 lio_dev->max_tx_queues = dpdk_queues;
2017 lio_dev->max_rx_queues = dpdk_queues;
2019 /* Enable input and output queues for this device */
2020 if (lio_dev->fn_list.enable_io_queues(lio_dev))
2026 lio_free_sc_buffer_pool(lio_dev);
2027 if (lio_dev->mbox[0])
2028 lio_dev->fn_list.free_mbox(lio_dev);
2029 if (lio_dev->instr_queue[0])
2030 lio_free_instr_queue0(lio_dev);
2036 lio_eth_dev_uninit(struct rte_eth_dev *eth_dev)
2038 struct lio_device *lio_dev = LIO_DEV(eth_dev);
2040 PMD_INIT_FUNC_TRACE();
2042 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
2045 /* lio_free_sc_buffer_pool */
2046 lio_free_sc_buffer_pool(lio_dev);
2048 eth_dev->dev_ops = NULL;
2049 eth_dev->rx_pkt_burst = NULL;
2050 eth_dev->tx_pkt_burst = NULL;
2056 lio_eth_dev_init(struct rte_eth_dev *eth_dev)
2058 struct rte_pci_device *pdev = RTE_ETH_DEV_TO_PCI(eth_dev);
2059 struct lio_device *lio_dev = LIO_DEV(eth_dev);
2061 PMD_INIT_FUNC_TRACE();
2063 eth_dev->rx_pkt_burst = &lio_dev_recv_pkts;
2064 eth_dev->tx_pkt_burst = &lio_dev_xmit_pkts;
2066 /* Primary does the initialization. */
2067 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
2070 rte_eth_copy_pci_info(eth_dev, pdev);
2072 if (pdev->mem_resource[0].addr) {
2073 lio_dev->hw_addr = pdev->mem_resource[0].addr;
2075 PMD_INIT_LOG(ERR, "ERROR: Failed to map BAR0\n");
2079 lio_dev->eth_dev = eth_dev;
2080 /* set lio device print string */
2081 snprintf(lio_dev->dev_string, sizeof(lio_dev->dev_string),
2082 "%s[%02x:%02x.%x]", pdev->driver->driver.name,
2083 pdev->addr.bus, pdev->addr.devid, pdev->addr.function);
2085 lio_dev->port_id = eth_dev->data->port_id;
2087 if (lio_first_time_init(lio_dev, pdev)) {
2088 lio_dev_err(lio_dev, "Device init failed\n");
2092 eth_dev->dev_ops = &liovf_eth_dev_ops;
2093 eth_dev->data->mac_addrs = rte_zmalloc("lio", RTE_ETHER_ADDR_LEN, 0);
2094 if (eth_dev->data->mac_addrs == NULL) {
2095 lio_dev_err(lio_dev,
2096 "MAC addresses memory allocation failed\n");
2097 eth_dev->dev_ops = NULL;
2098 eth_dev->rx_pkt_burst = NULL;
2099 eth_dev->tx_pkt_burst = NULL;
2103 rte_atomic64_set(&lio_dev->status, LIO_DEV_RUNNING);
2106 lio_dev->port_configured = 0;
2107 /* Always allow unicast packets */
2108 lio_dev->ifflags |= LIO_IFFLAG_UNICAST;
2114 lio_eth_dev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
2115 struct rte_pci_device *pci_dev)
2117 return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct lio_device),
2122 lio_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
2124 return rte_eth_dev_pci_generic_remove(pci_dev,
2125 lio_eth_dev_uninit);
2128 /* Set of PCI devices this driver supports */
2129 static const struct rte_pci_id pci_id_liovf_map[] = {
2130 { RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_VF_VID) },
2131 { .vendor_id = 0, /* sentinel */ }
2134 static struct rte_pci_driver rte_liovf_pmd = {
2135 .id_table = pci_id_liovf_map,
2136 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
2137 .probe = lio_eth_dev_pci_probe,
2138 .remove = lio_eth_dev_pci_remove,
2141 RTE_PMD_REGISTER_PCI(net_liovf, rte_liovf_pmd);
2142 RTE_PMD_REGISTER_PCI_TABLE(net_liovf, pci_id_liovf_map);
2143 RTE_PMD_REGISTER_KMOD_DEP(net_liovf, "* igb_uio | vfio-pci");
2145 RTE_INIT(lio_init_log)
2147 lio_logtype_init = rte_log_register("pmd.net.liquidio.init");
2148 if (lio_logtype_init >= 0)
2149 rte_log_set_level(lio_logtype_init, RTE_LOG_NOTICE);
2150 lio_logtype_driver = rte_log_register("pmd.net.liquidio.driver");
2151 if (lio_logtype_driver >= 0)
2152 rte_log_set_level(lio_logtype_driver, RTE_LOG_NOTICE);