@@ -198,3 +198,4 @@ set_ttl =
vf =
vxlan_decap =
vxlan_encap =
+send_to_kernel =
@@ -128,3 +128,4 @@ set_tp_src = Y
set_ttl = Y
vxlan_decap = Y
vxlan_encap = Y
+send_to_kernel = Y
@@ -10967,6 +10967,38 @@ 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.
*
@@ -1753,6 +1753,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,
@@ -12192,6 +12192,51 @@ 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.
*
@@ -13697,9 +13742,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;
@@ -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;