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 CC9BDA00C4; Fri, 5 Aug 2022 05:26:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6CADB4067C; Fri, 5 Aug 2022 05:26:19 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2065.outbound.protection.outlook.com [40.107.93.65]) by mails.dpdk.org (Postfix) with ESMTP id 957DD400D5 for ; Fri, 5 Aug 2022 05:26:17 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B3KCz9bVGWQ8gaKdszmbSlhDfpuow1qYXgk3zr161WxzpN/6RrkQWGaaMSNn4LpE8I3gg5TbC4FN32SibetKyIYbzzCw32f1i1+9IGTB5WfaY9E+D+/dYVVemeWxARdkXr9z4DD+sHVRcEf7QlSLoiTyof8Wjc6SRz6UZ9MNIi4AwJozE+Xyji+O6KZqBbMG8DsPkTrYrxu0uiuDvyzNRQZ7VheDkClm0dJ9gD7h1OVyUvcNbF3U8gp6M+JM4ExAXlkdjMXJGwnKc3L8KHEWICGTGZBZG11XKLTVk5AWXTLJpLiRALJzFeGMcI6KWMRoTrgBa5ksoJAS+Rc/WCsT8Q== 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=kEFTrcFTxohiiyoOs3XObqVedvL+ZvYhZrF4IuMVbHA=; b=cfjfTMECrrwUpPqXnI50H+VDZltZV5WyJBHGZcp+25PFj0bd8cRY/UHEiD8kVaC0XhZ1YvTUXe6EmhgwXlOvRWzqslLWS9sw4m1izyyahifdVyt63amdYnVBoR+P0X7DOMj3AcbcSchv/UitefjvjUOUkoE47ZK6L4q1hsGENVkUHx8qt6R6GedMYbToiunYP1PALb+DytdcX3OeL4yj/J8779ramU/rvAxN08W9BLDpGQ5e9kwwPD9470CIkipAe3QQT+Gf2x3P0TVAxhqyWA8QeJdaXrdwn4cj0mCNRBt4KEd8xI6ZmlZ21iZJSH86/Hscc7IvxuPFehi03HzHfg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kEFTrcFTxohiiyoOs3XObqVedvL+ZvYhZrF4IuMVbHA=; b=LkRsfE/vJ+pr2ec2+HUCH0flpFC/TKeStNWZcjF6uOSZczUNabN0n8UNW2B+TBjtDJM8XS6x36kQIBNx4ManAPuNJGTLEnPAvC/YRFFhGMAGkgpM2G7RHCilPSnQstDimXxBVqjyuoursOrpzvAd/bWR6MosyyHWEcDqPC2nIYBQ7oWZRmnZMUFWgmatZ8flVdsxrmLN8Yhti4oUPos/IpxUvLTkQN+E1UhcKJ0t4FN5Ronc/Tkt/LBInFM1M/psH5qhVpComi7VUevapzwy5205NhLnpeQB4ZucAYq6ztSVnY4rn7ax5ksBWDs/8rfmgm/kuJ1JIsVDrD2ndo5wpQ== Received: from CO6PR12MB5396.namprd12.prod.outlook.com (2603:10b6:303:139::8) by BN6PR12MB1923.namprd12.prod.outlook.com (2603:10b6:404:107::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.15; Fri, 5 Aug 2022 03:26:15 +0000 Received: from CO6PR12MB5396.namprd12.prod.outlook.com ([fe80::718a:265e:d776:e7e1]) by CO6PR12MB5396.namprd12.prod.outlook.com ([fe80::718a:265e:d776:e7e1%9]) with mapi id 15.20.5504.016; Fri, 5 Aug 2022 03:26:15 +0000 From: Suanming Mou To: Volodymyr Fialko , "dev@dpdk.org" , Radu Nicolau , Akhil Goyal CC: "jerinj@marvell.com" , "anoobj@marvell.com" Subject: RE: [PATCH 3/6] examples/ipsec-secgw: add lookaside event mode Thread-Topic: [PATCH 3/6] examples/ipsec-secgw: add lookaside event mode Thread-Index: AQHYp+4iOMXd9OB2hUaVN2ATE3rNjq2fpNqg Date: Fri, 5 Aug 2022 03:26:14 +0000 Message-ID: References: <20220804103626.102688-1-vfialko@marvell.com> <20220804103626.102688-4-vfialko@marvell.com> In-Reply-To: <20220804103626.102688-4-vfialko@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: bf7c2302-7d59-4436-9bbe-08da769240ba x-ms-traffictypediagnostic: BN6PR12MB1923:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: v1baXQSStutmDTf7Fr/1Z5mI5nD0zJXrEi73hb0b72C6KBwObcVzI6yAdJCLp8r7uBBzUU3yE9fLgjCUT53NXen1UCYNDjXBKPFGBRcIbfyQOoiaxxxSG+ed3pawiAEDx61+e+aqSCck/KbmyMsO7Wr5xrMWAsyzOkOGcxG+IJhvtWGYUU+fElb045nuggcXl4ukpfFZXPhN/UevStLfdhncpnX7HA2gm8W6fTHqUy+fX0zSzg4PQd/4v+xe0/18oBkD12FqLOQXJiI9cadHOtEEAlyKETPIEyneL98qfq/gCEbgCelFMDMlnGGvlqblguxSh7uKoV65xb321LaYQZTDGL/81hIRWPyEnQoeNdr9ZU4fDJKMGb1NHF5yk0Z0KBsrVZvbfyDrZH3syRCRM6IaU4/4RlxuH3sp8RN7rqnMrkrM6wJCv5Bmsl3JPRrJTCnQVjTrfM9YWAkuucBQPKaqaYU4RRTr+xlKFiKEKm+zGb7yaXDS5n3OLAY/5cSXduaJwR8WaBmXGW0MuDTFKaqNrBD0fePQ6J+x57pblYHr5xSS/0YMaeyLWDG5UHyAMHq29Q8qH2G4ZoQeMsWY+p/UoVIqbirBYX0HAuwBlh7zzp/tGhDmNh6Y+uzPxCQRvth8yoh+9bFPuAKJNqFs7GgKd//mu0wY80RK3qabG54a33OQ4dn7KJJNeBcEm7LJvIZH7L9j8er7a+BaAgP9t4wym3Dz9PS/F0EPF3EVXWn0BX5ypkapz1X1MqFzulPQz2yynVrnC1wXR+FGZ5ZsLpzW98KDWdtidFUcB7O7+FZBvdxA7X9+Elzrb+pLQKWR x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR12MB5396.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(366004)(396003)(346002)(136003)(376002)(39860400002)(316002)(186003)(83380400001)(55016003)(86362001)(2906002)(33656002)(38100700002)(64756008)(66446008)(66476007)(76116006)(66946007)(8676002)(4326008)(122000001)(38070700005)(52536014)(8936002)(5660300002)(26005)(9686003)(41300700001)(478600001)(71200400001)(66556008)(53546011)(54906003)(110136005)(7696005)(6506007); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Hcx11gCzAULwlWaIScuuj82Zfijpo26aVyi4Mr8rgWrXXAA0Ri6VQ3k3nkzu?= =?us-ascii?Q?xoZ+oFUPKyalc6dRSL9VCmNUa1mfTmaEBm6stZyWnQRChRToIz0ViIcePwxL?= =?us-ascii?Q?JaVoJhPv5oCdlz/FhmrsCda4mwcaYXgcQ2BqmGNSm2ot9pdWJBn8b1fVGh9P?= =?us-ascii?Q?zsXUizmB0mfwkf+dasjYcAQ1SBq60+dCW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= =?us-ascii?Q?Tot5GARi/wz/lBAqh6BIoCtW1v+hc0iF41+hTvuWFHstJHMW+R5wD3piWwF1?= =?us-ascii?Q?nJRZYfA/Dx2jgbc4HYkhEcgRCe0Jg72uP8olxQsPBogbhr05YzQDVFvMNpY2?= =?us-ascii?Q?zBfkYKPoolQEhrKUfgLsVelAiR5BINnHKpuYR/c7q4/5CHPPeVWIVW+VFkRg?= =?us-ascii?Q?rcc/AIUX5jK2khrsFVhGxU14uuV55lYI1SwZI3YMpU84DLTF3urhoxusJXbj?= =?us-ascii?Q?J4O04zwzlbiA8ohjQnVb45fIZ6fqF16eYC6EF3KYzWwoTwmpEUMh6fmOtjt7?= =?us-ascii?Q?F858vKEWkUzsNCt2LyXSHVV9D6bXOjKFCqB8+NHeuHal9geMfnFZE0bHpms0?= =?us-ascii?Q?6vI/QSRtbtWjQDt/aA5dL3KQ7i8RtUnN5xlsLl4qDKCaspVs2NSWFo4W9pU+?= =?us-ascii?Q?cbU7x7sd1V74P2hHROasDoS0EHF4udKInxBtoo6MAa9oQL+RfUlW+hXZQM5d?= =?us-ascii?Q?YoS5aRSduEsq6sXnxTv7gjdvC2q7TiqyyDpfaiEJ?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO6PR12MB5396.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bf7c2302-7d59-4436-9bbe-08da769240ba X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Aug 2022 03:26:14.8995 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: DcHm8yy7zZyiUIb0u6QhD9FPgEJDzBgPKaAR3ZxgpAvptRUdedMiyezVHBJXz0Becfrk0KSvBcozICP2Z0Q0XQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1923 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 Hi, > -----Original Message----- > From: Volodymyr Fialko > Sent: Thursday, August 4, 2022 6:36 PM > To: dev@dpdk.org; Radu Nicolau ; Akhil Goyal > > Cc: jerinj@marvell.com; anoobj@marvell.com; Volodymyr Fialko > > Subject: [PATCH 3/6] examples/ipsec-secgw: add lookaside event mode >=20 > Add base support for lookaside event mode. Events that are coming from et= hdev > will be enqueued to the event crypto adapter, processed and enqueued back= to > ethdev for the transmission. >=20 > Signed-off-by: Volodymyr Fialko > --- > doc/guides/sample_app_ug/ipsec_secgw.rst | 4 +- > examples/ipsec-secgw/ipsec-secgw.c | 3 +- > examples/ipsec-secgw/ipsec.c | 35 +++- > examples/ipsec-secgw/ipsec.h | 8 +- > examples/ipsec-secgw/ipsec_worker.c | 224 +++++++++++++++++++++-- > examples/ipsec-secgw/sa.c | 23 ++- > 6 files changed, 262 insertions(+), 35 deletions(-) >=20 snip > create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, d= iff --git > a/examples/ipsec-secgw/ipsec_worker.c b/examples/ipsec- > secgw/ipsec_worker.c > index 803157d8ee..2661f0275f 100644 > --- a/examples/ipsec-secgw/ipsec_worker.c > +++ b/examples/ipsec-secgw/ipsec_worker.c > @@ -3,6 +3,7 @@ > * Copyright (C) 2020 Marvell International Ltd. > */ > #include > +#include > #include > #include > #include > @@ -11,6 +12,7 @@ > #include "ipsec.h" > #include "ipsec-secgw.h" > #include "ipsec_worker.h" > +#include "sad.h" >=20 > #if defined(__ARM_NEON) > #include "ipsec_lpm_neon.h" > @@ -228,6 +230,43 @@ check_sp_sa_bulk(struct sp_ctx *sp, struct sa_ctx > *sa_ctx, > ip->num =3D j; > } >=20 > +static inline void > +pkt_l3_len_set(struct rte_mbuf *pkt) > +{ > + struct rte_ipv4_hdr *ipv4; > + struct rte_ipv6_hdr *ipv6; > + size_t l3len, ext_len; > + uint32_t l3_type; > + int next_proto; > + uint8_t *p; > + > + l3_type =3D pkt->packet_type & RTE_PTYPE_L3_MASK; > + if (l3_type =3D=3D RTE_PTYPE_L3_IPV4) { > + ipv4 =3D rte_pktmbuf_mtod(pkt, struct rte_ipv4_hdr *); > + pkt->l3_len =3D ipv4->ihl * 4; > + } else if (l3_type & RTE_PTYPE_L3_IPV6) { > + ipv6 =3D rte_pktmbuf_mtod(pkt, struct rte_ipv6_hdr *); > + l3len =3D sizeof(struct rte_ipv6_hdr); > + 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 ipv6->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->l3_len =3D l3len; > + } > +} > + > static inline uint16_t > route4_pkt(struct rte_mbuf *pkt, struct rt_ctx *rt_ctx) { @@ -287,9 +32= 6,67 > @@ get_route(struct rte_mbuf *pkt, struct route_table *rt, enum pkt_type = type) > return RTE_MAX_ETHPORTS; > } >=20 > +static inline void > +crypto_op_reset(const struct rte_ipsec_session *ss, struct rte_mbuf *mb[= ], > + struct rte_crypto_op *cop[], uint16_t num) { > + struct rte_crypto_sym_op *sop; > + uint32_t i; > + > + const struct rte_crypto_op unproc_cop =3D { > + .type =3D RTE_CRYPTO_OP_TYPE_SYMMETRIC, > + .status =3D RTE_CRYPTO_OP_STATUS_NOT_PROCESSED, > + .sess_type =3D RTE_CRYPTO_OP_SECURITY_SESSION, > + }; > + > + for (i =3D 0; i !=3D num; i++) { > + cop[i]->raw =3D unproc_cop.raw; > + sop =3D cop[i]->sym; > + sop->m_src =3D mb[i]; > + sop->m_dst =3D NULL; > + __rte_security_attach_session(sop, ss->security.ses); > + } > +} > + > +static inline int > +event_crypto_enqueue(struct ipsec_ctx *ctx __rte_unused, struct rte_mbuf > *pkt, > + struct ipsec_sa *sa, const struct eh_event_link_info *ev_link) { > + struct ipsec_mbuf_metadata *priv; > + struct rte_ipsec_session *sess; > + struct rte_crypto_op *cop; > + struct rte_event cev; > + int ret; > + > + /* Get IPsec session */ > + sess =3D ipsec_get_primary_session(sa); > + > + /* Get pkt private data */ > + priv =3D get_priv(pkt); > + cop =3D &priv->cop; > + > + /* Reset crypto operation data */ > + crypto_op_reset(sess, &pkt, &cop, 1); > + > + /* Update event_ptr with rte_crypto_op */ > + cev.event =3D 0; > + cev.event_ptr =3D cop; > + > + /* Enqueue event to crypto adapter */ > + ret =3D rte_event_crypto_adapter_enqueue(ev_link->eventdev_id, > + ev_link->event_port_id, &cev, 1); > + if (unlikely(ret <=3D 0)) { > + /* pkt will be freed by the caller */ > + RTE_LOG_DP(DEBUG, IPSEC, "Cannot enqueue event: %i > (errno: %i)\n", ret, rte_errno); > + return rte_errno; > + } > + > + return 0; > +} > + > static inline int > process_ipsec_ev_inbound(struct ipsec_ctx *ctx, struct route_table *rt, > - struct rte_event *ev) > + const struct eh_event_link_info *ev_link, struct rte_event *ev) > { > struct ipsec_sa *sa =3D NULL; > struct rte_mbuf *pkt; > @@ -340,7 +437,22 @@ process_ipsec_ev_inbound(struct ipsec_ctx *ctx, stru= ct > route_table *rt, > goto drop_pkt_and_exit; > } > break; > + case PKT_TYPE_IPSEC_IPV4: > + case PKT_TYPE_IPSEC_IPV6: > + rte_pktmbuf_adj(pkt, RTE_ETHER_HDR_LEN); > + pkt_l3_len_set(pkt); One small question, in case free_pkts() happens inside pkt_l3_len_set(pkt),= can the pkt still be used in sad_lookup() below? Should return value be added to pkt_l3_len_set() in case pkt free? > + > + sad_lookup(&ctx->sa_ctx->sad, &pkt, (void **)&sa, 1); > + sa =3D ipsec_mask_saptr(sa); > + if (unlikely(sa =3D=3D NULL)) { > + RTE_LOG_DP(DEBUG, IPSEC, "Cannot find sa\n"); > + goto drop_pkt_and_exit; > + } >=20 snip