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 E7F5442DFC; Sat, 8 Jul 2023 03:58:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1BEE642D4F; Sat, 8 Jul 2023 03:57:36 +0200 (CEST) Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) by mails.dpdk.org (Postfix) with ESMTP id CBC5842D37 for ; Sat, 8 Jul 2023 03:57:31 +0200 (CEST) Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-1b059dd7c0cso2503488fac.0 for ; Fri, 07 Jul 2023 18:57:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1688781451; x=1691373451; 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=kCWRDMcwmvFF9ALe0kl8MmyAQw2GA717TEvW0vvHaVg=; b=jXPFaR9tUzvzqlOh90TT2unIIS1BWbgC4whEpTzD574Zz+gPqiYxAM6S2Ymv91nulb lvSnHPqrBOKmBXZ2SZ1qPz18Q9Jpb2oU/YjhIe9Mj9vvdSOGRSlZZJLhmfME1Qudl8ZY FGeukxVo7SOMXc3jAcyuxBXcluJfepPT8uHOS5rFl/h0ZXX0iSTTilusKXt6F2FP3BL8 yoRcVt3Ae6oSR9B0Pmi5d2E5fAXrRwU0hsTflXHWR7mjGQ6AIv5oWKn6LASm2OrV83Ne qWFyM0zi3H0uWVU83UJKNGqRMoH8TN7vde3zVY8L0IzuYu7cDMOgGFE4f0VHQVjWYVyX dXbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688781451; x=1691373451; 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=kCWRDMcwmvFF9ALe0kl8MmyAQw2GA717TEvW0vvHaVg=; b=fnzva9NTfmMUiPeg+3NNv0edWrXwZF3K9aIh+j6nn5LxAOdG8zmt7OPSVfFVj/naMG xaxa+x0jfO4IeWSkhA2w/+MM7XdTjNn1keXC22paCQGaCyV9B7vo3VJPksyw1dqcoCPH D3PnYsbLfTX/ZkhEufYd9/hf+myCt/kxGQhVmxC92bV54NxgKpA8zLo3D/oc/mtIt2Zj MjOTenPzTDNHczZVnFfDZ0R6BYhO1LapgQUmTFnVgtxMts9c/IqoUfKvhPSiY0Yswx88 y9dCh9LTs5T2sXLznbDqTgMrZfUiOepKisFzvek1IAoTMTb7iVZKz2SyCeWvyxqHrfQH u4NA== X-Gm-Message-State: ABy/qLbU3hp1yTqX8R6KaLz5HYIFhOoc8xZdU9Z9VHZbXezpGVJBLH8g C8Oe8GqXf9cczaQGrMuvRQ3Zjw5xrj+RkEeqF6wKmCau X-Google-Smtp-Source: APBJJlGlmL7V4pqzb7XKqcGxOjshGY4o91UpS3P+qHV/sZvlR4DvJG/aSoh/RKGWa05g3Qc6FC0SEw== X-Received: by 2002:a05:6870:1702:b0:1b3:ce91:ba64 with SMTP id h2-20020a056870170200b001b3ce91ba64mr8533445oae.59.1688781450982; Fri, 07 Jul 2023 18:57:30 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 18:57:30 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Kirill Rybalchenko Subject: [PATCH v5 10/11] examples/ptpclient: use rte_pktmbuf_mtod_offset Date: Fri, 7 Jul 2023 18:57:17 -0700 Message-Id: <20230708015718.75565-11-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 --- examples/ptpclient/ptpclient.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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