* [PATCH 01/10] common/mlx5: update meson build file
2022-09-20 14:04 [PATCH 00/10] net/mlx5: implement send to kernel action Michael Savisko
@ 2022-09-20 14:04 ` Michael Savisko
2022-09-20 14:04 ` [PATCH 02/10] net/mlx5: disable send to kernel action in HW streering Michael Savisko
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Michael Savisko @ 2022-09-20 14:04 UTC (permalink / raw)
To: dev; +Cc: michaelsav, orika, viacheslavo, asafp, Matan Azrad
Define HAVE_MLX5DV_DR_ACTION_CREATE_DEST_ROOT_TABLE macro if function
mlx5dv_dr_action_create_dest_root_table exists in infiniband/mlx5dv.h
Signed-off-by: Michael Savisko <michaelsav@nvidia.com>
---
drivers/common/mlx5/linux/meson.build | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/common/mlx5/linux/meson.build b/drivers/common/mlx5/linux/meson.build
index f9d1937571..e13ee55819 100644
--- a/drivers/common/mlx5/linux/meson.build
+++ b/drivers/common/mlx5/linux/meson.build
@@ -213,6 +213,8 @@ has_sym_args = [
'ibv_reg_mr_iova' ],
[ 'HAVE_MLX5_IBV_IMPORT_CTX_PD_AND_MR', 'infiniband/verbs.h',
'ibv_import_device' ],
+ [ 'HAVE_MLX5DV_DR_ACTION_CREATE_DEST_ROOT_TABLE', 'infiniband/mlx5dv.h',
+ 'mlx5dv_dr_action_create_dest_root_table' ],
]
if libmtcr_ul_found
has_sym_args += [
--
2.27.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 02/10] net/mlx5: disable send to kernel action in HW streering
2022-09-20 14:04 [PATCH 00/10] net/mlx5: implement send to kernel action Michael Savisko
2022-09-20 14:04 ` [PATCH 01/10] common/mlx5: update meson build file Michael Savisko
@ 2022-09-20 14:04 ` Michael Savisko
2022-09-20 14:04 ` [PATCH 03/10] common/mlx5: new glue callback for send to kernel action Michael Savisko
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Michael Savisko @ 2022-09-20 14:04 UTC (permalink / raw)
To: dev; +Cc: michaelsav, orika, viacheslavo, asafp, Matan Azrad
Fail translation of RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL action in
HW steering.
Signed-off-by: Michael Savisko <michaelsav@nvidia.com>
---
drivers/net/mlx5/mlx5_flow_hw.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 12498794a5..b168ff9e7e 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -707,6 +707,9 @@ flow_hw_actions_translate(struct rte_eth_dev *dev,
reformat_pos = i++;
refmt_type = MLX5DR_ACTION_REFORMAT_TYPE_TNL_L2_TO_L2;
break;
+ case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL:
+ DRV_LOG(ERR, "send to kernel action is not supported in HW steering.");
+ goto err;
case RTE_FLOW_ACTION_TYPE_END:
actions_end = true;
break;
--
2.27.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 03/10] common/mlx5: new glue callback for send to kernel action
2022-09-20 14:04 [PATCH 00/10] net/mlx5: implement send to kernel action Michael Savisko
2022-09-20 14:04 ` [PATCH 01/10] common/mlx5: update meson build file Michael Savisko
2022-09-20 14:04 ` [PATCH 02/10] net/mlx5: disable send to kernel action in HW streering Michael Savisko
@ 2022-09-20 14:04 ` Michael Savisko
2022-09-20 14:04 ` [PATCH 04/10] net/mlx5: add function to create " Michael Savisko
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Michael Savisko @ 2022-09-20 14:04 UTC (permalink / raw)
To: dev; +Cc: michaelsav, orika, viacheslavo, asafp, Matan Azrad
Add new glue callback dr_create_flow_action_send_to_kernel.
Default callback invokes mlx5dv_dr_action_create_dest_root_table().
Signed-off-by: Michael Savisko <michaelsav@nvidia.com>
---
drivers/common/mlx5/linux/mlx5_glue.c | 17 +++++++++++++++++
drivers/common/mlx5/linux/mlx5_glue.h | 2 ++
2 files changed, 19 insertions(+)
diff --git a/drivers/common/mlx5/linux/mlx5_glue.c b/drivers/common/mlx5/linux/mlx5_glue.c
index 450dd6a06a..b954df0784 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.c
+++ b/drivers/common/mlx5/linux/mlx5_glue.c
@@ -1434,6 +1434,21 @@ mlx5_glue_dv_free_pp(struct mlx5dv_pp *pp)
#endif
}
+static void *
+mlx5_glue_dr_create_flow_action_send_to_kernel(void *tbl, uint16_t priority)
+{
+#ifdef HAVE_MLX5DV_DR_ACTION_CREATE_DEST_ROOT_TABLE
+ struct mlx5dv_dr_table *table = (struct mlx5dv_dr_table *)tbl;
+
+ return mlx5dv_dr_action_create_dest_root_table(table, priority);
+#else
+ RTE_SET_USED(tbl);
+ RTE_SET_USED(priority);
+ errno = ENOTSUP;
+ return NULL;
+#endif
+}
+
__rte_cache_aligned
const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) {
.version = MLX5_GLUE_VERSION,
@@ -1561,4 +1576,6 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) {
.dv_free_var = mlx5_glue_dv_free_var,
.dv_alloc_pp = mlx5_glue_dv_alloc_pp,
.dv_free_pp = mlx5_glue_dv_free_pp,
+ .dr_create_flow_action_send_to_kernel =
+ mlx5_glue_dr_create_flow_action_send_to_kernel,
};
diff --git a/drivers/common/mlx5/linux/mlx5_glue.h b/drivers/common/mlx5/linux/mlx5_glue.h
index c4903a6dce..9616dfdd06 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.h
+++ b/drivers/common/mlx5/linux/mlx5_glue.h
@@ -373,6 +373,8 @@ struct mlx5_glue {
void *(*dv_create_flow_action_aso)
(struct mlx5dv_dr_domain *domain, void *aso_obj,
uint32_t offset, uint32_t flags, uint8_t return_reg_c);
+ void *(*dr_create_flow_action_send_to_kernel)(void *tbl,
+ uint16_t priority);
};
extern const struct mlx5_glue *mlx5_glue;
--
2.27.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 04/10] net/mlx5: add function to create send to kernel action
2022-09-20 14:04 [PATCH 00/10] net/mlx5: implement send to kernel action Michael Savisko
` (2 preceding siblings ...)
2022-09-20 14:04 ` [PATCH 03/10] common/mlx5: new glue callback for send to kernel action Michael Savisko
@ 2022-09-20 14:04 ` Michael Savisko
2022-09-20 14:04 ` [PATCH 05/10] net/mlx5: introduce new mlx5 action flag Michael Savisko
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Michael Savisko @ 2022-09-20 14:04 UTC (permalink / raw)
To: dev; +Cc: michaelsav, orika, viacheslavo, asafp, Matan Azrad
Add static inline mlx5_flow_os_create_flow_action_send_to_kernel(),
which calls dr_create_flow_action_send_to_kernel glue callback.
Signed-off-by: Michael Savisko <michaelsav@nvidia.com>
---
drivers/net/mlx5/linux/mlx5_flow_os.h | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/net/mlx5/linux/mlx5_flow_os.h b/drivers/net/mlx5/linux/mlx5_flow_os.h
index bcb48b3e56..ed71289322 100644
--- a/drivers/net/mlx5/linux/mlx5_flow_os.h
+++ b/drivers/net/mlx5/linux/mlx5_flow_os.h
@@ -368,6 +368,28 @@ mlx5_flow_os_create_flow_action_default_miss(void **action)
return (*action) ? 0 : -1;
}
+/**
+ * Create flow action: send_to_kernel.
+ *
+ * @param[in] tbl
+ * Pointer to destination root table.
+ * @param[in] priority
+ * Priority to which traffic will arrive.
+ * @param[out] action
+ * Pointer to a valid action on success, NULL otherwise.
+ *
+ * @return
+ * 0 on success, or -1 on failure and errno is set.
+ */
+static inline int
+mlx5_flow_os_create_flow_action_send_to_kernel(void *tbl, uint16_t priority,
+ void **action)
+{
+ *action = mlx5_glue->dr_create_flow_action_send_to_kernel(tbl,
+ priority);
+ return (*action) ? 0 : -1;
+}
+
/**
* Create flow action: dest_devx_tir
*
--
2.27.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 05/10] net/mlx5: introduce new mlx5 action flag
2022-09-20 14:04 [PATCH 00/10] net/mlx5: implement send to kernel action Michael Savisko
` (3 preceding siblings ...)
2022-09-20 14:04 ` [PATCH 04/10] net/mlx5: add function to create " Michael Savisko
@ 2022-09-20 14:04 ` Michael Savisko
2022-09-20 14:04 ` [PATCH 06/10] net/mlx5: introduce new mlx5 flow fate Michael Savisko
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Michael Savisko @ 2022-09-20 14:04 UTC (permalink / raw)
To: dev; +Cc: michaelsav, orika, viacheslavo, asafp, Matan Azrad
Add new mlx5 action flag MLX5_FLOW_ACTION_SEND_TO_KERNEL.
Signed-off-by: Michael Savisko <michaelsav@nvidia.com>
---
drivers/net/mlx5/mlx5_flow.h | 4 +++-
drivers/net/mlx5/mlx5_flow_dv.c | 11 +++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 4c233cd94a..3afdd46421 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -274,12 +274,14 @@ enum mlx5_feature_name {
#define MLX5_FLOW_ACTION_MODIFY_FIELD (1ull << 39)
#define MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY (1ull << 40)
#define MLX5_FLOW_ACTION_CT (1ull << 41)
+#define MLX5_FLOW_ACTION_SEND_TO_KERNEL (1ull << 42)
#define MLX5_FLOW_FATE_ACTIONS \
(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \
MLX5_FLOW_ACTION_RSS | MLX5_FLOW_ACTION_JUMP | \
MLX5_FLOW_ACTION_DEFAULT_MISS | \
- MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY)
+ MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY | \
+ MLX5_FLOW_ACTION_SEND_TO_KERNEL)
#define MLX5_FLOW_FATE_ESWITCH_ACTIONS \
(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_PORT_ID | \
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index bee9363515..7e0b13b8b1 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -7953,6 +7953,12 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
* list it here as a supported type
*/
break;
+#ifdef HAVE_MLX5DV_DR_ACTION_CREATE_DEST_ROOT_TABLE
+ case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL:
+ action_flags |= MLX5_FLOW_ACTION_SEND_TO_KERNEL;
+ ++actions_n;
+ break;
+#endif
default:
return rte_flow_error_set(error, ENOTSUP,
RTE_FLOW_ERROR_TYPE_ACTION,
@@ -13677,6 +13683,11 @@ flow_dv_translate(struct rte_eth_dev *dev,
actions_n++;
action_flags |= MLX5_FLOW_ACTION_CT;
break;
+ case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL:
+ return rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_ACTION,
+ NULL, "send to kernel action is not supported.");
+ break;
case RTE_FLOW_ACTION_TYPE_END:
actions_end = true;
if (mhdr_res->actions_num) {
--
2.27.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 06/10] net/mlx5: introduce new mlx5 flow fate
2022-09-20 14:04 [PATCH 00/10] net/mlx5: implement send to kernel action Michael Savisko
` (4 preceding siblings ...)
2022-09-20 14:04 ` [PATCH 05/10] net/mlx5: introduce new mlx5 action flag Michael Savisko
@ 2022-09-20 14:04 ` Michael Savisko
2022-09-20 14:04 ` [PATCH 07/10] net/mlx5: get priority to send traffic to kernel Michael Savisko
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Michael Savisko @ 2022-09-20 14:04 UTC (permalink / raw)
To: dev; +Cc: michaelsav, orika, viacheslavo, asafp, Matan Azrad
Add element MLX5_FLOW_FATE_SEND_TO_KERNEL in enum mlx5_flow_fate_type.
For that purpose field 'fate_action' in structure mlx5_flow_handle must be
expanded from 3 bits to 4 bits.
Signed-off-by: Michael Savisko <michaelsav@nvidia.com>
---
drivers/net/mlx5/mlx5_flow.h | 3 ++-
drivers/net/mlx5/mlx5_flow_dv.c | 6 ++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 3afdd46421..860c6cd2ad 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -476,6 +476,7 @@ enum mlx5_flow_fate_type {
MLX5_FLOW_FATE_DEFAULT_MISS,
MLX5_FLOW_FATE_SHARED_RSS,
MLX5_FLOW_FATE_MTR,
+ MLX5_FLOW_FATE_SEND_TO_KERNEL,
MLX5_FLOW_FATE_MAX,
};
@@ -708,7 +709,7 @@ struct mlx5_flow_handle {
void *drv_flow; /**< pointer to driver flow object. */
uint32_t split_flow_id:27; /**< Sub flow unique match flow id. */
uint32_t is_meter_flow_id:1; /**< Indicate if flow_id is for meter. */
- uint32_t fate_action:3; /**< Fate action type. */
+ uint32_t fate_action:4; /**< Fate action type. */
union {
uint32_t rix_hrxq; /**< Hash Rx queue object index. */
uint32_t rix_jump; /**< Index to the jump action resource. */
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 7e0b13b8b1..8f8a1208e9 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -14735,6 +14735,12 @@ flow_dv_fate_resource_release(struct rte_eth_dev *dev,
flow_dv_port_id_action_resource_release(dev,
handle->rix_port_id_action);
break;
+ case MLX5_FLOW_FATE_SEND_TO_KERNEL:
+ /* In case of send_to_kernel action the actual release of
+ * resource is done when all shared DR resources are released
+ * since this resource is created once and always reused.
+ */
+ break;
default:
DRV_LOG(DEBUG, "Incorrect fate action:%d", handle->fate_action);
break;
--
2.27.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 07/10] net/mlx5: get priority to send traffic to kernel
2022-09-20 14:04 [PATCH 00/10] net/mlx5: implement send to kernel action Michael Savisko
` (5 preceding siblings ...)
2022-09-20 14:04 ` [PATCH 06/10] net/mlx5: introduce new mlx5 flow fate Michael Savisko
@ 2022-09-20 14:04 ` Michael Savisko
2022-09-20 14:04 ` [PATCH 08/10] net/mlx5: expose table resource release function Michael Savisko
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Michael Savisko @ 2022-09-20 14:04 UTC (permalink / raw)
To: dev; +Cc: michaelsav, orika, viacheslavo, asafp, Matan Azrad
Introduce mlx5_get_send_to_kernel_priority() function which returns
value of priority which must be used to jump back to table 0 in order
to send traffic to kernel. This function returns lowest priority.
Signed-off-by: Michael Savisko <michaelsav@nvidia.com>
---
drivers/net/mlx5/mlx5_flow.c | 33 +++++++++++++++++++++++++++++++++
drivers/net/mlx5/mlx5_flow.h | 1 +
2 files changed, 34 insertions(+)
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 8c93a3f2e5..c9e2b68957 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -10968,6 +10968,39 @@ mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
return res;
}
+/**
+ * Get the priority for sending traffic to kernel table.
+ *
+ * @param[in] dev
+ * Pointer to the Ethernet device structure.
+ *
+ * @return
+ * On success: the value of priority for sending traffic to kernel table
+ * On failure: -1
+ */
+uint32_t
+mlx5_get_send_to_kernel_priority(struct rte_eth_dev *dev)
+{
+ struct mlx5_priv *priv = dev->data->dev_private;
+ uint32_t res;
+
+ switch (priv->sh->flow_max_priority) {
+ case RTE_DIM(priority_map_5):
+ res = 15;
+ break;
+ case RTE_DIM(priority_map_3):
+ res = 7;
+ break;
+ default:
+ DRV_LOG(ERR,
+ "port %u maximum priority: %d expected 8/16",
+ dev->data->port_id, priv->sh->flow_max_priority);
+ res = (uint32_t)-1;
+ }
+
+ return res;
+}
+
/**
* Get the E-Switch Manager vport id.
*
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 860c6cd2ad..f4228a5549 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -1750,6 +1750,7 @@ uint32_t mlx5_get_lowest_priority(struct rte_eth_dev *dev,
uint16_t mlx5_get_matcher_priority(struct rte_eth_dev *dev,
const struct rte_flow_attr *attr,
uint32_t subpriority, bool external);
+uint32_t mlx5_get_send_to_kernel_priority(struct rte_eth_dev *dev);
int mlx5_flow_get_reg_id(struct rte_eth_dev *dev,
enum mlx5_feature_name feature,
uint32_t id,
--
2.27.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 08/10] net/mlx5: expose table resource release function
2022-09-20 14:04 [PATCH 00/10] net/mlx5: implement send to kernel action Michael Savisko
` (6 preceding siblings ...)
2022-09-20 14:04 ` [PATCH 07/10] net/mlx5: get priority to send traffic to kernel Michael Savisko
@ 2022-09-20 14:04 ` Michael Savisko
2022-09-20 14:04 ` [PATCH 09/10] net/mlx5: add send to kernel action resource holder Michael Savisko
2022-09-20 14:04 ` [PATCH 10/10] net/mlx5: translation of rte flow send to kernel action Michael Savisko
9 siblings, 0 replies; 11+ messages in thread
From: Michael Savisko @ 2022-09-20 14:04 UTC (permalink / raw)
To: dev; +Cc: michaelsav, orika, viacheslavo, asafp, Matan Azrad
Change function flow_dv_tbl_resource_release() from
static to external. Prestep for next commit.
Signed-off-by: Michael Savisko <michaelsav@nvidia.com>
---
drivers/net/mlx5/mlx5_flow.h | 2 ++
drivers/net/mlx5/mlx5_flow_dv.c | 6 +-----
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index f4228a5549..dac65a640c 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -1916,6 +1916,8 @@ struct mlx5_flow_tbl_resource *flow_dv_tbl_resource_get(struct rte_eth_dev *dev,
bool external, const struct mlx5_flow_tunnel *tunnel,
uint32_t group_id, uint8_t dummy,
uint32_t table_id, struct rte_flow_error *error);
+int flow_dv_tbl_resource_release(struct mlx5_dev_ctx_shared *sh,
+ struct mlx5_flow_tbl_resource *tbl);
struct mlx5_list_entry *flow_dv_tag_create_cb(void *tool_ctx, void *cb_ctx);
int flow_dv_tag_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 8f8a1208e9..01bdd34d1d 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -75,10 +75,6 @@ union flow_dv_attr {
uint32_t attr;
};
-static int
-flow_dv_tbl_resource_release(struct mlx5_dev_ctx_shared *sh,
- struct mlx5_flow_tbl_resource *tbl);
-
static int
flow_dv_encap_decap_resource_release(struct rte_eth_dev *dev,
uint32_t encap_decap_idx);
@@ -10911,7 +10907,7 @@ flow_dv_tbl_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry)
* @return
* Returns 0 if table was released, else return 1;
*/
-static int
+int
flow_dv_tbl_resource_release(struct mlx5_dev_ctx_shared *sh,
struct mlx5_flow_tbl_resource *tbl)
{
--
2.27.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 09/10] net/mlx5: add send to kernel action resource holder
2022-09-20 14:04 [PATCH 00/10] net/mlx5: implement send to kernel action Michael Savisko
` (7 preceding siblings ...)
2022-09-20 14:04 ` [PATCH 08/10] net/mlx5: expose table resource release function Michael Savisko
@ 2022-09-20 14:04 ` Michael Savisko
2022-09-20 14:04 ` [PATCH 10/10] net/mlx5: translation of rte flow send to kernel action Michael Savisko
9 siblings, 0 replies; 11+ messages in thread
From: Michael Savisko @ 2022-09-20 14:04 UTC (permalink / raw)
To: dev; +Cc: michaelsav, orika, viacheslavo, asafp, Matan Azrad
Add new structure mlx5_send_to_kernel_action which will hold
together allocated action resource and a reference to used table.
A new structure member of this type added to struct mlx5_dev_ctx_shared.
The member will be initialized upon first created send_to_kernel
action and will be reused for all future actions of this type.
Release of these resources will be done when all shared DR
resources are being released in mlx5_os_free_shared_dr().
Signed-off-by: Michael Savisko <michaelsav@nvidia.com>
---
drivers/net/mlx5/linux/mlx5_os.c | 11 +++++++++++
drivers/net/mlx5/mlx5.h | 6 ++++++
2 files changed, 17 insertions(+)
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 0741028dab..840e650045 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -708,6 +708,17 @@ mlx5_os_free_shared_dr(struct mlx5_priv *priv)
mlx5_glue->destroy_flow_action(sh->pop_vlan_action);
sh->pop_vlan_action = NULL;
}
+ if (sh->send_to_kernel_action.action) {
+ void *action = sh->send_to_kernel_action.action;
+ mlx5_glue->destroy_flow_action(action);
+ sh->send_to_kernel_action.action = NULL;
+ }
+ if (sh->send_to_kernel_action.tbl) {
+ struct mlx5_flow_tbl_resource *tbl =
+ sh->send_to_kernel_action.tbl;
+ flow_dv_tbl_resource_release(sh, tbl);
+ sh->send_to_kernel_action.tbl = NULL;
+ }
#endif /* HAVE_MLX5DV_DR */
if (sh->default_miss_action)
mlx5_glue->destroy_flow_action
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 8af84aef50..b93d451af6 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -1178,6 +1178,11 @@ struct mlx5_flex_item {
struct mlx5_flex_pattern_field map[MLX5_FLEX_ITEM_MAPPING_NUM];
};
+struct mlx5_send_to_kernel_action {
+ void *action;
+ void *tbl;
+};
+
/*
* Shared Infiniband device context for Master/Representors
* which belong to same IB device with multiple IB ports.
@@ -1229,6 +1234,7 @@ struct mlx5_dev_ctx_shared {
/* Direct Rules tables for FDB, NIC TX+RX */
void *dr_drop_action; /* Pointer to DR drop action, any domain. */
void *pop_vlan_action; /* Pointer to DR pop VLAN action. */
+ struct mlx5_send_to_kernel_action send_to_kernel_action;
struct mlx5_hlist *encaps_decaps; /* Encap/decap action hash list. */
struct mlx5_hlist *modify_cmds;
struct mlx5_hlist *tag_table;
--
2.27.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 10/10] net/mlx5: translation of rte flow send to kernel action
2022-09-20 14:04 [PATCH 00/10] net/mlx5: implement send to kernel action Michael Savisko
` (8 preceding siblings ...)
2022-09-20 14:04 ` [PATCH 09/10] net/mlx5: add send to kernel action resource holder Michael Savisko
@ 2022-09-20 14:04 ` Michael Savisko
9 siblings, 0 replies; 11+ messages in thread
From: Michael Savisko @ 2022-09-20 14:04 UTC (permalink / raw)
To: dev; +Cc: michaelsav, orika, viacheslavo, asafp, Matan Azrad
Add flow_dv_translate_action_send_to_kernel() function which
will allocate rdma-core send_to_kernel action object.
Called from flow_dv_translate().
Signed-off-by: Michael Savisko <michaelsav@nvidia.com>
---
drivers/net/mlx5/mlx5_flow_dv.c | 62 +++++++++++++++++++++++++++++++--
1 file changed, 59 insertions(+), 3 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 01bdd34d1d..bb9b8f9800 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -12175,6 +12175,56 @@ flow_dv_translate_action_sample(struct rte_eth_dev *dev,
return 0;
}
+static void *
+flow_dv_translate_action_send_to_kernel(struct rte_eth_dev *dev,
+ struct rte_flow_error *error)
+{
+ struct mlx5_flow_tbl_resource *tbl;
+ struct mlx5_dev_ctx_shared *sh;
+ uint32_t priority;
+ void *action;
+ int ret;
+
+ sh = MLX5_SH(dev);
+ if (sh->send_to_kernel_action.action)
+ return sh->send_to_kernel_action.action;
+
+ priority = mlx5_get_send_to_kernel_priority(dev);
+ if (priority == (uint32_t)-1) {
+ rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+ "required priority is not available");
+ return NULL;
+ }
+
+ tbl = flow_dv_tbl_resource_get(dev, 0, 0, 0, false, NULL, 0, 0, 0,
+ error);
+ if (!tbl) {
+ rte_flow_error_set(error, ENODATA,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+ "cannot find destination root table");
+ return NULL;
+ }
+
+ ret = mlx5_flow_os_create_flow_action_send_to_kernel(tbl->obj,
+ priority, &action);
+ if (ret) {
+ rte_flow_error_set(error, ENOMEM,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+ "cannot create action");
+ goto err;
+ }
+
+ MLX5_ASSERT(action);
+ sh->send_to_kernel_action.action = action;
+ sh->send_to_kernel_action.tbl = tbl;
+ return action;
+
+err:
+ flow_dv_tbl_resource_release(sh, tbl);
+ return NULL;
+}
+
/**
* Convert Sample action to DV specification.
*
@@ -13680,9 +13730,15 @@ flow_dv_translate(struct rte_eth_dev *dev,
action_flags |= MLX5_FLOW_ACTION_CT;
break;
case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL:
- return rte_flow_error_set(error, ENOTSUP,
- RTE_FLOW_ERROR_TYPE_ACTION,
- NULL, "send to kernel action is not supported.");
+ dev_flow->dv.actions[actions_n] =
+ flow_dv_translate_action_send_to_kernel(dev,
+ error);
+ if (!dev_flow->dv.actions[actions_n])
+ return -rte_errno;
+ actions_n++;
+ action_flags |= MLX5_FLOW_ACTION_SEND_TO_KERNEL;
+ dev_flow->handle->fate_action =
+ MLX5_FLOW_FATE_SEND_TO_KERNEL;
break;
case RTE_FLOW_ACTION_TYPE_END:
actions_end = true;
--
2.27.0
^ permalink raw reply [flat|nested] 11+ messages in thread