From: Ivan Malov Date: Tue, 29 Nov 2016 16:19:23 +0000 (+0000) Subject: net/sfc: provide basic stubs for Tx subsystem X-Git-Tag: spdx-start~5048 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=a8ad8cf83f01;p=dpdk.git net/sfc: provide basic stubs for Tx subsystem Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton Reviewed-by: Ferruh Yigit --- diff --git a/doc/guides/nics/features/sfc_efx.ini b/doc/guides/nics/features/sfc_efx.ini index 7dc2e92f11..67df1c6b87 100644 --- a/doc/guides/nics/features/sfc_efx.ini +++ b/doc/guides/nics/features/sfc_efx.ini @@ -5,6 +5,8 @@ ; [Features] Link status = Y +L3 checksum offload = P +L4 checksum offload = P BSD nic_uio = Y Linux UIO = Y Linux VFIO = Y diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst index 8145a6bd3e..aadd775931 100644 --- a/doc/guides/nics/sfc_efx.rst +++ b/doc/guides/nics/sfc_efx.rst @@ -46,6 +46,8 @@ SFC EFX PMD has support for: - Link state information +- IPv4/IPv6 TCP/UDP transmit checksum offload + Non-supported Features ---------------------- diff --git a/drivers/net/sfc/Makefile b/drivers/net/sfc/Makefile index f8969af118..dd099b20c3 100644 --- a/drivers/net/sfc/Makefile +++ b/drivers/net/sfc/Makefile @@ -88,6 +88,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_intr.c SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_ev.c SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_port.c SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_rx.c +SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_tx.c VPATH += $(SRCDIR)/base diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c index 4245fb8779..904ae7dce0 100644 --- a/drivers/net/sfc/sfc.c +++ b/drivers/net/sfc/sfc.c @@ -38,6 +38,7 @@ #include "sfc_log.h" #include "sfc_ev.h" #include "sfc_rx.h" +#include "sfc_tx.h" int @@ -362,10 +363,17 @@ sfc_configure(struct sfc_adapter *sa) if (rc != 0) goto fail_rx_init; + rc = sfc_tx_init(sa); + if (rc != 0) + goto fail_tx_init; + sa->state = SFC_ADAPTER_CONFIGURED; sfc_log_init(sa, "done"); return 0; +fail_tx_init: + sfc_rx_fini(sa); + fail_rx_init: sfc_port_fini(sa); @@ -392,6 +400,7 @@ sfc_close(struct sfc_adapter *sa) SFC_ASSERT(sa->state == SFC_ADAPTER_CONFIGURED); sa->state = SFC_ADAPTER_CLOSING; + sfc_tx_fini(sa); sfc_rx_fini(sa); sfc_port_fini(sa); sfc_ev_fini(sa); @@ -438,6 +447,7 @@ int sfc_attach(struct sfc_adapter *sa) { struct rte_pci_device *pci_dev = SFC_DEV_TO_PCI(sa->eth_dev); + const efx_nic_cfg_t *encp; efx_nic_t *enp; int rc; @@ -488,6 +498,10 @@ sfc_attach(struct sfc_adapter *sa) if (rc != 0) goto fail_estimate_rsrc_limits; + encp = efx_nic_cfg_get(sa->nic); + sa->txq_max_entries = encp->enc_txq_max_ndescs; + SFC_ASSERT(rte_is_power_of_2(sa->txq_max_entries)); + rc = sfc_intr_attach(sa); if (rc != 0) goto fail_intr_attach; diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index e3397ac676..543c36828c 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -118,6 +118,7 @@ struct sfc_intr { struct sfc_evq_info; struct sfc_rxq_info; +struct sfc_txq_info; struct sfc_port { unsigned int flow_ctrl; @@ -151,6 +152,8 @@ struct sfc_adapter { unsigned int rxq_max; unsigned int txq_max; + unsigned int txq_max_entries; + unsigned int evq_count; struct sfc_evq_info *evq_info; @@ -159,6 +162,9 @@ struct sfc_adapter { unsigned int rxq_count; struct sfc_rxq_info *rxq_info; + + unsigned int txq_count; + struct sfc_txq_info *txq_info; }; /* diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 7cb12acd8c..3a511a452a 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -52,16 +52,33 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->max_rx_pktlen = EFX_MAC_PDU_MAX; dev_info->max_rx_queues = sa->rxq_max; + dev_info->max_tx_queues = sa->txq_max; /* By default packets are dropped if no descriptors are available */ dev_info->default_rxconf.rx_drop_en = 1; + dev_info->tx_offload_capa = + DEV_TX_OFFLOAD_IPV4_CKSUM | + DEV_TX_OFFLOAD_UDP_CKSUM | + DEV_TX_OFFLOAD_TCP_CKSUM; + + dev_info->default_txconf.txq_flags = ETH_TXQ_FLAGS_NOVLANOFFL | + ETH_TXQ_FLAGS_NOXSUMSCTP; + dev_info->rx_desc_lim.nb_max = EFX_RXQ_MAXNDESCS; dev_info->rx_desc_lim.nb_min = EFX_RXQ_MINNDESCS; /* The RXQ hardware requires that the descriptor count is a power * of 2, but rx_desc_lim cannot properly describe that constraint. */ dev_info->rx_desc_lim.nb_align = EFX_RXQ_MINNDESCS; + + dev_info->tx_desc_lim.nb_max = sa->txq_max_entries; + dev_info->tx_desc_lim.nb_min = EFX_TXQ_MINNDESCS; + /* + * The TXQ hardware requires that the descriptor count is a power + * of 2, but tx_desc_lim cannot properly describe that constraint + */ + dev_info->tx_desc_lim.nb_align = EFX_TXQ_MINNDESCS; } static int diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c new file mode 100644 index 0000000000..ef4be45ee5 --- /dev/null +++ b/drivers/net/sfc/sfc_tx.c @@ -0,0 +1,82 @@ +/*- + * Copyright (c) 2016 Solarflare Communications Inc. + * All rights reserved. + * + * This software was jointly developed between OKTET Labs (under contract + * for Solarflare) and Solarflare Communications, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sfc.h" +#include "sfc_log.h" +#include "sfc_ev.h" +#include "sfc_tx.h" + +static int +sfc_tx_qinit_info(struct sfc_adapter *sa, unsigned int sw_index) +{ + sfc_log_init(sa, "TxQ = %u", sw_index); + + return 0; +} + +int +sfc_tx_init(struct sfc_adapter *sa) +{ + unsigned int sw_index; + int rc = 0; + + sa->txq_count = sa->eth_dev->data->nb_tx_queues; + + sa->txq_info = rte_calloc_socket("sfc-txqs", sa->txq_count, + sizeof(sa->txq_info[0]), 0, + sa->socket_id); + if (sa->txq_info == NULL) + goto fail_txqs_alloc; + + for (sw_index = 0; sw_index < sa->txq_count; ++sw_index) { + rc = sfc_tx_qinit_info(sa, sw_index); + if (rc != 0) + goto fail_tx_qinit_info; + } + + return 0; + +fail_tx_qinit_info: + rte_free(sa->txq_info); + sa->txq_info = NULL; + +fail_txqs_alloc: + sa->txq_count = 0; + + sfc_log_init(sa, "failed (rc = %d)", rc); + return rc; +} + +void +sfc_tx_fini(struct sfc_adapter *sa) +{ + rte_free(sa->txq_info); + sa->txq_info = NULL; + sa->txq_count = 0; +} diff --git a/drivers/net/sfc/sfc_tx.h b/drivers/net/sfc/sfc_tx.h new file mode 100644 index 0000000000..549abc48cf --- /dev/null +++ b/drivers/net/sfc/sfc_tx.h @@ -0,0 +1,53 @@ +/*- + * Copyright (c) 2016 Solarflare Communications Inc. + * All rights reserved. + * + * This software was jointly developed between OKTET Labs (under contract + * for Solarflare) and Solarflare Communications, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SFC_TX_H +#define _SFC_TX_H + +#include +#include + +#include "efx.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct sfc_adapter; + +struct sfc_txq_info { +}; + +int sfc_tx_init(struct sfc_adapter *sa); +void sfc_tx_fini(struct sfc_adapter *sa); + +#ifdef __cplusplus +} +#endif +#endif /* _SFC_TX_H */