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 4356242DFC; Sat, 8 Jul 2023 03:57:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EC6604114A; Sat, 8 Jul 2023 03:57:24 +0200 (CEST) Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) by mails.dpdk.org (Postfix) with ESMTP id C4BCB40A8A for ; Sat, 8 Jul 2023 03:57:22 +0200 (CEST) Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-6b8decf09e1so2352213a34.0 for ; Fri, 07 Jul 2023 18:57:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1688781442; x=1691373442; 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=omB4hFpJpoydz8FPWHufWc0tyBRatRl+4+2eJunbN6Lp6le8XOvOvvvYVf0+raOjvG hbn/j14vvbRarELKDg/MEDkt8OPOyx61PGClBYnILqvhDmK7ueo2fT02mBxiypCgywmG FUgfnTHEFvP6B+P2RU/LFAMTa07feszIrqe6wvWwXl2oe1be1ktXRxcfLthHBclcAxEf LlAtsttRankVFS+OASfOq95fabNHwsxFa9Z1qdopM6iz6im+1tnzMEkmd/SWWrdk8lPk L6sCPdyR008a7Isr61rkIJo0v67StL9Cu+J81duFiEpKDW6C8B9P6JnV4nP91Q7A7+ZH Fw/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688781442; x=1691373442; 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=icxspRize6OdMcK9LMfkvi/b2SYXQ0tAerlxpDo7Xys0OtQPpey1CbGJUjdeoCbvOT BZghnfuaYQEgUVC+6c13UqsSFtqDMbLJVXckvfCJtlw4M74UNJxvBcpdiQpDvkr2ZeP4 +o5VPRHytQEovQvKGTZNlSV+KH5qJ2j+e4HqIGEyJtf1pwQsJbHNkBxbMD6Do08KIbwd /d8Q40VwyAKhzuosuDKpMznI+wrM6hKXQHlQGcZPQlZJ6d53O4xuw0qtWeexeFytJ+e5 fIiqHJYNa1X+fySEmQWAYKtJTcFMVprTvl9cM2KxJ+FGx/LLam4hppoEZSNKu1s2A2o2 ndtg== X-Gm-Message-State: ABy/qLbabSjRjc4A5s0k/d4FRKA38JOBf4+Rk3XSgMB0IEuw4Gx7ny/g HANfXJKRVBS7+5xREV403QQSdn72ETKyi7aOssGBzrfA X-Google-Smtp-Source: APBJJlEb+y7OZxiifhbmLaOK6vuwHkFtmLmd+Q5SHHAJfHRqV5uaRWhgw7STF2e4z/q30bNHATaTIA== X-Received: by 2002:a05:6870:79e:b0:1b0:22b3:25ff with SMTP id en30-20020a056870079e00b001b022b325ffmr7603997oab.47.1688781441763; Fri, 07 Jul 2023 18:57:21 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id 24-20020a17090a035800b00263f5ac814esm2260269pjf.38.2023.07.07.18.57.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 18:57:21 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Jiayu Hu Subject: [PATCH v5 01/11] gro: use rte_pktmbuf_mtod_offset Date: Fri, 7 Jul 2023 18:57:08 -0700 Message-Id: <20230708015718.75565-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230708015718.75565-1-stephen@networkplumber.org> References: <20230505174813.133894-1-stephen@networkplumber.org> <20230708015718.75565-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