linux/drivers/vdpa/mlx5/core/mlx5_vdpa.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
   2/* Copyright (c) 2020 Mellanox Technologies Ltd. */
   3
   4#ifndef __MLX5_VDPA_H__
   5#define __MLX5_VDPA_H__
   6
   7#include <linux/vdpa.h>
   8#include <linux/mlx5/driver.h>
   9
  10struct mlx5_vdpa_direct_mr {
  11        u64 start;
  12        u64 end;
  13        u32 perm;
  14        struct mlx5_core_mkey mr;
  15        struct sg_table sg_head;
  16        int log_size;
  17        int nsg;
  18        int nent;
  19        struct list_head list;
  20        u64 offset;
  21};
  22
  23struct mlx5_vdpa_mr {
  24        struct mlx5_core_mkey mkey;
  25
  26        /* list of direct MRs descendants of this indirect mr */
  27        struct list_head head;
  28        unsigned long num_directs;
  29        unsigned long num_klms;
  30        bool initialized;
  31
  32        /* serialize mkey creation and destruction */
  33        struct mutex mkey_mtx;
  34};
  35
  36struct mlx5_vdpa_resources {
  37        u32 pdn;
  38        struct mlx5_uars_page *uar;
  39        void __iomem *kick_addr;
  40        u16 uid;
  41        u32 null_mkey;
  42        bool valid;
  43};
  44
  45struct mlx5_vdpa_dev {
  46        struct vdpa_device vdev;
  47        struct mlx5_core_dev *mdev;
  48        struct mlx5_vdpa_resources res;
  49
  50        u64 mlx_features;
  51        u64 actual_features;
  52        u8 status;
  53        u32 max_vqs;
  54        u32 generation;
  55
  56        struct mlx5_vdpa_mr mr;
  57};
  58
  59int mlx5_vdpa_alloc_pd(struct mlx5_vdpa_dev *dev, u32 *pdn, u16 uid);
  60int mlx5_vdpa_dealloc_pd(struct mlx5_vdpa_dev *dev, u32 pdn, u16 uid);
  61int mlx5_vdpa_get_null_mkey(struct mlx5_vdpa_dev *dev, u32 *null_mkey);
  62int mlx5_vdpa_create_tis(struct mlx5_vdpa_dev *mvdev, void *in, u32 *tisn);
  63void mlx5_vdpa_destroy_tis(struct mlx5_vdpa_dev *mvdev, u32 tisn);
  64int mlx5_vdpa_create_rqt(struct mlx5_vdpa_dev *mvdev, void *in, int inlen, u32 *rqtn);
  65void mlx5_vdpa_destroy_rqt(struct mlx5_vdpa_dev *mvdev, u32 rqtn);
  66int mlx5_vdpa_create_tir(struct mlx5_vdpa_dev *mvdev, void *in, u32 *tirn);
  67void mlx5_vdpa_destroy_tir(struct mlx5_vdpa_dev *mvdev, u32 tirn);
  68int mlx5_vdpa_alloc_transport_domain(struct mlx5_vdpa_dev *mvdev, u32 *tdn);
  69void mlx5_vdpa_dealloc_transport_domain(struct mlx5_vdpa_dev *mvdev, u32 tdn);
  70int mlx5_vdpa_alloc_resources(struct mlx5_vdpa_dev *mvdev);
  71void mlx5_vdpa_free_resources(struct mlx5_vdpa_dev *mvdev);
  72int mlx5_vdpa_create_mkey(struct mlx5_vdpa_dev *mvdev, struct mlx5_core_mkey *mkey, u32 *in,
  73                          int inlen);
  74int mlx5_vdpa_destroy_mkey(struct mlx5_vdpa_dev *mvdev, struct mlx5_core_mkey *mkey);
  75int mlx5_vdpa_handle_set_map(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb,
  76                             bool *change_map);
  77int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb);
  78void mlx5_vdpa_destroy_mr(struct mlx5_vdpa_dev *mvdev);
  79
  80#define mlx5_vdpa_warn(__dev, format, ...)                                                         \
  81        dev_warn((__dev)->mdev->device, "%s:%d:(pid %d) warning: " format, __func__, __LINE__,     \
  82                 current->pid, ##__VA_ARGS__)
  83
  84#define mlx5_vdpa_info(__dev, format, ...)                                                         \
  85        dev_info((__dev)->mdev->device, "%s:%d:(pid %d): " format, __func__, __LINE__,             \
  86                 current->pid, ##__VA_ARGS__)
  87
  88#define mlx5_vdpa_dbg(__dev, format, ...)                                                          \
  89        dev_debug((__dev)->mdev->device, "%s:%d:(pid %d): " format, __func__, __LINE__,            \
  90                  current->pid, ##__VA_ARGS__)
  91
  92#endif /* __MLX5_VDPA_H__ */
  93