From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 97926A0562; Thu, 2 Apr 2020 15:39:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 706A31BE0C; Thu, 2 Apr 2020 15:39:09 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id EB9942C15 for ; Thu, 2 Apr 2020 15:39:07 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 032DZmVm017890; Thu, 2 Apr 2020 06:39:07 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt0818; bh=u/pRf+I6uM/rRIOEmknPKaDMRcHVAVwgyKXWWxqlMqI=; b=FW2KDjtBWa9wVwbOKV6j7sohJtSqTfXkKrRTnKDcOsYH9KNHC2CIuRTmnJ7pKyMyEIbY pm4IXBRSw8Shlu6Y2GFjGTC0JoFuJi8M1mtiPV7E26j1W5PUHZwSA2LR4ZkfddrhzOHo snh7IS9xk91uRZdJIRwH/BdLfTu3KZGHR6ij85wFDIhuMHgtLrlNCsKqtvoJfFAaNEL7 CyeA7Qs3gh0hkVXGck/jb+a2zmOyddUs/x95xBVU+EvzJUki4qwTVEBxQkUJ3WEApwQJ +wkGKfHVyeg7RtJRY27GZixLavEBkoqHgfqaoCP2jcdaVW90bgWOC+MAZ+RaSXgnRL2A 6g== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0a-0016f401.pphosted.com with ESMTP id 304855t1g2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 02 Apr 2020 06:39:06 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 2 Apr 2020 06:39:05 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.106) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Thu, 2 Apr 2020 06:39:05 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X1myhcfL9MzDZrcHzw4GHy3c3pmUtDzZPsXPo4/YJFN2OryDVvInAvXgs7ahSnKZhKKh/WinML+Wjw66DF4BvkbCuWfpqTuRfhajVCklDX3sMG7DkpKFpCEV3hi4DS0GdN6GJqeWd3QZTMWvvKI6QbTl38Mfo/ZDa134HVcKQwxU9mK8M6S2lI3yPprrJponB94hxEnCiGMcF5+ngRv9v40MDuoh8VdQouE+PdX4iEE3gphH+fM5Mo+hYcw/EAahMclDao9StnVvSPFG6q5KLnqN9eRPSAPjeyZCW7/l1hZE9KC0Ntb6Ar3PSTFCW0DqIn9QbZeerGYw6Ell1o1JWA== 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-SenderADCheck; bh=u/pRf+I6uM/rRIOEmknPKaDMRcHVAVwgyKXWWxqlMqI=; b=iAYtfyc3ReukNWvJpi5w2bPogPnK9PBdQVP6PgbL2As64/+sjXVuVuPh461g4JHpR9EqcSjFAgJq7yJTZ0vPrVTWJXapkdC5a9QQY+v2hclcctIWG9g1RxDoGAEdSGcnfpF0x+DW2Q1KyQtSR/ie8/7r5Z184yXoDZsqumMgFb1AdQq93WDlhdOMLFt2pvhMb23b5MwByNMOc/s/BGcvRDlg9q6NT++Msdtp/+10nvAq5WCnu2IdfufGRzqZMS7CqmAth/kgkAo2DPf2U1et5iM43oQKjU1vjEqE65geM0Ga90c4dkq2OuKg26MhpTuLMQxuO8VJkcoLSSKdE/pfpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u/pRf+I6uM/rRIOEmknPKaDMRcHVAVwgyKXWWxqlMqI=; b=tHcouHik5pR5gQWxE/FHiSoi+mSQvEmeUuhmspof6n6NWt2GieKz5hZC6ijjcc0R+Ofp03wOgPEXDzcHHntFwuHoCDf4qm42dF5vxpdJvPisUd1B6K7rXX4UieyXLm2IRVmHUq8Sod5gB6o8IAkr+sxORtHjeLI9I1YNUf9CDC4= Received: from MN2PR18MB2877.namprd18.prod.outlook.com (2603:10b6:208:3b::26) by MN2PR18MB3448.namprd18.prod.outlook.com (2603:10b6:208:266::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.16; Thu, 2 Apr 2020 13:39:03 +0000 Received: from MN2PR18MB2877.namprd18.prod.outlook.com ([fe80::648f:e7fa:f95e:191b]) by MN2PR18MB2877.namprd18.prod.outlook.com ([fe80::648f:e7fa:f95e:191b%2]) with mapi id 15.20.2878.016; Thu, 2 Apr 2020 13:39:03 +0000 From: Anoob Joseph To: Praveen Shetty , "dev@dpdk.org" , "declan.doherty@intel.com" CC: "bernard.iremonger@intel.com" , "konstantin.ananyev@intel.com" Thread-Topic: [EXT] [PATCH v3] examples/ipsec-secgw: support flow director feature Thread-Index: AQHWB1yomOe+1JBZ9km8ZL+21y33gqhlzcFQ Date: Thu, 2 Apr 2020 13:39:03 +0000 Message-ID: References: <20200319162145.28906-1-praveen.shetty@intel.com> <20200331130211.24761-1-praveen.shetty@intel.com> In-Reply-To: <20200331130211.24761-1-praveen.shetty@intel.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [27.34.244.203] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d3113a54-cafe-4cd9-2dcb-08d7d70b357f x-ms-traffictypediagnostic: MN2PR18MB3448: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1824; x-forefront-prvs: 0361212EA8 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR18MB2877.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(346002)(376002)(39860400002)(136003)(366004)(396003)(9686003)(86362001)(30864003)(316002)(5660300002)(54906003)(81166006)(8676002)(55016002)(8936002)(81156014)(52536014)(110136005)(26005)(2906002)(6506007)(53546011)(478600001)(33656002)(4326008)(186003)(64756008)(71200400001)(76116006)(7696005)(66476007)(66446008)(66946007)(66556008); DIR:OUT; SFP:1101; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: N+nc/FFJBW1AVAKBXfW3t1QrauScCUQwa8HzXu5j7hev3QGq/jrxDQy71ArdSbj3m29Slo1vBDttOtHgmVWJu4sTZJVMXB1lMpIxaqzFWRJxC3McaoUidOdnpbsZQq23flAF6B5ApAXXdJADzm4HYH7hrHN3iMCtFeyDYxpSGx2quw1/KnfWc4j5+kk4UVDjKrEdeJsnNzUcT9zhXmpmv5uJFV3OVwVQ9o+I1tuiZwn7+MBBz2oIRa8ncJnSDllMMLbgyqqoIlehdcjrDDiYBqRMQGNgVh7sZQhYUxkwQUHM8+Xl+4I+k4kZpnsVxW6b2MafJ75VziIHbAr9uGC5gy0sP28kFG36KBcgMRq69vza+1/xvsNm8PXfXBPCVhUFiV3FSC6XN2qDuGzotRAlg0+pEw01tzf7V5jjsdS/WeE8EJMjI+AUUWn58hnFxCYm x-ms-exchange-antispam-messagedata: XnTmflQSC5ONdoGomth/5FlyvyyWRWRdxE5/OKUKTYHX+CNta56l3/rgwKv/TuA/s4HPr30LyLBiYaUfhh8kdldhsOGWtMxisx/ReZ7Y5MhKiK3zqd5UoRLQyUzHY/Wfdett3J6GKXTmlBo7KcJFgg== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: d3113a54-cafe-4cd9-2dcb-08d7d70b357f X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Apr 2020 13:39:03.7394 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: VsrZffMSeS7C5e9hKtp8nSXuUBWbtONkNKap2kdZZmgus4cT/A2rSM7F+ysOBziY1ZxVw+9w2jzN1zlgA/7+rA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB3448 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-02_05:2020-03-31, 2020-04-02 signatures=0 Subject: Re: [dpdk-dev] [EXT] [PATCH v3] examples/ipsec-secgw: support flow director feature 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Praveen, I've few minor comments. Please see inline. Thanks, Anoob > -----Original Message----- > From: Praveen Shetty > Sent: Tuesday, March 31, 2020 6:32 PM > To: dev@dpdk.org; declan.doherty@intel.com; Anoob Joseph > > Cc: bernard.iremonger@intel.com; konstantin.ananyev@intel.com > Subject: [EXT] [PATCH v3] examples/ipsec-secgw: support flow director fea= ture >=20 > External Email >=20 > ---------------------------------------------------------------------- > Support load distribution in security gateway application using NIC load > distribution feature(Flow Director). > Flow Director is used to redirect the specified inbound ipsec flow to a s= pecified > queue.This is achieved by extending the SA rule syntax to support specifi= cation > by adding new action_type of to a specified > . >=20 > Signed-off-by: Praveen Shetty > --- > v3 changes: > Incorporated Anoob review comments on v2. >=20 > examples/ipsec-secgw/ep0.cfg | 11 +++++ > examples/ipsec-secgw/ipsec-secgw.c | 55 +++++++++++++++++++++++ > examples/ipsec-secgw/ipsec.c | 67 +++++++++++++++++++++++++++ > examples/ipsec-secgw/ipsec.h | 9 ++++ > examples/ipsec-secgw/sa.c | 72 ++++++++++++++++++++++++++++-- > 5 files changed, 211 insertions(+), 3 deletions(-) >=20 > diff --git a/examples/ipsec-secgw/ep0.cfg b/examples/ipsec-secgw/ep0.cfg > index dfd4aca7d..6f8d5aa53 100644 > --- a/examples/ipsec-secgw/ep0.cfg > +++ b/examples/ipsec-secgw/ep0.cfg > @@ -29,6 +29,7 @@ sp ipv4 in esp protect 111 pri 1 dst 192.168.186.0/24 s= port > 0:65535 dport 0:6553 sp ipv4 in esp protect 115 pri 1 dst 192.168.210.0/= 24 sport > 0:65535 dport 0:65535 sp ipv4 in esp protect 116 pri 1 dst 192.168.211.0= /24 > sport 0:65535 dport 0:65535 sp ipv4 in esp protect 115 pri 1 dst > 192.168.210.0/24 sport 0:65535 dport 0:65535 > +sp ipv4 in esp protect 117 pri 1 dst 192.168.212.0/24 sport 0:65535 > +dport 0:65535 > sp ipv4 in esp protect 125 pri 1 dst 192.168.65.0/24 sport 0:65535 dport= 0:65535 > sp ipv4 in esp protect 125 pri 1 dst 192.168.65.0/24 sport 0:65535 dport = 0:65535 > sp ipv4 in esp protect 126 pri 1 dst 192.168.66.0/24 sport 0:65535 dport = 0:65535 > @@ -61,6 +62,8 @@ sp ipv6 in esp protect 125 pri 1 dst > ffff:0000:0000:0000:aaaa:aaaa:0000:0000/96 > sport 0:65535 dport 0:65535 > sp ipv6 in esp protect 126 pri 1 dst > ffff:0000:0000:0000:bbbb:bbbb:0000:0000/96 \ sport 0:65535 dport 0:65535 > +sp ipv6 in esp protect 127 pri 1 dst > +ffff:0000:0000:0000:cccc:dddd:0000:0000/96 \ sport 0:65535 dport > +0:65535 >=20 > #SA rules > sa out 5 cipher_algo aes-128-cbc cipher_key 0:0:0:0:0:0:0:0:0:0:0:0:0:0:= 0:0 \ > @@ -118,6 +121,9 @@ dst 172.16.1.5 >=20 > sa in 116 cipher_algo null auth_algo null mode ipv4-tunnel src 172.16.2.= 6 dst > 172.16.1.6 >=20 > +sa in 117 cipher_algo null auth_algo null mode ipv4-tunnel src > +172.16.2.7 \ dst 172.16.1.7 flow-direction 0 2 > + > sa in 125 cipher_algo aes-128-cbc cipher_key c3:c3:c3:c3:c3:c3:c3:c3:c3:= c3:c3:\ > c3:c3:c3:c3:c3 auth_algo sha1-hmac auth_key > c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:\ > c3:c3:c3:c3:c3:c3:c3:c3:c3 mode ipv6-tunnel \ @@ -130,6 +136,11 @@ sa in > 126 cipher_algo aes-128-cbc cipher_key 4d:4d:4d:4d:4d:4d:4d:4d:4d:4d:4d:\ > src 2222:2222:2222:2222:2222:2222:2222:6666 \ dst > 1111:1111:1111:1111:1111:1111:1111:6666 >=20 > +sa in 127 cipher_algo null auth_algo null mode ipv6-tunnel \ src > +2222:2222:2222:2222:2222:2222:2222:7777 \ dst > +1111:1111:1111:1111:1111:1111:1111:7777 \ flow-direction 0 3 > + > #Routing rules > rt ipv4 dst 172.16.2.5/32 port 0 > rt ipv4 dst 172.16.2.6/32 port 1 > diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec- > secgw/ipsec-secgw.c > index ce36e6d9c..4400b075c 100644 > --- a/examples/ipsec-secgw/ipsec-secgw.c > +++ b/examples/ipsec-secgw/ipsec-secgw.c > @@ -246,6 +246,30 @@ static struct rte_eth_conf port_conf =3D { > .txmode =3D { > .mq_mode =3D ETH_MQ_TX_NONE, > }, > + .fdir_conf =3D { > + .mode =3D RTE_FDIR_MODE_NONE, > + .pballoc =3D RTE_FDIR_PBALLOC_64K, > + .status =3D RTE_FDIR_REPORT_STATUS, > + .mask =3D { > + .vlan_tci_mask =3D 0xFFEF, > + .ipv4_mask =3D { > + .src_ip =3D 0xFFFFFFFF, > + .dst_ip =3D 0xFFFFFFFF, > + }, > + .ipv6_mask =3D { > + .src_ip =3D {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, > + 0xFFFFFFFF}, > + .dst_ip =3D {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, > + 0xFFFFFFFF}, > + }, > + .src_port_mask =3D 0xFFFF, > + .dst_port_mask =3D 0xFFFF, > + .mac_addr_byte_mask =3D 0xFF, > + .tunnel_type_mask =3D 1, > + .tunnel_id_mask =3D 0xFFFFFFFF, > + }, > + .drop_queue =3D 127, > + } > }; >=20 > struct socket_ctx socket_ctx[NB_SOCKETS]; @@ -1183,6 +1207,28 @@ > ipsec_poll_mode_worker(void) > } > } >=20 > +int > +check_flow_params(uint16_t fdir_portid, uint8_t fdir_qid) { > + uint16_t i; > + uint16_t portid; > + uint8_t queueid; > + > + for (i =3D 0; i < nb_lcore_params; ++i) { > + portid =3D lcore_params_array[i].port_id; > + if (portid =3D=3D fdir_portid) { > + queueid =3D lcore_params_array[i].queue_id; > + if (queueid =3D=3D fdir_qid) > + break; > + } > + > + if (i =3D=3D nb_lcore_params - 1) > + return -1; > + } > + > + return 1; > +} > + > static int32_t > check_poll_mode_params(struct eh_conf *eh_conf) { @@ -2813,6 +2859,15 > @@ main(int32_t argc, char **argv) >=20 > sa_check_offloads(portid, &req_rx_offloads[portid], > &req_tx_offloads[portid]); > + /* check if FDIR is configured on the port */ > + if (check_fdir_configured(portid)) { > + /* Enable FDIR */ > + port_conf.fdir_conf.mode =3D > RTE_FDIR_MODE_PERFECT; > + /* Disable RSS */ > + port_conf.rxmode.mq_mode =3D ETH_MQ_RX_NONE; > + port_conf.rx_adv_conf.rss_conf.rss_hf =3D 0; > + port_conf.rx_adv_conf.rss_conf.rss_key =3D NULL; > + } > port_init(portid, req_rx_offloads[portid], > req_tx_offloads[portid]); > } > diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c = index > d40657102..76ee9dbcf 100644 > --- a/examples/ipsec-secgw/ipsec.c > +++ b/examples/ipsec-secgw/ipsec.c > @@ -418,6 +418,73 @@ create_inline_session(struct socket_ctx *skt_ctx, > struct ipsec_sa *sa, > return 0; > } >=20 > +int > +create_ipsec_esp_flow(struct ipsec_sa *sa) { > + int ret =3D 0; > + struct rte_flow_error err; > + if (sa->direction =3D=3D RTE_SECURITY_IPSEC_SA_DIR_EGRESS) > + return 0; /* No Flow director rules for Egress traffic */ [Anoob] Any reason why this is not relevant for Egress.=20 As for the code I would suggest something like, /* No flow director rules for Egress traffic */ if (sa->direction =3D=3D RTE_SECURITY_IPSEC_SA_DIR_EGRESS) return 0; ... =20 > + if (sa->flags =3D=3D TRANSPORT) { > + RTE_LOG(ERR, IPSEC, > + "No Flow director rule for transport mode:"); [Anoob] Is the ending : required in the line above? And do might need a \n? Also, why is one case returning 0 (EGRESS) and another (TRANSPORT) is retur= ning -1? One is treated as error and other is not? =20 > + return -1; > + } > + sa->action[0].type =3D RTE_FLOW_ACTION_TYPE_QUEUE; > + sa->pattern[0].type =3D RTE_FLOW_ITEM_TYPE_ETH; > + sa->action[0].conf =3D > + &(struct rte_flow_action_queue){ > + .index =3D sa->fdir_qid, > + }; > + sa->attr.egress =3D 0; > + sa->attr.ingress =3D 1; > + if (IS_IP6(sa->flags)) { > + sa->pattern[1].mask =3D &rte_flow_item_ipv6_mask; > + sa->pattern[1].type =3D RTE_FLOW_ITEM_TYPE_IPV6; > + sa->pattern[1].spec =3D &sa->ipv6_spec; > + memcpy(sa->ipv6_spec.hdr.dst_addr, > + sa->dst.ip.ip6.ip6_b, sizeof(sa->dst.ip.ip6.ip6_b)); > + memcpy(sa->ipv6_spec.hdr.src_addr, > + sa->src.ip.ip6.ip6_b, sizeof(sa->src.ip.ip6.ip6_b)); > + sa->pattern[2].type =3D RTE_FLOW_ITEM_TYPE_ESP; > + sa->pattern[2].spec =3D &sa->esp_spec; > + sa->pattern[2].mask =3D &rte_flow_item_esp_mask; > + sa->esp_spec.hdr.spi =3D rte_cpu_to_be_32(sa->spi); > + sa->pattern[3].type =3D RTE_FLOW_ITEM_TYPE_END; > + } else if (IS_IP4(sa->flags)) { > + sa->pattern[1].mask =3D &rte_flow_item_ipv4_mask; > + sa->pattern[1].type =3D RTE_FLOW_ITEM_TYPE_IPV4; > + sa->pattern[1].spec =3D &sa->ipv4_spec; > + sa->ipv4_spec.hdr.dst_addr =3D sa->dst.ip.ip4; > + sa->ipv4_spec.hdr.src_addr =3D sa->src.ip.ip4; > + sa->pattern[2].type =3D RTE_FLOW_ITEM_TYPE_ESP; > + sa->pattern[2].spec =3D &sa->esp_spec; > + sa->pattern[2].mask =3D &rte_flow_item_esp_mask; > + sa->esp_spec.hdr.spi =3D rte_cpu_to_be_32(sa->spi); > + sa->pattern[3].type =3D RTE_FLOW_ITEM_TYPE_END; > + } > + sa->action[1].type =3D RTE_FLOW_ACTION_TYPE_END; > + > + ret =3D rte_flow_validate(sa->portid, &sa->attr, > + sa->pattern, sa->action, > + &err); > + if (ret < 0) { > + RTE_LOG(ERR, IPSEC, > + "Flow Validation failed\n"); [Anoob] The above should fit into one line. Also V should be small. =20 > + return ret; > + } > + sa->flow =3D rte_flow_create(sa->portid, > + &sa->attr, sa->pattern, sa->action, > + &err); [Anoob] Start breaking into multiple lines when you exceed 80 char limits. = In the earlier line, &sa->attr should fit into the line above. Also, having a blank line above rte_flow_create() line would be good. =20 > + if (!sa->flow) { > + RTE_LOG(ERR, IPSEC, > + "Flow Creation failed\n"); [Anoob] Above should fit into one line. Also C should be small. > + return -1; > + } > + > + return 0; > +} > + > /* > * queue crypto-ops into PMD queue. > */ > diff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h > index f8f29f9b1..b0e9f45cb 100644 > --- a/examples/ipsec-secgw/ipsec.h > +++ b/examples/ipsec-secgw/ipsec.h > @@ -144,6 +144,8 @@ struct ipsec_sa { > }; > enum rte_security_ipsec_sa_direction direction; > uint16_t portid; > + uint8_t fdir_qid; > + uint8_t fdir_flag; >=20 > #define MAX_RTE_FLOW_PATTERN (4) > #define MAX_RTE_FLOW_ACTIONS (3) > @@ -408,5 +410,12 @@ create_lookaside_session(struct ipsec_ctx *ipsec_ctx= , > struct ipsec_sa *sa, int create_inline_session(struct socket_ctx *skt_c= tx, struct > ipsec_sa *sa, > struct rte_ipsec_session *ips); > +int > +check_flow_params(uint16_t fdir_portid, uint8_t fdir_qid); > + > +int > +create_ipsec_esp_flow(struct ipsec_sa *sa); >=20 > +int > +check_fdir_configured(uint16_t portid); > #endif /* __IPSEC_H__ */ > diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c index > 0eb52d141..ddd275142 100644 > --- a/examples/ipsec-secgw/sa.c > +++ b/examples/ipsec-secgw/sa.c > @@ -271,6 +271,7 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens, > uint32_t type_p =3D 0; > uint32_t portid_p =3D 0; > uint32_t fallback_p =3D 0; > + int16_t status_p =3D 0; >=20 > if (strcmp(tokens[0], "in") =3D=3D 0) { > ri =3D &nb_sa_in; > @@ -295,6 +296,7 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens, > if (atoi(tokens[1]) =3D=3D INVALID_SPI) > return; > rule->spi =3D atoi(tokens[1]); > + rule->portid =3D UINT16_MAX; > ips =3D ipsec_get_primary_session(rule); >=20 > for (ti =3D 2; ti < n_tokens; ti++) { > @@ -636,9 +638,14 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens, > INCREMENT_TOKEN_INDEX(ti, n_tokens, status); > if (status->status < 0) > return; > - rule->portid =3D atoi(tokens[ti]); > - if (status->status < 0) > + if (rule->portid =3D=3D UINT16_MAX) > + rule->portid =3D atoi(tokens[ti]); > + else if (rule->portid !=3D atoi(tokens[ti])) { > + APP_CHECK(0, status, "portid %s " > + "not matching with already assigned portid > %u", > + tokens[ti], rule->portid); > return; [Anoob] Alignment for APP_CHECK's broken up parts are not following the con= vention. > + } > portid_p =3D 1; > continue; > } > @@ -681,6 +688,43 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens, > fallback_p =3D 1; > continue; > } > + if (strcmp(tokens[ti], "flow-direction") =3D=3D 0) { > + if (ips->type =3D=3D > + > RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL || > + ips->type =3D=3D > + > RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL || > + ips->type =3D=3D > + > RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) { > + APP_CHECK(0, status, "Flow Director not " > + "supported for security session " > + "type:%d", ips->type); > + return; > + } > + rule->fdir_flag =3D 1; > + INCREMENT_TOKEN_INDEX(ti, n_tokens, status); > + if (status->status < 0) > + return; > + if (rule->portid =3D=3D UINT16_MAX) > + rule->portid =3D atoi(tokens[ti]); > + else if (rule->portid !=3D atoi(tokens[ti])) { > + APP_CHECK(0, status, "portid %s " > + "not matching with already assigned portid > %u", > + tokens[ti], rule->portid); > + return; > + } > + INCREMENT_TOKEN_INDEX(ti, n_tokens, status); > + if (status->status < 0) > + return; > + rule->fdir_qid =3D atoi(tokens[ti]); > + /* validating portid and queueid */ > + status_p =3D check_flow_params(rule->portid, > + rule->fdir_qid); > + if (status_p < 0) { > + printf("port id %u / queue id %u is not valid\n", > + rule->portid, rule->fdir_qid); > + } > + continue; > + } >=20 > /* unrecognizeable input */ > APP_CHECK(0, status, "unrecognized input \"%s\"", @@ -719,7 > +763,6 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens, > if (!type_p || (!portid_p && ips->type !=3D > RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)) { > ips->type =3D RTE_SECURITY_ACTION_TYPE_NONE; > - rule->portid =3D -1; > } >=20 > *ri =3D *ri + 1; > @@ -823,6 +866,9 @@ print_one_sa_rule(const struct ipsec_sa *sa, int > inbound) > break; > } > } > + if (sa->fdir_flag =3D=3D 1) > + printf("flow-direction %d %d", sa->portid, sa->fdir_qid); > + > printf("\n"); > } >=20 > @@ -1141,6 +1187,12 @@ sa_add_rules(struct sa_ctx *sa_ctx, const struct > ipsec_sa entries[], > } > } >=20 > + if (sa->fdir_flag && inbound) { > + rc =3D create_ipsec_esp_flow(sa); > + if (rc !=3D 0) > + RTE_LOG(ERR, IPSEC_ESP, > + "create_ipsec_esp flow failed\n"); [Anoob] Instead of function name, can you give the description of what actu= ally failed? > + } > print_one_sa_rule(sa, inbound); > } >=20 > @@ -1243,6 +1295,20 @@ fill_ipsec_session(struct rte_ipsec_session *ss, s= truct > rte_ipsec_sa *sa) > return rc; > } >=20 > +int > +check_fdir_configured(uint16_t portid) > +{ > + struct ipsec_sa *sa =3D NULL; > + uint32_t idx_sa =3D 0; > + > + for (idx_sa =3D 0; idx_sa < nb_sa_in; idx_sa++) { > + sa =3D &sa_in[idx_sa]; > + if (sa->portid =3D=3D portid) > + return sa->fdir_flag; > + } > + return 0; > +} > + > /* > * Initialise related rte_ipsec_sa object. > */ > -- > 2.17.1