From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 30228133F; Wed, 15 Mar 2017 03:42:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489545759; x=1521081759; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=mAYCTBtgolr2UF/AgV6hn2dqu3mxznOuWxlTPHDq6jU=; b=AZqNbcy/bA8WXR/xkV9eEP2HVxqaiXjwmzhzn6rNJILe0Zaa47YGoKH1 8Aadcx1OU7voaRsD+00Euqj98Zf+WQ==; Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Mar 2017 19:42:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,166,1486454400"; d="scan'208";a="76917638" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga006.fm.intel.com with ESMTP; 14 Mar 2017 19:42:37 -0700 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 14 Mar 2017 19:42:37 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 14 Mar 2017 19:42:37 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.177]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0248.002; Wed, 15 Mar 2017 10:42:35 +0800 From: "Wei, FangfangX" To: "dev@dpdk.org" CC: "Ananyev, Konstantin" , "stable@dpdk.org" , "Dai, Wei" Thread-Topic: [PATCH v2] examples/ip_fragmentation: fix check of packet type Thread-Index: AQHSnNLnLcq+2RwNLUWsaYf+7AzlxKGVH9hwgAARzhA= Date: Wed, 15 Mar 2017 02:42:34 +0000 Message-ID: <067B569323FEB248B5CB480E1954F4346EA0FC09@SHSMSX101.ccr.corp.intel.com> References: <1489502869-16472-1-git-send-email-wei.dai@intel.com> <49759EB36A64CF4892C1AFEC9231E8D64E50CCDD@PGSMSX101.gar.corp.intel.com> In-Reply-To: <49759EB36A64CF4892C1AFEC9231E8D64E50CCDD@PGSMSX101.gar.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMWMzYTQxYzYtYzlhNi00YjYzLTliOTQtMmY1NGJiN2Y4ZDE2IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IkdWenBoNnYxdGJiSjEyaDdrNU8xNHlVWUNpZVJoczY1MUxETFkyM241MDA9In0= x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: [dpdk-stable] FW: [PATCH v2] examples/ip_fragmentation: fix check of packet type X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Mar 2017 02:42:40 -0000 -----Original Message----- From: Dai, Wei=20 Sent: Wednesday, March 15, 2017 9:39 AM To: Wei, FangfangX Subject: FW: [PATCH v2] examples/ip_fragmentation: fix check of packet type > -----Original Message----- > From: Dai, Wei > Sent: Tuesday, March 14, 2017 10:48 PM > To: dev@dpdk.org > Cc: Ananyev, Konstantin ; Dai, Wei=20 > ; stable@dpdk.org > Subject: [PATCH v2] examples/ip_fragmentation: fix check of packet=20 > type >=20 > The packet_type in mbuf is not correctly filled by ixgbe 82599 NIC. > To use the ether_type in ethernet header to check packet type is more rel= iaber. >=20 > Fixes: 3c0184cc0c60 ("examples: replace some offload flags with packet=20 > type") > Fixes: ab351fe1c95c ("mbuf: remove packet type from offload flags") >=20 > Cc: stable@dpdk.org >=20 > Reported-by: Fangfang Wei > Signed-off-by: Wei Dai Tested-by: Fangfang Wei > --- > examples/ip_fragmentation/main.c | 74 > ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 74 insertions(+) >=20 > diff --git a/examples/ip_fragmentation/main.c > b/examples/ip_fragmentation/main.c > index 9e9ecae..151f059 100644 > --- a/examples/ip_fragmentation/main.c > +++ b/examples/ip_fragmentation/main.c > @@ -653,6 +653,74 @@ check_all_ports_link_status(uint8_t port_num,=20 > uint32_t port_mask) > } > } >=20 > +/* Check L3 packet type detection capablity of the NIC port */ static=20 > +int check_ptype(int portid) { > + int i, ret; > + int ptype_l3_ipv4 =3D 0, ptype_l3_ipv6 =3D 0; > + uint32_t ptype_mask =3D RTE_PTYPE_L3_MASK; > + > + ret =3D rte_eth_dev_get_supported_ptypes(portid, ptype_mask, NULL, 0); > + if (ret <=3D 0) > + return 0; > + > + uint32_t ptypes[ret]; > + > + ret =3D rte_eth_dev_get_supported_ptypes(portid, ptype_mask, ptypes, > ret); > + for (i =3D 0; i < ret; ++i) { > + if (ptypes[i] & RTE_PTYPE_L3_IPV4) > + ptype_l3_ipv4 =3D 1; > + if (ptypes[i] & RTE_PTYPE_L3_IPV6) > + ptype_l3_ipv6 =3D 1; > + } > + > + if (ptype_l3_ipv4 =3D=3D 0) > + printf("port %d cannot parse RTE_PTYPE_L3_IPV4\n", portid); > + > + if (ptype_l3_ipv6 =3D=3D 0) > + printf("port %d cannot parse RTE_PTYPE_L3_IPV6\n", portid); > + > + if (ptype_l3_ipv4 && ptype_l3_ipv6) > + return 1; > + > + return 0; > + > +} > + > +/* Parse packet type of a packet by SW */ static inline void=20 > +parse_ptype(struct rte_mbuf *m) { > + struct ether_hdr *eth_hdr; > + uint32_t packet_type =3D RTE_PTYPE_UNKNOWN; > + uint16_t ether_type; > + > + eth_hdr =3D rte_pktmbuf_mtod(m, struct ether_hdr *); > + ether_type =3D eth_hdr->ether_type; > + if (ether_type =3D=3D rte_cpu_to_be_16(ETHER_TYPE_IPv4)) > + packet_type |=3D RTE_PTYPE_L3_IPV4_EXT_UNKNOWN; > + else if (ether_type =3D=3D rte_cpu_to_be_16(ETHER_TYPE_IPv6)) > + packet_type |=3D RTE_PTYPE_L3_IPV6_EXT_UNKNOWN; > + > + m->packet_type =3D packet_type; > +} > + > +/* callback function to detect packet type for a queue of a port */=20 > +static uint16_t cb_parse_ptype(uint8_t port __rte_unused, uint16_t=20 > +queue __rte_unused, > + struct rte_mbuf *pkts[], uint16_t nb_pkts, > + uint16_t max_pkts __rte_unused, > + void *user_param __rte_unused) > +{ > + uint16_t i; > + > + for (i =3D 0; i < nb_pkts; ++i) > + parse_ptype(pkts[i]); > + > + return nb_pkts; > +} > + > static int > init_routing_table(void) > { > @@ -944,6 +1012,12 @@ main(int argc, char **argv) > ret, portid); >=20 > rte_eth_promiscuous_enable(portid); > + > + if (check_ptype(portid) =3D=3D 0) { > + rte_eth_add_rx_callback(portid, 0, cb_parse_ptype, NULL); > + printf("Add Rx callback funciton to detect L3 packet type by > SW :" > + " port =3D %d\n", portid); > + } > } >=20 > if (init_routing_table() < 0) > -- > 2.7.4