From patchwork Fri Aug 27 06:56:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 97424 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4EB8CA0C43; Fri, 27 Aug 2021 08:58:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5B04941271; Fri, 27 Aug 2021 08:58:00 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 1E59D410E9 for ; Fri, 27 Aug 2021 08:57:57 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id DE1DA7F6FC; Fri, 27 Aug 2021 09:57:56 +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 6B2887F6D6; Fri, 27 Aug 2021 09:57:33 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 6B2887F6D6 Authentication-Results: shelob.oktetlabs.ru/6B2887F6D6; 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:45 +0300 Message-Id: <20210827065717.1838258-7-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 Subject: [dpdk-dev] [PATCH 06/38] net/sfc: support EF100 Tx override prefix 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 internal mbuf dynamic flag and field to request EF100 native Tx datapath to use Tx prefix descriptor to override egress m-port. Overriding egress m-port is necessary on representor Tx burst so that the packet will reach corresponding VF. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton Reviewed-by: Ivan Malov --- drivers/net/sfc/sfc_dp.c | 46 ++++++++++++++++++++++++++++++++++ drivers/net/sfc/sfc_dp.h | 25 ++++++++++++++++++ drivers/net/sfc/sfc_ef100_tx.c | 25 ++++++++++++++++++ drivers/net/sfc/sfc_ethdev.c | 4 +++ 4 files changed, 100 insertions(+) diff --git a/drivers/net/sfc/sfc_dp.c b/drivers/net/sfc/sfc_dp.c index 24ed0898c8..66a84c99c8 100644 --- a/drivers/net/sfc/sfc_dp.c +++ b/drivers/net/sfc/sfc_dp.c @@ -12,6 +12,9 @@ #include #include +#include + +#include "efx.h" #include "sfc_dp.h" #include "sfc_log.h" @@ -77,3 +80,46 @@ sfc_dp_register(struct sfc_dp_list *head, struct sfc_dp *entry) return 0; } + +uint64_t sfc_dp_mport_override; +int sfc_dp_mport_offset = -1; + +int +sfc_dp_mport_register(void) +{ + static const struct rte_mbuf_dynfield mport = { + .name = "rte_net_sfc_dynfield_mport", + .size = sizeof(efx_mport_id_t), + .align = __alignof__(efx_mport_id_t), + }; + static const struct rte_mbuf_dynflag mport_override = { + .name = "rte_net_sfc_dynflag_mport_override", + }; + + int field_offset; + int flag; + + if (sfc_dp_mport_override != 0) { + SFC_GENERIC_LOG(INFO, "%s() already registered", __func__); + return 0; + } + + field_offset = rte_mbuf_dynfield_register(&mport); + if (field_offset < 0) { + SFC_GENERIC_LOG(ERR, "%s() failed to register mport dynfield", + __func__); + return -1; + } + + flag = rte_mbuf_dynflag_register(&mport_override); + if (flag < 0) { + SFC_GENERIC_LOG(ERR, "%s() failed to register mport dynflag", + __func__); + return -1; + } + + sfc_dp_mport_offset = field_offset; + sfc_dp_mport_override = UINT64_C(1) << flag; + + return 0; +} diff --git a/drivers/net/sfc/sfc_dp.h b/drivers/net/sfc/sfc_dp.h index 7fd8f34b0f..f3c6892426 100644 --- a/drivers/net/sfc/sfc_dp.h +++ b/drivers/net/sfc/sfc_dp.h @@ -126,6 +126,31 @@ struct sfc_dp *sfc_dp_find_by_caps(struct sfc_dp_list *head, unsigned int avail_caps); int sfc_dp_register(struct sfc_dp_list *head, struct sfc_dp *entry); +/** + * Dynamically registered mbuf flag "mport_override" (as a bitmask). + * + * If this flag is set in an mbuf then the dynamically registered + * mbuf field "mport" holds a valid value. This is used to direct + * port representor transmit traffic to the correct target port. + */ +extern uint64_t sfc_dp_mport_override; + +/** + * Dynamically registered mbuf field "mport" (mbuf byte offset). + * + * If the dynamically registered "mport_override" flag is set in + * an mbuf then the mbuf "mport" field holds a valid value. This + * is used to direct port representor transmit traffic to the + * correct target port. + */ +extern int sfc_dp_mport_offset; + +/** + * Register dynamic mbuf flag and field which can be used to require Tx override + * prefix descriptor with egress mport set. + */ +int sfc_dp_mport_register(void); + #ifdef __cplusplus } #endif diff --git a/drivers/net/sfc/sfc_ef100_tx.c b/drivers/net/sfc/sfc_ef100_tx.c index 522e9a0d34..51eecbe832 100644 --- a/drivers/net/sfc/sfc_ef100_tx.c +++ b/drivers/net/sfc/sfc_ef100_tx.c @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -309,6 +310,19 @@ sfc_ef100_tx_reap(struct sfc_ef100_txq *txq) sfc_ef100_tx_reap_num_descs(txq, sfc_ef100_tx_process_events(txq)); } +static void +sfc_ef100_tx_qdesc_prefix_create(const struct rte_mbuf *m, efx_oword_t *tx_desc) +{ + efx_mport_id_t *mport_id = + RTE_MBUF_DYNFIELD(m, sfc_dp_mport_offset, efx_mport_id_t *); + + EFX_POPULATE_OWORD_3(*tx_desc, + ESF_GZ_TX_PREFIX_EGRESS_MPORT, + mport_id->id, + ESF_GZ_TX_PREFIX_EGRESS_MPORT_EN, 1, + ESF_GZ_TX_DESC_TYPE, ESE_GZ_TX_DESC_TYPE_PREFIX); +} + static uint8_t sfc_ef100_tx_qdesc_cso_inner_l3(uint64_t tx_tunnel) { @@ -525,6 +539,11 @@ sfc_ef100_tx_pkt_descs_max(const struct rte_mbuf *m) SFC_MBUF_SEG_LEN_MAX)); } + if (m->ol_flags & sfc_dp_mport_override) { + /* Tx override prefix descriptor will be used */ + extra_descs++; + } + /* * Any segment of scattered packet cannot be bigger than maximum * segment length. Make sure that subsequent segments do not need @@ -671,6 +690,12 @@ sfc_ef100_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) break; } + if (m_seg->ol_flags & sfc_dp_mport_override) { + id = added++ & txq->ptr_mask; + sfc_ef100_tx_qdesc_prefix_create(m_seg, + &txq->txq_hw_ring[id]); + } + if (m_seg->ol_flags & PKT_TX_TCP_SEG) { m_seg = sfc_ef100_xmit_tso_pkt(txq, m_seg, &added); } else { diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 41add341a0..8e17189875 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -2245,6 +2245,10 @@ sfc_eth_dev_init(struct rte_eth_dev *dev) return 1; } + rc = sfc_dp_mport_register(); + if (rc != 0) + return rc; + sfc_register_dp(); logtype_main = sfc_register_logtype(&pci_dev->addr,