1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Cavium, Inc
5 #include <rte_string_fns.h>
6 #include <rte_ethdev_driver.h>
7 #include <rte_ethdev_pci.h>
8 #include <rte_cycles.h>
9 #include <rte_malloc.h>
10 #include <rte_alarm.h>
11 #include <rte_ether.h>
14 #include "lio_23xx_vf.h"
15 #include "lio_ethdev.h"
19 int lio_logtype_driver;
21 /* Default RSS key in use */
22 static uint8_t lio_rss_key[40] = {
23 0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2,
24 0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0,
25 0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4,
26 0x77, 0xCB, 0x2D, 0xA3, 0x80, 0x30, 0xF2, 0x0C,
27 0x6A, 0x42, 0xB7, 0x3B, 0xBE, 0xAC, 0x01, 0xFA,
30 static const struct rte_eth_desc_lim lio_rx_desc_lim = {
31 .nb_max = CN23XX_MAX_OQ_DESCRIPTORS,
32 .nb_min = CN23XX_MIN_OQ_DESCRIPTORS,
36 static const struct rte_eth_desc_lim lio_tx_desc_lim = {
37 .nb_max = CN23XX_MAX_IQ_DESCRIPTORS,
38 .nb_min = CN23XX_MIN_IQ_DESCRIPTORS,
42 /* Wait for control command to reach nic. */
44 lio_wait_for_ctrl_cmd(struct lio_device *lio_dev,
45 struct lio_dev_ctrl_cmd *ctrl_cmd)
47 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
49 while ((ctrl_cmd->cond == 0) && --timeout) {
50 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
58 * \brief Send Rx control command
59 * @param eth_dev Pointer to the structure rte_eth_dev
60 * @param start_stop whether to start or stop
63 lio_send_rx_ctrl_cmd(struct rte_eth_dev *eth_dev, int start_stop)
65 struct lio_device *lio_dev = LIO_DEV(eth_dev);
66 struct lio_dev_ctrl_cmd ctrl_cmd;
67 struct lio_ctrl_pkt ctrl_pkt;
69 /* flush added to prevent cmd failure
70 * incase the queue is full
72 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
74 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
75 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
77 ctrl_cmd.eth_dev = eth_dev;
80 ctrl_pkt.ncmd.s.cmd = LIO_CMD_RX_CTL;
81 ctrl_pkt.ncmd.s.param1 = start_stop;
82 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
84 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
85 lio_dev_err(lio_dev, "Failed to send RX Control message\n");
89 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
90 lio_dev_err(lio_dev, "RX Control command timed out\n");
97 /* store statistics names and its offset in stats structure */
98 struct rte_lio_xstats_name_off {
99 char name[RTE_ETH_XSTATS_NAME_SIZE];
103 static const struct rte_lio_xstats_name_off rte_lio_stats_strings[] = {
104 {"rx_pkts", offsetof(struct octeon_rx_stats, total_rcvd)},
105 {"rx_bytes", offsetof(struct octeon_rx_stats, bytes_rcvd)},
106 {"rx_broadcast_pkts", offsetof(struct octeon_rx_stats, total_bcst)},
107 {"rx_multicast_pkts", offsetof(struct octeon_rx_stats, total_mcst)},
108 {"rx_flow_ctrl_pkts", offsetof(struct octeon_rx_stats, ctl_rcvd)},
109 {"rx_fifo_err", offsetof(struct octeon_rx_stats, fifo_err)},
110 {"rx_dmac_drop", offsetof(struct octeon_rx_stats, dmac_drop)},
111 {"rx_fcs_err", offsetof(struct octeon_rx_stats, fcs_err)},
112 {"rx_jabber_err", offsetof(struct octeon_rx_stats, jabber_err)},
113 {"rx_l2_err", offsetof(struct octeon_rx_stats, l2_err)},
114 {"rx_vxlan_pkts", offsetof(struct octeon_rx_stats, fw_rx_vxlan)},
115 {"rx_vxlan_err", offsetof(struct octeon_rx_stats, fw_rx_vxlan_err)},
116 {"rx_lro_pkts", offsetof(struct octeon_rx_stats, fw_lro_pkts)},
117 {"tx_pkts", (offsetof(struct octeon_tx_stats, total_pkts_sent)) +
118 sizeof(struct octeon_rx_stats)},
119 {"tx_bytes", (offsetof(struct octeon_tx_stats, total_bytes_sent)) +
120 sizeof(struct octeon_rx_stats)},
121 {"tx_broadcast_pkts",
122 (offsetof(struct octeon_tx_stats, bcast_pkts_sent)) +
123 sizeof(struct octeon_rx_stats)},
124 {"tx_multicast_pkts",
125 (offsetof(struct octeon_tx_stats, mcast_pkts_sent)) +
126 sizeof(struct octeon_rx_stats)},
127 {"tx_flow_ctrl_pkts", (offsetof(struct octeon_tx_stats, ctl_sent)) +
128 sizeof(struct octeon_rx_stats)},
129 {"tx_fifo_err", (offsetof(struct octeon_tx_stats, fifo_err)) +
130 sizeof(struct octeon_rx_stats)},
131 {"tx_total_collisions", (offsetof(struct octeon_tx_stats,
133 sizeof(struct octeon_rx_stats)},
134 {"tx_tso", (offsetof(struct octeon_tx_stats, fw_tso)) +
135 sizeof(struct octeon_rx_stats)},
136 {"tx_vxlan_pkts", (offsetof(struct octeon_tx_stats, fw_tx_vxlan)) +
137 sizeof(struct octeon_rx_stats)},
140 #define LIO_NB_XSTATS RTE_DIM(rte_lio_stats_strings)
142 /* Get hw stats of the port */
144 lio_dev_xstats_get(struct rte_eth_dev *eth_dev, struct rte_eth_xstat *xstats,
147 struct lio_device *lio_dev = LIO_DEV(eth_dev);
148 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
149 struct octeon_link_stats *hw_stats;
150 struct lio_link_stats_resp *resp;
151 struct lio_soft_command *sc;
156 if (!lio_dev->intf_open) {
157 lio_dev_err(lio_dev, "Port %d down\n",
162 if (n < LIO_NB_XSTATS)
163 return LIO_NB_XSTATS;
165 resp_size = sizeof(struct lio_link_stats_resp);
166 sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
170 resp = (struct lio_link_stats_resp *)sc->virtrptr;
171 lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
172 LIO_OPCODE_PORT_STATS, 0, 0, 0);
174 /* Setting wait time in seconds */
175 sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
177 retval = lio_send_soft_command(lio_dev, sc);
178 if (retval == LIO_IQ_SEND_FAILED) {
179 lio_dev_err(lio_dev, "failed to get port stats from firmware. status: %x\n",
184 while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
185 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
186 lio_process_ordered_list(lio_dev);
190 retval = resp->status;
192 lio_dev_err(lio_dev, "failed to get port stats from firmware\n");
196 lio_swap_8B_data((uint64_t *)(&resp->link_stats),
197 sizeof(struct octeon_link_stats) >> 3);
199 hw_stats = &resp->link_stats;
201 for (i = 0; i < LIO_NB_XSTATS; i++) {
204 *(uint64_t *)(((char *)hw_stats) +
205 rte_lio_stats_strings[i].offset);
208 lio_free_soft_command(sc);
210 return LIO_NB_XSTATS;
213 lio_free_soft_command(sc);
219 lio_dev_xstats_get_names(struct rte_eth_dev *eth_dev,
220 struct rte_eth_xstat_name *xstats_names,
221 unsigned limit __rte_unused)
223 struct lio_device *lio_dev = LIO_DEV(eth_dev);
226 if (!lio_dev->intf_open) {
227 lio_dev_err(lio_dev, "Port %d down\n",
232 if (xstats_names == NULL)
233 return LIO_NB_XSTATS;
235 /* Note: limit checked in rte_eth_xstats_names() */
237 for (i = 0; i < LIO_NB_XSTATS; i++) {
238 snprintf(xstats_names[i].name, sizeof(xstats_names[i].name),
239 "%s", rte_lio_stats_strings[i].name);
242 return LIO_NB_XSTATS;
245 /* Reset hw stats for the port */
247 lio_dev_xstats_reset(struct rte_eth_dev *eth_dev)
249 struct lio_device *lio_dev = LIO_DEV(eth_dev);
250 struct lio_dev_ctrl_cmd ctrl_cmd;
251 struct lio_ctrl_pkt ctrl_pkt;
253 if (!lio_dev->intf_open) {
254 lio_dev_err(lio_dev, "Port %d down\n",
259 /* flush added to prevent cmd failure
260 * incase the queue is full
262 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
264 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
265 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
267 ctrl_cmd.eth_dev = eth_dev;
270 ctrl_pkt.ncmd.s.cmd = LIO_CMD_CLEAR_STATS;
271 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
273 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
274 lio_dev_err(lio_dev, "Failed to send clear stats command\n");
278 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
279 lio_dev_err(lio_dev, "Clear stats command timed out\n");
283 /* clear stored per queue stats */
284 RTE_FUNC_PTR_OR_RET(*eth_dev->dev_ops->stats_reset);
285 (*eth_dev->dev_ops->stats_reset)(eth_dev);
288 /* Retrieve the device statistics (# packets in/out, # bytes in/out, etc */
290 lio_dev_stats_get(struct rte_eth_dev *eth_dev,
291 struct rte_eth_stats *stats)
293 struct lio_device *lio_dev = LIO_DEV(eth_dev);
294 struct lio_droq_stats *oq_stats;
295 struct lio_iq_stats *iq_stats;
296 struct lio_instr_queue *txq;
297 struct lio_droq *droq;
303 for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
304 iq_no = lio_dev->linfo.txpciq[i].s.q_no;
305 txq = lio_dev->instr_queue[iq_no];
307 iq_stats = &txq->stats;
308 pkts += iq_stats->tx_done;
309 drop += iq_stats->tx_dropped;
310 bytes += iq_stats->tx_tot_bytes;
314 stats->opackets = pkts;
315 stats->obytes = bytes;
316 stats->oerrors = drop;
322 for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
323 oq_no = lio_dev->linfo.rxpciq[i].s.q_no;
324 droq = lio_dev->droq[oq_no];
326 oq_stats = &droq->stats;
327 pkts += oq_stats->rx_pkts_received;
328 drop += (oq_stats->rx_dropped +
329 oq_stats->dropped_toomany +
330 oq_stats->dropped_nomem);
331 bytes += oq_stats->rx_bytes_received;
334 stats->ibytes = bytes;
335 stats->ipackets = pkts;
336 stats->ierrors = drop;
342 lio_dev_stats_reset(struct rte_eth_dev *eth_dev)
344 struct lio_device *lio_dev = LIO_DEV(eth_dev);
345 struct lio_droq_stats *oq_stats;
346 struct lio_iq_stats *iq_stats;
347 struct lio_instr_queue *txq;
348 struct lio_droq *droq;
351 for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
352 iq_no = lio_dev->linfo.txpciq[i].s.q_no;
353 txq = lio_dev->instr_queue[iq_no];
355 iq_stats = &txq->stats;
356 memset(iq_stats, 0, sizeof(struct lio_iq_stats));
360 for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
361 oq_no = lio_dev->linfo.rxpciq[i].s.q_no;
362 droq = lio_dev->droq[oq_no];
364 oq_stats = &droq->stats;
365 memset(oq_stats, 0, sizeof(struct lio_droq_stats));
371 lio_dev_info_get(struct rte_eth_dev *eth_dev,
372 struct rte_eth_dev_info *devinfo)
374 struct lio_device *lio_dev = LIO_DEV(eth_dev);
375 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
377 switch (pci_dev->id.subsystem_device_id) {
378 /* CN23xx 10G cards */
379 case PCI_SUBSYS_DEV_ID_CN2350_210:
380 case PCI_SUBSYS_DEV_ID_CN2360_210:
381 case PCI_SUBSYS_DEV_ID_CN2350_210SVPN3:
382 case PCI_SUBSYS_DEV_ID_CN2360_210SVPN3:
383 case PCI_SUBSYS_DEV_ID_CN2350_210SVPT:
384 case PCI_SUBSYS_DEV_ID_CN2360_210SVPT:
385 devinfo->speed_capa = ETH_LINK_SPEED_10G;
387 /* CN23xx 25G cards */
388 case PCI_SUBSYS_DEV_ID_CN2350_225:
389 case PCI_SUBSYS_DEV_ID_CN2360_225:
390 devinfo->speed_capa = ETH_LINK_SPEED_25G;
393 devinfo->speed_capa = ETH_LINK_SPEED_10G;
395 "Unknown CN23XX subsystem device id. Setting 10G as default link speed.\n");
399 devinfo->max_rx_queues = lio_dev->max_rx_queues;
400 devinfo->max_tx_queues = lio_dev->max_tx_queues;
402 devinfo->min_rx_bufsize = LIO_MIN_RX_BUF_SIZE;
403 devinfo->max_rx_pktlen = LIO_MAX_RX_PKTLEN;
405 devinfo->max_mac_addrs = 1;
407 devinfo->rx_offload_capa = (DEV_RX_OFFLOAD_IPV4_CKSUM |
408 DEV_RX_OFFLOAD_UDP_CKSUM |
409 DEV_RX_OFFLOAD_TCP_CKSUM |
410 DEV_RX_OFFLOAD_VLAN_STRIP);
411 devinfo->tx_offload_capa = (DEV_TX_OFFLOAD_IPV4_CKSUM |
412 DEV_TX_OFFLOAD_UDP_CKSUM |
413 DEV_TX_OFFLOAD_TCP_CKSUM |
414 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM);
416 devinfo->rx_desc_lim = lio_rx_desc_lim;
417 devinfo->tx_desc_lim = lio_tx_desc_lim;
419 devinfo->reta_size = LIO_RSS_MAX_TABLE_SZ;
420 devinfo->hash_key_size = LIO_RSS_MAX_KEY_SZ;
421 devinfo->flow_type_rss_offloads = (ETH_RSS_IPV4 |
422 ETH_RSS_NONFRAG_IPV4_TCP |
424 ETH_RSS_NONFRAG_IPV6_TCP |
426 ETH_RSS_IPV6_TCP_EX);
431 lio_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu)
433 struct lio_device *lio_dev = LIO_DEV(eth_dev);
434 uint16_t pf_mtu = lio_dev->linfo.link.s.mtu;
435 uint32_t frame_len = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
436 struct lio_dev_ctrl_cmd ctrl_cmd;
437 struct lio_ctrl_pkt ctrl_pkt;
439 PMD_INIT_FUNC_TRACE();
441 if (!lio_dev->intf_open) {
442 lio_dev_err(lio_dev, "Port %d down, can't set MTU\n",
447 /* check if VF MTU is within allowed range.
448 * New value should not exceed PF MTU.
450 if (mtu < RTE_ETHER_MIN_MTU || mtu > pf_mtu) {
451 lio_dev_err(lio_dev, "VF MTU should be >= %d and <= %d\n",
452 RTE_ETHER_MIN_MTU, pf_mtu);
456 /* flush added to prevent cmd failure
457 * incase the queue is full
459 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
461 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
462 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
464 ctrl_cmd.eth_dev = eth_dev;
467 ctrl_pkt.ncmd.s.cmd = LIO_CMD_CHANGE_MTU;
468 ctrl_pkt.ncmd.s.param1 = mtu;
469 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
471 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
472 lio_dev_err(lio_dev, "Failed to send command to change MTU\n");
476 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
477 lio_dev_err(lio_dev, "Command to change MTU timed out\n");
481 if (frame_len > RTE_ETHER_MAX_LEN)
482 eth_dev->data->dev_conf.rxmode.offloads |=
483 DEV_RX_OFFLOAD_JUMBO_FRAME;
485 eth_dev->data->dev_conf.rxmode.offloads &=
486 ~DEV_RX_OFFLOAD_JUMBO_FRAME;
488 eth_dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_len;
489 eth_dev->data->mtu = mtu;
495 lio_dev_rss_reta_update(struct rte_eth_dev *eth_dev,
496 struct rte_eth_rss_reta_entry64 *reta_conf,
499 struct lio_device *lio_dev = LIO_DEV(eth_dev);
500 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
501 struct lio_rss_set *rss_param;
502 struct lio_dev_ctrl_cmd ctrl_cmd;
503 struct lio_ctrl_pkt ctrl_pkt;
506 if (!lio_dev->intf_open) {
507 lio_dev_err(lio_dev, "Port %d down, can't update reta\n",
512 if (reta_size != LIO_RSS_MAX_TABLE_SZ) {
514 "The size of hash lookup table configured (%d) doesn't match the number hardware can supported (%d)\n",
515 reta_size, LIO_RSS_MAX_TABLE_SZ);
519 /* flush added to prevent cmd failure
520 * incase the queue is full
522 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
524 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
525 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
527 rss_param = (struct lio_rss_set *)&ctrl_pkt.udd[0];
529 ctrl_cmd.eth_dev = eth_dev;
532 ctrl_pkt.ncmd.s.cmd = LIO_CMD_SET_RSS;
533 ctrl_pkt.ncmd.s.more = sizeof(struct lio_rss_set) >> 3;
534 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
536 rss_param->param.flags = 0xF;
537 rss_param->param.flags &= ~LIO_RSS_PARAM_ITABLE_UNCHANGED;
538 rss_param->param.itablesize = LIO_RSS_MAX_TABLE_SZ;
540 for (i = 0; i < (reta_size / RTE_RETA_GROUP_SIZE); i++) {
541 for (j = 0; j < RTE_RETA_GROUP_SIZE; j++) {
542 if ((reta_conf[i].mask) & ((uint64_t)1 << j)) {
543 index = (i * RTE_RETA_GROUP_SIZE) + j;
544 rss_state->itable[index] = reta_conf[i].reta[j];
549 rss_state->itable_size = LIO_RSS_MAX_TABLE_SZ;
550 memcpy(rss_param->itable, rss_state->itable, rss_state->itable_size);
552 lio_swap_8B_data((uint64_t *)rss_param, LIO_RSS_PARAM_SIZE >> 3);
554 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
555 lio_dev_err(lio_dev, "Failed to set rss hash\n");
559 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
560 lio_dev_err(lio_dev, "Set rss hash timed out\n");
568 lio_dev_rss_reta_query(struct rte_eth_dev *eth_dev,
569 struct rte_eth_rss_reta_entry64 *reta_conf,
572 struct lio_device *lio_dev = LIO_DEV(eth_dev);
573 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
576 if (reta_size != LIO_RSS_MAX_TABLE_SZ) {
578 "The size of hash lookup table configured (%d) doesn't match the number hardware can supported (%d)\n",
579 reta_size, LIO_RSS_MAX_TABLE_SZ);
583 num = reta_size / RTE_RETA_GROUP_SIZE;
585 for (i = 0; i < num; i++) {
586 memcpy(reta_conf->reta,
587 &rss_state->itable[i * RTE_RETA_GROUP_SIZE],
588 RTE_RETA_GROUP_SIZE);
596 lio_dev_rss_hash_conf_get(struct rte_eth_dev *eth_dev,
597 struct rte_eth_rss_conf *rss_conf)
599 struct lio_device *lio_dev = LIO_DEV(eth_dev);
600 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
601 uint8_t *hash_key = NULL;
604 if (rss_state->hash_disable) {
605 lio_dev_info(lio_dev, "RSS disabled in nic\n");
606 rss_conf->rss_hf = 0;
611 hash_key = rss_conf->rss_key;
612 if (hash_key != NULL)
613 memcpy(hash_key, rss_state->hash_key, rss_state->hash_key_size);
616 rss_hf |= ETH_RSS_IPV4;
617 if (rss_state->tcp_hash)
618 rss_hf |= ETH_RSS_NONFRAG_IPV4_TCP;
620 rss_hf |= ETH_RSS_IPV6;
621 if (rss_state->ipv6_tcp_hash)
622 rss_hf |= ETH_RSS_NONFRAG_IPV6_TCP;
623 if (rss_state->ipv6_ex)
624 rss_hf |= ETH_RSS_IPV6_EX;
625 if (rss_state->ipv6_tcp_ex_hash)
626 rss_hf |= ETH_RSS_IPV6_TCP_EX;
628 rss_conf->rss_hf = rss_hf;
634 lio_dev_rss_hash_update(struct rte_eth_dev *eth_dev,
635 struct rte_eth_rss_conf *rss_conf)
637 struct lio_device *lio_dev = LIO_DEV(eth_dev);
638 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
639 struct lio_rss_set *rss_param;
640 struct lio_dev_ctrl_cmd ctrl_cmd;
641 struct lio_ctrl_pkt ctrl_pkt;
643 if (!lio_dev->intf_open) {
644 lio_dev_err(lio_dev, "Port %d down, can't update hash\n",
649 /* flush added to prevent cmd failure
650 * incase the queue is full
652 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
654 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
655 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
657 rss_param = (struct lio_rss_set *)&ctrl_pkt.udd[0];
659 ctrl_cmd.eth_dev = eth_dev;
662 ctrl_pkt.ncmd.s.cmd = LIO_CMD_SET_RSS;
663 ctrl_pkt.ncmd.s.more = sizeof(struct lio_rss_set) >> 3;
664 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
666 rss_param->param.flags = 0xF;
668 if (rss_conf->rss_key) {
669 rss_param->param.flags &= ~LIO_RSS_PARAM_HASH_KEY_UNCHANGED;
670 rss_state->hash_key_size = LIO_RSS_MAX_KEY_SZ;
671 rss_param->param.hashkeysize = LIO_RSS_MAX_KEY_SZ;
672 memcpy(rss_state->hash_key, rss_conf->rss_key,
673 rss_state->hash_key_size);
674 memcpy(rss_param->key, rss_state->hash_key,
675 rss_state->hash_key_size);
678 if ((rss_conf->rss_hf & LIO_RSS_OFFLOAD_ALL) == 0) {
679 /* Can't disable rss through hash flags,
680 * if it is enabled by default during init
682 if (!rss_state->hash_disable)
685 /* This is for --disable-rss during testpmd launch */
686 rss_param->param.flags |= LIO_RSS_PARAM_DISABLE_RSS;
688 uint32_t hashinfo = 0;
690 /* Can't enable rss if disabled by default during init */
691 if (rss_state->hash_disable)
694 if (rss_conf->rss_hf & ETH_RSS_IPV4) {
695 hashinfo |= LIO_RSS_HASH_IPV4;
701 if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV4_TCP) {
702 hashinfo |= LIO_RSS_HASH_TCP_IPV4;
703 rss_state->tcp_hash = 1;
705 rss_state->tcp_hash = 0;
708 if (rss_conf->rss_hf & ETH_RSS_IPV6) {
709 hashinfo |= LIO_RSS_HASH_IPV6;
715 if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV6_TCP) {
716 hashinfo |= LIO_RSS_HASH_TCP_IPV6;
717 rss_state->ipv6_tcp_hash = 1;
719 rss_state->ipv6_tcp_hash = 0;
722 if (rss_conf->rss_hf & ETH_RSS_IPV6_EX) {
723 hashinfo |= LIO_RSS_HASH_IPV6_EX;
724 rss_state->ipv6_ex = 1;
726 rss_state->ipv6_ex = 0;
729 if (rss_conf->rss_hf & ETH_RSS_IPV6_TCP_EX) {
730 hashinfo |= LIO_RSS_HASH_TCP_IPV6_EX;
731 rss_state->ipv6_tcp_ex_hash = 1;
733 rss_state->ipv6_tcp_ex_hash = 0;
736 rss_param->param.flags &= ~LIO_RSS_PARAM_HASH_INFO_UNCHANGED;
737 rss_param->param.hashinfo = hashinfo;
740 lio_swap_8B_data((uint64_t *)rss_param, LIO_RSS_PARAM_SIZE >> 3);
742 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
743 lio_dev_err(lio_dev, "Failed to set rss hash\n");
747 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
748 lio_dev_err(lio_dev, "Set rss hash timed out\n");
756 * Add vxlan dest udp port for an interface.
759 * Pointer to the structure rte_eth_dev
764 * On success return 0
765 * On failure return -1
768 lio_dev_udp_tunnel_add(struct rte_eth_dev *eth_dev,
769 struct rte_eth_udp_tunnel *udp_tnl)
771 struct lio_device *lio_dev = LIO_DEV(eth_dev);
772 struct lio_dev_ctrl_cmd ctrl_cmd;
773 struct lio_ctrl_pkt ctrl_pkt;
778 if (udp_tnl->prot_type != RTE_TUNNEL_TYPE_VXLAN) {
779 lio_dev_err(lio_dev, "Unsupported tunnel type\n");
783 /* flush added to prevent cmd failure
784 * incase the queue is full
786 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
788 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
789 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
791 ctrl_cmd.eth_dev = eth_dev;
794 ctrl_pkt.ncmd.s.cmd = LIO_CMD_VXLAN_PORT_CONFIG;
795 ctrl_pkt.ncmd.s.param1 = udp_tnl->udp_port;
796 ctrl_pkt.ncmd.s.more = LIO_CMD_VXLAN_PORT_ADD;
797 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
799 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
800 lio_dev_err(lio_dev, "Failed to send VXLAN_PORT_ADD command\n");
804 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
805 lio_dev_err(lio_dev, "VXLAN_PORT_ADD command timed out\n");
813 * Remove vxlan dest udp port for an interface.
816 * Pointer to the structure rte_eth_dev
821 * On success return 0
822 * On failure return -1
825 lio_dev_udp_tunnel_del(struct rte_eth_dev *eth_dev,
826 struct rte_eth_udp_tunnel *udp_tnl)
828 struct lio_device *lio_dev = LIO_DEV(eth_dev);
829 struct lio_dev_ctrl_cmd ctrl_cmd;
830 struct lio_ctrl_pkt ctrl_pkt;
835 if (udp_tnl->prot_type != RTE_TUNNEL_TYPE_VXLAN) {
836 lio_dev_err(lio_dev, "Unsupported tunnel type\n");
840 /* flush added to prevent cmd failure
841 * incase the queue is full
843 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
845 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
846 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
848 ctrl_cmd.eth_dev = eth_dev;
851 ctrl_pkt.ncmd.s.cmd = LIO_CMD_VXLAN_PORT_CONFIG;
852 ctrl_pkt.ncmd.s.param1 = udp_tnl->udp_port;
853 ctrl_pkt.ncmd.s.more = LIO_CMD_VXLAN_PORT_DEL;
854 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
856 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
857 lio_dev_err(lio_dev, "Failed to send VXLAN_PORT_DEL command\n");
861 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
862 lio_dev_err(lio_dev, "VXLAN_PORT_DEL command timed out\n");
870 lio_dev_vlan_filter_set(struct rte_eth_dev *eth_dev, uint16_t vlan_id, int on)
872 struct lio_device *lio_dev = LIO_DEV(eth_dev);
873 struct lio_dev_ctrl_cmd ctrl_cmd;
874 struct lio_ctrl_pkt ctrl_pkt;
876 if (lio_dev->linfo.vlan_is_admin_assigned)
879 /* flush added to prevent cmd failure
880 * incase the queue is full
882 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
884 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
885 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
887 ctrl_cmd.eth_dev = eth_dev;
890 ctrl_pkt.ncmd.s.cmd = on ?
891 LIO_CMD_ADD_VLAN_FILTER : LIO_CMD_DEL_VLAN_FILTER;
892 ctrl_pkt.ncmd.s.param1 = vlan_id;
893 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
895 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
896 lio_dev_err(lio_dev, "Failed to %s VLAN port\n",
897 on ? "add" : "remove");
901 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
902 lio_dev_err(lio_dev, "Command to %s VLAN port timed out\n",
903 on ? "add" : "remove");
911 lio_hweight64(uint64_t w)
913 uint64_t res = w - ((w >> 1) & 0x5555555555555555ul);
916 (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul);
917 res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful;
918 res = res + (res >> 8);
919 res = res + (res >> 16);
921 return (res + (res >> 32)) & 0x00000000000000FFul;
925 lio_dev_link_update(struct rte_eth_dev *eth_dev,
926 int wait_to_complete __rte_unused)
928 struct lio_device *lio_dev = LIO_DEV(eth_dev);
929 struct rte_eth_link link;
932 memset(&link, 0, sizeof(link));
933 link.link_status = ETH_LINK_DOWN;
934 link.link_speed = ETH_SPEED_NUM_NONE;
935 link.link_duplex = ETH_LINK_HALF_DUPLEX;
936 link.link_autoneg = ETH_LINK_AUTONEG;
938 /* Return what we found */
939 if (lio_dev->linfo.link.s.link_up == 0) {
940 /* Interface is down */
941 return rte_eth_linkstatus_set(eth_dev, &link);
944 link.link_status = ETH_LINK_UP; /* Interface is up */
945 link.link_duplex = ETH_LINK_FULL_DUPLEX;
946 switch (lio_dev->linfo.link.s.speed) {
947 case LIO_LINK_SPEED_10000:
948 link.link_speed = ETH_SPEED_NUM_10G;
950 case LIO_LINK_SPEED_25000:
951 link.link_speed = ETH_SPEED_NUM_25G;
954 link.link_speed = ETH_SPEED_NUM_NONE;
955 link.link_duplex = ETH_LINK_HALF_DUPLEX;
958 return rte_eth_linkstatus_set(eth_dev, &link);
962 * \brief Net device enable, disable allmulticast
963 * @param eth_dev Pointer to the structure rte_eth_dev
966 * On success return 0
967 * On failure return negative errno
970 lio_change_dev_flag(struct rte_eth_dev *eth_dev)
972 struct lio_device *lio_dev = LIO_DEV(eth_dev);
973 struct lio_dev_ctrl_cmd ctrl_cmd;
974 struct lio_ctrl_pkt ctrl_pkt;
976 /* flush added to prevent cmd failure
977 * incase the queue is full
979 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
981 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
982 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
984 ctrl_cmd.eth_dev = eth_dev;
987 /* Create a ctrl pkt command to be sent to core app. */
988 ctrl_pkt.ncmd.s.cmd = LIO_CMD_CHANGE_DEVFLAGS;
989 ctrl_pkt.ncmd.s.param1 = lio_dev->ifflags;
990 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
992 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
993 lio_dev_err(lio_dev, "Failed to send change flag message\n");
997 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
998 lio_dev_err(lio_dev, "Change dev flag command timed out\n");
1006 lio_dev_promiscuous_enable(struct rte_eth_dev *eth_dev)
1008 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1010 if (strcmp(lio_dev->firmware_version, LIO_VF_TRUST_MIN_VERSION) < 0) {
1011 lio_dev_err(lio_dev, "Require firmware version >= %s\n",
1012 LIO_VF_TRUST_MIN_VERSION);
1016 if (!lio_dev->intf_open) {
1017 lio_dev_err(lio_dev, "Port %d down, can't enable promiscuous\n",
1022 lio_dev->ifflags |= LIO_IFFLAG_PROMISC;
1023 return lio_change_dev_flag(eth_dev);
1027 lio_dev_promiscuous_disable(struct rte_eth_dev *eth_dev)
1029 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1031 if (strcmp(lio_dev->firmware_version, LIO_VF_TRUST_MIN_VERSION) < 0) {
1032 lio_dev_err(lio_dev, "Require firmware version >= %s\n",
1033 LIO_VF_TRUST_MIN_VERSION);
1037 if (!lio_dev->intf_open) {
1038 lio_dev_err(lio_dev, "Port %d down, can't disable promiscuous\n",
1043 lio_dev->ifflags &= ~LIO_IFFLAG_PROMISC;
1044 return lio_change_dev_flag(eth_dev);
1048 lio_dev_allmulticast_enable(struct rte_eth_dev *eth_dev)
1050 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1052 if (!lio_dev->intf_open) {
1053 lio_dev_err(lio_dev, "Port %d down, can't enable multicast\n",
1058 lio_dev->ifflags |= LIO_IFFLAG_ALLMULTI;
1059 lio_change_dev_flag(eth_dev);
1063 lio_dev_allmulticast_disable(struct rte_eth_dev *eth_dev)
1065 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1067 if (!lio_dev->intf_open) {
1068 lio_dev_err(lio_dev, "Port %d down, can't disable multicast\n",
1073 lio_dev->ifflags &= ~LIO_IFFLAG_ALLMULTI;
1074 lio_change_dev_flag(eth_dev);
1078 lio_dev_rss_configure(struct rte_eth_dev *eth_dev)
1080 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1081 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
1082 struct rte_eth_rss_reta_entry64 reta_conf[8];
1083 struct rte_eth_rss_conf rss_conf;
1086 /* Configure the RSS key and the RSS protocols used to compute
1087 * the RSS hash of input packets.
1089 rss_conf = eth_dev->data->dev_conf.rx_adv_conf.rss_conf;
1090 if ((rss_conf.rss_hf & LIO_RSS_OFFLOAD_ALL) == 0) {
1091 rss_state->hash_disable = 1;
1092 lio_dev_rss_hash_update(eth_dev, &rss_conf);
1096 if (rss_conf.rss_key == NULL)
1097 rss_conf.rss_key = lio_rss_key; /* Default hash key */
1099 lio_dev_rss_hash_update(eth_dev, &rss_conf);
1101 memset(reta_conf, 0, sizeof(reta_conf));
1102 for (i = 0; i < LIO_RSS_MAX_TABLE_SZ; i++) {
1103 uint8_t q_idx, conf_idx, reta_idx;
1105 q_idx = (uint8_t)((eth_dev->data->nb_rx_queues > 1) ?
1106 i % eth_dev->data->nb_rx_queues : 0);
1107 conf_idx = i / RTE_RETA_GROUP_SIZE;
1108 reta_idx = i % RTE_RETA_GROUP_SIZE;
1109 reta_conf[conf_idx].reta[reta_idx] = q_idx;
1110 reta_conf[conf_idx].mask |= ((uint64_t)1 << reta_idx);
1113 lio_dev_rss_reta_update(eth_dev, reta_conf, LIO_RSS_MAX_TABLE_SZ);
1117 lio_dev_mq_rx_configure(struct rte_eth_dev *eth_dev)
1119 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1120 struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
1121 struct rte_eth_rss_conf rss_conf;
1123 switch (eth_dev->data->dev_conf.rxmode.mq_mode) {
1125 lio_dev_rss_configure(eth_dev);
1127 case ETH_MQ_RX_NONE:
1128 /* if mq_mode is none, disable rss mode. */
1130 memset(&rss_conf, 0, sizeof(rss_conf));
1131 rss_state->hash_disable = 1;
1132 lio_dev_rss_hash_update(eth_dev, &rss_conf);
1137 * Setup our receive queue/ringbuffer. This is the
1138 * queue the Octeon uses to send us packets and
1139 * responses. We are given a memory pool for our
1140 * packet buffers that are used to populate the receive
1144 * Pointer to the structure rte_eth_dev
1147 * @param num_rx_descs
1148 * Number of entries in the queue
1150 * Where to allocate memory
1152 * Pointer to the struction rte_eth_rxconf
1154 * Pointer to the packet pool
1157 * - On success, return 0
1158 * - On failure, return -1
1161 lio_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t q_no,
1162 uint16_t num_rx_descs, unsigned int socket_id,
1163 const struct rte_eth_rxconf *rx_conf __rte_unused,
1164 struct rte_mempool *mp)
1166 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1167 struct rte_pktmbuf_pool_private *mbp_priv;
1168 uint32_t fw_mapped_oq;
1171 if (q_no >= lio_dev->nb_rx_queues) {
1172 lio_dev_err(lio_dev, "Invalid rx queue number %u\n", q_no);
1176 lio_dev_dbg(lio_dev, "setting up rx queue %u\n", q_no);
1178 fw_mapped_oq = lio_dev->linfo.rxpciq[q_no].s.q_no;
1180 /* Free previous allocation if any */
1181 if (eth_dev->data->rx_queues[q_no] != NULL) {
1182 lio_dev_rx_queue_release(eth_dev->data->rx_queues[q_no]);
1183 eth_dev->data->rx_queues[q_no] = NULL;
1186 mbp_priv = rte_mempool_get_priv(mp);
1187 buf_size = mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM;
1189 if (lio_setup_droq(lio_dev, fw_mapped_oq, num_rx_descs, buf_size, mp,
1191 lio_dev_err(lio_dev, "droq allocation failed\n");
1195 eth_dev->data->rx_queues[q_no] = lio_dev->droq[fw_mapped_oq];
1201 * Release the receive queue/ringbuffer. Called by
1205 * Opaque pointer to the receive queue to release
1211 lio_dev_rx_queue_release(void *rxq)
1213 struct lio_droq *droq = rxq;
1218 lio_delete_droq_queue(droq->lio_dev, oq_no);
1223 * Allocate and initialize SW ring. Initialize associated HW registers.
1226 * Pointer to structure rte_eth_dev
1231 * @param num_tx_descs
1232 * Number of ringbuffer descriptors
1235 * NUMA socket id, used for memory allocations
1238 * Pointer to the structure rte_eth_txconf
1241 * - On success, return 0
1242 * - On failure, return -errno value
1245 lio_dev_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t q_no,
1246 uint16_t num_tx_descs, unsigned int socket_id,
1247 const struct rte_eth_txconf *tx_conf __rte_unused)
1249 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1250 int fw_mapped_iq = lio_dev->linfo.txpciq[q_no].s.q_no;
1253 if (q_no >= lio_dev->nb_tx_queues) {
1254 lio_dev_err(lio_dev, "Invalid tx queue number %u\n", q_no);
1258 lio_dev_dbg(lio_dev, "setting up tx queue %u\n", q_no);
1260 /* Free previous allocation if any */
1261 if (eth_dev->data->tx_queues[q_no] != NULL) {
1262 lio_dev_tx_queue_release(eth_dev->data->tx_queues[q_no]);
1263 eth_dev->data->tx_queues[q_no] = NULL;
1266 retval = lio_setup_iq(lio_dev, q_no, lio_dev->linfo.txpciq[q_no],
1267 num_tx_descs, lio_dev, socket_id);
1270 lio_dev_err(lio_dev, "Runtime IQ(TxQ) creation failed.\n");
1274 retval = lio_setup_sglists(lio_dev, q_no, fw_mapped_iq,
1275 lio_dev->instr_queue[fw_mapped_iq]->nb_desc,
1279 lio_delete_instruction_queue(lio_dev, fw_mapped_iq);
1283 eth_dev->data->tx_queues[q_no] = lio_dev->instr_queue[fw_mapped_iq];
1289 * Release the transmit queue/ringbuffer. Called by
1293 * Opaque pointer to the transmit queue to release
1299 lio_dev_tx_queue_release(void *txq)
1301 struct lio_instr_queue *tq = txq;
1302 uint32_t fw_mapped_iq_no;
1307 lio_delete_sglist(tq);
1309 fw_mapped_iq_no = tq->txpciq.s.q_no;
1310 lio_delete_instruction_queue(tq->lio_dev, fw_mapped_iq_no);
1315 * Api to check link state.
1318 lio_dev_get_link_status(struct rte_eth_dev *eth_dev)
1320 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1321 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1322 struct lio_link_status_resp *resp;
1323 union octeon_link_status *ls;
1324 struct lio_soft_command *sc;
1327 if (!lio_dev->intf_open)
1330 resp_size = sizeof(struct lio_link_status_resp);
1331 sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
1335 resp = (struct lio_link_status_resp *)sc->virtrptr;
1336 lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
1337 LIO_OPCODE_INFO, 0, 0, 0);
1339 /* Setting wait time in seconds */
1340 sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
1342 if (lio_send_soft_command(lio_dev, sc) == LIO_IQ_SEND_FAILED)
1343 goto get_status_fail;
1345 while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
1346 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
1351 goto get_status_fail;
1353 ls = &resp->link_info.link;
1355 lio_swap_8B_data((uint64_t *)ls, sizeof(union octeon_link_status) >> 3);
1357 if (lio_dev->linfo.link.link_status64 != ls->link_status64) {
1358 if (ls->s.mtu < eth_dev->data->mtu) {
1359 lio_dev_info(lio_dev, "Lowered VF MTU to %d as PF MTU dropped\n",
1361 eth_dev->data->mtu = ls->s.mtu;
1363 lio_dev->linfo.link.link_status64 = ls->link_status64;
1364 lio_dev_link_update(eth_dev, 0);
1367 lio_free_soft_command(sc);
1372 lio_free_soft_command(sc);
1375 /* This function will be invoked every LSC_TIMEOUT ns (100ms)
1376 * and will update link state if it changes.
1379 lio_sync_link_state_check(void *eth_dev)
1381 struct lio_device *lio_dev =
1382 (((struct rte_eth_dev *)eth_dev)->data->dev_private);
1384 if (lio_dev->port_configured)
1385 lio_dev_get_link_status(eth_dev);
1387 /* Schedule periodic link status check.
1388 * Stop check if interface is close and start again while opening.
1390 if (lio_dev->intf_open)
1391 rte_eal_alarm_set(LIO_LSC_TIMEOUT, lio_sync_link_state_check,
1396 lio_dev_start(struct rte_eth_dev *eth_dev)
1399 uint32_t frame_len = eth_dev->data->dev_conf.rxmode.max_rx_pkt_len;
1400 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1401 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1404 lio_dev_info(lio_dev, "Starting port %d\n", eth_dev->data->port_id);
1406 if (lio_dev->fn_list.enable_io_queues(lio_dev))
1409 if (lio_send_rx_ctrl_cmd(eth_dev, 1))
1412 /* Ready for link status updates */
1413 lio_dev->intf_open = 1;
1416 /* Configure RSS if device configured with multiple RX queues. */
1417 lio_dev_mq_rx_configure(eth_dev);
1419 /* Before update the link info,
1420 * must set linfo.link.link_status64 to 0.
1422 lio_dev->linfo.link.link_status64 = 0;
1424 /* start polling for lsc */
1425 ret = rte_eal_alarm_set(LIO_LSC_TIMEOUT,
1426 lio_sync_link_state_check,
1429 lio_dev_err(lio_dev,
1430 "link state check handler creation failed\n");
1431 goto dev_lsc_handle_error;
1434 while ((lio_dev->linfo.link.link_status64 == 0) && (--timeout))
1437 if (lio_dev->linfo.link.link_status64 == 0) {
1439 goto dev_mtu_set_error;
1442 mtu = (uint16_t)(frame_len - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN);
1443 if (mtu < RTE_ETHER_MIN_MTU)
1444 mtu = RTE_ETHER_MIN_MTU;
1446 if (eth_dev->data->mtu != mtu) {
1447 ret = lio_dev_mtu_set(eth_dev, mtu);
1449 goto dev_mtu_set_error;
1455 rte_eal_alarm_cancel(lio_sync_link_state_check, eth_dev);
1457 dev_lsc_handle_error:
1458 lio_dev->intf_open = 0;
1459 lio_send_rx_ctrl_cmd(eth_dev, 0);
1464 /* Stop device and disable input/output functions */
1466 lio_dev_stop(struct rte_eth_dev *eth_dev)
1468 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1470 lio_dev_info(lio_dev, "Stopping port %d\n", eth_dev->data->port_id);
1471 lio_dev->intf_open = 0;
1474 /* Cancel callback if still running. */
1475 rte_eal_alarm_cancel(lio_sync_link_state_check, eth_dev);
1477 lio_send_rx_ctrl_cmd(eth_dev, 0);
1479 lio_wait_for_instr_fetch(lio_dev);
1481 /* Clear recorded link status */
1482 lio_dev->linfo.link.link_status64 = 0;
1486 lio_dev_set_link_up(struct rte_eth_dev *eth_dev)
1488 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1490 if (!lio_dev->intf_open) {
1491 lio_dev_info(lio_dev, "Port is stopped, Start the port first\n");
1495 if (lio_dev->linfo.link.s.link_up) {
1496 lio_dev_info(lio_dev, "Link is already UP\n");
1500 if (lio_send_rx_ctrl_cmd(eth_dev, 1)) {
1501 lio_dev_err(lio_dev, "Unable to set Link UP\n");
1505 lio_dev->linfo.link.s.link_up = 1;
1506 eth_dev->data->dev_link.link_status = ETH_LINK_UP;
1512 lio_dev_set_link_down(struct rte_eth_dev *eth_dev)
1514 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1516 if (!lio_dev->intf_open) {
1517 lio_dev_info(lio_dev, "Port is stopped, Start the port first\n");
1521 if (!lio_dev->linfo.link.s.link_up) {
1522 lio_dev_info(lio_dev, "Link is already DOWN\n");
1526 lio_dev->linfo.link.s.link_up = 0;
1527 eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
1529 if (lio_send_rx_ctrl_cmd(eth_dev, 0)) {
1530 lio_dev->linfo.link.s.link_up = 1;
1531 eth_dev->data->dev_link.link_status = ETH_LINK_UP;
1532 lio_dev_err(lio_dev, "Unable to set Link Down\n");
1540 * Reset and stop the device. This occurs on the first
1541 * call to this routine. Subsequent calls will simply
1542 * return. NB: This will require the NIC to be rebooted.
1545 * Pointer to the structure rte_eth_dev
1551 lio_dev_close(struct rte_eth_dev *eth_dev)
1553 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1555 lio_dev_info(lio_dev, "closing port %d\n", eth_dev->data->port_id);
1557 if (lio_dev->intf_open)
1558 lio_dev_stop(eth_dev);
1560 /* Reset ioq regs */
1561 lio_dev->fn_list.setup_device_regs(lio_dev);
1563 if (lio_dev->pci_dev->kdrv == RTE_KDRV_IGB_UIO) {
1564 cn23xx_vf_ask_pf_to_do_flr(lio_dev);
1565 rte_delay_ms(LIO_PCI_FLR_WAIT);
1569 lio_dev->fn_list.free_mbox(lio_dev);
1571 /* Free glist resources */
1572 rte_free(lio_dev->glist_head);
1573 rte_free(lio_dev->glist_lock);
1574 lio_dev->glist_head = NULL;
1575 lio_dev->glist_lock = NULL;
1577 lio_dev->port_configured = 0;
1579 /* Delete all queues */
1580 lio_dev_clear_queues(eth_dev);
1584 * Enable tunnel rx checksum verification from firmware.
1587 lio_enable_hw_tunnel_rx_checksum(struct rte_eth_dev *eth_dev)
1589 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1590 struct lio_dev_ctrl_cmd ctrl_cmd;
1591 struct lio_ctrl_pkt ctrl_pkt;
1593 /* flush added to prevent cmd failure
1594 * incase the queue is full
1596 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1598 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1599 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1601 ctrl_cmd.eth_dev = eth_dev;
1604 ctrl_pkt.ncmd.s.cmd = LIO_CMD_TNL_RX_CSUM_CTL;
1605 ctrl_pkt.ncmd.s.param1 = LIO_CMD_RXCSUM_ENABLE;
1606 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1608 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1609 lio_dev_err(lio_dev, "Failed to send TNL_RX_CSUM command\n");
1613 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd))
1614 lio_dev_err(lio_dev, "TNL_RX_CSUM command timed out\n");
1618 * Enable checksum calculation for inner packet in a tunnel.
1621 lio_enable_hw_tunnel_tx_checksum(struct rte_eth_dev *eth_dev)
1623 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1624 struct lio_dev_ctrl_cmd ctrl_cmd;
1625 struct lio_ctrl_pkt ctrl_pkt;
1627 /* flush added to prevent cmd failure
1628 * incase the queue is full
1630 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1632 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1633 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1635 ctrl_cmd.eth_dev = eth_dev;
1638 ctrl_pkt.ncmd.s.cmd = LIO_CMD_TNL_TX_CSUM_CTL;
1639 ctrl_pkt.ncmd.s.param1 = LIO_CMD_TXCSUM_ENABLE;
1640 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1642 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1643 lio_dev_err(lio_dev, "Failed to send TNL_TX_CSUM command\n");
1647 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd))
1648 lio_dev_err(lio_dev, "TNL_TX_CSUM command timed out\n");
1652 lio_send_queue_count_update(struct rte_eth_dev *eth_dev, int num_txq,
1655 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1656 struct lio_dev_ctrl_cmd ctrl_cmd;
1657 struct lio_ctrl_pkt ctrl_pkt;
1659 if (strcmp(lio_dev->firmware_version, LIO_Q_RECONF_MIN_VERSION) < 0) {
1660 lio_dev_err(lio_dev, "Require firmware version >= %s\n",
1661 LIO_Q_RECONF_MIN_VERSION);
1665 /* flush added to prevent cmd failure
1666 * incase the queue is full
1668 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
1670 memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
1671 memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
1673 ctrl_cmd.eth_dev = eth_dev;
1676 ctrl_pkt.ncmd.s.cmd = LIO_CMD_QUEUE_COUNT_CTL;
1677 ctrl_pkt.ncmd.s.param1 = num_txq;
1678 ctrl_pkt.ncmd.s.param2 = num_rxq;
1679 ctrl_pkt.ctrl_cmd = &ctrl_cmd;
1681 if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
1682 lio_dev_err(lio_dev, "Failed to send queue count control command\n");
1686 if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
1687 lio_dev_err(lio_dev, "Queue count control command timed out\n");
1695 lio_reconf_queues(struct rte_eth_dev *eth_dev, int num_txq, int num_rxq)
1697 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1699 if (lio_dev->nb_rx_queues != num_rxq ||
1700 lio_dev->nb_tx_queues != num_txq) {
1701 if (lio_send_queue_count_update(eth_dev, num_txq, num_rxq))
1703 lio_dev->nb_rx_queues = num_rxq;
1704 lio_dev->nb_tx_queues = num_txq;
1707 if (lio_dev->intf_open)
1708 lio_dev_stop(eth_dev);
1710 /* Reset ioq registers */
1711 if (lio_dev->fn_list.setup_device_regs(lio_dev)) {
1712 lio_dev_err(lio_dev, "Failed to configure device registers\n");
1720 lio_dev_configure(struct rte_eth_dev *eth_dev)
1722 struct lio_device *lio_dev = LIO_DEV(eth_dev);
1723 uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
1724 int retval, num_iqueues, num_oqueues;
1725 uint8_t mac[RTE_ETHER_ADDR_LEN], i;
1726 struct lio_if_cfg_resp *resp;
1727 struct lio_soft_command *sc;
1728 union lio_if_cfg if_cfg;
1731 PMD_INIT_FUNC_TRACE();
1733 /* Inform firmware about change in number of queues to use.
1734 * Disable IO queues and reset registers for re-configuration.
1736 if (lio_dev->port_configured)
1737 return lio_reconf_queues(eth_dev,
1738 eth_dev->data->nb_tx_queues,
1739 eth_dev->data->nb_rx_queues);
1741 lio_dev->nb_rx_queues = eth_dev->data->nb_rx_queues;
1742 lio_dev->nb_tx_queues = eth_dev->data->nb_tx_queues;
1744 /* Set max number of queues which can be re-configured. */
1745 lio_dev->max_rx_queues = eth_dev->data->nb_rx_queues;
1746 lio_dev->max_tx_queues = eth_dev->data->nb_tx_queues;
1748 resp_size = sizeof(struct lio_if_cfg_resp);
1749 sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
1753 resp = (struct lio_if_cfg_resp *)sc->virtrptr;
1755 /* Firmware doesn't have capability to reconfigure the queues,
1756 * Claim all queues, and use as many required
1758 if_cfg.if_cfg64 = 0;
1759 if_cfg.s.num_iqueues = lio_dev->nb_tx_queues;
1760 if_cfg.s.num_oqueues = lio_dev->nb_rx_queues;
1761 if_cfg.s.base_queue = 0;
1763 if_cfg.s.gmx_port_id = lio_dev->pf_num;
1765 lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
1766 LIO_OPCODE_IF_CFG, 0,
1767 if_cfg.if_cfg64, 0);
1769 /* Setting wait time in seconds */
1770 sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
1772 retval = lio_send_soft_command(lio_dev, sc);
1773 if (retval == LIO_IQ_SEND_FAILED) {
1774 lio_dev_err(lio_dev, "iq/oq config failed status: %x\n",
1776 /* Soft instr is freed by driver in case of failure. */
1777 goto nic_config_fail;
1780 /* Sleep on a wait queue till the cond flag indicates that the
1781 * response arrived or timed-out.
1783 while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
1784 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
1785 lio_process_ordered_list(lio_dev);
1789 retval = resp->status;
1791 lio_dev_err(lio_dev, "iq/oq config failed\n");
1792 goto nic_config_fail;
1795 strlcpy(lio_dev->firmware_version,
1796 resp->cfg_info.lio_firmware_version, LIO_FW_VERSION_LENGTH);
1798 lio_swap_8B_data((uint64_t *)(&resp->cfg_info),
1799 sizeof(struct octeon_if_cfg_info) >> 3);
1801 num_iqueues = lio_hweight64(resp->cfg_info.iqmask);
1802 num_oqueues = lio_hweight64(resp->cfg_info.oqmask);
1804 if (!(num_iqueues) || !(num_oqueues)) {
1805 lio_dev_err(lio_dev,
1806 "Got bad iqueues (%016lx) or oqueues (%016lx) from firmware.\n",
1807 (unsigned long)resp->cfg_info.iqmask,
1808 (unsigned long)resp->cfg_info.oqmask);
1809 goto nic_config_fail;
1812 lio_dev_dbg(lio_dev,
1813 "interface %d, iqmask %016lx, oqmask %016lx, numiqueues %d, numoqueues %d\n",
1814 eth_dev->data->port_id,
1815 (unsigned long)resp->cfg_info.iqmask,
1816 (unsigned long)resp->cfg_info.oqmask,
1817 num_iqueues, num_oqueues);
1819 lio_dev->linfo.num_rxpciq = num_oqueues;
1820 lio_dev->linfo.num_txpciq = num_iqueues;
1822 for (i = 0; i < num_oqueues; i++) {
1823 lio_dev->linfo.rxpciq[i].rxpciq64 =
1824 resp->cfg_info.linfo.rxpciq[i].rxpciq64;
1825 lio_dev_dbg(lio_dev, "index %d OQ %d\n",
1826 i, lio_dev->linfo.rxpciq[i].s.q_no);
1829 for (i = 0; i < num_iqueues; i++) {
1830 lio_dev->linfo.txpciq[i].txpciq64 =
1831 resp->cfg_info.linfo.txpciq[i].txpciq64;
1832 lio_dev_dbg(lio_dev, "index %d IQ %d\n",
1833 i, lio_dev->linfo.txpciq[i].s.q_no);
1836 lio_dev->linfo.hw_addr = resp->cfg_info.linfo.hw_addr;
1837 lio_dev->linfo.gmxport = resp->cfg_info.linfo.gmxport;
1838 lio_dev->linfo.link.link_status64 =
1839 resp->cfg_info.linfo.link.link_status64;
1841 /* 64-bit swap required on LE machines */
1842 lio_swap_8B_data(&lio_dev->linfo.hw_addr, 1);
1843 for (i = 0; i < RTE_ETHER_ADDR_LEN; i++)
1844 mac[i] = *((uint8_t *)(((uint8_t *)&lio_dev->linfo.hw_addr) +
1847 /* Copy the permanent MAC address */
1848 rte_ether_addr_copy((struct rte_ether_addr *)mac,
1849 ð_dev->data->mac_addrs[0]);
1851 /* enable firmware checksum support for tunnel packets */
1852 lio_enable_hw_tunnel_rx_checksum(eth_dev);
1853 lio_enable_hw_tunnel_tx_checksum(eth_dev);
1855 lio_dev->glist_lock =
1856 rte_zmalloc(NULL, sizeof(*lio_dev->glist_lock) * num_iqueues, 0);
1857 if (lio_dev->glist_lock == NULL)
1860 lio_dev->glist_head =
1861 rte_zmalloc(NULL, sizeof(*lio_dev->glist_head) * num_iqueues,
1863 if (lio_dev->glist_head == NULL) {
1864 rte_free(lio_dev->glist_lock);
1865 lio_dev->glist_lock = NULL;
1869 lio_dev_link_update(eth_dev, 0);
1871 lio_dev->port_configured = 1;
1873 lio_free_soft_command(sc);
1875 /* Reset ioq regs */
1876 lio_dev->fn_list.setup_device_regs(lio_dev);
1878 /* Free iq_0 used during init */
1879 lio_free_instr_queue0(lio_dev);
1884 lio_dev_err(lio_dev, "Failed retval %d\n", retval);
1885 lio_free_soft_command(sc);
1886 lio_free_instr_queue0(lio_dev);
1891 /* Define our ethernet definitions */
1892 static const struct eth_dev_ops liovf_eth_dev_ops = {
1893 .dev_configure = lio_dev_configure,
1894 .dev_start = lio_dev_start,
1895 .dev_stop = lio_dev_stop,
1896 .dev_set_link_up = lio_dev_set_link_up,
1897 .dev_set_link_down = lio_dev_set_link_down,
1898 .dev_close = lio_dev_close,
1899 .promiscuous_enable = lio_dev_promiscuous_enable,
1900 .promiscuous_disable = lio_dev_promiscuous_disable,
1901 .allmulticast_enable = lio_dev_allmulticast_enable,
1902 .allmulticast_disable = lio_dev_allmulticast_disable,
1903 .link_update = lio_dev_link_update,
1904 .stats_get = lio_dev_stats_get,
1905 .xstats_get = lio_dev_xstats_get,
1906 .xstats_get_names = lio_dev_xstats_get_names,
1907 .stats_reset = lio_dev_stats_reset,
1908 .xstats_reset = lio_dev_xstats_reset,
1909 .dev_infos_get = lio_dev_info_get,
1910 .vlan_filter_set = lio_dev_vlan_filter_set,
1911 .rx_queue_setup = lio_dev_rx_queue_setup,
1912 .rx_queue_release = lio_dev_rx_queue_release,
1913 .tx_queue_setup = lio_dev_tx_queue_setup,
1914 .tx_queue_release = lio_dev_tx_queue_release,
1915 .reta_update = lio_dev_rss_reta_update,
1916 .reta_query = lio_dev_rss_reta_query,
1917 .rss_hash_conf_get = lio_dev_rss_hash_conf_get,
1918 .rss_hash_update = lio_dev_rss_hash_update,
1919 .udp_tunnel_port_add = lio_dev_udp_tunnel_add,
1920 .udp_tunnel_port_del = lio_dev_udp_tunnel_del,
1921 .mtu_set = lio_dev_mtu_set,
1925 lio_check_pf_hs_response(void *lio_dev)
1927 struct lio_device *dev = lio_dev;
1929 /* check till response arrives */
1930 if (dev->pfvf_hsword.coproc_tics_per_us)
1933 cn23xx_vf_handle_mbox(dev);
1935 rte_eal_alarm_set(1, lio_check_pf_hs_response, lio_dev);
1939 * \brief Identify the LIO device and to map the BAR address space
1940 * @param lio_dev lio device
1943 lio_chip_specific_setup(struct lio_device *lio_dev)
1945 struct rte_pci_device *pdev = lio_dev->pci_dev;
1946 uint32_t dev_id = pdev->id.device_id;
1951 case LIO_CN23XX_VF_VID:
1952 lio_dev->chip_id = LIO_CN23XX_VF_VID;
1953 ret = cn23xx_vf_setup_device(lio_dev);
1958 lio_dev_err(lio_dev, "Unsupported Chip\n");
1962 lio_dev_info(lio_dev, "DEVICE : %s\n", s);
1968 lio_first_time_init(struct lio_device *lio_dev,
1969 struct rte_pci_device *pdev)
1973 PMD_INIT_FUNC_TRACE();
1975 /* set dpdk specific pci device pointer */
1976 lio_dev->pci_dev = pdev;
1978 /* Identify the LIO type and set device ops */
1979 if (lio_chip_specific_setup(lio_dev)) {
1980 lio_dev_err(lio_dev, "Chip specific setup failed\n");
1984 /* Initialize soft command buffer pool */
1985 if (lio_setup_sc_buffer_pool(lio_dev)) {
1986 lio_dev_err(lio_dev, "sc buffer pool allocation failed\n");
1990 /* Initialize lists to manage the requests of different types that
1991 * arrive from applications for this lio device.
1993 lio_setup_response_list(lio_dev);
1995 if (lio_dev->fn_list.setup_mbox(lio_dev)) {
1996 lio_dev_err(lio_dev, "Mailbox setup failed\n");
2000 /* Check PF response */
2001 lio_check_pf_hs_response((void *)lio_dev);
2003 /* Do handshake and exit if incompatible PF driver */
2004 if (cn23xx_pfvf_handshake(lio_dev))
2007 /* Request and wait for device reset. */
2008 if (pdev->kdrv == RTE_KDRV_IGB_UIO) {
2009 cn23xx_vf_ask_pf_to_do_flr(lio_dev);
2010 /* FLR wait time doubled as a precaution. */
2011 rte_delay_ms(LIO_PCI_FLR_WAIT * 2);
2014 if (lio_dev->fn_list.setup_device_regs(lio_dev)) {
2015 lio_dev_err(lio_dev, "Failed to configure device registers\n");
2019 if (lio_setup_instr_queue0(lio_dev)) {
2020 lio_dev_err(lio_dev, "Failed to setup instruction queue 0\n");
2024 dpdk_queues = (int)lio_dev->sriov_info.rings_per_vf;
2026 lio_dev->max_tx_queues = dpdk_queues;
2027 lio_dev->max_rx_queues = dpdk_queues;
2029 /* Enable input and output queues for this device */
2030 if (lio_dev->fn_list.enable_io_queues(lio_dev))
2036 lio_free_sc_buffer_pool(lio_dev);
2037 if (lio_dev->mbox[0])
2038 lio_dev->fn_list.free_mbox(lio_dev);
2039 if (lio_dev->instr_queue[0])
2040 lio_free_instr_queue0(lio_dev);
2046 lio_eth_dev_uninit(struct rte_eth_dev *eth_dev)
2048 struct lio_device *lio_dev = LIO_DEV(eth_dev);
2050 PMD_INIT_FUNC_TRACE();
2052 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
2055 /* lio_free_sc_buffer_pool */
2056 lio_free_sc_buffer_pool(lio_dev);
2058 eth_dev->dev_ops = NULL;
2059 eth_dev->rx_pkt_burst = NULL;
2060 eth_dev->tx_pkt_burst = NULL;
2066 lio_eth_dev_init(struct rte_eth_dev *eth_dev)
2068 struct rte_pci_device *pdev = RTE_ETH_DEV_TO_PCI(eth_dev);
2069 struct lio_device *lio_dev = LIO_DEV(eth_dev);
2071 PMD_INIT_FUNC_TRACE();
2073 eth_dev->rx_pkt_burst = &lio_dev_recv_pkts;
2074 eth_dev->tx_pkt_burst = &lio_dev_xmit_pkts;
2076 /* Primary does the initialization. */
2077 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
2080 rte_eth_copy_pci_info(eth_dev, pdev);
2082 if (pdev->mem_resource[0].addr) {
2083 lio_dev->hw_addr = pdev->mem_resource[0].addr;
2085 PMD_INIT_LOG(ERR, "ERROR: Failed to map BAR0\n");
2089 lio_dev->eth_dev = eth_dev;
2090 /* set lio device print string */
2091 snprintf(lio_dev->dev_string, sizeof(lio_dev->dev_string),
2092 "%s[%02x:%02x.%x]", pdev->driver->driver.name,
2093 pdev->addr.bus, pdev->addr.devid, pdev->addr.function);
2095 lio_dev->port_id = eth_dev->data->port_id;
2097 if (lio_first_time_init(lio_dev, pdev)) {
2098 lio_dev_err(lio_dev, "Device init failed\n");
2102 eth_dev->dev_ops = &liovf_eth_dev_ops;
2103 eth_dev->data->mac_addrs = rte_zmalloc("lio", RTE_ETHER_ADDR_LEN, 0);
2104 if (eth_dev->data->mac_addrs == NULL) {
2105 lio_dev_err(lio_dev,
2106 "MAC addresses memory allocation failed\n");
2107 eth_dev->dev_ops = NULL;
2108 eth_dev->rx_pkt_burst = NULL;
2109 eth_dev->tx_pkt_burst = NULL;
2113 rte_atomic64_set(&lio_dev->status, LIO_DEV_RUNNING);
2116 lio_dev->port_configured = 0;
2117 /* Always allow unicast packets */
2118 lio_dev->ifflags |= LIO_IFFLAG_UNICAST;
2124 lio_eth_dev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
2125 struct rte_pci_device *pci_dev)
2127 return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct lio_device),
2132 lio_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
2134 return rte_eth_dev_pci_generic_remove(pci_dev,
2135 lio_eth_dev_uninit);
2138 /* Set of PCI devices this driver supports */
2139 static const struct rte_pci_id pci_id_liovf_map[] = {
2140 { RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_VF_VID) },
2141 { .vendor_id = 0, /* sentinel */ }
2144 static struct rte_pci_driver rte_liovf_pmd = {
2145 .id_table = pci_id_liovf_map,
2146 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
2147 .probe = lio_eth_dev_pci_probe,
2148 .remove = lio_eth_dev_pci_remove,
2151 RTE_PMD_REGISTER_PCI(net_liovf, rte_liovf_pmd);
2152 RTE_PMD_REGISTER_PCI_TABLE(net_liovf, pci_id_liovf_map);
2153 RTE_PMD_REGISTER_KMOD_DEP(net_liovf, "* igb_uio | vfio-pci");
2155 RTE_INIT(lio_init_log)
2157 lio_logtype_init = rte_log_register("pmd.net.liquidio.init");
2158 if (lio_logtype_init >= 0)
2159 rte_log_set_level(lio_logtype_init, RTE_LOG_NOTICE);
2160 lio_logtype_driver = rte_log_register("pmd.net.liquidio.driver");
2161 if (lio_logtype_driver >= 0)
2162 rte_log_set_level(lio_logtype_driver, RTE_LOG_NOTICE);