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 6AF2642DFC; Fri, 7 Jul 2023 22:39:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 41D9340FAE; Fri, 7 Jul 2023 22:39:14 +0200 (CEST) Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by mails.dpdk.org (Postfix) with ESMTP id 5E57B40E01 for ; Fri, 7 Jul 2023 22:39:13 +0200 (CEST) Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-55b1238a024so1774197a12.0 for ; Fri, 07 Jul 2023 13:39:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1688762352; x=1691354352; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vObgcPMDzvD/5VxKEhbH2z7+/u+sGbwSbqWVkuVmxZs=; b=2yjUSWaRDNHocDCo3iCc7nTvDv2mLQg2n1+h0IN8b9ZALKOqyvnV8I7S5Lfis/ZljH LSWEXOKFHVFqB6poiumq9ooBap68Nfeh3UrpmieJ7omlKG+biEk0y5YnlBXPLU6S3g90 qoxgGnPrjWXXiWqjNPlZmGtk+3jjwNssP8KojGB1LTQHsBKwNP46jAUPDLly3x949cpq 0GxIlYEAQ9vEmzWtCWhZFVLIdLGTemDSeVFK8+EesxFPTzkxC/DcRA3gX7+ckl2dOaHy yff9RKB+HHQz8CjY0iRkgfyi/U56uwn0lmk9t0OVgt4n1QQj4pKQxP7FdGRO+vNGtLyf cLQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688762352; x=1691354352; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vObgcPMDzvD/5VxKEhbH2z7+/u+sGbwSbqWVkuVmxZs=; b=OnnmN+3iG6Tu9N798ig2+CmFP9JSUVnnkmy38bHIcgcMc6T/U7qYV847SNnfgKdWm4 RTjopCvnRuA0dRdILrFnUPU7zI+r45HFmNukZKkYbAWYRmRGlTAeYZT1AJF74pzyZF52 YhIuSJgM/awIefdldXwkhe7/1QmY8AI7TAOfCsJAOJgaXi3lu+EA/LEHo3OaCtc/cBRS cd7HvlSWzlSNi+yPGZGF0J2era46GDF6sdh2vFnzjnx87PkMztds8GcgH7jfibZVQoqJ Vz56LWz/wCFFN4vX5QYdz7nVsf0nGQlmOGMCW5yVaK58K7poN0yotFtuvQolSGsEXuIA Oxbg== X-Gm-Message-State: ABy/qLaixL9SaHOBqCJePBomTPJkwhbho+jwLCUQ3HLfnBm/7PIQ6Y2s hBDcx/+oSh9NTnsPqZXwBnZC3rebO+YvGqnRZaCUZlkY X-Google-Smtp-Source: APBJJlH+CTfCvd/vhHFdwuCZ+cHAdhmznRtqKw1TjNCjQ38dJBdpDfZhRToEjbzDCKDstOpKEATkHg== X-Received: by 2002:a05:6a20:8f0c:b0:130:1542:2681 with SMTP id b12-20020a056a208f0c00b0013015422681mr7324386pzk.34.1688762352297; Fri, 07 Jul 2023 13:39:12 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id t15-20020a170902b20f00b001b83db0bcf2sm3640493plr.141.2023.07.07.13.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 13:39:11 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Jiayu Hu Subject: [PATCH v4 01/11] gro: use rte_pktmbuf_mtod_offset Date: Fri, 7 Jul 2023 13:38:58 -0700 Message-Id: <20230707203908.64371-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230707203908.64371-1-stephen@networkplumber.org> References: <20230505174813.133894-1-stephen@networkplumber.org> <20230707203908.64371-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Replace explicit packet offset computations with rte_pktmbuf_mtod_offset(). Signed-off-by: Stephen Hemminger --- lib/gro/gro_tcp.h | 4 ++-- lib/gro/gro_tcp4.c | 4 ++-- lib/gro/gro_tcp6.c | 4 ++-- lib/gro/gro_udp4.c | 4 ++-- lib/gro/gro_vxlan_tcp4.c | 4 ++-- lib/gro/gro_vxlan_udp4.c | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/gro/gro_tcp.h b/lib/gro/gro_tcp.h index d926c4b8cc71..bbd2f9c16a00 100644 --- a/lib/gro/gro_tcp.h +++ b/lib/gro/gro_tcp.h @@ -150,8 +150,8 @@ check_seq_option(struct gro_tcp_item *item, struct rte_tcp_hdr *tcph_orig; uint16_t len, tcp_hl_orig; - iph_orig = (char *)(rte_pktmbuf_mtod(pkt_orig, char *) + - l2_offset + pkt_orig->l2_len); + iph_orig = rte_pktmbuf_mtod_offset(pkt_orig, char *, + l2_offset + pkt_orig->l2_len); tcph_orig = (struct rte_tcp_hdr *)(iph_orig + pkt_orig->l3_len); tcp_hl_orig = pkt_orig->l4_len; diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c index 6645de592b63..d6c0f9182d45 100644 --- a/lib/gro/gro_tcp4.c +++ b/lib/gro/gro_tcp4.c @@ -223,8 +223,8 @@ update_header(struct gro_tcp_item *item) struct rte_ipv4_hdr *ipv4_hdr; struct rte_mbuf *pkt = item->firstseg; - ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) + - pkt->l2_len); + ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *, + pkt->l2_len); ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len - pkt->l2_len); } diff --git a/lib/gro/gro_tcp6.c b/lib/gro/gro_tcp6.c index 5aa39801e132..6edfb6045cf6 100644 --- a/lib/gro/gro_tcp6.c +++ b/lib/gro/gro_tcp6.c @@ -118,8 +118,8 @@ update_header(struct gro_tcp_item *item) struct rte_ipv6_hdr *ipv6_hdr; struct rte_mbuf *pkt = item->firstseg; - ipv6_hdr = (struct rte_ipv6_hdr *)(rte_pktmbuf_mtod(pkt, char *) + - pkt->l2_len); + ipv6_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv6_hdr *, + pkt->l2_len); ipv6_hdr->payload_len = rte_cpu_to_be_16(pkt->pkt_len - pkt->l2_len - pkt->l3_len); } diff --git a/lib/gro/gro_udp4.c b/lib/gro/gro_udp4.c index 42596d33b6dc..019e05bcdea5 100644 --- a/lib/gro/gro_udp4.c +++ b/lib/gro/gro_udp4.c @@ -179,8 +179,8 @@ update_header(struct gro_udp4_item *item) struct rte_mbuf *pkt = item->firstseg; uint16_t frag_offset; - ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) + - pkt->l2_len); + ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *, + pkt->l2_len); ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len - pkt->l2_len); diff --git a/lib/gro/gro_vxlan_tcp4.c b/lib/gro/gro_vxlan_tcp4.c index 6ab700192261..2752650389a4 100644 --- a/lib/gro/gro_vxlan_tcp4.c +++ b/lib/gro/gro_vxlan_tcp4.c @@ -263,8 +263,8 @@ update_vxlan_header(struct gro_vxlan_tcp4_item *item) /* Update the outer IPv4 header. */ len = pkt->pkt_len - pkt->outer_l2_len; - ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) + - pkt->outer_l2_len); + ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *, + pkt->outer_l2_len); ipv4_hdr->total_length = rte_cpu_to_be_16(len); /* Update the outer UDP header. */ diff --git a/lib/gro/gro_vxlan_udp4.c b/lib/gro/gro_vxlan_udp4.c index b78a7ae89eef..ca8cee270d3d 100644 --- a/lib/gro/gro_vxlan_udp4.c +++ b/lib/gro/gro_vxlan_udp4.c @@ -259,8 +259,8 @@ update_vxlan_header(struct gro_vxlan_udp4_item *item) /* Update the outer IPv4 header. */ len = pkt->pkt_len - pkt->outer_l2_len; - ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) + - pkt->outer_l2_len); + ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *, + pkt->outer_l2_len); ipv4_hdr->total_length = rte_cpu_to_be_16(len); /* Update the outer UDP header. */ -- 2.39.2