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 AA5BAA034F; Mon, 11 Oct 2021 16:49:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A1C084113B; Mon, 11 Oct 2021 16:49:27 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id CC14041139 for ; Mon, 11 Oct 2021 16:49:26 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 9950B7F6F8; Mon, 11 Oct 2021 17:49:26 +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 91C767F6FA; Mon, 11 Oct 2021 17:49:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 91C767F6FA Authentication-Results: shelob.oktetlabs.ru/91C767F6FA; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org Cc: Igor Romanov , Andy Moreton , Ivan Malov Date: Mon, 11 Oct 2021 17:48:25 +0300 Message-Id: <20211011144857.446802-7-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211011144857.446802-1-andrew.rybchenko@oktetlabs.ru> References: <20210827065717.1838258-1-andrew.rybchenko@oktetlabs.ru> <20211011144857.446802-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 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 b353bfe358..7f5212c3fd 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -2248,6 +2248,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, -- 2.30.2