net/mlx5: fix meter policy creation assert
[dpdk.git] / drivers / net / mlx5 / mlx5_flow.c
index ab48c52..15a4a8c 100644 (file)
@@ -175,6 +175,9 @@ mlx5_nsh_proto_to_item_type(uint8_t proto_spec, uint8_t proto_mask)
        enum rte_flow_item_type type;
 
        switch (proto_mask & proto_spec) {
+       case 0:
+               type = RTE_FLOW_ITEM_TYPE_VOID;
+               break;
        case RTE_VXLAN_GPE_TYPE_IPV4:
                type = RTE_FLOW_ITEM_TYPE_IPV4;
                break;
@@ -196,13 +199,16 @@ mlx5_inet_proto_to_item_type(uint8_t proto_spec, uint8_t proto_mask)
        enum rte_flow_item_type type;
 
        switch (proto_mask & proto_spec) {
+       case 0:
+               type = RTE_FLOW_ITEM_TYPE_VOID;
+               break;
        case IPPROTO_UDP:
                type = RTE_FLOW_ITEM_TYPE_UDP;
                break;
        case IPPROTO_TCP:
                type = RTE_FLOW_ITEM_TYPE_TCP;
                break;
-       case IPPROTO_IP:
+       case IPPROTO_IPIP:
                type = RTE_FLOW_ITEM_TYPE_IPV4;
                break;
        case IPPROTO_IPV6:
@@ -221,6 +227,9 @@ mlx5_ethertype_to_item_type(rte_be16_t type_spec,
        enum rte_flow_item_type type;
 
        switch (rte_be_to_cpu_16(type_spec & type_mask)) {
+       case 0:
+               type = RTE_FLOW_ITEM_TYPE_VOID;
+               break;
        case RTE_ETHER_TYPE_TEB:
                type = is_tunnel ?
                       RTE_FLOW_ITEM_TYPE_ETH : RTE_FLOW_ITEM_TYPE_END;
@@ -1743,6 +1752,12 @@ mlx5_flow_validate_action_queue(const struct rte_flow_action *action,
                                          RTE_FLOW_ERROR_TYPE_ACTION, NULL,
                                          "can't have 2 fate actions in"
                                          " same flow");
+       if (attr->egress)
+               return rte_flow_error_set(error, ENOTSUP,
+                                         RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL,
+                                         "queue action not supported for egress.");
+       if (mlx5_is_external_rxq(dev, queue->index))
+               return 0;
        if (!priv->rxqs_n)
                return rte_flow_error_set(error, EINVAL,
                                          RTE_FLOW_ERROR_TYPE_ACTION_CONF,
@@ -1757,11 +1772,6 @@ mlx5_flow_validate_action_queue(const struct rte_flow_action *action,
                                          RTE_FLOW_ERROR_TYPE_ACTION_CONF,
                                          &queue->index,
                                          "queue is not configured");
-       if (attr->egress)
-               return rte_flow_error_set(error, ENOTSUP,
-                                         RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL,
-                                         "queue action not supported for "
-                                         "egress");
        return 0;
 }
 
@@ -1776,7 +1786,7 @@ mlx5_flow_validate_action_queue(const struct rte_flow_action *action,
  *   Size of the @p queues array.
  * @param[out] error
  *   On error, filled with a textual error description.
- * @param[out] queue
+ * @param[out] queue_idx
  *   On error, filled with an offending queue index in @p queues array.
  *
  * @return
@@ -1789,17 +1799,27 @@ mlx5_validate_rss_queues(struct rte_eth_dev *dev,
 {
        const struct mlx5_priv *priv = dev->data->dev_private;
        bool is_hairpin = false;
+       bool is_ext_rss = false;
        uint32_t i;
 
        for (i = 0; i != queues_n; ++i) {
-               struct mlx5_rxq_ctrl *rxq_ctrl = mlx5_rxq_ctrl_get(dev,
-                                                                  queues[i]);
+               struct mlx5_rxq_ctrl *rxq_ctrl;
 
+               if (mlx5_is_external_rxq(dev, queues[0])) {
+                       is_ext_rss = true;
+                       continue;
+               }
+               if (is_ext_rss) {
+                       *error = "Combining external and regular RSS queues is not supported";
+                       *queue_idx = i;
+                       return -ENOTSUP;
+               }
                if (queues[i] >= priv->rxqs_n) {
                        *error = "queue index out of range";
                        *queue_idx = i;
                        return -EINVAL;
                }
+               rxq_ctrl = mlx5_rxq_ctrl_get(dev, queues[i]);
                if (rxq_ctrl == NULL) {
                        *error =  "queue is not configured";
                        *queue_idx = i;
@@ -1894,7 +1914,7 @@ mlx5_validate_action_rss(struct rte_eth_dev *dev,
                                          RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL,
                                          "L4 partial RSS requested but L4 RSS"
                                          " type not specified");
-       if (!priv->rxqs_n)
+       if (!priv->rxqs_n && priv->ext_rxqs == NULL)
                return rte_flow_error_set(error, EINVAL,
                                          RTE_FLOW_ERROR_TYPE_ACTION_CONF,
                                          NULL, "No Rx queues configured");
@@ -6276,6 +6296,8 @@ flow_create_split_meter(struct rte_eth_dev *dev,
                                                                  fm->policy_id,
                                                                  NULL);
                        MLX5_ASSERT(wks->policy);
+                       if (wks->policy->mark)
+                               wks->mark = 1;
                        if (wks->policy->is_hierarchy) {
                                wks->final_policy =
                                mlx5_flow_meter_hierarchy_get_final_policy(dev,