From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 713894C91 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 9B13510007E; 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 x329Sr4n028272; 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 E77DF161612; Tue, 2 Apr 2019 10:28:53 +0100 (BST) From: Andrew Rybchenko To: CC: Igor Romanov Date: Tue, 2 Apr 2019 10:28:40 +0100 Message-ID: <1554197324-32391-9-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 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24526.005 X-TM-AS-Result: No-10.473600-4.000000-10 X-TMASE-MatchedRID: BgWyh4+V8QQPRVepDWIjx0hwlOfYeSqxgRykyfrH1xkJW4Re2U2py9GX gQphHQmx09NQNrxIpFYBtjkcfRMmqTIRhSUG+oeicYGYuKj6YmB/r8x3wtvaX3aMP8m6qk6ShEs PoifR3f3nsHGifULMdNMKNgYnbS2Jlh5qb5HiiQfMZk86HxFjjqX1XMd/Sqvu1gisw2JKo8lrF3 zE72icb6lVr7hWmDw8xmzLko6q/sDrbAOAP87o65A6S0SjvcYUndls9F9zmi2bKItl61J/yZ+in TK0bC9eKrauXd3MZDV4aBaaKovc7xrm++wprvj/AmY0g1U/u2qRPsFNokFWItCKIk8e+w4t X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--10.473600-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24526.005 X-MDID: 1554197339-5kzl_OWs7OS5 Subject: [dpdk-dev] [PATCH 08/12] net/sfc: introduce descriptor space check in 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: , X-List-Received-Date: Tue, 02 Apr 2019 09:29:06 -0000 From: Igor Romanov Add descriptor space check to Tx prepare function to inform a caller that a packet that needs more than maximum Tx descriptors of a queue can not be sent. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/sfc_dp_tx.h | 31 ++++++++++++++++++++++++++++++- drivers/net/sfc/sfc_ef10_tx.c | 4 +++- drivers/net/sfc/sfc_tx.c | 9 ++++++++- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/net/sfc/sfc_dp_tx.h b/drivers/net/sfc/sfc_dp_tx.h index c42d0d01f..ebc941857 100644 --- a/drivers/net/sfc/sfc_dp_tx.h +++ b/drivers/net/sfc/sfc_dp_tx.h @@ -196,8 +196,13 @@ 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, - uint32_t tso_tcp_header_offset_limit) + uint32_t tso_tcp_header_offset_limit, + unsigned int max_fill_level, + unsigned int nb_tso_descs, + unsigned int nb_vlan_descs) { + unsigned int descs_required = m->nb_segs; + #ifdef RTE_LIBRTE_SFC_EFX_DEBUG int ret; @@ -214,11 +219,35 @@ sfc_dp_tx_prepare_pkt(struct rte_mbuf *m, if (m->ol_flags & PKT_TX_TCP_SEG) { unsigned int tcph_off = m->l2_len + m->l3_len; + unsigned int header_len = tcph_off + m->l4_len; if (unlikely(tcph_off > tso_tcp_header_offset_limit)) return EINVAL; + + descs_required += nb_tso_descs; + + /* + * Extra descriptor that is required when a packet header + * is separated from remaining content of the first segment. + */ + if (rte_pktmbuf_data_len(m) > header_len) + descs_required++; } + /* + * The number of VLAN descriptors is added regardless of requested + * VLAN offload since VLAN is sticky and sending packet without VLAN + * insertion may require VLAN descriptor to reset the sticky to 0. + */ + descs_required += nb_vlan_descs; + + /* + * Max fill level must be sufficient to hold all required descriptors + * to send the packet entirely. + */ + if (descs_required > max_fill_level) + return ENOBUFS; + return 0; } diff --git a/drivers/net/sfc/sfc_ef10_tx.c b/drivers/net/sfc/sfc_ef10_tx.c index 3d6ba4292..e7ab993dd 100644 --- a/drivers/net/sfc/sfc_ef10_tx.c +++ b/drivers/net/sfc/sfc_ef10_tx.c @@ -349,7 +349,9 @@ sfc_ef10_prepare_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, } #endif ret = sfc_dp_tx_prepare_pkt(m, - txq->tso_tcp_header_offset_limit); + txq->tso_tcp_header_offset_limit, + txq->max_fill_level, + SFC_EF10_TSO_OPT_DESCS_NUM, 0); if (unlikely(ret != 0)) { rte_errno = ret; break; diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c index e128bff90..4037802e6 100644 --- a/drivers/net/sfc/sfc_tx.c +++ b/drivers/net/sfc/sfc_tx.c @@ -709,8 +709,15 @@ sfc_efx_prepare_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, for (i = 0; i < nb_pkts; i++) { int ret; + /* + * EFX Tx datapath may require extra VLAN descriptor if VLAN + * insertion offload is requested regardless the offload + * requested/supported. + */ ret = sfc_dp_tx_prepare_pkt(tx_pkts[i], - encp->enc_tx_tso_tcp_header_offset_limit); + encp->enc_tx_tso_tcp_header_offset_limit, + txq->max_fill_level, EFX_TX_FATSOV2_OPT_NDESCS, + 1); if (unlikely(ret != 0)) { rte_errno = ret; break; -- 2.17.1 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 DC572A0679 for ; Tue, 2 Apr 2019 11:31:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8D7615F24; Tue, 2 Apr 2019 11:29:24 +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 713894C91 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 9B13510007E; 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 x329Sr4n028272; 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 E77DF161612; Tue, 2 Apr 2019 10:28:53 +0100 (BST) From: Andrew Rybchenko To: CC: Igor Romanov Date: Tue, 2 Apr 2019 10:28:40 +0100 Message-ID: <1554197324-32391-9-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-10.473600-4.000000-10 X-TMASE-MatchedRID: BgWyh4+V8QQPRVepDWIjx0hwlOfYeSqxgRykyfrH1xkJW4Re2U2py9GX gQphHQmx09NQNrxIpFYBtjkcfRMmqTIRhSUG+oeicYGYuKj6YmB/r8x3wtvaX3aMP8m6qk6ShEs PoifR3f3nsHGifULMdNMKNgYnbS2Jlh5qb5HiiQfMZk86HxFjjqX1XMd/Sqvu1gisw2JKo8lrF3 zE72icb6lVr7hWmDw8xmzLko6q/sDrbAOAP87o65A6S0SjvcYUndls9F9zmi2bKItl61J/yZ+in TK0bC9eKrauXd3MZDV4aBaaKovc7xrm++wprvj/AmY0g1U/u2qRPsFNokFWItCKIk8e+w4t X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--10.473600-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24526.005 X-MDID: 1554197339-5kzl_OWs7OS5 Subject: [dpdk-dev] [PATCH 08/12] net/sfc: introduce descriptor space check in 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: <20190402092840.verpM07l8g6BA1WMOKJurUmuUScTetgojVnQeO7-_CA@z> From: Igor Romanov Add descriptor space check to Tx prepare function to inform a caller that a packet that needs more than maximum Tx descriptors of a queue can not be sent. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/sfc_dp_tx.h | 31 ++++++++++++++++++++++++++++++- drivers/net/sfc/sfc_ef10_tx.c | 4 +++- drivers/net/sfc/sfc_tx.c | 9 ++++++++- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/net/sfc/sfc_dp_tx.h b/drivers/net/sfc/sfc_dp_tx.h index c42d0d01f..ebc941857 100644 --- a/drivers/net/sfc/sfc_dp_tx.h +++ b/drivers/net/sfc/sfc_dp_tx.h @@ -196,8 +196,13 @@ 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, - uint32_t tso_tcp_header_offset_limit) + uint32_t tso_tcp_header_offset_limit, + unsigned int max_fill_level, + unsigned int nb_tso_descs, + unsigned int nb_vlan_descs) { + unsigned int descs_required = m->nb_segs; + #ifdef RTE_LIBRTE_SFC_EFX_DEBUG int ret; @@ -214,11 +219,35 @@ sfc_dp_tx_prepare_pkt(struct rte_mbuf *m, if (m->ol_flags & PKT_TX_TCP_SEG) { unsigned int tcph_off = m->l2_len + m->l3_len; + unsigned int header_len = tcph_off + m->l4_len; if (unlikely(tcph_off > tso_tcp_header_offset_limit)) return EINVAL; + + descs_required += nb_tso_descs; + + /* + * Extra descriptor that is required when a packet header + * is separated from remaining content of the first segment. + */ + if (rte_pktmbuf_data_len(m) > header_len) + descs_required++; } + /* + * The number of VLAN descriptors is added regardless of requested + * VLAN offload since VLAN is sticky and sending packet without VLAN + * insertion may require VLAN descriptor to reset the sticky to 0. + */ + descs_required += nb_vlan_descs; + + /* + * Max fill level must be sufficient to hold all required descriptors + * to send the packet entirely. + */ + if (descs_required > max_fill_level) + return ENOBUFS; + return 0; } diff --git a/drivers/net/sfc/sfc_ef10_tx.c b/drivers/net/sfc/sfc_ef10_tx.c index 3d6ba4292..e7ab993dd 100644 --- a/drivers/net/sfc/sfc_ef10_tx.c +++ b/drivers/net/sfc/sfc_ef10_tx.c @@ -349,7 +349,9 @@ sfc_ef10_prepare_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, } #endif ret = sfc_dp_tx_prepare_pkt(m, - txq->tso_tcp_header_offset_limit); + txq->tso_tcp_header_offset_limit, + txq->max_fill_level, + SFC_EF10_TSO_OPT_DESCS_NUM, 0); if (unlikely(ret != 0)) { rte_errno = ret; break; diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c index e128bff90..4037802e6 100644 --- a/drivers/net/sfc/sfc_tx.c +++ b/drivers/net/sfc/sfc_tx.c @@ -709,8 +709,15 @@ sfc_efx_prepare_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, for (i = 0; i < nb_pkts; i++) { int ret; + /* + * EFX Tx datapath may require extra VLAN descriptor if VLAN + * insertion offload is requested regardless the offload + * requested/supported. + */ ret = sfc_dp_tx_prepare_pkt(tx_pkts[i], - encp->enc_tx_tso_tcp_header_offset_limit); + encp->enc_tx_tso_tcp_header_offset_limit, + txq->max_fill_level, EFX_TX_FATSOV2_OPT_NDESCS, + 1); if (unlikely(ret != 0)) { rte_errno = ret; break; -- 2.17.1