There are some renaming:
- in the DV flow engine overall: flow_d_* -> flow_dv_*
- in flow_dv_translate(): res -> mhdr_res

Signed-off-by: Yongseok Koh <ys...@mellanox.com>
Signed-off-by: Viacheslav Ovsiienko <viachesl...@mellanox.com>
Acked-by: Matan Azrad <ma...@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 151 ++++++++++++++++++++--------------------
 1 file changed, 76 insertions(+), 75 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 170726f..9b2eba5 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -183,7 +183,7 @@ struct field_modify_info modify_tcp[] = {
  *   Pointer to the rte_eth_dev structure.
  */
 static void
-flow_d_shared_lock(struct rte_eth_dev *dev)
+flow_dv_shared_lock(struct rte_eth_dev *dev)
 {
        struct mlx5_priv *priv = dev->data->dev_private;
        struct mlx5_ibv_shared *sh = priv->sh;
@@ -198,7 +198,7 @@ struct field_modify_info modify_tcp[] = {
 }
 
 static void
-flow_d_shared_unlock(struct rte_eth_dev *dev)
+flow_dv_shared_unlock(struct rte_eth_dev *dev)
 {
        struct mlx5_priv *priv = dev->data->dev_private;
        struct mlx5_ibv_shared *sh = priv->sh;
@@ -5599,7 +5599,8 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
- * Fill the flow with DV spec.
+ * Fill the flow with DV spec, lock free
+ * (mutex should be acquired by caller).
  *
  * @param[in] dev
  *   Pointer to rte_eth_dev structure.
@@ -5618,12 +5619,12 @@ struct field_modify_info modify_tcp[] = {
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
 static int
-flow_dv_translate(struct rte_eth_dev *dev,
-                 struct mlx5_flow *dev_flow,
-                 const struct rte_flow_attr *attr,
-                 const struct rte_flow_item items[],
-                 const struct rte_flow_action actions[],
-                 struct rte_flow_error *error)
+__flow_dv_translate(struct rte_eth_dev *dev,
+                   struct mlx5_flow *dev_flow,
+                   const struct rte_flow_attr *attr,
+                   const struct rte_flow_item items[],
+                   const struct rte_flow_action actions[],
+                   struct rte_flow_error *error)
 {
        struct mlx5_priv *priv = dev->data->dev_private;
        struct rte_flow *flow = dev_flow->flow;
@@ -5638,7 +5639,7 @@ struct field_modify_info modify_tcp[] = {
        };
        int actions_n = 0;
        bool actions_end = false;
-       struct mlx5_flow_dv_modify_hdr_resource res = {
+       struct mlx5_flow_dv_modify_hdr_resource mhdr_res = {
                .ft_type = attr->egress ? MLX5DV_FLOW_TABLE_TYPE_NIC_TX :
                                          MLX5DV_FLOW_TABLE_TYPE_NIC_RX
        };
@@ -5658,7 +5659,7 @@ struct field_modify_info modify_tcp[] = {
                return ret;
        dev_flow->group = table;
        if (attr->transfer)
-               res.ft_type = MLX5DV_FLOW_TABLE_TYPE_FDB;
+               mhdr_res.ft_type = MLX5DV_FLOW_TABLE_TYPE_FDB;
        if (priority == MLX5_FLOW_PRIO_RSVD)
                priority = priv->config.flow_prio - 1;
        for (; !actions_end ; actions++) {
@@ -5807,7 +5808,7 @@ struct field_modify_info modify_tcp[] = {
                        mlx5_update_vlan_vid_pcp(actions, &vlan);
                        /* If no VLAN push - this is a modify header action */
                        if (flow_dv_convert_action_modify_vlan_vid
-                                                       (&res, actions, error))
+                                               (&mhdr_res, actions, error))
                                return -rte_errno;
                        action_flags |= MLX5_FLOW_ACTION_OF_SET_VLAN_VID;
                        break;
@@ -5906,8 +5907,8 @@ struct field_modify_info modify_tcp[] = {
                        break;
                case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC:
                case RTE_FLOW_ACTION_TYPE_SET_MAC_DST:
-                       if (flow_dv_convert_action_modify_mac(&res, actions,
-                                                             error))
+                       if (flow_dv_convert_action_modify_mac
+                                       (&mhdr_res, actions, error))
                                return -rte_errno;
                        action_flags |= actions->type ==
                                        RTE_FLOW_ACTION_TYPE_SET_MAC_SRC ?
@@ -5916,8 +5917,8 @@ struct field_modify_info modify_tcp[] = {
                        break;
                case RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC:
                case RTE_FLOW_ACTION_TYPE_SET_IPV4_DST:
-                       if (flow_dv_convert_action_modify_ipv4(&res, actions,
-                                                              error))
+                       if (flow_dv_convert_action_modify_ipv4
+                                       (&mhdr_res, actions, error))
                                return -rte_errno;
                        action_flags |= actions->type ==
                                        RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC ?
@@ -5926,8 +5927,8 @@ struct field_modify_info modify_tcp[] = {
                        break;
                case RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC:
                case RTE_FLOW_ACTION_TYPE_SET_IPV6_DST:
-                       if (flow_dv_convert_action_modify_ipv6(&res, actions,
-                                                              error))
+                       if (flow_dv_convert_action_modify_ipv6
+                                       (&mhdr_res, actions, error))
                                return -rte_errno;
                        action_flags |= actions->type ==
                                        RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC ?
@@ -5936,9 +5937,9 @@ struct field_modify_info modify_tcp[] = {
                        break;
                case RTE_FLOW_ACTION_TYPE_SET_TP_SRC:
                case RTE_FLOW_ACTION_TYPE_SET_TP_DST:
-                       if (flow_dv_convert_action_modify_tp(&res, actions,
-                                                            items, &flow_attr,
-                                                            error))
+                       if (flow_dv_convert_action_modify_tp
+                                       (&mhdr_res, actions, items,
+                                        &flow_attr, error))
                                return -rte_errno;
                        action_flags |= actions->type ==
                                        RTE_FLOW_ACTION_TYPE_SET_TP_SRC ?
@@ -5946,23 +5947,22 @@ struct field_modify_info modify_tcp[] = {
                                        MLX5_FLOW_ACTION_SET_TP_DST;
                        break;
                case RTE_FLOW_ACTION_TYPE_DEC_TTL:
-                       if (flow_dv_convert_action_modify_dec_ttl(&res, items,
-                                                                 &flow_attr,
-                                                                 error))
+                       if (flow_dv_convert_action_modify_dec_ttl
+                                       (&mhdr_res, items, &flow_attr, error))
                                return -rte_errno;
                        action_flags |= MLX5_FLOW_ACTION_DEC_TTL;
                        break;
                case RTE_FLOW_ACTION_TYPE_SET_TTL:
-                       if (flow_dv_convert_action_modify_ttl(&res, actions,
-                                                            items, &flow_attr,
-                                                            error))
+                       if (flow_dv_convert_action_modify_ttl
+                                       (&mhdr_res, actions, items,
+                                        &flow_attr, error))
                                return -rte_errno;
                        action_flags |= MLX5_FLOW_ACTION_SET_TTL;
                        break;
                case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
                case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
-                       if (flow_dv_convert_action_modify_tcp_seq(&res, actions,
-                                                                 error))
+                       if (flow_dv_convert_action_modify_tcp_seq
+                                       (&mhdr_res, actions, error))
                                return -rte_errno;
                        action_flags |= actions->type ==
                                        RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
@@ -5972,8 +5972,8 @@ struct field_modify_info modify_tcp[] = {
 
                case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
                case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
-                       if (flow_dv_convert_action_modify_tcp_ack(&res, actions,
-                                                                 error))
+                       if (flow_dv_convert_action_modify_tcp_ack
+                                       (&mhdr_res, actions, error))
                                return -rte_errno;
                        action_flags |= actions->type ==
                                        RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
@@ -5981,14 +5981,14 @@ struct field_modify_info modify_tcp[] = {
                                        MLX5_FLOW_ACTION_DEC_TCP_ACK;
                        break;
                case MLX5_RTE_FLOW_ACTION_TYPE_TAG:
-                       if (flow_dv_convert_action_set_reg(&res, actions,
-                                                          error))
+                       if (flow_dv_convert_action_set_reg
+                                       (&mhdr_res, actions, error))
                                return -rte_errno;
                        action_flags |= MLX5_FLOW_ACTION_SET_TAG;
                        break;
                case MLX5_RTE_FLOW_ACTION_TYPE_COPY_MREG:
-                       if (flow_dv_convert_action_copy_mreg(dev, &res,
-                                                            actions, error))
+                       if (flow_dv_convert_action_copy_mreg
+                                       (dev, &mhdr_res, actions, error))
                                return -rte_errno;
                        action_flags |= MLX5_FLOW_ACTION_SET_TAG;
                        break;
@@ -5997,9 +5997,7 @@ struct field_modify_info modify_tcp[] = {
                        if (action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS) {
                                /* create modify action if needed. */
                                if (flow_dv_modify_hdr_resource_register
-                                                               (dev, &res,
-                                                                dev_flow,
-                                                                error))
+                                       (dev, &mhdr_res, dev_flow, error))
                                        return -rte_errno;
                                dev_flow->dv.actions[modify_action_position] =
                                        dev_flow->dv.modify_hdr->verbs_action;
@@ -6217,7 +6215,8 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
- * Apply the flow to the NIC.
+ * Apply the flow to the NIC, lock free,
+ * (mutex should be acquired by caller).
  *
  * @param[in] dev
  *   Pointer to the Ethernet device structure.
@@ -6230,8 +6229,8 @@ struct field_modify_info modify_tcp[] = {
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
 static int
-flow_dv_apply(struct rte_eth_dev *dev, struct rte_flow *flow,
-             struct rte_flow_error *error)
+__flow_dv_apply(struct rte_eth_dev *dev, struct rte_flow *flow,
+               struct rte_flow_error *error)
 {
        struct mlx5_flow_dv *dv;
        struct mlx5_flow *dev_flow;
@@ -6529,6 +6528,7 @@ struct field_modify_info modify_tcp[] = {
 
 /**
  * Remove the flow from the NIC but keeps it in memory.
+ * Lock free, (mutex should be acquired by caller).
  *
  * @param[in] dev
  *   Pointer to Ethernet device.
@@ -6536,7 +6536,7 @@ struct field_modify_info modify_tcp[] = {
  *   Pointer to flow structure.
  */
 static void
-flow_dv_remove(struct rte_eth_dev *dev, struct rte_flow *flow)
+__flow_dv_remove(struct rte_eth_dev *dev, struct rte_flow *flow)
 {
        struct mlx5_flow_dv *dv;
        struct mlx5_flow *dev_flow;
@@ -6564,6 +6564,7 @@ struct field_modify_info modify_tcp[] = {
 
 /**
  * Remove the flow from the NIC and the memory.
+ * Lock free, (mutex should be acquired by caller).
  *
  * @param[in] dev
  *   Pointer to the Ethernet device structure.
@@ -6571,13 +6572,13 @@ struct field_modify_info modify_tcp[] = {
  *   Pointer to flow structure.
  */
 static void
-flow_dv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow)
+__flow_dv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow)
 {
        struct mlx5_flow *dev_flow;
 
        if (!flow)
                return;
-       flow_dv_remove(dev, flow);
+       __flow_dv_remove(dev, flow);
        if (flow->counter) {
                flow_dv_counter_release(dev, flow->counter);
                flow->counter = NULL;
@@ -6688,69 +6689,69 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /*
- * Mutex-protected thunk to flow_dv_translate().
+ * Mutex-protected thunk to lock-free  __flow_dv_translate().
  */
 static int
-flow_d_translate(struct rte_eth_dev *dev,
-                struct mlx5_flow *dev_flow,
-                const struct rte_flow_attr *attr,
-                const struct rte_flow_item items[],
-                const struct rte_flow_action actions[],
-                struct rte_flow_error *error)
+flow_dv_translate(struct rte_eth_dev *dev,
+                 struct mlx5_flow *dev_flow,
+                 const struct rte_flow_attr *attr,
+                 const struct rte_flow_item items[],
+                 const struct rte_flow_action actions[],
+                 struct rte_flow_error *error)
 {
        int ret;
 
-       flow_d_shared_lock(dev);
-       ret = flow_dv_translate(dev, dev_flow, attr, items, actions, error);
-       flow_d_shared_unlock(dev);
+       flow_dv_shared_lock(dev);
+       ret = __flow_dv_translate(dev, dev_flow, attr, items, actions, error);
+       flow_dv_shared_unlock(dev);
        return ret;
 }
 
 /*
- * Mutex-protected thunk to flow_dv_apply().
+ * Mutex-protected thunk to lock-free  __flow_dv_apply().
  */
 static int
-flow_d_apply(struct rte_eth_dev *dev,
-            struct rte_flow *flow,
-            struct rte_flow_error *error)
+flow_dv_apply(struct rte_eth_dev *dev,
+             struct rte_flow *flow,
+             struct rte_flow_error *error)
 {
        int ret;
 
-       flow_d_shared_lock(dev);
-       ret = flow_dv_apply(dev, flow, error);
-       flow_d_shared_unlock(dev);
+       flow_dv_shared_lock(dev);
+       ret = __flow_dv_apply(dev, flow, error);
+       flow_dv_shared_unlock(dev);
        return ret;
 }
 
 /*
- * Mutex-protected thunk to flow_dv_remove().
+ * Mutex-protected thunk to lock-free __flow_dv_remove().
  */
 static void
-flow_d_remove(struct rte_eth_dev *dev, struct rte_flow *flow)
+flow_dv_remove(struct rte_eth_dev *dev, struct rte_flow *flow)
 {
-       flow_d_shared_lock(dev);
-       flow_dv_remove(dev, flow);
-       flow_d_shared_unlock(dev);
+       flow_dv_shared_lock(dev);
+       __flow_dv_remove(dev, flow);
+       flow_dv_shared_unlock(dev);
 }
 
 /*
- * Mutex-protected thunk to flow_dv_destroy().
+ * Mutex-protected thunk to lock-free __flow_dv_destroy().
  */
 static void
-flow_d_destroy(struct rte_eth_dev *dev, struct rte_flow *flow)
+flow_dv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow)
 {
-       flow_d_shared_lock(dev);
-       flow_dv_destroy(dev, flow);
-       flow_d_shared_unlock(dev);
+       flow_dv_shared_lock(dev);
+       __flow_dv_destroy(dev, flow);
+       flow_dv_shared_unlock(dev);
 }
 
 const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops = {
        .validate = flow_dv_validate,
        .prepare = flow_dv_prepare,
-       .translate = flow_d_translate,
-       .apply = flow_d_apply,
-       .remove = flow_d_remove,
-       .destroy = flow_d_destroy,
+       .translate = flow_dv_translate,
+       .apply = flow_dv_apply,
+       .remove = flow_dv_remove,
+       .destroy = flow_dv_destroy,
        .query = flow_dv_query,
 };
 
-- 
1.8.3.1

Reply via email to