Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
[sfrench/cifs-2.6.git] / drivers / net / ethernet / mellanox / mlx5 / core / en_fs_ethtool.c
index 839662644ed382856878ffe6dee95626dd9709ee..ea3a490b569a58c46b49196b3637bec4923b7843 100644 (file)
@@ -32,6 +32,8 @@
 
 #include <linux/mlx5/fs.h>
 #include "en.h"
+#include "en/params.h"
+#include "en/xsk/umem.h"
 
 struct mlx5e_ethtool_rule {
        struct list_head             list;
@@ -414,6 +416,14 @@ add_ethtool_flow_rule(struct mlx5e_priv *priv,
        if (fs->ring_cookie == RX_CLS_FLOW_DISC) {
                flow_act.action = MLX5_FLOW_CONTEXT_ACTION_DROP;
        } else {
+               struct mlx5e_params *params = &priv->channels.params;
+               enum mlx5e_rq_group group;
+               struct mlx5e_tir *tir;
+               u16 ix;
+
+               mlx5e_qid_get_ch_and_group(params, fs->ring_cookie, &ix, &group);
+               tir = group == MLX5E_RQ_GROUP_XSK ? priv->xsk_tir : priv->direct_tir;
+
                dst = kzalloc(sizeof(*dst), GFP_KERNEL);
                if (!dst) {
                        err = -ENOMEM;
@@ -421,7 +431,7 @@ add_ethtool_flow_rule(struct mlx5e_priv *priv,
                }
 
                dst->type = MLX5_FLOW_DESTINATION_TYPE_TIR;
-               dst->tir_num = priv->direct_tir[fs->ring_cookie].tirn;
+               dst->tir_num = tir[ix].tirn;
                flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
        }
 
@@ -600,9 +610,9 @@ static int validate_flow(struct mlx5e_priv *priv,
        if (fs->location >= MAX_NUM_OF_ETHTOOL_RULES)
                return -ENOSPC;
 
-       if (fs->ring_cookie >= priv->channels.params.num_channels &&
-           fs->ring_cookie != RX_CLS_FLOW_DISC)
-               return -EINVAL;
+       if (fs->ring_cookie != RX_CLS_FLOW_DISC)
+               if (!mlx5e_qid_validate(&priv->channels.params, fs->ring_cookie))
+                       return -EINVAL;
 
        switch (fs->flow_type & ~(FLOW_EXT | FLOW_MAC_EXT)) {
        case ETHER_FLOW: