RDMA/mlx5: Replace struct mlx5_core_mkey by u32 key
authorAharon Landau <aharonl@nvidia.com>
Tue, 12 Oct 2021 10:26:33 +0000 (13:26 +0300)
committerLeon Romanovsky <leonro@nvidia.com>
Tue, 19 Oct 2021 11:34:12 +0000 (14:34 +0300)
In mlx5_core and vdpa there is no use of mlx5_core_mkey members except
for the key itself.

As preparation for moving mlx5_core_mkey to mlx5_ib, the occurrences of
struct mlx5_core_mkey in all modules except for mlx5_ib are replaced by
a u32 key.

Signed-off-by: Aharon Landau <aharonl@nvidia.com>
Reviewed-by: Shay Drory <shayd@nvidia.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
21 files changed:
drivers/infiniband/hw/mlx5/mr.c
drivers/infiniband/hw/mlx5/odp.c
drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c
drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.h
drivers/net/ethernet/mellanox/mlx5/core/diag/rsc_dump.c
drivers/net/ethernet/mellanox/mlx5/core/en.h
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
drivers/net/ethernet/mellanox/mlx5/core/en/trap.c
drivers/net/ethernet/mellanox/mlx5/core/en_common.c
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
drivers/net/ethernet/mellanox/mlx5/core/fpga/core.h
drivers/net/ethernet/mellanox/mlx5/core/mr.c
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h
drivers/vdpa/mlx5/core/mlx5_vdpa.h
drivers/vdpa/mlx5/core/mr.c
drivers/vdpa/mlx5/core/resources.c
drivers/vdpa/mlx5/net/mlx5_vnet.c
include/linux/mlx5/driver.h

index 9d7f1cadaa7657d67ffbe630689ddea7f881d85a..e2f020472ae20e5f00986533241bd06237a4133a 100644 (file)
@@ -104,8 +104,14 @@ static int
 mlx5_ib_create_mkey(struct mlx5_ib_dev *dev, struct mlx5_core_mkey *mkey,
                    u32 *in, int inlen)
 {
+       int ret;
+
        assign_mkey_variant(dev, mkey, in);
-       return mlx5_core_create_mkey(dev->mdev, mkey, in, inlen);
+       ret = mlx5_core_create_mkey(dev->mdev, &mkey->key, in, inlen);
+       if (!ret)
+               init_waitqueue_head(&mkey->wait);
+
+       return ret;
 }
 
 static int
@@ -133,7 +139,7 @@ static int destroy_mkey(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr)
 {
        WARN_ON(xa_load(&dev->odp_mkeys, mlx5_base_mkey(mr->mmkey.key)));
 
-       return mlx5_core_destroy_mkey(dev->mdev, &mr->mmkey);
+       return mlx5_core_destroy_mkey(dev->mdev, mr->mmkey.key);
 }
 
 static void create_mkey_callback(int status, struct mlx5_async_work *context)
@@ -260,10 +266,11 @@ static struct mlx5_ib_mr *create_cache_mr(struct mlx5_cache_ent *ent)
                goto free_in;
        }
 
-       err = mlx5_core_create_mkey(ent->dev->mdev, &mr->mmkey, in, inlen);
+       err = mlx5_core_create_mkey(ent->dev->mdev, &mr->mmkey.key, in, inlen);
        if (err)
                goto free_mr;
 
+       init_waitqueue_head(&mr->mmkey.wait);
        mr->mmkey.type = MLX5_MKEY_MR;
        WRITE_ONCE(ent->dev->cache.last_add, jiffies);
        spin_lock_irq(&ent->lock);
@@ -290,7 +297,7 @@ static void remove_cache_mr_locked(struct mlx5_cache_ent *ent)
        ent->available_mrs--;
        ent->total_mrs--;
        spin_unlock_irq(&ent->lock);
-       mlx5_core_destroy_mkey(ent->dev->mdev, &mr->mmkey);
+       mlx5_core_destroy_mkey(ent->dev->mdev, mr->mmkey.key);
        kfree(mr);
        spin_lock_irq(&ent->lock);
 }
@@ -658,7 +665,7 @@ static void clean_keys(struct mlx5_ib_dev *dev, int c)
                ent->available_mrs--;
                ent->total_mrs--;
                spin_unlock_irq(&ent->lock);
-               mlx5_core_destroy_mkey(dev->mdev, &mr->mmkey);
+               mlx5_core_destroy_mkey(dev->mdev, mr->mmkey.key);
        }
 
        list_for_each_entry_safe(mr, tmp_mr, &del_list, list) {
@@ -2326,7 +2333,7 @@ int mlx5_ib_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata)
        return 0;
 
 free_mkey:
-       mlx5_core_destroy_mkey(dev->mdev, &mw->mmkey);
+       mlx5_core_destroy_mkey(dev->mdev, mw->mmkey.key);
 free:
        kfree(in);
        return err;
@@ -2345,7 +2352,7 @@ int mlx5_ib_dealloc_mw(struct ib_mw *mw)
                 */
                mlx5r_deref_wait_odp_mkey(&mmw->mmkey);
 
-       return mlx5_core_destroy_mkey(dev->mdev, &mmw->mmkey);
+       return mlx5_core_destroy_mkey(dev->mdev, mmw->mmkey.key);
 }
 
 int mlx5_ib_check_mr_status(struct ib_mr *ibmr, u32 check_mask,
index d119ba3101a3259ccc44fa57ff8421da761dae72..a654367af056580f7edd9b41deadded00bfa1d6e 100644 (file)
@@ -909,7 +909,7 @@ next_mr:
                pklm = (struct mlx5_klm *)MLX5_ADDR_OF(query_mkey_out, out,
                                                       bsf0_klm0_pas_mtt0_1);
 
-               ret = mlx5_core_query_mkey(dev->mdev, mmkey, out, outlen);
+               ret = mlx5_core_query_mkey(dev->mdev, mmkey->key, out, outlen);
                if (ret)
                        goto end;
 
index f9cf9fb31547973e41808db83ce27500052f0758..02db3148240ac565fa23613716140012078d541c 100644 (file)
@@ -745,7 +745,7 @@ static int mlx5_fw_tracer_set_mtrc_conf(struct mlx5_fw_tracer *tracer)
        MLX5_SET(mtrc_conf, in, trace_mode, TRACE_TO_MEMORY);
        MLX5_SET(mtrc_conf, in, log_trace_buffer_size,
                 ilog2(TRACER_BUFFER_PAGE_NUM));
-       MLX5_SET(mtrc_conf, in, trace_mkey, tracer->buff.mkey.key);
+       MLX5_SET(mtrc_conf, in, trace_mkey, tracer->buff.mkey);
 
        err = mlx5_core_access_reg(dev, in, sizeof(in), out, sizeof(out),
                                   MLX5_REG_MTRC_CONF, 0, 1);
@@ -1028,7 +1028,7 @@ int mlx5_fw_tracer_init(struct mlx5_fw_tracer *tracer)
 
 err_notifier_unregister:
        mlx5_eq_notifier_unregister(dev, &tracer->nb);
-       mlx5_core_destroy_mkey(dev, &tracer->buff.mkey);
+       mlx5_core_destroy_mkey(dev, tracer->buff.mkey);
 err_dealloc_pd:
        mlx5_core_dealloc_pd(dev, tracer->buff.pdn);
 err_cancel_work:
@@ -1051,7 +1051,7 @@ void mlx5_fw_tracer_cleanup(struct mlx5_fw_tracer *tracer)
        if (tracer->owner)
                mlx5_fw_tracer_ownership_release(tracer);
 
-       mlx5_core_destroy_mkey(tracer->dev, &tracer->buff.mkey);
+       mlx5_core_destroy_mkey(tracer->dev, tracer->buff.mkey);
        mlx5_core_dealloc_pd(tracer->dev, tracer->buff.pdn);
 }
 
index 97252a85d65e6b1189814d744be8c7b10d40dd68..4762b55b0b0eee908997a104e27a30c3f2b8ac0d 100644 (file)
@@ -89,7 +89,7 @@ struct mlx5_fw_tracer {
                void *log_buf;
                dma_addr_t dma;
                u32 size;
-               struct mlx5_core_mkey mkey;
+               u32 mkey;
                u32 consumer_index;
        } buff;
 
index ed4fb79b4db7635109f7a75431b971516a371859..538adab6878b5b087ce74b34eb9b0136b79eb1db 100644 (file)
@@ -30,7 +30,7 @@ static const char *const mlx5_rsc_sgmt_name[] = {
 
 struct mlx5_rsc_dump {
        u32 pdn;
-       struct mlx5_core_mkey mkey;
+       u32 mkey;
        u16 fw_segment_type[MLX5_SGMT_TYPE_NUM];
 };
 
@@ -89,7 +89,7 @@ static int mlx5_rsc_dump_trigger(struct mlx5_core_dev *dev, struct mlx5_rsc_dump
                return -ENOMEM;
 
        in_seq_num = MLX5_GET(resource_dump, cmd->cmd, seq_num);
-       MLX5_SET(resource_dump, cmd->cmd, mkey, rsc_dump->mkey.key);
+       MLX5_SET(resource_dump, cmd->cmd, mkey, rsc_dump->mkey);
        MLX5_SET64(resource_dump, cmd->cmd, address, dma);
 
        err = mlx5_core_access_reg(dev, cmd->cmd, sizeof(cmd->cmd), cmd->cmd,
@@ -202,7 +202,7 @@ free_page:
 }
 
 static int mlx5_rsc_dump_create_mkey(struct mlx5_core_dev *mdev, u32 pdn,
-                                    struct mlx5_core_mkey *mkey)
+                                    u32 *mkey)
 {
        int inlen = MLX5_ST_SZ_BYTES(create_mkey_in);
        void *mkc;
@@ -276,7 +276,7 @@ int mlx5_rsc_dump_init(struct mlx5_core_dev *dev)
        return err;
 
 destroy_mkey:
-       mlx5_core_destroy_mkey(dev, &rsc_dump->mkey);
+       mlx5_core_destroy_mkey(dev, rsc_dump->mkey);
 free_pd:
        mlx5_core_dealloc_pd(dev, rsc_dump->pdn);
        return err;
@@ -287,6 +287,6 @@ void mlx5_rsc_dump_cleanup(struct mlx5_core_dev *dev)
        if (IS_ERR_OR_NULL(dev->rsc_dump))
                return;
 
-       mlx5_core_destroy_mkey(dev, &dev->rsc_dump->mkey);
+       mlx5_core_destroy_mkey(dev, dev->rsc_dump->mkey);
        mlx5_core_dealloc_pd(dev, dev->rsc_dump->pdn);
 }
index 03a7a4ce5cd5ec42ba18a80f642183cd37a15085..7761daa25f631efc1465ee65bf1be5935ad85c90 100644 (file)
@@ -665,7 +665,7 @@ struct mlx5e_rq {
        u8                     wq_type;
        u32                    rqn;
        struct mlx5_core_dev  *mdev;
-       struct mlx5_core_mkey  umr_mkey;
+       u32  umr_mkey;
        struct mlx5e_dma_info  wqe_overflow;
 
        /* XDP read-mostly */
index 3a86f66d1295588ac3e77e0e55b110cd619532bb..18d542b1c5cbd4ed482fcff9cae01272f21b9ed9 100644 (file)
@@ -682,7 +682,7 @@ int mlx5e_ptp_open(struct mlx5e_priv *priv, struct mlx5e_params *params,
        c->tstamp   = &priv->tstamp;
        c->pdev     = mlx5_core_dma_dev(priv->mdev);
        c->netdev   = priv->netdev;
-       c->mkey_be  = cpu_to_be32(priv->mdev->mlx5e_res.hw_objs.mkey.key);
+       c->mkey_be  = cpu_to_be32(priv->mdev->mlx5e_res.hw_objs.mkey);
        c->num_tc   = mlx5e_get_dcb_num_tc(params);
        c->stats    = &priv->ptp_stats.ch;
        c->lag_port = lag_port;
index d54607a427403f619bbaa41a953548922084c29a..a55b066746cb763dddd2b4577b47342856ea0319 100644 (file)
@@ -137,7 +137,7 @@ static struct mlx5e_trap *mlx5e_open_trap(struct mlx5e_priv *priv)
        t->tstamp   = &priv->tstamp;
        t->pdev     = mlx5_core_dma_dev(priv->mdev);
        t->netdev   = priv->netdev;
-       t->mkey_be  = cpu_to_be32(priv->mdev->mlx5e_res.hw_objs.mkey.key);
+       t->mkey_be  = cpu_to_be32(priv->mdev->mlx5e_res.hw_objs.mkey);
        t->stats    = &priv->trap_stats.ch;
 
        netif_napi_add(netdev, &t->napi, mlx5e_trap_napi_poll, 64);
index 84eb7201c142e245d8e73b9c4e2cea84c0520abb..c0f409c195bf8dc20a9b7433469af8397f110b1a 100644 (file)
@@ -47,7 +47,7 @@ void mlx5e_mkey_set_relaxed_ordering(struct mlx5_core_dev *mdev, void *mkc)
 }
 
 static int mlx5e_create_mkey(struct mlx5_core_dev *mdev, u32 pdn,
-                            struct mlx5_core_mkey *mkey)
+                            u32 *mkey)
 {
        int inlen = MLX5_ST_SZ_BYTES(create_mkey_in);
        void *mkc;
@@ -108,7 +108,7 @@ int mlx5e_create_mdev_resources(struct mlx5_core_dev *mdev)
        return 0;
 
 err_destroy_mkey:
-       mlx5_core_destroy_mkey(mdev, &res->mkey);
+       mlx5_core_destroy_mkey(mdev, res->mkey);
 err_dealloc_transport_domain:
        mlx5_core_dealloc_transport_domain(mdev, res->td.tdn);
 err_dealloc_pd:
@@ -121,7 +121,7 @@ void mlx5e_destroy_mdev_resources(struct mlx5_core_dev *mdev)
        struct mlx5e_hw_objs *res = &mdev->mlx5e_res.hw_objs;
 
        mlx5_free_bfreg(mdev, &res->bfreg);
-       mlx5_core_destroy_mkey(mdev, &res->mkey);
+       mlx5_core_destroy_mkey(mdev, res->mkey);
        mlx5_core_dealloc_transport_domain(mdev, res->td.tdn);
        mlx5_core_dealloc_pd(mdev, res->pdn);
        memset(res, 0, sizeof(*res));
index 09c8b71b186c72c7d6200c5b93762320a0bf16e8..63076d0e8b63dcfacaeb9518ded0e79f67b8ac45 100644 (file)
@@ -234,8 +234,7 @@ static int mlx5e_rq_alloc_mpwqe_info(struct mlx5e_rq *rq, int node)
 }
 
 static int mlx5e_create_umr_mkey(struct mlx5_core_dev *mdev,
-                                u64 npages, u8 page_shift,
-                                struct mlx5_core_mkey *umr_mkey,
+                                u64 npages, u8 page_shift, u32 *umr_mkey,
                                 dma_addr_t filler_addr)
 {
        struct mlx5_mtt *mtt;
@@ -455,7 +454,7 @@ static int mlx5e_alloc_rq(struct mlx5e_params *params,
                err = mlx5e_create_rq_umr_mkey(mdev, rq);
                if (err)
                        goto err_rq_drop_page;
-               rq->mkey_be = cpu_to_be32(rq->umr_mkey.key);
+               rq->mkey_be = cpu_to_be32(rq->umr_mkey);
 
                err = mlx5e_rq_alloc_mpwqe_info(rq, node);
                if (err)
@@ -487,7 +486,7 @@ static int mlx5e_alloc_rq(struct mlx5e_params *params,
                if (err)
                        goto err_rq_frags;
 
-               rq->mkey_be = cpu_to_be32(mdev->mlx5e_res.hw_objs.mkey.key);
+               rq->mkey_be = cpu_to_be32(mdev->mlx5e_res.hw_objs.mkey);
        }
 
        if (xsk) {
@@ -574,7 +573,7 @@ err_free_by_rq_type:
        case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
                kvfree(rq->mpwqe.info);
 err_rq_mkey:
-               mlx5_core_destroy_mkey(mdev, &rq->umr_mkey);
+               mlx5_core_destroy_mkey(mdev, rq->umr_mkey);
 err_rq_drop_page:
                mlx5e_free_mpwqe_rq_drop_page(rq);
                break;
@@ -607,7 +606,7 @@ static void mlx5e_free_rq(struct mlx5e_rq *rq)
        switch (rq->wq_type) {
        case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
                kvfree(rq->mpwqe.info);
-               mlx5_core_destroy_mkey(rq->mdev, &rq->umr_mkey);
+               mlx5_core_destroy_mkey(rq->mdev, rq->umr_mkey);
                mlx5e_free_mpwqe_rq_drop_page(rq);
                break;
        default: /* MLX5_WQ_TYPE_CYCLIC */
@@ -1991,7 +1990,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
        c->cpu      = cpu;
        c->pdev     = mlx5_core_dma_dev(priv->mdev);
        c->netdev   = priv->netdev;
-       c->mkey_be  = cpu_to_be32(priv->mdev->mlx5e_res.hw_objs.mkey.key);
+       c->mkey_be  = cpu_to_be32(priv->mdev->mlx5e_res.hw_objs.mkey);
        c->num_tc   = mlx5e_get_dcb_num_tc(params);
        c->xdp      = !!params->xdp_prog;
        c->stats    = &priv->channel_stats[ix].ch;
index 306279b7f9e7045197dd06134616add6d0e88609..12abe991583a872cb9375ec20482b3317c7fdf53 100644 (file)
@@ -115,7 +115,7 @@ static int mlx5_fpga_conn_post_recv(struct mlx5_fpga_conn *conn,
        ix = conn->qp.rq.pc & (conn->qp.rq.size - 1);
        data = mlx5_wq_cyc_get_wqe(&conn->qp.wq.rq, ix);
        data->byte_count = cpu_to_be32(buf->sg[0].size);
-       data->lkey = cpu_to_be32(conn->fdev->conn_res.mkey.key);
+       data->lkey = cpu_to_be32(conn->fdev->conn_res.mkey);
        data->addr = cpu_to_be64(buf->sg[0].dma_addr);
 
        conn->qp.rq.pc++;
@@ -155,7 +155,7 @@ static void mlx5_fpga_conn_post_send(struct mlx5_fpga_conn *conn,
                if (!buf->sg[sgi].data)
                        break;
                data->byte_count = cpu_to_be32(buf->sg[sgi].size);
-               data->lkey = cpu_to_be32(conn->fdev->conn_res.mkey.key);
+               data->lkey = cpu_to_be32(conn->fdev->conn_res.mkey);
                data->addr = cpu_to_be64(buf->sg[sgi].dma_addr);
                data++;
                size++;
@@ -221,7 +221,7 @@ static int mlx5_fpga_conn_post_recv_buf(struct mlx5_fpga_conn *conn)
 }
 
 static int mlx5_fpga_conn_create_mkey(struct mlx5_core_dev *mdev, u32 pdn,
-                                     struct mlx5_core_mkey *mkey)
+                                     u32 *mkey)
 {
        int inlen = MLX5_ST_SZ_BYTES(create_mkey_in);
        void *mkc;
@@ -978,7 +978,7 @@ int mlx5_fpga_conn_device_init(struct mlx5_fpga_device *fdev)
                mlx5_fpga_err(fdev, "create mkey failed, %d\n", err);
                goto err_dealloc_pd;
        }
-       mlx5_fpga_dbg(fdev, "Created mkey 0x%x\n", fdev->conn_res.mkey.key);
+       mlx5_fpga_dbg(fdev, "Created mkey 0x%x\n", fdev->conn_res.mkey);
 
        return 0;
 
@@ -994,7 +994,7 @@ out:
 
 void mlx5_fpga_conn_device_cleanup(struct mlx5_fpga_device *fdev)
 {
-       mlx5_core_destroy_mkey(fdev->mdev, &fdev->conn_res.mkey);
+       mlx5_core_destroy_mkey(fdev->mdev, fdev->conn_res.mkey);
        mlx5_core_dealloc_pd(fdev->mdev, fdev->conn_res.pdn);
        mlx5_put_uars_page(fdev->mdev, fdev->conn_res.uar);
        mlx5_nic_vport_disable_roce(fdev->mdev);
index 52c9dee91ea465340155a14b9a4bcffc55b03cbb..2a984e82ae16ba53c5c4102c355afeffa9503ecf 100644 (file)
@@ -54,7 +54,7 @@ struct mlx5_fpga_device {
        /* QP Connection resources */
        struct {
                u32 pdn;
-               struct mlx5_core_mkey mkey;
+               u32 mkey;
                struct mlx5_uars_page *uar;
        } conn_res;
 
index 6e99fd166f98c4a9ae80ba9d949678fb86053d70..f099a087400effbb642d2d4d09be213f9f72207c 100644 (file)
@@ -35,9 +35,8 @@
 #include <linux/mlx5/driver.h>
 #include "mlx5_core.h"
 
-int mlx5_core_create_mkey(struct mlx5_core_dev *dev,
-                         struct mlx5_core_mkey *mkey,
-                         u32 *in, int inlen)
+int mlx5_core_create_mkey(struct mlx5_core_dev *dev, u32 *mkey, u32 *in,
+                         int inlen)
 {
        u32 lout[MLX5_ST_SZ_DW(create_mkey_out)] = {};
        u32 mkey_index;
@@ -50,33 +49,32 @@ int mlx5_core_create_mkey(struct mlx5_core_dev *dev,
                return err;
 
        mkey_index = MLX5_GET(create_mkey_out, lout, mkey_index);
-       mkey->key = (u32)mlx5_mkey_variant(mkey->key) | mlx5_idx_to_mkey(mkey_index);
-       init_waitqueue_head(&mkey->wait);
+       *mkey = MLX5_GET(create_mkey_in, in, memory_key_mkey_entry.mkey_7_0) |
+               mlx5_idx_to_mkey(mkey_index);
 
-       mlx5_core_dbg(dev, "out 0x%x, mkey 0x%x\n", mkey_index, mkey->key);
+       mlx5_core_dbg(dev, "out 0x%x, mkey 0x%x\n", mkey_index, *mkey);
        return 0;
 }
 EXPORT_SYMBOL(mlx5_core_create_mkey);
 
-int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev,
-                          struct mlx5_core_mkey *mkey)
+int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev, u32 mkey)
 {
        u32 in[MLX5_ST_SZ_DW(destroy_mkey_in)] = {};
 
        MLX5_SET(destroy_mkey_in, in, opcode, MLX5_CMD_OP_DESTROY_MKEY);
-       MLX5_SET(destroy_mkey_in, in, mkey_index, mlx5_mkey_to_idx(mkey->key));
+       MLX5_SET(destroy_mkey_in, in, mkey_index, mlx5_mkey_to_idx(mkey));
        return mlx5_cmd_exec_in(dev, destroy_mkey, in);
 }
 EXPORT_SYMBOL(mlx5_core_destroy_mkey);
 
-int mlx5_core_query_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mkey *mkey,
-                        u32 *out, int outlen)
+int mlx5_core_query_mkey(struct mlx5_core_dev *dev, u32 mkey, u32 *out,
+                        int outlen)
 {
        u32 in[MLX5_ST_SZ_DW(query_mkey_in)] = {};
 
        memset(out, 0, outlen);
        MLX5_SET(query_mkey_in, in, opcode, MLX5_CMD_OP_QUERY_MKEY);
-       MLX5_SET(query_mkey_in, in, mkey_index, mlx5_mkey_to_idx(mkey->key));
+       MLX5_SET(query_mkey_in, in, mkey_index, mlx5_mkey_to_idx(mkey));
        return mlx5_cmd_exec(dev, in, sizeof(in), out, outlen);
 }
 EXPORT_SYMBOL(mlx5_core_query_mkey);
index 66c24767e3b00a4875c91f04e492a27095686ab6..7f6fd9c5e371b4af30b9cc78307c514fbf68a808 100644 (file)
@@ -24,7 +24,7 @@ struct mlx5dr_icm_dm {
 };
 
 struct mlx5dr_icm_mr {
-       struct mlx5_core_mkey mkey;
+       u32 mkey;
        struct mlx5dr_icm_dm dm;
        struct mlx5dr_domain *dmn;
        size_t length;
@@ -33,7 +33,7 @@ struct mlx5dr_icm_mr {
 
 static int dr_icm_create_dm_mkey(struct mlx5_core_dev *mdev,
                                 u32 pd, u64 length, u64 start_addr, int mode,
-                                struct mlx5_core_mkey *mkey)
+                                u32 *mkey)
 {
        u32 inlen = MLX5_ST_SZ_BYTES(create_mkey_in);
        u32 in[MLX5_ST_SZ_DW(create_mkey_in)] = {};
@@ -116,7 +116,7 @@ dr_icm_pool_mr_create(struct mlx5dr_icm_pool *pool)
        return icm_mr;
 
 free_mkey:
-       mlx5_core_destroy_mkey(mdev, &icm_mr->mkey);
+       mlx5_core_destroy_mkey(mdev, icm_mr->mkey);
 free_dm:
        mlx5_dm_sw_icm_dealloc(mdev, icm_mr->dm.type, icm_mr->dm.length, 0,
                               icm_mr->dm.addr, icm_mr->dm.obj_id);
@@ -130,7 +130,7 @@ static void dr_icm_pool_mr_destroy(struct mlx5dr_icm_mr *icm_mr)
        struct mlx5_core_dev *mdev = icm_mr->dmn->mdev;
        struct mlx5dr_icm_dm *dm = &icm_mr->dm;
 
-       mlx5_core_destroy_mkey(mdev, &icm_mr->mkey);
+       mlx5_core_destroy_mkey(mdev, icm_mr->mkey);
        mlx5_dm_sw_icm_dealloc(mdev, dm->type, dm->length, 0,
                               dm->addr, dm->obj_id);
        kvfree(icm_mr);
@@ -252,7 +252,7 @@ dr_icm_chunk_create(struct mlx5dr_icm_pool *pool,
 
        offset = mlx5dr_icm_pool_dm_type_to_entry_size(pool->icm_type) * seg;
 
-       chunk->rkey = buddy_mem_pool->icm_mr->mkey.key;
+       chunk->rkey = buddy_mem_pool->icm_mr->mkey;
        chunk->mr_addr = offset;
        chunk->icm_addr =
                (uintptr_t)buddy_mem_pool->icm_mr->icm_start_addr + offset;
index bfb14b4b19067598ab73706a838085c62f329958..00aef47d7682d5a8e22f5c73b1c53895e8ddf7a8 100644 (file)
@@ -350,7 +350,7 @@ static void dr_fill_data_segs(struct mlx5dr_send_ring *send_ring,
        send_info->read.length = send_info->write.length;
        /* Read into the same write area */
        send_info->read.addr = (uintptr_t)send_info->write.addr;
-       send_info->read.lkey = send_ring->mr->mkey.key;
+       send_info->read.lkey = send_ring->mr->mkey;
 
        if (send_ring->pending_wqe % send_ring->signal_th == 0)
                send_info->read.send_flags = IB_SEND_SIGNALED;
@@ -388,7 +388,7 @@ static int dr_postsend_icm_data(struct mlx5dr_domain *dmn,
                       (void *)(uintptr_t)send_info->write.addr,
                       send_info->write.length);
                send_info->write.addr = (uintptr_t)send_ring->mr->dma_addr + buff_offset;
-               send_info->write.lkey = send_ring->mr->mkey.key;
+               send_info->write.lkey = send_ring->mr->mkey;
        }
 
        send_ring->tx_head++;
@@ -848,8 +848,7 @@ static void dr_destroy_cq(struct mlx5_core_dev *mdev, struct mlx5dr_cq *cq)
        kfree(cq);
 }
 
-static int
-dr_create_mkey(struct mlx5_core_dev *mdev, u32 pdn, struct mlx5_core_mkey *mkey)
+static int dr_create_mkey(struct mlx5_core_dev *mdev, u32 pdn, u32 *mkey)
 {
        u32 in[MLX5_ST_SZ_DW(create_mkey_in)] = {};
        void *mkc;
@@ -908,7 +907,7 @@ static struct mlx5dr_mr *dr_reg_mr(struct mlx5_core_dev *mdev,
 
 static void dr_dereg_mr(struct mlx5_core_dev *mdev, struct mlx5dr_mr *mr)
 {
-       mlx5_core_destroy_mkey(mdev, &mr->mkey);
+       mlx5_core_destroy_mkey(mdev, mr->mkey);
        dma_unmap_single(mlx5_core_dma_dev(mdev), mr->dma_addr, mr->size,
                         DMA_BIDIRECTIONAL);
        kfree(mr);
@@ -1039,7 +1038,7 @@ int mlx5dr_send_ring_force_drain(struct mlx5dr_domain *dmn)
        send_info.write.lkey = 0;
        /* Using the sync_mr in order to write/read */
        send_info.remote_addr = (uintptr_t)send_ring->sync_mr->addr;
-       send_info.rkey = send_ring->sync_mr->mkey.key;
+       send_info.rkey = send_ring->sync_mr->mkey;
 
        for (i = 0; i < num_of_sends_req; i++) {
                ret = dr_postsend_icm_data(dmn, &send_info);
index b20e8aabb861b6cd55cac43b9e7870eb643ed5cf..6c67185c05c1202ebcc3306568cd15101412b69e 100644 (file)
@@ -1275,7 +1275,7 @@ struct mlx5dr_cq {
 
 struct mlx5dr_mr {
        struct mlx5_core_dev *mdev;
-       struct mlx5_core_mkey mkey;
+       u32 mkey;
        dma_addr_t dma_addr;
        void *addr;
        size_t size;
index 01a848adf5903c4c64b2200cb852f696c053cfec..3163b313a470a81c90f51299de2fc8094510cff9 100644 (file)
@@ -15,7 +15,7 @@ struct mlx5_vdpa_direct_mr {
        u64 start;
        u64 end;
        u32 perm;
-       struct mlx5_core_mkey mr;
+       u32 mr;
        struct sg_table sg_head;
        int log_size;
        int nsg;
@@ -25,7 +25,7 @@ struct mlx5_vdpa_direct_mr {
 };
 
 struct mlx5_vdpa_mr {
-       struct mlx5_core_mkey mkey;
+       u32 mkey;
 
        /* list of direct MRs descendants of this indirect mr */
        struct list_head head;
@@ -99,9 +99,9 @@ int mlx5_vdpa_alloc_transport_domain(struct mlx5_vdpa_dev *mvdev, u32 *tdn);
 void mlx5_vdpa_dealloc_transport_domain(struct mlx5_vdpa_dev *mvdev, u32 tdn);
 int mlx5_vdpa_alloc_resources(struct mlx5_vdpa_dev *mvdev);
 void mlx5_vdpa_free_resources(struct mlx5_vdpa_dev *mvdev);
-int mlx5_vdpa_create_mkey(struct mlx5_vdpa_dev *mvdev, struct mlx5_core_mkey *mkey, u32 *in,
+int mlx5_vdpa_create_mkey(struct mlx5_vdpa_dev *mvdev, u32 *mkey, u32 *in,
                          int inlen);
-int mlx5_vdpa_destroy_mkey(struct mlx5_vdpa_dev *mvdev, struct mlx5_core_mkey *mkey);
+int mlx5_vdpa_destroy_mkey(struct mlx5_vdpa_dev *mvdev, u32 mkey);
 int mlx5_vdpa_handle_set_map(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb,
                             bool *change_map);
 int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb);
index ff010c6d0cd39e78e9e688ad398102ab18048bd2..a639b9208d4148b045210bcb687556cd7ba602ff 100644 (file)
@@ -88,7 +88,7 @@ static int create_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct
 
 static void destroy_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr *mr)
 {
-       mlx5_vdpa_destroy_mkey(mvdev, &mr->mr);
+       mlx5_vdpa_destroy_mkey(mvdev, mr->mr);
 }
 
 static u64 map_start(struct vhost_iotlb_map *map, struct mlx5_vdpa_direct_mr *mr)
@@ -162,7 +162,7 @@ again:
                }
 
                if (preve == dmr->start) {
-                       klm->key = cpu_to_be32(dmr->mr.key);
+                       klm->key = cpu_to_be32(dmr->mr);
                        klm->bcount = cpu_to_be32(klm_bcount(dmr->end - dmr->start));
                        preve = dmr->end;
                } else {
@@ -217,7 +217,7 @@ static int create_indirect_key(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_mr
 
 static void destroy_indirect_key(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_mr *mkey)
 {
-       mlx5_vdpa_destroy_mkey(mvdev, &mkey->mkey);
+       mlx5_vdpa_destroy_mkey(mvdev, mkey->mkey);
 }
 
 static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr *mr,
@@ -449,7 +449,7 @@ static int create_dma_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_mr *mr)
 
 static void destroy_dma_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_mr *mr)
 {
-       mlx5_vdpa_destroy_mkey(mvdev, &mr->mkey);
+       mlx5_vdpa_destroy_mkey(mvdev, mr->mkey);
 }
 
 static int dup_iotlb(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *src)
index 72b2d80e75b089f19ddc152f23bc61640ab402dd..9800f9bec225a5fe0ad7b4b5fb4bba0646e0e0f1 100644 (file)
@@ -198,7 +198,7 @@ void mlx5_vdpa_dealloc_transport_domain(struct mlx5_vdpa_dev *mvdev, u32 tdn)
        mlx5_cmd_exec_in(mvdev->mdev, dealloc_transport_domain, in);
 }
 
-int mlx5_vdpa_create_mkey(struct mlx5_vdpa_dev *mvdev, struct mlx5_core_mkey *mkey, u32 *in,
+int mlx5_vdpa_create_mkey(struct mlx5_vdpa_dev *mvdev, u32 *mkey, u32 *in,
                          int inlen)
 {
        u32 lout[MLX5_ST_SZ_DW(create_mkey_out)] = {};
@@ -213,17 +213,17 @@ int mlx5_vdpa_create_mkey(struct mlx5_vdpa_dev *mvdev, struct mlx5_core_mkey *mk
                return err;
 
        mkey_index = MLX5_GET(create_mkey_out, lout, mkey_index);
-       mkey->key |= mlx5_idx_to_mkey(mkey_index);
+       *mkey |= mlx5_idx_to_mkey(mkey_index);
        return 0;
 }
 
-int mlx5_vdpa_destroy_mkey(struct mlx5_vdpa_dev *mvdev, struct mlx5_core_mkey *mkey)
+int mlx5_vdpa_destroy_mkey(struct mlx5_vdpa_dev *mvdev, u32 mkey)
 {
        u32 in[MLX5_ST_SZ_DW(destroy_mkey_in)] = {};
 
        MLX5_SET(destroy_mkey_in, in, uid, mvdev->res.uid);
        MLX5_SET(destroy_mkey_in, in, opcode, MLX5_CMD_OP_DESTROY_MKEY);
-       MLX5_SET(destroy_mkey_in, in, mkey_index, mlx5_mkey_to_idx(mkey->key));
+       MLX5_SET(destroy_mkey_in, in, mkey_index, mlx5_mkey_to_idx(mkey));
        return mlx5_cmd_exec_in(mvdev->mdev, destroy_mkey, in);
 }
 
index bd56de7484dcb1d72d2b99cbeef7932adfb81888..5c7d2a953dbd60cee08fda65969d8f0e53672cb8 100644 (file)
@@ -865,7 +865,7 @@ static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque
        MLX5_SET64(virtio_q, vq_ctx, desc_addr, mvq->desc_addr);
        MLX5_SET64(virtio_q, vq_ctx, used_addr, mvq->device_addr);
        MLX5_SET64(virtio_q, vq_ctx, available_addr, mvq->driver_addr);
-       MLX5_SET(virtio_q, vq_ctx, virtio_q_mkey, ndev->mvdev.mr.mkey.key);
+       MLX5_SET(virtio_q, vq_ctx, virtio_q_mkey, ndev->mvdev.mr.mkey);
        MLX5_SET(virtio_q, vq_ctx, umem_1_id, mvq->umem1.id);
        MLX5_SET(virtio_q, vq_ctx, umem_1_size, mvq->umem1.size);
        MLX5_SET(virtio_q, vq_ctx, umem_2_id, mvq->umem2.id);
index f0ce7d4dc4ff8a3485304c29cecef44946ca7993..bd99f713720b1c7c16403b097f2068442fe788fa 100644 (file)
@@ -650,7 +650,7 @@ struct mlx5e_resources {
        struct mlx5e_hw_objs {
                u32                        pdn;
                struct mlx5_td             td;
-               struct mlx5_core_mkey      mkey;
+               u32                        mkey;
                struct mlx5_sq_bfreg       bfreg;
        } hw_objs;
        struct devlink_port dl_port;
@@ -1021,13 +1021,11 @@ struct mlx5_cmd_mailbox *mlx5_alloc_cmd_mailbox_chain(struct mlx5_core_dev *dev,
                                                      gfp_t flags, int npages);
 void mlx5_free_cmd_mailbox_chain(struct mlx5_core_dev *dev,
                                 struct mlx5_cmd_mailbox *head);
-int mlx5_core_create_mkey(struct mlx5_core_dev *dev,
-                         struct mlx5_core_mkey *mkey,
-                         u32 *in, int inlen);
-int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev,
-                          struct mlx5_core_mkey *mkey);
-int mlx5_core_query_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mkey *mkey,
-                        u32 *out, int outlen);
+int mlx5_core_create_mkey(struct mlx5_core_dev *dev, u32 *mkey, u32 *in,
+                         int inlen);
+int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev, u32 mkey);
+int mlx5_core_query_mkey(struct mlx5_core_dev *dev, u32 mkey, u32 *out,
+                        int outlen);
 int mlx5_core_alloc_pd(struct mlx5_core_dev *dev, u32 *pdn);
 int mlx5_core_dealloc_pd(struct mlx5_core_dev *dev, u32 pdn);
 int mlx5_pagealloc_init(struct mlx5_core_dev *dev);