net/mlx5: change operations for non-cached flows
[dpdk.git] / drivers / net / mlx5 / mlx5_flow.c
index 41072da..aad9689 100644 (file)
@@ -8,6 +8,7 @@
 #include <stdalign.h>
 #include <stdint.h>
 #include <string.h>
+#include <stdbool.h>
 
 /* Verbs header. */
 /* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
@@ -1836,7 +1837,6 @@ mlx5_flow_validate_item_vxlan(const struct rte_flow_item *item,
                uint32_t vlan_id;
                uint8_t vni[4];
        } id = { .vlan_id = 0, };
-       uint32_t vlan_id = 0;
 
 
        if (item_flags & MLX5_FLOW_LAYER_TUNNEL)
@@ -1863,23 +1863,8 @@ mlx5_flow_validate_item_vxlan(const struct rte_flow_item *item,
                return ret;
        if (spec) {
                memcpy(&id.vni[1], spec->vni, 3);
-               vlan_id = id.vlan_id;
                memcpy(&id.vni[1], mask->vni, 3);
-               vlan_id &= id.vlan_id;
        }
-       /*
-        * Tunnel id 0 is equivalent as not adding a VXLAN layer, if
-        * only this layer is defined in the Verbs specification it is
-        * interpreted as wildcard and all packets will match this
-        * rule, if it follows a full stack layer (ex: eth / ipv4 /
-        * udp), all packets matching the layers before will also
-        * match this rule.  To avoid such situation, VNI 0 is
-        * currently refused.
-        */
-       if (!vlan_id)
-               return rte_flow_error_set(error, ENOTSUP,
-                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
-                                         "VXLAN vni cannot be 0");
        if (!(item_flags & MLX5_FLOW_LAYER_OUTER))
                return rte_flow_error_set(error, ENOTSUP,
                                          RTE_FLOW_ERROR_TYPE_ITEM, item,
@@ -1918,7 +1903,6 @@ mlx5_flow_validate_item_vxlan_gpe(const struct rte_flow_item *item,
                uint32_t vlan_id;
                uint8_t vni[4];
        } id = { .vlan_id = 0, };
-       uint32_t vlan_id = 0;
 
        if (!priv->config.l3_vxlan_en)
                return rte_flow_error_set(error, ENOTSUP,
@@ -1956,22 +1940,8 @@ mlx5_flow_validate_item_vxlan_gpe(const struct rte_flow_item *item,
                                                  "VxLAN-GPE protocol"
                                                  " not supported");
                memcpy(&id.vni[1], spec->vni, 3);
-               vlan_id = id.vlan_id;
                memcpy(&id.vni[1], mask->vni, 3);
-               vlan_id &= id.vlan_id;
        }
-       /*
-        * Tunnel id 0 is equivalent as not adding a VXLAN layer, if only this
-        * layer is defined in the Verbs specification it is interpreted as
-        * wildcard and all packets will match this rule, if it follows a full
-        * stack layer (ex: eth / ipv4 / udp), all packets matching the layers
-        * before will also match this rule.  To avoid such situation, VNI 0
-        * is currently refused.
-        */
-       if (!vlan_id)
-               return rte_flow_error_set(error, ENOTSUP,
-                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
-                                         "VXLAN-GPE vni cannot be 0");
        if (!(item_flags & MLX5_FLOW_LAYER_OUTER))
                return rte_flow_error_set(error, ENOTSUP,
                                          RTE_FLOW_ERROR_TYPE_ITEM, item,
@@ -4480,15 +4450,25 @@ flow_list_destroy(struct rte_eth_dev *dev, struct mlx5_flows *list,
  *   Pointer to Ethernet device.
  * @param list
  *   Pointer to a TAILQ flow list.
+ * @param active
+ *   If flushing is called avtively.
  */
 void
-mlx5_flow_list_flush(struct rte_eth_dev *dev, struct mlx5_flows *list)
+mlx5_flow_list_flush(struct rte_eth_dev *dev, struct mlx5_flows *list,
+                    bool active)
 {
+       uint32_t num_flushed = 0;
+
        while (!TAILQ_EMPTY(list)) {
                struct rte_flow *flow;
 
                flow = TAILQ_FIRST(list);
                flow_list_destroy(dev, list, flow);
+               num_flushed++;
+       }
+       if (active) {
+               DRV_LOG(INFO, "port %u: %u flows flushed before stopping",
+                       dev->data->port_id, num_flushed);
        }
 }
 
@@ -4553,6 +4533,37 @@ error:
        return -rte_errno;
 }
 
+/**
+ * Stop all default actions for flows.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ * @param list
+ *   Pointer to a TAILQ flow list.
+ */
+void
+mlx5_flow_stop_default(struct rte_eth_dev *dev)
+{
+       flow_mreg_del_default_copy_action(dev);
+}
+
+/**
+ * Start all default actions for flows.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_flow_start_default(struct rte_eth_dev *dev)
+{
+       struct rte_flow_error error;
+
+       /* Make sure default copy action (reg_c[0] -> reg_b) is created. */
+       return flow_mreg_add_default_copy_action(dev, &error);
+}
+
 /**
  * Verify the flow list is empty
  *
@@ -4768,7 +4779,7 @@ mlx5_flow_flush(struct rte_eth_dev *dev,
 {
        struct mlx5_priv *priv = dev->data->dev_private;
 
-       mlx5_flow_list_flush(dev, &priv->flows);
+       mlx5_flow_list_flush(dev, &priv->flows, false);
        return 0;
 }
 
@@ -5210,7 +5221,7 @@ flow_fdir_filter_flush(struct rte_eth_dev *dev)
 {
        struct mlx5_priv *priv = dev->data->dev_private;
 
-       mlx5_flow_list_flush(dev, &priv->flows);
+       mlx5_flow_list_flush(dev, &priv->flows, false);
 }
 
 /**