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 82E5C1094 for ; Mon, 2 Jan 2017 11:41:36 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 02 Jan 2017 02:41:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,432,1477983600"; d="scan'208";a="918091777" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga003.jf.intel.com with ESMTP; 02 Jan 2017 02:41:35 -0800 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 2 Jan 2017 02:41:34 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 2 Jan 2017 02:41:34 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.177]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.204]) with mapi id 14.03.0248.002; Mon, 2 Jan 2017 18:41:30 +0800 From: "Xing, Beilei" To: "Zhao1, Wei" , "dev@dpdk.org" CC: "Zhao1, Wei" , "Lu, Wenzhuo" Thread-Topic: [dpdk-dev] [PATCH v2 11/18] net/ixgbe: parse n-tuple filter Thread-Index: AQHSYnLiUouvO6AG4UO/04SoHPQFJaElAIoA Date: Mon, 2 Jan 2017 10:41:30 +0000 Message-ID: <94479800C636CB44BD422CB454846E013158CE6F@SHSMSX101.ccr.corp.intel.com> References: <1483084390-53159-1-git-send-email-wei.zhao1@intel.com> <1483084390-53159-12-git-send-email-wei.zhao1@intel.com> In-Reply-To: <1483084390-53159-12-git-send-email-wei.zhao1@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYmMwZmQ1YzctNWUxMi00MmIzLTgyOTQtYTQ5MmYxYjc0NmE0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6ImJJaUNhekNMcHVVMGVmXC9HM09QN0dVQ0RZZ3NYNm1QT091UkdYckpIWGNFPSJ9 x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2 11/18] net/ixgbe: parse n-tuple filter 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, 02 Jan 2017 10:41:37 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wei Zhao > Sent: Friday, December 30, 2016 3:53 PM > To: dev@dpdk.org > Cc: Zhao1, Wei ; Lu, Wenzhuo > Subject: [dpdk-dev] [PATCH v2 11/18] net/ixgbe: parse n-tuple filter >=20 > Add rule validate function and check if the rule is a n-tuple rule, and g= et the > n-tuple info. >=20 > Signed-off-by: Wei Zhao > Signed-off-by: Wenzhuo Lu >=20 > --- >=20 > v2:add new error set function > --- > drivers/net/ixgbe/ixgbe_ethdev.c | 414 > ++++++++++++++++++++++++++++++++++++++- > 1 file changed, 409 insertions(+), 5 deletions(-) >=20 > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c > b/drivers/net/ixgbe/ixgbe_ethdev.c > index 0de1318..198cc4b 100644 > --- a/drivers/net/ixgbe/ixgbe_ethdev.c > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c > @@ -388,6 +388,24 @@ static int ixgbe_dev_udp_tunnel_port_del(struct > rte_eth_dev *dev, > struct rte_eth_udp_tunnel *udp_tunnel); static int > ixgbe_filter_restore(struct rte_eth_dev *dev); static void > ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev); > +static int > +cons_parse_ntuple_filter(const struct rte_flow_attr *attr, > + const struct rte_flow_item pattern[], > + const struct rte_flow_action actions[], > + struct rte_eth_ntuple_filter *filter, > + struct rte_flow_error *error); Why do you declare cons_parse_ntuple_filter here? And seems it doesn't alig= n with the name rule. > +static int > +ixgbe_parse_ntuple_filter(const struct rte_flow_attr *attr, > + const struct rte_flow_item pattern[], > + const struct rte_flow_action actions[], > + struct rte_eth_ntuple_filter *filter, > + struct rte_flow_error *error); > +static int > +ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, > + const struct rte_flow_attr *attr, > + const struct rte_flow_item pattern[], > + const struct rte_flow_action actions[], > + struct rte_flow_error *error); > static int ixgbe_flow_flush(struct rte_eth_dev *dev, > struct rte_flow_error *error); > /* > @@ -769,7 +787,7 @@ static const struct rte_ixgbe_xstats_name_off > rte_ixgbevf_stats_strings[] =3D { > #define IXGBEVF_NB_XSTATS (sizeof(rte_ixgbevf_stats_strings) / \ > sizeof(rte_ixgbevf_stats_strings[0])) > static const struct rte_flow_ops ixgbe_flow_ops =3D { > - NULL, > + ixgbe_flow_validate, > NULL, > NULL, > ixgbe_flow_flush, > @@ -8072,6 +8090,390 @@ ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev > *dev) > return 0; > } >=20 > +static inline uint32_t > +rte_be_to_cpu_24(uint32_t x) > +{ > + return ((x & 0x000000ffUL) << 16) | > + (x & 0x0000ff00UL) | > + ((x & 0x00ff0000UL) >> 16); > +} Why do you define the function in PMD with rte_ prefixed? Do you want to mo= ve it to rte library? > + > + > +/** > + * Parse the rule to see if it is a n-tuple rule. > + * And get the n-tuple filter info BTW. > + */ > +static int > +cons_parse_ntuple_filter(const struct rte_flow_attr *attr, > + const struct rte_flow_item pattern[], > + const struct rte_flow_action actions[], > + struct rte_eth_ntuple_filter *filter, > + struct rte_flow_error *error) How about splitting the function into three functions? Including parse patt= ern/parse actions/parse attr. > + > +/* a specific function for ixgbe because the flags is specific */ > +static int ixgbe_parse_ntuple_filter(const struct rte_flow_attr *attr, > + const struct rte_flow_item pattern[], > + const struct rte_flow_action actions[], > + struct rte_eth_ntuple_filter *filter, > + struct rte_flow_error *error) > +{ > + int ret; > + > + ret =3D cons_parse_ntuple_filter(attr, pattern, actions, filter, error)= ; > + > + if (ret) > + return ret; > + > + /* Ixgbe doesn't support tcp flags. */ > + if (filter->flags & RTE_NTUPLE_FLAGS_TCP_FLAG) { > + memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > + NULL, "Not supported by ntuple filter"); > + return -rte_errno; > + } > + > + /* Ixgbe doesn't support many priorities. */ > + if (filter->priority < IXGBE_MIN_N_TUPLE_PRIO || > + filter->priority > IXGBE_MAX_N_TUPLE_PRIO) { > + memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > + NULL, "Priority not supported by ntuple filter"); > + return -rte_errno; > + } > + > + if (filter->queue >=3D IXGBE_MAX_RX_QUEUE_NUM || > + filter->priority > IXGBE_5TUPLE_MAX_PRI || > + filter->priority < IXGBE_5TUPLE_MIN_PRI) > + return -rte_errno; > + > + /* fixed value for ixgbe */ > + filter->flags =3D RTE_5TUPLE_FLAGS; > + return 0; > +} > + > +/** > + * Check if the flow rule is supported by ixgbe. > + * It only checkes the format. Don't guarantee the rule can be Typo: checkes -> checks > +programmed into > + * the HW. Because there can be no enough room for the rule. > + */ > +static int > +ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev, > + const struct rte_flow_attr *attr, > + const struct rte_flow_item pattern[], > + const struct rte_flow_action actions[], > + struct rte_flow_error *error) > +{ > + struct rte_eth_ntuple_filter ntuple_filter; > + int ret; > + > + memset(&ntuple_filter, 0, sizeof(struct rte_eth_ntuple_filter)); > + ret =3D ixgbe_parse_ntuple_filter(attr, pattern, > + actions, &ntuple_filter, error); > + if (!ret) > + return 0; > + > + return ret; > +} > + > /* Destroy all flow rules associated with a port on ixgbe. */ static i= nt > ixgbe_flow_flush(struct rte_eth_dev *dev, @@ -8085,15 +8487,17 @@ > ixgbe_flow_flush(struct rte_eth_dev *dev, >=20 > ret =3D ixgbe_clear_all_fdir_filter(dev); > if (ret < 0) { > - rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_HANDLE, > - NULL, "Failed to flush rule"); > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_HANDLE, > + NULL, "Failed to flush rule"); > return ret; > } >=20 > ret =3D ixgbe_clear_all_l2_tn_filter(dev); > if (ret < 0) { > - rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_HANDLE, > - NULL, "Failed to flush rule"); > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_HANDLE, > + NULL, "Failed to flush rule"); > return ret; > } >=20 > -- > 2.5.5