1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Cavium, Inc
5 #include <rte_string_fns.h>
6 #include <ethdev_driver.h>
7 #include <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"
18 /* Default RSS key in use */
19 static uint8_t lio_rss_key[40] = {
20 0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2,
21 0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0,
22 0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4,
23 0x77, 0xCB, 0x2D, 0xA3, 0x80, 0x30, 0xF2, 0x0C,
24 0x6A, 0x42, 0xB7, 0x3B, 0xBE, 0xAC, 0x01, 0xFA,
27 static const struct rte_eth_desc_lim lio_rx_desc_lim = {
28 .nb_max = CN23XX_MAX_OQ_DESCRIPTORS,
29 .nb_min = CN23XX_MIN_OQ_DESCRIPTORS,
33 static const struct rte_eth_desc_lim lio_tx_desc_lim = {
34 .nb_max = CN23XX_MAX_IQ_DESCRIPTORS,
35 .nb_min = CN23XX_MIN_IQ_DESCRIPTORS,
39 /* Wait for control command to reach nic. */
41 lio_wait_for_ctrl_cmd(struct lio_device *lio_dev,
42 struct lio_dev_ctrl_cmd *ctrl_cmd)
44 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
46 while ((ctrl_cmd->cond == 0) && --timeout) {
47 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
55 * \brief Send Rx control command
56 * @param eth_dev Pointer to the structure rte_eth_dev
57 * @param start_stop whether to start or stop
60 lio_send_rx_ctrl_cmd(struct rte_eth_dev *eth_dev, int start_stop)
62 struct lio_device *lio_dev = LIO_DEV(eth_dev);
63 struct lio_dev_ctrl_cmd ctrl_cmd;
64 struct lio_ctrl_pkt ctrl_pkt;
66 /* flush added to prevent cmd failure
67 * incase the queue is full
69 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
71 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
72 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
74 ctrl_cmd.eth_dev = eth_dev;
77 ctrl_pkt.ncmd.s.cmd = LIO_CMD_RX_CTL;
78 ctrl_pkt.ncmd.s.param1 = start_stop;
79 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
81 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
82 lio_dev_err(lio_dev, "Failed to send RX Control message\n");
86 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
87 lio_dev_err(lio_dev, "RX Control command timed out\n");
94 /* store statistics names and its offset in stats structure */
95 struct rte_lio_xstats_name_off {
96 char name[RTE_ETH_XSTATS_NAME_SIZE];
100 static const struct rte_lio_xstats_name_off rte_lio_stats_strings[] = {
101 {"rx_pkts", offsetof(struct octeon_rx_stats, total_rcvd)},
102 {"rx_bytes", offsetof(struct octeon_rx_stats, bytes_rcvd)},
103 {"rx_broadcast_pkts", offsetof(struct octeon_rx_stats, total_bcst)},
104 {"rx_multicast_pkts", offsetof(struct octeon_rx_stats, total_mcst)},
105 {"rx_flow_ctrl_pkts", offsetof(struct octeon_rx_stats, ctl_rcvd)},
106 {"rx_fifo_err", offsetof(struct octeon_rx_stats, fifo_err)},
107 {"rx_dmac_drop", offsetof(struct octeon_rx_stats, dmac_drop)},
108 {"rx_fcs_err", offsetof(struct octeon_rx_stats, fcs_err)},
109 {"rx_jabber_err", offsetof(struct octeon_rx_stats, jabber_err)},
110 {"rx_l2_err", offsetof(struct octeon_rx_stats, l2_err)},
111 {"rx_vxlan_pkts", offsetof(struct octeon_rx_stats, fw_rx_vxlan)},
112 {"rx_vxlan_err", offsetof(struct octeon_rx_stats, fw_rx_vxlan_err)},
113 {"rx_lro_pkts", offsetof(struct octeon_rx_stats, fw_lro_pkts)},
114 {"tx_pkts", (offsetof(struct octeon_tx_stats, total_pkts_sent)) +
115 sizeof(struct octeon_rx_stats)},
116 {"tx_bytes", (offsetof(struct octeon_tx_stats, total_bytes_sent)) +
117 sizeof(struct octeon_rx_stats)},
118 {"tx_broadcast_pkts",
119 (offsetof(struct octeon_tx_stats, bcast_pkts_sent)) +
120 sizeof(struct octeon_rx_stats)},
121 {"tx_multicast_pkts",
122 (offsetof(struct octeon_tx_stats, mcast_pkts_sent)) +
123 sizeof(struct octeon_rx_stats)},
124 {"tx_flow_ctrl_pkts", (offsetof(struct octeon_tx_stats, ctl_sent)) +
125 sizeof(struct octeon_rx_stats)},
126 {"tx_fifo_err", (offsetof(struct octeon_tx_stats, fifo_err)) +
127 sizeof(struct octeon_rx_stats)},
128 {"tx_total_collisions", (offsetof(struct octeon_tx_stats,
130 sizeof(struct octeon_rx_stats)},
131 {"tx_tso", (offsetof(struct octeon_tx_stats, fw_tso)) +
132 sizeof(struct octeon_rx_stats)},
133 {"tx_vxlan_pkts", (offsetof(struct octeon_tx_stats, fw_tx_vxlan)) +
134 sizeof(struct octeon_rx_stats)},
137 #define LIO_NB_XSTATS RTE_DIM(rte_lio_stats_strings)
139 /* Get hw stats of the port */
141 lio_dev_xstats_get(struct rte_eth_dev *eth_dev, struct rte_eth_xstat *xstats,
144 struct lio_device *lio_dev = LIO_DEV(eth_dev);
145 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
146 struct octeon_link_stats *hw_stats;
147 struct lio_link_stats_resp *resp;
148 struct lio_soft_command *sc;
153 if (!lio_dev->intf_open) {
154 lio_dev_err(lio_dev, "Port %d down\n",
159 if (n < LIO_NB_XSTATS)
160 return LIO_NB_XSTATS;
162 resp_size = sizeof(struct lio_link_stats_resp);
163 sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
167 resp = (struct lio_link_stats_resp *)sc->virtrptr;
168 lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
169 LIO_OPCODE_PORT_STATS, 0, 0, 0);
171 /* Setting wait time in seconds */
172 sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
174 retval = lio_send_soft_command(lio_dev, sc);
175 if (retval == LIO_IQ_SEND_FAILED) {
176 lio_dev_err(lio_dev, "failed to get port stats from firmware. status: %x\n",
181 while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
182 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
183 lio_process_ordered_list(lio_dev);
187 retval = resp->status;
189 lio_dev_err(lio_dev, "failed to get port stats from firmware\n");
193 lio_swap_8B_data((uint64_t *)(&resp->link_stats),
194 sizeof(struct octeon_link_stats) >> 3);
196 hw_stats = &resp->link_stats;
198 for (i = 0; i < LIO_NB_XSTATS; i++) {
201 *(uint64_t *)(((char *)hw_stats) +
202 rte_lio_stats_strings[i].offset);
205 lio_free_soft_command(sc);
207 return LIO_NB_XSTATS;
210 lio_free_soft_command(sc);
216 lio_dev_xstats_get_names(struct rte_eth_dev *eth_dev,
217 struct rte_eth_xstat_name *xstats_names,
218 unsigned limit __rte_unused)
220 struct lio_device *lio_dev = LIO_DEV(eth_dev);
223 if (!lio_dev->intf_open) {
224 lio_dev_err(lio_dev, "Port %d down\n",
229 if (xstats_names == NULL)
230 return LIO_NB_XSTATS;
232 /* Note: limit checked in rte_eth_xstats_names() */
234 for (i = 0; i < LIO_NB_XSTATS; i++) {
235 snprintf(xstats_names[i].name, sizeof(xstats_names[i].name),
236 "%s", rte_lio_stats_strings[i].name);
239 return LIO_NB_XSTATS;
242 /* Reset hw stats for the port */
244 lio_dev_xstats_reset(struct rte_eth_dev *eth_dev)
246 struct lio_device *lio_dev = LIO_DEV(eth_dev);
247 struct lio_dev_ctrl_cmd ctrl_cmd;
248 struct lio_ctrl_pkt ctrl_pkt;
251 if (!lio_dev->intf_open) {
252 lio_dev_err(lio_dev, "Port %d down\n",
257 /* flush added to prevent cmd failure
258 * incase the queue is full
260 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
262 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
263 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
265 ctrl_cmd.eth_dev = eth_dev;
268 ctrl_pkt.ncmd.s.cmd = LIO_CMD_CLEAR_STATS;
269 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
271 ret = lio_send_ctrl_pkt(lio_dev, &ctrl_pkt);
273 lio_dev_err(lio_dev, "Failed to send clear stats command\n");
277 ret = lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd);
279 lio_dev_err(lio_dev, "Clear stats command timed out\n");
283 /* clear stored per queue stats */
284 RTE_FUNC_PTR_OR_ERR_RET(*eth_dev->dev_ops->stats_reset, 0);
285 return (*eth_dev->dev_ops->stats_reset)(eth_dev);
288 /* Retrieve the device statistics (# packets in/out, # bytes in/out, etc */
290 lio_dev_stats_get(struct rte_eth_dev *eth_dev,
291 struct rte_eth_stats *stats)
293 struct lio_device *lio_dev = LIO_DEV(eth_dev);
294 struct lio_droq_stats *oq_stats;
295 struct lio_iq_stats *iq_stats;
296 struct lio_instr_queue *txq;
297 struct lio_droq *droq;
303 for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
304 iq_no = lio_dev->linfo.txpciq[i].s.q_no;
305 txq = lio_dev->instr_queue[iq_no];
307 iq_stats = &txq->stats;
308 pkts += iq_stats->tx_done;
309 drop += iq_stats->tx_dropped;
310 bytes += iq_stats->tx_tot_bytes;
314 stats->opackets = pkts;
315 stats->obytes = bytes;
316 stats->oerrors = drop;
322 for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
323 oq_no = lio_dev->linfo.rxpciq[i].s.q_no;
324 droq = lio_dev->droq[oq_no];
326 oq_stats = &droq->stats;
327 pkts += oq_stats->rx_pkts_received;
328 drop += (oq_stats->rx_dropped +
329 oq_stats->dropped_toomany +
330 oq_stats->dropped_nomem);
331 bytes += oq_stats->rx_bytes_received;
334 stats->ibytes = bytes;
335 stats->ipackets = pkts;
336 stats->ierrors = drop;
342 lio_dev_stats_reset(struct rte_eth_dev *eth_dev)
344 struct lio_device *lio_dev = LIO_DEV(eth_dev);
345 struct lio_droq_stats *oq_stats;
346 struct lio_iq_stats *iq_stats;
347 struct lio_instr_queue *txq;
348 struct lio_droq *droq;
351 for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
352 iq_no = lio_dev->linfo.txpciq[i].s.q_no;
353 txq = lio_dev->instr_queue[iq_no];
355 iq_stats = &txq->stats;
356 memset(iq_stats, 0, sizeof(struct lio_iq_stats));
360 for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
361 oq_no = lio_dev->linfo.rxpciq[i].s.q_no;
362 droq = lio_dev->droq[oq_no];
364 oq_stats = &droq->stats;
365 memset(oq_stats, 0, sizeof(struct lio_droq_stats));
373 lio_dev_info_get(struct rte_eth_dev *eth_dev,
374 struct rte_eth_dev_info *devinfo)
376 struct lio_device *lio_dev = LIO_DEV(eth_dev);
377 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
379 switch (pci_dev->id.subsystem_device_id) {
380 /* CN23xx 10G cards */
381 case PCI_SUBSYS_DEV_ID_CN2350_210:
382 case PCI_SUBSYS_DEV_ID_CN2360_210:
383 case PCI_SUBSYS_DEV_ID_CN2350_210SVPN3:
384 case PCI_SUBSYS_DEV_ID_CN2360_210SVPN3:
385 case PCI_SUBSYS_DEV_ID_CN2350_210SVPT:
386 case PCI_SUBSYS_DEV_ID_CN2360_210SVPT:
387 devinfo->speed_capa = ETH_LINK_SPEED_10G;
389 /* CN23xx 25G cards */
390 case PCI_SUBSYS_DEV_ID_CN2350_225:
391 case PCI_SUBSYS_DEV_ID_CN2360_225:
392 devinfo->speed_capa = ETH_LINK_SPEED_25G;
395 devinfo->speed_capa = ETH_LINK_SPEED_10G;
397 "Unknown CN23XX subsystem device id. Setting 10G as default link speed.\n");
401 devinfo->max_rx_queues = lio_dev->max_rx_queues;
402 devinfo->max_tx_queues = lio_dev->max_tx_queues;
404 devinfo->min_rx_bufsize = LIO_MIN_RX_BUF_SIZE;
405 devinfo->max_rx_pktlen = LIO_MAX_RX_PKTLEN;
407 devinfo->max_mac_addrs = 1;
409 devinfo->rx_offload_capa = (DEV_RX_OFFLOAD_IPV4_CKSUM |
410 DEV_RX_OFFLOAD_UDP_CKSUM |
411 DEV_RX_OFFLOAD_TCP_CKSUM |
412 DEV_RX_OFFLOAD_VLAN_STRIP |
413 DEV_RX_OFFLOAD_RSS_HASH);
414 devinfo->tx_offload_capa = (DEV_TX_OFFLOAD_IPV4_CKSUM |
415 DEV_TX_OFFLOAD_UDP_CKSUM |
416 DEV_TX_OFFLOAD_TCP_CKSUM |
417 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM);
419 devinfo->rx_desc_lim = lio_rx_desc_lim;
420 devinfo->tx_desc_lim = lio_tx_desc_lim;
422 devinfo->reta_size = LIO_RSS_MAX_TABLE_SZ;
423 devinfo->hash_key_size = LIO_RSS_MAX_KEY_SZ;
424 devinfo->flow_type_rss_offloads = (ETH_RSS_IPV4 |
425 ETH_RSS_NONFRAG_IPV4_TCP |
427 ETH_RSS_NONFRAG_IPV6_TCP |
429 ETH_RSS_IPV6_TCP_EX);
434 lio_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu)
436 struct lio_device *lio_dev = LIO_DEV(eth_dev);
437 uint16_t pf_mtu = lio_dev->linfo.link.s.mtu;
438 uint32_t frame_len = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
439 struct lio_dev_ctrl_cmd ctrl_cmd;
440 struct lio_ctrl_pkt ctrl_pkt;
442 PMD_INIT_FUNC_TRACE();
444 if (!lio_dev->intf_open) {
445 lio_dev_err(lio_dev, "Port %d down, can't set MTU\n",
450 /* check if VF MTU is within allowed range.
451 * New value should not exceed PF MTU.
453 if (mtu < RTE_ETHER_MIN_MTU || mtu > pf_mtu) {
454 lio_dev_err(lio_dev, "VF MTU should be >= %d and <= %d\n",
455 RTE_ETHER_MIN_MTU, pf_mtu);
459 /* flush added to prevent cmd failure
460 * incase the queue is full
462 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
464 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
465 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
467 ctrl_cmd.eth_dev = eth_dev;
470 ctrl_pkt.ncmd.s.cmd = LIO_CMD_CHANGE_MTU;
471 ctrl_pkt.ncmd.s.param1 = mtu;
472 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
474 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
475 lio_dev_err(lio_dev, "Failed to send command to change MTU\n");
479 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
480 lio_dev_err(lio_dev, "Command to change MTU timed out\n");
484 if (frame_len > LIO_ETH_MAX_LEN)
485 eth_dev->data->dev_conf.rxmode.offloads |=
486 DEV_RX_OFFLOAD_JUMBO_FRAME;
488 eth_dev->data->dev_conf.rxmode.offloads &=
489 ~DEV_RX_OFFLOAD_JUMBO_FRAME;
491 eth_dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_len;
492 eth_dev->data->mtu = mtu;
498 lio_dev_rss_reta_update(struct rte_eth_dev *eth_dev,
499 struct rte_eth_rss_reta_entry64 *reta_conf,
502 struct lio_device *lio_dev = LIO_DEV(eth_dev);
503 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
504 struct lio_rss_set *rss_param;
505 struct lio_dev_ctrl_cmd ctrl_cmd;
506 struct lio_ctrl_pkt ctrl_pkt;
509 if (!lio_dev->intf_open) {
510 lio_dev_err(lio_dev, "Port %d down, can't update reta\n",
515 if (reta_size != LIO_RSS_MAX_TABLE_SZ) {
517 "The size of hash lookup table configured (%d) doesn't match the number hardware can supported (%d)\n",
518 reta_size, LIO_RSS_MAX_TABLE_SZ);
522 /* flush added to prevent cmd failure
523 * incase the queue is full
525 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
527 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
528 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
530 rss_param = (struct lio_rss_set *)&ctrl_pkt.udd[0];
532 ctrl_cmd.eth_dev = eth_dev;
535 ctrl_pkt.ncmd.s.cmd = LIO_CMD_SET_RSS;
536 ctrl_pkt.ncmd.s.more = sizeof(struct lio_rss_set) >> 3;
537 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
539 rss_param->param.flags = 0xF;
540 rss_param->param.flags &= ~LIO_RSS_PARAM_ITABLE_UNCHANGED;
541 rss_param->param.itablesize = LIO_RSS_MAX_TABLE_SZ;
543 for (i = 0; i < (reta_size / RTE_RETA_GROUP_SIZE); i++) {
544 for (j = 0; j < RTE_RETA_GROUP_SIZE; j++) {
545 if ((reta_conf[i].mask) & ((uint64_t)1 << j)) {
546 index = (i * RTE_RETA_GROUP_SIZE) + j;
547 rss_state->itable[index] = reta_conf[i].reta[j];
552 rss_state->itable_size = LIO_RSS_MAX_TABLE_SZ;
553 memcpy(rss_param->itable, rss_state->itable, rss_state->itable_size);
555 lio_swap_8B_data((uint64_t *)rss_param, LIO_RSS_PARAM_SIZE >> 3);
557 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
558 lio_dev_err(lio_dev, "Failed to set rss hash\n");
562 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
563 lio_dev_err(lio_dev, "Set rss hash timed out\n");
571 lio_dev_rss_reta_query(struct rte_eth_dev *eth_dev,
572 struct rte_eth_rss_reta_entry64 *reta_conf,
575 struct lio_device *lio_dev = LIO_DEV(eth_dev);
576 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
579 if (reta_size != LIO_RSS_MAX_TABLE_SZ) {
581 "The size of hash lookup table configured (%d) doesn't match the number hardware can supported (%d)\n",
582 reta_size, LIO_RSS_MAX_TABLE_SZ);
586 num = reta_size / RTE_RETA_GROUP_SIZE;
588 for (i = 0; i < num; i++) {
589 memcpy(reta_conf->reta,
590 &rss_state->itable[i * RTE_RETA_GROUP_SIZE],
591 RTE_RETA_GROUP_SIZE);
599 lio_dev_rss_hash_conf_get(struct rte_eth_dev *eth_dev,
600 struct rte_eth_rss_conf *rss_conf)
602 struct lio_device *lio_dev = LIO_DEV(eth_dev);
603 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
604 uint8_t *hash_key = NULL;
607 if (rss_state->hash_disable) {
608 lio_dev_info(lio_dev, "RSS disabled in nic\n");
609 rss_conf->rss_hf = 0;
614 hash_key = rss_conf->rss_key;
615 if (hash_key != NULL)
616 memcpy(hash_key, rss_state->hash_key, rss_state->hash_key_size);
619 rss_hf |= ETH_RSS_IPV4;
620 if (rss_state->tcp_hash)
621 rss_hf |= ETH_RSS_NONFRAG_IPV4_TCP;
623 rss_hf |= ETH_RSS_IPV6;
624 if (rss_state->ipv6_tcp_hash)
625 rss_hf |= ETH_RSS_NONFRAG_IPV6_TCP;
626 if (rss_state->ipv6_ex)
627 rss_hf |= ETH_RSS_IPV6_EX;
628 if (rss_state->ipv6_tcp_ex_hash)
629 rss_hf |= ETH_RSS_IPV6_TCP_EX;
631 rss_conf->rss_hf = rss_hf;
637 lio_dev_rss_hash_update(struct rte_eth_dev *eth_dev,
638 struct rte_eth_rss_conf *rss_conf)
640 struct lio_device *lio_dev = LIO_DEV(eth_dev);
641 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
642 struct lio_rss_set *rss_param;
643 struct lio_dev_ctrl_cmd ctrl_cmd;
644 struct lio_ctrl_pkt ctrl_pkt;
646 if (!lio_dev->intf_open) {
647 lio_dev_err(lio_dev, "Port %d down, can't update hash\n",
652 /* flush added to prevent cmd failure
653 * incase the queue is full
655 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
657 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
658 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
660 rss_param = (struct lio_rss_set *)&ctrl_pkt.udd[0];
662 ctrl_cmd.eth_dev = eth_dev;
665 ctrl_pkt.ncmd.s.cmd = LIO_CMD_SET_RSS;
666 ctrl_pkt.ncmd.s.more = sizeof(struct lio_rss_set) >> 3;
667 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
669 rss_param->param.flags = 0xF;
671 if (rss_conf->rss_key) {
672 rss_param->param.flags &= ~LIO_RSS_PARAM_HASH_KEY_UNCHANGED;
673 rss_state->hash_key_size = LIO_RSS_MAX_KEY_SZ;
674 rss_param->param.hashkeysize = LIO_RSS_MAX_KEY_SZ;
675 memcpy(rss_state->hash_key, rss_conf->rss_key,
676 rss_state->hash_key_size);
677 memcpy(rss_param->key, rss_state->hash_key,
678 rss_state->hash_key_size);
681 if ((rss_conf->rss_hf & LIO_RSS_OFFLOAD_ALL) == 0) {
682 /* Can't disable rss through hash flags,
683 * if it is enabled by default during init
685 if (!rss_state->hash_disable)
688 /* This is for --disable-rss during testpmd launch */
689 rss_param->param.flags |= LIO_RSS_PARAM_DISABLE_RSS;
691 uint32_t hashinfo = 0;
693 /* Can't enable rss if disabled by default during init */
694 if (rss_state->hash_disable)
697 if (rss_conf->rss_hf & ETH_RSS_IPV4) {
698 hashinfo |= LIO_RSS_HASH_IPV4;
704 if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV4_TCP) {
705 hashinfo |= LIO_RSS_HASH_TCP_IPV4;
706 rss_state->tcp_hash = 1;
708 rss_state->tcp_hash = 0;
711 if (rss_conf->rss_hf & ETH_RSS_IPV6) {
712 hashinfo |= LIO_RSS_HASH_IPV6;
718 if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV6_TCP) {
719 hashinfo |= LIO_RSS_HASH_TCP_IPV6;
720 rss_state->ipv6_tcp_hash = 1;
722 rss_state->ipv6_tcp_hash = 0;
725 if (rss_conf->rss_hf & ETH_RSS_IPV6_EX) {
726 hashinfo |= LIO_RSS_HASH_IPV6_EX;
727 rss_state->ipv6_ex = 1;
729 rss_state->ipv6_ex = 0;
732 if (rss_conf->rss_hf & ETH_RSS_IPV6_TCP_EX) {
733 hashinfo |= LIO_RSS_HASH_TCP_IPV6_EX;
734 rss_state->ipv6_tcp_ex_hash = 1;
736 rss_state->ipv6_tcp_ex_hash = 0;
739 rss_param->param.flags &= ~LIO_RSS_PARAM_HASH_INFO_UNCHANGED;
740 rss_param->param.hashinfo = hashinfo;
743 lio_swap_8B_data((uint64_t *)rss_param, LIO_RSS_PARAM_SIZE >> 3);
745 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
746 lio_dev_err(lio_dev, "Failed to set rss hash\n");
750 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
751 lio_dev_err(lio_dev, "Set rss hash timed out\n");
759 * Add vxlan dest udp port for an interface.
762 * Pointer to the structure rte_eth_dev
767 * On success return 0
768 * On failure return -1
771 lio_dev_udp_tunnel_add(struct rte_eth_dev *eth_dev,
772 struct rte_eth_udp_tunnel *udp_tnl)
774 struct lio_device *lio_dev = LIO_DEV(eth_dev);
775 struct lio_dev_ctrl_cmd ctrl_cmd;
776 struct lio_ctrl_pkt ctrl_pkt;
781 if (udp_tnl->prot_type != RTE_TUNNEL_TYPE_VXLAN) {
782 lio_dev_err(lio_dev, "Unsupported tunnel type\n");
786 /* flush added to prevent cmd failure
787 * incase the queue is full
789 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
791 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
792 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
794 ctrl_cmd.eth_dev = eth_dev;
797 ctrl_pkt.ncmd.s.cmd = LIO_CMD_VXLAN_PORT_CONFIG;
798 ctrl_pkt.ncmd.s.param1 = udp_tnl->udp_port;
799 ctrl_pkt.ncmd.s.more = LIO_CMD_VXLAN_PORT_ADD;
800 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
802 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
803 lio_dev_err(lio_dev, "Failed to send VXLAN_PORT_ADD command\n");
807 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
808 lio_dev_err(lio_dev, "VXLAN_PORT_ADD command timed out\n");
816 * Remove vxlan dest udp port for an interface.
819 * Pointer to the structure rte_eth_dev
824 * On success return 0
825 * On failure return -1
828 lio_dev_udp_tunnel_del(struct rte_eth_dev *eth_dev,
829 struct rte_eth_udp_tunnel *udp_tnl)
831 struct lio_device *lio_dev = LIO_DEV(eth_dev);
832 struct lio_dev_ctrl_cmd ctrl_cmd;
833 struct lio_ctrl_pkt ctrl_pkt;
838 if (udp_tnl->prot_type != RTE_TUNNEL_TYPE_VXLAN) {
839 lio_dev_err(lio_dev, "Unsupported tunnel type\n");
843 /* flush added to prevent cmd failure
844 * incase the queue is full
846 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
848 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
849 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
851 ctrl_cmd.eth_dev = eth_dev;
854 ctrl_pkt.ncmd.s.cmd = LIO_CMD_VXLAN_PORT_CONFIG;
855 ctrl_pkt.ncmd.s.param1 = udp_tnl->udp_port;
856 ctrl_pkt.ncmd.s.more = LIO_CMD_VXLAN_PORT_DEL;
857 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
859 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
860 lio_dev_err(lio_dev, "Failed to send VXLAN_PORT_DEL command\n");
864 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
865 lio_dev_err(lio_dev, "VXLAN_PORT_DEL command timed out\n");
873 lio_dev_vlan_filter_set(struct rte_eth_dev *eth_dev, uint16_t vlan_id, int on)
875 struct lio_device *lio_dev = LIO_DEV(eth_dev);
876 struct lio_dev_ctrl_cmd ctrl_cmd;
877 struct lio_ctrl_pkt ctrl_pkt;
879 if (lio_dev->linfo.vlan_is_admin_assigned)
882 /* flush added to prevent cmd failure
883 * incase the queue is full
885 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
887 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
888 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
890 ctrl_cmd.eth_dev = eth_dev;
893 ctrl_pkt.ncmd.s.cmd = on ?
894 LIO_CMD_ADD_VLAN_FILTER : LIO_CMD_DEL_VLAN_FILTER;
895 ctrl_pkt.ncmd.s.param1 = vlan_id;
896 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
898 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
899 lio_dev_err(lio_dev, "Failed to %s VLAN port\n",
900 on ? "add" : "remove");
904 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
905 lio_dev_err(lio_dev, "Command to %s VLAN port timed out\n",
906 on ? "add" : "remove");
914 lio_hweight64(uint64_t w)
916 uint64_t res = w - ((w >> 1) & 0x5555555555555555ul);
919 (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul);
920 res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful;
921 res = res + (res >> 8);
922 res = res + (res >> 16);
924 return (res + (res >> 32)) & 0x00000000000000FFul;
928 lio_dev_link_update(struct rte_eth_dev *eth_dev,
929 int wait_to_complete __rte_unused)
931 struct lio_device *lio_dev = LIO_DEV(eth_dev);
932 struct rte_eth_link link;
935 memset(&link, 0, sizeof(link));
936 link.link_status = ETH_LINK_DOWN;
937 link.link_speed = ETH_SPEED_NUM_NONE;
938 link.link_duplex = ETH_LINK_HALF_DUPLEX;
939 link.link_autoneg = ETH_LINK_AUTONEG;
941 /* Return what we found */
942 if (lio_dev->linfo.link.s.link_up == 0) {
943 /* Interface is down */
944 return rte_eth_linkstatus_set(eth_dev, &link);
947 link.link_status = ETH_LINK_UP; /* Interface is up */
948 link.link_duplex = ETH_LINK_FULL_DUPLEX;
949 switch (lio_dev->linfo.link.s.speed) {
950 case LIO_LINK_SPEED_10000:
951 link.link_speed = ETH_SPEED_NUM_10G;
953 case LIO_LINK_SPEED_25000:
954 link.link_speed = ETH_SPEED_NUM_25G;
957 link.link_speed = ETH_SPEED_NUM_NONE;
958 link.link_duplex = ETH_LINK_HALF_DUPLEX;
961 return rte_eth_linkstatus_set(eth_dev, &link);
965 * \brief Net device enable, disable allmulticast
966 * @param eth_dev Pointer to the structure rte_eth_dev
969 * On success return 0
970 * On failure return negative errno
973 lio_change_dev_flag(struct rte_eth_dev *eth_dev)
975 struct lio_device *lio_dev = LIO_DEV(eth_dev);
976 struct lio_dev_ctrl_cmd ctrl_cmd;
977 struct lio_ctrl_pkt ctrl_pkt;
979 /* flush added to prevent cmd failure
980 * incase the queue is full
982 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
984 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
985 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
987 ctrl_cmd.eth_dev = eth_dev;
990 /* Create a ctrl pkt command to be sent to core app. */
991 ctrl_pkt.ncmd.s.cmd = LIO_CMD_CHANGE_DEVFLAGS;
992 ctrl_pkt.ncmd.s.param1 = lio_dev->ifflags;
993 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
995 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
996 lio_dev_err(lio_dev, "Failed to send change flag message\n");
1000 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
1001 lio_dev_err(lio_dev, "Change dev flag command timed out\n");
1009 lio_dev_promiscuous_enable(struct rte_eth_dev *eth_dev)
1011 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1013 if (strcmp(lio_dev->firmware_version, LIO_VF_TRUST_MIN_VERSION) < 0) {
1014 lio_dev_err(lio_dev, "Require firmware version >= %s\n",
1015 LIO_VF_TRUST_MIN_VERSION);
1019 if (!lio_dev->intf_open) {
1020 lio_dev_err(lio_dev, "Port %d down, can't enable promiscuous\n",
1025 lio_dev->ifflags |= LIO_IFFLAG_PROMISC;
1026 return lio_change_dev_flag(eth_dev);
1030 lio_dev_promiscuous_disable(struct rte_eth_dev *eth_dev)
1032 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1034 if (strcmp(lio_dev->firmware_version, LIO_VF_TRUST_MIN_VERSION) < 0) {
1035 lio_dev_err(lio_dev, "Require firmware version >= %s\n",
1036 LIO_VF_TRUST_MIN_VERSION);
1040 if (!lio_dev->intf_open) {
1041 lio_dev_err(lio_dev, "Port %d down, can't disable promiscuous\n",
1046 lio_dev->ifflags &= ~LIO_IFFLAG_PROMISC;
1047 return lio_change_dev_flag(eth_dev);
1051 lio_dev_allmulticast_enable(struct rte_eth_dev *eth_dev)
1053 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1055 if (!lio_dev->intf_open) {
1056 lio_dev_err(lio_dev, "Port %d down, can't enable multicast\n",
1061 lio_dev->ifflags |= LIO_IFFLAG_ALLMULTI;
1062 return lio_change_dev_flag(eth_dev);
1066 lio_dev_allmulticast_disable(struct rte_eth_dev *eth_dev)
1068 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1070 if (!lio_dev->intf_open) {
1071 lio_dev_err(lio_dev, "Port %d down, can't disable multicast\n",
1076 lio_dev->ifflags &= ~LIO_IFFLAG_ALLMULTI;
1077 return lio_change_dev_flag(eth_dev);
1081 lio_dev_rss_configure(struct rte_eth_dev *eth_dev)
1083 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1084 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
1085 struct rte_eth_rss_reta_entry64 reta_conf[8];
1086 struct rte_eth_rss_conf rss_conf;
1089 /* Configure the RSS key and the RSS protocols used to compute
1090 * the RSS hash of input packets.
1092 rss_conf = eth_dev->data->dev_conf.rx_adv_conf.rss_conf;
1093 if ((rss_conf.rss_hf & LIO_RSS_OFFLOAD_ALL) == 0) {
1094 rss_state->hash_disable = 1;
1095 lio_dev_rss_hash_update(eth_dev, &rss_conf);
1099 if (rss_conf.rss_key == NULL)
1100 rss_conf.rss_key = lio_rss_key; /* Default hash key */
1102 lio_dev_rss_hash_update(eth_dev, &rss_conf);
1104 memset(reta_conf, 0, sizeof(reta_conf));
1105 for (i = 0; i < LIO_RSS_MAX_TABLE_SZ; i++) {
1106 uint8_t q_idx, conf_idx, reta_idx;
1108 q_idx = (uint8_t)((eth_dev->data->nb_rx_queues > 1) ?
1109 i % eth_dev->data->nb_rx_queues : 0);
1110 conf_idx = i / RTE_RETA_GROUP_SIZE;
1111 reta_idx = i % RTE_RETA_GROUP_SIZE;
1112 reta_conf[conf_idx].reta[reta_idx] = q_idx;
1113 reta_conf[conf_idx].mask |= ((uint64_t)1 << reta_idx);
1116 lio_dev_rss_reta_update(eth_dev, reta_conf, LIO_RSS_MAX_TABLE_SZ);
1120 lio_dev_mq_rx_configure(struct rte_eth_dev *eth_dev)
1122 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1123 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
1124 struct rte_eth_rss_conf rss_conf;
1126 switch (eth_dev->data->dev_conf.rxmode.mq_mode) {
1128 lio_dev_rss_configure(eth_dev);
1130 case ETH_MQ_RX_NONE:
1131 /* if mq_mode is none, disable rss mode. */
1133 memset(&rss_conf, 0, sizeof(rss_conf));
1134 rss_state->hash_disable = 1;
1135 lio_dev_rss_hash_update(eth_dev, &rss_conf);
1140 * Setup our receive queue/ringbuffer. This is the
1141 * queue the Octeon uses to send us packets and
1142 * responses. We are given a memory pool for our
1143 * packet buffers that are used to populate the receive
1147 * Pointer to the structure rte_eth_dev
1150 * @param num_rx_descs
1151 * Number of entries in the queue
1153 * Where to allocate memory
1155 * Pointer to the struction rte_eth_rxconf
1157 * Pointer to the packet pool
1160 * - On success, return 0
1161 * - On failure, return -1
1164 lio_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t q_no,
1165 uint16_t num_rx_descs, unsigned int socket_id,
1166 const struct rte_eth_rxconf *rx_conf __rte_unused,
1167 struct rte_mempool *mp)
1169 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1170 struct rte_pktmbuf_pool_private *mbp_priv;
1171 uint32_t fw_mapped_oq;
1174 if (q_no >= lio_dev->nb_rx_queues) {
1175 lio_dev_err(lio_dev, "Invalid rx queue number %u\n", q_no);
1179 lio_dev_dbg(lio_dev, "setting up rx queue %u\n", q_no);
1181 fw_mapped_oq = lio_dev->linfo.rxpciq[q_no].s.q_no;
1183 /* Free previous allocation if any */
1184 if (eth_dev->data->rx_queues[q_no] != NULL) {
1185 lio_dev_rx_queue_release(eth_dev, q_no);
1186 eth_dev->data->rx_queues[q_no] = NULL;
1189 mbp_priv = rte_mempool_get_priv(mp);
1190 buf_size = mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM;
1192 if (lio_setup_droq(lio_dev, fw_mapped_oq, num_rx_descs, buf_size, mp,
1194 lio_dev_err(lio_dev, "droq allocation failed\n");
1198 eth_dev->data->rx_queues[q_no] = lio_dev->droq[fw_mapped_oq];
1204 * Release the receive queue/ringbuffer. Called by
1208 * Pointer to Ethernet device structure.
1210 * Receive queue index.
1216 lio_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t q_no)
1218 struct lio_droq *droq = dev->data->rx_queues[q_no];
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, 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 * Pointer to Ethernet device structure.
1300 * Transmit queue index.
1306 lio_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t q_no)
1308 struct lio_instr_queue *tq = dev->data->tx_queues[q_no];
1309 uint32_t fw_mapped_iq_no;
1314 lio_delete_sglist(tq);
1316 fw_mapped_iq_no = tq->txpciq.s.q_no;
1317 lio_delete_instruction_queue(tq->lio_dev, fw_mapped_iq_no);
1322 * Api to check link state.
1325 lio_dev_get_link_status(struct rte_eth_dev *eth_dev)
1327 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1328 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1329 struct lio_link_status_resp *resp;
1330 union octeon_link_status *ls;
1331 struct lio_soft_command *sc;
1334 if (!lio_dev->intf_open)
1337 resp_size = sizeof(struct lio_link_status_resp);
1338 sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
1342 resp = (struct lio_link_status_resp *)sc->virtrptr;
1343 lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
1344 LIO_OPCODE_INFO, 0, 0, 0);
1346 /* Setting wait time in seconds */
1347 sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
1349 if (lio_send_soft_command(lio_dev, sc) == LIO_IQ_SEND_FAILED)
1350 goto get_status_fail;
1352 while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
1353 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
1358 goto get_status_fail;
1360 ls = &resp->link_info.link;
1362 lio_swap_8B_data((uint64_t *)ls, sizeof(union octeon_link_status) >> 3);
1364 if (lio_dev->linfo.link.link_status64 != ls->link_status64) {
1365 if (ls->s.mtu < eth_dev->data->mtu) {
1366 lio_dev_info(lio_dev, "Lowered VF MTU to %d as PF MTU dropped\n",
1368 eth_dev->data->mtu = ls->s.mtu;
1370 lio_dev->linfo.link.link_status64 = ls->link_status64;
1371 lio_dev_link_update(eth_dev, 0);
1374 lio_free_soft_command(sc);
1379 lio_free_soft_command(sc);
1382 /* This function will be invoked every LSC_TIMEOUT ns (100ms)
1383 * and will update link state if it changes.
1386 lio_sync_link_state_check(void *eth_dev)
1388 struct lio_device *lio_dev =
1389 (((struct rte_eth_dev *)eth_dev)->data->dev_private);
1391 if (lio_dev->port_configured)
1392 lio_dev_get_link_status(eth_dev);
1394 /* Schedule periodic link status check.
1395 * Stop check if interface is close and start again while opening.
1397 if (lio_dev->intf_open)
1398 rte_eal_alarm_set(LIO_LSC_TIMEOUT, lio_sync_link_state_check,
1403 lio_dev_start(struct rte_eth_dev *eth_dev)
1406 uint32_t frame_len = eth_dev->data->dev_conf.rxmode.max_rx_pkt_len;
1407 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1408 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1411 lio_dev_info(lio_dev, "Starting port %d\n", eth_dev->data->port_id);
1413 if (lio_dev->fn_list.enable_io_queues(lio_dev))
1416 if (lio_send_rx_ctrl_cmd(eth_dev, 1))
1419 /* Ready for link status updates */
1420 lio_dev->intf_open = 1;
1423 /* Configure RSS if device configured with multiple RX queues. */
1424 lio_dev_mq_rx_configure(eth_dev);
1426 /* Before update the link info,
1427 * must set linfo.link.link_status64 to 0.
1429 lio_dev->linfo.link.link_status64 = 0;
1431 /* start polling for lsc */
1432 ret = rte_eal_alarm_set(LIO_LSC_TIMEOUT,
1433 lio_sync_link_state_check,
1436 lio_dev_err(lio_dev,
1437 "link state check handler creation failed\n");
1438 goto dev_lsc_handle_error;
1441 while ((lio_dev->linfo.link.link_status64 == 0) && (--timeout))
1444 if (lio_dev->linfo.link.link_status64 == 0) {
1446 goto dev_mtu_set_error;
1449 mtu = (uint16_t)(frame_len - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN);
1450 if (mtu < RTE_ETHER_MIN_MTU)
1451 mtu = RTE_ETHER_MIN_MTU;
1453 if (eth_dev->data->mtu != mtu) {
1454 ret = lio_dev_mtu_set(eth_dev, mtu);
1456 goto dev_mtu_set_error;
1462 rte_eal_alarm_cancel(lio_sync_link_state_check, eth_dev);
1464 dev_lsc_handle_error:
1465 lio_dev->intf_open = 0;
1466 lio_send_rx_ctrl_cmd(eth_dev, 0);
1471 /* Stop device and disable input/output functions */
1473 lio_dev_stop(struct rte_eth_dev *eth_dev)
1475 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1477 lio_dev_info(lio_dev, "Stopping port %d\n", eth_dev->data->port_id);
1478 eth_dev->data->dev_started = 0;
1479 lio_dev->intf_open = 0;
1482 /* Cancel callback if still running. */
1483 rte_eal_alarm_cancel(lio_sync_link_state_check, eth_dev);
1485 lio_send_rx_ctrl_cmd(eth_dev, 0);
1487 lio_wait_for_instr_fetch(lio_dev);
1489 /* Clear recorded link status */
1490 lio_dev->linfo.link.link_status64 = 0;
1496 lio_dev_set_link_up(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 UP\n");
1510 if (lio_send_rx_ctrl_cmd(eth_dev, 1)) {
1511 lio_dev_err(lio_dev, "Unable to set Link UP\n");
1515 lio_dev->linfo.link.s.link_up = 1;
1516 eth_dev->data->dev_link.link_status = ETH_LINK_UP;
1522 lio_dev_set_link_down(struct rte_eth_dev *eth_dev)
1524 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1526 if (!lio_dev->intf_open) {
1527 lio_dev_info(lio_dev, "Port is stopped, Start the port first\n");
1531 if (!lio_dev->linfo.link.s.link_up) {
1532 lio_dev_info(lio_dev, "Link is already DOWN\n");
1536 lio_dev->linfo.link.s.link_up = 0;
1537 eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
1539 if (lio_send_rx_ctrl_cmd(eth_dev, 0)) {
1540 lio_dev->linfo.link.s.link_up = 1;
1541 eth_dev->data->dev_link.link_status = ETH_LINK_UP;
1542 lio_dev_err(lio_dev, "Unable to set Link Down\n");
1550 * Reset and stop the device. This occurs on the first
1551 * call to this routine. Subsequent calls will simply
1552 * return. NB: This will require the NIC to be rebooted.
1555 * Pointer to the structure rte_eth_dev
1561 lio_dev_close(struct rte_eth_dev *eth_dev)
1563 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1566 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1569 lio_dev_info(lio_dev, "closing port %d\n", eth_dev->data->port_id);
1571 if (lio_dev->intf_open)
1572 ret = lio_dev_stop(eth_dev);
1574 /* Reset ioq regs */
1575 lio_dev->fn_list.setup_device_regs(lio_dev);
1577 if (lio_dev->pci_dev->kdrv == RTE_PCI_KDRV_IGB_UIO) {
1578 cn23xx_vf_ask_pf_to_do_flr(lio_dev);
1579 rte_delay_ms(LIO_PCI_FLR_WAIT);
1583 lio_dev->fn_list.free_mbox(lio_dev);
1585 /* Free glist resources */
1586 rte_free(lio_dev->glist_head);
1587 rte_free(lio_dev->glist_lock);
1588 lio_dev->glist_head = NULL;
1589 lio_dev->glist_lock = NULL;
1591 lio_dev->port_configured = 0;
1593 /* Delete all queues */
1594 lio_dev_clear_queues(eth_dev);
1600 * Enable tunnel rx checksum verification from firmware.
1603 lio_enable_hw_tunnel_rx_checksum(struct rte_eth_dev *eth_dev)
1605 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1606 struct lio_dev_ctrl_cmd ctrl_cmd;
1607 struct lio_ctrl_pkt ctrl_pkt;
1609 /* flush added to prevent cmd failure
1610 * incase the queue is full
1612 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1614 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1615 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1617 ctrl_cmd.eth_dev = eth_dev;
1620 ctrl_pkt.ncmd.s.cmd = LIO_CMD_TNL_RX_CSUM_CTL;
1621 ctrl_pkt.ncmd.s.param1 = LIO_CMD_RXCSUM_ENABLE;
1622 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1624 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1625 lio_dev_err(lio_dev, "Failed to send TNL_RX_CSUM command\n");
1629 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd))
1630 lio_dev_err(lio_dev, "TNL_RX_CSUM command timed out\n");
1634 * Enable checksum calculation for inner packet in a tunnel.
1637 lio_enable_hw_tunnel_tx_checksum(struct rte_eth_dev *eth_dev)
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 /* flush added to prevent cmd failure
1644 * incase the queue is full
1646 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1648 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1649 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1651 ctrl_cmd.eth_dev = eth_dev;
1654 ctrl_pkt.ncmd.s.cmd = LIO_CMD_TNL_TX_CSUM_CTL;
1655 ctrl_pkt.ncmd.s.param1 = LIO_CMD_TXCSUM_ENABLE;
1656 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1658 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1659 lio_dev_err(lio_dev, "Failed to send TNL_TX_CSUM command\n");
1663 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd))
1664 lio_dev_err(lio_dev, "TNL_TX_CSUM command timed out\n");
1668 lio_send_queue_count_update(struct rte_eth_dev *eth_dev, int num_txq,
1671 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1672 struct lio_dev_ctrl_cmd ctrl_cmd;
1673 struct lio_ctrl_pkt ctrl_pkt;
1675 if (strcmp(lio_dev->firmware_version, LIO_Q_RECONF_MIN_VERSION) < 0) {
1676 lio_dev_err(lio_dev, "Require firmware version >= %s\n",
1677 LIO_Q_RECONF_MIN_VERSION);
1681 /* flush added to prevent cmd failure
1682 * incase the queue is full
1684 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1686 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1687 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1689 ctrl_cmd.eth_dev = eth_dev;
1692 ctrl_pkt.ncmd.s.cmd = LIO_CMD_QUEUE_COUNT_CTL;
1693 ctrl_pkt.ncmd.s.param1 = num_txq;
1694 ctrl_pkt.ncmd.s.param2 = num_rxq;
1695 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1697 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1698 lio_dev_err(lio_dev, "Failed to send queue count control command\n");
1702 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
1703 lio_dev_err(lio_dev, "Queue count control command timed out\n");
1711 lio_reconf_queues(struct rte_eth_dev *eth_dev, int num_txq, int num_rxq)
1713 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1716 if (lio_dev->nb_rx_queues != num_rxq ||
1717 lio_dev->nb_tx_queues != num_txq) {
1718 if (lio_send_queue_count_update(eth_dev, num_txq, num_rxq))
1720 lio_dev->nb_rx_queues = num_rxq;
1721 lio_dev->nb_tx_queues = num_txq;
1724 if (lio_dev->intf_open) {
1725 ret = lio_dev_stop(eth_dev);
1730 /* Reset ioq registers */
1731 if (lio_dev->fn_list.setup_device_regs(lio_dev)) {
1732 lio_dev_err(lio_dev, "Failed to configure device registers\n");
1740 lio_dev_configure(struct rte_eth_dev *eth_dev)
1742 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1743 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1744 int retval, num_iqueues, num_oqueues;
1745 uint8_t mac[RTE_ETHER_ADDR_LEN], i;
1746 struct lio_if_cfg_resp *resp;
1747 struct lio_soft_command *sc;
1748 union lio_if_cfg if_cfg;
1751 PMD_INIT_FUNC_TRACE();
1753 if (eth_dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
1754 eth_dev->data->dev_conf.rxmode.offloads |=
1755 DEV_RX_OFFLOAD_RSS_HASH;
1757 /* Inform firmware about change in number of queues to use.
1758 * Disable IO queues and reset registers for re-configuration.
1760 if (lio_dev->port_configured)
1761 return lio_reconf_queues(eth_dev,
1762 eth_dev->data->nb_tx_queues,
1763 eth_dev->data->nb_rx_queues);
1765 lio_dev->nb_rx_queues = eth_dev->data->nb_rx_queues;
1766 lio_dev->nb_tx_queues = eth_dev->data->nb_tx_queues;
1768 /* Set max number of queues which can be re-configured. */
1769 lio_dev->max_rx_queues = eth_dev->data->nb_rx_queues;
1770 lio_dev->max_tx_queues = eth_dev->data->nb_tx_queues;
1772 resp_size = sizeof(struct lio_if_cfg_resp);
1773 sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
1777 resp = (struct lio_if_cfg_resp *)sc->virtrptr;
1779 /* Firmware doesn't have capability to reconfigure the queues,
1780 * Claim all queues, and use as many required
1782 if_cfg.if_cfg64 = 0;
1783 if_cfg.s.num_iqueues = lio_dev->nb_tx_queues;
1784 if_cfg.s.num_oqueues = lio_dev->nb_rx_queues;
1785 if_cfg.s.base_queue = 0;
1787 if_cfg.s.gmx_port_id = lio_dev->pf_num;
1789 lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
1790 LIO_OPCODE_IF_CFG, 0,
1791 if_cfg.if_cfg64, 0);
1793 /* Setting wait time in seconds */
1794 sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
1796 retval = lio_send_soft_command(lio_dev, sc);
1797 if (retval == LIO_IQ_SEND_FAILED) {
1798 lio_dev_err(lio_dev, "iq/oq config failed status: %x\n",
1800 /* Soft instr is freed by driver in case of failure. */
1801 goto nic_config_fail;
1804 /* Sleep on a wait queue till the cond flag indicates that the
1805 * response arrived or timed-out.
1807 while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
1808 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
1809 lio_process_ordered_list(lio_dev);
1813 retval = resp->status;
1815 lio_dev_err(lio_dev, "iq/oq config failed\n");
1816 goto nic_config_fail;
1819 strlcpy(lio_dev->firmware_version,
1820 resp->cfg_info.lio_firmware_version, LIO_FW_VERSION_LENGTH);
1822 lio_swap_8B_data((uint64_t *)(&resp->cfg_info),
1823 sizeof(struct octeon_if_cfg_info) >> 3);
1825 num_iqueues = lio_hweight64(resp->cfg_info.iqmask);
1826 num_oqueues = lio_hweight64(resp->cfg_info.oqmask);
1828 if (!(num_iqueues) || !(num_oqueues)) {
1829 lio_dev_err(lio_dev,
1830 "Got bad iqueues (%016lx) or oqueues (%016lx) from firmware.\n",
1831 (unsigned long)resp->cfg_info.iqmask,
1832 (unsigned long)resp->cfg_info.oqmask);
1833 goto nic_config_fail;
1836 lio_dev_dbg(lio_dev,
1837 "interface %d, iqmask %016lx, oqmask %016lx, numiqueues %d, numoqueues %d\n",
1838 eth_dev->data->port_id,
1839 (unsigned long)resp->cfg_info.iqmask,
1840 (unsigned long)resp->cfg_info.oqmask,
1841 num_iqueues, num_oqueues);
1843 lio_dev->linfo.num_rxpciq = num_oqueues;
1844 lio_dev->linfo.num_txpciq = num_iqueues;
1846 for (i = 0; i < num_oqueues; i++) {
1847 lio_dev->linfo.rxpciq[i].rxpciq64 =
1848 resp->cfg_info.linfo.rxpciq[i].rxpciq64;
1849 lio_dev_dbg(lio_dev, "index %d OQ %d\n",
1850 i, lio_dev->linfo.rxpciq[i].s.q_no);
1853 for (i = 0; i < num_iqueues; i++) {
1854 lio_dev->linfo.txpciq[i].txpciq64 =
1855 resp->cfg_info.linfo.txpciq[i].txpciq64;
1856 lio_dev_dbg(lio_dev, "index %d IQ %d\n",
1857 i, lio_dev->linfo.txpciq[i].s.q_no);
1860 lio_dev->linfo.hw_addr = resp->cfg_info.linfo.hw_addr;
1861 lio_dev->linfo.gmxport = resp->cfg_info.linfo.gmxport;
1862 lio_dev->linfo.link.link_status64 =
1863 resp->cfg_info.linfo.link.link_status64;
1865 /* 64-bit swap required on LE machines */
1866 lio_swap_8B_data(&lio_dev->linfo.hw_addr, 1);
1867 for (i = 0; i < RTE_ETHER_ADDR_LEN; i++)
1868 mac[i] = *((uint8_t *)(((uint8_t *)&lio_dev->linfo.hw_addr) +
1871 /* Copy the permanent MAC address */
1872 rte_ether_addr_copy((struct rte_ether_addr *)mac,
1873 ð_dev->data->mac_addrs[0]);
1875 /* enable firmware checksum support for tunnel packets */
1876 lio_enable_hw_tunnel_rx_checksum(eth_dev);
1877 lio_enable_hw_tunnel_tx_checksum(eth_dev);
1879 lio_dev->glist_lock =
1880 rte_zmalloc(NULL, sizeof(*lio_dev->glist_lock) * num_iqueues, 0);
1881 if (lio_dev->glist_lock == NULL)
1884 lio_dev->glist_head =
1885 rte_zmalloc(NULL, sizeof(*lio_dev->glist_head) * num_iqueues,
1887 if (lio_dev->glist_head == NULL) {
1888 rte_free(lio_dev->glist_lock);
1889 lio_dev->glist_lock = NULL;
1893 lio_dev_link_update(eth_dev, 0);
1895 lio_dev->port_configured = 1;
1897 lio_free_soft_command(sc);
1899 /* Reset ioq regs */
1900 lio_dev->fn_list.setup_device_regs(lio_dev);
1902 /* Free iq_0 used during init */
1903 lio_free_instr_queue0(lio_dev);
1908 lio_dev_err(lio_dev, "Failed retval %d\n", retval);
1909 lio_free_soft_command(sc);
1910 lio_free_instr_queue0(lio_dev);
1915 /* Define our ethernet definitions */
1916 static const struct eth_dev_ops liovf_eth_dev_ops = {
1917 .dev_configure = lio_dev_configure,
1918 .dev_start = lio_dev_start,
1919 .dev_stop = lio_dev_stop,
1920 .dev_set_link_up = lio_dev_set_link_up,
1921 .dev_set_link_down = lio_dev_set_link_down,
1922 .dev_close = lio_dev_close,
1923 .promiscuous_enable = lio_dev_promiscuous_enable,
1924 .promiscuous_disable = lio_dev_promiscuous_disable,
1925 .allmulticast_enable = lio_dev_allmulticast_enable,
1926 .allmulticast_disable = lio_dev_allmulticast_disable,
1927 .link_update = lio_dev_link_update,
1928 .stats_get = lio_dev_stats_get,
1929 .xstats_get = lio_dev_xstats_get,
1930 .xstats_get_names = lio_dev_xstats_get_names,
1931 .stats_reset = lio_dev_stats_reset,
1932 .xstats_reset = lio_dev_xstats_reset,
1933 .dev_infos_get = lio_dev_info_get,
1934 .vlan_filter_set = lio_dev_vlan_filter_set,
1935 .rx_queue_setup = lio_dev_rx_queue_setup,
1936 .rx_queue_release = lio_dev_rx_queue_release,
1937 .tx_queue_setup = lio_dev_tx_queue_setup,
1938 .tx_queue_release = lio_dev_tx_queue_release,
1939 .reta_update = lio_dev_rss_reta_update,
1940 .reta_query = lio_dev_rss_reta_query,
1941 .rss_hash_conf_get = lio_dev_rss_hash_conf_get,
1942 .rss_hash_update = lio_dev_rss_hash_update,
1943 .udp_tunnel_port_add = lio_dev_udp_tunnel_add,
1944 .udp_tunnel_port_del = lio_dev_udp_tunnel_del,
1945 .mtu_set = lio_dev_mtu_set,
1949 lio_check_pf_hs_response(void *lio_dev)
1951 struct lio_device *dev = lio_dev;
1953 /* check till response arrives */
1954 if (dev->pfvf_hsword.coproc_tics_per_us)
1957 cn23xx_vf_handle_mbox(dev);
1959 rte_eal_alarm_set(1, lio_check_pf_hs_response, lio_dev);
1963 * \brief Identify the LIO device and to map the BAR address space
1964 * @param lio_dev lio device
1967 lio_chip_specific_setup(struct lio_device *lio_dev)
1969 struct rte_pci_device *pdev = lio_dev->pci_dev;
1970 uint32_t dev_id = pdev->id.device_id;
1975 case LIO_CN23XX_VF_VID:
1976 lio_dev->chip_id = LIO_CN23XX_VF_VID;
1977 ret = cn23xx_vf_setup_device(lio_dev);
1982 lio_dev_err(lio_dev, "Unsupported Chip\n");
1986 lio_dev_info(lio_dev, "DEVICE : %s\n", s);
1992 lio_first_time_init(struct lio_device *lio_dev,
1993 struct rte_pci_device *pdev)
1997 PMD_INIT_FUNC_TRACE();
1999 /* set dpdk specific pci device pointer */
2000 lio_dev->pci_dev = pdev;
2002 /* Identify the LIO type and set device ops */
2003 if (lio_chip_specific_setup(lio_dev)) {
2004 lio_dev_err(lio_dev, "Chip specific setup failed\n");
2008 /* Initialize soft command buffer pool */
2009 if (lio_setup_sc_buffer_pool(lio_dev)) {
2010 lio_dev_err(lio_dev, "sc buffer pool allocation failed\n");
2014 /* Initialize lists to manage the requests of different types that
2015 * arrive from applications for this lio device.
2017 lio_setup_response_list(lio_dev);
2019 if (lio_dev->fn_list.setup_mbox(lio_dev)) {
2020 lio_dev_err(lio_dev, "Mailbox setup failed\n");
2024 /* Check PF response */
2025 lio_check_pf_hs_response((void *)lio_dev);
2027 /* Do handshake and exit if incompatible PF driver */
2028 if (cn23xx_pfvf_handshake(lio_dev))
2031 /* Request and wait for device reset. */
2032 if (pdev->kdrv == RTE_PCI_KDRV_IGB_UIO) {
2033 cn23xx_vf_ask_pf_to_do_flr(lio_dev);
2034 /* FLR wait time doubled as a precaution. */
2035 rte_delay_ms(LIO_PCI_FLR_WAIT * 2);
2038 if (lio_dev->fn_list.setup_device_regs(lio_dev)) {
2039 lio_dev_err(lio_dev, "Failed to configure device registers\n");
2043 if (lio_setup_instr_queue0(lio_dev)) {
2044 lio_dev_err(lio_dev, "Failed to setup instruction queue 0\n");
2048 dpdk_queues = (int)lio_dev->sriov_info.rings_per_vf;
2050 lio_dev->max_tx_queues = dpdk_queues;
2051 lio_dev->max_rx_queues = dpdk_queues;
2053 /* Enable input and output queues for this device */
2054 if (lio_dev->fn_list.enable_io_queues(lio_dev))
2060 lio_free_sc_buffer_pool(lio_dev);
2061 if (lio_dev->mbox[0])
2062 lio_dev->fn_list.free_mbox(lio_dev);
2063 if (lio_dev->instr_queue[0])
2064 lio_free_instr_queue0(lio_dev);
2070 lio_eth_dev_uninit(struct rte_eth_dev *eth_dev)
2072 struct lio_device *lio_dev = LIO_DEV(eth_dev);
2074 PMD_INIT_FUNC_TRACE();
2076 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
2079 /* lio_free_sc_buffer_pool */
2080 lio_free_sc_buffer_pool(lio_dev);
2086 lio_eth_dev_init(struct rte_eth_dev *eth_dev)
2088 struct rte_pci_device *pdev = RTE_ETH_DEV_TO_PCI(eth_dev);
2089 struct lio_device *lio_dev = LIO_DEV(eth_dev);
2091 PMD_INIT_FUNC_TRACE();
2093 eth_dev->rx_pkt_burst = &lio_dev_recv_pkts;
2094 eth_dev->tx_pkt_burst = &lio_dev_xmit_pkts;
2096 /* Primary does the initialization. */
2097 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
2100 rte_eth_copy_pci_info(eth_dev, pdev);
2101 eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
2103 if (pdev->mem_resource[0].addr) {
2104 lio_dev->hw_addr = pdev->mem_resource[0].addr;
2106 PMD_INIT_LOG(ERR, "ERROR: Failed to map BAR0\n");
2110 lio_dev->eth_dev = eth_dev;
2111 /* set lio device print string */
2112 snprintf(lio_dev->dev_string, sizeof(lio_dev->dev_string),
2113 "%s[%02x:%02x.%x]", pdev->driver->driver.name,
2114 pdev->addr.bus, pdev->addr.devid, pdev->addr.function);
2116 lio_dev->port_id = eth_dev->data->port_id;
2118 if (lio_first_time_init(lio_dev, pdev)) {
2119 lio_dev_err(lio_dev, "Device init failed\n");
2123 eth_dev->dev_ops = &liovf_eth_dev_ops;
2124 eth_dev->data->mac_addrs = rte_zmalloc("lio", RTE_ETHER_ADDR_LEN, 0);
2125 if (eth_dev->data->mac_addrs == NULL) {
2126 lio_dev_err(lio_dev,
2127 "MAC addresses memory allocation failed\n");
2128 eth_dev->dev_ops = NULL;
2129 eth_dev->rx_pkt_burst = NULL;
2130 eth_dev->tx_pkt_burst = NULL;
2134 rte_atomic64_set(&lio_dev->status, LIO_DEV_RUNNING);
2137 lio_dev->port_configured = 0;
2138 /* Always allow unicast packets */
2139 lio_dev->ifflags |= LIO_IFFLAG_UNICAST;
2145 lio_eth_dev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
2146 struct rte_pci_device *pci_dev)
2148 return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct lio_device),
2153 lio_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
2155 return rte_eth_dev_pci_generic_remove(pci_dev,
2156 lio_eth_dev_uninit);
2159 /* Set of PCI devices this driver supports */
2160 static const struct rte_pci_id pci_id_liovf_map[] = {
2161 { RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_VF_VID) },
2162 { .vendor_id = 0, /* sentinel */ }
2165 static struct rte_pci_driver rte_liovf_pmd = {
2166 .id_table = pci_id_liovf_map,
2167 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
2168 .probe = lio_eth_dev_pci_probe,
2169 .remove = lio_eth_dev_pci_remove,
2172 RTE_PMD_REGISTER_PCI(net_liovf, rte_liovf_pmd);
2173 RTE_PMD_REGISTER_PCI_TABLE(net_liovf, pci_id_liovf_map);
2174 RTE_PMD_REGISTER_KMOD_DEP(net_liovf, "* igb_uio | vfio-pci");
2175 RTE_LOG_REGISTER_SUFFIX(lio_logtype_init, init, NOTICE);
2176 RTE_LOG_REGISTER_SUFFIX(lio_logtype_driver, driver, NOTICE);