ethdev: separate driver APIs
[dpdk.git] / drivers / net / mlx5 / mlx5_flow.c
index 1eda836..13b6483 100644 (file)
 #pragma GCC diagnostic error "-Wpedantic"
 #endif
 
-#include <rte_ethdev.h>
+#include <rte_ethdev_driver.h>
 #include <rte_flow.h>
 #include <rte_flow_driver.h>
 #include <rte_malloc.h>
+#include <rte_ip.h>
 
 #include "mlx5.h"
+#include "mlx5_defs.h"
 #include "mlx5_prm.h"
 
 /* Define minimal priority for control plane flows. */
@@ -429,6 +431,7 @@ static const struct mlx5_flow_items mlx5_flow_items[] = {
 /** Structure to pass to the conversion function. */
 struct mlx5_flow_parse {
        uint32_t inner; /**< Set once VXLAN is encountered. */
+       uint32_t allmulti:1; /**< Set once allmulti dst MAC is encountered. */
        uint32_t create:1;
        /**< Whether resources should remain after a validate. */
        uint32_t drop:1; /**< Target is a drop queue. */
@@ -567,9 +570,15 @@ priv_flow_convert_rss_conf(struct priv *priv,
                           struct mlx5_flow_parse *parser,
                           const struct rte_eth_rss_conf *rss_conf)
 {
-       const struct rte_eth_rss_conf *rss =
-               rss_conf ? rss_conf : &priv->rss_conf;
+       const struct rte_eth_rss_conf *rss;
 
+       if (rss_conf) {
+               if (rss_conf->rss_hf & MLX5_RSS_HF_MASK)
+                       return EINVAL;
+               rss = rss_conf;
+       } else {
+               rss = &priv->rss_conf;
+       }
        if (rss->rss_key_len > 40)
                return EINVAL;
        parser->rss_conf.rss_key_len = rss->rss_key_len;
@@ -770,7 +779,7 @@ priv_flow_convert_actions(struct priv *priv,
                } else if (actions->type == RTE_FLOW_ACTION_TYPE_FLAG) {
                        parser->mark = 1;
                } else if (actions->type == RTE_FLOW_ACTION_TYPE_COUNT &&
-                          priv->counter_set_supported) {
+                          priv->config.flow_counter_en) {
                        parser->count = 1;
                } else {
                        goto exit_action_not_supported;
@@ -860,6 +869,10 @@ priv_flow_convert_items_validate(struct priv *priv,
                                parser->queue[n].offset += cur_item->dst_sz;
                }
        }
+       if (parser->drop) {
+               parser->queue[HASH_RXQ_ETH].offset +=
+                       sizeof(struct ibv_flow_spec_action_drop);
+       }
        if (parser->mark) {
                for (i = 0; i != hash_rxq_init_n; ++i)
                        parser->queue[i].offset +=
@@ -1165,6 +1178,17 @@ exit_free:
                        }
                }
        }
+       if (parser->allmulti &&
+           parser->layer == HASH_RXQ_ETH) {
+               for (i = 0; i != hash_rxq_init_n; ++i) {
+                       if (!parser->queue[i].ibv_attr)
+                               continue;
+                       if (parser->queue[i].ibv_attr->num_of_specs != 1)
+                               break;
+                       parser->queue[i].ibv_attr->type =
+                                               IBV_FLOW_ATTR_MC_DEFAULT;
+               }
+       }
        return ret;
 exit_enomem:
        for (i = 0; i != hash_rxq_init_n; ++i) {
@@ -1262,6 +1286,7 @@ mlx5_flow_create_eth(const struct rte_flow_item *item,
                eth.val.ether_type &= eth.mask.ether_type;
        }
        mlx5_flow_create_copy(parser, &eth, eth_size);
+       parser->allmulti = eth.val.dst_mac[0] & 1;
        return 0;
 }
 
@@ -1386,6 +1411,8 @@ mlx5_flow_create_ipv6(const struct rte_flow_item *item,
                parser->layer = HASH_RXQ_IPV6;
        if (spec) {
                unsigned int i;
+               uint32_t vtc_flow_val;
+               uint32_t vtc_flow_mask;
 
                if (!mask)
                        mask = default_mask;
@@ -1397,7 +1424,20 @@ mlx5_flow_create_ipv6(const struct rte_flow_item *item,
                       RTE_DIM(ipv6.mask.src_ip));
                memcpy(&ipv6.mask.dst_ip, mask->hdr.dst_addr,
                       RTE_DIM(ipv6.mask.dst_ip));
-               ipv6.mask.flow_label = mask->hdr.vtc_flow;
+               vtc_flow_val = rte_be_to_cpu_32(spec->hdr.vtc_flow);
+               vtc_flow_mask = rte_be_to_cpu_32(mask->hdr.vtc_flow);
+               ipv6.val.flow_label =
+                       rte_cpu_to_be_32((vtc_flow_val & IPV6_HDR_FL_MASK) >>
+                                        IPV6_HDR_FL_SHIFT);
+               ipv6.val.traffic_class = (vtc_flow_val & IPV6_HDR_TC_MASK) >>
+                                        IPV6_HDR_TC_SHIFT;
+               ipv6.val.next_hdr = spec->hdr.proto;
+               ipv6.val.hop_limit = spec->hdr.hop_limits;
+               ipv6.mask.flow_label =
+                       rte_cpu_to_be_32((vtc_flow_mask & IPV6_HDR_FL_MASK) >>
+                                        IPV6_HDR_FL_SHIFT);
+               ipv6.mask.traffic_class = (vtc_flow_mask & IPV6_HDR_TC_MASK) >>
+                                         IPV6_HDR_TC_SHIFT;
                ipv6.mask.next_hdr = mask->hdr.proto;
                ipv6.mask.hop_limit = mask->hdr.hop_limits;
                /* Remove unwanted bits from values. */
@@ -1406,6 +1446,7 @@ mlx5_flow_create_ipv6(const struct rte_flow_item *item,
                        ipv6.val.dst_ip[i] &= ipv6.mask.dst_ip[i];
                }
                ipv6.val.flow_label &= ipv6.mask.flow_label;
+               ipv6.val.traffic_class &= ipv6.mask.traffic_class;
                ipv6.val.next_hdr &= ipv6.mask.next_hdr;
                ipv6.val.hop_limit &= ipv6.mask.hop_limit;
        }