From patchwork Fri May 5 17:48:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 126704 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C70BB42A49; Fri, 5 May 2023 19:48:24 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1206642D16; Fri, 5 May 2023 19:48:20 +0200 (CEST) Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by mails.dpdk.org (Postfix) with ESMTP id CFC27410EA for ; Fri, 5 May 2023 19:48:18 +0200 (CEST) Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-64115eef620so21341675b3a.1 for ; Fri, 05 May 2023 10:48:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1683308898; x=1685900898; 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=S/fBocBp4c6TNBaX8tRmecKLA8o4i54C4sI6m9zFMbM=; b=bWEHFLLBDBOIt4PHuZJqxUE9ugw9AYJhgJLtG/LSQzx5JjgH6RFdLGcS2irDdzT+X9 3ZHi94Cq+/A+UoEZ3FwYZ8Ycw1E9O9aYDcLZlg+SFkFWM7EWrzuE/VBi32QJpTCGXfXB yMs0emMHaUiwMzRcl4Wrvv7QkcDIa5cnisrCWks0O9cONJPvt1Tg0rQhKdOETEv9W4uW hx5iwJ/vwoH5brRzyCtw1GvPifv258zTlW+N8b7lpk5FxSM3CdrdAUhxPTe2fS6znPsb +2+iLFJ49J/LRvACdAoWBDMiL7tlVQaF50ps6s2POWAXQm22sx9FQHqwqGb980QCLAKx r/pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683308898; x=1685900898; 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=S/fBocBp4c6TNBaX8tRmecKLA8o4i54C4sI6m9zFMbM=; b=Hwa3RHIn2JEcsSa0c5KvIPwgr1PP1mA0sCMdlfwl525ognbg5MMoJzIODWu48wFapQ kH+w6YDiuPiSvDb2QL10G+36VVDspWvCJVDsj0OCZS3wfT87/j12IXWbORsWCxINPg7R ls9SsCqg7GeraiCuJZCJ6Nm67zcFjKMfoVGnSw8FB7H9TCtyn7QIxTkgDUqnt2Y+lCp5 JYLdOnNuVN0XRHnxthTvl1IZ24DNHR5RPAFphv13EB5sB4csFM3HGiwdPUZqlsoHNlrA EQT/GqzxUxvV6PAtlGLAUdsQMMHla8um9KU+C7X14m/Nj3XcmvBKmXCOHkHj8sA/3zsc rwRA== X-Gm-Message-State: AC+VfDz+N80va2mAQsdnX+7TaOUDtV6hdCmfdnf38V8f9uNV9uZlyjAf R0BzVjST5HqS4EzfZKwKUSOZcvEThtMM/Q+by6PG3g== X-Google-Smtp-Source: ACHHUZ4cdIYhPGMLJ3n896SHA9iN+u/dwPxySUMAevcYILqEmIWSry8YZhIU+YQQA4lS05hVrJ2zCw== X-Received: by 2002:a05:6a20:1595:b0:f2:4c39:8028 with SMTP id h21-20020a056a20159500b000f24c398028mr3118425pzj.21.1683308897813; Fri, 05 May 2023 10:48:17 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id a15-20020aa780cf000000b0063799398eb9sm1895707pfn.58.2023.05.05.10.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 10:48:17 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Jiayu Hu Subject: [PATCH 01/14] gro: use rte_pktmbuf_mtod_offset Date: Fri, 5 May 2023 10:48:00 -0700 Message-Id: <20230505174813.133894-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230505174813.133894-1-stephen@networkplumber.org> References: <20230505174813.133894-1-stephen@networkplumber.org> MIME-Version: 1.0 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 Use rte_pktmbuf_mtod_offset. Change was automatically generated by cocci/mtod-offset.cocci. Signed-off-by: Stephen Hemminger --- lib/gro/gro_tcp4.c | 4 ++-- lib/gro/gro_tcp4.h | 4 ++-- lib/gro/gro_udp4.c | 4 ++-- lib/gro/gro_vxlan_tcp4.c | 4 ++-- lib/gro/gro_vxlan_udp4.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c index 0014096e6332..6f8466e70211 100644 --- a/lib/gro/gro_tcp4.c +++ b/lib/gro/gro_tcp4.c @@ -182,8 +182,8 @@ update_header(struct gro_tcp4_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_tcp4.h b/lib/gro/gro_tcp4.h index 212f97a0427c..c76f1f5686d1 100644 --- a/lib/gro/gro_tcp4.h +++ b/lib/gro/gro_tcp4.h @@ -272,8 +272,8 @@ check_seq_option(struct gro_tcp4_item *item, struct rte_tcp_hdr *tcph_orig; uint16_t len, tcp_hl_orig; - iph_orig = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt_orig, char *) + - l2_offset + pkt_orig->l2_len); + iph_orig = rte_pktmbuf_mtod_offset(pkt_orig, struct rte_ipv4_hdr *, + l2_offset + pkt_orig->l2_len); tcph_orig = (struct rte_tcp_hdr *)((char *)iph_orig + pkt_orig->l3_len); tcp_hl_orig = pkt_orig->l4_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 3be4deb7c76f..b93a02c149cc 100644 --- a/lib/gro/gro_vxlan_tcp4.c +++ b/lib/gro/gro_vxlan_tcp4.c @@ -269,8 +269,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. */