]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - include/rdma/ib_verbs.h
NFS: Additional refactoring for fs_context conversion
[linux.git] / include / rdma / ib_verbs.h
index e7e733add99f80f68bd7cd4fd545c7322528bf18..5608e14e3aadf893570e4189c81cb5472a27e184 100644 (file)
@@ -445,6 +445,8 @@ struct ib_device_attr {
        struct ib_tm_caps       tm_caps;
        struct ib_cq_caps       cq_caps;
        u64                     max_dm_size;
+       /* Max entries for sgl for optimized performance per READ */
+       u32                     max_sgl_rd;
 };
 
 enum ib_mtu {
@@ -1471,6 +1473,7 @@ struct ib_ucontext {
         * Implementation details of the RDMA core, don't use in drivers:
         */
        struct rdma_restrack_entry res;
+       struct xarray mmap_xa;
 };
 
 struct ib_uobject {
@@ -2120,7 +2123,7 @@ struct ib_flow_action {
        atomic_t                        usecnt;
 };
 
-struct ib_mad_hdr;
+struct ib_mad;
 struct ib_grh;
 
 enum ib_process_mad_flags {
@@ -2218,6 +2221,11 @@ struct rdma_netdev_alloc_params {
                                      struct net_device *netdev, void *param);
 };
 
+struct ib_odp_counters {
+       atomic64_t faults;
+       atomic64_t invalidations;
+};
+
 struct ib_counters {
        struct ib_device        *device;
        struct ib_uobject       *uobject;
@@ -2251,6 +2259,21 @@ struct iw_cm_conn_param;
 
 #define DECLARE_RDMA_OBJ_SIZE(ib_struct) size_t size_##ib_struct
 
+struct rdma_user_mmap_entry {
+       struct kref ref;
+       struct ib_ucontext *ucontext;
+       unsigned long start_pgoff;
+       size_t npages;
+       bool driver_removed;
+};
+
+/* Return the offset (in bytes) the user should pass to libc's mmap() */
+static inline u64
+rdma_user_mmap_get_offset(const struct rdma_user_mmap_entry *entry)
+{
+       return (u64)entry->start_pgoff << PAGE_SHIFT;
+}
+
 /**
  * struct ib_device_ops - InfiniBand device operations
  * This structure defines all the InfiniBand device operations, providers will
@@ -2278,9 +2301,8 @@ struct ib_device_ops {
        int (*process_mad)(struct ib_device *device, int process_mad_flags,
                           u8 port_num, const struct ib_wc *in_wc,
                           const struct ib_grh *in_grh,
-                          const struct ib_mad_hdr *in_mad, size_t in_mad_size,
-                          struct ib_mad_hdr *out_mad, size_t *out_mad_size,
-                          u16 *out_mad_pkey_index);
+                          const struct ib_mad *in_mad, struct ib_mad *out_mad,
+                          size_t *out_mad_size, u16 *out_mad_pkey_index);
        int (*query_device)(struct ib_device *device,
                            struct ib_device_attr *device_attr,
                            struct ib_udata *udata);
@@ -2363,6 +2385,13 @@ struct ib_device_ops {
                              struct ib_udata *udata);
        void (*dealloc_ucontext)(struct ib_ucontext *context);
        int (*mmap)(struct ib_ucontext *context, struct vm_area_struct *vma);
+       /**
+        * This will be called once refcount of an entry in mmap_xa reaches
+        * zero. The type of the memory that was mapped may differ between
+        * entries and is opaque to the rdma_user_mmap interface.
+        * Therefore needs to be implemented by the driver in mmap_free.
+        */
+       void (*mmap_free)(struct rdma_user_mmap_entry *entry);
        void (*disassociate_ucontext)(struct ib_ucontext *ibcontext);
        int (*alloc_pd)(struct ib_pd *pd, struct ib_udata *udata);
        void (*dealloc_pd)(struct ib_pd *pd, struct ib_udata *udata);
@@ -2422,8 +2451,6 @@ struct ib_device_ops {
                            u64 iova);
        int (*unmap_fmr)(struct list_head *fmr_list);
        int (*dealloc_fmr)(struct ib_fmr *fmr);
-       void (*invalidate_range)(struct ib_umem_odp *umem_odp,
-                                unsigned long start, unsigned long end);
        int (*attach_mcast)(struct ib_qp *qp, union ib_gid *gid, u16 lid);
        int (*detach_mcast)(struct ib_qp *qp, union ib_gid *gid, u16 lid);
        struct ib_xrcd *(*alloc_xrcd)(struct ib_device *device,
@@ -2448,6 +2475,9 @@ struct ib_device_ops {
                             struct ifla_vf_info *ivf);
        int (*get_vf_stats)(struct ib_device *device, int vf, u8 port,
                            struct ifla_vf_stats *stats);
+       int (*get_vf_guid)(struct ib_device *device, int vf, u8 port,
+                           struct ifla_vf_guid *node_guid,
+                           struct ifla_vf_guid *port_guid);
        int (*set_vf_guid)(struct ib_device *device, int vf, u8 port, u64 guid,
                           int type);
        struct ib_wq *(*create_wq)(struct ib_pd *pd,
@@ -2563,6 +2593,13 @@ struct ib_device_ops {
         */
        int (*counter_update_stats)(struct rdma_counter *counter);
 
+       /**
+        * Allows rdma drivers to add their own restrack attributes
+        * dumped via 'rdma stat' iproute2 command.
+        */
+       int (*fill_stat_entry)(struct sk_buff *msg,
+                              struct rdma_restrack_entry *entry);
+
        DECLARE_RDMA_OBJ_SIZE(ib_ah);
        DECLARE_RDMA_OBJ_SIZE(ib_cq);
        DECLARE_RDMA_OBJ_SIZE(ib_pd);
@@ -2789,18 +2826,26 @@ void  ib_set_client_data(struct ib_device *device, struct ib_client *client,
 void ib_set_device_ops(struct ib_device *device,
                       const struct ib_device_ops *ops);
 
-#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
 int rdma_user_mmap_io(struct ib_ucontext *ucontext, struct vm_area_struct *vma,
-                     unsigned long pfn, unsigned long size, pgprot_t prot);
-#else
-static inline int rdma_user_mmap_io(struct ib_ucontext *ucontext,
-                                   struct vm_area_struct *vma,
-                                   unsigned long pfn, unsigned long size,
-                                   pgprot_t prot)
-{
-       return -EINVAL;
-}
-#endif
+                     unsigned long pfn, unsigned long size, pgprot_t prot,
+                     struct rdma_user_mmap_entry *entry);
+int rdma_user_mmap_entry_insert(struct ib_ucontext *ucontext,
+                               struct rdma_user_mmap_entry *entry,
+                               size_t length);
+int rdma_user_mmap_entry_insert_range(struct ib_ucontext *ucontext,
+                                     struct rdma_user_mmap_entry *entry,
+                                     size_t length, u32 min_pgoff,
+                                     u32 max_pgoff);
+
+struct rdma_user_mmap_entry *
+rdma_user_mmap_entry_get_pgoff(struct ib_ucontext *ucontext,
+                              unsigned long pgoff);
+struct rdma_user_mmap_entry *
+rdma_user_mmap_entry_get(struct ib_ucontext *ucontext,
+                        struct vm_area_struct *vma);
+void rdma_user_mmap_entry_put(struct rdma_user_mmap_entry *entry);
+
+void rdma_user_mmap_entry_remove(struct rdma_user_mmap_entry *entry);
 
 static inline int ib_copy_from_udata(void *dest, struct ib_udata *udata, size_t len)
 {
@@ -3303,6 +3348,9 @@ int ib_get_vf_config(struct ib_device *device, int vf, u8 port,
                     struct ifla_vf_info *info);
 int ib_get_vf_stats(struct ib_device *device, int vf, u8 port,
                    struct ifla_vf_stats *stats);
+int ib_get_vf_guid(struct ib_device *device, int vf, u8 port,
+                   struct ifla_vf_guid *node_guid,
+                   struct ifla_vf_guid *port_guid);
 int ib_set_vf_guid(struct ib_device *device, int vf, u8 port, u64 guid,
                   int type);
 
@@ -4043,9 +4091,7 @@ static inline void ib_dma_unmap_sg_attrs(struct ib_device *dev,
  */
 static inline unsigned int ib_dma_max_seg_size(struct ib_device *dev)
 {
-       struct device_dma_parameters *p = dev->dma_device->dma_parms;
-
-       return p ? p->max_segment_size : UINT_MAX;
+       return dma_get_max_seg_size(dev->dma_device);
 }
 
 /**