]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/net/ethernet/mellanox/mlx5/core/en_main.c
bpf: mlx5e: Report bpf_prog ID during XDP_QUERY_PROG
[linux.git] / drivers / net / ethernet / mellanox / mlx5 / core / en_main.c
index 41cd22a223dccbd9dae460331525a1fc2414be9e..c8f3aefe735d192aa4f4f808eec0645c964fdc6c 100644 (file)
@@ -252,9 +252,9 @@ static void mlx5e_update_pport_counters(struct mlx5e_priv *priv)
        void *out;
        u32 *in;
 
-       in = mlx5_vzalloc(sz);
+       in = kvzalloc(sz, GFP_KERNEL);
        if (!in)
-               goto free_out;
+               return;
 
        MLX5_SET(ppcnt_reg, in, local_port, 1);
 
@@ -288,7 +288,6 @@ static void mlx5e_update_pport_counters(struct mlx5e_priv *priv)
                                     MLX5_REG_PPCNT, 0, 0);
        }
 
-free_out:
        kvfree(in);
 }
 
@@ -314,7 +313,7 @@ static void mlx5e_update_pcie_counters(struct mlx5e_priv *priv)
        if (!MLX5_CAP_MCAM_FEATURE(mdev, pcie_performance_group))
                return;
 
-       in = mlx5_vzalloc(sz);
+       in = kvzalloc(sz, GFP_KERNEL);
        if (!in)
                return;
 
@@ -503,7 +502,7 @@ static int mlx5e_create_umr_mkey(struct mlx5_core_dev *mdev,
        if (!MLX5E_VALID_NUM_MTTS(npages))
                return -EINVAL;
 
-       in = mlx5_vzalloc(inlen);
+       in = kvzalloc(inlen, GFP_KERNEL);
        if (!in)
                return -ENOMEM;
 
@@ -711,7 +710,7 @@ static int mlx5e_create_rq(struct mlx5e_rq *rq,
 
        inlen = MLX5_ST_SZ_BYTES(create_rq_in) +
                sizeof(u64) * rq->wq_ctrl.buf.npages;
-       in = mlx5_vzalloc(inlen);
+       in = kvzalloc(inlen, GFP_KERNEL);
        if (!in)
                return -ENOMEM;
 
@@ -748,7 +747,7 @@ static int mlx5e_modify_rq_state(struct mlx5e_rq *rq, int curr_state,
        int err;
 
        inlen = MLX5_ST_SZ_BYTES(modify_rq_in);
-       in = mlx5_vzalloc(inlen);
+       in = kvzalloc(inlen, GFP_KERNEL);
        if (!in)
                return -ENOMEM;
 
@@ -776,7 +775,7 @@ static int mlx5e_modify_rq_scatter_fcs(struct mlx5e_rq *rq, bool enable)
        int err;
 
        inlen = MLX5_ST_SZ_BYTES(modify_rq_in);
-       in = mlx5_vzalloc(inlen);
+       in = kvzalloc(inlen, GFP_KERNEL);
        if (!in)
                return -ENOMEM;
 
@@ -805,7 +804,7 @@ static int mlx5e_modify_rq_vsd(struct mlx5e_rq *rq, bool vsd)
        int err;
 
        inlen = MLX5_ST_SZ_BYTES(modify_rq_in);
-       in = mlx5_vzalloc(inlen);
+       in = kvzalloc(inlen, GFP_KERNEL);
        if (!in)
                return -ENOMEM;
 
@@ -1134,7 +1133,7 @@ static int mlx5e_create_sq(struct mlx5_core_dev *mdev,
 
        inlen = MLX5_ST_SZ_BYTES(create_sq_in) +
                sizeof(u64) * csp->wq_ctrl->buf.npages;
-       in = mlx5_vzalloc(inlen);
+       in = kvzalloc(inlen, GFP_KERNEL);
        if (!in)
                return -ENOMEM;
 
@@ -1182,7 +1181,7 @@ static int mlx5e_modify_sq(struct mlx5_core_dev *mdev, u32 sqn,
        int err;
 
        inlen = MLX5_ST_SZ_BYTES(modify_sq_in);
-       in = mlx5_vzalloc(inlen);
+       in = kvzalloc(inlen, GFP_KERNEL);
        if (!in)
                return -ENOMEM;
 
@@ -1496,7 +1495,7 @@ static int mlx5e_create_cq(struct mlx5e_cq *cq, struct mlx5e_cq_param *param)
 
        inlen = MLX5_ST_SZ_BYTES(create_cq_in) +
                sizeof(u64) * cq->wq_ctrl.frag_buf.npages;
-       in = mlx5_vzalloc(inlen);
+       in = kvzalloc(inlen, GFP_KERNEL);
        if (!in)
                return -ENOMEM;
 
@@ -2091,7 +2090,7 @@ mlx5e_create_rqt(struct mlx5e_priv *priv, int sz, struct mlx5e_rqt *rqt)
        int i;
 
        inlen = MLX5_ST_SZ_BYTES(create_rqt_in) + sizeof(u32) * sz;
-       in = mlx5_vzalloc(inlen);
+       in = kvzalloc(inlen, GFP_KERNEL);
        if (!in)
                return -ENOMEM;
 
@@ -2210,7 +2209,7 @@ int mlx5e_redirect_rqt(struct mlx5e_priv *priv, u32 rqtn, int sz,
        int err;
 
        inlen = MLX5_ST_SZ_BYTES(modify_rqt_in) + sizeof(u32) * sz;
-       in = mlx5_vzalloc(inlen);
+       in = kvzalloc(inlen, GFP_KERNEL);
        if (!in)
                return -ENOMEM;
 
@@ -2433,7 +2432,7 @@ static int mlx5e_modify_tirs_lro(struct mlx5e_priv *priv)
        int ix;
 
        inlen = MLX5_ST_SZ_BYTES(modify_tir_in);
-       in = mlx5_vzalloc(inlen);
+       in = kvzalloc(inlen, GFP_KERNEL);
        if (!in)
                return -ENOMEM;
 
@@ -2850,7 +2849,7 @@ int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv)
        int tt;
 
        inlen = MLX5_ST_SZ_BYTES(create_tir_in);
-       in = mlx5_vzalloc(inlen);
+       in = kvzalloc(inlen, GFP_KERNEL);
        if (!in)
                return -ENOMEM;
 
@@ -2889,7 +2888,7 @@ int mlx5e_create_direct_tirs(struct mlx5e_priv *priv)
        int ix;
 
        inlen = MLX5_ST_SZ_BYTES(create_tir_in);
-       in = mlx5_vzalloc(inlen);
+       in = kvzalloc(inlen, GFP_KERNEL);
        if (!in)
                return -ENOMEM;
 
@@ -2992,13 +2991,17 @@ static int mlx5e_setup_tc(struct net_device *netdev, u8 tc)
 }
 
 static int mlx5e_ndo_setup_tc(struct net_device *dev, u32 handle,
-                             __be16 proto, struct tc_to_netdev *tc)
+                             u32 chain_index, __be16 proto,
+                             struct tc_to_netdev *tc)
 {
        struct mlx5e_priv *priv = netdev_priv(dev);
 
        if (TC_H_MAJ(handle) != TC_H_MAJ(TC_H_INGRESS))
                goto mqprio;
 
+       if (chain_index)
+               return -EOPNOTSUPP;
+
        switch (tc->type) {
        case TC_SETUP_CLSFLOWER:
                switch (tc->cls_flower->command) {
@@ -3596,11 +3599,19 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)
        return err;
 }
 
-static bool mlx5e_xdp_attached(struct net_device *dev)
+static u32 mlx5e_xdp_query(struct net_device *dev)
 {
        struct mlx5e_priv *priv = netdev_priv(dev);
+       const struct bpf_prog *xdp_prog;
+       u32 prog_id = 0;
+
+       mutex_lock(&priv->state_lock);
+       xdp_prog = priv->channels.params.xdp_prog;
+       if (xdp_prog)
+               prog_id = xdp_prog->aux->id;
+       mutex_unlock(&priv->state_lock);
 
-       return !!priv->channels.params.xdp_prog;
+       return prog_id;
 }
 
 static int mlx5e_xdp(struct net_device *dev, struct netdev_xdp *xdp)
@@ -3609,7 +3620,8 @@ static int mlx5e_xdp(struct net_device *dev, struct netdev_xdp *xdp)
        case XDP_SETUP_PROG:
                return mlx5e_xdp_set(dev, xdp->prog);
        case XDP_QUERY_PROG:
-               xdp->prog_attached = mlx5e_xdp_attached(dev);
+               xdp->prog_id = mlx5e_xdp_query(dev);
+               xdp->prog_attached = !!xdp->prog_id;
                return 0;
        default:
                return -EINVAL;