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 7E29F42A7F; Sat, 6 May 2023 18:04:48 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A7D6C42D47; Sat, 6 May 2023 18:04:14 +0200 (CEST) Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by mails.dpdk.org (Postfix) with ESMTP id 7042542D37 for ; Sat, 6 May 2023 18:04:12 +0200 (CEST) Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-643a1fed360so1142287b3a.3 for ; Sat, 06 May 2023 09:04:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1683389051; x=1685981051; 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=8qVC3bA2BibKgFfmQilRnT4WLw2Cs5kUTFiZdVZhDJc=; b=Tv2ZozIJKz4/3+QqAPQfeT+Nc4sVGZER2+MHs/lyxeKwFVTOKRzkB//831rXUUmsCX /ytixhTeWO7OT6kA8uGytFZgP+rrPgSxsx8dLLYxr9sRzR1cn26CwDznhDgd2VAI7TtL PBQtzPgeWiAUAzOUpe9ElWJhj/TzNRtTQ2lM1nnEDQ61JPCkoMr1KAlDAYKO6HU/q59v 7SiAENXQwfCzA7S3KGgwx4WB4lcwI+osIuJ1hpE1Z5iGth0d8Hm1qiZkfIg5Uo3c2gJA Ug1dCsORjilGjUv/e06yaJj4BNy4fh1jqztT8PSlAbMpmJ00k8UdKhnpn9nBoZWVFFel 6WJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683389051; x=1685981051; 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=8qVC3bA2BibKgFfmQilRnT4WLw2Cs5kUTFiZdVZhDJc=; b=J2hYp0kgt4LrcOuQProFCKg+XCyrgHW9/x0/X5Dfm9C5e3MdxuB3rDCJJQmSbhF+yq KKOKfDfLzXY7+rYeFw9dsE3hFhCICIUO7SCXImyrX9zLaP6P30WOVq+jGT8FhpmSQEk4 QyWPRI1+1WawWvQ0gS8v2oQRd6DJv90SBvk4RfvDORZkrnBG+MBNqegonFFnde8Fkpzf aEXHmHT1ysi8JqY5C24MYjWzmfxJLdg6OeYOI1PseZnMsuavqbVy007j82l2hHYfS4AS BhaK20mBPfFZiGkXhaQ105OViKdqtAlpmogrFsoKxbONSJ0ib/7Na9ap7qHc+pZ0vjea B7RA== X-Gm-Message-State: AC+VfDylWeICLmwBusTBhGBFcvzp0lvw70zrKTD4IrNDDkq3nFcH2lR+ BIxUbxHZgepdZ+Z9r9FeWb8rT0G9duKG433o1JJlmg== X-Google-Smtp-Source: ACHHUZ5av/q1cZnOsd87LS0IWiVwkzpXOyvBRaQaCm/dy+I4GPFG9Afsu/AktMq6/mPu+zHakKp8TA== X-Received: by 2002:a05:6a00:1514:b0:643:b6a9:b8d8 with SMTP id q20-20020a056a00151400b00643b6a9b8d8mr3086435pfu.23.1683389051406; Sat, 06 May 2023 09:04:11 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id e14-20020a62ee0e000000b006436ffa3dc4sm3369890pfi.24.2023.05.06.09.04.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 May 2023 09:04:10 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Akhil Goyal , Fan Zhang , Kirill Rybalchenko Subject: [PATCH v2 05/14] examples: use rte_pktmbuf_mtod_offset Date: Sat, 6 May 2023 09:03:54 -0700 Message-Id: <20230506160404.7423-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230506160404.7423-1-stephen@networkplumber.org> References: <20230505174813.133894-1-stephen@networkplumber.org> <20230506160404.7423-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 Automatically generated from cocci/mtod-offset.cocci Signed-off-by: Stephen Hemminger --- examples/l2fwd-crypto/main.c | 16 +++++++++------- examples/ptpclient/ptpclient.c | 18 +++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index efe7eea2a768..403ed6b44de9 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]; diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c index cdf2da64dfee..2535d848a1e9 100644 --- a/examples/ptpclient/ptpclient.c +++ b/examples/ptpclient/ptpclient.c @@ -354,8 +354,8 @@ parse_sync(struct ptpv2_data_slave_ordinary *ptp_data, uint16_t rx_tstamp_idx) { struct ptp_header *ptp_hdr; - ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(ptp_data->m, char *) - + sizeof(struct rte_ether_hdr)); + ptp_hdr = rte_pktmbuf_mtod_offset(ptp_data->m, struct ptp_header *, + sizeof(struct rte_ether_hdr)); ptp_data->seqID_SYNC = rte_be_to_cpu_16(ptp_hdr->seq_id); if (ptp_data->ptpset == 0) { @@ -397,15 +397,15 @@ parse_fup(struct ptpv2_data_slave_ordinary *ptp_data) int ret; eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *); - ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(m, char *) - + sizeof(struct rte_ether_hdr)); + ptp_hdr = rte_pktmbuf_mtod_offset(m, struct ptp_header *, + sizeof(struct rte_ether_hdr)); if (memcmp(&ptp_data->master_clock_id, &ptp_hdr->source_port_id.clock_id, sizeof(struct clock_id)) != 0) return; ptp_data->seqID_FOLLOWUP = rte_be_to_cpu_16(ptp_hdr->seq_id); - ptp_msg = (struct ptp_message *) (rte_pktmbuf_mtod(m, char *) + + ptp_msg = rte_pktmbuf_mtod_offset(m, struct ptp_message *, sizeof(struct rte_ether_hdr)); origin_tstamp = &ptp_msg->follow_up.precise_origin_tstamp; @@ -537,8 +537,8 @@ parse_drsp(struct ptpv2_data_slave_ordinary *ptp_data) struct tstamp *rx_tstamp; uint16_t seq_id; - ptp_msg = (struct ptp_message *) (rte_pktmbuf_mtod(m, char *) + - sizeof(struct rte_ether_hdr)); + ptp_msg = rte_pktmbuf_mtod_offset(m, struct ptp_message *, + sizeof(struct rte_ether_hdr)); seq_id = rte_be_to_cpu_16(ptp_msg->delay_resp.hdr.seq_id); if (memcmp(&ptp_data->client_clock_id, &ptp_msg->delay_resp.req_port_id.clock_id, @@ -585,8 +585,8 @@ parse_ptp_frames(uint16_t portid, struct rte_mbuf *m) { if (eth_type == PTP_PROTOCOL) { ptp_data.m = m; ptp_data.portid = portid; - ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(m, char *) - + sizeof(struct rte_ether_hdr)); + ptp_hdr = rte_pktmbuf_mtod_offset(m, struct ptp_header *, + sizeof(struct rte_ether_hdr)); switch (ptp_hdr->msg_type) { case SYNC: -- 2.39.2