From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nbfkord-smmo02.seg.att.com (nbfkord-smmo02.seg.att.com [209.65.160.78]) by dpdk.org (Postfix) with ESMTP id 9E3BE2A5D for ; Mon, 21 Nov 2016 16:01:41 +0100 (CET) Received: from unknown [12.187.104.26] by nbfkord-smmo02.seg.att.com(mxl_mta-7.2.4-7) with SMTP id 55c03385.0.1541296.00-2318.3424248.nbfkord-smmo02.seg.att.com (envelope-from ); Mon, 21 Nov 2016 15:01:41 +0000 (UTC) X-MXL-Hash: 58330c555cb82f2c-03accbf6b88cd4b94dbe722d6011924f06e77839 Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Mon, 21 Nov 2016 07:01:22 -0800 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25 via Frontend Transport; Mon, 21 Nov 2016 07:01:22 -0800 Received: from uklogin.uk.solarflarecom.com (uklogin.uk.solarflarecom.com [10.17.10.10]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id uALF1LxU007230 for ; Mon, 21 Nov 2016 15:01:21 GMT Received: from uklogin.uk.solarflarecom.com (localhost.localdomain [127.0.0.1]) by uklogin.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id uALF1J3Z006765 for ; Mon, 21 Nov 2016 15:01:21 GMT From: Andrew Rybchenko To: Date: Mon, 21 Nov 2016 15:00:58 +0000 Message-ID: <1479740470-6723-45-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1479740470-6723-1-git-send-email-arybchenko@solarflare.com> References: <1479740470-6723-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-AnalysisOut: [v=2.1 cv=UI/baXry c=1 sm=1 tr=0 a=8BlWFWvVlq5taO8ncb8nKg==] X-AnalysisOut: [:17 a=L24OOQBejmoA:10 a=zRKbQ67AAAAA:8 a=3AGVCxh2S-hBM6XUf] X-AnalysisOut: [DkA:9 a=PA03WX8tBzeizutn5_OT:22] X-Spam: [F=0.2000000000; CM=0.500; S=0.200(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [12.187.104.26] Subject: [dpdk-dev] [PATCH 44/56] net/sfc: implement Rx subsystem stubs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Nov 2016 15:01:42 -0000 Reviewed-by: Andy Moreton Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/efx/Makefile | 1 + drivers/net/sfc/efx/sfc.c | 9 ++++ drivers/net/sfc/efx/sfc.h | 4 ++ drivers/net/sfc/efx/sfc_ethdev.c | 10 ++++ drivers/net/sfc/efx/sfc_rx.c | 104 +++++++++++++++++++++++++++++++++++++++ drivers/net/sfc/efx/sfc_rx.h | 53 ++++++++++++++++++++ 6 files changed, 181 insertions(+) create mode 100644 drivers/net/sfc/efx/sfc_rx.c create mode 100644 drivers/net/sfc/efx/sfc_rx.h diff --git a/drivers/net/sfc/efx/Makefile b/drivers/net/sfc/efx/Makefile index 6e860b8..eb82c89 100644 --- a/drivers/net/sfc/efx/Makefile +++ b/drivers/net/sfc/efx/Makefile @@ -87,6 +87,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_mcdi.c 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 VPATH += $(SRCDIR)/base diff --git a/drivers/net/sfc/efx/sfc.c b/drivers/net/sfc/efx/sfc.c index 01e0c94..c0f48a8 100644 --- a/drivers/net/sfc/efx/sfc.c +++ b/drivers/net/sfc/efx/sfc.c @@ -37,6 +37,7 @@ #include "sfc.h" #include "sfc_log.h" #include "sfc_ev.h" +#include "sfc_rx.h" int @@ -349,10 +350,17 @@ sfc_configure(struct sfc_adapter *sa) if (rc != 0) goto fail_port_init; + rc = sfc_rx_init(sa); + if (rc != 0) + goto fail_rx_init; + sa->state = SFC_ADAPTER_CONFIGURED; sfc_log_init(sa, "done"); return 0; +fail_rx_init: + sfc_port_fini(sa); + fail_port_init: sfc_ev_fini(sa); @@ -376,6 +384,7 @@ sfc_close(struct sfc_adapter *sa) SFC_ASSERT(sa->state == SFC_ADAPTER_CONFIGURED); sa->state = SFC_ADAPTER_CLOSING; + sfc_rx_fini(sa); sfc_port_fini(sa); sfc_ev_fini(sa); sfc_intr_fini(sa); diff --git a/drivers/net/sfc/efx/sfc.h b/drivers/net/sfc/efx/sfc.h index f328482..a592b53 100644 --- a/drivers/net/sfc/efx/sfc.h +++ b/drivers/net/sfc/efx/sfc.h @@ -114,6 +114,7 @@ struct sfc_intr { }; struct sfc_evq_info; +struct sfc_rxq_info; struct sfc_port { unsigned int flow_ctrl; @@ -152,6 +153,9 @@ struct sfc_adapter { unsigned int mgmt_evq_index; rte_spinlock_t mgmt_evq_lock; + + unsigned int rxq_count; + struct sfc_rxq_info *rxq_info; }; /* diff --git a/drivers/net/sfc/efx/sfc_ethdev.c b/drivers/net/sfc/efx/sfc_ethdev.c index a8a6a17..8d628fe 100644 --- a/drivers/net/sfc/efx/sfc_ethdev.c +++ b/drivers/net/sfc/efx/sfc_ethdev.c @@ -48,6 +48,16 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) sfc_log_init(sa, "entry"); dev_info->max_rx_pktlen = EFX_MAC_PDU_MAX; + + /* By default packets are dropped if no descriptors are available */ + dev_info->default_rxconf.rx_drop_en = 1; + + 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; } static int diff --git a/drivers/net/sfc/efx/sfc_rx.c b/drivers/net/sfc/efx/sfc_rx.c new file mode 100644 index 0000000..961e6b6 --- /dev/null +++ b/drivers/net/sfc/efx/sfc_rx.c @@ -0,0 +1,104 @@ +/*- + * 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 "efx.h" + +#include "sfc.h" +#include "sfc_log.h" +#include "sfc_rx.h" + +static int +sfc_rx_qinit_info(struct sfc_adapter *sa, unsigned int sw_index) +{ + struct sfc_rxq_info *rxq_info = &sa->rxq_info[sw_index]; + unsigned int max_entries; + int rc; + + max_entries = EFX_RXQ_MAXNDESCS; + SFC_ASSERT(rte_is_power_of_2(max_entries)); + + rxq_info->max_entries = max_entries; + + return 0; +} + +/** + * Initialize Rx subsystem. + * + * Called at device configuration stage when number of receive queues is + * specified together with other device level receive configuration. + * + * It should be used to allocate NUMA-unaware resources. + */ +int +sfc_rx_init(struct sfc_adapter *sa) +{ + unsigned int sw_index; + int rc; + + sa->rxq_count = sa->eth_dev->data->nb_rx_queues; + + rc = ENOMEM; + sa->rxq_info = rte_calloc_socket("sfc-rxqs", sa->rxq_count, + sizeof(struct sfc_rxq_info), 0, + sa->socket_id); + if (sa->rxq_info == NULL) + goto fail_rxqs_alloc; + + for (sw_index = 0; sw_index < sa->rxq_count; ++sw_index) { + rc = sfc_rx_qinit_info(sa, sw_index); + if (rc != 0) + goto fail_rx_qinit_info; + } + + return 0; + +fail_rx_qinit_info: + rte_free(sa->rxq_info); + sa->rxq_info = NULL; + +fail_rxqs_alloc: + sa->rxq_count = 0; + sfc_log_init(sa, "failed %d", rc); + return rc; +} + +/** + * Shutdown Rx subsystem. + * + * Called at device close stage, for example, before device + * reconfiguration or shutdown. + */ +void +sfc_rx_fini(struct sfc_adapter *sa) +{ + rte_free(sa->rxq_info); + sa->rxq_info = NULL; + sa->rxq_count = 0; +} diff --git a/drivers/net/sfc/efx/sfc_rx.h b/drivers/net/sfc/efx/sfc_rx.h new file mode 100644 index 0000000..c1758a1 --- /dev/null +++ b/drivers/net/sfc/efx/sfc_rx.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_RX_H +#define _SFC_RX_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct sfc_adapter; + +/** + * Receive queue information used during setup/release only. + * Allocated on the same socket as adapter data. + */ +struct sfc_rxq_info { + unsigned int max_entries; +}; + +int sfc_rx_init(struct sfc_adapter *sa); +void sfc_rx_fini(struct sfc_adapter *sa); + +#ifdef __cplusplus +} +#endif +#endif /* _SFC_RX_H */ -- 2.5.5