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 D29E3A0679 for ; Tue, 2 Apr 2019 11:29:38 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 11DDA5323; Tue, 2 Apr 2019 11:29:11 +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 668923798 for ; Tue, 2 Apr 2019 11:28:59 +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 0BC8C10007E; 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:54 -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 x329Srwm028260; 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 B9701161612; Tue, 2 Apr 2019 10:28:53 +0100 (BST) From: Andrew Rybchenko To: CC: Igor Romanov Date: Tue, 2 Apr 2019 10:28:36 +0100 Message-ID: <1554197324-32391-5-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-7.185700-4.000000-10 X-TMASE-MatchedRID: GGTeld1kIWgyRohotsnq5+G5dRZCgxC3Thn37FFP5A0lC3U/r0iv83B4 4IkzjfYyj6kCfX0Edc7/Pn5pXbkQo3tcjyQQG4KiFyqkfsPWu1BKgIbix5+XxKbuBeSz8VQ6v7Q YgpRtFn6njTWnjQxrsYbV78WQIIG+aPW3y1xO3y/1RUeLAvHT8rVNU7DO2GYBx3iBZykOdRxjqy r7FE9KQPZat09EUv0I9jjbGUN5dRQgiUNITFoQ77RtO1RC1Ep0f6/Md8Lb2l8rYyNNmvu5tbdaM hWaXsFHgsUtzIjIFbkvhdlQKzaVq8RyU2VJ3/XInu1HSadECDWd2Wz0X3OaLZsoi2XrUn/Jn6Kd MrRsL14qtq5d3cxkNRME7z1CCNiPIPgm+PzyadqNNaJRrmVa6sv709mLaq8JMJcU28/wAj3AvpL E+mvX8g== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--7.185700-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24526.005 X-MDID: 1554197338-tmGKrtFpoG5S Subject: [dpdk-dev] [PATCH 04/12] net/sfc: support Tx preparation in EFX datapath 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: <20190402092836._AJFxmoZB9HSxu444m4nxIr93dyp7da1NDZeV8Znvuc@z> From: Igor Romanov Implement generic checks in Tx prepare function and update Tx burst function accordingly. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- doc/guides/rel_notes/release_19_05.rst | 1 + drivers/net/sfc/sfc_dp_tx.h | 24 ++++++++++++++++++++++++ drivers/net/sfc/sfc_ethdev.c | 4 ++++ drivers/net/sfc/sfc_tso.c | 13 +++++++------ drivers/net/sfc/sfc_tx.c | 20 ++++++++++++++++++++ 5 files changed, 56 insertions(+), 6 deletions(-) diff --git a/doc/guides/rel_notes/release_19_05.rst b/doc/guides/rel_notes/release_19_05.rst index bdad1ddbe..173c852c8 100644 --- a/doc/guides/rel_notes/release_19_05.rst +++ b/doc/guides/rel_notes/release_19_05.rst @@ -73,6 +73,7 @@ New Features * Added support for RSS RETA and hash configuration get API in a secondary process. * Added support for Rx packet types list in a secondary process. + * Added Tx prepare to do Tx offloads checks. * **Updated Mellanox drivers.** diff --git a/drivers/net/sfc/sfc_dp_tx.h b/drivers/net/sfc/sfc_dp_tx.h index 9cb2198e2..885094b67 100644 --- a/drivers/net/sfc/sfc_dp_tx.h +++ b/drivers/net/sfc/sfc_dp_tx.h @@ -13,6 +13,7 @@ #include #include "sfc_dp.h" +#include "sfc_debug.h" #ifdef __cplusplus extern "C" { @@ -170,6 +171,7 @@ struct sfc_dp_tx { sfc_dp_tx_qtx_ev_t *qtx_ev; sfc_dp_tx_qreap_t *qreap; sfc_dp_tx_qdesc_status_t *qdesc_status; + eth_tx_prep_t pkt_prepare; eth_tx_burst_t pkt_burst; }; @@ -192,6 +194,28 @@ sfc_dp_find_tx_by_caps(struct sfc_dp_list *head, unsigned int avail_caps) /** Get Tx datapath ops by the datapath TxQ handle */ 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) +{ +#ifdef RTE_LIBRTE_SFC_EFX_DEBUG + int ret; + + ret = rte_validate_tx_offload(m); + if (ret != 0) { + /* + * Negative error code is returned by rte_validate_tx_offload(), + * but positive are used inside net/sfc PMD. + */ + SFC_ASSERT(ret < 0); + return -ret; + } +#else + RTE_SET_USED(m); +#endif + + return 0; +} + extern struct sfc_dp_tx sfc_efx_tx; extern struct sfc_dp_tx sfc_ef10_tx; extern struct sfc_dp_tx sfc_ef10_simple_tx; diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 2675d4a8c..6c33601e7 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -1854,6 +1854,7 @@ sfc_eth_dev_set_ops(struct rte_eth_dev *dev) sa->priv.dp_tx = dp_tx; dev->rx_pkt_burst = dp_rx->pkt_burst; + dev->tx_pkt_prepare = dp_tx->pkt_prepare; dev->tx_pkt_burst = dp_tx->pkt_burst; dev->dev_ops = &sfc_eth_dev_ops; @@ -1881,6 +1882,7 @@ sfc_eth_dev_clear_ops(struct rte_eth_dev *dev) struct sfc_adapter_shared *sas = sfc_adapter_shared_by_eth_dev(dev); dev->dev_ops = NULL; + dev->tx_pkt_prepare = NULL; dev->rx_pkt_burst = NULL; dev->tx_pkt_burst = NULL; @@ -1961,6 +1963,7 @@ sfc_eth_dev_secondary_init(struct rte_eth_dev *dev, uint32_t logtype_main) dev->process_private = sap; dev->rx_pkt_burst = dp_rx->pkt_burst; + dev->tx_pkt_prepare = dp_tx->pkt_prepare; dev->tx_pkt_burst = dp_tx->pkt_burst; dev->dev_ops = &sfc_eth_dev_secondary_ops; @@ -1982,6 +1985,7 @@ sfc_eth_dev_secondary_clear_ops(struct rte_eth_dev *dev) free(dev->process_private); dev->process_private = NULL; dev->dev_ops = NULL; + dev->tx_pkt_prepare = NULL; dev->tx_pkt_burst = NULL; dev->rx_pkt_burst = NULL; } diff --git a/drivers/net/sfc/sfc_tso.c b/drivers/net/sfc/sfc_tso.c index 1ce787f3c..2c03c0837 100644 --- a/drivers/net/sfc/sfc_tso.c +++ b/drivers/net/sfc/sfc_tso.c @@ -97,7 +97,7 @@ sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx, uint8_t *tsoh; const struct tcp_hdr *th; efsys_dma_addr_t header_paddr; - uint16_t packet_id; + uint16_t packet_id = 0; uint32_t sent_seq; struct rte_mbuf *m = *in_seg; size_t nh_off = m->l2_len; /* IP header offset */ @@ -147,17 +147,18 @@ sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx, tsoh = rte_pktmbuf_mtod(m, uint8_t *); } - /* Handle IP header */ + /* + * Handle IP header. Tx prepare has debug-only checks that offload flags + * are correctly filled in in TSO mbuf. Use zero IPID if there is no + * IPv4 flag. If the packet is still IPv4, HW will simply start from + * zero IPID. + */ if (m->ol_flags & PKT_TX_IPV4) { const struct ipv4_hdr *iphe4; iphe4 = (const struct ipv4_hdr *)(tsoh + nh_off); rte_memcpy(&packet_id, &iphe4->packet_id, sizeof(uint16_t)); packet_id = rte_be_to_cpu_16(packet_id); - } else if (m->ol_flags & PKT_TX_IPV6) { - packet_id = 0; - } else { - return EINVAL; } /* Handle TCP header */ diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c index 4b1f94ce8..16fd220bf 100644 --- a/drivers/net/sfc/sfc_tx.c +++ b/drivers/net/sfc/sfc_tx.c @@ -697,6 +697,25 @@ sfc_efx_tx_maybe_insert_tag(struct sfc_efx_txq *txq, struct rte_mbuf *m, return 1; } +static uint16_t +sfc_efx_prepare_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts) +{ + uint16_t i; + + for (i = 0; i < nb_pkts; i++) { + int ret; + + ret = sfc_dp_tx_prepare_pkt(tx_pkts[i]); + if (unlikely(ret != 0)) { + rte_errno = ret; + break; + } + } + + return i; +} + static uint16_t sfc_efx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) { @@ -1122,5 +1141,6 @@ struct sfc_dp_tx sfc_efx_tx = { .qstop = sfc_efx_tx_qstop, .qreap = sfc_efx_tx_qreap, .qdesc_status = sfc_efx_tx_qdesc_status, + .pkt_prepare = sfc_efx_prepare_pkts, .pkt_burst = sfc_efx_xmit_pkts, }; -- 2.17.1