From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 123FDA0679 for ; Tue, 2 Apr 2019 11:30:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 12D225F1A; Tue, 2 Apr 2019 11:29:23 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 180E44C8F for ; Tue, 2 Apr 2019 11:29:05 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (webmail.solarflare.com [12.187.104.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id 5363010007E; Tue, 2 Apr 2019 09:28:58 +0000 (UTC) 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.1395.4; Tue, 2 Apr 2019 02:28:55 -0700 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.1395.4 via Frontend Transport; Tue, 2 Apr 2019 02:28:55 -0700 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id x329Sr5u028269; Tue, 2 Apr 2019 10:28:53 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id DBE23161610; Tue, 2 Apr 2019 10:28:53 +0100 (BST) From: Andrew Rybchenko To: CC: Igor Romanov Date: Tue, 2 Apr 2019 10:28:39 +0100 Message-ID: <1554197324-32391-8-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1554197324-32391-1-git-send-email-arybchenko@solarflare.com> References: <1554197324-32391-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24526.005 X-TM-AS-Result: No-11.733300-4.000000-10 X-TMASE-MatchedRID: hBctg3n6uw8yEYUlBvqHoh+WEMjoO9WWTJDl9FKHbrkKogmGusPLb7hM KKwx1memJLJED3bHtl7TCjYGJ20tiX/6I2TJrPffdXu122+iJtrGYnoF/CTeZeVLofsFQv6xOUy eBugoF8X0shYcMYIWz9e9LQYmNJh4oRBuyTyY0I2QOktEo73GFDfwU1OWX2US/NpLPdn/hpo6cg wTFeDdf0v7BxPBPjToQr7W/2h+I70fE8yM4pjsDwtuKBGekqUpI/NGWt0UYPAd1/kjzLMiBuHEa ii5fXWSAbEzkJrNVraaG2DktqYnJnzvDlMXZnfD X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--11.733300-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24526.005 X-MDID: 1554197339-K5jL7idS81C7 Subject: [dpdk-dev] [PATCH 07/12] net/sfc: move TSO header checks from Tx burst to Tx prepare X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Message-ID: <20190402092839.otFHARxX3PRauO--5gN-Y-E0H9I65XDTQzCQcpwRtIY@z> From: Igor Romanov Tx offloads checks should be done in Tx prepare. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/sfc_dp_tx.h | 12 +++++++++--- drivers/net/sfc/sfc_ef10_tx.c | 9 ++++----- drivers/net/sfc/sfc_tso.c | 9 --------- drivers/net/sfc/sfc_tx.c | 20 ++++++++++---------- 4 files changed, 23 insertions(+), 27 deletions(-) diff --git a/drivers/net/sfc/sfc_dp_tx.h b/drivers/net/sfc/sfc_dp_tx.h index 885094b67..c42d0d01f 100644 --- a/drivers/net/sfc/sfc_dp_tx.h +++ b/drivers/net/sfc/sfc_dp_tx.h @@ -195,7 +195,8 @@ sfc_dp_find_tx_by_caps(struct sfc_dp_list *head, unsigned int avail_caps) const struct sfc_dp_tx *sfc_dp_tx_by_dp_txq(const struct sfc_dp_txq *dp_txq); static inline int -sfc_dp_tx_prepare_pkt(struct rte_mbuf *m) +sfc_dp_tx_prepare_pkt(struct rte_mbuf *m, + uint32_t tso_tcp_header_offset_limit) { #ifdef RTE_LIBRTE_SFC_EFX_DEBUG int ret; @@ -209,10 +210,15 @@ sfc_dp_tx_prepare_pkt(struct rte_mbuf *m) SFC_ASSERT(ret < 0); return -ret; } -#else - RTE_SET_USED(m); #endif + if (m->ol_flags & PKT_TX_TCP_SEG) { + unsigned int tcph_off = m->l2_len + m->l3_len; + + if (unlikely(tcph_off > tso_tcp_header_offset_limit)) + return EINVAL; + } + return 0; } diff --git a/drivers/net/sfc/sfc_ef10_tx.c b/drivers/net/sfc/sfc_ef10_tx.c index b317997ca..3d6ba4292 100644 --- a/drivers/net/sfc/sfc_ef10_tx.c +++ b/drivers/net/sfc/sfc_ef10_tx.c @@ -320,9 +320,10 @@ sfc_ef10_try_reap(struct sfc_ef10_txq * const txq, unsigned int added, } static uint16_t -sfc_ef10_prepare_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, +sfc_ef10_prepare_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) { + struct sfc_ef10_txq * const txq = sfc_ef10_txq_by_dp_txq(tx_queue); uint16_t i; for (i = 0; i < nb_pkts; i++) { @@ -347,7 +348,8 @@ sfc_ef10_prepare_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, } } #endif - ret = sfc_dp_tx_prepare_pkt(m); + ret = sfc_dp_tx_prepare_pkt(m, + txq->tso_tcp_header_offset_limit); if (unlikely(ret != 0)) { rte_errno = ret; break; @@ -378,9 +380,6 @@ sfc_ef10_xmit_tso_pkt(struct sfc_ef10_txq * const txq, struct rte_mbuf *m_seg, struct rte_mbuf *m_seg_to_free_up_to = first_m_seg; bool eop; - if (unlikely(tcph_off > txq->tso_tcp_header_offset_limit)) - return EMSGSIZE; - /* * Preliminary estimation of required DMA descriptors, including extra * descriptor for TSO header that is needed when the header is diff --git a/drivers/net/sfc/sfc_tso.c b/drivers/net/sfc/sfc_tso.c index 2c03c0837..f46c0e912 100644 --- a/drivers/net/sfc/sfc_tso.c +++ b/drivers/net/sfc/sfc_tso.c @@ -103,18 +103,9 @@ sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx, size_t nh_off = m->l2_len; /* IP header offset */ size_t tcph_off = m->l2_len + m->l3_len; /* TCP header offset */ size_t header_len = m->l2_len + m->l3_len + m->l4_len; - const efx_nic_cfg_t *encp = efx_nic_cfg_get(txq->evq->sa->nic); idx += SFC_EF10_TSO_OPT_DESCS_NUM; - /* - * The TCP header must start at most 208 bytes into the frame. - * If it starts later than this then the NIC won't realise - * it's a TCP packet and TSO edits won't be applied - */ - if (unlikely(tcph_off > encp->enc_tx_tso_tcp_header_offset_limit)) - return EMSGSIZE; - header_paddr = rte_pktmbuf_iova(m); /* diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c index 16fd220bf..e128bff90 100644 --- a/drivers/net/sfc/sfc_tx.c +++ b/drivers/net/sfc/sfc_tx.c @@ -698,15 +698,19 @@ sfc_efx_tx_maybe_insert_tag(struct sfc_efx_txq *txq, struct rte_mbuf *m, } static uint16_t -sfc_efx_prepare_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, +sfc_efx_prepare_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) { + struct sfc_dp_txq *dp_txq = tx_queue; + struct sfc_efx_txq *txq = sfc_efx_txq_by_dp_txq(dp_txq); + const efx_nic_cfg_t *encp = efx_nic_cfg_get(txq->evq->sa->nic); uint16_t i; for (i = 0; i < nb_pkts; i++) { int ret; - ret = sfc_dp_tx_prepare_pkt(tx_pkts[i]); + ret = sfc_dp_tx_prepare_pkt(tx_pkts[i], + encp->enc_tx_tso_tcp_header_offset_limit); if (unlikely(ret != 0)) { rte_errno = ret; break; @@ -776,14 +780,10 @@ sfc_efx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) */ if (sfc_efx_tso_do(txq, added, &m_seg, &in_off, &pend, &pkt_descs, &pkt_len) != 0) { - /* We may have reached this place for - * one of the following reasons: - * - * 1) Packet header linearization is needed - * and the header length is greater - * than SFC_TSOH_STD_LEN - * 2) TCP header starts at more then - * 208 bytes into the frame + /* We may have reached this place if packet + * header linearization is needed but the + * header length is greater than + * SFC_TSOH_STD_LEN * * We will deceive RTE saying that we have sent * the packet, but we will actually drop it. -- 2.17.1