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;
254 if (!lio_dev->intf_open) {
255 lio_dev_err(lio_dev, "Port %d down\n",
260 /* flush added to prevent cmd failure
261 * incase the queue is full
263 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
265 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
266 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
268 ctrl_cmd.eth_dev = eth_dev;
271 ctrl_pkt.ncmd.s.cmd = LIO_CMD_CLEAR_STATS;
272 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
274 ret = lio_send_ctrl_pkt(lio_dev, &ctrl_pkt);
276 lio_dev_err(lio_dev, "Failed to send clear stats command\n");
280 ret = lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd);
282 lio_dev_err(lio_dev, "Clear stats command timed out\n");
286 /* clear stored per queue stats */
287 RTE_FUNC_PTR_OR_ERR_RET(*eth_dev->dev_ops->stats_reset, 0);
288 return (*eth_dev->dev_ops->stats_reset)(eth_dev);
291 /* Retrieve the device statistics (# packets in/out, # bytes in/out, etc */
293 lio_dev_stats_get(struct rte_eth_dev *eth_dev,
294 struct rte_eth_stats *stats)
296 struct lio_device *lio_dev = LIO_DEV(eth_dev);
297 struct lio_droq_stats *oq_stats;
298 struct lio_iq_stats *iq_stats;
299 struct lio_instr_queue *txq;
300 struct lio_droq *droq;
306 for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
307 iq_no = lio_dev->linfo.txpciq[i].s.q_no;
308 txq = lio_dev->instr_queue[iq_no];
310 iq_stats = &txq->stats;
311 pkts += iq_stats->tx_done;
312 drop += iq_stats->tx_dropped;
313 bytes += iq_stats->tx_tot_bytes;
317 stats->opackets = pkts;
318 stats->obytes = bytes;
319 stats->oerrors = drop;
325 for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
326 oq_no = lio_dev->linfo.rxpciq[i].s.q_no;
327 droq = lio_dev->droq[oq_no];
329 oq_stats = &droq->stats;
330 pkts += oq_stats->rx_pkts_received;
331 drop += (oq_stats->rx_dropped +
332 oq_stats->dropped_toomany +
333 oq_stats->dropped_nomem);
334 bytes += oq_stats->rx_bytes_received;
337 stats->ibytes = bytes;
338 stats->ipackets = pkts;
339 stats->ierrors = drop;
345 lio_dev_stats_reset(struct rte_eth_dev *eth_dev)
347 struct lio_device *lio_dev = LIO_DEV(eth_dev);
348 struct lio_droq_stats *oq_stats;
349 struct lio_iq_stats *iq_stats;
350 struct lio_instr_queue *txq;
351 struct lio_droq *droq;
354 for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
355 iq_no = lio_dev->linfo.txpciq[i].s.q_no;
356 txq = lio_dev->instr_queue[iq_no];
358 iq_stats = &txq->stats;
359 memset(iq_stats, 0, sizeof(struct lio_iq_stats));
363 for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
364 oq_no = lio_dev->linfo.rxpciq[i].s.q_no;
365 droq = lio_dev->droq[oq_no];
367 oq_stats = &droq->stats;
368 memset(oq_stats, 0, sizeof(struct lio_droq_stats));
376 lio_dev_info_get(struct rte_eth_dev *eth_dev,
377 struct rte_eth_dev_info *devinfo)
379 struct lio_device *lio_dev = LIO_DEV(eth_dev);
380 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
382 switch (pci_dev->id.subsystem_device_id) {
383 /* CN23xx 10G cards */
384 case PCI_SUBSYS_DEV_ID_CN2350_210:
385 case PCI_SUBSYS_DEV_ID_CN2360_210:
386 case PCI_SUBSYS_DEV_ID_CN2350_210SVPN3:
387 case PCI_SUBSYS_DEV_ID_CN2360_210SVPN3:
388 case PCI_SUBSYS_DEV_ID_CN2350_210SVPT:
389 case PCI_SUBSYS_DEV_ID_CN2360_210SVPT:
390 devinfo->speed_capa = ETH_LINK_SPEED_10G;
392 /* CN23xx 25G cards */
393 case PCI_SUBSYS_DEV_ID_CN2350_225:
394 case PCI_SUBSYS_DEV_ID_CN2360_225:
395 devinfo->speed_capa = ETH_LINK_SPEED_25G;
398 devinfo->speed_capa = ETH_LINK_SPEED_10G;
400 "Unknown CN23XX subsystem device id. Setting 10G as default link speed.\n");
404 devinfo->max_rx_queues = lio_dev->max_rx_queues;
405 devinfo->max_tx_queues = lio_dev->max_tx_queues;
407 devinfo->min_rx_bufsize = LIO_MIN_RX_BUF_SIZE;
408 devinfo->max_rx_pktlen = LIO_MAX_RX_PKTLEN;
410 devinfo->max_mac_addrs = 1;
412 devinfo->rx_offload_capa = (DEV_RX_OFFLOAD_IPV4_CKSUM |
413 DEV_RX_OFFLOAD_UDP_CKSUM |
414 DEV_RX_OFFLOAD_TCP_CKSUM |
415 DEV_RX_OFFLOAD_VLAN_STRIP);
416 devinfo->tx_offload_capa = (DEV_TX_OFFLOAD_IPV4_CKSUM |
417 DEV_TX_OFFLOAD_UDP_CKSUM |
418 DEV_TX_OFFLOAD_TCP_CKSUM |
419 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM);
421 devinfo->rx_desc_lim = lio_rx_desc_lim;
422 devinfo->tx_desc_lim = lio_tx_desc_lim;
424 devinfo->reta_size = LIO_RSS_MAX_TABLE_SZ;
425 devinfo->hash_key_size = LIO_RSS_MAX_KEY_SZ;
426 devinfo->flow_type_rss_offloads = (ETH_RSS_IPV4 |
427 ETH_RSS_NONFRAG_IPV4_TCP |
429 ETH_RSS_NONFRAG_IPV6_TCP |
431 ETH_RSS_IPV6_TCP_EX);
436 lio_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu)
438 struct lio_device *lio_dev = LIO_DEV(eth_dev);
439 uint16_t pf_mtu = lio_dev->linfo.link.s.mtu;
440 uint32_t frame_len = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
441 struct lio_dev_ctrl_cmd ctrl_cmd;
442 struct lio_ctrl_pkt ctrl_pkt;
444 PMD_INIT_FUNC_TRACE();
446 if (!lio_dev->intf_open) {
447 lio_dev_err(lio_dev, "Port %d down, can't set MTU\n",
452 /* check if VF MTU is within allowed range.
453 * New value should not exceed PF MTU.
455 if (mtu < RTE_ETHER_MIN_MTU || mtu > pf_mtu) {
456 lio_dev_err(lio_dev, "VF MTU should be >= %d and <= %d\n",
457 RTE_ETHER_MIN_MTU, pf_mtu);
461 /* flush added to prevent cmd failure
462 * incase the queue is full
464 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
466 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
467 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
469 ctrl_cmd.eth_dev = eth_dev;
472 ctrl_pkt.ncmd.s.cmd = LIO_CMD_CHANGE_MTU;
473 ctrl_pkt.ncmd.s.param1 = mtu;
474 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
476 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
477 lio_dev_err(lio_dev, "Failed to send command to change MTU\n");
481 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
482 lio_dev_err(lio_dev, "Command to change MTU timed out\n");
486 if (frame_len > RTE_ETHER_MAX_LEN)
487 eth_dev->data->dev_conf.rxmode.offloads |=
488 DEV_RX_OFFLOAD_JUMBO_FRAME;
490 eth_dev->data->dev_conf.rxmode.offloads &=
491 ~DEV_RX_OFFLOAD_JUMBO_FRAME;
493 eth_dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_len;
494 eth_dev->data->mtu = mtu;
500 lio_dev_rss_reta_update(struct rte_eth_dev *eth_dev,
501 struct rte_eth_rss_reta_entry64 *reta_conf,
504 struct lio_device *lio_dev = LIO_DEV(eth_dev);
505 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
506 struct lio_rss_set *rss_param;
507 struct lio_dev_ctrl_cmd ctrl_cmd;
508 struct lio_ctrl_pkt ctrl_pkt;
511 if (!lio_dev->intf_open) {
512 lio_dev_err(lio_dev, "Port %d down, can't update reta\n",
517 if (reta_size != LIO_RSS_MAX_TABLE_SZ) {
519 "The size of hash lookup table configured (%d) doesn't match the number hardware can supported (%d)\n",
520 reta_size, LIO_RSS_MAX_TABLE_SZ);
524 /* flush added to prevent cmd failure
525 * incase the queue is full
527 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
529 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
530 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
532 rss_param = (struct lio_rss_set *)&ctrl_pkt.udd[0];
534 ctrl_cmd.eth_dev = eth_dev;
537 ctrl_pkt.ncmd.s.cmd = LIO_CMD_SET_RSS;
538 ctrl_pkt.ncmd.s.more = sizeof(struct lio_rss_set) >> 3;
539 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
541 rss_param->param.flags = 0xF;
542 rss_param->param.flags &= ~LIO_RSS_PARAM_ITABLE_UNCHANGED;
543 rss_param->param.itablesize = LIO_RSS_MAX_TABLE_SZ;
545 for (i = 0; i < (reta_size / RTE_RETA_GROUP_SIZE); i++) {
546 for (j = 0; j < RTE_RETA_GROUP_SIZE; j++) {
547 if ((reta_conf[i].mask) & ((uint64_t)1 << j)) {
548 index = (i * RTE_RETA_GROUP_SIZE) + j;
549 rss_state->itable[index] = reta_conf[i].reta[j];
554 rss_state->itable_size = LIO_RSS_MAX_TABLE_SZ;
555 memcpy(rss_param->itable, rss_state->itable, rss_state->itable_size);
557 lio_swap_8B_data((uint64_t *)rss_param, LIO_RSS_PARAM_SIZE >> 3);
559 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
560 lio_dev_err(lio_dev, "Failed to set rss hash\n");
564 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
565 lio_dev_err(lio_dev, "Set rss hash timed out\n");
573 lio_dev_rss_reta_query(struct rte_eth_dev *eth_dev,
574 struct rte_eth_rss_reta_entry64 *reta_conf,
577 struct lio_device *lio_dev = LIO_DEV(eth_dev);
578 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
581 if (reta_size != LIO_RSS_MAX_TABLE_SZ) {
583 "The size of hash lookup table configured (%d) doesn't match the number hardware can supported (%d)\n",
584 reta_size, LIO_RSS_MAX_TABLE_SZ);
588 num = reta_size / RTE_RETA_GROUP_SIZE;
590 for (i = 0; i < num; i++) {
591 memcpy(reta_conf->reta,
592 &rss_state->itable[i * RTE_RETA_GROUP_SIZE],
593 RTE_RETA_GROUP_SIZE);
601 lio_dev_rss_hash_conf_get(struct rte_eth_dev *eth_dev,
602 struct rte_eth_rss_conf *rss_conf)
604 struct lio_device *lio_dev = LIO_DEV(eth_dev);
605 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
606 uint8_t *hash_key = NULL;
609 if (rss_state->hash_disable) {
610 lio_dev_info(lio_dev, "RSS disabled in nic\n");
611 rss_conf->rss_hf = 0;
616 hash_key = rss_conf->rss_key;
617 if (hash_key != NULL)
618 memcpy(hash_key, rss_state->hash_key, rss_state->hash_key_size);
621 rss_hf |= ETH_RSS_IPV4;
622 if (rss_state->tcp_hash)
623 rss_hf |= ETH_RSS_NONFRAG_IPV4_TCP;
625 rss_hf |= ETH_RSS_IPV6;
626 if (rss_state->ipv6_tcp_hash)
627 rss_hf |= ETH_RSS_NONFRAG_IPV6_TCP;
628 if (rss_state->ipv6_ex)
629 rss_hf |= ETH_RSS_IPV6_EX;
630 if (rss_state->ipv6_tcp_ex_hash)
631 rss_hf |= ETH_RSS_IPV6_TCP_EX;
633 rss_conf->rss_hf = rss_hf;
639 lio_dev_rss_hash_update(struct rte_eth_dev *eth_dev,
640 struct rte_eth_rss_conf *rss_conf)
642 struct lio_device *lio_dev = LIO_DEV(eth_dev);
643 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
644 struct lio_rss_set *rss_param;
645 struct lio_dev_ctrl_cmd ctrl_cmd;
646 struct lio_ctrl_pkt ctrl_pkt;
648 if (!lio_dev->intf_open) {
649 lio_dev_err(lio_dev, "Port %d down, can't update hash\n",
654 /* flush added to prevent cmd failure
655 * incase the queue is full
657 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
659 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
660 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
662 rss_param = (struct lio_rss_set *)&ctrl_pkt.udd[0];
664 ctrl_cmd.eth_dev = eth_dev;
667 ctrl_pkt.ncmd.s.cmd = LIO_CMD_SET_RSS;
668 ctrl_pkt.ncmd.s.more = sizeof(struct lio_rss_set) >> 3;
669 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
671 rss_param->param.flags = 0xF;
673 if (rss_conf->rss_key) {
674 rss_param->param.flags &= ~LIO_RSS_PARAM_HASH_KEY_UNCHANGED;
675 rss_state->hash_key_size = LIO_RSS_MAX_KEY_SZ;
676 rss_param->param.hashkeysize = LIO_RSS_MAX_KEY_SZ;
677 memcpy(rss_state->hash_key, rss_conf->rss_key,
678 rss_state->hash_key_size);
679 memcpy(rss_param->key, rss_state->hash_key,
680 rss_state->hash_key_size);
683 if ((rss_conf->rss_hf & LIO_RSS_OFFLOAD_ALL) == 0) {
684 /* Can't disable rss through hash flags,
685 * if it is enabled by default during init
687 if (!rss_state->hash_disable)
690 /* This is for --disable-rss during testpmd launch */
691 rss_param->param.flags |= LIO_RSS_PARAM_DISABLE_RSS;
693 uint32_t hashinfo = 0;
695 /* Can't enable rss if disabled by default during init */
696 if (rss_state->hash_disable)
699 if (rss_conf->rss_hf & ETH_RSS_IPV4) {
700 hashinfo |= LIO_RSS_HASH_IPV4;
706 if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV4_TCP) {
707 hashinfo |= LIO_RSS_HASH_TCP_IPV4;
708 rss_state->tcp_hash = 1;
710 rss_state->tcp_hash = 0;
713 if (rss_conf->rss_hf & ETH_RSS_IPV6) {
714 hashinfo |= LIO_RSS_HASH_IPV6;
720 if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV6_TCP) {
721 hashinfo |= LIO_RSS_HASH_TCP_IPV6;
722 rss_state->ipv6_tcp_hash = 1;
724 rss_state->ipv6_tcp_hash = 0;
727 if (rss_conf->rss_hf & ETH_RSS_IPV6_EX) {
728 hashinfo |= LIO_RSS_HASH_IPV6_EX;
729 rss_state->ipv6_ex = 1;
731 rss_state->ipv6_ex = 0;
734 if (rss_conf->rss_hf & ETH_RSS_IPV6_TCP_EX) {
735 hashinfo |= LIO_RSS_HASH_TCP_IPV6_EX;
736 rss_state->ipv6_tcp_ex_hash = 1;
738 rss_state->ipv6_tcp_ex_hash = 0;
741 rss_param->param.flags &= ~LIO_RSS_PARAM_HASH_INFO_UNCHANGED;
742 rss_param->param.hashinfo = hashinfo;
745 lio_swap_8B_data((uint64_t *)rss_param, LIO_RSS_PARAM_SIZE >> 3);
747 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
748 lio_dev_err(lio_dev, "Failed to set rss hash\n");
752 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
753 lio_dev_err(lio_dev, "Set rss hash timed out\n");
761 * Add vxlan dest udp port for an interface.
764 * Pointer to the structure rte_eth_dev
769 * On success return 0
770 * On failure return -1
773 lio_dev_udp_tunnel_add(struct rte_eth_dev *eth_dev,
774 struct rte_eth_udp_tunnel *udp_tnl)
776 struct lio_device *lio_dev = LIO_DEV(eth_dev);
777 struct lio_dev_ctrl_cmd ctrl_cmd;
778 struct lio_ctrl_pkt ctrl_pkt;
783 if (udp_tnl->prot_type != RTE_TUNNEL_TYPE_VXLAN) {
784 lio_dev_err(lio_dev, "Unsupported tunnel type\n");
788 /* flush added to prevent cmd failure
789 * incase the queue is full
791 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
793 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
794 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
796 ctrl_cmd.eth_dev = eth_dev;
799 ctrl_pkt.ncmd.s.cmd = LIO_CMD_VXLAN_PORT_CONFIG;
800 ctrl_pkt.ncmd.s.param1 = udp_tnl->udp_port;
801 ctrl_pkt.ncmd.s.more = LIO_CMD_VXLAN_PORT_ADD;
802 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
804 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
805 lio_dev_err(lio_dev, "Failed to send VXLAN_PORT_ADD command\n");
809 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
810 lio_dev_err(lio_dev, "VXLAN_PORT_ADD command timed out\n");
818 * Remove vxlan dest udp port for an interface.
821 * Pointer to the structure rte_eth_dev
826 * On success return 0
827 * On failure return -1
830 lio_dev_udp_tunnel_del(struct rte_eth_dev *eth_dev,
831 struct rte_eth_udp_tunnel *udp_tnl)
833 struct lio_device *lio_dev = LIO_DEV(eth_dev);
834 struct lio_dev_ctrl_cmd ctrl_cmd;
835 struct lio_ctrl_pkt ctrl_pkt;
840 if (udp_tnl->prot_type != RTE_TUNNEL_TYPE_VXLAN) {
841 lio_dev_err(lio_dev, "Unsupported tunnel type\n");
845 /* flush added to prevent cmd failure
846 * incase the queue is full
848 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
850 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
851 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
853 ctrl_cmd.eth_dev = eth_dev;
856 ctrl_pkt.ncmd.s.cmd = LIO_CMD_VXLAN_PORT_CONFIG;
857 ctrl_pkt.ncmd.s.param1 = udp_tnl->udp_port;
858 ctrl_pkt.ncmd.s.more = LIO_CMD_VXLAN_PORT_DEL;
859 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
861 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
862 lio_dev_err(lio_dev, "Failed to send VXLAN_PORT_DEL command\n");
866 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
867 lio_dev_err(lio_dev, "VXLAN_PORT_DEL command timed out\n");
875 lio_dev_vlan_filter_set(struct rte_eth_dev *eth_dev, uint16_t vlan_id, int on)
877 struct lio_device *lio_dev = LIO_DEV(eth_dev);
878 struct lio_dev_ctrl_cmd ctrl_cmd;
879 struct lio_ctrl_pkt ctrl_pkt;
881 if (lio_dev->linfo.vlan_is_admin_assigned)
884 /* flush added to prevent cmd failure
885 * incase the queue is full
887 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
889 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
890 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
892 ctrl_cmd.eth_dev = eth_dev;
895 ctrl_pkt.ncmd.s.cmd = on ?
896 LIO_CMD_ADD_VLAN_FILTER : LIO_CMD_DEL_VLAN_FILTER;
897 ctrl_pkt.ncmd.s.param1 = vlan_id;
898 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
900 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
901 lio_dev_err(lio_dev, "Failed to %s VLAN port\n",
902 on ? "add" : "remove");
906 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
907 lio_dev_err(lio_dev, "Command to %s VLAN port timed out\n",
908 on ? "add" : "remove");
916 lio_hweight64(uint64_t w)
918 uint64_t res = w - ((w >> 1) & 0x5555555555555555ul);
921 (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul);
922 res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful;
923 res = res + (res >> 8);
924 res = res + (res >> 16);
926 return (res + (res >> 32)) & 0x00000000000000FFul;
930 lio_dev_link_update(struct rte_eth_dev *eth_dev,
931 int wait_to_complete __rte_unused)
933 struct lio_device *lio_dev = LIO_DEV(eth_dev);
934 struct rte_eth_link link;
937 memset(&link, 0, sizeof(link));
938 link.link_status = ETH_LINK_DOWN;
939 link.link_speed = ETH_SPEED_NUM_NONE;
940 link.link_duplex = ETH_LINK_HALF_DUPLEX;
941 link.link_autoneg = ETH_LINK_AUTONEG;
943 /* Return what we found */
944 if (lio_dev->linfo.link.s.link_up == 0) {
945 /* Interface is down */
946 return rte_eth_linkstatus_set(eth_dev, &link);
949 link.link_status = ETH_LINK_UP; /* Interface is up */
950 link.link_duplex = ETH_LINK_FULL_DUPLEX;
951 switch (lio_dev->linfo.link.s.speed) {
952 case LIO_LINK_SPEED_10000:
953 link.link_speed = ETH_SPEED_NUM_10G;
955 case LIO_LINK_SPEED_25000:
956 link.link_speed = ETH_SPEED_NUM_25G;
959 link.link_speed = ETH_SPEED_NUM_NONE;
960 link.link_duplex = ETH_LINK_HALF_DUPLEX;
963 return rte_eth_linkstatus_set(eth_dev, &link);
967 * \brief Net device enable, disable allmulticast
968 * @param eth_dev Pointer to the structure rte_eth_dev
971 * On success return 0
972 * On failure return negative errno
975 lio_change_dev_flag(struct rte_eth_dev *eth_dev)
977 struct lio_device *lio_dev = LIO_DEV(eth_dev);
978 struct lio_dev_ctrl_cmd ctrl_cmd;
979 struct lio_ctrl_pkt ctrl_pkt;
981 /* flush added to prevent cmd failure
982 * incase the queue is full
984 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
986 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
987 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
989 ctrl_cmd.eth_dev = eth_dev;
992 /* Create a ctrl pkt command to be sent to core app. */
993 ctrl_pkt.ncmd.s.cmd = LIO_CMD_CHANGE_DEVFLAGS;
994 ctrl_pkt.ncmd.s.param1 = lio_dev->ifflags;
995 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
997 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
998 lio_dev_err(lio_dev, "Failed to send change flag message\n");
1002 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
1003 lio_dev_err(lio_dev, "Change dev flag command timed out\n");
1011 lio_dev_promiscuous_enable(struct rte_eth_dev *eth_dev)
1013 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1015 if (strcmp(lio_dev->firmware_version, LIO_VF_TRUST_MIN_VERSION) < 0) {
1016 lio_dev_err(lio_dev, "Require firmware version >= %s\n",
1017 LIO_VF_TRUST_MIN_VERSION);
1021 if (!lio_dev->intf_open) {
1022 lio_dev_err(lio_dev, "Port %d down, can't enable promiscuous\n",
1027 lio_dev->ifflags |= LIO_IFFLAG_PROMISC;
1028 return lio_change_dev_flag(eth_dev);
1032 lio_dev_promiscuous_disable(struct rte_eth_dev *eth_dev)
1034 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1036 if (strcmp(lio_dev->firmware_version, LIO_VF_TRUST_MIN_VERSION) < 0) {
1037 lio_dev_err(lio_dev, "Require firmware version >= %s\n",
1038 LIO_VF_TRUST_MIN_VERSION);
1042 if (!lio_dev->intf_open) {
1043 lio_dev_err(lio_dev, "Port %d down, can't disable promiscuous\n",
1048 lio_dev->ifflags &= ~LIO_IFFLAG_PROMISC;
1049 return lio_change_dev_flag(eth_dev);
1053 lio_dev_allmulticast_enable(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 enable multicast\n",
1063 lio_dev->ifflags |= LIO_IFFLAG_ALLMULTI;
1064 return lio_change_dev_flag(eth_dev);
1068 lio_dev_allmulticast_disable(struct rte_eth_dev *eth_dev)
1070 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1072 if (!lio_dev->intf_open) {
1073 lio_dev_err(lio_dev, "Port %d down, can't disable multicast\n",
1078 lio_dev->ifflags &= ~LIO_IFFLAG_ALLMULTI;
1079 return lio_change_dev_flag(eth_dev);
1083 lio_dev_rss_configure(struct rte_eth_dev *eth_dev)
1085 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1086 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
1087 struct rte_eth_rss_reta_entry64 reta_conf[8];
1088 struct rte_eth_rss_conf rss_conf;
1091 /* Configure the RSS key and the RSS protocols used to compute
1092 * the RSS hash of input packets.
1094 rss_conf = eth_dev->data->dev_conf.rx_adv_conf.rss_conf;
1095 if ((rss_conf.rss_hf & LIO_RSS_OFFLOAD_ALL) == 0) {
1096 rss_state->hash_disable = 1;
1097 lio_dev_rss_hash_update(eth_dev, &rss_conf);
1101 if (rss_conf.rss_key == NULL)
1102 rss_conf.rss_key = lio_rss_key; /* Default hash key */
1104 lio_dev_rss_hash_update(eth_dev, &rss_conf);
1106 memset(reta_conf, 0, sizeof(reta_conf));
1107 for (i = 0; i < LIO_RSS_MAX_TABLE_SZ; i++) {
1108 uint8_t q_idx, conf_idx, reta_idx;
1110 q_idx = (uint8_t)((eth_dev->data->nb_rx_queues > 1) ?
1111 i % eth_dev->data->nb_rx_queues : 0);
1112 conf_idx = i / RTE_RETA_GROUP_SIZE;
1113 reta_idx = i % RTE_RETA_GROUP_SIZE;
1114 reta_conf[conf_idx].reta[reta_idx] = q_idx;
1115 reta_conf[conf_idx].mask |= ((uint64_t)1 << reta_idx);
1118 lio_dev_rss_reta_update(eth_dev, reta_conf, LIO_RSS_MAX_TABLE_SZ);
1122 lio_dev_mq_rx_configure(struct rte_eth_dev *eth_dev)
1124 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1125 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
1126 struct rte_eth_rss_conf rss_conf;
1128 switch (eth_dev->data->dev_conf.rxmode.mq_mode) {
1130 lio_dev_rss_configure(eth_dev);
1132 case ETH_MQ_RX_NONE:
1133 /* if mq_mode is none, disable rss mode. */
1135 memset(&rss_conf, 0, sizeof(rss_conf));
1136 rss_state->hash_disable = 1;
1137 lio_dev_rss_hash_update(eth_dev, &rss_conf);
1142 * Setup our receive queue/ringbuffer. This is the
1143 * queue the Octeon uses to send us packets and
1144 * responses. We are given a memory pool for our
1145 * packet buffers that are used to populate the receive
1149 * Pointer to the structure rte_eth_dev
1152 * @param num_rx_descs
1153 * Number of entries in the queue
1155 * Where to allocate memory
1157 * Pointer to the struction rte_eth_rxconf
1159 * Pointer to the packet pool
1162 * - On success, return 0
1163 * - On failure, return -1
1166 lio_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t q_no,
1167 uint16_t num_rx_descs, unsigned int socket_id,
1168 const struct rte_eth_rxconf *rx_conf __rte_unused,
1169 struct rte_mempool *mp)
1171 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1172 struct rte_pktmbuf_pool_private *mbp_priv;
1173 uint32_t fw_mapped_oq;
1176 if (q_no >= lio_dev->nb_rx_queues) {
1177 lio_dev_err(lio_dev, "Invalid rx queue number %u\n", q_no);
1181 lio_dev_dbg(lio_dev, "setting up rx queue %u\n", q_no);
1183 fw_mapped_oq = lio_dev->linfo.rxpciq[q_no].s.q_no;
1185 /* Free previous allocation if any */
1186 if (eth_dev->data->rx_queues[q_no] != NULL) {
1187 lio_dev_rx_queue_release(eth_dev->data->rx_queues[q_no]);
1188 eth_dev->data->rx_queues[q_no] = NULL;
1191 mbp_priv = rte_mempool_get_priv(mp);
1192 buf_size = mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM;
1194 if (lio_setup_droq(lio_dev, fw_mapped_oq, num_rx_descs, buf_size, mp,
1196 lio_dev_err(lio_dev, "droq allocation failed\n");
1200 eth_dev->data->rx_queues[q_no] = lio_dev->droq[fw_mapped_oq];
1206 * Release the receive queue/ringbuffer. Called by
1210 * Opaque pointer to the receive queue to release
1216 lio_dev_rx_queue_release(void *rxq)
1218 struct lio_droq *droq = rxq;
1223 lio_delete_droq_queue(droq->lio_dev, oq_no);
1228 * Allocate and initialize SW ring. Initialize associated HW registers.
1231 * Pointer to structure rte_eth_dev
1236 * @param num_tx_descs
1237 * Number of ringbuffer descriptors
1240 * NUMA socket id, used for memory allocations
1243 * Pointer to the structure rte_eth_txconf
1246 * - On success, return 0
1247 * - On failure, return -errno value
1250 lio_dev_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t q_no,
1251 uint16_t num_tx_descs, unsigned int socket_id,
1252 const struct rte_eth_txconf *tx_conf __rte_unused)
1254 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1255 int fw_mapped_iq = lio_dev->linfo.txpciq[q_no].s.q_no;
1258 if (q_no >= lio_dev->nb_tx_queues) {
1259 lio_dev_err(lio_dev, "Invalid tx queue number %u\n", q_no);
1263 lio_dev_dbg(lio_dev, "setting up tx queue %u\n", q_no);
1265 /* Free previous allocation if any */
1266 if (eth_dev->data->tx_queues[q_no] != NULL) {
1267 lio_dev_tx_queue_release(eth_dev->data->tx_queues[q_no]);
1268 eth_dev->data->tx_queues[q_no] = NULL;
1271 retval = lio_setup_iq(lio_dev, q_no, lio_dev->linfo.txpciq[q_no],
1272 num_tx_descs, lio_dev, socket_id);
1275 lio_dev_err(lio_dev, "Runtime IQ(TxQ) creation failed.\n");
1279 retval = lio_setup_sglists(lio_dev, q_no, fw_mapped_iq,
1280 lio_dev->instr_queue[fw_mapped_iq]->nb_desc,
1284 lio_delete_instruction_queue(lio_dev, fw_mapped_iq);
1288 eth_dev->data->tx_queues[q_no] = lio_dev->instr_queue[fw_mapped_iq];
1294 * Release the transmit queue/ringbuffer. Called by
1298 * Opaque pointer to the transmit queue to release
1304 lio_dev_tx_queue_release(void *txq)
1306 struct lio_instr_queue *tq = txq;
1307 uint32_t fw_mapped_iq_no;
1312 lio_delete_sglist(tq);
1314 fw_mapped_iq_no = tq->txpciq.s.q_no;
1315 lio_delete_instruction_queue(tq->lio_dev, fw_mapped_iq_no);
1320 * Api to check link state.
1323 lio_dev_get_link_status(struct rte_eth_dev *eth_dev)
1325 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1326 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1327 struct lio_link_status_resp *resp;
1328 union octeon_link_status *ls;
1329 struct lio_soft_command *sc;
1332 if (!lio_dev->intf_open)
1335 resp_size = sizeof(struct lio_link_status_resp);
1336 sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
1340 resp = (struct lio_link_status_resp *)sc->virtrptr;
1341 lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
1342 LIO_OPCODE_INFO, 0, 0, 0);
1344 /* Setting wait time in seconds */
1345 sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
1347 if (lio_send_soft_command(lio_dev, sc) == LIO_IQ_SEND_FAILED)
1348 goto get_status_fail;
1350 while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
1351 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
1356 goto get_status_fail;
1358 ls = &resp->link_info.link;
1360 lio_swap_8B_data((uint64_t *)ls, sizeof(union octeon_link_status) >> 3);
1362 if (lio_dev->linfo.link.link_status64 != ls->link_status64) {
1363 if (ls->s.mtu < eth_dev->data->mtu) {
1364 lio_dev_info(lio_dev, "Lowered VF MTU to %d as PF MTU dropped\n",
1366 eth_dev->data->mtu = ls->s.mtu;
1368 lio_dev->linfo.link.link_status64 = ls->link_status64;
1369 lio_dev_link_update(eth_dev, 0);
1372 lio_free_soft_command(sc);
1377 lio_free_soft_command(sc);
1380 /* This function will be invoked every LSC_TIMEOUT ns (100ms)
1381 * and will update link state if it changes.
1384 lio_sync_link_state_check(void *eth_dev)
1386 struct lio_device *lio_dev =
1387 (((struct rte_eth_dev *)eth_dev)->data->dev_private);
1389 if (lio_dev->port_configured)
1390 lio_dev_get_link_status(eth_dev);
1392 /* Schedule periodic link status check.
1393 * Stop check if interface is close and start again while opening.
1395 if (lio_dev->intf_open)
1396 rte_eal_alarm_set(LIO_LSC_TIMEOUT, lio_sync_link_state_check,
1401 lio_dev_start(struct rte_eth_dev *eth_dev)
1404 uint32_t frame_len = eth_dev->data->dev_conf.rxmode.max_rx_pkt_len;
1405 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1406 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1409 lio_dev_info(lio_dev, "Starting port %d\n", eth_dev->data->port_id);
1411 if (lio_dev->fn_list.enable_io_queues(lio_dev))
1414 if (lio_send_rx_ctrl_cmd(eth_dev, 1))
1417 /* Ready for link status updates */
1418 lio_dev->intf_open = 1;
1421 /* Configure RSS if device configured with multiple RX queues. */
1422 lio_dev_mq_rx_configure(eth_dev);
1424 /* Before update the link info,
1425 * must set linfo.link.link_status64 to 0.
1427 lio_dev->linfo.link.link_status64 = 0;
1429 /* start polling for lsc */
1430 ret = rte_eal_alarm_set(LIO_LSC_TIMEOUT,
1431 lio_sync_link_state_check,
1434 lio_dev_err(lio_dev,
1435 "link state check handler creation failed\n");
1436 goto dev_lsc_handle_error;
1439 while ((lio_dev->linfo.link.link_status64 == 0) && (--timeout))
1442 if (lio_dev->linfo.link.link_status64 == 0) {
1444 goto dev_mtu_set_error;
1447 mtu = (uint16_t)(frame_len - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN);
1448 if (mtu < RTE_ETHER_MIN_MTU)
1449 mtu = RTE_ETHER_MIN_MTU;
1451 if (eth_dev->data->mtu != mtu) {
1452 ret = lio_dev_mtu_set(eth_dev, mtu);
1454 goto dev_mtu_set_error;
1460 rte_eal_alarm_cancel(lio_sync_link_state_check, eth_dev);
1462 dev_lsc_handle_error:
1463 lio_dev->intf_open = 0;
1464 lio_send_rx_ctrl_cmd(eth_dev, 0);
1469 /* Stop device and disable input/output functions */
1471 lio_dev_stop(struct rte_eth_dev *eth_dev)
1473 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1475 lio_dev_info(lio_dev, "Stopping port %d\n", eth_dev->data->port_id);
1476 lio_dev->intf_open = 0;
1479 /* Cancel callback if still running. */
1480 rte_eal_alarm_cancel(lio_sync_link_state_check, eth_dev);
1482 lio_send_rx_ctrl_cmd(eth_dev, 0);
1484 lio_wait_for_instr_fetch(lio_dev);
1486 /* Clear recorded link status */
1487 lio_dev->linfo.link.link_status64 = 0;
1491 lio_dev_set_link_up(struct rte_eth_dev *eth_dev)
1493 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1495 if (!lio_dev->intf_open) {
1496 lio_dev_info(lio_dev, "Port is stopped, Start the port first\n");
1500 if (lio_dev->linfo.link.s.link_up) {
1501 lio_dev_info(lio_dev, "Link is already UP\n");
1505 if (lio_send_rx_ctrl_cmd(eth_dev, 1)) {
1506 lio_dev_err(lio_dev, "Unable to set Link UP\n");
1510 lio_dev->linfo.link.s.link_up = 1;
1511 eth_dev->data->dev_link.link_status = ETH_LINK_UP;
1517 lio_dev_set_link_down(struct rte_eth_dev *eth_dev)
1519 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1521 if (!lio_dev->intf_open) {
1522 lio_dev_info(lio_dev, "Port is stopped, Start the port first\n");
1526 if (!lio_dev->linfo.link.s.link_up) {
1527 lio_dev_info(lio_dev, "Link is already DOWN\n");
1531 lio_dev->linfo.link.s.link_up = 0;
1532 eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
1534 if (lio_send_rx_ctrl_cmd(eth_dev, 0)) {
1535 lio_dev->linfo.link.s.link_up = 1;
1536 eth_dev->data->dev_link.link_status = ETH_LINK_UP;
1537 lio_dev_err(lio_dev, "Unable to set Link Down\n");
1545 * Reset and stop the device. This occurs on the first
1546 * call to this routine. Subsequent calls will simply
1547 * return. NB: This will require the NIC to be rebooted.
1550 * Pointer to the structure rte_eth_dev
1556 lio_dev_close(struct rte_eth_dev *eth_dev)
1558 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1560 lio_dev_info(lio_dev, "closing port %d\n", eth_dev->data->port_id);
1562 if (lio_dev->intf_open)
1563 lio_dev_stop(eth_dev);
1565 /* Reset ioq regs */
1566 lio_dev->fn_list.setup_device_regs(lio_dev);
1568 if (lio_dev->pci_dev->kdrv == RTE_KDRV_IGB_UIO) {
1569 cn23xx_vf_ask_pf_to_do_flr(lio_dev);
1570 rte_delay_ms(LIO_PCI_FLR_WAIT);
1574 lio_dev->fn_list.free_mbox(lio_dev);
1576 /* Free glist resources */
1577 rte_free(lio_dev->glist_head);
1578 rte_free(lio_dev->glist_lock);
1579 lio_dev->glist_head = NULL;
1580 lio_dev->glist_lock = NULL;
1582 lio_dev->port_configured = 0;
1584 /* Delete all queues */
1585 lio_dev_clear_queues(eth_dev);
1589 * Enable tunnel rx checksum verification from firmware.
1592 lio_enable_hw_tunnel_rx_checksum(struct rte_eth_dev *eth_dev)
1594 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1595 struct lio_dev_ctrl_cmd ctrl_cmd;
1596 struct lio_ctrl_pkt ctrl_pkt;
1598 /* flush added to prevent cmd failure
1599 * incase the queue is full
1601 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1603 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1604 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1606 ctrl_cmd.eth_dev = eth_dev;
1609 ctrl_pkt.ncmd.s.cmd = LIO_CMD_TNL_RX_CSUM_CTL;
1610 ctrl_pkt.ncmd.s.param1 = LIO_CMD_RXCSUM_ENABLE;
1611 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1613 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1614 lio_dev_err(lio_dev, "Failed to send TNL_RX_CSUM command\n");
1618 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd))
1619 lio_dev_err(lio_dev, "TNL_RX_CSUM command timed out\n");
1623 * Enable checksum calculation for inner packet in a tunnel.
1626 lio_enable_hw_tunnel_tx_checksum(struct rte_eth_dev *eth_dev)
1628 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1629 struct lio_dev_ctrl_cmd ctrl_cmd;
1630 struct lio_ctrl_pkt ctrl_pkt;
1632 /* flush added to prevent cmd failure
1633 * incase the queue is full
1635 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1637 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1638 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1640 ctrl_cmd.eth_dev = eth_dev;
1643 ctrl_pkt.ncmd.s.cmd = LIO_CMD_TNL_TX_CSUM_CTL;
1644 ctrl_pkt.ncmd.s.param1 = LIO_CMD_TXCSUM_ENABLE;
1645 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1647 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1648 lio_dev_err(lio_dev, "Failed to send TNL_TX_CSUM command\n");
1652 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd))
1653 lio_dev_err(lio_dev, "TNL_TX_CSUM command timed out\n");
1657 lio_send_queue_count_update(struct rte_eth_dev *eth_dev, int num_txq,
1660 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1661 struct lio_dev_ctrl_cmd ctrl_cmd;
1662 struct lio_ctrl_pkt ctrl_pkt;
1664 if (strcmp(lio_dev->firmware_version, LIO_Q_RECONF_MIN_VERSION) < 0) {
1665 lio_dev_err(lio_dev, "Require firmware version >= %s\n",
1666 LIO_Q_RECONF_MIN_VERSION);
1670 /* flush added to prevent cmd failure
1671 * incase the queue is full
1673 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1675 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1676 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1678 ctrl_cmd.eth_dev = eth_dev;
1681 ctrl_pkt.ncmd.s.cmd = LIO_CMD_QUEUE_COUNT_CTL;
1682 ctrl_pkt.ncmd.s.param1 = num_txq;
1683 ctrl_pkt.ncmd.s.param2 = num_rxq;
1684 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1686 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1687 lio_dev_err(lio_dev, "Failed to send queue count control command\n");
1691 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
1692 lio_dev_err(lio_dev, "Queue count control command timed out\n");
1700 lio_reconf_queues(struct rte_eth_dev *eth_dev, int num_txq, int num_rxq)
1702 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1704 if (lio_dev->nb_rx_queues != num_rxq ||
1705 lio_dev->nb_tx_queues != num_txq) {
1706 if (lio_send_queue_count_update(eth_dev, num_txq, num_rxq))
1708 lio_dev->nb_rx_queues = num_rxq;
1709 lio_dev->nb_tx_queues = num_txq;
1712 if (lio_dev->intf_open)
1713 lio_dev_stop(eth_dev);
1715 /* Reset ioq registers */
1716 if (lio_dev->fn_list.setup_device_regs(lio_dev)) {
1717 lio_dev_err(lio_dev, "Failed to configure device registers\n");
1725 lio_dev_configure(struct rte_eth_dev *eth_dev)
1727 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1728 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1729 int retval, num_iqueues, num_oqueues;
1730 uint8_t mac[RTE_ETHER_ADDR_LEN], i;
1731 struct lio_if_cfg_resp *resp;
1732 struct lio_soft_command *sc;
1733 union lio_if_cfg if_cfg;
1736 PMD_INIT_FUNC_TRACE();
1738 /* Inform firmware about change in number of queues to use.
1739 * Disable IO queues and reset registers for re-configuration.
1741 if (lio_dev->port_configured)
1742 return lio_reconf_queues(eth_dev,
1743 eth_dev->data->nb_tx_queues,
1744 eth_dev->data->nb_rx_queues);
1746 lio_dev->nb_rx_queues = eth_dev->data->nb_rx_queues;
1747 lio_dev->nb_tx_queues = eth_dev->data->nb_tx_queues;
1749 /* Set max number of queues which can be re-configured. */
1750 lio_dev->max_rx_queues = eth_dev->data->nb_rx_queues;
1751 lio_dev->max_tx_queues = eth_dev->data->nb_tx_queues;
1753 resp_size = sizeof(struct lio_if_cfg_resp);
1754 sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
1758 resp = (struct lio_if_cfg_resp *)sc->virtrptr;
1760 /* Firmware doesn't have capability to reconfigure the queues,
1761 * Claim all queues, and use as many required
1763 if_cfg.if_cfg64 = 0;
1764 if_cfg.s.num_iqueues = lio_dev->nb_tx_queues;
1765 if_cfg.s.num_oqueues = lio_dev->nb_rx_queues;
1766 if_cfg.s.base_queue = 0;
1768 if_cfg.s.gmx_port_id = lio_dev->pf_num;
1770 lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
1771 LIO_OPCODE_IF_CFG, 0,
1772 if_cfg.if_cfg64, 0);
1774 /* Setting wait time in seconds */
1775 sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
1777 retval = lio_send_soft_command(lio_dev, sc);
1778 if (retval == LIO_IQ_SEND_FAILED) {
1779 lio_dev_err(lio_dev, "iq/oq config failed status: %x\n",
1781 /* Soft instr is freed by driver in case of failure. */
1782 goto nic_config_fail;
1785 /* Sleep on a wait queue till the cond flag indicates that the
1786 * response arrived or timed-out.
1788 while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
1789 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
1790 lio_process_ordered_list(lio_dev);
1794 retval = resp->status;
1796 lio_dev_err(lio_dev, "iq/oq config failed\n");
1797 goto nic_config_fail;
1800 strlcpy(lio_dev->firmware_version,
1801 resp->cfg_info.lio_firmware_version, LIO_FW_VERSION_LENGTH);
1803 lio_swap_8B_data((uint64_t *)(&resp->cfg_info),
1804 sizeof(struct octeon_if_cfg_info) >> 3);
1806 num_iqueues = lio_hweight64(resp->cfg_info.iqmask);
1807 num_oqueues = lio_hweight64(resp->cfg_info.oqmask);
1809 if (!(num_iqueues) || !(num_oqueues)) {
1810 lio_dev_err(lio_dev,
1811 "Got bad iqueues (%016lx) or oqueues (%016lx) from firmware.\n",
1812 (unsigned long)resp->cfg_info.iqmask,
1813 (unsigned long)resp->cfg_info.oqmask);
1814 goto nic_config_fail;
1817 lio_dev_dbg(lio_dev,
1818 "interface %d, iqmask %016lx, oqmask %016lx, numiqueues %d, numoqueues %d\n",
1819 eth_dev->data->port_id,
1820 (unsigned long)resp->cfg_info.iqmask,
1821 (unsigned long)resp->cfg_info.oqmask,
1822 num_iqueues, num_oqueues);
1824 lio_dev->linfo.num_rxpciq = num_oqueues;
1825 lio_dev->linfo.num_txpciq = num_iqueues;
1827 for (i = 0; i < num_oqueues; i++) {
1828 lio_dev->linfo.rxpciq[i].rxpciq64 =
1829 resp->cfg_info.linfo.rxpciq[i].rxpciq64;
1830 lio_dev_dbg(lio_dev, "index %d OQ %d\n",
1831 i, lio_dev->linfo.rxpciq[i].s.q_no);
1834 for (i = 0; i < num_iqueues; i++) {
1835 lio_dev->linfo.txpciq[i].txpciq64 =
1836 resp->cfg_info.linfo.txpciq[i].txpciq64;
1837 lio_dev_dbg(lio_dev, "index %d IQ %d\n",
1838 i, lio_dev->linfo.txpciq[i].s.q_no);
1841 lio_dev->linfo.hw_addr = resp->cfg_info.linfo.hw_addr;
1842 lio_dev->linfo.gmxport = resp->cfg_info.linfo.gmxport;
1843 lio_dev->linfo.link.link_status64 =
1844 resp->cfg_info.linfo.link.link_status64;
1846 /* 64-bit swap required on LE machines */
1847 lio_swap_8B_data(&lio_dev->linfo.hw_addr, 1);
1848 for (i = 0; i < RTE_ETHER_ADDR_LEN; i++)
1849 mac[i] = *((uint8_t *)(((uint8_t *)&lio_dev->linfo.hw_addr) +
1852 /* Copy the permanent MAC address */
1853 rte_ether_addr_copy((struct rte_ether_addr *)mac,
1854 ð_dev->data->mac_addrs[0]);
1856 /* enable firmware checksum support for tunnel packets */
1857 lio_enable_hw_tunnel_rx_checksum(eth_dev);
1858 lio_enable_hw_tunnel_tx_checksum(eth_dev);
1860 lio_dev->glist_lock =
1861 rte_zmalloc(NULL, sizeof(*lio_dev->glist_lock) * num_iqueues, 0);
1862 if (lio_dev->glist_lock == NULL)
1865 lio_dev->glist_head =
1866 rte_zmalloc(NULL, sizeof(*lio_dev->glist_head) * num_iqueues,
1868 if (lio_dev->glist_head == NULL) {
1869 rte_free(lio_dev->glist_lock);
1870 lio_dev->glist_lock = NULL;
1874 lio_dev_link_update(eth_dev, 0);
1876 lio_dev->port_configured = 1;
1878 lio_free_soft_command(sc);
1880 /* Reset ioq regs */
1881 lio_dev->fn_list.setup_device_regs(lio_dev);
1883 /* Free iq_0 used during init */
1884 lio_free_instr_queue0(lio_dev);
1889 lio_dev_err(lio_dev, "Failed retval %d\n", retval);
1890 lio_free_soft_command(sc);
1891 lio_free_instr_queue0(lio_dev);
1896 /* Define our ethernet definitions */
1897 static const struct eth_dev_ops liovf_eth_dev_ops = {
1898 .dev_configure = lio_dev_configure,
1899 .dev_start = lio_dev_start,
1900 .dev_stop = lio_dev_stop,
1901 .dev_set_link_up = lio_dev_set_link_up,
1902 .dev_set_link_down = lio_dev_set_link_down,
1903 .dev_close = lio_dev_close,
1904 .promiscuous_enable = lio_dev_promiscuous_enable,
1905 .promiscuous_disable = lio_dev_promiscuous_disable,
1906 .allmulticast_enable = lio_dev_allmulticast_enable,
1907 .allmulticast_disable = lio_dev_allmulticast_disable,
1908 .link_update = lio_dev_link_update,
1909 .stats_get = lio_dev_stats_get,
1910 .xstats_get = lio_dev_xstats_get,
1911 .xstats_get_names = lio_dev_xstats_get_names,
1912 .stats_reset = lio_dev_stats_reset,
1913 .xstats_reset = lio_dev_xstats_reset,
1914 .dev_infos_get = lio_dev_info_get,
1915 .vlan_filter_set = lio_dev_vlan_filter_set,
1916 .rx_queue_setup = lio_dev_rx_queue_setup,
1917 .rx_queue_release = lio_dev_rx_queue_release,
1918 .tx_queue_setup = lio_dev_tx_queue_setup,
1919 .tx_queue_release = lio_dev_tx_queue_release,
1920 .reta_update = lio_dev_rss_reta_update,
1921 .reta_query = lio_dev_rss_reta_query,
1922 .rss_hash_conf_get = lio_dev_rss_hash_conf_get,
1923 .rss_hash_update = lio_dev_rss_hash_update,
1924 .udp_tunnel_port_add = lio_dev_udp_tunnel_add,
1925 .udp_tunnel_port_del = lio_dev_udp_tunnel_del,
1926 .mtu_set = lio_dev_mtu_set,
1930 lio_check_pf_hs_response(void *lio_dev)
1932 struct lio_device *dev = lio_dev;
1934 /* check till response arrives */
1935 if (dev->pfvf_hsword.coproc_tics_per_us)
1938 cn23xx_vf_handle_mbox(dev);
1940 rte_eal_alarm_set(1, lio_check_pf_hs_response, lio_dev);
1944 * \brief Identify the LIO device and to map the BAR address space
1945 * @param lio_dev lio device
1948 lio_chip_specific_setup(struct lio_device *lio_dev)
1950 struct rte_pci_device *pdev = lio_dev->pci_dev;
1951 uint32_t dev_id = pdev->id.device_id;
1956 case LIO_CN23XX_VF_VID:
1957 lio_dev->chip_id = LIO_CN23XX_VF_VID;
1958 ret = cn23xx_vf_setup_device(lio_dev);
1963 lio_dev_err(lio_dev, "Unsupported Chip\n");
1967 lio_dev_info(lio_dev, "DEVICE : %s\n", s);
1973 lio_first_time_init(struct lio_device *lio_dev,
1974 struct rte_pci_device *pdev)
1978 PMD_INIT_FUNC_TRACE();
1980 /* set dpdk specific pci device pointer */
1981 lio_dev->pci_dev = pdev;
1983 /* Identify the LIO type and set device ops */
1984 if (lio_chip_specific_setup(lio_dev)) {
1985 lio_dev_err(lio_dev, "Chip specific setup failed\n");
1989 /* Initialize soft command buffer pool */
1990 if (lio_setup_sc_buffer_pool(lio_dev)) {
1991 lio_dev_err(lio_dev, "sc buffer pool allocation failed\n");
1995 /* Initialize lists to manage the requests of different types that
1996 * arrive from applications for this lio device.
1998 lio_setup_response_list(lio_dev);
2000 if (lio_dev->fn_list.setup_mbox(lio_dev)) {
2001 lio_dev_err(lio_dev, "Mailbox setup failed\n");
2005 /* Check PF response */
2006 lio_check_pf_hs_response((void *)lio_dev);
2008 /* Do handshake and exit if incompatible PF driver */
2009 if (cn23xx_pfvf_handshake(lio_dev))
2012 /* Request and wait for device reset. */
2013 if (pdev->kdrv == RTE_KDRV_IGB_UIO) {
2014 cn23xx_vf_ask_pf_to_do_flr(lio_dev);
2015 /* FLR wait time doubled as a precaution. */
2016 rte_delay_ms(LIO_PCI_FLR_WAIT * 2);
2019 if (lio_dev->fn_list.setup_device_regs(lio_dev)) {
2020 lio_dev_err(lio_dev, "Failed to configure device registers\n");
2024 if (lio_setup_instr_queue0(lio_dev)) {
2025 lio_dev_err(lio_dev, "Failed to setup instruction queue 0\n");
2029 dpdk_queues = (int)lio_dev->sriov_info.rings_per_vf;
2031 lio_dev->max_tx_queues = dpdk_queues;
2032 lio_dev->max_rx_queues = dpdk_queues;
2034 /* Enable input and output queues for this device */
2035 if (lio_dev->fn_list.enable_io_queues(lio_dev))
2041 lio_free_sc_buffer_pool(lio_dev);
2042 if (lio_dev->mbox[0])
2043 lio_dev->fn_list.free_mbox(lio_dev);
2044 if (lio_dev->instr_queue[0])
2045 lio_free_instr_queue0(lio_dev);
2051 lio_eth_dev_uninit(struct rte_eth_dev *eth_dev)
2053 struct lio_device *lio_dev = LIO_DEV(eth_dev);
2055 PMD_INIT_FUNC_TRACE();
2057 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
2060 /* lio_free_sc_buffer_pool */
2061 lio_free_sc_buffer_pool(lio_dev);
2063 eth_dev->dev_ops = NULL;
2064 eth_dev->rx_pkt_burst = NULL;
2065 eth_dev->tx_pkt_burst = NULL;
2071 lio_eth_dev_init(struct rte_eth_dev *eth_dev)
2073 struct rte_pci_device *pdev = RTE_ETH_DEV_TO_PCI(eth_dev);
2074 struct lio_device *lio_dev = LIO_DEV(eth_dev);
2076 PMD_INIT_FUNC_TRACE();
2078 eth_dev->rx_pkt_burst = &lio_dev_recv_pkts;
2079 eth_dev->tx_pkt_burst = &lio_dev_xmit_pkts;
2081 /* Primary does the initialization. */
2082 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
2085 rte_eth_copy_pci_info(eth_dev, pdev);
2087 if (pdev->mem_resource[0].addr) {
2088 lio_dev->hw_addr = pdev->mem_resource[0].addr;
2090 PMD_INIT_LOG(ERR, "ERROR: Failed to map BAR0\n");
2094 lio_dev->eth_dev = eth_dev;
2095 /* set lio device print string */
2096 snprintf(lio_dev->dev_string, sizeof(lio_dev->dev_string),
2097 "%s[%02x:%02x.%x]", pdev->driver->driver.name,
2098 pdev->addr.bus, pdev->addr.devid, pdev->addr.function);
2100 lio_dev->port_id = eth_dev->data->port_id;
2102 if (lio_first_time_init(lio_dev, pdev)) {
2103 lio_dev_err(lio_dev, "Device init failed\n");
2107 eth_dev->dev_ops = &liovf_eth_dev_ops;
2108 eth_dev->data->mac_addrs = rte_zmalloc("lio", RTE_ETHER_ADDR_LEN, 0);
2109 if (eth_dev->data->mac_addrs == NULL) {
2110 lio_dev_err(lio_dev,
2111 "MAC addresses memory allocation failed\n");
2112 eth_dev->dev_ops = NULL;
2113 eth_dev->rx_pkt_burst = NULL;
2114 eth_dev->tx_pkt_burst = NULL;
2118 rte_atomic64_set(&lio_dev->status, LIO_DEV_RUNNING);
2121 lio_dev->port_configured = 0;
2122 /* Always allow unicast packets */
2123 lio_dev->ifflags |= LIO_IFFLAG_UNICAST;
2129 lio_eth_dev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
2130 struct rte_pci_device *pci_dev)
2132 return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct lio_device),
2137 lio_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
2139 return rte_eth_dev_pci_generic_remove(pci_dev,
2140 lio_eth_dev_uninit);
2143 /* Set of PCI devices this driver supports */
2144 static const struct rte_pci_id pci_id_liovf_map[] = {
2145 { RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_VF_VID) },
2146 { .vendor_id = 0, /* sentinel */ }
2149 static struct rte_pci_driver rte_liovf_pmd = {
2150 .id_table = pci_id_liovf_map,
2151 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
2152 .probe = lio_eth_dev_pci_probe,
2153 .remove = lio_eth_dev_pci_remove,
2156 RTE_PMD_REGISTER_PCI(net_liovf, rte_liovf_pmd);
2157 RTE_PMD_REGISTER_PCI_TABLE(net_liovf, pci_id_liovf_map);
2158 RTE_PMD_REGISTER_KMOD_DEP(net_liovf, "* igb_uio | vfio-pci");
2160 RTE_INIT(lio_init_log)
2162 lio_logtype_init = rte_log_register("pmd.net.liquidio.init");
2163 if (lio_logtype_init >= 0)
2164 rte_log_set_level(lio_logtype_init, RTE_LOG_NOTICE);
2165 lio_logtype_driver = rte_log_register("pmd.net.liquidio.driver");
2166 if (lio_logtype_driver >= 0)
2167 rte_log_set_level(lio_logtype_driver, RTE_LOG_NOTICE);