From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 9981614E8 for ; Mon, 11 Dec 2017 16:52:28 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Dec 2017 07:52:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,392,1508828400"; d="scan'208";a="15057997" Received: from irsmsx105.ger.corp.intel.com ([163.33.3.28]) by orsmga001.jf.intel.com with ESMTP; 11 Dec 2017 07:52:26 -0800 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.49]) by irsmsx105.ger.corp.intel.com ([163.33.3.28]) with mapi id 14.03.0319.002; Mon, 11 Dec 2017 15:52:25 +0000 From: "Singh, Jasvinder" To: "Iremonger, Bernard" , "dev@dpdk.org" Thread-Topic: [PATCH 2/3] lib/librte_flow_classy: add run api for flow classification Thread-Index: AQHTbR9izRv//YRNak+Up3Vj7cjRxaM0loQAgAGuOwCACBDQgA== Date: Mon, 11 Dec 2017 15:52:25 +0000 Message-ID: <54CBAA185211B4429112C315DA58FF6D33298A37@IRSMSX103.ger.corp.intel.com> References: <20171123113215.64757-1-jasvinder.singh@intel.com> <20171123113215.64757-2-jasvinder.singh@intel.com> <8CEF83825BEC744B83065625E567D7C24E063FA2@IRSMSX108.ger.corp.intel.com> <8CEF83825BEC744B83065625E567D7C24E06464B@IRSMSX108.ger.corp.intel.com> <8CEF83825BEC744B83065625E567D7C24E064CC8@IRSMSX108.ger.corp.intel.com> In-Reply-To: <8CEF83825BEC744B83065625E567D7C24E064CC8@IRSMSX108.ger.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMTQ4OWZjMmItZWVkZC00YjBjLTlkYjAtZTM2M2JmZTc0NmY5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6ImtvM3VzNzRUUjA5SFwveUE4UFFTY2xiSXFaalQ3RVczeDk5eUpiRVZnUTlJPSJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 2/3] lib/librte_flow_classy: add run api for flow classification 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: , X-List-Received-Date: Mon, 11 Dec 2017 15:52:29 -0000 > -----Original Message----- > From: Iremonger, Bernard > Sent: Wednesday, December 6, 2017 12:41 PM > To: Iremonger, Bernard ; Singh, Jasvinder > ; dev@dpdk.org > Subject: RE: [PATCH 2/3] lib/librte_flow_classy: add run api for flow > classification >=20 > Hi Jasvinder, >=20 > >=20 > > > > -----Original Message----- > > > > From: Singh, Jasvinder > > > > Sent: Thursday, November 23, 2017 11:32 AM > > > > To: dev@dpdk.org > > > > Cc: Iremonger, Bernard > > > > Subject: [PATCH 2/3] lib/librte_flow_classy: add run api for flow > > > > classification > > > > > > > > This patch extends the flow classification library by adding run ap= i. > > > > This function classifies the packets based on the flow rules > > > > stored in the classifier table. > > > > During lookup operation, the table entry is identified on lookup > > > > hit and based on meta-data stored at table entry, actions are > > > > performed on the current packet. > > > > The meta-information about the actions stored in the table entry > > > > is determined from the actions fields specified in flow rules. > > > > > > > > Signed-off-by: Jasvinder Singh > > > > --- > > > > lib/librte_flow_classify/rte_flow_classify.c | 56 > > > > ++++++++++++++++++++++ > > > > lib/librte_flow_classify/rte_flow_classify.h | 24 ++++++++++ > > > > .../rte_flow_classify_version.map | 1 + > > > > 3 files changed, 81 insertions(+) > > > > > > > > diff --git a/lib/librte_flow_classify/rte_flow_classify.c > > > > b/lib/librte_flow_classify/rte_flow_classify.c > > > > index ff1bc86..5433bfe 100644 > > > > --- a/lib/librte_flow_classify/rte_flow_classify.c > > > > +++ b/lib/librte_flow_classify/rte_flow_classify.c > > > > @@ -37,6 +37,9 @@ > > > > #include > > > > #include > > > > > > > > +#define RTE_PKT_METADATA_PTR(pkt, offset) \ > > > > + (&((uint32_t *)(pkt))[offset]) > > > > + > > > > int librte_flow_classify_logtype; > > > > > > > > static uint32_t unique_id =3D 1; > > > > @@ -674,6 +677,59 @@ action_apply(struct rte_flow_classifier *cls, > > > > } > > > > > > > > int > > > > +rte_flow_classifier_run(struct rte_flow_classifier *cls, > > > > + struct rte_mbuf **pkts, > > > > + const uint16_t nb_pkts, > > > > + uint32_t pkt_offset) > > > > +{ > > > > + struct rte_flow_action_mark *mark; > > > > + struct classify_action *action; > > > > + uint64_t pkts_mask =3D RTE_LEN2MASK(nb_pkts, uint64_t); > > > > + uint64_t action_mask; > > > > + uint32_t *ptr, i, j; > > > > + int ret =3D -EINVAL; > > > > + > > > > + if (!cls || !pkts || nb_pkts =3D=3D 0) > > > > + return ret; > > > > + > > > > + for (i =3D 0; i < cls->num_tables; i++) { > > > > + if (cls->table_mask & (1LU << i)) { > > > > + struct rte_cls_table *table =3D &cls->tables[i]; > > > > + uint64_t lookup_hit_mask; > > > > + > > > > + ret =3D table->ops.f_lookup(table->h_table, > > > > + pkts, pkts_mask, &lookup_hit_mask, > > > > + (void **)cls->entries); > > > > + if (ret) > > > > + return ret; > > > > + > > > > + if (lookup_hit_mask) { > > > > + for (j =3D 0; j < nb_pkts; j++) { > > > > + uint64_t pkt_mask =3D 1LLU << j; > > > > + > > > > + if ((lookup_hit_mask & pkt_mask) =3D=3D > > > > 0) > > > > + continue; > > > > + /* Meta-data */ > > > > + enum rte_flow_action_type act_type > > > > =3D > > > > + > > > > RTE_FLOW_ACTION_TYPE_MARK; > > > > + action =3D &cls->entries[j]->action; > > > > + action_mask =3D action->action_mask; > > > > + > > > > + if (action_mask & (1LLU << act_type)) > > > > { > > > > + mark =3D &action->act.mark; > > > > + ptr =3D > > > > RTE_PKT_METADATA_PTR( > > > > + pkts[j], pkt_offset); > > > > + *ptr =3D mark->id; > > > > + } > > > > + } > > > > + } > > > > + } > > > > + } > > > > + > > > > + return 0; > > > > +} > > > > + > > > > +int > > > > rte_flow_classifier_query(struct rte_flow_classifier *cls, > > > > struct rte_mbuf **pkts, > > > > const uint16_t nb_pkts, > > > > diff --git a/lib/librte_flow_classify/rte_flow_classify.h > > > > b/lib/librte_flow_classify/rte_flow_classify.h > > > > index b9b669f..b74bd11 100644 > > > > --- a/lib/librte_flow_classify/rte_flow_classify.h > > > > +++ b/lib/librte_flow_classify/rte_flow_classify.h > > > > @@ -273,6 +273,30 @@ rte_flow_classify_table_entry_delete(struct > > > > rte_flow_classifier *cls, > > > > struct rte_flow_classify_rule *rule); > > > > > > > > /** > > > > + * Flow classifier run. > > > > + * > > > > + * As a result of lookup operation, flow classifer idenfies the > > > > + * table entries that are hit and executes the actions on the pack= ets. > > > > + * > > > > + * @param[in] cls > > > > + * Flow classifier handle > > > > + * @param[in] pkts > > > > + * Pointer to packets to process > > > > + * @param[in] nb_pkts > > > > + * Number of packets to process > > > > + * @param[in] pkt_offset > > > > + * Offset to store action metadata in the mbuf headroom > > > > + * > > > > + * @return > > > > + * 0 on success, error code otherwise. > > > > + */ > > > > +int > > > > +rte_flow_classifier_run(struct rte_flow_classifier *cls, > > > > + struct rte_mbuf **pkts, > > > > + const uint16_t nb_pkts, > > > > + uint32_t pkt_offset); > > > > + > > > > +/** > > > > * Query flow classifier for given rule. > > > > * > > > > * @param[in] cls > > > > diff --git > > > > a/lib/librte_flow_classify/rte_flow_classify_version.map > > > > b/lib/librte_flow_classify/rte_flow_classify_version.map > > > > index 49bc25c..b51cb1a 100644 > > > > --- a/lib/librte_flow_classify/rte_flow_classify_version.map > > > > +++ b/lib/librte_flow_classify/rte_flow_classify_version.map > > > > @@ -4,6 +4,7 @@ EXPERIMENTAL { > > > > rte_flow_classifier_create; > > > > rte_flow_classifier_free; > > > > rte_flow_classifier_query; > > > > + rte_flow_classifier_run; > > > > rte_flow_classify_table_create; > > > > rte_flow_classify_table_entry_add; > > > > rte_flow_classify_table_entry_delete; > > > > -- > > > > 2.9.3 > > > > >=20 > Tests should be added to test_flow_classify.c for the > rte_flow_classifier_run() API. > The flow_classify sample application should exercise the > rte_flow_classifier_run() API. Ok, will do in v2. Jasvinder