net/mlx5: fix packet length assert in MPRQ
[dpdk.git] / drivers / net / mlx5 / mlx5_flow.c
index 109d71e..e9ae2f7 100644 (file)
@@ -894,6 +894,35 @@ flow_rxq_flags_clear(struct rte_eth_dev *dev)
        }
 }
 
+/**
+ * Set the Rx queue dynamic metadata (mask and offset) for a flow
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ */
+void
+mlx5_flow_rxq_dynf_metadata_set(struct rte_eth_dev *dev)
+{
+       struct mlx5_priv *priv = dev->data->dev_private;
+       struct mlx5_rxq_data *data;
+       unsigned int i;
+
+       for (i = 0; i != priv->rxqs_n; ++i) {
+               if (!(*priv->rxqs)[i])
+                       continue;
+               data = (*priv->rxqs)[i];
+               if (!rte_flow_dynf_metadata_avail()) {
+                       data->dynf_meta = 0;
+                       data->flow_meta_mask = 0;
+                       data->flow_meta_offset = -1;
+               } else {
+                       data->dynf_meta = 1;
+                       data->flow_meta_mask = rte_flow_dynf_metadata_mask;
+                       data->flow_meta_offset = rte_flow_dynf_metadata_offs;
+               }
+       }
+}
+
 /*
  * return a pointer to the desired action in the list of actions.
  *
@@ -2342,6 +2371,7 @@ flow_null_validate(struct rte_eth_dev *dev __rte_unused,
                   const struct rte_flow_item items[] __rte_unused,
                   const struct rte_flow_action actions[] __rte_unused,
                   bool external __rte_unused,
+                  int hairpin __rte_unused,
                   struct rte_flow_error *error)
 {
        return rte_flow_error_set(error, ENOTSUP,
@@ -2457,6 +2487,8 @@ flow_get_drv_type(struct rte_eth_dev *dev, const struct rte_flow_attr *attr)
  *   Pointer to the list of actions.
  * @param[in] external
  *   This flow rule is created by request external to PMD.
+ * @param[in] hairpin
+ *   Number of hairpin TX actions, 0 means classic flow.
  * @param[out] error
  *   Pointer to the error structure.
  *
@@ -2468,13 +2500,14 @@ flow_drv_validate(struct rte_eth_dev *dev,
                  const struct rte_flow_attr *attr,
                  const struct rte_flow_item items[],
                  const struct rte_flow_action actions[],
-                 bool external, struct rte_flow_error *error)
+                 bool external, int hairpin, struct rte_flow_error *error)
 {
        const struct mlx5_flow_driver_ops *fops;
        enum mlx5_flow_drv_type type = flow_get_drv_type(dev, attr);
 
        fops = flow_get_drv_ops(type);
-       return fops->validate(dev, attr, items, actions, external, error);
+       return fops->validate(dev, attr, items, actions, external,
+                             hairpin, error);
 }
 
 /**
@@ -2635,27 +2668,6 @@ flow_drv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow)
        fops->destroy(dev, flow);
 }
 
-/**
- * Validate a flow supported by the NIC.
- *
- * @see rte_flow_validate()
- * @see rte_flow_ops
- */
-int
-mlx5_flow_validate(struct rte_eth_dev *dev,
-                  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;
-
-       ret = flow_drv_validate(dev, attr, items, actions, true, error);
-       if (ret < 0)
-               return ret;
-       return 0;
-}
-
 /**
  * Get RSS action from the action list.
  *
@@ -4271,15 +4283,16 @@ flow_list_create(struct rte_eth_dev *dev, uint32_t *list,
        const struct rte_flow_action *p_actions_rx = actions;
        uint32_t i;
        uint32_t idx = 0;
-       int hairpin_flow = 0;
+       int hairpin_flow;
        uint32_t hairpin_id = 0;
        struct rte_flow_attr attr_tx = { .priority = 0 };
-       int ret = flow_drv_validate(dev, attr, items, p_actions_rx, external,
-                                   error);
+       int ret;
 
+       hairpin_flow = flow_check_hairpin_split(dev, attr, actions);
+       ret = flow_drv_validate(dev, attr, items, p_actions_rx,
+                               external, hairpin_flow, error);
        if (ret < 0)
                return 0;
-       hairpin_flow = flow_check_hairpin_split(dev, attr, actions);
        if (hairpin_flow > 0) {
                if (hairpin_flow > MLX5_MAX_SPLIT_ACTIONS) {
                        rte_errno = EINVAL;
@@ -4470,6 +4483,26 @@ mlx5_flow_create_esw_table_zero_flow(struct rte_eth_dev *dev)
                                                   actions, false, &error);
 }
 
+/**
+ * Validate a flow supported by the NIC.
+ *
+ * @see rte_flow_validate()
+ * @see rte_flow_ops
+ */
+int
+mlx5_flow_validate(struct rte_eth_dev *dev,
+                  const struct rte_flow_attr *attr,
+                  const struct rte_flow_item items[],
+                  const struct rte_flow_action actions[],
+                  struct rte_flow_error *error)
+{
+       int hairpin_flow;
+
+       hairpin_flow = flow_check_hairpin_split(dev, attr, actions);
+       return flow_drv_validate(dev, attr, items, actions,
+                               true, hairpin_flow, error);
+}
+
 /**
  * Create a flow.
  *
@@ -4491,9 +4524,12 @@ mlx5_flow_create(struct rte_eth_dev *dev,
         * are not affected.
         */
        if (unlikely(!dev->data->dev_started)) {
-               rte_errno = ENODEV;
                DRV_LOG(DEBUG, "port %u is not started when "
                        "inserting a flow", dev->data->port_id);
+               rte_flow_error_set(error, ENODEV,
+                                  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+                                  NULL,
+                                  "port not started");
                return NULL;
        }
        return (void *)(uintptr_t)flow_list_create(dev, &priv->flows,
@@ -4654,6 +4690,7 @@ void
 mlx5_flow_stop_default(struct rte_eth_dev *dev)
 {
        flow_mreg_del_default_copy_action(dev);
+       flow_rxq_flags_clear(dev);
 }
 
 /**