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 6BA7BA050D; Thu, 14 Apr 2022 17:43:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5533C40E09; Thu, 14 Apr 2022 17:43:28 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 418C840687 for ; Thu, 14 Apr 2022 17:43:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649951006; x=1681487006; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=4/2Sj8B9t5lhAlLAKII44BNdxTuRUjXD80doyOWRUu0=; b=I+fx2dfl4HNXRg27vXjHIInPUH1a7G3fvUAqs0KiG1F9o2P2Djn5fCIF lu/fIPxH+jVDut4zifJ8hzKUDIFDVg+MaqtotlYrcZepfQVkowgVszMVE cR6wD3vfsclFr+tHJ9jUiWLDHDbyo7UHtcivtWSd77mdX26tGFxqNYAzz bPX4QsrsAm5GERtb/ublUfYsyJjczk+d7KHciPzB1Y0SFtJNyWHodaxxD tjYlFXFCtVTj2izBO5VOXEEVX2y3xnTOSE/L4r9NLye6rxGEWTriOqzgb /LFFP5ATBwDKRa7ubO82UtUu9xi6R3oQYRs5/5peXWlxZPHCIocVo64mp w==; X-IronPort-AV: E=McAfee;i="6400,9594,10317"; a="242891351" X-IronPort-AV: E=Sophos;i="5.90,260,1643702400"; d="scan'208";a="242891351" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2022 08:43:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,260,1643702400"; d="scan'208";a="656049898" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by fmsmga002.fm.intel.com with ESMTP; 14 Apr 2022 08:43:25 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Thu, 14 Apr 2022 08:43:24 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Thu, 14 Apr 2022 08:43:24 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.174) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Thu, 14 Apr 2022 08:43:24 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eL9lcMWUJ8lj6nQUj6wyPWKYThHP29sfh5Wqi8LBPMVfNWad6Vx9L+NXC/7MmZw5D4STm69vJWVkSINX+/DvwYKtQhqcQjfbhDSg/k83WI0yrk4m4T1GHlAVD7cdKoYvARFd+5+Kzd/RUHfgqdpsMgMA+Dkmd1fJpZvUOi5wqg1xw6jChcqu6OK1UsWM5GU2lNkUwPFcxP0KKmT4g/Sqp6yhXhO1UjJ92h5EsEh3UUPoIfqX/O4amgnDfBQqvLUs/OYNinEcjsX5vr20H+M40GZdCXrdQiIZcUNFePY3iFMoZ92cuiGIkZJBp8HHSGrSjPYp0gpZRIle0jn6nE/OuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aeiJBZ768kmJFKytBRgevwalWF+T2PoOa6GN/RAqHts=; b=fX7/u/5DgWcnUvkm7pa6fmHrkvsan4BodGZllNTHLikkSyb+vYbQKsnPREPSlgpLknaLAbbXfSEbSpkSHe/UxZyzc1Gn02m5mPTBaAetZoegQhHEGRR2c4st1DF4seRQmZqJwkCfUNW9JRPXxOT6SPtUJzpcF88Z7nrmlHxkN1S3hlq0VQ3jZgtRGaxE49xX6UePs2aPN27yEwPhXVrlmzmF86PcMYWfgofXc8Cf8Yon5UfFCdBo+3OGRk2B2m42seIpgFHcTIkdBMPfYcHqV3jN/m5OI0sL7qGSm2sdBYqAW7BYknLhhD6HmlYMbjIuKlPweb9oy4P3beFQ4aP43Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from DM6PR11MB4491.namprd11.prod.outlook.com (2603:10b6:5:204::19) by BY5PR11MB4451.namprd11.prod.outlook.com (2603:10b6:a03:1cb::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.18; Thu, 14 Apr 2022 15:43:22 +0000 Received: from DM6PR11MB4491.namprd11.prod.outlook.com ([fe80::dc35:d5af:9936:eef3]) by DM6PR11MB4491.namprd11.prod.outlook.com ([fe80::dc35:d5af:9936:eef3%3]) with mapi id 15.20.5164.020; Thu, 14 Apr 2022 15:43:22 +0000 From: "Ananyev, Konstantin" To: Nithin Dabilpuram , "jerinj@marvell.com" , "Nicolau, Radu" , Akhil Goyal CC: "dev@dpdk.org" , "anoobj@marvell.com" Subject: RE: [PATCH 2/7] examples/ipsec-secgw: use HW parsed packet type in poll mode Thread-Topic: [PATCH 2/7] examples/ipsec-secgw: use HW parsed packet type in poll mode Thread-Index: AQHYPhagTQUrun4KlkqMzk+r1jgB7KzvoQcw Date: Thu, 14 Apr 2022 15:43:22 +0000 Message-ID: References: <20220322175902.363520-1-ndabilpuram@marvell.com> <20220322175902.363520-2-ndabilpuram@marvell.com> In-Reply-To: <20220322175902.363520-2-ndabilpuram@marvell.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.6.401.20 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 52cf114b-4bd1-4136-0687-08da1e2d81d4 x-ms-traffictypediagnostic: BY5PR11MB4451:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: DSV+77cHUvZVSht/avJs2shn+VmJ1jyWWvtTbU/DE6UxooEmY+Yqcvon65N2rW54PsigOu3r9J9txB7UkgzCUVbtD5frTTNjXv3fLgPskBvPE6wTI8BhIvpPhnID76KW6UI9rQ4KQC8rUh5TwPK6P6GdtYiTX/tSAJxFeg0CfaTCgrdZyUC7jGaPXKq/FkAnClkhv+Z+BU53LLKEwdM6W3Fzv5v3sJSl9pGMzGYKtJzIuzOLwxAwIB2xCxqWd6H/5t19sq7Og3iuWOV2uTbuljQb8JLALKGVIfPuZLpEgKtASO10TjdcjD/npLaxlhjjvTHXxoqmWw19EfggYlC6YRP4gsGTpq8sdx/jUcfsGdSxF6y0q/RhtVKZF97776FMIDvLYuCi2uyDsd49XccOvxLT/krxd4BSXRjTzaPSL6+UN+1xVKTS/sBq9xRaPXqW3csLU6Lp0ECfDXNOn+53NLpLOs/lyHGYkh68MRBpmDzdq5c12cnecwfVgLC0fKcJLquxnIahWc5EExwf8LrZ3hfsR9258cLtvVrqBI0pA+V4ZponerPZsVwejQQBTpJZcgJ39OdWVMz/xGQ5RMfUE6aQo/QXNDY4pRXCd5law9DAGRsEIpdvdnhxv+hrWHtSaOfL0j2SKLPNqvs0AAx8r1eRe/13DKTnmhYWjpxN+aCegL7S5FewG/MZHZmHKVZredLvuflcY4waVqT37W4hag== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB4491.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(7696005)(9686003)(26005)(186003)(6506007)(122000001)(33656002)(5660300002)(2906002)(4326008)(8676002)(83380400001)(86362001)(66446008)(66556008)(66946007)(66476007)(64756008)(76116006)(38100700002)(71200400001)(508600001)(55016003)(30864003)(52536014)(8936002)(38070700005)(82960400001)(316002)(54906003)(110136005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?wEnrJ+KNJOXxA7t8xKZHWNy+X65WBmw/VvRjcm8raGUKu//mlCUOoNlAeqCW?= =?us-ascii?Q?LL8vNh9kon9CTiMzWIU/PJ2npB4gB++JwQf9PQq95GxKzTfLDKtBpxApBCs9?= =?us-ascii?Q?ma5H/6OkYQCMTDPIeG+RNWgF1V7m8p0sfIiSa7KZCi215Z7kanLyNsrgZ8X5?= =?us-ascii?Q?+QSnN5DEhFjyatCz4cJdpc6IXXp0VSXDg4FFELnkbp9xEqP7P0jeLVnOcEHE?= =?us-ascii?Q?CrYhS82lsEcdjSMnSPdc68+crES+TTUZG7Q/nS2W6y+Pm9ZyMkd+gPlW6nbu?= =?us-ascii?Q?89PwceNn0vk1nD/DNUg43VOH1Lm14uHplYZdfy9zSHC1acBDLb0QqrYphYq9?= =?us-ascii?Q?Ne+VDQ9uZp7g4hlrWVRvb+rDorkg+gMyfuxHHDk0QDjtWesMGmOxqQt76Qx5?= =?us-ascii?Q?oztkXYlZh8/U+zTIju51gtIthrqi03We3m5RMyIVWswjsPzWPWN9jI9KyaKN?= =?us-ascii?Q?03QYq2Q7jItDc/Rv3NbQqIRhvXqvezeIomBEBQF3UmoySdwEiOr6CDN3vto7?= =?us-ascii?Q?cICO68iiKQDJEfbJQvFr2K3bo2cFM2Q+/cmgrz81+r5bgZGlj9d5xckyulnE?= =?us-ascii?Q?9vlJDmcfJpzPNar1GUfwGHRut/aM6bw0uFVGUZFLxwVPnB2fX6MG73BZeNSL?= =?us-ascii?Q?P5XDquKk8svmJAOH/TO3t+W4b0jikXD+39fml5te9uEws5Y9Cqn+gjPmA/bi?= =?us-ascii?Q?s94vexf0G5r9/C8n0llpWmvm6a8oTRwoKYz6b2rNAoAiMHWpOtOedSojtzGD?= =?us-ascii?Q?eZW8fDSHNN8l1Bt6rZiU94JQKNSzfNoPA4HX0Om+IiT9LjS9B6q0Z0r2zq+l?= =?us-ascii?Q?smiIIyrrApmvgPNKKz0luoPofm7NsacUApGGc7kCssdNLLuhiCk6+J/gwy/D?= =?us-ascii?Q?UqF0fENp0CMmpYq11l5McV5J4/Tut19cCyy6vwnwVOOlk5pbHpAqXWrbVkk2?= =?us-ascii?Q?pyjRY/ptlECt/3Ho1Li5pSM5zuZSLEg99zs37TMGV1AnktDhWTaa17g0HmUM?= =?us-ascii?Q?BcMH/2wp+A1C8rI5zwILM7DdrGURPfmQAL7Vk1ZuYxqUYM4hwa5FsJw5jIxN?= =?us-ascii?Q?K+/g8p926s/OU13joPVjCGjSiaDf5S6xUHdCT8YxQLmoKHodT2TYxMTgGRMh?= =?us-ascii?Q?fwLy9s1RP63eu+4psQLVLUA66rjh88WwuxZ3NbCjNmrkotJ4gjHsn8eEntV+?= =?us-ascii?Q?w8KHpM7vQIjpv/b6aAoEF2E44vfAe665f6MZCmclht8M/M0p+MvA/nUU43VT?= =?us-ascii?Q?EHiIrtT3lonlCi3/+SjuCfapoJKhzsxNarfUjlOdSkGGKSUiG9a9IeaFD2+P?= =?us-ascii?Q?zRikV7Y1OfZPAY+7UDxU8B4R31vchg4d4HpaMlTTbF5HrGXehNnWe/6Dr0G7?= =?us-ascii?Q?V8w4unqEID6ggShymMUO8PBc1PcY6HXBcwLjqAymr9DMu3J6MKW2QkvmIoEI?= =?us-ascii?Q?YXGfAMonRa95xguSf30nD3xdWpNOkFch9vuv0a9bql85nYxVhBCUvj0P5135?= =?us-ascii?Q?oJlKVspdqLWyDQ/fc6Pvrek5K0FJZgLMXaNYfAG2FODfrvsr4prNAZy0QV3R?= =?us-ascii?Q?yulJ0+e51FqKBl1Ozck6b5E3s/3aOvZA/kCVcmL34tzll6CDEr8kqEeGO6dP?= =?us-ascii?Q?9NU3tetJdSP6W6E7+fasUrcCfqlJhHmRZZZz4I/SwYCplrdkc9VkKx9uF8pf?= =?us-ascii?Q?EoZd6Lv3nsOKmC8L7CIW22UrtpQBPQ3GX9mzwMxYClToB/3jKaGE8v+CUOCp?= =?us-ascii?Q?xTciJQUGWNydRi8RaqwOv3HJYPLFi2o=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB4491.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 52cf114b-4bd1-4136-0687-08da1e2d81d4 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Apr 2022 15:43:22.5770 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 7bqbPDmHXfnL3UrSgJ/j2X3dgGtzWgzhX7Z3OWIchzPpaUwD85HtbXSdu/RRdl37OnLbRGYYkVNw9eq9aecUpIgecMo2hO4IlbKaqQwYQiU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB4451 X-OriginatorOrg: intel.com 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 > Use HW parsed packet type when ethdev supports necessary protocols. > If packet type is not supported, then register ethdev callbacks > for parse packet in SW. This is better for performance as it > effects fast path. >=20 > Signed-off-by: Nithin Dabilpuram > --- > examples/ipsec-secgw/ipsec-secgw.c | 259 +++++++++++++++++++++++++++----= ------ > 1 file changed, 194 insertions(+), 65 deletions(-) >=20 > diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ip= sec-secgw.c > index 76919e5..e8f9e90 100644 > --- a/examples/ipsec-secgw/ipsec-secgw.c > +++ b/examples/ipsec-secgw/ipsec-secgw.c > @@ -374,53 +374,30 @@ print_stats_cb(__rte_unused void *param) > static inline void > prepare_one_packet(struct rte_mbuf *pkt, struct ipsec_traffic *t) > { > + uint32_t ptype =3D pkt->packet_type; > const struct rte_ether_hdr *eth; > const struct rte_ipv4_hdr *iph4; > const struct rte_ipv6_hdr *iph6; > - const struct rte_udp_hdr *udp; > - uint16_t ip4_hdr_len; > - uint16_t nat_port; > + uint32_t tun_type, l3_type; > + > + tun_type =3D ptype & RTE_PTYPE_TUNNEL_MASK; > + l3_type =3D ptype & RTE_PTYPE_L3_MASK; >=20 > eth =3D rte_pktmbuf_mtod(pkt, const struct rte_ether_hdr *); > - if (eth->ether_type =3D=3D rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) { > - > + if (l3_type =3D=3D RTE_PTYPE_L3_IPV4) { > iph4 =3D (const struct rte_ipv4_hdr *)rte_pktmbuf_adj(pkt, > RTE_ETHER_HDR_LEN); > adjust_ipv4_pktlen(pkt, iph4, 0); >=20 > - switch (iph4->next_proto_id) { > - case IPPROTO_ESP: > + if (tun_type =3D=3D RTE_PTYPE_TUNNEL_ESP) { > t->ipsec.pkts[(t->ipsec.num)++] =3D pkt; > - break; > - case IPPROTO_UDP: > - if (app_sa_prm.udp_encap =3D=3D 1) { > - ip4_hdr_len =3D ((iph4->version_ihl & > - RTE_IPV4_HDR_IHL_MASK) * > - RTE_IPV4_IHL_MULTIPLIER); > - udp =3D rte_pktmbuf_mtod_offset(pkt, > - struct rte_udp_hdr *, ip4_hdr_len); > - nat_port =3D rte_cpu_to_be_16(IPSEC_NAT_T_PORT); > - if (udp->src_port =3D=3D nat_port || > - udp->dst_port =3D=3D nat_port){ > - t->ipsec.pkts[(t->ipsec.num)++] =3D pkt; > - pkt->packet_type |=3D > - MBUF_PTYPE_TUNNEL_ESP_IN_UDP; > - break; > - } > - } > - /* Fall through */ > - default: > + } else { > t->ip4.data[t->ip4.num] =3D &iph4->next_proto_id; > t->ip4.pkts[(t->ip4.num)++] =3D pkt; > } > pkt->l2_len =3D 0; > pkt->l3_len =3D sizeof(*iph4); > - pkt->packet_type |=3D RTE_PTYPE_L3_IPV4; > - if (pkt->packet_type & RTE_PTYPE_L4_TCP) > - pkt->l4_len =3D sizeof(struct rte_tcp_hdr); > - else if (pkt->packet_type & RTE_PTYPE_L4_UDP) > - pkt->l4_len =3D sizeof(struct rte_udp_hdr); > - } else if (eth->ether_type =3D=3D rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6)= ) { > + } else if (l3_type & RTE_PTYPE_L3_IPV6) { As a nit: RTE_ETH_IS_IPV6_HDR(l3_type) > int next_proto; > size_t l3len, ext_len; > uint8_t *p; > @@ -430,47 +407,37 @@ prepare_one_packet(struct rte_mbuf *pkt, struct ips= ec_traffic *t) > RTE_ETHER_HDR_LEN); > adjust_ipv6_pktlen(pkt, iph6, 0); >=20 > - next_proto =3D iph6->proto; > - > - /* determine l3 header size up to ESP extension */ > l3len =3D sizeof(struct ip6_hdr); > - p =3D rte_pktmbuf_mtod(pkt, uint8_t *); > - while (next_proto !=3D IPPROTO_ESP && l3len < pkt->data_len && > - (next_proto =3D rte_ipv6_get_next_ext(p + l3len, > - next_proto, &ext_len)) >=3D 0) > - l3len +=3D ext_len; >=20 > - /* drop packet when IPv6 header exceeds first segment length */ > - if (unlikely(l3len > pkt->data_len)) { > - free_pkts(&pkt, 1); > - return; > - } > - > - switch (next_proto) { > - case IPPROTO_ESP: > + if (tun_type =3D=3D RTE_PTYPE_TUNNEL_ESP) { > t->ipsec.pkts[(t->ipsec.num)++] =3D pkt; > - break; > - case IPPROTO_UDP: > - if (app_sa_prm.udp_encap =3D=3D 1) { > - udp =3D rte_pktmbuf_mtod_offset(pkt, > - struct rte_udp_hdr *, l3len); > - nat_port =3D rte_cpu_to_be_16(IPSEC_NAT_T_PORT); > - if (udp->src_port =3D=3D nat_port || > - udp->dst_port =3D=3D nat_port){ > - t->ipsec.pkts[(t->ipsec.num)++] =3D pkt; > - pkt->packet_type |=3D > - MBUF_PTYPE_TUNNEL_ESP_IN_UDP; > - break; > - } > - } > - /* Fall through */ > - default: > + } else { > t->ip6.data[t->ip6.num] =3D &iph6->proto; > t->ip6.pkts[(t->ip6.num)++] =3D pkt; > } > + > + /* Determine l3 header size up to ESP extension by walking > + * through extension headers. > + */ > + if (l3_type =3D=3D RTE_PTYPE_L3_IPV6_EXT || > + l3_type =3D=3D RTE_PTYPE_L3_IPV6_EXT_UNKNOWN) { > + p =3D rte_pktmbuf_mtod(pkt, uint8_t *); > + next_proto =3D iph6->proto; > + while (next_proto !=3D IPPROTO_ESP && > + l3len < pkt->data_len && > + (next_proto =3D rte_ipv6_get_next_ext(p + l3len, > + next_proto, &ext_len)) >=3D 0) > + l3len +=3D ext_len; > + > + /* Drop pkt when IPv6 header exceeds first seg size */ > + if (unlikely(l3len > pkt->data_len)) { > + free_pkts(&pkt, 1); > + return; > + } > + } > + > pkt->l2_len =3D 0; > pkt->l3_len =3D l3len; > - pkt->packet_type |=3D RTE_PTYPE_L3_IPV6; > } else { > /* Unknown/Unsupported type, drop the packet */ > RTE_LOG(ERR, IPSEC, "Unsupported packet type 0x%x\n", > @@ -479,6 +446,11 @@ prepare_one_packet(struct rte_mbuf *pkt, struct ipse= c_traffic *t) > return; > } >=20 > + if (ptype & RTE_PTYPE_L4_TCP) I think it needs to be: If ((ptype & RTE_PTYPE_L4_MASK) =3D=3D RTE_PTYPE_L4_TCP) Same for udp. Though it seems that it was there already since commit a7f32947a316c4757a315239752596ca1cf1b268. > + pkt->l4_len =3D sizeof(struct rte_tcp_hdr); > + else if (ptype & RTE_PTYPE_L4_UDP) > + pkt->l4_len =3D sizeof(struct rte_udp_hdr); > + > /* Check if the packet has been processed inline. For inline protocol > * processed packets, the metadata in the mbuf can be used to identify > * the security processing done on the packet. The metadata will be > @@ -2249,6 +2221,147 @@ cryptodevs_init(uint16_t req_queue_num) > return total_nb_qps; > } >=20 > +static int > +check_ptype(int portid) > +{ > + int l3_ipv4 =3D 0, l3_ipv6 =3D 0, l4_udp =3D 0, tunnel_esp =3D 0; > + int i, nb_ptypes; > + uint32_t mask; > + > + mask =3D (RTE_PTYPE_L3_MASK | RTE_PTYPE_L4_MASK | > + RTE_PTYPE_TUNNEL_MASK); > + > + nb_ptypes =3D rte_eth_dev_get_supported_ptypes(portid, mask, NULL, 0); > + if (nb_ptypes <=3D 0) > + return 0; > + > + uint32_t ptypes[nb_ptypes]; > + > + nb_ptypes =3D rte_eth_dev_get_supported_ptypes(portid, mask, ptypes, nb= _ptypes); > + for (i =3D 0; i < nb_ptypes; ++i) { > + if (ptypes[i] & RTE_PTYPE_L3_IPV4) As nit: RTE_ETH_IS_IPV4_HDR(ptypes[i]) > + l3_ipv4 =3D 1; > + if (ptypes[i] & RTE_PTYPE_L3_IPV6) As nit: RTE_ETH_IS_IPV6_HDR(ptypes[i]) > + l3_ipv6 =3D 1; > + if (ptypes[i] & RTE_PTYPE_TUNNEL_ESP) if ((ptypes[i] & RTE_PTYPE_TUNNEL_MASK =3D=3D RTE_PTYPE_TUNNEL_ESP)=20 > + tunnel_esp =3D 1; > + if (ptypes[i] & RTE_PTYPE_L4_UDP) Same as above. > + l4_udp =3D 1; > + } > + > + if (l3_ipv4 =3D=3D 0) > + printf("port %d cannot parse RTE_PTYPE_L3_IPV4\n", portid); > + > + if (l3_ipv6 =3D=3D 0) > + printf("port %d cannot parse RTE_PTYPE_L3_IPV6\n", portid); > + > + if (l4_udp =3D=3D 0) > + printf("port %d cannot parse RTE_PTYPE_L4_UDP\n", portid); > + > + if (tunnel_esp =3D=3D 0) > + printf("port %d cannot parse RTE_PTYPE_TUNNEL_ESP\n", portid); > + > + if (l3_ipv4 && l3_ipv6 && l4_udp && tunnel_esp) > + return 1; > + > + return 0; > + > +} > + > +static inline void > +parse_ptype(struct rte_mbuf *m) > +{ > + uint32_t packet_type =3D RTE_PTYPE_UNKNOWN; > + const struct rte_ipv4_hdr *iph4; > + const struct rte_ipv6_hdr *iph6; > + const struct rte_ether_hdr *eth; > + const struct rte_udp_hdr *udp; > + uint16_t nat_port, ether_type; > + int next_proto =3D 0; > + size_t ext_len =3D 0; > + const uint8_t *p; > + uint32_t l3len; > + > + eth =3D rte_pktmbuf_mtod(m, struct rte_ether_hdr *); > + ether_type =3D eth->ether_type; > + > + if (ether_type =3D=3D rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) { > + iph4 =3D (const struct rte_ipv4_hdr *)(eth + 1); > + l3len =3D ((iph4->version_ihl & RTE_IPV4_HDR_IHL_MASK) * > + RTE_IPV4_IHL_MULTIPLIER); > + > + if (l3len =3D=3D sizeof(struct rte_ipv4_hdr)) > + packet_type |=3D RTE_PTYPE_L3_IPV4; > + else > + packet_type |=3D RTE_PTYPE_L3_IPV4_EXT_UNKNOWN; > + > + next_proto =3D iph4->next_proto_id; > + p =3D (const uint8_t *)iph4; > + } else if (ether_type =3D=3D rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6)) { > + iph6 =3D (const struct rte_ipv6_hdr *)(eth + 1); > + l3len =3D sizeof(struct ip6_hdr); > + > + /* determine l3 header size up to ESP extension */ > + next_proto =3D iph6->proto; > + p =3D (const uint8_t *)iph6; > + while (next_proto !=3D IPPROTO_ESP && l3len < m->data_len && > + (next_proto =3D rte_ipv6_get_next_ext(p + l3len, > + next_proto, &ext_len)) >=3D 0) > + l3len +=3D ext_len; > + > + /* Skip IPv6 header exceeds first segment length */ > + if (unlikely(l3len + RTE_ETHER_HDR_LEN > m->data_len)) > + goto exit; > + > + if (l3len =3D=3D sizeof(struct ip6_hdr)) > + packet_type |=3D RTE_PTYPE_L3_IPV6; > + else > + packet_type |=3D RTE_PTYPE_L3_IPV6_EXT; > + } > + > + switch (next_proto) { > + case IPPROTO_ESP: > + packet_type |=3D RTE_PTYPE_TUNNEL_ESP; > + break; > + case IPPROTO_UDP: > + if (app_sa_prm.udp_encap =3D=3D 1) { > + udp =3D (const struct rte_udp_hdr *)(p + l3len); > + nat_port =3D rte_cpu_to_be_16(IPSEC_NAT_T_PORT); > + if (udp->src_port =3D=3D nat_port || > + udp->dst_port =3D=3D nat_port) > + packet_type |=3D > + MBUF_PTYPE_TUNNEL_ESP_IN_UDP; > + } > + break; > + default: > + break; > + } > +exit: > + m->packet_type =3D packet_type; > +} > + > +static uint16_t > +parse_ptype_cb(uint16_t port __rte_unused, uint16_t queue __rte_unused, > + struct rte_mbuf *pkts[], uint16_t nb_pkts, > + uint16_t max_pkts __rte_unused, > + void *user_param __rte_unused) > +{ > + uint32_t i; > + > + if (unlikely(nb_pkts =3D=3D 0)) > + return nb_pkts; > + > + rte_prefetch0(rte_pktmbuf_mtod(pkts[0], struct ether_hdr *)); > + for (i =3D 0; i < (unsigned int) (nb_pkts - 1); ++i) { > + rte_prefetch0(rte_pktmbuf_mtod(pkts[i+1], > + struct ether_hdr *)); > + parse_ptype(pkts[i]); > + } > + parse_ptype(pkts[i]); > + > + return nb_pkts; > +} > + > static void > port_init(uint16_t portid, uint64_t req_rx_offloads, uint64_t req_tx_off= loads) > { > @@ -2260,6 +2373,7 @@ port_init(uint16_t portid, uint64_t req_rx_offloads= , uint64_t req_tx_offloads) > struct lcore_conf *qconf; > struct rte_ether_addr ethaddr; > struct rte_eth_conf local_port_conf =3D port_conf; > + int ptype_supported; >=20 > ret =3D rte_eth_dev_info_get(portid, &dev_info); > if (ret !=3D 0) > @@ -2357,6 +2471,11 @@ port_init(uint16_t portid, uint64_t req_rx_offload= s, uint64_t req_tx_offloads) > rte_exit(EXIT_FAILURE, "Cannot adjust number of descriptors: " > "err=3D%d, port=3D%d\n", ret, portid); >=20 > + /* Check if required ptypes are supported */ > + ptype_supported =3D check_ptype(portid); > + if (!ptype_supported) > + printf("Port %d: softly parse packet type info\n", portid); > + > /* init one TX queue per lcore */ > tx_queueid =3D 0; > for (lcore_id =3D 0; lcore_id < RTE_MAX_LCORE; lcore_id++) { > @@ -2418,6 +2537,16 @@ port_init(uint16_t portid, uint64_t req_rx_offload= s, uint64_t req_tx_offloads) > rte_exit(EXIT_FAILURE, > "rte_eth_rx_queue_setup: err=3D%d, " > "port=3D%d\n", ret, portid); > + > + /* Register Rx callback if ptypes are not supported */ > + if (!ptype_supported && > + !rte_eth_add_rx_callback(portid, queue, > + parse_ptype_cb, NULL)) { > + printf("Failed to add rx callback: port=3D%d, " > + "queue=3D%d\n", portid, queue); > + } > + > + > } > } > printf("\n"); > -- > 2.8.4