vdpa.h (a6a51adc6e8aafebfe0c4beb80e99694ea562b40) vdpa.h (d4821902e43453b85b31329441a9f6ac071228a8)
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _LINUX_VDPA_H
3#define _LINUX_VDPA_H
4
5#include <linux/kernel.h>
6#include <linux/device.h>
7#include <linux/interrupt.h>
8#include <linux/vhost_iotlb.h>

--- 71 unchanged lines hidden (view full) ---

80 const char *driver_override;
81 const struct vdpa_config_ops *config;
82 struct rw_semaphore cf_lock; /* Protects get/set config */
83 unsigned int index;
84 bool features_valid;
85 bool use_va;
86 u32 nvqs;
87 struct vdpa_mgmt_dev *mdev;
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _LINUX_VDPA_H
3#define _LINUX_VDPA_H
4
5#include <linux/kernel.h>
6#include <linux/device.h>
7#include <linux/interrupt.h>
8#include <linux/vhost_iotlb.h>

--- 71 unchanged lines hidden (view full) ---

80 const char *driver_override;
81 const struct vdpa_config_ops *config;
82 struct rw_semaphore cf_lock; /* Protects get/set config */
83 unsigned int index;
84 bool features_valid;
85 bool use_va;
86 u32 nvqs;
87 struct vdpa_mgmt_dev *mdev;
88 unsigned int ngroups;
88};
89
90/**
91 * struct vdpa_iova_range - the IOVA range support by the device
92 * @first: start of the IOVA range
93 * @last: end of the IOVA range
94 */
95struct vdpa_iova_range {

--- 71 unchanged lines hidden (view full) ---

167 * @vdev: vdpa device
168 * @idx: virtqueue index
169 * Returns int: irq number of a virtqueue,
170 * negative number if no irq assigned.
171 * @get_vq_align: Get the virtqueue align requirement
172 * for the device
173 * @vdev: vdpa device
174 * Returns virtqueue algin requirement
89};
90
91/**
92 * struct vdpa_iova_range - the IOVA range support by the device
93 * @first: start of the IOVA range
94 * @last: end of the IOVA range
95 */
96struct vdpa_iova_range {

--- 71 unchanged lines hidden (view full) ---

168 * @vdev: vdpa device
169 * @idx: virtqueue index
170 * Returns int: irq number of a virtqueue,
171 * negative number if no irq assigned.
172 * @get_vq_align: Get the virtqueue align requirement
173 * for the device
174 * @vdev: vdpa device
175 * Returns virtqueue algin requirement
176 * @get_vq_group: Get the group id for a specific virtqueue
177 * @vdev: vdpa device
178 * @idx: virtqueue index
179 * Returns u32: group id for this virtqueue
175 * @get_device_features: Get virtio features supported by the device
176 * @vdev: vdpa device
177 * Returns the virtio features support by the
178 * device
179 * @set_driver_features: Set virtio features supported by the driver
180 * @vdev: vdpa device
181 * @features: feature support by the driver
182 * Returns integer: success (0) or error (< 0)

--- 98 unchanged lines hidden (view full) ---

281 struct netlink_ext_ack *extack);
282 struct vdpa_notification_area
283 (*get_vq_notification)(struct vdpa_device *vdev, u16 idx);
284 /* vq irq is not expected to be changed once DRIVER_OK is set */
285 int (*get_vq_irq)(struct vdpa_device *vdev, u16 idx);
286
287 /* Device ops */
288 u32 (*get_vq_align)(struct vdpa_device *vdev);
180 * @get_device_features: Get virtio features supported by the device
181 * @vdev: vdpa device
182 * Returns the virtio features support by the
183 * device
184 * @set_driver_features: Set virtio features supported by the driver
185 * @vdev: vdpa device
186 * @features: feature support by the driver
187 * Returns integer: success (0) or error (< 0)

--- 98 unchanged lines hidden (view full) ---

286 struct netlink_ext_ack *extack);
287 struct vdpa_notification_area
288 (*get_vq_notification)(struct vdpa_device *vdev, u16 idx);
289 /* vq irq is not expected to be changed once DRIVER_OK is set */
290 int (*get_vq_irq)(struct vdpa_device *vdev, u16 idx);
291
292 /* Device ops */
293 u32 (*get_vq_align)(struct vdpa_device *vdev);
294 u32 (*get_vq_group)(struct vdpa_device *vdev, u16 idx);
289 u64 (*get_device_features)(struct vdpa_device *vdev);
290 int (*set_driver_features)(struct vdpa_device *vdev, u64 features);
291 u64 (*get_driver_features)(struct vdpa_device *vdev);
292 void (*set_config_cb)(struct vdpa_device *vdev,
293 struct vdpa_callback *cb);
294 u16 (*get_vq_num_max)(struct vdpa_device *vdev);
295 u16 (*get_vq_num_min)(struct vdpa_device *vdev);
296 u32 (*get_device_id)(struct vdpa_device *vdev);

--- 16 unchanged lines hidden (view full) ---

313 int (*dma_unmap)(struct vdpa_device *vdev, u64 iova, u64 size);
314
315 /* Free device resources */
316 void (*free)(struct vdpa_device *vdev);
317};
318
319struct vdpa_device *__vdpa_alloc_device(struct device *parent,
320 const struct vdpa_config_ops *config,
295 u64 (*get_device_features)(struct vdpa_device *vdev);
296 int (*set_driver_features)(struct vdpa_device *vdev, u64 features);
297 u64 (*get_driver_features)(struct vdpa_device *vdev);
298 void (*set_config_cb)(struct vdpa_device *vdev,
299 struct vdpa_callback *cb);
300 u16 (*get_vq_num_max)(struct vdpa_device *vdev);
301 u16 (*get_vq_num_min)(struct vdpa_device *vdev);
302 u32 (*get_device_id)(struct vdpa_device *vdev);

--- 16 unchanged lines hidden (view full) ---

319 int (*dma_unmap)(struct vdpa_device *vdev, u64 iova, u64 size);
320
321 /* Free device resources */
322 void (*free)(struct vdpa_device *vdev);
323};
324
325struct vdpa_device *__vdpa_alloc_device(struct device *parent,
326 const struct vdpa_config_ops *config,
327 unsigned int ngroups,
321 size_t size, const char *name,
322 bool use_va);
323
324/**
325 * vdpa_alloc_device - allocate and initilaize a vDPA device
326 *
327 * @dev_struct: the type of the parent structure
328 * @member: the name of struct vdpa_device within the @dev_struct
329 * @parent: the parent device
330 * @config: the bus operations that is supported by this device
328 size_t size, const char *name,
329 bool use_va);
330
331/**
332 * vdpa_alloc_device - allocate and initilaize a vDPA device
333 *
334 * @dev_struct: the type of the parent structure
335 * @member: the name of struct vdpa_device within the @dev_struct
336 * @parent: the parent device
337 * @config: the bus operations that is supported by this device
338 * @ngroups: the number of virtqueue groups supported by this device
331 * @name: name of the vdpa device
332 * @use_va: indicate whether virtual address must be used by this device
333 *
334 * Return allocated data structure or ERR_PTR upon error
335 */
339 * @name: name of the vdpa device
340 * @use_va: indicate whether virtual address must be used by this device
341 *
342 * Return allocated data structure or ERR_PTR upon error
343 */
336#define vdpa_alloc_device(dev_struct, member, parent, config, name, use_va) \
337 container_of(__vdpa_alloc_device( \
338 parent, config, \
344#define vdpa_alloc_device(dev_struct, member, parent, config, ngroups, name, use_va) \
345 container_of((__vdpa_alloc_device( \
346 parent, config, ngroups, \
339 sizeof(dev_struct) + \
340 BUILD_BUG_ON_ZERO(offsetof( \
347 sizeof(dev_struct) + \
348 BUILD_BUG_ON_ZERO(offsetof( \
341 dev_struct, member)), name, use_va), \
349 dev_struct, member)), name, use_va)), \
342 dev_struct, member)
343
344int vdpa_register_device(struct vdpa_device *vdev, u32 nvqs);
345void vdpa_unregister_device(struct vdpa_device *vdev);
346
347int _vdpa_register_device(struct vdpa_device *vdev, u32 nvqs);
348void _vdpa_unregister_device(struct vdpa_device *vdev);
349

--- 130 unchanged lines hidden ---
350 dev_struct, member)
351
352int vdpa_register_device(struct vdpa_device *vdev, u32 nvqs);
353void vdpa_unregister_device(struct vdpa_device *vdev);
354
355int _vdpa_register_device(struct vdpa_device *vdev, u32 nvqs);
356void _vdpa_unregister_device(struct vdpa_device *vdev);
357

--- 130 unchanged lines hidden ---