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 5C5CF42DFC; Fri, 7 Jul 2023 22:40:21 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 93A9742D52; Fri, 7 Jul 2023 22:39:27 +0200 (CEST) Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by mails.dpdk.org (Postfix) with ESMTP id 8A86042D30 for ; Fri, 7 Jul 2023 22:39:22 +0200 (CEST) Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1b89cfb4571so15757695ad.3 for ; Fri, 07 Jul 2023 13:39:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1688762361; x=1691354361; 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=wwS2rmOQ9nJLLKvDK9MXA/E8Oeyws+SFh/8bRR3Jcbs=; b=uP1h1dTdXXSrDotYVeuE/s3JimM3BrR5Bcp0myq0ncuqMBFPgWSHdaJU8TrvLVeX08 JZSQMBHwY/rCB1oyGnPemyXjQbbUkM9fDvqsK6MGqnd+EcS/R3v9iaUFL+/zH0znIFQp ccVfOC3vP5eMbjxQlsEbenTUD03hL5wT3+YeMgLFc8bjFkKrb0FUL8xLwO9694UM+KiK fjc9dMwe2iHtc7gz3N4XbYH051KyTPZC5bAt6wYVWC370fjWkLG6eRHPppLSJu5zDmrs CgezVhEI4qDoqvJLCcqYtl/DCzf+OGsR90He4zlBRrzvu78uxahfDBqpP66qnns2XXwY vaFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688762361; x=1691354361; 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=wwS2rmOQ9nJLLKvDK9MXA/E8Oeyws+SFh/8bRR3Jcbs=; b=ZrBrXlmNi5GBWK6jFdA4Rsay1MUhbraw1GSmbf8eZLM/rULEemW2yore5ooTB6SFKz QlI6G7SpvVNr/Cxmhi3X/OKXJqq6t/zjVxoHvY263wRqo0mq7W9fI3vgcO5Sfn9p5XQj rcAWL+57a82uHM8iPbFhZCjJzM7qDN0NMuxpk3gouiCsrNE2SE1AEekHEqzDg2mXvgYP bsai70x8izM9ybM3Z+c4dU1BK4bmatKS0f7Q3FKMEyXd00I2H/spHSB6Fs5/qek9/5mk FHGBFYui8nWdy3VOBgegl9Zxa2pnzgpI00I3EkP04ZKTJnXHKMbx+QsaBMcxkcWbugsZ wO1A== X-Gm-Message-State: ABy/qLYFCUIFJ8/jy85yeldxcGYu1lWxBeNC3ExcCK9QXbJ5smPWIjmm lir5vwygAgMLoWLspqHO/ykxZYJ2T1qBwdROwyIGimla X-Google-Smtp-Source: APBJJlFiHsUGqe9s0FBejyjR9Qvc7rC2egDCrKZjtO2iKfNe9BF9/zRX3bosQyC/+Y0GTqKKdRIcjw== X-Received: by 2002:a17:902:b691:b0:1b8:987f:3f34 with SMTP id c17-20020a170902b69100b001b8987f3f34mr5664266pls.25.1688762361545; Fri, 07 Jul 2023 13:39:21 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 13:39:21 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Akhil Goyal , Fan Zhang Subject: [PATCH v4 11/11] examples/l2fwd-crypto: use rte_pktmbuf_mtod_offset Date: Fri, 7 Jul 2023 13:39:08 -0700 Message-Id: <20230707203908.64371-12-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 --- examples/l2fwd-crypto/main.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index efe7eea2a768..981b449710a7 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -410,8 +410,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m, ipdata_offset = sizeof(struct rte_ether_hdr); - ip_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(m, char *) + - ipdata_offset); + ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, + ipdata_offset); ipdata_offset += (ip_hdr->version_ihl & RTE_IPV4_HDR_IHL_MASK) * RTE_IPV4_IHL_MULTIPLIER; @@ -479,8 +479,9 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m, op->sym->auth.digest.data = (uint8_t *)rte_pktmbuf_append(m, cparams->digest_length); } else { - op->sym->auth.digest.data = rte_pktmbuf_mtod(m, - uint8_t *) + ipdata_offset + data_len; + op->sym->auth.digest.data = rte_pktmbuf_mtod_offset(m, + uint8_t *, + ipdata_offset + data_len); } op->sym->auth.digest.phys_addr = rte_pktmbuf_iova_offset(m, @@ -540,8 +541,9 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m, op->sym->aead.digest.data = (uint8_t *)rte_pktmbuf_append(m, cparams->digest_length); } else { - op->sym->aead.digest.data = rte_pktmbuf_mtod(m, - uint8_t *) + ipdata_offset + data_len; + op->sym->aead.digest.data = rte_pktmbuf_mtod_offset(m, + uint8_t *, + ipdata_offset + data_len); } op->sym->aead.digest.phys_addr = rte_pktmbuf_iova_offset(m, @@ -631,7 +633,7 @@ l2fwd_simple_forward(struct rte_mbuf *m, uint16_t portid, struct rte_ipv4_hdr *ip_hdr; uint32_t ipdata_offset = sizeof(struct rte_ether_hdr); - ip_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(m, char *) + + ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, ipdata_offset); dst_port = l2fwd_dst_ports[portid]; -- 2.39.2