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 5344C378B for ; Tue, 2 Apr 2019 11:29:00 +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 122D010007E; Tue, 2 Apr 2019 09:28:59 +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 x329SsYg028278; Tue, 2 Apr 2019 10:28:54 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 0A4CF161612; Tue, 2 Apr 2019 10:28:54 +0100 (BST) From: Andrew Rybchenko To: CC: Ivan Malov Date: Tue, 2 Apr 2019 10:28:42 +0100 Message-ID: <1554197324-32391-11-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-7.960900-4.000000-10 X-TMASE-MatchedRID: hPnsbxNiy9IBM5SnKo8xnNWxbZgaqhS0xLtUkmJKh3TFpA1uJFd1mtj3 ZmXrgmMgdImKBhZE+L/AC7+rw+mMJaawq2pdPD7UA9lly13c/gFQCOsAlaxN72HaXGR9wawUxGS h4nc4VFwYl3ap7qdZC9TBL7+hlq/xg4jZH72x497il2r2x2PwtfZCh7IN8a4Ayaz/THj7NZyjxY yRBa/qJcFwgTvxipFajoczmuoPCq2VpNOWWa9RKdgfKb4RmRehFiynSWyN9yMIDXlwVbvVzBB+n S/JFbJ+QwymtxuJ6y0= X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--7.960900-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24526.005 X-MDID: 1554197339-4PRSEUvGJqxf Subject: [dpdk-dev] [PATCH 10/12] net/sfc: factor out function to get IPv4 packet ID for TSO 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:00 -0000 From: Ivan Malov As a result, code duplication will be avoided in the current TSO implementations (EFX and EF10 native). The future patch to add support for tunnel TSO will also reuse the new function. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/sfc_ef10_tx.c | 9 ++------- drivers/net/sfc/sfc_tso.c | 9 ++------- drivers/net/sfc/sfc_tso.h | 12 ++++++++++++ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/net/sfc/sfc_ef10_tx.c b/drivers/net/sfc/sfc_ef10_tx.c index 959408449..bcbd15d55 100644 --- a/drivers/net/sfc/sfc_ef10_tx.c +++ b/drivers/net/sfc/sfc_ef10_tx.c @@ -479,13 +479,8 @@ sfc_ef10_xmit_tso_pkt(struct sfc_ef10_txq * const txq, struct rte_mbuf *m_seg, * 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 (first_m_seg->ol_flags & PKT_TX_IPV4) { - const struct ipv4_hdr *iphe4; - - iphe4 = (const struct ipv4_hdr *)(hdr_addr + iph_off); - rte_memcpy(&packet_id, &iphe4->packet_id, sizeof(uint16_t)); - packet_id = rte_be_to_cpu_16(packet_id); - } + if (first_m_seg->ol_flags & PKT_TX_IPV4) + packet_id = sfc_tso_ip4_get_ipid(hdr_addr, iph_off); th = (const struct tcp_hdr *)(hdr_addr + tcph_off); rte_memcpy(&sent_seq, &th->sent_seq, sizeof(uint32_t)); diff --git a/drivers/net/sfc/sfc_tso.c b/drivers/net/sfc/sfc_tso.c index a882e64dd..1374aceaa 100644 --- a/drivers/net/sfc/sfc_tso.c +++ b/drivers/net/sfc/sfc_tso.c @@ -146,13 +146,8 @@ sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx, * 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); - } + if (m->ol_flags & PKT_TX_IPV4) + packet_id = sfc_tso_ip4_get_ipid(tsoh, nh_off); /* Handle TCP header */ th = (const struct tcp_hdr *)(tsoh + tcph_off); diff --git a/drivers/net/sfc/sfc_tso.h b/drivers/net/sfc/sfc_tso.h index cd151782f..8ecefdfd2 100644 --- a/drivers/net/sfc/sfc_tso.h +++ b/drivers/net/sfc/sfc_tso.h @@ -26,6 +26,18 @@ extern "C" { */ #define SFC_EF10_TSO_HDR_DESCS_NUM 1 +static inline uint16_t +sfc_tso_ip4_get_ipid(const uint8_t *pkt_hdrp, size_t ip_hdr_off) +{ + const struct ipv4_hdr *ip_hdrp; + uint16_t ipid; + + ip_hdrp = (const struct ipv4_hdr *)(pkt_hdrp + ip_hdr_off); + rte_memcpy(&ipid, &ip_hdrp->packet_id, sizeof(ipid)); + + return rte_be_to_cpu_16(ipid); +} + unsigned int sfc_tso_prepare_header(uint8_t *tsoh, size_t header_len, struct rte_mbuf **in_seg, size_t *in_off); -- 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 3085EA0679 for ; Tue, 2 Apr 2019 11:30:30 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 449C35B1C; Tue, 2 Apr 2019 11:29:19 +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 5344C378B for ; Tue, 2 Apr 2019 11:29:00 +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 122D010007E; Tue, 2 Apr 2019 09:28:59 +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 x329SsYg028278; Tue, 2 Apr 2019 10:28:54 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 0A4CF161612; Tue, 2 Apr 2019 10:28:54 +0100 (BST) From: Andrew Rybchenko To: CC: Ivan Malov Date: Tue, 2 Apr 2019 10:28:42 +0100 Message-ID: <1554197324-32391-11-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.960900-4.000000-10 X-TMASE-MatchedRID: hPnsbxNiy9IBM5SnKo8xnNWxbZgaqhS0xLtUkmJKh3TFpA1uJFd1mtj3 ZmXrgmMgdImKBhZE+L/AC7+rw+mMJaawq2pdPD7UA9lly13c/gFQCOsAlaxN72HaXGR9wawUxGS h4nc4VFwYl3ap7qdZC9TBL7+hlq/xg4jZH72x497il2r2x2PwtfZCh7IN8a4Ayaz/THj7NZyjxY yRBa/qJcFwgTvxipFajoczmuoPCq2VpNOWWa9RKdgfKb4RmRehFiynSWyN9yMIDXlwVbvVzBB+n S/JFbJ+QwymtxuJ6y0= X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--7.960900-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24526.005 X-MDID: 1554197339-4PRSEUvGJqxf Subject: [dpdk-dev] [PATCH 10/12] net/sfc: factor out function to get IPv4 packet ID for TSO 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: <20190402092842.-hNLuR7fteahpvP3c6erwfejgeiuFQ7ICPYItdJM8QI@z> From: Ivan Malov As a result, code duplication will be avoided in the current TSO implementations (EFX and EF10 native). The future patch to add support for tunnel TSO will also reuse the new function. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/sfc_ef10_tx.c | 9 ++------- drivers/net/sfc/sfc_tso.c | 9 ++------- drivers/net/sfc/sfc_tso.h | 12 ++++++++++++ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/net/sfc/sfc_ef10_tx.c b/drivers/net/sfc/sfc_ef10_tx.c index 959408449..bcbd15d55 100644 --- a/drivers/net/sfc/sfc_ef10_tx.c +++ b/drivers/net/sfc/sfc_ef10_tx.c @@ -479,13 +479,8 @@ sfc_ef10_xmit_tso_pkt(struct sfc_ef10_txq * const txq, struct rte_mbuf *m_seg, * 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 (first_m_seg->ol_flags & PKT_TX_IPV4) { - const struct ipv4_hdr *iphe4; - - iphe4 = (const struct ipv4_hdr *)(hdr_addr + iph_off); - rte_memcpy(&packet_id, &iphe4->packet_id, sizeof(uint16_t)); - packet_id = rte_be_to_cpu_16(packet_id); - } + if (first_m_seg->ol_flags & PKT_TX_IPV4) + packet_id = sfc_tso_ip4_get_ipid(hdr_addr, iph_off); th = (const struct tcp_hdr *)(hdr_addr + tcph_off); rte_memcpy(&sent_seq, &th->sent_seq, sizeof(uint32_t)); diff --git a/drivers/net/sfc/sfc_tso.c b/drivers/net/sfc/sfc_tso.c index a882e64dd..1374aceaa 100644 --- a/drivers/net/sfc/sfc_tso.c +++ b/drivers/net/sfc/sfc_tso.c @@ -146,13 +146,8 @@ sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx, * 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); - } + if (m->ol_flags & PKT_TX_IPV4) + packet_id = sfc_tso_ip4_get_ipid(tsoh, nh_off); /* Handle TCP header */ th = (const struct tcp_hdr *)(tsoh + tcph_off); diff --git a/drivers/net/sfc/sfc_tso.h b/drivers/net/sfc/sfc_tso.h index cd151782f..8ecefdfd2 100644 --- a/drivers/net/sfc/sfc_tso.h +++ b/drivers/net/sfc/sfc_tso.h @@ -26,6 +26,18 @@ extern "C" { */ #define SFC_EF10_TSO_HDR_DESCS_NUM 1 +static inline uint16_t +sfc_tso_ip4_get_ipid(const uint8_t *pkt_hdrp, size_t ip_hdr_off) +{ + const struct ipv4_hdr *ip_hdrp; + uint16_t ipid; + + ip_hdrp = (const struct ipv4_hdr *)(pkt_hdrp + ip_hdr_off); + rte_memcpy(&ipid, &ip_hdrp->packet_id, sizeof(ipid)); + + return rte_be_to_cpu_16(ipid); +} + unsigned int sfc_tso_prepare_header(uint8_t *tsoh, size_t header_len, struct rte_mbuf **in_seg, size_t *in_off); -- 2.17.1