aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <konstantinb@nvidia.com>2021-04-14 07:08:56 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2021-07-12 09:34:39 +0000
commit559eaa44d91ad74973612843835a8248b3df7341 (patch)
treeb2895c8511de37cf24cf66e809f28de0677f8b71
parente012189d0265851c631261bdcb175727ba715b34 (diff)
downloadsrc-559eaa44d91ad74973612843835a8248b3df7341.tar.gz
src-559eaa44d91ad74973612843835a8248b3df7341.zip
mlx5en: add mlx5e_add_vxlan_rule_from_db() helper
Reviewed by: hselasky Sponsored by: Mellanox Technologies/NVidia Networking MFC after: 1 week
-rw-r--r--sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c41
1 files changed, 26 insertions, 15 deletions
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c b/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c
index 9e10a3728b1d..648dc199157c 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c
@@ -1802,11 +1802,34 @@ mlx5e_vxlan_family_to_proto(sa_family_t family, u_int *proto)
}
static int
-mlx5e_add_vxlan_rule(struct mlx5e_priv *priv, sa_family_t family, u_int port)
+mlx5e_add_vxlan_rule_from_db(struct mlx5e_priv *priv,
+ struct mlx5e_vxlan_db_el *el)
{
- struct mlx5e_vxlan_db_el *el;
u32 *match_criteria;
u32 *match_value;
+ int err;
+
+ match_value = mlx5_vzalloc(MLX5_ST_SZ_BYTES(fte_match_param));
+ match_criteria = mlx5_vzalloc(MLX5_ST_SZ_BYTES(fte_match_param));
+ if (match_value == NULL || match_criteria == NULL) {
+ mlx5_en_err(priv->ifp, "alloc failed\n");
+ err = -ENOMEM;
+ goto add_vxlan_rule_out;
+ }
+
+ err = mlx5e_add_vxlan_rule_sub(priv, match_criteria, match_value, el);
+
+add_vxlan_rule_out:
+ kvfree(match_criteria);
+ kvfree(match_value);
+
+ return (err);
+}
+
+static int
+mlx5e_add_vxlan_rule(struct mlx5e_priv *priv, sa_family_t family, u_int port)
+{
+ struct mlx5e_vxlan_db_el *el;
u_int proto;
int err;
@@ -1821,25 +1844,13 @@ mlx5e_add_vxlan_rule(struct mlx5e_priv *priv, sa_family_t family, u_int port)
}
el = mlx5e_vxlan_alloc_db_el(priv, proto, port);
- match_value = mlx5_vzalloc(MLX5_ST_SZ_BYTES(fte_match_param));
- match_criteria = mlx5_vzalloc(MLX5_ST_SZ_BYTES(fte_match_param));
- if (match_value == NULL || match_criteria == NULL) {
- mlx5_en_err(priv->ifp, "alloc failed\n");
- err = -ENOMEM;
- goto add_vxlan_rule_out;
- }
-
- err = mlx5e_add_vxlan_rule_sub(priv, match_criteria, match_value, el);
+ err = mlx5e_add_vxlan_rule_from_db(priv, el);
if (err == 0) {
TAILQ_INSERT_TAIL(&priv->vxlan.head, el, link);
} else {
kvfree(el);
}
-add_vxlan_rule_out:
- kvfree(match_criteria);
- kvfree(match_value);
-
return (err);
}