From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 1B82CFBB0 for ; Tue, 20 Dec 2016 19:12:18 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP; 20 Dec 2016 10:12:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,379,1477983600"; d="scan'208";a="1074513542" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.237.220.29]) ([10.237.220.29]) by orsmga001.jf.intel.com with ESMTP; 20 Dec 2016 10:12:16 -0800 To: Beilei Xing , jingjing.wu@intel.com, helin.zhang@intel.com References: <1480679625-4157-1-git-send-email-beilei.xing@intel.com> <1480679625-4157-11-git-send-email-beilei.xing@intel.com> Cc: dev@dpdk.org, wenzhuo.lu@intel.com, Adrien Mazarguil From: Ferruh Yigit Message-ID: Date: Tue, 20 Dec 2016 18:12:15 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <1480679625-4157-11-git-send-email-beilei.xing@intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH 10/24] ethdev: parse ethertype 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: Tue, 20 Dec 2016 18:12:19 -0000 On 12/2/2016 11:53 AM, Beilei Xing wrote: > Check if the rule is a ethertype rule, and get the ethertype > info BTW. > > Signed-off-by: Wenzhuo Lu > Signed-off-by: Beilei Xing > --- CC: Adrien Mazarguil > lib/librte_ether/rte_flow.c | 136 +++++++++++++++++++++++++++++++++++++ > lib/librte_ether/rte_flow_driver.h | 34 ++++++++++ <...> > diff --git a/lib/librte_ether/rte_flow_driver.h b/lib/librte_ether/rte_flow_driver.h > index a88c621..2760c74 100644 > --- a/lib/librte_ether/rte_flow_driver.h > +++ b/lib/librte_ether/rte_flow_driver.h > @@ -170,6 +170,40 @@ rte_flow_error_set(struct rte_flow_error *error, > const struct rte_flow_ops * > rte_flow_ops_get(uint8_t port_id, struct rte_flow_error *error); > > +int cons_parse_ethertype_filter(const struct rte_flow_attr *attr, > + const struct rte_flow_item *pattern, > + const struct rte_flow_action *actions, > + struct rte_eth_ethertype_filter *filter, > + struct rte_flow_error *error); Although this is helper function, it may be good if it follows the rte_follow namespace. > + > +#define PATTERN_SKIP_VOID(filter, filter_struct, error_type) \ > + do { \ > + if (!pattern) { \ > + memset(filter, 0, sizeof(filter_struct)); \ > + error->type = error_type; \ > + return -EINVAL; \ > + } \ > + item = pattern + i; \ I believe macros that relies on variables that not passed as argument is not good idea. > + while (item->type == RTE_FLOW_ITEM_TYPE_VOID) { \ > + i++; \ > + item = pattern + i; \ > + } \ > + } while (0) > + > +#define ACTION_SKIP_VOID(filter, filter_struct, error_type) \ > + do { \ > + if (!actions) { \ > + memset(filter, 0, sizeof(filter_struct)); \ > + error->type = error_type; \ > + return -EINVAL; \ > + } \ > + act = actions + i; \ > + while (act->type == RTE_FLOW_ACTION_TYPE_VOID) { \ > + i++; \ > + act = actions + i; \ > + } \ > + } while (0) Are these macros generic enough for all rte_flow consumers? What do you think separate this patch, and use these after applied, meanwhile keeping function and MACROS PMD internal? > + > #ifdef __cplusplus > } > #endif >