1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Cavium, Inc
5 #include <rte_ethdev_driver.h>
6 #include <rte_ethdev_pci.h>
7 #include <rte_cycles.h>
8 #include <rte_malloc.h>
10 #include <rte_ether.h>
13 #include "lio_23xx_vf.h"
14 #include "lio_ethdev.h"
18 int lio_logtype_driver;
20 /* Default RSS key in use */
21 static uint8_t lio_rss_key[40] = {
22 0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2,
23 0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0,
24 0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4,
25 0x77, 0xCB, 0x2D, 0xA3, 0x80, 0x30, 0xF2, 0x0C,
26 0x6A, 0x42, 0xB7, 0x3B, 0xBE, 0xAC, 0x01, 0xFA,
29 static const struct rte_eth_desc_lim lio_rx_desc_lim = {
30 .nb_max = CN23XX_MAX_OQ_DESCRIPTORS,
31 .nb_min = CN23XX_MIN_OQ_DESCRIPTORS,
35 static const struct rte_eth_desc_lim lio_tx_desc_lim = {
36 .nb_max = CN23XX_MAX_IQ_DESCRIPTORS,
37 .nb_min = CN23XX_MIN_IQ_DESCRIPTORS,
41 /* Wait for control command to reach nic. */
43 lio_wait_for_ctrl_cmd(struct lio_device *lio_dev,
44 struct lio_dev_ctrl_cmd *ctrl_cmd)
46 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
48 while ((ctrl_cmd->cond == 0) && --timeout) {
49 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
57 * \brief Send Rx control command
58 * @param eth_dev Pointer to the structure rte_eth_dev
59 * @param start_stop whether to start or stop
62 lio_send_rx_ctrl_cmd(struct rte_eth_dev *eth_dev, int start_stop)
64 struct lio_device *lio_dev = LIO_DEV(eth_dev);
65 struct lio_dev_ctrl_cmd ctrl_cmd;
66 struct lio_ctrl_pkt ctrl_pkt;
68 /* flush added to prevent cmd failure
69 * incase the queue is full
71 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
73 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
74 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
76 ctrl_cmd.eth_dev = eth_dev;
79 ctrl_pkt.ncmd.s.cmd = LIO_CMD_RX_CTL;
80 ctrl_pkt.ncmd.s.param1 = start_stop;
81 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
83 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
84 lio_dev_err(lio_dev, "Failed to send RX Control message\n");
88 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
89 lio_dev_err(lio_dev, "RX Control command timed out\n");
96 /* store statistics names and its offset in stats structure */
97 struct rte_lio_xstats_name_off {
98 char name[RTE_ETH_XSTATS_NAME_SIZE];
102 static const struct rte_lio_xstats_name_off rte_lio_stats_strings[] = {
103 {"rx_pkts", offsetof(struct octeon_rx_stats, total_rcvd)},
104 {"rx_bytes", offsetof(struct octeon_rx_stats, bytes_rcvd)},
105 {"rx_broadcast_pkts", offsetof(struct octeon_rx_stats, total_bcst)},
106 {"rx_multicast_pkts", offsetof(struct octeon_rx_stats, total_mcst)},
107 {"rx_flow_ctrl_pkts", offsetof(struct octeon_rx_stats, ctl_rcvd)},
108 {"rx_fifo_err", offsetof(struct octeon_rx_stats, fifo_err)},
109 {"rx_dmac_drop", offsetof(struct octeon_rx_stats, dmac_drop)},
110 {"rx_fcs_err", offsetof(struct octeon_rx_stats, fcs_err)},
111 {"rx_jabber_err", offsetof(struct octeon_rx_stats, jabber_err)},
112 {"rx_l2_err", offsetof(struct octeon_rx_stats, l2_err)},
113 {"rx_vxlan_pkts", offsetof(struct octeon_rx_stats, fw_rx_vxlan)},
114 {"rx_vxlan_err", offsetof(struct octeon_rx_stats, fw_rx_vxlan_err)},
115 {"rx_lro_pkts", offsetof(struct octeon_rx_stats, fw_lro_pkts)},
116 {"tx_pkts", (offsetof(struct octeon_tx_stats, total_pkts_sent)) +
117 sizeof(struct octeon_rx_stats)},
118 {"tx_bytes", (offsetof(struct octeon_tx_stats, total_bytes_sent)) +
119 sizeof(struct octeon_rx_stats)},
120 {"tx_broadcast_pkts",
121 (offsetof(struct octeon_tx_stats, bcast_pkts_sent)) +
122 sizeof(struct octeon_rx_stats)},
123 {"tx_multicast_pkts",
124 (offsetof(struct octeon_tx_stats, mcast_pkts_sent)) +
125 sizeof(struct octeon_rx_stats)},
126 {"tx_flow_ctrl_pkts", (offsetof(struct octeon_tx_stats, ctl_sent)) +
127 sizeof(struct octeon_rx_stats)},
128 {"tx_fifo_err", (offsetof(struct octeon_tx_stats, fifo_err)) +
129 sizeof(struct octeon_rx_stats)},
130 {"tx_total_collisions", (offsetof(struct octeon_tx_stats,
132 sizeof(struct octeon_rx_stats)},
133 {"tx_tso", (offsetof(struct octeon_tx_stats, fw_tso)) +
134 sizeof(struct octeon_rx_stats)},
135 {"tx_vxlan_pkts", (offsetof(struct octeon_tx_stats, fw_tx_vxlan)) +
136 sizeof(struct octeon_rx_stats)},
139 #define LIO_NB_XSTATS RTE_DIM(rte_lio_stats_strings)
141 /* Get hw stats of the port */
143 lio_dev_xstats_get(struct rte_eth_dev *eth_dev, struct rte_eth_xstat *xstats,
146 struct lio_device *lio_dev = LIO_DEV(eth_dev);
147 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
148 struct octeon_link_stats *hw_stats;
149 struct lio_link_stats_resp *resp;
150 struct lio_soft_command *sc;
155 if (!lio_dev->intf_open) {
156 lio_dev_err(lio_dev, "Port %d down\n",
161 if (n < LIO_NB_XSTATS)
162 return LIO_NB_XSTATS;
164 resp_size = sizeof(struct lio_link_stats_resp);
165 sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
169 resp = (struct lio_link_stats_resp *)sc->virtrptr;
170 lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
171 LIO_OPCODE_PORT_STATS, 0, 0, 0);
173 /* Setting wait time in seconds */
174 sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
176 retval = lio_send_soft_command(lio_dev, sc);
177 if (retval == LIO_IQ_SEND_FAILED) {
178 lio_dev_err(lio_dev, "failed to get port stats from firmware. status: %x\n",
183 while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
184 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
185 lio_process_ordered_list(lio_dev);
189 retval = resp->status;
191 lio_dev_err(lio_dev, "failed to get port stats from firmware\n");
195 lio_swap_8B_data((uint64_t *)(&resp->link_stats),
196 sizeof(struct octeon_link_stats) >> 3);
198 hw_stats = &resp->link_stats;
200 for (i = 0; i < LIO_NB_XSTATS; i++) {
203 *(uint64_t *)(((char *)hw_stats) +
204 rte_lio_stats_strings[i].offset);
207 lio_free_soft_command(sc);
209 return LIO_NB_XSTATS;
212 lio_free_soft_command(sc);
218 lio_dev_xstats_get_names(struct rte_eth_dev *eth_dev,
219 struct rte_eth_xstat_name *xstats_names,
220 unsigned limit __rte_unused)
222 struct lio_device *lio_dev = LIO_DEV(eth_dev);
225 if (!lio_dev->intf_open) {
226 lio_dev_err(lio_dev, "Port %d down\n",
231 if (xstats_names == NULL)
232 return LIO_NB_XSTATS;
234 /* Note: limit checked in rte_eth_xstats_names() */
236 for (i = 0; i < LIO_NB_XSTATS; i++) {
237 snprintf(xstats_names[i].name, sizeof(xstats_names[i].name),
238 "%s", rte_lio_stats_strings[i].name);
241 return LIO_NB_XSTATS;
244 /* Reset hw stats for the port */
246 lio_dev_xstats_reset(struct rte_eth_dev *eth_dev)
248 struct lio_device *lio_dev = LIO_DEV(eth_dev);
249 struct lio_dev_ctrl_cmd ctrl_cmd;
250 struct lio_ctrl_pkt ctrl_pkt;
252 if (!lio_dev->intf_open) {
253 lio_dev_err(lio_dev, "Port %d down\n",
258 /* flush added to prevent cmd failure
259 * incase the queue is full
261 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
263 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
264 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
266 ctrl_cmd.eth_dev = eth_dev;
269 ctrl_pkt.ncmd.s.cmd = LIO_CMD_CLEAR_STATS;
270 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
272 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
273 lio_dev_err(lio_dev, "Failed to send clear stats command\n");
277 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
278 lio_dev_err(lio_dev, "Clear stats command timed out\n");
282 /* clear stored per queue stats */
283 RTE_FUNC_PTR_OR_RET(*eth_dev->dev_ops->stats_reset);
284 (*eth_dev->dev_ops->stats_reset)(eth_dev);
287 /* Retrieve the device statistics (# packets in/out, # bytes in/out, etc */
289 lio_dev_stats_get(struct rte_eth_dev *eth_dev,
290 struct rte_eth_stats *stats)
292 struct lio_device *lio_dev = LIO_DEV(eth_dev);
293 struct lio_droq_stats *oq_stats;
294 struct lio_iq_stats *iq_stats;
295 struct lio_instr_queue *txq;
296 struct lio_droq *droq;
302 for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
303 iq_no = lio_dev->linfo.txpciq[i].s.q_no;
304 txq = lio_dev->instr_queue[iq_no];
306 iq_stats = &txq->stats;
307 pkts += iq_stats->tx_done;
308 drop += iq_stats->tx_dropped;
309 bytes += iq_stats->tx_tot_bytes;
313 stats->opackets = pkts;
314 stats->obytes = bytes;
315 stats->oerrors = drop;
321 for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
322 oq_no = lio_dev->linfo.rxpciq[i].s.q_no;
323 droq = lio_dev->droq[oq_no];
325 oq_stats = &droq->stats;
326 pkts += oq_stats->rx_pkts_received;
327 drop += (oq_stats->rx_dropped +
328 oq_stats->dropped_toomany +
329 oq_stats->dropped_nomem);
330 bytes += oq_stats->rx_bytes_received;
333 stats->ibytes = bytes;
334 stats->ipackets = pkts;
335 stats->ierrors = drop;
341 lio_dev_stats_reset(struct rte_eth_dev *eth_dev)
343 struct lio_device *lio_dev = LIO_DEV(eth_dev);
344 struct lio_droq_stats *oq_stats;
345 struct lio_iq_stats *iq_stats;
346 struct lio_instr_queue *txq;
347 struct lio_droq *droq;
350 for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
351 iq_no = lio_dev->linfo.txpciq[i].s.q_no;
352 txq = lio_dev->instr_queue[iq_no];
354 iq_stats = &txq->stats;
355 memset(iq_stats, 0, sizeof(struct lio_iq_stats));
359 for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
360 oq_no = lio_dev->linfo.rxpciq[i].s.q_no;
361 droq = lio_dev->droq[oq_no];
363 oq_stats = &droq->stats;
364 memset(oq_stats, 0, sizeof(struct lio_droq_stats));
370 lio_dev_info_get(struct rte_eth_dev *eth_dev,
371 struct rte_eth_dev_info *devinfo)
373 struct lio_device *lio_dev = LIO_DEV(eth_dev);
374 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
376 switch (pci_dev->id.subsystem_device_id) {
377 /* CN23xx 10G cards */
378 case PCI_SUBSYS_DEV_ID_CN2350_210:
379 case PCI_SUBSYS_DEV_ID_CN2360_210:
380 case PCI_SUBSYS_DEV_ID_CN2350_210SVPN3:
381 case PCI_SUBSYS_DEV_ID_CN2360_210SVPN3:
382 case PCI_SUBSYS_DEV_ID_CN2350_210SVPT:
383 case PCI_SUBSYS_DEV_ID_CN2360_210SVPT:
384 devinfo->speed_capa = ETH_LINK_SPEED_10G;
386 /* CN23xx 25G cards */
387 case PCI_SUBSYS_DEV_ID_CN2350_225:
388 case PCI_SUBSYS_DEV_ID_CN2360_225:
389 devinfo->speed_capa = ETH_LINK_SPEED_25G;
392 devinfo->speed_capa = ETH_LINK_SPEED_10G;
394 "Unknown CN23XX subsystem device id. Setting 10G as default link speed.\n");
397 devinfo->max_rx_queues = lio_dev->max_rx_queues;
398 devinfo->max_tx_queues = lio_dev->max_tx_queues;
400 devinfo->min_rx_bufsize = LIO_MIN_RX_BUF_SIZE;
401 devinfo->max_rx_pktlen = LIO_MAX_RX_PKTLEN;
403 devinfo->max_mac_addrs = 1;
405 devinfo->rx_offload_capa = (DEV_RX_OFFLOAD_IPV4_CKSUM |
406 DEV_RX_OFFLOAD_UDP_CKSUM |
407 DEV_RX_OFFLOAD_TCP_CKSUM |
408 DEV_RX_OFFLOAD_VLAN_STRIP);
409 devinfo->tx_offload_capa = (DEV_TX_OFFLOAD_IPV4_CKSUM |
410 DEV_TX_OFFLOAD_UDP_CKSUM |
411 DEV_TX_OFFLOAD_TCP_CKSUM |
412 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM);
414 devinfo->rx_desc_lim = lio_rx_desc_lim;
415 devinfo->tx_desc_lim = lio_tx_desc_lim;
417 devinfo->reta_size = LIO_RSS_MAX_TABLE_SZ;
418 devinfo->hash_key_size = LIO_RSS_MAX_KEY_SZ;
419 devinfo->flow_type_rss_offloads = (ETH_RSS_IPV4 |
420 ETH_RSS_NONFRAG_IPV4_TCP |
422 ETH_RSS_NONFRAG_IPV6_TCP |
424 ETH_RSS_IPV6_TCP_EX);
428 lio_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu)
430 struct lio_device *lio_dev = LIO_DEV(eth_dev);
431 uint16_t pf_mtu = lio_dev->linfo.link.s.mtu;
432 uint32_t frame_len = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
433 struct lio_dev_ctrl_cmd ctrl_cmd;
434 struct lio_ctrl_pkt ctrl_pkt;
436 PMD_INIT_FUNC_TRACE();
438 if (!lio_dev->intf_open) {
439 lio_dev_err(lio_dev, "Port %d down, can't set MTU\n",
444 /* check if VF MTU is within allowed range.
445 * New value should not exceed PF MTU.
447 if ((mtu < ETHER_MIN_MTU) || (mtu > pf_mtu)) {
448 lio_dev_err(lio_dev, "VF MTU should be >= %d and <= %d\n",
449 ETHER_MIN_MTU, pf_mtu);
453 /* flush added to prevent cmd failure
454 * incase the queue is full
456 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
458 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
459 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
461 ctrl_cmd.eth_dev = eth_dev;
464 ctrl_pkt.ncmd.s.cmd = LIO_CMD_CHANGE_MTU;
465 ctrl_pkt.ncmd.s.param1 = mtu;
466 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
468 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
469 lio_dev_err(lio_dev, "Failed to send command to change MTU\n");
473 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
474 lio_dev_err(lio_dev, "Command to change MTU timed out\n");
478 if (frame_len > ETHER_MAX_LEN)
479 eth_dev->data->dev_conf.rxmode.offloads |=
480 DEV_RX_OFFLOAD_JUMBO_FRAME;
482 eth_dev->data->dev_conf.rxmode.offloads &=
483 ~DEV_RX_OFFLOAD_JUMBO_FRAME;
485 eth_dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_len;
486 eth_dev->data->mtu = mtu;
492 lio_dev_rss_reta_update(struct rte_eth_dev *eth_dev,
493 struct rte_eth_rss_reta_entry64 *reta_conf,
496 struct lio_device *lio_dev = LIO_DEV(eth_dev);
497 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
498 struct lio_rss_set *rss_param;
499 struct lio_dev_ctrl_cmd ctrl_cmd;
500 struct lio_ctrl_pkt ctrl_pkt;
503 if (!lio_dev->intf_open) {
504 lio_dev_err(lio_dev, "Port %d down, can't update reta\n",
509 if (reta_size != LIO_RSS_MAX_TABLE_SZ) {
511 "The size of hash lookup table configured (%d) doesn't match the number hardware can supported (%d)\n",
512 reta_size, LIO_RSS_MAX_TABLE_SZ);
516 /* flush added to prevent cmd failure
517 * incase the queue is full
519 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
521 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
522 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
524 rss_param = (struct lio_rss_set *)&ctrl_pkt.udd[0];
526 ctrl_cmd.eth_dev = eth_dev;
529 ctrl_pkt.ncmd.s.cmd = LIO_CMD_SET_RSS;
530 ctrl_pkt.ncmd.s.more = sizeof(struct lio_rss_set) >> 3;
531 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
533 rss_param->param.flags = 0xF;
534 rss_param->param.flags &= ~LIO_RSS_PARAM_ITABLE_UNCHANGED;
535 rss_param->param.itablesize = LIO_RSS_MAX_TABLE_SZ;
537 for (i = 0; i < (reta_size / RTE_RETA_GROUP_SIZE); i++) {
538 for (j = 0; j < RTE_RETA_GROUP_SIZE; j++) {
539 if ((reta_conf[i].mask) & ((uint64_t)1 << j)) {
540 index = (i * RTE_RETA_GROUP_SIZE) + j;
541 rss_state->itable[index] = reta_conf[i].reta[j];
546 rss_state->itable_size = LIO_RSS_MAX_TABLE_SZ;
547 memcpy(rss_param->itable, rss_state->itable, rss_state->itable_size);
549 lio_swap_8B_data((uint64_t *)rss_param, LIO_RSS_PARAM_SIZE >> 3);
551 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
552 lio_dev_err(lio_dev, "Failed to set rss hash\n");
556 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
557 lio_dev_err(lio_dev, "Set rss hash timed out\n");
565 lio_dev_rss_reta_query(struct rte_eth_dev *eth_dev,
566 struct rte_eth_rss_reta_entry64 *reta_conf,
569 struct lio_device *lio_dev = LIO_DEV(eth_dev);
570 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
573 if (reta_size != LIO_RSS_MAX_TABLE_SZ) {
575 "The size of hash lookup table configured (%d) doesn't match the number hardware can supported (%d)\n",
576 reta_size, LIO_RSS_MAX_TABLE_SZ);
580 num = reta_size / RTE_RETA_GROUP_SIZE;
582 for (i = 0; i < num; i++) {
583 memcpy(reta_conf->reta,
584 &rss_state->itable[i * RTE_RETA_GROUP_SIZE],
585 RTE_RETA_GROUP_SIZE);
593 lio_dev_rss_hash_conf_get(struct rte_eth_dev *eth_dev,
594 struct rte_eth_rss_conf *rss_conf)
596 struct lio_device *lio_dev = LIO_DEV(eth_dev);
597 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
598 uint8_t *hash_key = NULL;
601 if (rss_state->hash_disable) {
602 lio_dev_info(lio_dev, "RSS disabled in nic\n");
603 rss_conf->rss_hf = 0;
608 hash_key = rss_conf->rss_key;
609 if (hash_key != NULL)
610 memcpy(hash_key, rss_state->hash_key, rss_state->hash_key_size);
613 rss_hf |= ETH_RSS_IPV4;
614 if (rss_state->tcp_hash)
615 rss_hf |= ETH_RSS_NONFRAG_IPV4_TCP;
617 rss_hf |= ETH_RSS_IPV6;
618 if (rss_state->ipv6_tcp_hash)
619 rss_hf |= ETH_RSS_NONFRAG_IPV6_TCP;
620 if (rss_state->ipv6_ex)
621 rss_hf |= ETH_RSS_IPV6_EX;
622 if (rss_state->ipv6_tcp_ex_hash)
623 rss_hf |= ETH_RSS_IPV6_TCP_EX;
625 rss_conf->rss_hf = rss_hf;
631 lio_dev_rss_hash_update(struct rte_eth_dev *eth_dev,
632 struct rte_eth_rss_conf *rss_conf)
634 struct lio_device *lio_dev = LIO_DEV(eth_dev);
635 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
636 struct lio_rss_set *rss_param;
637 struct lio_dev_ctrl_cmd ctrl_cmd;
638 struct lio_ctrl_pkt ctrl_pkt;
640 if (!lio_dev->intf_open) {
641 lio_dev_err(lio_dev, "Port %d down, can't update hash\n",
646 /* flush added to prevent cmd failure
647 * incase the queue is full
649 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
651 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
652 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
654 rss_param = (struct lio_rss_set *)&ctrl_pkt.udd[0];
656 ctrl_cmd.eth_dev = eth_dev;
659 ctrl_pkt.ncmd.s.cmd = LIO_CMD_SET_RSS;
660 ctrl_pkt.ncmd.s.more = sizeof(struct lio_rss_set) >> 3;
661 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
663 rss_param->param.flags = 0xF;
665 if (rss_conf->rss_key) {
666 rss_param->param.flags &= ~LIO_RSS_PARAM_HASH_KEY_UNCHANGED;
667 rss_state->hash_key_size = LIO_RSS_MAX_KEY_SZ;
668 rss_param->param.hashkeysize = LIO_RSS_MAX_KEY_SZ;
669 memcpy(rss_state->hash_key, rss_conf->rss_key,
670 rss_state->hash_key_size);
671 memcpy(rss_param->key, rss_state->hash_key,
672 rss_state->hash_key_size);
675 if ((rss_conf->rss_hf & LIO_RSS_OFFLOAD_ALL) == 0) {
676 /* Can't disable rss through hash flags,
677 * if it is enabled by default during init
679 if (!rss_state->hash_disable)
682 /* This is for --disable-rss during testpmd launch */
683 rss_param->param.flags |= LIO_RSS_PARAM_DISABLE_RSS;
685 uint32_t hashinfo = 0;
687 /* Can't enable rss if disabled by default during init */
688 if (rss_state->hash_disable)
691 if (rss_conf->rss_hf & ETH_RSS_IPV4) {
692 hashinfo |= LIO_RSS_HASH_IPV4;
698 if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV4_TCP) {
699 hashinfo |= LIO_RSS_HASH_TCP_IPV4;
700 rss_state->tcp_hash = 1;
702 rss_state->tcp_hash = 0;
705 if (rss_conf->rss_hf & ETH_RSS_IPV6) {
706 hashinfo |= LIO_RSS_HASH_IPV6;
712 if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV6_TCP) {
713 hashinfo |= LIO_RSS_HASH_TCP_IPV6;
714 rss_state->ipv6_tcp_hash = 1;
716 rss_state->ipv6_tcp_hash = 0;
719 if (rss_conf->rss_hf & ETH_RSS_IPV6_EX) {
720 hashinfo |= LIO_RSS_HASH_IPV6_EX;
721 rss_state->ipv6_ex = 1;
723 rss_state->ipv6_ex = 0;
726 if (rss_conf->rss_hf & ETH_RSS_IPV6_TCP_EX) {
727 hashinfo |= LIO_RSS_HASH_TCP_IPV6_EX;
728 rss_state->ipv6_tcp_ex_hash = 1;
730 rss_state->ipv6_tcp_ex_hash = 0;
733 rss_param->param.flags &= ~LIO_RSS_PARAM_HASH_INFO_UNCHANGED;
734 rss_param->param.hashinfo = hashinfo;
737 lio_swap_8B_data((uint64_t *)rss_param, LIO_RSS_PARAM_SIZE >> 3);
739 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
740 lio_dev_err(lio_dev, "Failed to set rss hash\n");
744 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
745 lio_dev_err(lio_dev, "Set rss hash timed out\n");
753 * Add vxlan dest udp port for an interface.
756 * Pointer to the structure rte_eth_dev
761 * On success return 0
762 * On failure return -1
765 lio_dev_udp_tunnel_add(struct rte_eth_dev *eth_dev,
766 struct rte_eth_udp_tunnel *udp_tnl)
768 struct lio_device *lio_dev = LIO_DEV(eth_dev);
769 struct lio_dev_ctrl_cmd ctrl_cmd;
770 struct lio_ctrl_pkt ctrl_pkt;
775 if (udp_tnl->prot_type != RTE_TUNNEL_TYPE_VXLAN) {
776 lio_dev_err(lio_dev, "Unsupported tunnel type\n");
780 /* flush added to prevent cmd failure
781 * incase the queue is full
783 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
785 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
786 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
788 ctrl_cmd.eth_dev = eth_dev;
791 ctrl_pkt.ncmd.s.cmd = LIO_CMD_VXLAN_PORT_CONFIG;
792 ctrl_pkt.ncmd.s.param1 = udp_tnl->udp_port;
793 ctrl_pkt.ncmd.s.more = LIO_CMD_VXLAN_PORT_ADD;
794 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
796 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
797 lio_dev_err(lio_dev, "Failed to send VXLAN_PORT_ADD command\n");
801 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
802 lio_dev_err(lio_dev, "VXLAN_PORT_ADD command timed out\n");
810 * Remove vxlan dest udp port for an interface.
813 * Pointer to the structure rte_eth_dev
818 * On success return 0
819 * On failure return -1
822 lio_dev_udp_tunnel_del(struct rte_eth_dev *eth_dev,
823 struct rte_eth_udp_tunnel *udp_tnl)
825 struct lio_device *lio_dev = LIO_DEV(eth_dev);
826 struct lio_dev_ctrl_cmd ctrl_cmd;
827 struct lio_ctrl_pkt ctrl_pkt;
832 if (udp_tnl->prot_type != RTE_TUNNEL_TYPE_VXLAN) {
833 lio_dev_err(lio_dev, "Unsupported tunnel type\n");
837 /* flush added to prevent cmd failure
838 * incase the queue is full
840 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
842 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
843 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
845 ctrl_cmd.eth_dev = eth_dev;
848 ctrl_pkt.ncmd.s.cmd = LIO_CMD_VXLAN_PORT_CONFIG;
849 ctrl_pkt.ncmd.s.param1 = udp_tnl->udp_port;
850 ctrl_pkt.ncmd.s.more = LIO_CMD_VXLAN_PORT_DEL;
851 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
853 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
854 lio_dev_err(lio_dev, "Failed to send VXLAN_PORT_DEL command\n");
858 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
859 lio_dev_err(lio_dev, "VXLAN_PORT_DEL command timed out\n");
867 lio_dev_vlan_filter_set(struct rte_eth_dev *eth_dev, uint16_t vlan_id, int on)
869 struct lio_device *lio_dev = LIO_DEV(eth_dev);
870 struct lio_dev_ctrl_cmd ctrl_cmd;
871 struct lio_ctrl_pkt ctrl_pkt;
873 if (lio_dev->linfo.vlan_is_admin_assigned)
876 /* flush added to prevent cmd failure
877 * incase the queue is full
879 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
881 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
882 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
884 ctrl_cmd.eth_dev = eth_dev;
887 ctrl_pkt.ncmd.s.cmd = on ?
888 LIO_CMD_ADD_VLAN_FILTER : LIO_CMD_DEL_VLAN_FILTER;
889 ctrl_pkt.ncmd.s.param1 = vlan_id;
890 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
892 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
893 lio_dev_err(lio_dev, "Failed to %s VLAN port\n",
894 on ? "add" : "remove");
898 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
899 lio_dev_err(lio_dev, "Command to %s VLAN port timed out\n",
900 on ? "add" : "remove");
908 lio_hweight64(uint64_t w)
910 uint64_t res = w - ((w >> 1) & 0x5555555555555555ul);
913 (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul);
914 res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful;
915 res = res + (res >> 8);
916 res = res + (res >> 16);
918 return (res + (res >> 32)) & 0x00000000000000FFul;
922 lio_dev_link_update(struct rte_eth_dev *eth_dev,
923 int wait_to_complete __rte_unused)
925 struct lio_device *lio_dev = LIO_DEV(eth_dev);
926 struct rte_eth_link link;
929 memset(&link, 0, sizeof(link));
930 link.link_status = ETH_LINK_DOWN;
931 link.link_speed = ETH_SPEED_NUM_NONE;
932 link.link_duplex = ETH_LINK_HALF_DUPLEX;
933 link.link_autoneg = ETH_LINK_AUTONEG;
935 /* Return what we found */
936 if (lio_dev->linfo.link.s.link_up == 0) {
937 /* Interface is down */
938 return rte_eth_linkstatus_set(eth_dev, &link);
941 link.link_status = ETH_LINK_UP; /* Interface is up */
942 link.link_duplex = ETH_LINK_FULL_DUPLEX;
943 switch (lio_dev->linfo.link.s.speed) {
944 case LIO_LINK_SPEED_10000:
945 link.link_speed = ETH_SPEED_NUM_10G;
947 case LIO_LINK_SPEED_25000:
948 link.link_speed = ETH_SPEED_NUM_25G;
951 link.link_speed = ETH_SPEED_NUM_NONE;
952 link.link_duplex = ETH_LINK_HALF_DUPLEX;
955 return rte_eth_linkstatus_set(eth_dev, &link);
959 * \brief Net device enable, disable allmulticast
960 * @param eth_dev Pointer to the structure rte_eth_dev
963 lio_change_dev_flag(struct rte_eth_dev *eth_dev)
965 struct lio_device *lio_dev = LIO_DEV(eth_dev);
966 struct lio_dev_ctrl_cmd ctrl_cmd;
967 struct lio_ctrl_pkt ctrl_pkt;
969 /* flush added to prevent cmd failure
970 * incase the queue is full
972 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
974 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
975 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
977 ctrl_cmd.eth_dev = eth_dev;
980 /* Create a ctrl pkt command to be sent to core app. */
981 ctrl_pkt.ncmd.s.cmd = LIO_CMD_CHANGE_DEVFLAGS;
982 ctrl_pkt.ncmd.s.param1 = lio_dev->ifflags;
983 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
985 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
986 lio_dev_err(lio_dev, "Failed to send change flag message\n");
990 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd))
991 lio_dev_err(lio_dev, "Change dev flag command timed out\n");
995 lio_dev_promiscuous_enable(struct rte_eth_dev *eth_dev)
997 struct lio_device *lio_dev = LIO_DEV(eth_dev);
999 if (strcmp(lio_dev->firmware_version, LIO_VF_TRUST_MIN_VERSION) < 0) {
1000 lio_dev_err(lio_dev, "Require firmware version >= %s\n",
1001 LIO_VF_TRUST_MIN_VERSION);
1005 if (!lio_dev->intf_open) {
1006 lio_dev_err(lio_dev, "Port %d down, can't enable promiscuous\n",
1011 lio_dev->ifflags |= LIO_IFFLAG_PROMISC;
1012 lio_change_dev_flag(eth_dev);
1016 lio_dev_promiscuous_disable(struct rte_eth_dev *eth_dev)
1018 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1020 if (strcmp(lio_dev->firmware_version, LIO_VF_TRUST_MIN_VERSION) < 0) {
1021 lio_dev_err(lio_dev, "Require firmware version >= %s\n",
1022 LIO_VF_TRUST_MIN_VERSION);
1026 if (!lio_dev->intf_open) {
1027 lio_dev_err(lio_dev, "Port %d down, can't disable promiscuous\n",
1032 lio_dev->ifflags &= ~LIO_IFFLAG_PROMISC;
1033 lio_change_dev_flag(eth_dev);
1037 lio_dev_allmulticast_enable(struct rte_eth_dev *eth_dev)
1039 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1041 if (!lio_dev->intf_open) {
1042 lio_dev_err(lio_dev, "Port %d down, can't enable multicast\n",
1047 lio_dev->ifflags |= LIO_IFFLAG_ALLMULTI;
1048 lio_change_dev_flag(eth_dev);
1052 lio_dev_allmulticast_disable(struct rte_eth_dev *eth_dev)
1054 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1056 if (!lio_dev->intf_open) {
1057 lio_dev_err(lio_dev, "Port %d down, can't disable multicast\n",
1062 lio_dev->ifflags &= ~LIO_IFFLAG_ALLMULTI;
1063 lio_change_dev_flag(eth_dev);
1067 lio_dev_rss_configure(struct rte_eth_dev *eth_dev)
1069 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1070 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
1071 struct rte_eth_rss_reta_entry64 reta_conf[8];
1072 struct rte_eth_rss_conf rss_conf;
1075 /* Configure the RSS key and the RSS protocols used to compute
1076 * the RSS hash of input packets.
1078 rss_conf = eth_dev->data->dev_conf.rx_adv_conf.rss_conf;
1079 if ((rss_conf.rss_hf & LIO_RSS_OFFLOAD_ALL) == 0) {
1080 rss_state->hash_disable = 1;
1081 lio_dev_rss_hash_update(eth_dev, &rss_conf);
1085 if (rss_conf.rss_key == NULL)
1086 rss_conf.rss_key = lio_rss_key; /* Default hash key */
1088 lio_dev_rss_hash_update(eth_dev, &rss_conf);
1090 memset(reta_conf, 0, sizeof(reta_conf));
1091 for (i = 0; i < LIO_RSS_MAX_TABLE_SZ; i++) {
1092 uint8_t q_idx, conf_idx, reta_idx;
1094 q_idx = (uint8_t)((eth_dev->data->nb_rx_queues > 1) ?
1095 i % eth_dev->data->nb_rx_queues : 0);
1096 conf_idx = i / RTE_RETA_GROUP_SIZE;
1097 reta_idx = i % RTE_RETA_GROUP_SIZE;
1098 reta_conf[conf_idx].reta[reta_idx] = q_idx;
1099 reta_conf[conf_idx].mask |= ((uint64_t)1 << reta_idx);
1102 lio_dev_rss_reta_update(eth_dev, reta_conf, LIO_RSS_MAX_TABLE_SZ);
1106 lio_dev_mq_rx_configure(struct rte_eth_dev *eth_dev)
1108 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1109 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
1110 struct rte_eth_rss_conf rss_conf;
1112 switch (eth_dev->data->dev_conf.rxmode.mq_mode) {
1114 lio_dev_rss_configure(eth_dev);
1116 case ETH_MQ_RX_NONE:
1117 /* if mq_mode is none, disable rss mode. */
1119 memset(&rss_conf, 0, sizeof(rss_conf));
1120 rss_state->hash_disable = 1;
1121 lio_dev_rss_hash_update(eth_dev, &rss_conf);
1126 * Setup our receive queue/ringbuffer. This is the
1127 * queue the Octeon uses to send us packets and
1128 * responses. We are given a memory pool for our
1129 * packet buffers that are used to populate the receive
1133 * Pointer to the structure rte_eth_dev
1136 * @param num_rx_descs
1137 * Number of entries in the queue
1139 * Where to allocate memory
1141 * Pointer to the struction rte_eth_rxconf
1143 * Pointer to the packet pool
1146 * - On success, return 0
1147 * - On failure, return -1
1150 lio_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t q_no,
1151 uint16_t num_rx_descs, unsigned int socket_id,
1152 const struct rte_eth_rxconf *rx_conf __rte_unused,
1153 struct rte_mempool *mp)
1155 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1156 struct rte_pktmbuf_pool_private *mbp_priv;
1157 uint32_t fw_mapped_oq;
1160 if (q_no >= lio_dev->nb_rx_queues) {
1161 lio_dev_err(lio_dev, "Invalid rx queue number %u\n", q_no);
1165 lio_dev_dbg(lio_dev, "setting up rx queue %u\n", q_no);
1167 fw_mapped_oq = lio_dev->linfo.rxpciq[q_no].s.q_no;
1169 /* Free previous allocation if any */
1170 if (eth_dev->data->rx_queues[q_no] != NULL) {
1171 lio_dev_rx_queue_release(eth_dev->data->rx_queues[q_no]);
1172 eth_dev->data->rx_queues[q_no] = NULL;
1175 mbp_priv = rte_mempool_get_priv(mp);
1176 buf_size = mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM;
1178 if (lio_setup_droq(lio_dev, fw_mapped_oq, num_rx_descs, buf_size, mp,
1180 lio_dev_err(lio_dev, "droq allocation failed\n");
1184 eth_dev->data->rx_queues[q_no] = lio_dev->droq[fw_mapped_oq];
1190 * Release the receive queue/ringbuffer. Called by
1194 * Opaque pointer to the receive queue to release
1200 lio_dev_rx_queue_release(void *rxq)
1202 struct lio_droq *droq = rxq;
1207 lio_delete_droq_queue(droq->lio_dev, oq_no);
1212 * Allocate and initialize SW ring. Initialize associated HW registers.
1215 * Pointer to structure rte_eth_dev
1220 * @param num_tx_descs
1221 * Number of ringbuffer descriptors
1224 * NUMA socket id, used for memory allocations
1227 * Pointer to the structure rte_eth_txconf
1230 * - On success, return 0
1231 * - On failure, return -errno value
1234 lio_dev_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t q_no,
1235 uint16_t num_tx_descs, unsigned int socket_id,
1236 const struct rte_eth_txconf *tx_conf __rte_unused)
1238 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1239 int fw_mapped_iq = lio_dev->linfo.txpciq[q_no].s.q_no;
1242 if (q_no >= lio_dev->nb_tx_queues) {
1243 lio_dev_err(lio_dev, "Invalid tx queue number %u\n", q_no);
1247 lio_dev_dbg(lio_dev, "setting up tx queue %u\n", q_no);
1249 /* Free previous allocation if any */
1250 if (eth_dev->data->tx_queues[q_no] != NULL) {
1251 lio_dev_tx_queue_release(eth_dev->data->tx_queues[q_no]);
1252 eth_dev->data->tx_queues[q_no] = NULL;
1255 retval = lio_setup_iq(lio_dev, q_no, lio_dev->linfo.txpciq[q_no],
1256 num_tx_descs, lio_dev, socket_id);
1259 lio_dev_err(lio_dev, "Runtime IQ(TxQ) creation failed.\n");
1263 retval = lio_setup_sglists(lio_dev, q_no, fw_mapped_iq,
1264 lio_dev->instr_queue[fw_mapped_iq]->nb_desc,
1268 lio_delete_instruction_queue(lio_dev, fw_mapped_iq);
1272 eth_dev->data->tx_queues[q_no] = lio_dev->instr_queue[fw_mapped_iq];
1278 * Release the transmit queue/ringbuffer. Called by
1282 * Opaque pointer to the transmit queue to release
1288 lio_dev_tx_queue_release(void *txq)
1290 struct lio_instr_queue *tq = txq;
1291 uint32_t fw_mapped_iq_no;
1296 lio_delete_sglist(tq);
1298 fw_mapped_iq_no = tq->txpciq.s.q_no;
1299 lio_delete_instruction_queue(tq->lio_dev, fw_mapped_iq_no);
1304 * Api to check link state.
1307 lio_dev_get_link_status(struct rte_eth_dev *eth_dev)
1309 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1310 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1311 struct lio_link_status_resp *resp;
1312 union octeon_link_status *ls;
1313 struct lio_soft_command *sc;
1316 if (!lio_dev->intf_open)
1319 resp_size = sizeof(struct lio_link_status_resp);
1320 sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
1324 resp = (struct lio_link_status_resp *)sc->virtrptr;
1325 lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
1326 LIO_OPCODE_INFO, 0, 0, 0);
1328 /* Setting wait time in seconds */
1329 sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
1331 if (lio_send_soft_command(lio_dev, sc) == LIO_IQ_SEND_FAILED)
1332 goto get_status_fail;
1334 while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
1335 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
1340 goto get_status_fail;
1342 ls = &resp->link_info.link;
1344 lio_swap_8B_data((uint64_t *)ls, sizeof(union octeon_link_status) >> 3);
1346 if (lio_dev->linfo.link.link_status64 != ls->link_status64) {
1347 if (ls->s.mtu < eth_dev->data->mtu) {
1348 lio_dev_info(lio_dev, "Lowered VF MTU to %d as PF MTU dropped\n",
1350 eth_dev->data->mtu = ls->s.mtu;
1352 lio_dev->linfo.link.link_status64 = ls->link_status64;
1353 lio_dev_link_update(eth_dev, 0);
1356 lio_free_soft_command(sc);
1361 lio_free_soft_command(sc);
1364 /* This function will be invoked every LSC_TIMEOUT ns (100ms)
1365 * and will update link state if it changes.
1368 lio_sync_link_state_check(void *eth_dev)
1370 struct lio_device *lio_dev =
1371 (((struct rte_eth_dev *)eth_dev)->data->dev_private);
1373 if (lio_dev->port_configured)
1374 lio_dev_get_link_status(eth_dev);
1376 /* Schedule periodic link status check.
1377 * Stop check if interface is close and start again while opening.
1379 if (lio_dev->intf_open)
1380 rte_eal_alarm_set(LIO_LSC_TIMEOUT, lio_sync_link_state_check,
1385 lio_dev_start(struct rte_eth_dev *eth_dev)
1388 uint32_t frame_len = eth_dev->data->dev_conf.rxmode.max_rx_pkt_len;
1389 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1390 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1393 lio_dev_info(lio_dev, "Starting port %d\n", eth_dev->data->port_id);
1395 if (lio_dev->fn_list.enable_io_queues(lio_dev))
1398 if (lio_send_rx_ctrl_cmd(eth_dev, 1))
1401 /* Ready for link status updates */
1402 lio_dev->intf_open = 1;
1405 /* Configure RSS if device configured with multiple RX queues. */
1406 lio_dev_mq_rx_configure(eth_dev);
1408 /* start polling for lsc */
1409 ret = rte_eal_alarm_set(LIO_LSC_TIMEOUT,
1410 lio_sync_link_state_check,
1413 lio_dev_err(lio_dev,
1414 "link state check handler creation failed\n");
1415 goto dev_lsc_handle_error;
1418 while ((lio_dev->linfo.link.link_status64 == 0) && (--timeout))
1421 if (lio_dev->linfo.link.link_status64 == 0) {
1423 goto dev_mtu_set_error;
1426 mtu = (uint16_t)(frame_len - ETHER_HDR_LEN - ETHER_CRC_LEN);
1427 if (mtu < ETHER_MIN_MTU)
1428 mtu = ETHER_MIN_MTU;
1430 if (eth_dev->data->mtu != mtu) {
1431 ret = lio_dev_mtu_set(eth_dev, mtu);
1433 goto dev_mtu_set_error;
1439 rte_eal_alarm_cancel(lio_sync_link_state_check, eth_dev);
1441 dev_lsc_handle_error:
1442 lio_dev->intf_open = 0;
1443 lio_send_rx_ctrl_cmd(eth_dev, 0);
1448 /* Stop device and disable input/output functions */
1450 lio_dev_stop(struct rte_eth_dev *eth_dev)
1452 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1454 lio_dev_info(lio_dev, "Stopping port %d\n", eth_dev->data->port_id);
1455 lio_dev->intf_open = 0;
1458 /* Cancel callback if still running. */
1459 rte_eal_alarm_cancel(lio_sync_link_state_check, eth_dev);
1461 lio_send_rx_ctrl_cmd(eth_dev, 0);
1463 lio_wait_for_instr_fetch(lio_dev);
1465 /* Clear recorded link status */
1466 lio_dev->linfo.link.link_status64 = 0;
1470 lio_dev_set_link_up(struct rte_eth_dev *eth_dev)
1472 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1474 if (!lio_dev->intf_open) {
1475 lio_dev_info(lio_dev, "Port is stopped, Start the port first\n");
1479 if (lio_dev->linfo.link.s.link_up) {
1480 lio_dev_info(lio_dev, "Link is already UP\n");
1484 if (lio_send_rx_ctrl_cmd(eth_dev, 1)) {
1485 lio_dev_err(lio_dev, "Unable to set Link UP\n");
1489 lio_dev->linfo.link.s.link_up = 1;
1490 eth_dev->data->dev_link.link_status = ETH_LINK_UP;
1496 lio_dev_set_link_down(struct rte_eth_dev *eth_dev)
1498 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1500 if (!lio_dev->intf_open) {
1501 lio_dev_info(lio_dev, "Port is stopped, Start the port first\n");
1505 if (!lio_dev->linfo.link.s.link_up) {
1506 lio_dev_info(lio_dev, "Link is already DOWN\n");
1510 lio_dev->linfo.link.s.link_up = 0;
1511 eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
1513 if (lio_send_rx_ctrl_cmd(eth_dev, 0)) {
1514 lio_dev->linfo.link.s.link_up = 1;
1515 eth_dev->data->dev_link.link_status = ETH_LINK_UP;
1516 lio_dev_err(lio_dev, "Unable to set Link Down\n");
1524 * Reset and stop the device. This occurs on the first
1525 * call to this routine. Subsequent calls will simply
1526 * return. NB: This will require the NIC to be rebooted.
1529 * Pointer to the structure rte_eth_dev
1535 lio_dev_close(struct rte_eth_dev *eth_dev)
1537 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1539 lio_dev_info(lio_dev, "closing port %d\n", eth_dev->data->port_id);
1541 if (lio_dev->intf_open)
1542 lio_dev_stop(eth_dev);
1544 /* Reset ioq regs */
1545 lio_dev->fn_list.setup_device_regs(lio_dev);
1547 if (lio_dev->pci_dev->kdrv == RTE_KDRV_IGB_UIO) {
1548 cn23xx_vf_ask_pf_to_do_flr(lio_dev);
1549 rte_delay_ms(LIO_PCI_FLR_WAIT);
1553 lio_dev->fn_list.free_mbox(lio_dev);
1555 /* Free glist resources */
1556 rte_free(lio_dev->glist_head);
1557 rte_free(lio_dev->glist_lock);
1558 lio_dev->glist_head = NULL;
1559 lio_dev->glist_lock = NULL;
1561 lio_dev->port_configured = 0;
1563 /* Delete all queues */
1564 lio_dev_clear_queues(eth_dev);
1568 * Enable tunnel rx checksum verification from firmware.
1571 lio_enable_hw_tunnel_rx_checksum(struct rte_eth_dev *eth_dev)
1573 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1574 struct lio_dev_ctrl_cmd ctrl_cmd;
1575 struct lio_ctrl_pkt ctrl_pkt;
1577 /* flush added to prevent cmd failure
1578 * incase the queue is full
1580 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1582 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1583 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1585 ctrl_cmd.eth_dev = eth_dev;
1588 ctrl_pkt.ncmd.s.cmd = LIO_CMD_TNL_RX_CSUM_CTL;
1589 ctrl_pkt.ncmd.s.param1 = LIO_CMD_RXCSUM_ENABLE;
1590 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1592 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1593 lio_dev_err(lio_dev, "Failed to send TNL_RX_CSUM command\n");
1597 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd))
1598 lio_dev_err(lio_dev, "TNL_RX_CSUM command timed out\n");
1602 * Enable checksum calculation for inner packet in a tunnel.
1605 lio_enable_hw_tunnel_tx_checksum(struct rte_eth_dev *eth_dev)
1607 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1608 struct lio_dev_ctrl_cmd ctrl_cmd;
1609 struct lio_ctrl_pkt ctrl_pkt;
1611 /* flush added to prevent cmd failure
1612 * incase the queue is full
1614 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1616 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1617 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1619 ctrl_cmd.eth_dev = eth_dev;
1622 ctrl_pkt.ncmd.s.cmd = LIO_CMD_TNL_TX_CSUM_CTL;
1623 ctrl_pkt.ncmd.s.param1 = LIO_CMD_TXCSUM_ENABLE;
1624 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1626 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1627 lio_dev_err(lio_dev, "Failed to send TNL_TX_CSUM command\n");
1631 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd))
1632 lio_dev_err(lio_dev, "TNL_TX_CSUM command timed out\n");
1636 lio_send_queue_count_update(struct rte_eth_dev *eth_dev, int num_txq,
1639 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1640 struct lio_dev_ctrl_cmd ctrl_cmd;
1641 struct lio_ctrl_pkt ctrl_pkt;
1643 if (strcmp(lio_dev->firmware_version, LIO_Q_RECONF_MIN_VERSION) < 0) {
1644 lio_dev_err(lio_dev, "Require firmware version >= %s\n",
1645 LIO_Q_RECONF_MIN_VERSION);
1649 /* flush added to prevent cmd failure
1650 * incase the queue is full
1652 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1654 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1655 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1657 ctrl_cmd.eth_dev = eth_dev;
1660 ctrl_pkt.ncmd.s.cmd = LIO_CMD_QUEUE_COUNT_CTL;
1661 ctrl_pkt.ncmd.s.param1 = num_txq;
1662 ctrl_pkt.ncmd.s.param2 = num_rxq;
1663 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1665 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1666 lio_dev_err(lio_dev, "Failed to send queue count control command\n");
1670 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
1671 lio_dev_err(lio_dev, "Queue count control command timed out\n");
1679 lio_reconf_queues(struct rte_eth_dev *eth_dev, int num_txq, int num_rxq)
1681 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1683 if (lio_dev->nb_rx_queues != num_rxq ||
1684 lio_dev->nb_tx_queues != num_txq) {
1685 if (lio_send_queue_count_update(eth_dev, num_txq, num_rxq))
1687 lio_dev->nb_rx_queues = num_rxq;
1688 lio_dev->nb_tx_queues = num_txq;
1691 if (lio_dev->intf_open)
1692 lio_dev_stop(eth_dev);
1694 /* Reset ioq registers */
1695 if (lio_dev->fn_list.setup_device_regs(lio_dev)) {
1696 lio_dev_err(lio_dev, "Failed to configure device registers\n");
1704 lio_dev_configure(struct rte_eth_dev *eth_dev)
1706 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1707 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1708 int retval, num_iqueues, num_oqueues;
1709 uint8_t mac[ETHER_ADDR_LEN], i;
1710 struct lio_if_cfg_resp *resp;
1711 struct lio_soft_command *sc;
1712 union lio_if_cfg if_cfg;
1715 PMD_INIT_FUNC_TRACE();
1717 /* Inform firmware about change in number of queues to use.
1718 * Disable IO queues and reset registers for re-configuration.
1720 if (lio_dev->port_configured)
1721 return lio_reconf_queues(eth_dev,
1722 eth_dev->data->nb_tx_queues,
1723 eth_dev->data->nb_rx_queues);
1725 lio_dev->nb_rx_queues = eth_dev->data->nb_rx_queues;
1726 lio_dev->nb_tx_queues = eth_dev->data->nb_tx_queues;
1728 /* Set max number of queues which can be re-configured. */
1729 lio_dev->max_rx_queues = eth_dev->data->nb_rx_queues;
1730 lio_dev->max_tx_queues = eth_dev->data->nb_tx_queues;
1732 resp_size = sizeof(struct lio_if_cfg_resp);
1733 sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
1737 resp = (struct lio_if_cfg_resp *)sc->virtrptr;
1739 /* Firmware doesn't have capability to reconfigure the queues,
1740 * Claim all queues, and use as many required
1742 if_cfg.if_cfg64 = 0;
1743 if_cfg.s.num_iqueues = lio_dev->nb_tx_queues;
1744 if_cfg.s.num_oqueues = lio_dev->nb_rx_queues;
1745 if_cfg.s.base_queue = 0;
1747 if_cfg.s.gmx_port_id = lio_dev->pf_num;
1749 lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
1750 LIO_OPCODE_IF_CFG, 0,
1751 if_cfg.if_cfg64, 0);
1753 /* Setting wait time in seconds */
1754 sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
1756 retval = lio_send_soft_command(lio_dev, sc);
1757 if (retval == LIO_IQ_SEND_FAILED) {
1758 lio_dev_err(lio_dev, "iq/oq config failed status: %x\n",
1760 /* Soft instr is freed by driver in case of failure. */
1761 goto nic_config_fail;
1764 /* Sleep on a wait queue till the cond flag indicates that the
1765 * response arrived or timed-out.
1767 while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
1768 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
1769 lio_process_ordered_list(lio_dev);
1773 retval = resp->status;
1775 lio_dev_err(lio_dev, "iq/oq config failed\n");
1776 goto nic_config_fail;
1779 snprintf(lio_dev->firmware_version, LIO_FW_VERSION_LENGTH, "%s",
1780 resp->cfg_info.lio_firmware_version);
1782 lio_swap_8B_data((uint64_t *)(&resp->cfg_info),
1783 sizeof(struct octeon_if_cfg_info) >> 3);
1785 num_iqueues = lio_hweight64(resp->cfg_info.iqmask);
1786 num_oqueues = lio_hweight64(resp->cfg_info.oqmask);
1788 if (!(num_iqueues) || !(num_oqueues)) {
1789 lio_dev_err(lio_dev,
1790 "Got bad iqueues (%016lx) or oqueues (%016lx) from firmware.\n",
1791 (unsigned long)resp->cfg_info.iqmask,
1792 (unsigned long)resp->cfg_info.oqmask);
1793 goto nic_config_fail;
1796 lio_dev_dbg(lio_dev,
1797 "interface %d, iqmask %016lx, oqmask %016lx, numiqueues %d, numoqueues %d\n",
1798 eth_dev->data->port_id,
1799 (unsigned long)resp->cfg_info.iqmask,
1800 (unsigned long)resp->cfg_info.oqmask,
1801 num_iqueues, num_oqueues);
1803 lio_dev->linfo.num_rxpciq = num_oqueues;
1804 lio_dev->linfo.num_txpciq = num_iqueues;
1806 for (i = 0; i < num_oqueues; i++) {
1807 lio_dev->linfo.rxpciq[i].rxpciq64 =
1808 resp->cfg_info.linfo.rxpciq[i].rxpciq64;
1809 lio_dev_dbg(lio_dev, "index %d OQ %d\n",
1810 i, lio_dev->linfo.rxpciq[i].s.q_no);
1813 for (i = 0; i < num_iqueues; i++) {
1814 lio_dev->linfo.txpciq[i].txpciq64 =
1815 resp->cfg_info.linfo.txpciq[i].txpciq64;
1816 lio_dev_dbg(lio_dev, "index %d IQ %d\n",
1817 i, lio_dev->linfo.txpciq[i].s.q_no);
1820 lio_dev->linfo.hw_addr = resp->cfg_info.linfo.hw_addr;
1821 lio_dev->linfo.gmxport = resp->cfg_info.linfo.gmxport;
1822 lio_dev->linfo.link.link_status64 =
1823 resp->cfg_info.linfo.link.link_status64;
1825 /* 64-bit swap required on LE machines */
1826 lio_swap_8B_data(&lio_dev->linfo.hw_addr, 1);
1827 for (i = 0; i < ETHER_ADDR_LEN; i++)
1828 mac[i] = *((uint8_t *)(((uint8_t *)&lio_dev->linfo.hw_addr) +
1831 /* Copy the permanent MAC address */
1832 ether_addr_copy((struct ether_addr *)mac, ð_dev->data->mac_addrs[0]);
1834 /* enable firmware checksum support for tunnel packets */
1835 lio_enable_hw_tunnel_rx_checksum(eth_dev);
1836 lio_enable_hw_tunnel_tx_checksum(eth_dev);
1838 lio_dev->glist_lock =
1839 rte_zmalloc(NULL, sizeof(*lio_dev->glist_lock) * num_iqueues, 0);
1840 if (lio_dev->glist_lock == NULL)
1843 lio_dev->glist_head =
1844 rte_zmalloc(NULL, sizeof(*lio_dev->glist_head) * num_iqueues,
1846 if (lio_dev->glist_head == NULL) {
1847 rte_free(lio_dev->glist_lock);
1848 lio_dev->glist_lock = NULL;
1852 lio_dev_link_update(eth_dev, 0);
1854 lio_dev->port_configured = 1;
1856 lio_free_soft_command(sc);
1858 /* Reset ioq regs */
1859 lio_dev->fn_list.setup_device_regs(lio_dev);
1861 /* Free iq_0 used during init */
1862 lio_free_instr_queue0(lio_dev);
1867 lio_dev_err(lio_dev, "Failed retval %d\n", retval);
1868 lio_free_soft_command(sc);
1869 lio_free_instr_queue0(lio_dev);
1874 /* Define our ethernet definitions */
1875 static const struct eth_dev_ops liovf_eth_dev_ops = {
1876 .dev_configure = lio_dev_configure,
1877 .dev_start = lio_dev_start,
1878 .dev_stop = lio_dev_stop,
1879 .dev_set_link_up = lio_dev_set_link_up,
1880 .dev_set_link_down = lio_dev_set_link_down,
1881 .dev_close = lio_dev_close,
1882 .promiscuous_enable = lio_dev_promiscuous_enable,
1883 .promiscuous_disable = lio_dev_promiscuous_disable,
1884 .allmulticast_enable = lio_dev_allmulticast_enable,
1885 .allmulticast_disable = lio_dev_allmulticast_disable,
1886 .link_update = lio_dev_link_update,
1887 .stats_get = lio_dev_stats_get,
1888 .xstats_get = lio_dev_xstats_get,
1889 .xstats_get_names = lio_dev_xstats_get_names,
1890 .stats_reset = lio_dev_stats_reset,
1891 .xstats_reset = lio_dev_xstats_reset,
1892 .dev_infos_get = lio_dev_info_get,
1893 .vlan_filter_set = lio_dev_vlan_filter_set,
1894 .rx_queue_setup = lio_dev_rx_queue_setup,
1895 .rx_queue_release = lio_dev_rx_queue_release,
1896 .tx_queue_setup = lio_dev_tx_queue_setup,
1897 .tx_queue_release = lio_dev_tx_queue_release,
1898 .reta_update = lio_dev_rss_reta_update,
1899 .reta_query = lio_dev_rss_reta_query,
1900 .rss_hash_conf_get = lio_dev_rss_hash_conf_get,
1901 .rss_hash_update = lio_dev_rss_hash_update,
1902 .udp_tunnel_port_add = lio_dev_udp_tunnel_add,
1903 .udp_tunnel_port_del = lio_dev_udp_tunnel_del,
1904 .mtu_set = lio_dev_mtu_set,
1908 lio_check_pf_hs_response(void *lio_dev)
1910 struct lio_device *dev = lio_dev;
1912 /* check till response arrives */
1913 if (dev->pfvf_hsword.coproc_tics_per_us)
1916 cn23xx_vf_handle_mbox(dev);
1918 rte_eal_alarm_set(1, lio_check_pf_hs_response, lio_dev);
1922 * \brief Identify the LIO device and to map the BAR address space
1923 * @param lio_dev lio device
1926 lio_chip_specific_setup(struct lio_device *lio_dev)
1928 struct rte_pci_device *pdev = lio_dev->pci_dev;
1929 uint32_t dev_id = pdev->id.device_id;
1934 case LIO_CN23XX_VF_VID:
1935 lio_dev->chip_id = LIO_CN23XX_VF_VID;
1936 ret = cn23xx_vf_setup_device(lio_dev);
1941 lio_dev_err(lio_dev, "Unsupported Chip\n");
1945 lio_dev_info(lio_dev, "DEVICE : %s\n", s);
1951 lio_first_time_init(struct lio_device *lio_dev,
1952 struct rte_pci_device *pdev)
1956 PMD_INIT_FUNC_TRACE();
1958 /* set dpdk specific pci device pointer */
1959 lio_dev->pci_dev = pdev;
1961 /* Identify the LIO type and set device ops */
1962 if (lio_chip_specific_setup(lio_dev)) {
1963 lio_dev_err(lio_dev, "Chip specific setup failed\n");
1967 /* Initialize soft command buffer pool */
1968 if (lio_setup_sc_buffer_pool(lio_dev)) {
1969 lio_dev_err(lio_dev, "sc buffer pool allocation failed\n");
1973 /* Initialize lists to manage the requests of different types that
1974 * arrive from applications for this lio device.
1976 lio_setup_response_list(lio_dev);
1978 if (lio_dev->fn_list.setup_mbox(lio_dev)) {
1979 lio_dev_err(lio_dev, "Mailbox setup failed\n");
1983 /* Check PF response */
1984 lio_check_pf_hs_response((void *)lio_dev);
1986 /* Do handshake and exit if incompatible PF driver */
1987 if (cn23xx_pfvf_handshake(lio_dev))
1990 /* Request and wait for device reset. */
1991 if (pdev->kdrv == RTE_KDRV_IGB_UIO) {
1992 cn23xx_vf_ask_pf_to_do_flr(lio_dev);
1993 /* FLR wait time doubled as a precaution. */
1994 rte_delay_ms(LIO_PCI_FLR_WAIT * 2);
1997 if (lio_dev->fn_list.setup_device_regs(lio_dev)) {
1998 lio_dev_err(lio_dev, "Failed to configure device registers\n");
2002 if (lio_setup_instr_queue0(lio_dev)) {
2003 lio_dev_err(lio_dev, "Failed to setup instruction queue 0\n");
2007 dpdk_queues = (int)lio_dev->sriov_info.rings_per_vf;
2009 lio_dev->max_tx_queues = dpdk_queues;
2010 lio_dev->max_rx_queues = dpdk_queues;
2012 /* Enable input and output queues for this device */
2013 if (lio_dev->fn_list.enable_io_queues(lio_dev))
2019 lio_free_sc_buffer_pool(lio_dev);
2020 if (lio_dev->mbox[0])
2021 lio_dev->fn_list.free_mbox(lio_dev);
2022 if (lio_dev->instr_queue[0])
2023 lio_free_instr_queue0(lio_dev);
2029 lio_eth_dev_uninit(struct rte_eth_dev *eth_dev)
2031 struct lio_device *lio_dev = LIO_DEV(eth_dev);
2033 PMD_INIT_FUNC_TRACE();
2035 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
2038 /* lio_free_sc_buffer_pool */
2039 lio_free_sc_buffer_pool(lio_dev);
2041 rte_free(eth_dev->data->mac_addrs);
2042 eth_dev->data->mac_addrs = NULL;
2044 eth_dev->dev_ops = NULL;
2045 eth_dev->rx_pkt_burst = NULL;
2046 eth_dev->tx_pkt_burst = NULL;
2052 lio_eth_dev_init(struct rte_eth_dev *eth_dev)
2054 struct rte_pci_device *pdev = RTE_ETH_DEV_TO_PCI(eth_dev);
2055 struct lio_device *lio_dev = LIO_DEV(eth_dev);
2057 PMD_INIT_FUNC_TRACE();
2059 eth_dev->rx_pkt_burst = &lio_dev_recv_pkts;
2060 eth_dev->tx_pkt_burst = &lio_dev_xmit_pkts;
2062 /* Primary does the initialization. */
2063 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
2066 rte_eth_copy_pci_info(eth_dev, pdev);
2068 if (pdev->mem_resource[0].addr) {
2069 lio_dev->hw_addr = pdev->mem_resource[0].addr;
2071 PMD_INIT_LOG(ERR, "ERROR: Failed to map BAR0\n");
2075 lio_dev->eth_dev = eth_dev;
2076 /* set lio device print string */
2077 snprintf(lio_dev->dev_string, sizeof(lio_dev->dev_string),
2078 "%s[%02x:%02x.%x]", pdev->driver->driver.name,
2079 pdev->addr.bus, pdev->addr.devid, pdev->addr.function);
2081 lio_dev->port_id = eth_dev->data->port_id;
2083 if (lio_first_time_init(lio_dev, pdev)) {
2084 lio_dev_err(lio_dev, "Device init failed\n");
2088 eth_dev->dev_ops = &liovf_eth_dev_ops;
2089 eth_dev->data->mac_addrs = rte_zmalloc("lio", ETHER_ADDR_LEN, 0);
2090 if (eth_dev->data->mac_addrs == NULL) {
2091 lio_dev_err(lio_dev,
2092 "MAC addresses memory allocation failed\n");
2093 eth_dev->dev_ops = NULL;
2094 eth_dev->rx_pkt_burst = NULL;
2095 eth_dev->tx_pkt_burst = NULL;
2099 rte_atomic64_set(&lio_dev->status, LIO_DEV_RUNNING);
2102 lio_dev->port_configured = 0;
2103 /* Always allow unicast packets */
2104 lio_dev->ifflags |= LIO_IFFLAG_UNICAST;
2110 lio_eth_dev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
2111 struct rte_pci_device *pci_dev)
2113 struct rte_eth_dev *eth_dev;
2116 eth_dev = rte_eth_dev_pci_allocate(pci_dev,
2117 sizeof(struct lio_device));
2118 if (eth_dev == NULL)
2121 ret = lio_eth_dev_init(eth_dev);
2123 rte_eth_dev_pci_release(eth_dev);
2129 lio_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
2131 return rte_eth_dev_pci_generic_remove(pci_dev,
2132 lio_eth_dev_uninit);
2135 /* Set of PCI devices this driver supports */
2136 static const struct rte_pci_id pci_id_liovf_map[] = {
2137 { RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_VF_VID) },
2138 { .vendor_id = 0, /* sentinel */ }
2141 static struct rte_pci_driver rte_liovf_pmd = {
2142 .id_table = pci_id_liovf_map,
2143 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
2144 .probe = lio_eth_dev_pci_probe,
2145 .remove = lio_eth_dev_pci_remove,
2148 RTE_PMD_REGISTER_PCI(net_liovf, rte_liovf_pmd);
2149 RTE_PMD_REGISTER_PCI_TABLE(net_liovf, pci_id_liovf_map);
2150 RTE_PMD_REGISTER_KMOD_DEP(net_liovf, "* igb_uio | vfio-pci");
2152 RTE_INIT(lio_init_log);
2156 lio_logtype_init = rte_log_register("pmd.net.liquidio.init");
2157 if (lio_logtype_init >= 0)
2158 rte_log_set_level(lio_logtype_init, RTE_LOG_NOTICE);
2159 lio_logtype_driver = rte_log_register("pmd.net.liquidio.driver");
2160 if (lio_logtype_driver >= 0)
2161 rte_log_set_level(lio_logtype_driver, RTE_LOG_NOTICE);