From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 6A9192E41 for ; Mon, 7 Mar 2016 19:51:39 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP; 07 Mar 2016 10:51:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,552,1449561600"; d="scan'208";a="904132022" Received: from irsmsx104.ger.corp.intel.com ([163.33.3.159]) by orsmga001.jf.intel.com with ESMTP; 07 Mar 2016 10:51:36 -0800 Received: from irsmsx155.ger.corp.intel.com (163.33.192.3) by IRSMSX104.ger.corp.intel.com (163.33.3.159) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 7 Mar 2016 18:51:35 +0000 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.35]) by irsmsx155.ger.corp.intel.com ([169.254.14.201]) with mapi id 14.03.0248.002; Mon, 7 Mar 2016 18:51:35 +0000 From: "Ananyev, Konstantin" To: "Tan, Jianfeng" , "dev@dpdk.org" Thread-Topic: [PATCH v2] examples/l3fwd: fix using packet type blindly Thread-Index: AQHRdiv5yYzf4nhaokaMGatUaEpWSp9OUUfA Date: Mon, 7 Mar 2016 18:51:35 +0000 Message-ID: <2601191342CEEE43887BDE71AB97725836B185E5@irsmsx105.ger.corp.intel.com> References: <1456795416-118189-1-git-send-email-jianfeng.tan@intel.com> <1457080687-114113-1-git-send-email-jianfeng.tan@intel.com> In-Reply-To: <1457080687-114113-1-git-send-email-jianfeng.tan@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMGI0Yzk1MTItYWE5MC00NTc3LTg3MjItNDE0ODcwMjg5NGRlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6Ijg0Yml6bW81R1BxMXdlU0NEZFB6eTJydUxKODhOSXFCM2NweTJrcTRGXC80PSJ9 x-ctpclassification: CTP_IC x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] examples/l3fwd: fix using packet type blindly X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Mar 2016 18:51:40 -0000 Hi Jianfeng, >=20 > +/* Requirements: > + * 1. IP packets without extension; > + * 2. L4 payload should be either TCP or UDP. > + */ > +int > +em_check_ptype(int portid) > +{ > + int i, ret; > + int ptype_l3_ipv4_ext =3D 0; > + int ptype_l3_ipv6_ext =3D 0; > + int ptype_l4_tcp =3D 0; > + int ptype_l4_udp =3D 0; > + > + ret =3D rte_eth_dev_get_ptype_info(portid, > + RTE_PTYPE_L3_MASK | RTE_PTYPE_L4_MASK, > + NULL, 0); > + if (ret <=3D 0) > + return 0; > + > + uint32_t ptypes[ret]; > + > + ret =3D rte_eth_dev_get_ptype_info(portid, > + RTE_PTYPE_L3_MASK | RTE_PTYPE_L4_MASK, > + ptypes, ret); > + for (i =3D 0; i < ret; ++i) { > + switch (ptypes[i]) { > + case RTE_PTYPE_L3_IPV4_EXT: > + ptype_l3_ipv4_ext =3D 1; > + break; > + case RTE_PTYPE_L3_IPV6_EXT: > + ptype_l3_ipv6_ext =3D 1; > + break; > + case RTE_PTYPE_L4_TCP: > + ptype_l4_tcp =3D 1; > + break; > + case RTE_PTYPE_L4_UDP: > + ptype_l4_udp =3D 1; > + break; > + } > + } > + > + if (ptype_l3_ipv4_ext =3D=3D 0) > + printf("port %d cannot parse RTE_PTYPE_L3_IPV4_EXT\n", portid); > + if (ptype_l3_ipv6_ext =3D=3D 0) > + printf("port %d cannot parse RTE_PTYPE_L3_IPV6_EXT\n", portid); > + if (!ptype_l3_ipv4_ext || !ptype_l3_ipv6_ext) > + return 0; > + > + if (ptype_l4_tcp =3D=3D 0) > + printf("port %d cannot parse RTE_PTYPE_L4_TCP\n", portid); > + if (ptype_l4_udp =3D=3D 0) > + printf("port %d cannot parse RTE_PTYPE_L4_UDP\n", portid); > + if (ptype_l4_tcp || ptype_l4_udp) > + return 1; Should probably be: if (ptype_l4_tcp && ptype_l4_udp) ? > + > + return 0; > +} > + > +static inline void > +em_parse_ptype(struct rte_mbuf *m) > +{ > + struct ether_hdr *eth_hdr; > + uint32_t packet_type =3D RTE_PTYPE_UNKNOWN; > + uint16_t ethertype; > + void *l3; > + int hdr_len; > + struct ipv4_hdr *ipv4_hdr; > + struct ipv6_hdr *ipv6_hdr; > + > + eth_hdr =3D rte_pktmbuf_mtod(m, struct ether_hdr *); > + ethertype =3D rte_be_to_cpu_16(eth_hdr->ether_type); I think you can avoid bswap here, if use constants in BE format=20 for comparison instead: =20 ethertype =3D eth_hdr->ether_type; switch (ethertype) { case (rte_cpu_to_be_16(ETHER_TYPE_IPv4)): ... Same for lpm. >=20 > @@ -612,6 +622,14 @@ parse_args(int argc, char **argv) > return -1; > } > } > + > + if (!strncmp(lgopts[option_index].name, > + CMD_LINE_OPT_PARSE_PTYPE, > + sizeof(CMD_LINE_OPT_PARSE_PTYPE))) { > + printf("soft parse-ptype is enabled\n"); > + parse_ptype =3D 1; > + } > + > break; >=20 > default: > @@ -965,6 +983,40 @@ main(int argc, char **argv) > rte_eth_promiscuous_enable(portid); > } >=20 > + printf("\n"); > + > + for (lcore_id =3D 0; lcore_id < RTE_MAX_LCORE; lcore_id++) { > + if (rte_lcore_is_enabled(lcore_id) =3D=3D 0) > + continue; > + qconf =3D &lcore_conf[lcore_id]; > + for (queue =3D 0; queue < qconf->n_rx_queue; ++queue) { > + portid =3D qconf->rx_queue_list[queue].port_id; > + queueid =3D qconf->rx_queue_list[queue].queue_id; > + > + ret =3D l3fwd_lkp.check_ptype(portid); > + if (ret) { > + printf("Port %d: built-in packet type info\n", > + portid); > + continue; > + } I thought that if parse_ptype !=3D 0 we always want to use a SW parsing, no matter does HW support it or not, no? So user can measure what is the performance difference between HW and SW ve= rsions? Another thing, that I forgot to ask earlier - with ptype querying in place,= would we like to set: RTE_I40E_INC_VECTOR=3Dy=20 by default? Konstantin