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->data->rx_queues[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 * Opaque pointer to the receive queue to release
1214 lio_dev_rx_queue_release(void *rxq)
1216 struct lio_droq *droq = rxq;
1221 lio_delete_droq_queue(droq->lio_dev, oq_no);
1226 * Allocate and initialize SW ring. Initialize associated HW registers.
1229 * Pointer to structure rte_eth_dev
1234 * @param num_tx_descs
1235 * Number of ringbuffer descriptors
1238 * NUMA socket id, used for memory allocations
1241 * Pointer to the structure rte_eth_txconf
1244 * - On success, return 0
1245 * - On failure, return -errno value
1248 lio_dev_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t q_no,
1249 uint16_t num_tx_descs, unsigned int socket_id,
1250 const struct rte_eth_txconf *tx_conf __rte_unused)
1252 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1253 int fw_mapped_iq = lio_dev->linfo.txpciq[q_no].s.q_no;
1256 if (q_no >= lio_dev->nb_tx_queues) {
1257 lio_dev_err(lio_dev, "Invalid tx queue number %u\n", q_no);
1261 lio_dev_dbg(lio_dev, "setting up tx queue %u\n", q_no);
1263 /* Free previous allocation if any */
1264 if (eth_dev->data->tx_queues[q_no] != NULL) {
1265 lio_dev_tx_queue_release(eth_dev->data->tx_queues[q_no]);
1266 eth_dev->data->tx_queues[q_no] = NULL;
1269 retval = lio_setup_iq(lio_dev, q_no, lio_dev->linfo.txpciq[q_no],
1270 num_tx_descs, lio_dev, socket_id);
1273 lio_dev_err(lio_dev, "Runtime IQ(TxQ) creation failed.\n");
1277 retval = lio_setup_sglists(lio_dev, q_no, fw_mapped_iq,
1278 lio_dev->instr_queue[fw_mapped_iq]->nb_desc,
1282 lio_delete_instruction_queue(lio_dev, fw_mapped_iq);
1286 eth_dev->data->tx_queues[q_no] = lio_dev->instr_queue[fw_mapped_iq];
1292 * Release the transmit queue/ringbuffer. Called by
1296 * Opaque pointer to the transmit queue to release
1302 lio_dev_tx_queue_release(void *txq)
1304 struct lio_instr_queue *tq = txq;
1305 uint32_t fw_mapped_iq_no;
1310 lio_delete_sglist(tq);
1312 fw_mapped_iq_no = tq->txpciq.s.q_no;
1313 lio_delete_instruction_queue(tq->lio_dev, fw_mapped_iq_no);
1318 * Api to check link state.
1321 lio_dev_get_link_status(struct rte_eth_dev *eth_dev)
1323 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1324 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1325 struct lio_link_status_resp *resp;
1326 union octeon_link_status *ls;
1327 struct lio_soft_command *sc;
1330 if (!lio_dev->intf_open)
1333 resp_size = sizeof(struct lio_link_status_resp);
1334 sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
1338 resp = (struct lio_link_status_resp *)sc->virtrptr;
1339 lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
1340 LIO_OPCODE_INFO, 0, 0, 0);
1342 /* Setting wait time in seconds */
1343 sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
1345 if (lio_send_soft_command(lio_dev, sc) == LIO_IQ_SEND_FAILED)
1346 goto get_status_fail;
1348 while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
1349 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
1354 goto get_status_fail;
1356 ls = &resp->link_info.link;
1358 lio_swap_8B_data((uint64_t *)ls, sizeof(union octeon_link_status) >> 3);
1360 if (lio_dev->linfo.link.link_status64 != ls->link_status64) {
1361 if (ls->s.mtu < eth_dev->data->mtu) {
1362 lio_dev_info(lio_dev, "Lowered VF MTU to %d as PF MTU dropped\n",
1364 eth_dev->data->mtu = ls->s.mtu;
1366 lio_dev->linfo.link.link_status64 = ls->link_status64;
1367 lio_dev_link_update(eth_dev, 0);
1370 lio_free_soft_command(sc);
1375 lio_free_soft_command(sc);
1378 /* This function will be invoked every LSC_TIMEOUT ns (100ms)
1379 * and will update link state if it changes.
1382 lio_sync_link_state_check(void *eth_dev)
1384 struct lio_device *lio_dev =
1385 (((struct rte_eth_dev *)eth_dev)->data->dev_private);
1387 if (lio_dev->port_configured)
1388 lio_dev_get_link_status(eth_dev);
1390 /* Schedule periodic link status check.
1391 * Stop check if interface is close and start again while opening.
1393 if (lio_dev->intf_open)
1394 rte_eal_alarm_set(LIO_LSC_TIMEOUT, lio_sync_link_state_check,
1399 lio_dev_start(struct rte_eth_dev *eth_dev)
1402 uint32_t frame_len = eth_dev->data->dev_conf.rxmode.max_rx_pkt_len;
1403 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1404 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1407 lio_dev_info(lio_dev, "Starting port %d\n", eth_dev->data->port_id);
1409 if (lio_dev->fn_list.enable_io_queues(lio_dev))
1412 if (lio_send_rx_ctrl_cmd(eth_dev, 1))
1415 /* Ready for link status updates */
1416 lio_dev->intf_open = 1;
1419 /* Configure RSS if device configured with multiple RX queues. */
1420 lio_dev_mq_rx_configure(eth_dev);
1422 /* Before update the link info,
1423 * must set linfo.link.link_status64 to 0.
1425 lio_dev->linfo.link.link_status64 = 0;
1427 /* start polling for lsc */
1428 ret = rte_eal_alarm_set(LIO_LSC_TIMEOUT,
1429 lio_sync_link_state_check,
1432 lio_dev_err(lio_dev,
1433 "link state check handler creation failed\n");
1434 goto dev_lsc_handle_error;
1437 while ((lio_dev->linfo.link.link_status64 == 0) && (--timeout))
1440 if (lio_dev->linfo.link.link_status64 == 0) {
1442 goto dev_mtu_set_error;
1445 mtu = (uint16_t)(frame_len - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN);
1446 if (mtu < RTE_ETHER_MIN_MTU)
1447 mtu = RTE_ETHER_MIN_MTU;
1449 if (eth_dev->data->mtu != mtu) {
1450 ret = lio_dev_mtu_set(eth_dev, mtu);
1452 goto dev_mtu_set_error;
1458 rte_eal_alarm_cancel(lio_sync_link_state_check, eth_dev);
1460 dev_lsc_handle_error:
1461 lio_dev->intf_open = 0;
1462 lio_send_rx_ctrl_cmd(eth_dev, 0);
1467 /* Stop device and disable input/output functions */
1469 lio_dev_stop(struct rte_eth_dev *eth_dev)
1471 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1473 lio_dev_info(lio_dev, "Stopping port %d\n", eth_dev->data->port_id);
1474 eth_dev->data->dev_started = 0;
1475 lio_dev->intf_open = 0;
1478 /* Cancel callback if still running. */
1479 rte_eal_alarm_cancel(lio_sync_link_state_check, eth_dev);
1481 lio_send_rx_ctrl_cmd(eth_dev, 0);
1483 lio_wait_for_instr_fetch(lio_dev);
1485 /* Clear recorded link status */
1486 lio_dev->linfo.link.link_status64 = 0;
1492 lio_dev_set_link_up(struct rte_eth_dev *eth_dev)
1494 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1496 if (!lio_dev->intf_open) {
1497 lio_dev_info(lio_dev, "Port is stopped, Start the port first\n");
1501 if (lio_dev->linfo.link.s.link_up) {
1502 lio_dev_info(lio_dev, "Link is already UP\n");
1506 if (lio_send_rx_ctrl_cmd(eth_dev, 1)) {
1507 lio_dev_err(lio_dev, "Unable to set Link UP\n");
1511 lio_dev->linfo.link.s.link_up = 1;
1512 eth_dev->data->dev_link.link_status = ETH_LINK_UP;
1518 lio_dev_set_link_down(struct rte_eth_dev *eth_dev)
1520 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1522 if (!lio_dev->intf_open) {
1523 lio_dev_info(lio_dev, "Port is stopped, Start the port first\n");
1527 if (!lio_dev->linfo.link.s.link_up) {
1528 lio_dev_info(lio_dev, "Link is already DOWN\n");
1532 lio_dev->linfo.link.s.link_up = 0;
1533 eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
1535 if (lio_send_rx_ctrl_cmd(eth_dev, 0)) {
1536 lio_dev->linfo.link.s.link_up = 1;
1537 eth_dev->data->dev_link.link_status = ETH_LINK_UP;
1538 lio_dev_err(lio_dev, "Unable to set Link Down\n");
1546 * Reset and stop the device. This occurs on the first
1547 * call to this routine. Subsequent calls will simply
1548 * return. NB: This will require the NIC to be rebooted.
1551 * Pointer to the structure rte_eth_dev
1557 lio_dev_close(struct rte_eth_dev *eth_dev)
1559 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1562 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1565 lio_dev_info(lio_dev, "closing port %d\n", eth_dev->data->port_id);
1567 if (lio_dev->intf_open)
1568 ret = lio_dev_stop(eth_dev);
1570 /* Reset ioq regs */
1571 lio_dev->fn_list.setup_device_regs(lio_dev);
1573 if (lio_dev->pci_dev->kdrv == RTE_PCI_KDRV_IGB_UIO) {
1574 cn23xx_vf_ask_pf_to_do_flr(lio_dev);
1575 rte_delay_ms(LIO_PCI_FLR_WAIT);
1579 lio_dev->fn_list.free_mbox(lio_dev);
1581 /* Free glist resources */
1582 rte_free(lio_dev->glist_head);
1583 rte_free(lio_dev->glist_lock);
1584 lio_dev->glist_head = NULL;
1585 lio_dev->glist_lock = NULL;
1587 lio_dev->port_configured = 0;
1589 /* Delete all queues */
1590 lio_dev_clear_queues(eth_dev);
1596 * Enable tunnel rx checksum verification from firmware.
1599 lio_enable_hw_tunnel_rx_checksum(struct rte_eth_dev *eth_dev)
1601 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1602 struct lio_dev_ctrl_cmd ctrl_cmd;
1603 struct lio_ctrl_pkt ctrl_pkt;
1605 /* flush added to prevent cmd failure
1606 * incase the queue is full
1608 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1610 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1611 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1613 ctrl_cmd.eth_dev = eth_dev;
1616 ctrl_pkt.ncmd.s.cmd = LIO_CMD_TNL_RX_CSUM_CTL;
1617 ctrl_pkt.ncmd.s.param1 = LIO_CMD_RXCSUM_ENABLE;
1618 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1620 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1621 lio_dev_err(lio_dev, "Failed to send TNL_RX_CSUM command\n");
1625 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd))
1626 lio_dev_err(lio_dev, "TNL_RX_CSUM command timed out\n");
1630 * Enable checksum calculation for inner packet in a tunnel.
1633 lio_enable_hw_tunnel_tx_checksum(struct rte_eth_dev *eth_dev)
1635 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1636 struct lio_dev_ctrl_cmd ctrl_cmd;
1637 struct lio_ctrl_pkt ctrl_pkt;
1639 /* flush added to prevent cmd failure
1640 * incase the queue is full
1642 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1644 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1645 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1647 ctrl_cmd.eth_dev = eth_dev;
1650 ctrl_pkt.ncmd.s.cmd = LIO_CMD_TNL_TX_CSUM_CTL;
1651 ctrl_pkt.ncmd.s.param1 = LIO_CMD_TXCSUM_ENABLE;
1652 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1654 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1655 lio_dev_err(lio_dev, "Failed to send TNL_TX_CSUM command\n");
1659 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd))
1660 lio_dev_err(lio_dev, "TNL_TX_CSUM command timed out\n");
1664 lio_send_queue_count_update(struct rte_eth_dev *eth_dev, int num_txq,
1667 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1668 struct lio_dev_ctrl_cmd ctrl_cmd;
1669 struct lio_ctrl_pkt ctrl_pkt;
1671 if (strcmp(lio_dev->firmware_version, LIO_Q_RECONF_MIN_VERSION) < 0) {
1672 lio_dev_err(lio_dev, "Require firmware version >= %s\n",
1673 LIO_Q_RECONF_MIN_VERSION);
1677 /* flush added to prevent cmd failure
1678 * incase the queue is full
1680 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1682 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1683 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1685 ctrl_cmd.eth_dev = eth_dev;
1688 ctrl_pkt.ncmd.s.cmd = LIO_CMD_QUEUE_COUNT_CTL;
1689 ctrl_pkt.ncmd.s.param1 = num_txq;
1690 ctrl_pkt.ncmd.s.param2 = num_rxq;
1691 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1693 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1694 lio_dev_err(lio_dev, "Failed to send queue count control command\n");
1698 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
1699 lio_dev_err(lio_dev, "Queue count control command timed out\n");
1707 lio_reconf_queues(struct rte_eth_dev *eth_dev, int num_txq, int num_rxq)
1709 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1712 if (lio_dev->nb_rx_queues != num_rxq ||
1713 lio_dev->nb_tx_queues != num_txq) {
1714 if (lio_send_queue_count_update(eth_dev, num_txq, num_rxq))
1716 lio_dev->nb_rx_queues = num_rxq;
1717 lio_dev->nb_tx_queues = num_txq;
1720 if (lio_dev->intf_open) {
1721 ret = lio_dev_stop(eth_dev);
1726 /* Reset ioq registers */
1727 if (lio_dev->fn_list.setup_device_regs(lio_dev)) {
1728 lio_dev_err(lio_dev, "Failed to configure device registers\n");
1736 lio_dev_configure(struct rte_eth_dev *eth_dev)
1738 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1739 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1740 int retval, num_iqueues, num_oqueues;
1741 uint8_t mac[RTE_ETHER_ADDR_LEN], i;
1742 struct lio_if_cfg_resp *resp;
1743 struct lio_soft_command *sc;
1744 union lio_if_cfg if_cfg;
1747 PMD_INIT_FUNC_TRACE();
1749 if (eth_dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
1750 eth_dev->data->dev_conf.rxmode.offloads |=
1751 DEV_RX_OFFLOAD_RSS_HASH;
1753 /* Inform firmware about change in number of queues to use.
1754 * Disable IO queues and reset registers for re-configuration.
1756 if (lio_dev->port_configured)
1757 return lio_reconf_queues(eth_dev,
1758 eth_dev->data->nb_tx_queues,
1759 eth_dev->data->nb_rx_queues);
1761 lio_dev->nb_rx_queues = eth_dev->data->nb_rx_queues;
1762 lio_dev->nb_tx_queues = eth_dev->data->nb_tx_queues;
1764 /* Set max number of queues which can be re-configured. */
1765 lio_dev->max_rx_queues = eth_dev->data->nb_rx_queues;
1766 lio_dev->max_tx_queues = eth_dev->data->nb_tx_queues;
1768 resp_size = sizeof(struct lio_if_cfg_resp);
1769 sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
1773 resp = (struct lio_if_cfg_resp *)sc->virtrptr;
1775 /* Firmware doesn't have capability to reconfigure the queues,
1776 * Claim all queues, and use as many required
1778 if_cfg.if_cfg64 = 0;
1779 if_cfg.s.num_iqueues = lio_dev->nb_tx_queues;
1780 if_cfg.s.num_oqueues = lio_dev->nb_rx_queues;
1781 if_cfg.s.base_queue = 0;
1783 if_cfg.s.gmx_port_id = lio_dev->pf_num;
1785 lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
1786 LIO_OPCODE_IF_CFG, 0,
1787 if_cfg.if_cfg64, 0);
1789 /* Setting wait time in seconds */
1790 sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
1792 retval = lio_send_soft_command(lio_dev, sc);
1793 if (retval == LIO_IQ_SEND_FAILED) {
1794 lio_dev_err(lio_dev, "iq/oq config failed status: %x\n",
1796 /* Soft instr is freed by driver in case of failure. */
1797 goto nic_config_fail;
1800 /* Sleep on a wait queue till the cond flag indicates that the
1801 * response arrived or timed-out.
1803 while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
1804 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
1805 lio_process_ordered_list(lio_dev);
1809 retval = resp->status;
1811 lio_dev_err(lio_dev, "iq/oq config failed\n");
1812 goto nic_config_fail;
1815 strlcpy(lio_dev->firmware_version,
1816 resp->cfg_info.lio_firmware_version, LIO_FW_VERSION_LENGTH);
1818 lio_swap_8B_data((uint64_t *)(&resp->cfg_info),
1819 sizeof(struct octeon_if_cfg_info) >> 3);
1821 num_iqueues = lio_hweight64(resp->cfg_info.iqmask);
1822 num_oqueues = lio_hweight64(resp->cfg_info.oqmask);
1824 if (!(num_iqueues) || !(num_oqueues)) {
1825 lio_dev_err(lio_dev,
1826 "Got bad iqueues (%016lx) or oqueues (%016lx) from firmware.\n",
1827 (unsigned long)resp->cfg_info.iqmask,
1828 (unsigned long)resp->cfg_info.oqmask);
1829 goto nic_config_fail;
1832 lio_dev_dbg(lio_dev,
1833 "interface %d, iqmask %016lx, oqmask %016lx, numiqueues %d, numoqueues %d\n",
1834 eth_dev->data->port_id,
1835 (unsigned long)resp->cfg_info.iqmask,
1836 (unsigned long)resp->cfg_info.oqmask,
1837 num_iqueues, num_oqueues);
1839 lio_dev->linfo.num_rxpciq = num_oqueues;
1840 lio_dev->linfo.num_txpciq = num_iqueues;
1842 for (i = 0; i < num_oqueues; i++) {
1843 lio_dev->linfo.rxpciq[i].rxpciq64 =
1844 resp->cfg_info.linfo.rxpciq[i].rxpciq64;
1845 lio_dev_dbg(lio_dev, "index %d OQ %d\n",
1846 i, lio_dev->linfo.rxpciq[i].s.q_no);
1849 for (i = 0; i < num_iqueues; i++) {
1850 lio_dev->linfo.txpciq[i].txpciq64 =
1851 resp->cfg_info.linfo.txpciq[i].txpciq64;
1852 lio_dev_dbg(lio_dev, "index %d IQ %d\n",
1853 i, lio_dev->linfo.txpciq[i].s.q_no);
1856 lio_dev->linfo.hw_addr = resp->cfg_info.linfo.hw_addr;
1857 lio_dev->linfo.gmxport = resp->cfg_info.linfo.gmxport;
1858 lio_dev->linfo.link.link_status64 =
1859 resp->cfg_info.linfo.link.link_status64;
1861 /* 64-bit swap required on LE machines */
1862 lio_swap_8B_data(&lio_dev->linfo.hw_addr, 1);
1863 for (i = 0; i < RTE_ETHER_ADDR_LEN; i++)
1864 mac[i] = *((uint8_t *)(((uint8_t *)&lio_dev->linfo.hw_addr) +
1867 /* Copy the permanent MAC address */
1868 rte_ether_addr_copy((struct rte_ether_addr *)mac,
1869 ð_dev->data->mac_addrs[0]);
1871 /* enable firmware checksum support for tunnel packets */
1872 lio_enable_hw_tunnel_rx_checksum(eth_dev);
1873 lio_enable_hw_tunnel_tx_checksum(eth_dev);
1875 lio_dev->glist_lock =
1876 rte_zmalloc(NULL, sizeof(*lio_dev->glist_lock) * num_iqueues, 0);
1877 if (lio_dev->glist_lock == NULL)
1880 lio_dev->glist_head =
1881 rte_zmalloc(NULL, sizeof(*lio_dev->glist_head) * num_iqueues,
1883 if (lio_dev->glist_head == NULL) {
1884 rte_free(lio_dev->glist_lock);
1885 lio_dev->glist_lock = NULL;
1889 lio_dev_link_update(eth_dev, 0);
1891 lio_dev->port_configured = 1;
1893 lio_free_soft_command(sc);
1895 /* Reset ioq regs */
1896 lio_dev->fn_list.setup_device_regs(lio_dev);
1898 /* Free iq_0 used during init */
1899 lio_free_instr_queue0(lio_dev);
1904 lio_dev_err(lio_dev, "Failed retval %d\n", retval);
1905 lio_free_soft_command(sc);
1906 lio_free_instr_queue0(lio_dev);
1911 /* Define our ethernet definitions */
1912 static const struct eth_dev_ops liovf_eth_dev_ops = {
1913 .dev_configure = lio_dev_configure,
1914 .dev_start = lio_dev_start,
1915 .dev_stop = lio_dev_stop,
1916 .dev_set_link_up = lio_dev_set_link_up,
1917 .dev_set_link_down = lio_dev_set_link_down,
1918 .dev_close = lio_dev_close,
1919 .promiscuous_enable = lio_dev_promiscuous_enable,
1920 .promiscuous_disable = lio_dev_promiscuous_disable,
1921 .allmulticast_enable = lio_dev_allmulticast_enable,
1922 .allmulticast_disable = lio_dev_allmulticast_disable,
1923 .link_update = lio_dev_link_update,
1924 .stats_get = lio_dev_stats_get,
1925 .xstats_get = lio_dev_xstats_get,
1926 .xstats_get_names = lio_dev_xstats_get_names,
1927 .stats_reset = lio_dev_stats_reset,
1928 .xstats_reset = lio_dev_xstats_reset,
1929 .dev_infos_get = lio_dev_info_get,
1930 .vlan_filter_set = lio_dev_vlan_filter_set,
1931 .rx_queue_setup = lio_dev_rx_queue_setup,
1932 .rx_queue_release = lio_dev_rx_queue_release,
1933 .tx_queue_setup = lio_dev_tx_queue_setup,
1934 .tx_queue_release = lio_dev_tx_queue_release,
1935 .reta_update = lio_dev_rss_reta_update,
1936 .reta_query = lio_dev_rss_reta_query,
1937 .rss_hash_conf_get = lio_dev_rss_hash_conf_get,
1938 .rss_hash_update = lio_dev_rss_hash_update,
1939 .udp_tunnel_port_add = lio_dev_udp_tunnel_add,
1940 .udp_tunnel_port_del = lio_dev_udp_tunnel_del,
1941 .mtu_set = lio_dev_mtu_set,
1945 lio_check_pf_hs_response(void *lio_dev)
1947 struct lio_device *dev = lio_dev;
1949 /* check till response arrives */
1950 if (dev->pfvf_hsword.coproc_tics_per_us)
1953 cn23xx_vf_handle_mbox(dev);
1955 rte_eal_alarm_set(1, lio_check_pf_hs_response, lio_dev);
1959 * \brief Identify the LIO device and to map the BAR address space
1960 * @param lio_dev lio device
1963 lio_chip_specific_setup(struct lio_device *lio_dev)
1965 struct rte_pci_device *pdev = lio_dev->pci_dev;
1966 uint32_t dev_id = pdev->id.device_id;
1971 case LIO_CN23XX_VF_VID:
1972 lio_dev->chip_id = LIO_CN23XX_VF_VID;
1973 ret = cn23xx_vf_setup_device(lio_dev);
1978 lio_dev_err(lio_dev, "Unsupported Chip\n");
1982 lio_dev_info(lio_dev, "DEVICE : %s\n", s);
1988 lio_first_time_init(struct lio_device *lio_dev,
1989 struct rte_pci_device *pdev)
1993 PMD_INIT_FUNC_TRACE();
1995 /* set dpdk specific pci device pointer */
1996 lio_dev->pci_dev = pdev;
1998 /* Identify the LIO type and set device ops */
1999 if (lio_chip_specific_setup(lio_dev)) {
2000 lio_dev_err(lio_dev, "Chip specific setup failed\n");
2004 /* Initialize soft command buffer pool */
2005 if (lio_setup_sc_buffer_pool(lio_dev)) {
2006 lio_dev_err(lio_dev, "sc buffer pool allocation failed\n");
2010 /* Initialize lists to manage the requests of different types that
2011 * arrive from applications for this lio device.
2013 lio_setup_response_list(lio_dev);
2015 if (lio_dev->fn_list.setup_mbox(lio_dev)) {
2016 lio_dev_err(lio_dev, "Mailbox setup failed\n");
2020 /* Check PF response */
2021 lio_check_pf_hs_response((void *)lio_dev);
2023 /* Do handshake and exit if incompatible PF driver */
2024 if (cn23xx_pfvf_handshake(lio_dev))
2027 /* Request and wait for device reset. */
2028 if (pdev->kdrv == RTE_PCI_KDRV_IGB_UIO) {
2029 cn23xx_vf_ask_pf_to_do_flr(lio_dev);
2030 /* FLR wait time doubled as a precaution. */
2031 rte_delay_ms(LIO_PCI_FLR_WAIT * 2);
2034 if (lio_dev->fn_list.setup_device_regs(lio_dev)) {
2035 lio_dev_err(lio_dev, "Failed to configure device registers\n");
2039 if (lio_setup_instr_queue0(lio_dev)) {
2040 lio_dev_err(lio_dev, "Failed to setup instruction queue 0\n");
2044 dpdk_queues = (int)lio_dev->sriov_info.rings_per_vf;
2046 lio_dev->max_tx_queues = dpdk_queues;
2047 lio_dev->max_rx_queues = dpdk_queues;
2049 /* Enable input and output queues for this device */
2050 if (lio_dev->fn_list.enable_io_queues(lio_dev))
2056 lio_free_sc_buffer_pool(lio_dev);
2057 if (lio_dev->mbox[0])
2058 lio_dev->fn_list.free_mbox(lio_dev);
2059 if (lio_dev->instr_queue[0])
2060 lio_free_instr_queue0(lio_dev);
2066 lio_eth_dev_uninit(struct rte_eth_dev *eth_dev)
2068 struct lio_device *lio_dev = LIO_DEV(eth_dev);
2070 PMD_INIT_FUNC_TRACE();
2072 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
2075 /* lio_free_sc_buffer_pool */
2076 lio_free_sc_buffer_pool(lio_dev);
2082 lio_eth_dev_init(struct rte_eth_dev *eth_dev)
2084 struct rte_pci_device *pdev = RTE_ETH_DEV_TO_PCI(eth_dev);
2085 struct lio_device *lio_dev = LIO_DEV(eth_dev);
2087 PMD_INIT_FUNC_TRACE();
2089 eth_dev->rx_pkt_burst = &lio_dev_recv_pkts;
2090 eth_dev->tx_pkt_burst = &lio_dev_xmit_pkts;
2092 /* Primary does the initialization. */
2093 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
2096 rte_eth_copy_pci_info(eth_dev, pdev);
2097 eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
2099 if (pdev->mem_resource[0].addr) {
2100 lio_dev->hw_addr = pdev->mem_resource[0].addr;
2102 PMD_INIT_LOG(ERR, "ERROR: Failed to map BAR0\n");
2106 lio_dev->eth_dev = eth_dev;
2107 /* set lio device print string */
2108 snprintf(lio_dev->dev_string, sizeof(lio_dev->dev_string),
2109 "%s[%02x:%02x.%x]", pdev->driver->driver.name,
2110 pdev->addr.bus, pdev->addr.devid, pdev->addr.function);
2112 lio_dev->port_id = eth_dev->data->port_id;
2114 if (lio_first_time_init(lio_dev, pdev)) {
2115 lio_dev_err(lio_dev, "Device init failed\n");
2119 eth_dev->dev_ops = &liovf_eth_dev_ops;
2120 eth_dev->data->mac_addrs = rte_zmalloc("lio", RTE_ETHER_ADDR_LEN, 0);
2121 if (eth_dev->data->mac_addrs == NULL) {
2122 lio_dev_err(lio_dev,
2123 "MAC addresses memory allocation failed\n");
2124 eth_dev->dev_ops = NULL;
2125 eth_dev->rx_pkt_burst = NULL;
2126 eth_dev->tx_pkt_burst = NULL;
2130 rte_atomic64_set(&lio_dev->status, LIO_DEV_RUNNING);
2133 lio_dev->port_configured = 0;
2134 /* Always allow unicast packets */
2135 lio_dev->ifflags |= LIO_IFFLAG_UNICAST;
2141 lio_eth_dev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
2142 struct rte_pci_device *pci_dev)
2144 return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct lio_device),
2149 lio_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
2151 return rte_eth_dev_pci_generic_remove(pci_dev,
2152 lio_eth_dev_uninit);
2155 /* Set of PCI devices this driver supports */
2156 static const struct rte_pci_id pci_id_liovf_map[] = {
2157 { RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_VF_VID) },
2158 { .vendor_id = 0, /* sentinel */ }
2161 static struct rte_pci_driver rte_liovf_pmd = {
2162 .id_table = pci_id_liovf_map,
2163 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
2164 .probe = lio_eth_dev_pci_probe,
2165 .remove = lio_eth_dev_pci_remove,
2168 RTE_PMD_REGISTER_PCI(net_liovf, rte_liovf_pmd);
2169 RTE_PMD_REGISTER_PCI_TABLE(net_liovf, pci_id_liovf_map);
2170 RTE_PMD_REGISTER_KMOD_DEP(net_liovf, "* igb_uio | vfio-pci");
2171 RTE_LOG_REGISTER(lio_logtype_init, pmd.net.liquidio.init, NOTICE);
2172 RTE_LOG_REGISTER(lio_logtype_driver, pmd.net.liquidio.driver, NOTICE);