From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rcdn-iport-5.cisco.com (rcdn-iport-5.cisco.com [173.37.86.76]) by dpdk.org (Postfix) with ESMTP id 0EB0B1E34 for ; Sat, 2 Mar 2019 11:45:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=12796; q=dns/txt; s=iport; t=1551523504; x=1552733104; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=rdHxnqIyQBskoLwua9qplxTUODQ0Fv+xtWRCk9m64Sg=; b=iveQ3F6nt/C50F/1aWWRMRoE2lCevR6Aq4fCKRlfUm22qFsD7U8QymE0 mm70VJ4aUNzm86hdstHPNWaFvzkOm0AfXXDvR8bipZ/NDYnGnU3vjFReO MHDGXkEYBEg5sGPxj4o8ZHS1AJKr5bI/btHzIO7MJg6h/5bisZZ6HHyLH 8=; X-IronPort-AV: E=Sophos;i="5.58,431,1544486400"; d="scan'208";a="309375933" Received: from alln-core-6.cisco.com ([173.36.13.139]) by rcdn-iport-5.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2019 10:45:03 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by alln-core-6.cisco.com (8.15.2/8.15.2) with ESMTP id x22Aj21w026749; Sat, 2 Mar 2019 10:45:03 GMT Received: by cisco.com (Postfix, from userid 508933) id BB7B120F2001; Sat, 2 Mar 2019 02:45:02 -0800 (PST) From: Hyong Youb Kim To: Ferruh Yigit Cc: dev@dpdk.org, John Daley , Hyong Youb Kim Date: Sat, 2 Mar 2019 02:42:46 -0800 Message-Id: <20190302104251.32565-9-hyonkim@cisco.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20190302104251.32565-1-hyonkim@cisco.com> References: <20190302104251.32565-1-hyonkim@cisco.com> X-Outbound-SMTP-Client: 10.193.184.48, savbu-usnic-a.cisco.com X-Outbound-Node: alln-core-6.cisco.com Subject: [dpdk-dev] [PATCH v2 08/13] net/enic: move arguments into struct 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: Sat, 02 Mar 2019 10:45:04 -0000 There are many copy_item functions, all with the same arguments, which makes it difficult to add/change arguments. Move the arguments into a struct to help subsequent commits that will add/fix features. Also remove self-explanatory verbose comments for these local functions. These changes are purely mechanical and have no impact on functionalities. Signed-off-by: Hyong Youb Kim --- drivers/net/enic/enic_flow.c | 209 ++++++++++++++----------------------------- 1 file changed, 67 insertions(+), 142 deletions(-) diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index c6ed9e1b9..fda641b6f 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -23,11 +23,27 @@ rte_log(RTE_LOG_ ## level, enicpmd_logtype_flow, \ fmt "\n", ##args) +/* + * Common arguments passed to copy_item functions. Use this structure + * so we can easily add new arguments. + * item: Item specification. + * filter: Partially filled in NIC filter structure. + * inner_ofst: If zero, this is an outer header. If non-zero, this is + * the offset into L5 where the header begins. + */ +struct copy_item_args { + const struct rte_flow_item *item; + struct filter_v2 *filter; + uint8_t *inner_ofst; +}; + +/* functions for copying items into enic filters */ +typedef int (enic_copy_item_fn)(struct copy_item_args *arg); + /** Info about how to copy items into enic filters. */ struct enic_items { /** Function for copying and validating an item. */ - int (*copy_item)(const struct rte_flow_item *item, - struct filter_v2 *enic_filter, u8 *inner_ofst); + enic_copy_item_fn *copy_item; /** List of valid previous items. */ const enum rte_flow_item_type * const prev_items; /** True if it's OK for this item to be the first item. For some NIC @@ -49,10 +65,6 @@ typedef int (copy_action_fn)(struct enic *enic, const struct rte_flow_action actions[], struct filter_action_v2 *enic_action); -/* functions for copying items into enic filters */ -typedef int(enic_copy_item_fn)(const struct rte_flow_item *item, - struct filter_v2 *enic_filter, u8 *inner_ofst); - /** Action capabilities for various NICs. */ struct enic_action_cap { /** list of valid actions */ @@ -340,20 +352,12 @@ mask_exact_match(const u8 *supported, const u8 *supplied, return 1; } -/** - * Copy IPv4 item into version 1 NIC filter. - * - * @param item[in] - * Item specification. - * @param enic_filter[out] - * Partially filled in NIC filter structure. - * @param inner_ofst[in] - * Should always be 0 for version 1. - */ static int -enic_copy_item_ipv4_v1(const struct rte_flow_item *item, - struct filter_v2 *enic_filter, u8 *inner_ofst) +enic_copy_item_ipv4_v1(struct copy_item_args *arg) { + const struct rte_flow_item *item = arg->item; + struct filter_v2 *enic_filter = arg->filter; + uint8_t *inner_ofst = arg->inner_ofst; const struct rte_flow_item_ipv4 *spec = item->spec; const struct rte_flow_item_ipv4 *mask = item->mask; struct filter_ipv4_5tuple *enic_5tup = &enic_filter->u.ipv4; @@ -390,20 +394,12 @@ enic_copy_item_ipv4_v1(const struct rte_flow_item *item, return 0; } -/** - * Copy UDP item into version 1 NIC filter. - * - * @param item[in] - * Item specification. - * @param enic_filter[out] - * Partially filled in NIC filter structure. - * @param inner_ofst[in] - * Should always be 0 for version 1. - */ static int -enic_copy_item_udp_v1(const struct rte_flow_item *item, - struct filter_v2 *enic_filter, u8 *inner_ofst) +enic_copy_item_udp_v1(struct copy_item_args *arg) { + const struct rte_flow_item *item = arg->item; + struct filter_v2 *enic_filter = arg->filter; + uint8_t *inner_ofst = arg->inner_ofst; const struct rte_flow_item_udp *spec = item->spec; const struct rte_flow_item_udp *mask = item->mask; struct filter_ipv4_5tuple *enic_5tup = &enic_filter->u.ipv4; @@ -441,20 +437,12 @@ enic_copy_item_udp_v1(const struct rte_flow_item *item, return 0; } -/** - * Copy TCP item into version 1 NIC filter. - * - * @param item[in] - * Item specification. - * @param enic_filter[out] - * Partially filled in NIC filter structure. - * @param inner_ofst[in] - * Should always be 0 for version 1. - */ static int -enic_copy_item_tcp_v1(const struct rte_flow_item *item, - struct filter_v2 *enic_filter, u8 *inner_ofst) +enic_copy_item_tcp_v1(struct copy_item_args *arg) { + const struct rte_flow_item *item = arg->item; + struct filter_v2 *enic_filter = arg->filter; + uint8_t *inner_ofst = arg->inner_ofst; const struct rte_flow_item_tcp *spec = item->spec; const struct rte_flow_item_tcp *mask = item->mask; struct filter_ipv4_5tuple *enic_5tup = &enic_filter->u.ipv4; @@ -492,21 +480,12 @@ enic_copy_item_tcp_v1(const struct rte_flow_item *item, return 0; } -/** - * Copy ETH item into version 2 NIC filter. - * - * @param item[in] - * Item specification. - * @param enic_filter[out] - * Partially filled in NIC filter structure. - * @param inner_ofst[in] - * If zero, this is an outer header. If non-zero, this is the offset into L5 - * where the header begins. - */ static int -enic_copy_item_eth_v2(const struct rte_flow_item *item, - struct filter_v2 *enic_filter, u8 *inner_ofst) +enic_copy_item_eth_v2(struct copy_item_args *arg) { + const struct rte_flow_item *item = arg->item; + struct filter_v2 *enic_filter = arg->filter; + uint8_t *inner_ofst = arg->inner_ofst; struct ether_hdr enic_spec; struct ether_hdr enic_mask; const struct rte_flow_item_eth *spec = item->spec; @@ -555,21 +534,12 @@ enic_copy_item_eth_v2(const struct rte_flow_item *item, return 0; } -/** - * Copy VLAN item into version 2 NIC filter. - * - * @param item[in] - * Item specification. - * @param enic_filter[out] - * Partially filled in NIC filter structure. - * @param inner_ofst[in] - * If zero, this is an outer header. If non-zero, this is the offset into L5 - * where the header begins. - */ static int -enic_copy_item_vlan_v2(const struct rte_flow_item *item, - struct filter_v2 *enic_filter, u8 *inner_ofst) +enic_copy_item_vlan_v2(struct copy_item_args *arg) { + const struct rte_flow_item *item = arg->item; + struct filter_v2 *enic_filter = arg->filter; + uint8_t *inner_ofst = arg->inner_ofst; const struct rte_flow_item_vlan *spec = item->spec; const struct rte_flow_item_vlan *mask = item->mask; struct filter_generic_1 *gp = &enic_filter->u.generic_1; @@ -612,20 +582,12 @@ enic_copy_item_vlan_v2(const struct rte_flow_item *item, return 0; } -/** - * Copy IPv4 item into version 2 NIC filter. - * - * @param item[in] - * Item specification. - * @param enic_filter[out] - * Partially filled in NIC filter structure. - * @param inner_ofst[in] - * Must be 0. Don't support inner IPv4 filtering. - */ static int -enic_copy_item_ipv4_v2(const struct rte_flow_item *item, - struct filter_v2 *enic_filter, u8 *inner_ofst) +enic_copy_item_ipv4_v2(struct copy_item_args *arg) { + const struct rte_flow_item *item = arg->item; + struct filter_v2 *enic_filter = arg->filter; + uint8_t *inner_ofst = arg->inner_ofst; const struct rte_flow_item_ipv4 *spec = item->spec; const struct rte_flow_item_ipv4 *mask = item->mask; struct filter_generic_1 *gp = &enic_filter->u.generic_1; @@ -662,20 +624,12 @@ enic_copy_item_ipv4_v2(const struct rte_flow_item *item, return 0; } -/** - * Copy IPv6 item into version 2 NIC filter. - * - * @param item[in] - * Item specification. - * @param enic_filter[out] - * Partially filled in NIC filter structure. - * @param inner_ofst[in] - * Must be 0. Don't support inner IPv6 filtering. - */ static int -enic_copy_item_ipv6_v2(const struct rte_flow_item *item, - struct filter_v2 *enic_filter, u8 *inner_ofst) +enic_copy_item_ipv6_v2(struct copy_item_args *arg) { + const struct rte_flow_item *item = arg->item; + struct filter_v2 *enic_filter = arg->filter; + uint8_t *inner_ofst = arg->inner_ofst; const struct rte_flow_item_ipv6 *spec = item->spec; const struct rte_flow_item_ipv6 *mask = item->mask; struct filter_generic_1 *gp = &enic_filter->u.generic_1; @@ -712,20 +666,12 @@ enic_copy_item_ipv6_v2(const struct rte_flow_item *item, return 0; } -/** - * Copy UDP item into version 2 NIC filter. - * - * @param item[in] - * Item specification. - * @param enic_filter[out] - * Partially filled in NIC filter structure. - * @param inner_ofst[in] - * Must be 0. Don't support inner UDP filtering. - */ static int -enic_copy_item_udp_v2(const struct rte_flow_item *item, - struct filter_v2 *enic_filter, u8 *inner_ofst) +enic_copy_item_udp_v2(struct copy_item_args *arg) { + const struct rte_flow_item *item = arg->item; + struct filter_v2 *enic_filter = arg->filter; + uint8_t *inner_ofst = arg->inner_ofst; const struct rte_flow_item_udp *spec = item->spec; const struct rte_flow_item_udp *mask = item->mask; struct filter_generic_1 *gp = &enic_filter->u.generic_1; @@ -762,20 +708,12 @@ enic_copy_item_udp_v2(const struct rte_flow_item *item, return 0; } -/** - * Copy TCP item into version 2 NIC filter. - * - * @param item[in] - * Item specification. - * @param enic_filter[out] - * Partially filled in NIC filter structure. - * @param inner_ofst[in] - * Must be 0. Don't support inner TCP filtering. - */ static int -enic_copy_item_tcp_v2(const struct rte_flow_item *item, - struct filter_v2 *enic_filter, u8 *inner_ofst) +enic_copy_item_tcp_v2(struct copy_item_args *arg) { + const struct rte_flow_item *item = arg->item; + struct filter_v2 *enic_filter = arg->filter; + uint8_t *inner_ofst = arg->inner_ofst; const struct rte_flow_item_tcp *spec = item->spec; const struct rte_flow_item_tcp *mask = item->mask; struct filter_generic_1 *gp = &enic_filter->u.generic_1; @@ -812,20 +750,12 @@ enic_copy_item_tcp_v2(const struct rte_flow_item *item, return 0; } -/** - * Copy SCTP item into version 2 NIC filter. - * - * @param item[in] - * Item specification. - * @param enic_filter[out] - * Partially filled in NIC filter structure. - * @param inner_ofst[in] - * Must be 0. Don't support inner SCTP filtering. - */ static int -enic_copy_item_sctp_v2(const struct rte_flow_item *item, - struct filter_v2 *enic_filter, u8 *inner_ofst) +enic_copy_item_sctp_v2(struct copy_item_args *arg) { + const struct rte_flow_item *item = arg->item; + struct filter_v2 *enic_filter = arg->filter; + uint8_t *inner_ofst = arg->inner_ofst; const struct rte_flow_item_sctp *spec = item->spec; const struct rte_flow_item_sctp *mask = item->mask; struct filter_generic_1 *gp = &enic_filter->u.generic_1; @@ -874,20 +804,12 @@ enic_copy_item_sctp_v2(const struct rte_flow_item *item, return 0; } -/** - * Copy UDP item into version 2 NIC filter. - * - * @param item[in] - * Item specification. - * @param enic_filter[out] - * Partially filled in NIC filter structure. - * @param inner_ofst[in] - * Must be 0. VxLAN headers always start at the beginning of L5. - */ static int -enic_copy_item_vxlan_v2(const struct rte_flow_item *item, - struct filter_v2 *enic_filter, u8 *inner_ofst) +enic_copy_item_vxlan_v2(struct copy_item_args *arg) { + const struct rte_flow_item *item = arg->item; + struct filter_v2 *enic_filter = arg->filter; + uint8_t *inner_ofst = arg->inner_ofst; const struct rte_flow_item_vxlan *spec = item->spec; const struct rte_flow_item_vxlan *mask = item->mask; struct filter_generic_1 *gp = &enic_filter->u.generic_1; @@ -966,13 +888,15 @@ enic_copy_filter(const struct rte_flow_item pattern[], u8 inner_ofst = 0; /* If encapsulated, ofst into L5 */ enum rte_flow_item_type prev_item; const struct enic_items *item_info; - + struct copy_item_args args; u8 is_first_item = 1; FLOW_TRACE(); prev_item = 0; + args.filter = enic_filter; + args.inner_ofst = &inner_ofst; for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) { /* Get info about how to validate and copy the item. If NULL * is returned the nic does not support the item. @@ -993,7 +917,8 @@ enic_copy_filter(const struct rte_flow_item pattern[], if (!item_stacking_valid(prev_item, item_info, is_first_item)) goto stacking_error; - ret = item_info->copy_item(item, enic_filter, &inner_ofst); + args.item = item; + ret = item_info->copy_item(&args); if (ret) goto item_not_supported; prev_item = item->type; -- 2.16.2