From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id EB322683E for ; Thu, 6 Dec 2018 06:42:14 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Dec 2018 21:42:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,321,1539673200"; d="scan'208,217";a="99085504" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga008.jf.intel.com with ESMTP; 05 Dec 2018 21:42:13 -0800 Received: from bgsmsx109.gar.corp.intel.com (10.223.4.211) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 5 Dec 2018 21:42:11 -0800 Received: from bgsmsx101.gar.corp.intel.com ([169.254.1.20]) by BGSMSX109.gar.corp.intel.com ([169.254.10.187]) with mapi id 14.03.0415.000; Thu, 6 Dec 2018 11:11:57 +0530 From: "Varghese, Vipin" To: bai bakari <912873551@qq.com> CC: dev Thread-Topic: RE: [dpdk-dev] About the data payload of rte_mbuf? Thread-Index: AQHUjRY7WaZyy/LCMkON2xNoav5OM6VxGyTg//+viQCAAGcGEA== Date: Thu, 6 Dec 2018 05:41:56 +0000 Message-ID: <4C9E0AB70F954A408CC4ADDBF0F8FA7D4D2D41B0@BGSMSX101.gar.corp.intel.com> References: <4C9E0AB70F954A408CC4ADDBF0F8FA7D4D2D40E2@BGSMSX101.gar.corp.intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDM1N2QyZDktZWY4ZC00MjE5LWI3Y2QtNjIyMzI4ZTVmOWIwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoibGxvRWd6WHJcL2txR3VcL3pxUjViZ1kyaGgrS2RSSEppY0NTSmRxd3RxemtYR0VqWmVhajZMTG1cL2dDWE42cVFCaCJ9 dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.223.10.10] MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] About the data payload of rte_mbuf? X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Dec 2018 05:42:15 -0000 Hi, snipped For your two question, 1. I think it's right, because the definition of "rte_pktmbuf_mtod_offset" = is: #define rte_pktmbuf_mtod_offset(m, t, o) \ ((t)((char *)(m)->buf_addr + (m)->data_off + (o))) You are passing ' ipv4_hdr =3D rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *= , sizeof(struct ether_hdr)); ' So you are expecting the start of packet is = ipv4 rather than ethernet header. Can you capture the packet and cross check the content in mbuf using 'pdump= ' tool 2. I set the packet type is IPv4 when i use dpdk-pktgen, that if can promis= e its type is IPv4? Capture the packet, I am sure it will have ethernet header + ipv4 header + = payload and not ipv4 header + payload. ------------------ Original ------------------ From: "Varghese, Vipin">; Date: Thu, Dec 6, 2018 12:20 PM To: "bai bakari"<912873551@qq.com>;"dev">; Subject: RE: [dpdk-dev] About the data payload of rte_mbuf? Hi, A quick query from your email Snipped > ipv4_hdr =3D rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *, sizeof(struct > ether_hdr)); Questions: 1. Should not be sizeof(struct ipv4_hdr) since you are passing second argum= ent as ipv4_hdr? 2. you are getting packets which starts from ether or ipv4? If it is ethern= et header would not you checking if ether type is ipv4 first? You can get a= rp, vlan, mpls right? ip_len =3D ntohs(ipv4_hdr->total_length); > > > > if (ipv4_hdr->next_proto_id =3D=3D IPPROTO_TCP) { > tcp_hdr =3D (struct tcp_hdr *)((uint8_t *)ipv4_hdr + ((ipv4_hdr->vers= ion_ihl & > 0xf) << 2)); > payload =3D (uint8_t *)tcp_hdr + (tcp_hdr->data_off << 2); > payload_len =3D ip_len - (payload - (uint8_t *)ipv4_hdr); > > } > > > when i send packets using dpdk-pktgen, i found: > ip_len =3D 46 > ip_header_len =3D 20 > but the tcp_header_len=3D(tcp_hdr->data_off << 2)=3D0, and (payload - (ui= nt8_t > *)ipv4_hdr) =3D 340 > ip_len. > > > I'm confused, is there any errors about the code to compute the payload_l= en of > rte_mbuf? > I think maybe the dpdk-pktgen cannot send the packets with payload? > > > I'm a beginner, anyone can help me how to compute the payload_len of > rte_mbuf and test it? > > > Thank you in advance!