From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A6BD9A0C43; Fri, 27 Aug 2021 08:59:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6716441287; Fri, 27 Aug 2021 08:58:43 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 06FB941251 for ; Fri, 27 Aug 2021 08:58:37 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 6D19E7F6DE; Fri, 27 Aug 2021 09:58:36 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id A56B87F6E2; Fri, 27 Aug 2021 09:57:34 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru A56B87F6E2 Authentication-Results: shelob.oktetlabs.ru/A56B87F6E2; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org Cc: Igor Romanov , Andy Moreton , Ivan Malov Date: Fri, 27 Aug 2021 09:56:56 +0300 Message-Id: <20210827065717.1838258-18-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210827065717.1838258-1-andrew.rybchenko@oktetlabs.ru> References: <20210827065717.1838258-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 17/38] net/sfc: implement representor RxQ start/stop X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Igor Romanov Add extra libefx flags to Rx queue information initialization function interface to be able to specify the ingress m-port flag for a representor RxQ. Rx prefix of packets on that queue will contain ingress m-port field required for packet forwarding in representor proxy. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton Reviewed-by: Ivan Malov --- drivers/net/sfc/sfc_ev.h | 8 ++ drivers/net/sfc/sfc_repr_proxy.c | 194 +++++++++++++++++++++++++++++++ drivers/net/sfc/sfc_repr_proxy.h | 7 ++ 3 files changed, 209 insertions(+) diff --git a/drivers/net/sfc/sfc_ev.h b/drivers/net/sfc/sfc_ev.h index 590cfb1694..bcb7fbe466 100644 --- a/drivers/net/sfc/sfc_ev.h +++ b/drivers/net/sfc/sfc_ev.h @@ -110,6 +110,14 @@ sfc_counters_rxq_sw_index(const struct sfc_adapter_shared *sas) return sas->counters_rxq_allocated ? 0 : SFC_SW_INDEX_INVALID; } +static inline sfc_sw_index_t +sfc_repr_rxq_sw_index(const struct sfc_adapter_shared *sas, + unsigned int repr_queue_id) +{ + return sfc_counters_rxq_sw_index(sas) + sfc_repr_nb_rxq(sas) + + repr_queue_id; +} + /* * Functions below define event queue to transmit/receive queue and vice * versa mapping. diff --git a/drivers/net/sfc/sfc_repr_proxy.c b/drivers/net/sfc/sfc_repr_proxy.c index 6a89cca40a..03b6421b04 100644 --- a/drivers/net/sfc/sfc_repr_proxy.c +++ b/drivers/net/sfc/sfc_repr_proxy.c @@ -15,6 +15,8 @@ #include "sfc_repr_proxy.h" #include "sfc_repr_proxy_api.h" #include "sfc.h" +#include "sfc_ev.h" +#include "sfc_rx.h" /** * Amount of time to wait for the representor proxy routine (which is @@ -136,6 +138,181 @@ sfc_repr_proxy_routine(void *arg) return 0; } +static int +sfc_repr_proxy_rxq_attach(struct sfc_adapter *sa) +{ + struct sfc_adapter_shared * const sas = sfc_sa2shared(sa); + struct sfc_repr_proxy *rp = &sa->repr_proxy; + unsigned int i; + + sfc_log_init(sa, "entry"); + + for (i = 0; i < sfc_repr_nb_rxq(sas); i++) { + sfc_sw_index_t sw_index = sfc_repr_rxq_sw_index(sas, i); + + rp->dp_rxq[i].sw_index = sw_index; + } + + sfc_log_init(sa, "done"); + + return 0; +} + +static void +sfc_repr_proxy_rxq_detach(struct sfc_adapter *sa) +{ + struct sfc_adapter_shared * const sas = sfc_sa2shared(sa); + struct sfc_repr_proxy *rp = &sa->repr_proxy; + unsigned int i; + + sfc_log_init(sa, "entry"); + + for (i = 0; i < sfc_repr_nb_rxq(sas); i++) + rp->dp_rxq[i].sw_index = 0; + + sfc_log_init(sa, "done"); +} + +static int +sfc_repr_proxy_rxq_init(struct sfc_adapter *sa, + struct sfc_repr_proxy_dp_rxq *rxq) +{ + struct sfc_adapter_shared * const sas = sfc_sa2shared(sa); + uint16_t nb_rx_desc = SFC_REPR_PROXY_RX_DESC_COUNT; + struct sfc_rxq_info *rxq_info; + struct rte_eth_rxconf rxconf = { + .rx_free_thresh = SFC_REPR_PROXY_RXQ_REFILL_LEVEL, + .rx_drop_en = 1, + }; + int rc; + + sfc_log_init(sa, "entry"); + + rxq_info = &sas->rxq_info[rxq->sw_index]; + if (rxq_info->state & SFC_RXQ_INITIALIZED) { + sfc_log_init(sa, "RxQ is already initialized - skip"); + return 0; + } + + nb_rx_desc = RTE_MIN(nb_rx_desc, sa->rxq_max_entries); + nb_rx_desc = RTE_MAX(nb_rx_desc, sa->rxq_min_entries); + + rc = sfc_rx_qinit_info(sa, rxq->sw_index, EFX_RXQ_FLAG_INGRESS_MPORT); + if (rc != 0) { + sfc_err(sa, "failed to init representor proxy RxQ info"); + goto fail_repr_rxq_init_info; + } + + rc = sfc_rx_qinit(sa, rxq->sw_index, nb_rx_desc, sa->socket_id, &rxconf, + rxq->mp); + if (rc != 0) { + sfc_err(sa, "failed to init representor proxy RxQ"); + goto fail_repr_rxq_init; + } + + sfc_log_init(sa, "done"); + + return 0; + +fail_repr_rxq_init: +fail_repr_rxq_init_info: + sfc_log_init(sa, "failed: %s", rte_strerror(rc)); + + return rc; +} + +static void +sfc_repr_proxy_rxq_fini(struct sfc_adapter *sa) +{ + struct sfc_adapter_shared * const sas = sfc_sa2shared(sa); + struct sfc_repr_proxy *rp = &sa->repr_proxy; + struct sfc_rxq_info *rxq_info; + unsigned int i; + + sfc_log_init(sa, "entry"); + + if (!sfc_repr_available(sas)) { + sfc_log_init(sa, "representors not supported - skip"); + return; + } + + for (i = 0; i < sfc_repr_nb_rxq(sas); i++) { + struct sfc_repr_proxy_dp_rxq *rxq = &rp->dp_rxq[i]; + + rxq_info = &sas->rxq_info[rxq->sw_index]; + if (rxq_info->state != SFC_RXQ_INITIALIZED) { + sfc_log_init(sa, + "representor RxQ %u is already finalized - skip", + i); + continue; + } + + sfc_rx_qfini(sa, rxq->sw_index); + } + + sfc_log_init(sa, "done"); +} + +static void +sfc_repr_proxy_rxq_stop(struct sfc_adapter *sa) +{ + struct sfc_adapter_shared * const sas = sfc_sa2shared(sa); + unsigned int i; + + sfc_log_init(sa, "entry"); + + for (i = 0; i < sfc_repr_nb_rxq(sas); i++) + sfc_rx_qstop(sa, sa->repr_proxy.dp_rxq[i].sw_index); + + sfc_repr_proxy_rxq_fini(sa); + + sfc_log_init(sa, "done"); +} + +static int +sfc_repr_proxy_rxq_start(struct sfc_adapter *sa) +{ + struct sfc_adapter_shared * const sas = sfc_sa2shared(sa); + struct sfc_repr_proxy *rp = &sa->repr_proxy; + unsigned int i; + int rc; + + sfc_log_init(sa, "entry"); + + if (!sfc_repr_available(sas)) { + sfc_log_init(sa, "representors not supported - skip"); + return 0; + } + + for (i = 0; i < sfc_repr_nb_rxq(sas); i++) { + struct sfc_repr_proxy_dp_rxq *rxq = &rp->dp_rxq[i]; + + rc = sfc_repr_proxy_rxq_init(sa, rxq); + if (rc != 0) { + sfc_err(sa, "failed to init representor proxy RxQ %u", + i); + goto fail_init; + } + + rc = sfc_rx_qstart(sa, rxq->sw_index); + if (rc != 0) { + sfc_err(sa, "failed to start representor proxy RxQ %u", + i); + goto fail_start; + } + } + + sfc_log_init(sa, "done"); + + return 0; + +fail_start: +fail_init: + sfc_repr_proxy_rxq_stop(sa); + sfc_log_init(sa, "failed: %s", rte_strerror(rc)); + return rc; +} + static int sfc_repr_proxy_ports_init(struct sfc_adapter *sa) { @@ -217,6 +394,10 @@ sfc_repr_proxy_attach(struct sfc_adapter *sa) return 0; } + rc = sfc_repr_proxy_rxq_attach(sa); + if (rc != 0) + goto fail_rxq_attach; + rc = sfc_repr_proxy_ports_init(sa); if (rc != 0) goto fail_ports_init; @@ -277,6 +458,9 @@ sfc_repr_proxy_attach(struct sfc_adapter *sa) sfc_repr_proxy_ports_fini(sa); fail_ports_init: + sfc_repr_proxy_rxq_detach(sa); + +fail_rxq_attach: sfc_log_init(sa, "failed: %s", rte_strerror(rc)); return rc; } @@ -297,6 +481,7 @@ sfc_repr_proxy_detach(struct sfc_adapter *sa) rte_service_map_lcore_set(rp->service_id, rp->service_core_id, 0); rte_service_component_unregister(rp->service_id); sfc_repr_proxy_ports_fini(sa); + sfc_repr_proxy_rxq_detach(sa); sfc_log_init(sa, "done"); } @@ -319,6 +504,10 @@ sfc_repr_proxy_start(struct sfc_adapter *sa) return 0; } + rc = sfc_repr_proxy_rxq_start(sa); + if (rc != 0) + goto fail_rxq_start; + /* Service core may be in "stopped" state, start it */ rc = rte_service_lcore_start(rp->service_core_id); if (rc != 0 && rc != -EALREADY) { @@ -360,6 +549,9 @@ sfc_repr_proxy_start(struct sfc_adapter *sa) /* Service lcore may be shared and we never stop it */ fail_start_core: + sfc_repr_proxy_rxq_stop(sa); + +fail_rxq_start: sfc_log_init(sa, "failed: %s", rte_strerror(rc)); return rc; } @@ -394,6 +586,8 @@ sfc_repr_proxy_stop(struct sfc_adapter *sa) /* Service lcore may be shared and we never stop it */ + sfc_repr_proxy_rxq_stop(sa); + rp->started = false; sfc_log_init(sa, "done"); diff --git a/drivers/net/sfc/sfc_repr_proxy.h b/drivers/net/sfc/sfc_repr_proxy.h index bd7ad7148a..dca3fca2b9 100644 --- a/drivers/net/sfc/sfc_repr_proxy.h +++ b/drivers/net/sfc/sfc_repr_proxy.h @@ -18,6 +18,7 @@ #include "efx.h" #include "sfc_repr.h" +#include "sfc_dp.h" #ifdef __cplusplus extern "C" { @@ -31,6 +32,10 @@ extern "C" { #define SFC_REPR_PROXY_NB_TXQ_MIN (1) #define SFC_REPR_PROXY_NB_TXQ_MAX (1) +#define SFC_REPR_PROXY_RX_DESC_COUNT 256 +#define SFC_REPR_PROXY_RXQ_REFILL_LEVEL (SFC_REPR_PROXY_RX_DESC_COUNT / 4) +#define SFC_REPR_PROXY_RX_BURST 32 + struct sfc_repr_proxy_rxq { struct rte_ring *ring; struct rte_mempool *mb_pool; @@ -52,6 +57,8 @@ struct sfc_repr_proxy_port { struct sfc_repr_proxy_dp_rxq { struct rte_mempool *mp; unsigned int ref_count; + + sfc_sw_index_t sw_index; }; enum sfc_repr_proxy_mbox_op { -- 2.30.2