4 * Copyright (c) 2016-2017 Solarflare Communications Inc.
7 * This software was jointly developed between OKTET Labs (under contract
8 * for Solarflare) and Solarflare Communications, Inc.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <rte_ethdev.h>
35 #include <rte_errno.h>
40 #include "sfc_debug.h"
42 #include "sfc_kvargs.h"
48 #include "sfc_dp_rx.h"
50 static struct sfc_dp_list sfc_dp_head =
51 TAILQ_HEAD_INITIALIZER(sfc_dp_head);
54 sfc_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
56 struct sfc_adapter *sa = dev->data->dev_private;
57 efx_nic_fw_info_t enfi;
62 * Return value of the callback is likely supposed to be
63 * equal to or greater than 0, nevertheless, if an error
64 * occurs, it will be desirable to pass it to the caller
66 if ((fw_version == NULL) || (fw_size == 0))
69 rc = efx_nic_get_fw_version(sa->nic, &enfi);
73 ret = snprintf(fw_version, fw_size,
74 "%" PRIu16 ".%" PRIu16 ".%" PRIu16 ".%" PRIu16,
75 enfi.enfi_mc_fw_version[0], enfi.enfi_mc_fw_version[1],
76 enfi.enfi_mc_fw_version[2], enfi.enfi_mc_fw_version[3]);
80 if (enfi.enfi_dpcpu_fw_ids_valid) {
81 size_t dpcpu_fw_ids_offset = MIN(fw_size - 1, (size_t)ret);
84 ret_extra = snprintf(fw_version + dpcpu_fw_ids_offset,
85 fw_size - dpcpu_fw_ids_offset,
86 " rx%" PRIx16 " tx%" PRIx16,
87 enfi.enfi_rx_dpcpu_fw_id,
88 enfi.enfi_tx_dpcpu_fw_id);
95 if (fw_size < (size_t)(++ret))
102 sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
104 struct sfc_adapter *sa = dev->data->dev_private;
105 const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
107 sfc_log_init(sa, "entry");
109 dev_info->pci_dev = RTE_DEV_TO_PCI(dev->device);
110 dev_info->max_rx_pktlen = EFX_MAC_PDU_MAX;
112 /* Autonegotiation may be disabled */
113 dev_info->speed_capa = ETH_LINK_SPEED_FIXED;
114 if (sa->port.phy_adv_cap_mask & EFX_PHY_CAP_1000FDX)
115 dev_info->speed_capa |= ETH_LINK_SPEED_1G;
116 if (sa->port.phy_adv_cap_mask & EFX_PHY_CAP_10000FDX)
117 dev_info->speed_capa |= ETH_LINK_SPEED_10G;
118 if (sa->port.phy_adv_cap_mask & EFX_PHY_CAP_40000FDX)
119 dev_info->speed_capa |= ETH_LINK_SPEED_40G;
121 dev_info->max_rx_queues = sa->rxq_max;
122 dev_info->max_tx_queues = sa->txq_max;
124 /* By default packets are dropped if no descriptors are available */
125 dev_info->default_rxconf.rx_drop_en = 1;
127 dev_info->rx_offload_capa =
128 DEV_RX_OFFLOAD_IPV4_CKSUM |
129 DEV_RX_OFFLOAD_UDP_CKSUM |
130 DEV_RX_OFFLOAD_TCP_CKSUM;
132 dev_info->tx_offload_capa =
133 DEV_TX_OFFLOAD_IPV4_CKSUM |
134 DEV_TX_OFFLOAD_UDP_CKSUM |
135 DEV_TX_OFFLOAD_TCP_CKSUM;
137 dev_info->default_txconf.txq_flags = ETH_TXQ_FLAGS_NOXSUMSCTP;
138 if ((~sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) ||
139 !encp->enc_hw_tx_insert_vlan_enabled)
140 dev_info->default_txconf.txq_flags |= ETH_TXQ_FLAGS_NOVLANOFFL;
142 dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_VLAN_INSERT;
144 if (~sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_SEG)
145 dev_info->default_txconf.txq_flags |= ETH_TXQ_FLAGS_NOMULTSEGS;
147 #if EFSYS_OPT_RX_SCALE
148 if (sa->rss_support != EFX_RX_SCALE_UNAVAILABLE) {
149 dev_info->reta_size = EFX_RSS_TBL_SIZE;
150 dev_info->hash_key_size = SFC_RSS_KEY_SIZE;
151 dev_info->flow_type_rss_offloads = SFC_RSS_OFFLOADS;
156 dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_TCP_TSO;
158 dev_info->rx_desc_lim.nb_max = EFX_RXQ_MAXNDESCS;
159 dev_info->rx_desc_lim.nb_min = EFX_RXQ_MINNDESCS;
160 /* The RXQ hardware requires that the descriptor count is a power
161 * of 2, but rx_desc_lim cannot properly describe that constraint.
163 dev_info->rx_desc_lim.nb_align = EFX_RXQ_MINNDESCS;
165 dev_info->tx_desc_lim.nb_max = sa->txq_max_entries;
166 dev_info->tx_desc_lim.nb_min = EFX_TXQ_MINNDESCS;
168 * The TXQ hardware requires that the descriptor count is a power
169 * of 2, but tx_desc_lim cannot properly describe that constraint
171 dev_info->tx_desc_lim.nb_align = EFX_TXQ_MINNDESCS;
174 static const uint32_t *
175 sfc_dev_supported_ptypes_get(struct rte_eth_dev *dev)
177 struct sfc_adapter *sa = dev->data->dev_private;
179 return sa->dp_rx->supported_ptypes_get();
183 sfc_dev_configure(struct rte_eth_dev *dev)
185 struct rte_eth_dev_data *dev_data = dev->data;
186 struct sfc_adapter *sa = dev_data->dev_private;
189 sfc_log_init(sa, "entry n_rxq=%u n_txq=%u",
190 dev_data->nb_rx_queues, dev_data->nb_tx_queues);
192 sfc_adapter_lock(sa);
194 case SFC_ADAPTER_CONFIGURED:
196 case SFC_ADAPTER_INITIALIZED:
197 rc = sfc_configure(sa);
200 sfc_err(sa, "unexpected adapter state %u to configure",
205 sfc_adapter_unlock(sa);
207 sfc_log_init(sa, "done %d", rc);
213 sfc_dev_start(struct rte_eth_dev *dev)
215 struct sfc_adapter *sa = dev->data->dev_private;
218 sfc_log_init(sa, "entry");
220 sfc_adapter_lock(sa);
222 sfc_adapter_unlock(sa);
224 sfc_log_init(sa, "done %d", rc);
230 sfc_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
232 struct sfc_adapter *sa = dev->data->dev_private;
233 struct rte_eth_link *dev_link = &dev->data->dev_link;
234 struct rte_eth_link old_link;
235 struct rte_eth_link current_link;
237 sfc_log_init(sa, "entry");
240 EFX_STATIC_ASSERT(sizeof(*dev_link) == sizeof(rte_atomic64_t));
241 *(int64_t *)&old_link = rte_atomic64_read((rte_atomic64_t *)dev_link);
243 if (sa->state != SFC_ADAPTER_STARTED) {
244 sfc_port_link_mode_to_info(EFX_LINK_UNKNOWN, ¤t_link);
245 if (!rte_atomic64_cmpset((volatile uint64_t *)dev_link,
246 *(uint64_t *)&old_link,
247 *(uint64_t *)¤t_link))
249 } else if (wait_to_complete) {
250 efx_link_mode_t link_mode;
252 if (efx_port_poll(sa->nic, &link_mode) != 0)
253 link_mode = EFX_LINK_UNKNOWN;
254 sfc_port_link_mode_to_info(link_mode, ¤t_link);
256 if (!rte_atomic64_cmpset((volatile uint64_t *)dev_link,
257 *(uint64_t *)&old_link,
258 *(uint64_t *)¤t_link))
261 sfc_ev_mgmt_qpoll(sa);
262 *(int64_t *)¤t_link =
263 rte_atomic64_read((rte_atomic64_t *)dev_link);
266 if (old_link.link_status != current_link.link_status)
267 sfc_info(sa, "Link status is %s",
268 current_link.link_status ? "UP" : "DOWN");
270 return old_link.link_status == current_link.link_status ? 0 : -1;
274 sfc_dev_stop(struct rte_eth_dev *dev)
276 struct sfc_adapter *sa = dev->data->dev_private;
278 sfc_log_init(sa, "entry");
280 sfc_adapter_lock(sa);
282 sfc_adapter_unlock(sa);
284 sfc_log_init(sa, "done");
288 sfc_dev_set_link_up(struct rte_eth_dev *dev)
290 struct sfc_adapter *sa = dev->data->dev_private;
293 sfc_log_init(sa, "entry");
295 sfc_adapter_lock(sa);
297 sfc_adapter_unlock(sa);
304 sfc_dev_set_link_down(struct rte_eth_dev *dev)
306 struct sfc_adapter *sa = dev->data->dev_private;
308 sfc_log_init(sa, "entry");
310 sfc_adapter_lock(sa);
312 sfc_adapter_unlock(sa);
318 sfc_dev_close(struct rte_eth_dev *dev)
320 struct sfc_adapter *sa = dev->data->dev_private;
322 sfc_log_init(sa, "entry");
324 sfc_adapter_lock(sa);
326 case SFC_ADAPTER_STARTED:
328 SFC_ASSERT(sa->state == SFC_ADAPTER_CONFIGURED);
330 case SFC_ADAPTER_CONFIGURED:
332 SFC_ASSERT(sa->state == SFC_ADAPTER_INITIALIZED);
334 case SFC_ADAPTER_INITIALIZED:
337 sfc_err(sa, "unexpected adapter state %u on close", sa->state);
340 sfc_adapter_unlock(sa);
342 sfc_log_init(sa, "done");
346 sfc_dev_filter_set(struct rte_eth_dev *dev, enum sfc_dev_filter_mode mode,
349 struct sfc_port *port;
351 struct sfc_adapter *sa = dev->data->dev_private;
352 boolean_t allmulti = (mode == SFC_DEV_FILTER_MODE_ALLMULTI);
353 const char *desc = (allmulti) ? "all-multi" : "promiscuous";
355 sfc_adapter_lock(sa);
358 toggle = (allmulti) ? (&port->allmulti) : (&port->promisc);
360 if (*toggle != enabled) {
363 if ((sa->state == SFC_ADAPTER_STARTED) &&
364 (sfc_set_rx_mode(sa) != 0)) {
365 *toggle = !(enabled);
366 sfc_warn(sa, "Failed to %s %s mode",
367 ((enabled) ? "enable" : "disable"), desc);
371 sfc_adapter_unlock(sa);
375 sfc_dev_promisc_enable(struct rte_eth_dev *dev)
377 sfc_dev_filter_set(dev, SFC_DEV_FILTER_MODE_PROMISC, B_TRUE);
381 sfc_dev_promisc_disable(struct rte_eth_dev *dev)
383 sfc_dev_filter_set(dev, SFC_DEV_FILTER_MODE_PROMISC, B_FALSE);
387 sfc_dev_allmulti_enable(struct rte_eth_dev *dev)
389 sfc_dev_filter_set(dev, SFC_DEV_FILTER_MODE_ALLMULTI, B_TRUE);
393 sfc_dev_allmulti_disable(struct rte_eth_dev *dev)
395 sfc_dev_filter_set(dev, SFC_DEV_FILTER_MODE_ALLMULTI, B_FALSE);
399 sfc_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
400 uint16_t nb_rx_desc, unsigned int socket_id,
401 const struct rte_eth_rxconf *rx_conf,
402 struct rte_mempool *mb_pool)
404 struct sfc_adapter *sa = dev->data->dev_private;
407 sfc_log_init(sa, "RxQ=%u nb_rx_desc=%u socket_id=%u",
408 rx_queue_id, nb_rx_desc, socket_id);
410 sfc_adapter_lock(sa);
412 rc = sfc_rx_qinit(sa, rx_queue_id, nb_rx_desc, socket_id,
417 dev->data->rx_queues[rx_queue_id] = sa->rxq_info[rx_queue_id].rxq->dp;
419 sfc_adapter_unlock(sa);
424 sfc_adapter_unlock(sa);
430 sfc_rx_queue_release(void *queue)
432 struct sfc_dp_rxq *dp_rxq = queue;
434 struct sfc_adapter *sa;
435 unsigned int sw_index;
440 rxq = sfc_rxq_by_dp_rxq(dp_rxq);
442 sfc_adapter_lock(sa);
444 sw_index = sfc_rxq_sw_index(rxq);
446 sfc_log_init(sa, "RxQ=%u", sw_index);
448 sa->eth_dev->data->rx_queues[sw_index] = NULL;
450 sfc_rx_qfini(sa, sw_index);
452 sfc_adapter_unlock(sa);
456 sfc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
457 uint16_t nb_tx_desc, unsigned int socket_id,
458 const struct rte_eth_txconf *tx_conf)
460 struct sfc_adapter *sa = dev->data->dev_private;
463 sfc_log_init(sa, "TxQ = %u, nb_tx_desc = %u, socket_id = %u",
464 tx_queue_id, nb_tx_desc, socket_id);
466 sfc_adapter_lock(sa);
468 rc = sfc_tx_qinit(sa, tx_queue_id, nb_tx_desc, socket_id, tx_conf);
472 dev->data->tx_queues[tx_queue_id] = sa->txq_info[tx_queue_id].txq->dp;
474 sfc_adapter_unlock(sa);
478 sfc_adapter_unlock(sa);
484 sfc_tx_queue_release(void *queue)
486 struct sfc_dp_txq *dp_txq = queue;
488 unsigned int sw_index;
489 struct sfc_adapter *sa;
494 txq = sfc_txq_by_dp_txq(dp_txq);
495 sw_index = sfc_txq_sw_index(txq);
497 SFC_ASSERT(txq->evq != NULL);
500 sfc_log_init(sa, "TxQ = %u", sw_index);
502 sfc_adapter_lock(sa);
504 SFC_ASSERT(sw_index < sa->eth_dev->data->nb_tx_queues);
505 sa->eth_dev->data->tx_queues[sw_index] = NULL;
507 sfc_tx_qfini(sa, sw_index);
509 sfc_adapter_unlock(sa);
513 sfc_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
515 struct sfc_adapter *sa = dev->data->dev_private;
516 struct sfc_port *port = &sa->port;
519 rte_spinlock_lock(&port->mac_stats_lock);
521 if (sfc_port_update_mac_stats(sa) != 0)
524 mac_stats = port->mac_stats_buf;
526 if (EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask,
527 EFX_MAC_VADAPTER_RX_UNICAST_PACKETS)) {
529 mac_stats[EFX_MAC_VADAPTER_RX_UNICAST_PACKETS] +
530 mac_stats[EFX_MAC_VADAPTER_RX_MULTICAST_PACKETS] +
531 mac_stats[EFX_MAC_VADAPTER_RX_BROADCAST_PACKETS];
533 mac_stats[EFX_MAC_VADAPTER_TX_UNICAST_PACKETS] +
534 mac_stats[EFX_MAC_VADAPTER_TX_MULTICAST_PACKETS] +
535 mac_stats[EFX_MAC_VADAPTER_TX_BROADCAST_PACKETS];
537 mac_stats[EFX_MAC_VADAPTER_RX_UNICAST_BYTES] +
538 mac_stats[EFX_MAC_VADAPTER_RX_MULTICAST_BYTES] +
539 mac_stats[EFX_MAC_VADAPTER_RX_BROADCAST_BYTES];
541 mac_stats[EFX_MAC_VADAPTER_TX_UNICAST_BYTES] +
542 mac_stats[EFX_MAC_VADAPTER_TX_MULTICAST_BYTES] +
543 mac_stats[EFX_MAC_VADAPTER_TX_BROADCAST_BYTES];
544 stats->imissed = mac_stats[EFX_MAC_VADAPTER_RX_OVERFLOW];
545 stats->ierrors = mac_stats[EFX_MAC_VADAPTER_RX_BAD_PACKETS];
546 stats->oerrors = mac_stats[EFX_MAC_VADAPTER_TX_BAD_PACKETS];
548 stats->ipackets = mac_stats[EFX_MAC_RX_PKTS];
549 stats->opackets = mac_stats[EFX_MAC_TX_PKTS];
550 stats->ibytes = mac_stats[EFX_MAC_RX_OCTETS];
551 stats->obytes = mac_stats[EFX_MAC_TX_OCTETS];
553 * Take into account stats which are whenever supported
554 * on EF10. If some stat is not supported by current
555 * firmware variant or HW revision, it is guaranteed
556 * to be zero in mac_stats.
559 mac_stats[EFX_MAC_RX_NODESC_DROP_CNT] +
560 mac_stats[EFX_MAC_PM_TRUNC_BB_OVERFLOW] +
561 mac_stats[EFX_MAC_PM_DISCARD_BB_OVERFLOW] +
562 mac_stats[EFX_MAC_PM_TRUNC_VFIFO_FULL] +
563 mac_stats[EFX_MAC_PM_DISCARD_VFIFO_FULL] +
564 mac_stats[EFX_MAC_PM_TRUNC_QBB] +
565 mac_stats[EFX_MAC_PM_DISCARD_QBB] +
566 mac_stats[EFX_MAC_PM_DISCARD_MAPPING] +
567 mac_stats[EFX_MAC_RXDP_Q_DISABLED_PKTS] +
568 mac_stats[EFX_MAC_RXDP_DI_DROPPED_PKTS];
570 mac_stats[EFX_MAC_RX_FCS_ERRORS] +
571 mac_stats[EFX_MAC_RX_ALIGN_ERRORS] +
572 mac_stats[EFX_MAC_RX_JABBER_PKTS];
573 /* no oerrors counters supported on EF10 */
577 rte_spinlock_unlock(&port->mac_stats_lock);
581 sfc_stats_reset(struct rte_eth_dev *dev)
583 struct sfc_adapter *sa = dev->data->dev_private;
584 struct sfc_port *port = &sa->port;
587 if (sa->state != SFC_ADAPTER_STARTED) {
589 * The operation cannot be done if port is not started; it
590 * will be scheduled to be done during the next port start
592 port->mac_stats_reset_pending = B_TRUE;
596 rc = sfc_port_reset_mac_stats(sa);
598 sfc_err(sa, "failed to reset statistics (rc = %d)", rc);
602 sfc_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
603 unsigned int xstats_count)
605 struct sfc_adapter *sa = dev->data->dev_private;
606 struct sfc_port *port = &sa->port;
612 rte_spinlock_lock(&port->mac_stats_lock);
614 rc = sfc_port_update_mac_stats(sa);
621 mac_stats = port->mac_stats_buf;
623 for (i = 0; i < EFX_MAC_NSTATS; ++i) {
624 if (EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) {
625 if (xstats != NULL && nstats < (int)xstats_count) {
626 xstats[nstats].id = nstats;
627 xstats[nstats].value = mac_stats[i];
634 rte_spinlock_unlock(&port->mac_stats_lock);
640 sfc_xstats_get_names(struct rte_eth_dev *dev,
641 struct rte_eth_xstat_name *xstats_names,
642 unsigned int xstats_count)
644 struct sfc_adapter *sa = dev->data->dev_private;
645 struct sfc_port *port = &sa->port;
647 unsigned int nstats = 0;
649 for (i = 0; i < EFX_MAC_NSTATS; ++i) {
650 if (EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) {
651 if (xstats_names != NULL && nstats < xstats_count)
652 strncpy(xstats_names[nstats].name,
653 efx_mac_stat_name(sa->nic, i),
654 sizeof(xstats_names[0].name));
663 sfc_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
665 struct sfc_adapter *sa = dev->data->dev_private;
666 unsigned int wanted_fc, link_fc;
668 memset(fc_conf, 0, sizeof(*fc_conf));
670 sfc_adapter_lock(sa);
672 if (sa->state == SFC_ADAPTER_STARTED)
673 efx_mac_fcntl_get(sa->nic, &wanted_fc, &link_fc);
675 link_fc = sa->port.flow_ctrl;
679 fc_conf->mode = RTE_FC_NONE;
681 case EFX_FCNTL_RESPOND:
682 fc_conf->mode = RTE_FC_RX_PAUSE;
684 case EFX_FCNTL_GENERATE:
685 fc_conf->mode = RTE_FC_TX_PAUSE;
687 case (EFX_FCNTL_RESPOND | EFX_FCNTL_GENERATE):
688 fc_conf->mode = RTE_FC_FULL;
691 sfc_err(sa, "%s: unexpected flow control value %#x",
695 fc_conf->autoneg = sa->port.flow_ctrl_autoneg;
697 sfc_adapter_unlock(sa);
703 sfc_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
705 struct sfc_adapter *sa = dev->data->dev_private;
706 struct sfc_port *port = &sa->port;
710 if (fc_conf->high_water != 0 || fc_conf->low_water != 0 ||
711 fc_conf->pause_time != 0 || fc_conf->send_xon != 0 ||
712 fc_conf->mac_ctrl_frame_fwd != 0) {
713 sfc_err(sa, "unsupported flow control settings specified");
718 switch (fc_conf->mode) {
722 case RTE_FC_RX_PAUSE:
723 fcntl = EFX_FCNTL_RESPOND;
725 case RTE_FC_TX_PAUSE:
726 fcntl = EFX_FCNTL_GENERATE;
729 fcntl = EFX_FCNTL_RESPOND | EFX_FCNTL_GENERATE;
736 sfc_adapter_lock(sa);
738 if (sa->state == SFC_ADAPTER_STARTED) {
739 rc = efx_mac_fcntl_set(sa->nic, fcntl, fc_conf->autoneg);
741 goto fail_mac_fcntl_set;
744 port->flow_ctrl = fcntl;
745 port->flow_ctrl_autoneg = fc_conf->autoneg;
747 sfc_adapter_unlock(sa);
752 sfc_adapter_unlock(sa);
759 sfc_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
761 struct sfc_adapter *sa = dev->data->dev_private;
762 size_t pdu = EFX_MAC_PDU(mtu);
766 sfc_log_init(sa, "mtu=%u", mtu);
769 if (pdu < EFX_MAC_PDU_MIN) {
770 sfc_err(sa, "too small MTU %u (PDU size %u less than min %u)",
771 (unsigned int)mtu, (unsigned int)pdu,
775 if (pdu > EFX_MAC_PDU_MAX) {
776 sfc_err(sa, "too big MTU %u (PDU size %u greater than max %u)",
777 (unsigned int)mtu, (unsigned int)pdu,
782 sfc_adapter_lock(sa);
784 if (pdu != sa->port.pdu) {
785 if (sa->state == SFC_ADAPTER_STARTED) {
788 old_pdu = sa->port.pdu;
799 * The driver does not use it, but other PMDs update jumbo_frame
800 * flag and max_rx_pkt_len when MTU is set.
802 dev->data->dev_conf.rxmode.jumbo_frame = (mtu > ETHER_MAX_LEN);
803 dev->data->dev_conf.rxmode.max_rx_pkt_len = sa->port.pdu;
805 sfc_adapter_unlock(sa);
807 sfc_log_init(sa, "done");
811 sa->port.pdu = old_pdu;
812 if (sfc_start(sa) != 0)
813 sfc_err(sa, "cannot start with neither new (%u) nor old (%u) "
814 "PDU max size - port is stopped",
815 (unsigned int)pdu, (unsigned int)old_pdu);
816 sfc_adapter_unlock(sa);
819 sfc_log_init(sa, "failed %d", rc);
824 sfc_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
826 struct sfc_adapter *sa = dev->data->dev_private;
827 const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
830 sfc_adapter_lock(sa);
832 if (sa->state != SFC_ADAPTER_STARTED) {
833 sfc_info(sa, "the port is not started");
834 sfc_info(sa, "the new MAC address will be set on port start");
839 if (encp->enc_allow_set_mac_with_installed_filters) {
840 rc = efx_mac_addr_set(sa->nic, mac_addr->addr_bytes);
842 sfc_err(sa, "cannot set MAC address (rc = %u)", rc);
847 * Changing the MAC address by means of MCDI request
848 * has no effect on received traffic, therefore
849 * we also need to update unicast filters
851 rc = sfc_set_rx_mode(sa);
853 sfc_err(sa, "cannot set filter (rc = %u)", rc);
855 sfc_warn(sa, "cannot set MAC address with filters installed");
856 sfc_warn(sa, "adapter will be restarted to pick the new MAC");
857 sfc_warn(sa, "(some traffic may be dropped)");
860 * Since setting MAC address with filters installed is not
861 * allowed on the adapter, one needs to simply restart adapter
862 * so that the new MAC address will be taken from an outer
863 * storage and set flawlessly by means of sfc_start() call
868 sfc_err(sa, "cannot restart adapter (rc = %u)", rc);
872 sfc_adapter_unlock(sa);
877 sfc_set_mc_addr_list(struct rte_eth_dev *dev, struct ether_addr *mc_addr_set,
880 struct sfc_adapter *sa = dev->data->dev_private;
881 struct sfc_port *port = &sa->port;
882 uint8_t *mc_addrs = port->mcast_addrs;
886 if (mc_addrs == NULL)
889 if (nb_mc_addr > port->max_mcast_addrs) {
890 sfc_err(sa, "too many multicast addresses: %u > %u",
891 nb_mc_addr, port->max_mcast_addrs);
895 for (i = 0; i < nb_mc_addr; ++i) {
896 (void)rte_memcpy(mc_addrs, mc_addr_set[i].addr_bytes,
898 mc_addrs += EFX_MAC_ADDR_LEN;
901 port->nb_mcast_addrs = nb_mc_addr;
903 if (sa->state != SFC_ADAPTER_STARTED)
906 rc = efx_mac_multicast_list_set(sa->nic, port->mcast_addrs,
907 port->nb_mcast_addrs);
909 sfc_err(sa, "cannot set multicast address list (rc = %u)", rc);
916 sfc_rx_queue_info_get(struct rte_eth_dev *dev, uint16_t rx_queue_id,
917 struct rte_eth_rxq_info *qinfo)
919 struct sfc_adapter *sa = dev->data->dev_private;
920 struct sfc_rxq_info *rxq_info;
923 sfc_adapter_lock(sa);
925 SFC_ASSERT(rx_queue_id < sa->rxq_count);
927 rxq_info = &sa->rxq_info[rx_queue_id];
929 SFC_ASSERT(rxq != NULL);
931 qinfo->mp = rxq->refill_mb_pool;
932 qinfo->conf.rx_free_thresh = rxq->refill_threshold;
933 qinfo->conf.rx_drop_en = 1;
934 qinfo->conf.rx_deferred_start = rxq_info->deferred_start;
935 qinfo->scattered_rx = (rxq_info->type == EFX_RXQ_TYPE_SCATTER);
936 qinfo->nb_desc = rxq_info->entries;
938 sfc_adapter_unlock(sa);
942 sfc_tx_queue_info_get(struct rte_eth_dev *dev, uint16_t tx_queue_id,
943 struct rte_eth_txq_info *qinfo)
945 struct sfc_adapter *sa = dev->data->dev_private;
946 struct sfc_txq_info *txq_info;
948 sfc_adapter_lock(sa);
950 SFC_ASSERT(tx_queue_id < sa->txq_count);
952 txq_info = &sa->txq_info[tx_queue_id];
953 SFC_ASSERT(txq_info->txq != NULL);
955 memset(qinfo, 0, sizeof(*qinfo));
957 qinfo->conf.txq_flags = txq_info->txq->flags;
958 qinfo->conf.tx_free_thresh = txq_info->txq->free_thresh;
959 qinfo->conf.tx_deferred_start = txq_info->deferred_start;
960 qinfo->nb_desc = txq_info->entries;
962 sfc_adapter_unlock(sa);
966 sfc_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)
968 struct sfc_adapter *sa = dev->data->dev_private;
970 sfc_log_init(sa, "RxQ=%u", rx_queue_id);
972 return sfc_rx_qdesc_npending(sa, rx_queue_id);
976 sfc_rx_descriptor_done(void *queue, uint16_t offset)
978 struct sfc_dp_rxq *dp_rxq = queue;
980 return sfc_rx_qdesc_done(dp_rxq, offset);
984 sfc_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
986 struct sfc_adapter *sa = dev->data->dev_private;
989 sfc_log_init(sa, "RxQ=%u", rx_queue_id);
991 sfc_adapter_lock(sa);
994 if (sa->state != SFC_ADAPTER_STARTED)
995 goto fail_not_started;
997 rc = sfc_rx_qstart(sa, rx_queue_id);
1001 sa->rxq_info[rx_queue_id].deferred_started = B_TRUE;
1003 sfc_adapter_unlock(sa);
1009 sfc_adapter_unlock(sa);
1015 sfc_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
1017 struct sfc_adapter *sa = dev->data->dev_private;
1019 sfc_log_init(sa, "RxQ=%u", rx_queue_id);
1021 sfc_adapter_lock(sa);
1022 sfc_rx_qstop(sa, rx_queue_id);
1024 sa->rxq_info[rx_queue_id].deferred_started = B_FALSE;
1026 sfc_adapter_unlock(sa);
1032 sfc_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
1034 struct sfc_adapter *sa = dev->data->dev_private;
1037 sfc_log_init(sa, "TxQ = %u", tx_queue_id);
1039 sfc_adapter_lock(sa);
1042 if (sa->state != SFC_ADAPTER_STARTED)
1043 goto fail_not_started;
1045 rc = sfc_tx_qstart(sa, tx_queue_id);
1047 goto fail_tx_qstart;
1049 sa->txq_info[tx_queue_id].deferred_started = B_TRUE;
1051 sfc_adapter_unlock(sa);
1057 sfc_adapter_unlock(sa);
1063 sfc_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
1065 struct sfc_adapter *sa = dev->data->dev_private;
1067 sfc_log_init(sa, "TxQ = %u", tx_queue_id);
1069 sfc_adapter_lock(sa);
1071 sfc_tx_qstop(sa, tx_queue_id);
1073 sa->txq_info[tx_queue_id].deferred_started = B_FALSE;
1075 sfc_adapter_unlock(sa);
1079 #if EFSYS_OPT_RX_SCALE
1081 sfc_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
1082 struct rte_eth_rss_conf *rss_conf)
1084 struct sfc_adapter *sa = dev->data->dev_private;
1086 if ((sa->rss_channels == 1) ||
1087 (sa->rss_support != EFX_RX_SCALE_EXCLUSIVE))
1090 sfc_adapter_lock(sa);
1093 * Mapping of hash configuration between RTE and EFX is not one-to-one,
1094 * hence, conversion is done here to derive a correct set of ETH_RSS
1095 * flags which corresponds to the active EFX configuration stored
1096 * locally in 'sfc_adapter' and kept up-to-date
1098 rss_conf->rss_hf = sfc_efx_to_rte_hash_type(sa->rss_hash_types);
1099 rss_conf->rss_key_len = SFC_RSS_KEY_SIZE;
1100 if (rss_conf->rss_key != NULL)
1101 rte_memcpy(rss_conf->rss_key, sa->rss_key, SFC_RSS_KEY_SIZE);
1103 sfc_adapter_unlock(sa);
1109 sfc_dev_rss_hash_update(struct rte_eth_dev *dev,
1110 struct rte_eth_rss_conf *rss_conf)
1112 struct sfc_adapter *sa = dev->data->dev_private;
1113 unsigned int efx_hash_types;
1116 if ((sa->rss_channels == 1) ||
1117 (sa->rss_support != EFX_RX_SCALE_EXCLUSIVE)) {
1118 sfc_err(sa, "RSS is not available");
1122 if ((rss_conf->rss_key != NULL) &&
1123 (rss_conf->rss_key_len != sizeof(sa->rss_key))) {
1124 sfc_err(sa, "RSS key size is wrong (should be %lu)",
1125 sizeof(sa->rss_key));
1129 if ((rss_conf->rss_hf & ~SFC_RSS_OFFLOADS) != 0) {
1130 sfc_err(sa, "unsupported hash functions requested");
1134 sfc_adapter_lock(sa);
1136 efx_hash_types = sfc_rte_to_efx_hash_type(rss_conf->rss_hf);
1138 rc = efx_rx_scale_mode_set(sa->nic, EFX_RX_HASHALG_TOEPLITZ,
1139 efx_hash_types, B_TRUE);
1141 goto fail_scale_mode_set;
1143 if (rss_conf->rss_key != NULL) {
1144 if (sa->state == SFC_ADAPTER_STARTED) {
1145 rc = efx_rx_scale_key_set(sa->nic, rss_conf->rss_key,
1146 sizeof(sa->rss_key));
1148 goto fail_scale_key_set;
1151 rte_memcpy(sa->rss_key, rss_conf->rss_key, sizeof(sa->rss_key));
1154 sa->rss_hash_types = efx_hash_types;
1156 sfc_adapter_unlock(sa);
1161 if (efx_rx_scale_mode_set(sa->nic, EFX_RX_HASHALG_TOEPLITZ,
1162 sa->rss_hash_types, B_TRUE) != 0)
1163 sfc_err(sa, "failed to restore RSS mode");
1165 fail_scale_mode_set:
1166 sfc_adapter_unlock(sa);
1171 sfc_dev_rss_reta_query(struct rte_eth_dev *dev,
1172 struct rte_eth_rss_reta_entry64 *reta_conf,
1175 struct sfc_adapter *sa = dev->data->dev_private;
1178 if ((sa->rss_channels == 1) ||
1179 (sa->rss_support != EFX_RX_SCALE_EXCLUSIVE))
1182 if (reta_size != EFX_RSS_TBL_SIZE)
1185 sfc_adapter_lock(sa);
1187 for (entry = 0; entry < reta_size; entry++) {
1188 int grp = entry / RTE_RETA_GROUP_SIZE;
1189 int grp_idx = entry % RTE_RETA_GROUP_SIZE;
1191 if ((reta_conf[grp].mask >> grp_idx) & 1)
1192 reta_conf[grp].reta[grp_idx] = sa->rss_tbl[entry];
1195 sfc_adapter_unlock(sa);
1201 sfc_dev_rss_reta_update(struct rte_eth_dev *dev,
1202 struct rte_eth_rss_reta_entry64 *reta_conf,
1205 struct sfc_adapter *sa = dev->data->dev_private;
1206 unsigned int *rss_tbl_new;
1211 if ((sa->rss_channels == 1) ||
1212 (sa->rss_support != EFX_RX_SCALE_EXCLUSIVE)) {
1213 sfc_err(sa, "RSS is not available");
1217 if (reta_size != EFX_RSS_TBL_SIZE) {
1218 sfc_err(sa, "RETA size is wrong (should be %u)",
1223 rss_tbl_new = rte_zmalloc("rss_tbl_new", sizeof(sa->rss_tbl), 0);
1224 if (rss_tbl_new == NULL)
1227 sfc_adapter_lock(sa);
1229 rte_memcpy(rss_tbl_new, sa->rss_tbl, sizeof(sa->rss_tbl));
1231 for (entry = 0; entry < reta_size; entry++) {
1232 int grp_idx = entry % RTE_RETA_GROUP_SIZE;
1233 struct rte_eth_rss_reta_entry64 *grp;
1235 grp = &reta_conf[entry / RTE_RETA_GROUP_SIZE];
1237 if (grp->mask & (1ull << grp_idx)) {
1238 if (grp->reta[grp_idx] >= sa->rss_channels) {
1240 goto bad_reta_entry;
1242 rss_tbl_new[entry] = grp->reta[grp_idx];
1246 rc = efx_rx_scale_tbl_set(sa->nic, rss_tbl_new, EFX_RSS_TBL_SIZE);
1248 rte_memcpy(sa->rss_tbl, rss_tbl_new, sizeof(sa->rss_tbl));
1251 sfc_adapter_unlock(sa);
1253 rte_free(rss_tbl_new);
1255 SFC_ASSERT(rc >= 0);
1261 sfc_dev_filter_ctrl(struct rte_eth_dev *dev, enum rte_filter_type filter_type,
1262 enum rte_filter_op filter_op,
1265 struct sfc_adapter *sa = dev->data->dev_private;
1268 sfc_log_init(sa, "entry");
1270 switch (filter_type) {
1271 case RTE_ETH_FILTER_NONE:
1272 sfc_err(sa, "Global filters configuration not supported");
1274 case RTE_ETH_FILTER_MACVLAN:
1275 sfc_err(sa, "MACVLAN filters not supported");
1277 case RTE_ETH_FILTER_ETHERTYPE:
1278 sfc_err(sa, "EtherType filters not supported");
1280 case RTE_ETH_FILTER_FLEXIBLE:
1281 sfc_err(sa, "Flexible filters not supported");
1283 case RTE_ETH_FILTER_SYN:
1284 sfc_err(sa, "SYN filters not supported");
1286 case RTE_ETH_FILTER_NTUPLE:
1287 sfc_err(sa, "NTUPLE filters not supported");
1289 case RTE_ETH_FILTER_TUNNEL:
1290 sfc_err(sa, "Tunnel filters not supported");
1292 case RTE_ETH_FILTER_FDIR:
1293 sfc_err(sa, "Flow Director filters not supported");
1295 case RTE_ETH_FILTER_HASH:
1296 sfc_err(sa, "Hash filters not supported");
1298 case RTE_ETH_FILTER_GENERIC:
1299 if (filter_op != RTE_ETH_FILTER_GET) {
1302 *(const void **)arg = &sfc_flow_ops;
1307 sfc_err(sa, "Unknown filter type %u", filter_type);
1311 sfc_log_init(sa, "exit: %d", -rc);
1312 SFC_ASSERT(rc >= 0);
1316 static const struct eth_dev_ops sfc_eth_dev_ops = {
1317 .dev_configure = sfc_dev_configure,
1318 .dev_start = sfc_dev_start,
1319 .dev_stop = sfc_dev_stop,
1320 .dev_set_link_up = sfc_dev_set_link_up,
1321 .dev_set_link_down = sfc_dev_set_link_down,
1322 .dev_close = sfc_dev_close,
1323 .promiscuous_enable = sfc_dev_promisc_enable,
1324 .promiscuous_disable = sfc_dev_promisc_disable,
1325 .allmulticast_enable = sfc_dev_allmulti_enable,
1326 .allmulticast_disable = sfc_dev_allmulti_disable,
1327 .link_update = sfc_dev_link_update,
1328 .stats_get = sfc_stats_get,
1329 .stats_reset = sfc_stats_reset,
1330 .xstats_get = sfc_xstats_get,
1331 .xstats_reset = sfc_stats_reset,
1332 .xstats_get_names = sfc_xstats_get_names,
1333 .dev_infos_get = sfc_dev_infos_get,
1334 .dev_supported_ptypes_get = sfc_dev_supported_ptypes_get,
1335 .mtu_set = sfc_dev_set_mtu,
1336 .rx_queue_start = sfc_rx_queue_start,
1337 .rx_queue_stop = sfc_rx_queue_stop,
1338 .tx_queue_start = sfc_tx_queue_start,
1339 .tx_queue_stop = sfc_tx_queue_stop,
1340 .rx_queue_setup = sfc_rx_queue_setup,
1341 .rx_queue_release = sfc_rx_queue_release,
1342 .rx_queue_count = sfc_rx_queue_count,
1343 .rx_descriptor_done = sfc_rx_descriptor_done,
1344 .tx_queue_setup = sfc_tx_queue_setup,
1345 .tx_queue_release = sfc_tx_queue_release,
1346 .flow_ctrl_get = sfc_flow_ctrl_get,
1347 .flow_ctrl_set = sfc_flow_ctrl_set,
1348 .mac_addr_set = sfc_mac_addr_set,
1349 #if EFSYS_OPT_RX_SCALE
1350 .reta_update = sfc_dev_rss_reta_update,
1351 .reta_query = sfc_dev_rss_reta_query,
1352 .rss_hash_update = sfc_dev_rss_hash_update,
1353 .rss_hash_conf_get = sfc_dev_rss_hash_conf_get,
1355 .filter_ctrl = sfc_dev_filter_ctrl,
1356 .set_mc_addr_list = sfc_set_mc_addr_list,
1357 .rxq_info_get = sfc_rx_queue_info_get,
1358 .txq_info_get = sfc_tx_queue_info_get,
1359 .fw_version_get = sfc_fw_version_get,
1363 sfc_eth_dev_set_ops(struct rte_eth_dev *dev)
1365 struct sfc_adapter *sa = dev->data->dev_private;
1366 unsigned int avail_caps = 0;
1367 const char *rx_name = NULL;
1368 const char *tx_name = NULL;
1371 switch (sa->family) {
1372 case EFX_FAMILY_HUNTINGTON:
1373 case EFX_FAMILY_MEDFORD:
1374 avail_caps |= SFC_DP_HW_FW_CAP_EF10;
1380 rc = sfc_kvargs_process(sa, SFC_KVARG_RX_DATAPATH,
1381 sfc_kvarg_string_handler, &rx_name);
1383 goto fail_kvarg_rx_datapath;
1385 if (rx_name != NULL) {
1386 sa->dp_rx = sfc_dp_find_rx_by_name(&sfc_dp_head, rx_name);
1387 if (sa->dp_rx == NULL) {
1388 sfc_err(sa, "Rx datapath %s not found", rx_name);
1392 if (!sfc_dp_match_hw_fw_caps(&sa->dp_rx->dp, avail_caps)) {
1394 "Insufficient Hw/FW capabilities to use Rx datapath %s",
1400 sa->dp_rx = sfc_dp_find_rx_by_caps(&sfc_dp_head, avail_caps);
1401 if (sa->dp_rx == NULL) {
1402 sfc_err(sa, "Rx datapath by caps %#x not found",
1409 sfc_info(sa, "use %s Rx datapath", sa->dp_rx->dp.name);
1411 dev->rx_pkt_burst = sa->dp_rx->pkt_burst;
1413 rc = sfc_kvargs_process(sa, SFC_KVARG_TX_DATAPATH,
1414 sfc_kvarg_string_handler, &tx_name);
1416 goto fail_kvarg_tx_datapath;
1418 if (tx_name != NULL) {
1419 sa->dp_tx = sfc_dp_find_tx_by_name(&sfc_dp_head, tx_name);
1420 if (sa->dp_tx == NULL) {
1421 sfc_err(sa, "Tx datapath %s not found", tx_name);
1425 if (!sfc_dp_match_hw_fw_caps(&sa->dp_tx->dp, avail_caps)) {
1427 "Insufficient Hw/FW capabilities to use Tx datapath %s",
1433 sa->dp_tx = sfc_dp_find_tx_by_caps(&sfc_dp_head, avail_caps);
1434 if (sa->dp_tx == NULL) {
1435 sfc_err(sa, "Tx datapath by caps %#x not found",
1442 sfc_info(sa, "use %s Tx datapath", sa->dp_tx->dp.name);
1444 dev->tx_pkt_burst = sa->dp_tx->pkt_burst;
1446 dev->dev_ops = &sfc_eth_dev_ops;
1451 fail_kvarg_tx_datapath:
1453 fail_kvarg_rx_datapath:
1458 sfc_register_dp(void)
1461 if (TAILQ_EMPTY(&sfc_dp_head)) {
1462 /* Prefer EF10 datapath */
1463 sfc_dp_register(&sfc_dp_head, &sfc_ef10_rx.dp);
1464 sfc_dp_register(&sfc_dp_head, &sfc_efx_rx.dp);
1466 sfc_dp_register(&sfc_dp_head, &sfc_ef10_tx.dp);
1467 sfc_dp_register(&sfc_dp_head, &sfc_efx_tx.dp);
1468 sfc_dp_register(&sfc_dp_head, &sfc_ef10_simple_tx.dp);
1473 sfc_eth_dev_init(struct rte_eth_dev *dev)
1475 struct sfc_adapter *sa = dev->data->dev_private;
1476 struct rte_pci_device *pci_dev = SFC_DEV_TO_PCI(dev);
1478 const efx_nic_cfg_t *encp;
1479 const struct ether_addr *from;
1483 /* Required for logging */
1486 /* Copy PCI device info to the dev->data */
1487 rte_eth_copy_pci_info(dev, pci_dev);
1489 rc = sfc_kvargs_parse(sa);
1491 goto fail_kvargs_parse;
1493 rc = sfc_kvargs_process(sa, SFC_KVARG_DEBUG_INIT,
1494 sfc_kvarg_bool_handler, &sa->debug_init);
1496 goto fail_kvarg_debug_init;
1498 sfc_log_init(sa, "entry");
1500 dev->data->mac_addrs = rte_zmalloc("sfc", ETHER_ADDR_LEN, 0);
1501 if (dev->data->mac_addrs == NULL) {
1503 goto fail_mac_addrs;
1506 sfc_adapter_lock_init(sa);
1507 sfc_adapter_lock(sa);
1509 sfc_log_init(sa, "probing");
1514 sfc_log_init(sa, "set device ops");
1515 rc = sfc_eth_dev_set_ops(dev);
1519 sfc_log_init(sa, "attaching");
1520 rc = sfc_attach(sa);
1524 encp = efx_nic_cfg_get(sa->nic);
1527 * The arguments are really reverse order in comparison to
1528 * Linux kernel. Copy from NIC config to Ethernet device data.
1530 from = (const struct ether_addr *)(encp->enc_mac_addr);
1531 ether_addr_copy(from, &dev->data->mac_addrs[0]);
1533 sfc_adapter_unlock(sa);
1535 sfc_log_init(sa, "done");
1543 sfc_adapter_unlock(sa);
1544 sfc_adapter_lock_fini(sa);
1545 rte_free(dev->data->mac_addrs);
1546 dev->data->mac_addrs = NULL;
1549 fail_kvarg_debug_init:
1550 sfc_kvargs_cleanup(sa);
1553 sfc_log_init(sa, "failed %d", rc);
1559 sfc_eth_dev_uninit(struct rte_eth_dev *dev)
1561 struct sfc_adapter *sa = dev->data->dev_private;
1563 sfc_log_init(sa, "entry");
1565 sfc_adapter_lock(sa);
1570 rte_free(dev->data->mac_addrs);
1571 dev->data->mac_addrs = NULL;
1573 dev->dev_ops = NULL;
1574 dev->rx_pkt_burst = NULL;
1575 dev->tx_pkt_burst = NULL;
1577 sfc_kvargs_cleanup(sa);
1579 sfc_adapter_unlock(sa);
1580 sfc_adapter_lock_fini(sa);
1582 sfc_log_init(sa, "done");
1584 /* Required for logging, so cleanup last */
1589 static const struct rte_pci_id pci_id_sfc_efx_map[] = {
1590 { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_FARMINGDALE) },
1591 { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_FARMINGDALE_VF) },
1592 { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_GREENPORT) },
1593 { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_GREENPORT_VF) },
1594 { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_MEDFORD) },
1595 { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_MEDFORD_VF) },
1596 { .vendor_id = 0 /* sentinel */ }
1599 static struct eth_driver sfc_efx_pmd = {
1601 .id_table = pci_id_sfc_efx_map,
1603 RTE_PCI_DRV_INTR_LSC |
1604 RTE_PCI_DRV_NEED_MAPPING,
1605 .probe = rte_eth_dev_pci_probe,
1606 .remove = rte_eth_dev_pci_remove,
1608 .eth_dev_init = sfc_eth_dev_init,
1609 .eth_dev_uninit = sfc_eth_dev_uninit,
1610 .dev_private_size = sizeof(struct sfc_adapter),
1613 RTE_PMD_REGISTER_PCI(net_sfc_efx, sfc_efx_pmd.pci_drv);
1614 RTE_PMD_REGISTER_PCI_TABLE(net_sfc_efx, pci_id_sfc_efx_map);
1615 RTE_PMD_REGISTER_KMOD_DEP(net_sfc_efx, "* igb_uio | uio_pci_generic | vfio");
1616 RTE_PMD_REGISTER_PARAM_STRING(net_sfc_efx,
1617 SFC_KVARG_RX_DATAPATH "=" SFC_KVARG_VALUES_RX_DATAPATH " "
1618 SFC_KVARG_TX_DATAPATH "=" SFC_KVARG_VALUES_TX_DATAPATH " "
1619 SFC_KVARG_PERF_PROFILE "=" SFC_KVARG_VALUES_PERF_PROFILE " "
1620 SFC_KVARG_STATS_UPDATE_PERIOD_MS "=<long> "
1621 SFC_KVARG_MCDI_LOGGING "=" SFC_KVARG_VALUES_BOOL " "
1622 SFC_KVARG_DEBUG_INIT "=" SFC_KVARG_VALUES_BOOL);