DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Chaoyong He <chaoyong.he@corigine.com>,
	Long Wu <long.wu@corigine.com>,
	Peng Zhang <peng.zhang@corigine.com>
Subject: [PATCH 5/7] net/nfp: simplify the flow item calculate logic
Date: Wed, 19 Jun 2024 17:19:39 +0800	[thread overview]
Message-ID: <20240619091941.3479371-6-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240619091941.3479371-1-chaoyong.he@corigine.com>

Simplify the flow item calculate logic.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower_flow.c | 66 ++++++------------------
 1 file changed, 15 insertions(+), 51 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index f73be3c9a2..c8270d81f1 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -821,7 +821,7 @@ struct nfp_item_calculate_param {
 };
 
 typedef int (*nfp_flow_key_check_item_fn)(struct nfp_item_calculate_param *param);
-typedef int (*nfp_flow_key_calculate_item_fn)(struct nfp_item_calculate_param *param);
+typedef void (*nfp_flow_key_calculate_item_fn)(struct nfp_item_calculate_param *param);
 
 static int
 nfp_flow_item_check_port(struct nfp_item_calculate_param *param)
@@ -925,24 +925,21 @@ nfp_flow_key_layers_check_items(const struct rte_flow_item items[])
 	return 0;
 }
 
-static int
+static void
 nfp_flow_item_calculate_stub(struct nfp_item_calculate_param *param __rte_unused)
 {
-	return 0;
 }
 
-static int
+static void
 nfp_flow_item_calculate_eth(struct nfp_item_calculate_param *param)
 {
 	if (param->item->spec != NULL) {
 		param->key_ls->key_layer |= NFP_FLOWER_LAYER_MAC;
 		param->key_ls->key_size += sizeof(struct nfp_flower_mac_mpls);
 	}
-
-	return 0;
 }
 
-static int
+static void
 nfp_flow_item_calculate_port(struct nfp_item_calculate_param *param)
 {
 	struct rte_eth_dev *ethdev;
@@ -950,56 +947,43 @@ nfp_flow_item_calculate_port(struct nfp_item_calculate_param *param)
 	const struct rte_flow_item_port_id *port_id;
 
 	port_id = param->item->spec;
-	if (port_id == NULL || port_id->id >= RTE_MAX_ETHPORTS)
-		return -ERANGE;
-
 	ethdev = &rte_eth_devices[port_id->id];
 	repr = ethdev->data->dev_private;
 	param->key_ls->port = repr->port_id;
-
-	return 0;
 }
 
-static int
+static void
 nfp_flow_item_calculate_vlan(struct nfp_item_calculate_param *param)
 {
 	param->key_ls->vlan = NFP_FLOWER_MASK_VLAN_CFI;
-
-	return 0;
 }
 
-static int
+static void
 nfp_flow_item_calculate_ipv4(struct nfp_item_calculate_param *param)
 {
 	param->key_ls->key_layer |= NFP_FLOWER_LAYER_IPV4;
 	param->key_ls->key_size += sizeof(struct nfp_flower_ipv4);
 	if (!param->flag->outer_ip4_flag)
 		param->flag->outer_ip4_flag = true;
-
-	return 0;
 }
 
-static int
+static void
 nfp_flow_item_calculate_ipv6(struct nfp_item_calculate_param *param)
 {
 	param->key_ls->key_layer |= NFP_FLOWER_LAYER_IPV6;
 	param->key_ls->key_size += sizeof(struct nfp_flower_ipv6);
 	if (!param->flag->outer_ip6_flag)
 		param->flag->outer_ip6_flag = true;
-
-	return 0;
 }
 
-static int
+static void
 nfp_flow_item_calculate_l4(struct nfp_item_calculate_param *param)
 {
 	param->key_ls->key_layer |= NFP_FLOWER_LAYER_TP;
 	param->key_ls->key_size += sizeof(struct nfp_flower_tp_ports);
-
-	return 0;
 }
 
-static int
+static void
 nfp_flow_item_calculate_vxlan(struct nfp_item_calculate_param *param)
 {
 	struct nfp_fl_key_ls *key_ls = param->key_ls;
@@ -1016,7 +1000,7 @@ nfp_flow_item_calculate_vxlan(struct nfp_item_calculate_param *param)
 		 * in `struct nfp_flower_ipv4_udp_tun`.
 		 */
 		key_ls->key_size -= sizeof(struct nfp_flower_ipv4);
-	} else if (param->flag->outer_ip6_flag) {
+	} else {
 		key_ls->key_layer |= NFP_FLOWER_LAYER_EXT_META;
 		key_ls->key_layer_two |= NFP_FLOWER_LAYER2_TUN_IPV6;
 		key_ls->key_size += sizeof(struct nfp_flower_ext_meta);
@@ -1026,15 +1010,10 @@ nfp_flow_item_calculate_vxlan(struct nfp_item_calculate_param *param)
 		 * in `struct nfp_flower_ipv6_udp_tun`.
 		 */
 		key_ls->key_size -= sizeof(struct nfp_flower_ipv6);
-	} else {
-		PMD_DRV_LOG(ERR, "No outer IP layer for VXLAN tunnel.");
-		return -EINVAL;
 	}
-
-	return 0;
 }
 
-static int
+static void
 nfp_flow_item_calculate_geneve(struct nfp_item_calculate_param *param)
 {
 	struct nfp_fl_key_ls *key_ls = param->key_ls;
@@ -1053,7 +1032,7 @@ nfp_flow_item_calculate_geneve(struct nfp_item_calculate_param *param)
 		 * in `struct nfp_flower_ipv4_udp_tun`.
 		 */
 		key_ls->key_size -= sizeof(struct nfp_flower_ipv4);
-	} else if (param->flag->outer_ip6_flag) {
+	} else {
 		key_ls->key_layer_two |= NFP_FLOWER_LAYER2_TUN_IPV6;
 		key_ls->key_size += sizeof(struct nfp_flower_ipv6_udp_tun);
 		/*
@@ -1061,15 +1040,10 @@ nfp_flow_item_calculate_geneve(struct nfp_item_calculate_param *param)
 		 * in `struct nfp_flower_ipv6_udp_tun`.
 		 */
 		key_ls->key_size -= sizeof(struct nfp_flower_ipv6);
-	} else {
-		PMD_DRV_LOG(ERR, "No outer IP layer for GENEVE tunnel.");
-		return -EINVAL;
 	}
-
-	return 0;
 }
 
-static int
+static void
 nfp_flow_item_calculate_gre(struct nfp_item_calculate_param *param)
 {
 	struct nfp_fl_key_ls *key_ls = param->key_ls;
@@ -1088,7 +1062,7 @@ nfp_flow_item_calculate_gre(struct nfp_item_calculate_param *param)
 		 * in `struct nfp_flower_ipv4_gre_tun`.
 		 */
 		key_ls->key_size -= sizeof(struct nfp_flower_ipv4);
-	} else if (param->flag->outer_ip6_flag) {
+	} else {
 		key_ls->key_layer_two |= NFP_FLOWER_LAYER2_TUN_IPV6;
 		key_ls->key_size += sizeof(struct nfp_flower_ipv6_gre_tun);
 		/*
@@ -1096,12 +1070,7 @@ nfp_flow_item_calculate_gre(struct nfp_item_calculate_param *param)
 		 * in `struct nfp_flower_ipv6_gre_tun`.
 		 */
 		key_ls->key_size -= sizeof(struct nfp_flower_ipv6);
-	} else {
-		PMD_DRV_LOG(ERR, "No outer IP layer for GRE tunnel.");
-		return -EINVAL;
 	}
-
-	return 0;
 }
 
 static nfp_flow_key_calculate_item_fn item_fns[] = {
@@ -1123,7 +1092,6 @@ static int
 nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[],
 		struct nfp_fl_key_ls *key_ls)
 {
-	int ret;
 	struct nfp_item_flag flag = {};
 	const struct rte_flow_item *item;
 	struct nfp_item_calculate_param param = {
@@ -1138,11 +1106,7 @@ nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[],
 		}
 
 		param.item = item;
-		ret = item_fns[item->type](&param);
-		if (ret != 0) {
-			PMD_DRV_LOG(ERR, "Flow item %d calculate fail", item->type);
-			return ret;
-		}
+		item_fns[item->type](&param);
 	}
 
 	return 0;
-- 
2.39.1


  parent reply	other threads:[~2024-06-19  9:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-19  9:19 [PATCH 0/7] refactor flow validate and create interface Chaoyong He
2024-06-19  9:19 ` [PATCH 1/7] net/nfp: remove the unused parameter Chaoyong He
2024-06-19  9:19 ` [PATCH 2/7] net/nfp: exit as soon as possible Chaoyong He
2024-06-19  9:19 ` [PATCH 3/7] net/nfp: remove the duplicate logic of output action Chaoyong He
2024-06-19  9:19 ` [PATCH 4/7] net/nfp: split out the flow item check logic Chaoyong He
2024-06-19  9:19 ` Chaoyong He [this message]
2024-06-19  9:19 ` [PATCH 6/7] net/nfp: split out the flow action " Chaoyong He
2024-06-19  9:19 ` [PATCH 7/7] net/nfp: simplify the flow action calculate logic Chaoyong He

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240619091941.3479371-6-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=long.wu@corigine.com \
    --cc=oss-drivers@corigine.com \
    --cc=peng.zhang@corigine.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).