IB/mlx5: Enable WQ creation and modification with cvlan offload
authorNoa Osherovich <noaos@mellanox.com>
Wed, 18 Jan 2017 13:40:02 +0000 (15:40 +0200)
committerDoug Ledford <dledford@redhat.com>
Tue, 14 Feb 2017 16:41:14 +0000 (11:41 -0500)
Allow creating a WQ with cvlan stripping considering device's
capabilities. The default value was fixed to disable vlan stripping
till was asked explicitly.

In addition, allow modification of a WQ to turn on/off this property.

Signed-off-by: Noa Osherovich <noaos@mellanox.com>
Reviewed-by: Maor Gottlieb <maorg@mellanox.com>
Reviewed-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/mlx5/qp.c

index f395ee9d2fea3dcfaa7b4eaa26392a373e98f4de..59bbe246c92d441dc4a705275c2be0ed3c102671 100644 (file)
@@ -4624,9 +4624,20 @@ static int  create_rq(struct mlx5_ib_rwq *rwq, struct ib_pd *pd,
        MLX5_SET(wq, wq, log_wq_pg_sz, rwq->log_page_size);
        MLX5_SET(wq, wq, wq_signature, rwq->wq_sig);
        MLX5_SET64(wq, wq, dbr_addr, rwq->db.dma);
+       if (init_attr->create_flags & IB_WQ_FLAGS_CVLAN_STRIPPING) {
+               if (!(MLX5_CAP_GEN(dev->mdev, eth_net_offloads) &&
+                     MLX5_CAP_ETH(dev->mdev, vlan_cap))) {
+                       mlx5_ib_dbg(dev, "VLAN offloads are not supported\n");
+                       err = -EOPNOTSUPP;
+                       goto out;
+               }
+       } else {
+               MLX5_SET(rqc, rqc, vsd, 1);
+       }
        rq_pas0 = (__be64 *)MLX5_ADDR_OF(wq, wq, pas);
        mlx5_ib_populate_pas(dev, rwq->umem, rwq->page_shift, rq_pas0, 0);
        err = mlx5_core_create_rq_tracked(dev->mdev, in, inlen, &rwq->core_qp);
+out:
        kvfree(in);
        return err;
 }
@@ -4910,6 +4921,22 @@ int mlx5_ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr,
        MLX5_SET(modify_rq_in, in, rq_state, curr_wq_state);
        MLX5_SET(rqc, rqc, state, wq_state);
 
+       if (wq_attr_mask & IB_WQ_FLAGS) {
+               if (wq_attr->flags_mask & IB_WQ_FLAGS_CVLAN_STRIPPING) {
+                       if (!(MLX5_CAP_GEN(dev->mdev, eth_net_offloads) &&
+                             MLX5_CAP_ETH(dev->mdev, vlan_cap))) {
+                               mlx5_ib_dbg(dev, "VLAN offloads are not "
+                                           "supported\n");
+                               err = -EOPNOTSUPP;
+                               goto out;
+                       }
+                       MLX5_SET64(modify_rq_in, in, modify_bitmask,
+                                  MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_VSD);
+                       MLX5_SET(rqc, rqc, vsd,
+                                (wq_attr->flags & IB_WQ_FLAGS_CVLAN_STRIPPING) ? 0 : 1);
+               }
+       }
+
        if (curr_wq_state == IB_WQS_RESET && wq_state == IB_WQS_RDY) {
                if (MLX5_CAP_GEN(dev->mdev, modify_rq_counter_set_id)) {
                        MLX5_SET64(modify_rq_in, in, modify_bitmask,
@@ -4921,9 +4948,10 @@ int mlx5_ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr,
        }
 
        err = mlx5_core_modify_rq(dev->mdev, rwq->core_qp.qpn, in, inlen);
-       kvfree(in);
        if (!err)
                rwq->ibwq.state = (wq_state == MLX5_RQC_STATE_ERR) ? IB_WQS_ERR : wq_state;
 
+out:
+       kvfree(in);
        return err;
 }