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/virtio.h>
9 #include <linux/vhost_iotlb.h>
10 #include <linux/virtio_net.h>
11 #include <linux/virtio_blk.h>
12 #include <linux/if_ether.h>
13
14 /**
15 * struct vdpa_callback - vDPA callback definition.
16 * @callback: interrupt callback function
17 * @private: the data passed to the callback function
18 * @trigger: the eventfd for the callback (Optional).
19 * When it is set, the vDPA driver must guarantee that
20 * signaling it is functional equivalent to triggering
21 * the callback. Then vDPA parent can signal it directly
22 * instead of triggering the callback.
23 */
24 struct vdpa_callback {
25 irqreturn_t (*callback)(void *data);
26 void *private;
27 struct eventfd_ctx *trigger;
28 };
29
30 /**
31 * struct vdpa_notification_area - vDPA notification area
32 * @addr: base address of the notification area
33 * @size: size of the notification area
34 */
35 struct vdpa_notification_area {
36 resource_size_t addr;
37 resource_size_t size;
38 };
39
40 /**
41 * struct vdpa_vq_state_split - vDPA split virtqueue state
42 * @avail_index: available index
43 */
44 struct vdpa_vq_state_split {
45 u16 avail_index;
46 };
47
48 /**
49 * struct vdpa_vq_state_packed - vDPA packed virtqueue state
50 * @last_avail_counter: last driver ring wrap counter observed by device
51 * @last_avail_idx: device available index
52 * @last_used_counter: device ring wrap counter
53 * @last_used_idx: used index
54 */
55 struct vdpa_vq_state_packed {
56 u16 last_avail_counter:1;
57 u16 last_avail_idx:15;
58 u16 last_used_counter:1;
59 u16 last_used_idx:15;
60 };
61
62 struct vdpa_vq_state {
63 union {
64 struct vdpa_vq_state_split split;
65 struct vdpa_vq_state_packed packed;
66 };
67 };
68
69 struct vdpa_mgmt_dev;
70
71 /**
72 * struct vdpa_device - representation of a vDPA device
73 * @dev: underlying device
74 * @vmap: the metadata passed to upper layer to be used for mapping
75 * @config: the configuration ops for this device.
76 * @map: the map ops for this device
77 * @cf_lock: Protects get and set access to configuration layout.
78 * @index: device index
79 * @features_valid: were features initialized? for legacy guests
80 * @ngroups: the number of virtqueue groups
81 * @nas: the number of address spaces
82 * @use_va: indicate whether virtual address must be used by this device
83 * @nvqs: maximum number of supported virtqueues
84 * @mdev: management device pointer; caller must setup when registering device as part
85 * of dev_add() mgmtdev ops callback before invoking _vdpa_register_device().
86 */
87 struct vdpa_device {
88 struct device dev;
89 union virtio_map vmap;
90 const struct vdpa_config_ops *config;
91 const struct virtio_map_ops *map;
92 struct rw_semaphore cf_lock; /* Protects get/set config */
93 unsigned int index;
94 bool features_valid;
95 bool use_va;
96 u32 nvqs;
97 struct vdpa_mgmt_dev *mdev;
98 unsigned int ngroups;
99 unsigned int nas;
100 };
101
102 /**
103 * struct vdpa_iova_range - the IOVA range support by the device
104 * @first: start of the IOVA range
105 * @last: end of the IOVA range
106 */
107 struct vdpa_iova_range {
108 u64 first;
109 u64 last;
110 };
111
112 struct vdpa_dev_set_config {
113 u64 device_features;
114 struct {
115 u8 mac[ETH_ALEN];
116 u16 mtu;
117 u16 max_vq_pairs;
118 } net;
119 u64 mask;
120 };
121
122 /**
123 * struct vdpa_map_file - file area for device memory mapping
124 * @file: vma->vm_file for the mapping
125 * @offset: mapping offset in the vm_file
126 */
127 struct vdpa_map_file {
128 struct file *file;
129 u64 offset;
130 };
131
132 /**
133 * struct vdpa_config_ops - operations for configuring a vDPA device.
134 * Note: vDPA device drivers are required to implement all of the
135 * operations unless it is mentioned to be optional in the following
136 * list.
137 *
138 * @set_vq_address: Set the address of virtqueue
139 * @vdev: vdpa device
140 * @idx: virtqueue index
141 * @desc_area: address of desc area
142 * @driver_area: address of driver area
143 * @device_area: address of device area
144 * Returns integer: success (0) or error (< 0)
145 * @set_vq_num: Set the size of virtqueue
146 * @vdev: vdpa device
147 * @idx: virtqueue index
148 * @num: the size of virtqueue
149 * @kick_vq: Kick the virtqueue
150 * @vdev: vdpa device
151 * @idx: virtqueue index
152 * @kick_vq_with_data: Kick the virtqueue and supply extra data
153 * (only if VIRTIO_F_NOTIFICATION_DATA is negotiated)
154 * @vdev: vdpa device
155 * @data for split virtqueue:
156 * 16 bits vqn and 16 bits next available index.
157 * @data for packed virtqueue:
158 * 16 bits vqn, 15 least significant bits of
159 * next available index and 1 bit next_wrap.
160 * @set_vq_cb: Set the interrupt callback function for
161 * a virtqueue
162 * @vdev: vdpa device
163 * @idx: virtqueue index
164 * @cb: virtio-vdev interrupt callback structure
165 * @set_vq_ready: Set ready status for a virtqueue
166 * @vdev: vdpa device
167 * @idx: virtqueue index
168 * @ready: ready (true) not ready(false)
169 * @get_vq_ready: Get ready status for a virtqueue
170 * @vdev: vdpa device
171 * @idx: virtqueue index
172 * Returns boolean: ready (true) or not (false)
173 * @set_vq_state: Set the state for a virtqueue
174 * @vdev: vdpa device
175 * @idx: virtqueue index
176 * @state: pointer to set virtqueue state (last_avail_idx)
177 * Returns integer: success (0) or error (< 0)
178 * @get_vq_state: Get the state for a virtqueue
179 * @vdev: vdpa device
180 * @idx: virtqueue index
181 * @state: pointer to returned state (last_avail_idx)
182 * @get_vendor_vq_stats: Get the vendor statistics of a device.
183 * @vdev: vdpa device
184 * @idx: virtqueue index
185 * @msg: socket buffer holding stats message
186 * @extack: extack for reporting error messages
187 * Returns integer: success (0) or error (< 0)
188 * @get_vq_notification: Get the notification area for a virtqueue (optional)
189 * @vdev: vdpa device
190 * @idx: virtqueue index
191 * Returns the notification area
192 * @get_vq_irq: Get the irq number of a virtqueue (optional,
193 * but must implemented if require vq irq offloading)
194 * @vdev: vdpa device
195 * @idx: virtqueue index
196 * Returns int: irq number of a virtqueue,
197 * negative number if no irq assigned.
198 * @get_vq_size: Get the size of a specific virtqueue (optional)
199 * @vdev: vdpa device
200 * @idx: virtqueue index
201 * Return u16: the size of the virtqueue
202 * @get_vq_align: Get the virtqueue align requirement
203 * for the device
204 * @vdev: vdpa device
205 * Returns virtqueue algin requirement
206 * @get_vq_group: Get the group id for a specific
207 * virtqueue (optional)
208 * @vdev: vdpa device
209 * @idx: virtqueue index
210 * Returns u32: group id for this virtqueue
211 * @get_vq_desc_group: Get the group id for the descriptor table of
212 * a specific virtqueue (optional)
213 * @vdev: vdpa device
214 * @idx: virtqueue index
215 * Returns u32: group id for the descriptor table
216 * portion of this virtqueue. Could be different
217 * than the one from @get_vq_group, in which case
218 * the access to the descriptor table can be
219 * confined to a separate asid, isolating from
220 * the virtqueue's buffer address access.
221 * @get_device_features: Get virtio features supported by the device
222 * @vdev: vdpa device
223 * Returns the virtio features support by the
224 * device
225 * @get_backend_features: Get parent-specific backend features (optional)
226 * Returns the vdpa features supported by the
227 * device.
228 * @set_driver_features: Set virtio features supported by the driver
229 * @vdev: vdpa device
230 * @features: feature support by the driver
231 * Returns integer: success (0) or error (< 0)
232 * @get_driver_features: Get the virtio driver features in action
233 * @vdev: vdpa device
234 * Returns the virtio features accepted
235 * @set_config_cb: Set the config interrupt callback
236 * @vdev: vdpa device
237 * @cb: virtio-vdev interrupt callback structure
238 * @get_vq_num_max: Get the max size of virtqueue
239 * @vdev: vdpa device
240 * Returns u16: max size of virtqueue
241 * @get_vq_num_min: Get the min size of virtqueue (optional)
242 * @vdev: vdpa device
243 * Returns u16: min size of virtqueue
244 * @get_device_id: Get virtio device id
245 * @vdev: vdpa device
246 * Returns u32: virtio device id
247 * @get_vendor_id: Get id for the vendor that provides this device
248 * @vdev: vdpa device
249 * Returns u32: virtio vendor id
250 * @get_status: Get the device status
251 * @vdev: vdpa device
252 * Returns u8: virtio device status
253 * @set_status: Set the device status
254 * @vdev: vdpa device
255 * @status: virtio device status
256 * @reset: Reset device
257 * @vdev: vdpa device
258 * Returns integer: success (0) or error (< 0)
259 * @compat_reset: Reset device with compatibility quirks to
260 * accommodate older userspace. Only needed by
261 * parent driver which used to have bogus reset
262 * behaviour, and has to maintain such behaviour
263 * for compatibility with older userspace.
264 * Historically compliant driver only has to
265 * implement .reset, Historically non-compliant
266 * driver should implement both.
267 * @vdev: vdpa device
268 * @flags: compatibility quirks for reset
269 * Returns integer: success (0) or error (< 0)
270 * @suspend: Suspend the device (optional)
271 * @vdev: vdpa device
272 * Returns integer: success (0) or error (< 0)
273 * @resume: Resume the device (optional)
274 * @vdev: vdpa device
275 * Returns integer: success (0) or error (< 0)
276 * @get_config_size: Get the size of the configuration space includes
277 * fields that are conditional on feature bits.
278 * @vdev: vdpa device
279 * Returns size_t: configuration size
280 * @get_config: Read from device specific configuration space
281 * @vdev: vdpa device
282 * @offset: offset from the beginning of
283 * configuration space
284 * @buf: buffer used to read to
285 * @len: the length to read from
286 * configuration space
287 * @set_config: Write to device specific configuration space
288 * @vdev: vdpa device
289 * @offset: offset from the beginning of
290 * configuration space
291 * @buf: buffer used to write from
292 * @len: the length to write to
293 * configuration space
294 * @get_generation: Get device config generation (optional)
295 * @vdev: vdpa device
296 * Returns u32: device generation
297 * @get_iova_range: Get supported iova range (optional)
298 * @vdev: vdpa device
299 * Returns the iova range supported by
300 * the device.
301 * @set_vq_affinity: Set the affinity of virtqueue (optional)
302 * @vdev: vdpa device
303 * @idx: virtqueue index
304 * @cpu_mask: the affinity mask
305 * Returns integer: success (0) or error (< 0)
306 * @get_vq_affinity: Get the affinity of virtqueue (optional)
307 * @vdev: vdpa device
308 * @idx: virtqueue index
309 * Returns the affinity mask
310 * @set_group_asid: Set address space identifier for a
311 * virtqueue group (optional). Caller must
312 * prevent this from being executed concurrently
313 * with set_status.
314 * @vdev: vdpa device
315 * @group: virtqueue group
316 * @asid: address space id for this group
317 * Returns integer: success (0) or error (< 0)
318 * @set_map: Set device memory mapping (optional)
319 * Needed for device that using device
320 * specific DMA translation (on-chip IOMMU)
321 * @vdev: vdpa device
322 * @asid: address space identifier
323 * @iotlb: vhost memory mapping to be
324 * used by the vDPA
325 * Returns integer: success (0) or error (< 0)
326 * @dma_map: Map an area of PA to IOVA (optional)
327 * Needed for device that using device
328 * specific DMA translation (on-chip IOMMU)
329 * and preferring incremental map.
330 * @vdev: vdpa device
331 * @asid: address space identifier
332 * @iova: iova to be mapped
333 * @size: size of the area
334 * @pa: physical address for the map
335 * @perm: device access permission (VHOST_MAP_XX)
336 * Returns integer: success (0) or error (< 0)
337 * @dma_unmap: Unmap an area of IOVA (optional but
338 * must be implemented with dma_map)
339 * Needed for device that using device
340 * specific DMA translation (on-chip IOMMU)
341 * and preferring incremental unmap.
342 * @vdev: vdpa device
343 * @asid: address space identifier
344 * @iova: iova to be unmapped
345 * @size: size of the area
346 * Returns integer: success (0) or error (< 0)
347 * @reset_map: Reset device memory mapping to the default
348 * state (optional)
349 * Needed for devices that are using device
350 * specific DMA translation and prefer mapping
351 * to be decoupled from the virtio life cycle,
352 * i.e. device .reset op does not reset mapping
353 * @vdev: vdpa device
354 * @asid: address space identifier
355 * Returns integer: success (0) or error (< 0)
356 * @get_vq_map: Get the map metadata for a specific
357 * virtqueue (optional)
358 * @vdev: vdpa device
359 * @idx: virtqueue index
360 * Returns map token union error (NULL)
361 * @bind_mm: Bind the device to a specific address space
362 * so the vDPA framework can use VA when this
363 * callback is implemented. (optional)
364 * @vdev: vdpa device
365 * @mm: address space to bind
366 * @unbind_mm: Unbind the device from the address space
367 * bound using the bind_mm callback. (optional)
368 * @vdev: vdpa device
369 * @free: Free resources that belongs to vDPA (optional)
370 * @vdev: vdpa device
371 */
372 struct vdpa_config_ops {
373 /* Virtqueue ops */
374 int (*set_vq_address)(struct vdpa_device *vdev,
375 u16 idx, u64 desc_area, u64 driver_area,
376 u64 device_area);
377 void (*set_vq_num)(struct vdpa_device *vdev, u16 idx, u32 num);
378 void (*kick_vq)(struct vdpa_device *vdev, u16 idx);
379 void (*kick_vq_with_data)(struct vdpa_device *vdev, u32 data);
380 void (*set_vq_cb)(struct vdpa_device *vdev, u16 idx,
381 struct vdpa_callback *cb);
382 void (*set_vq_ready)(struct vdpa_device *vdev, u16 idx, bool ready);
383 bool (*get_vq_ready)(struct vdpa_device *vdev, u16 idx);
384 int (*set_vq_state)(struct vdpa_device *vdev, u16 idx,
385 const struct vdpa_vq_state *state);
386 int (*get_vq_state)(struct vdpa_device *vdev, u16 idx,
387 struct vdpa_vq_state *state);
388 int (*get_vendor_vq_stats)(struct vdpa_device *vdev, u16 idx,
389 struct sk_buff *msg,
390 struct netlink_ext_ack *extack);
391 struct vdpa_notification_area
392 (*get_vq_notification)(struct vdpa_device *vdev, u16 idx);
393 /* vq irq is not expected to be changed once DRIVER_OK is set */
394 int (*get_vq_irq)(struct vdpa_device *vdev, u16 idx);
395 u16 (*get_vq_size)(struct vdpa_device *vdev, u16 idx);
396
397 /* Device ops */
398 u32 (*get_vq_align)(struct vdpa_device *vdev);
399 u32 (*get_vq_group)(struct vdpa_device *vdev, u16 idx);
400 u32 (*get_vq_desc_group)(struct vdpa_device *vdev, u16 idx);
401 u64 (*get_device_features)(struct vdpa_device *vdev);
402 u64 (*get_backend_features)(const struct vdpa_device *vdev);
403 int (*set_driver_features)(struct vdpa_device *vdev, u64 features);
404 u64 (*get_driver_features)(struct vdpa_device *vdev);
405 void (*set_config_cb)(struct vdpa_device *vdev,
406 struct vdpa_callback *cb);
407 u16 (*get_vq_num_max)(struct vdpa_device *vdev);
408 u16 (*get_vq_num_min)(struct vdpa_device *vdev);
409 u32 (*get_device_id)(struct vdpa_device *vdev);
410 u32 (*get_vendor_id)(struct vdpa_device *vdev);
411 u8 (*get_status)(struct vdpa_device *vdev);
412 void (*set_status)(struct vdpa_device *vdev, u8 status);
413 int (*reset)(struct vdpa_device *vdev);
414 int (*compat_reset)(struct vdpa_device *vdev, u32 flags);
415 #define VDPA_RESET_F_CLEAN_MAP 1
416 int (*suspend)(struct vdpa_device *vdev);
417 int (*resume)(struct vdpa_device *vdev);
418 size_t (*get_config_size)(struct vdpa_device *vdev);
419 void (*get_config)(struct vdpa_device *vdev, unsigned int offset,
420 void *buf, unsigned int len);
421 void (*set_config)(struct vdpa_device *vdev, unsigned int offset,
422 const void *buf, unsigned int len);
423 u32 (*get_generation)(struct vdpa_device *vdev);
424 struct vdpa_iova_range (*get_iova_range)(struct vdpa_device *vdev);
425 int (*set_vq_affinity)(struct vdpa_device *vdev, u16 idx,
426 const struct cpumask *cpu_mask);
427 const struct cpumask *(*get_vq_affinity)(struct vdpa_device *vdev,
428 u16 idx);
429
430 /* DMA ops */
431 int (*set_map)(struct vdpa_device *vdev, unsigned int asid,
432 struct vhost_iotlb *iotlb);
433 int (*dma_map)(struct vdpa_device *vdev, unsigned int asid,
434 u64 iova, u64 size, u64 pa, u32 perm, void *opaque);
435 int (*dma_unmap)(struct vdpa_device *vdev, unsigned int asid,
436 u64 iova, u64 size);
437 int (*reset_map)(struct vdpa_device *vdev, unsigned int asid);
438 int (*set_group_asid)(struct vdpa_device *vdev, unsigned int group,
439 unsigned int asid);
440 union virtio_map (*get_vq_map)(struct vdpa_device *vdev, u16 idx);
441 int (*bind_mm)(struct vdpa_device *vdev, struct mm_struct *mm);
442 void (*unbind_mm)(struct vdpa_device *vdev);
443
444 /* Free device resources */
445 void (*free)(struct vdpa_device *vdev);
446 };
447
448 struct vdpa_device *__vdpa_alloc_device(struct device *parent,
449 const struct vdpa_config_ops *config,
450 const struct virtio_map_ops *map,
451 unsigned int ngroups, unsigned int nas,
452 size_t size, const char *name,
453 bool use_va);
454
455 /**
456 * vdpa_alloc_device - allocate and initilaize a vDPA device
457 *
458 * @dev_struct: the type of the parent structure
459 * @member: the name of struct vdpa_device within the @dev_struct
460 * @parent: the parent device
461 * @config: the bus operations that is supported by this device
462 * @map: the map operations that is supported by this device
463 * @ngroups: the number of virtqueue groups supported by this device
464 * @nas: the number of address spaces
465 * @name: name of the vdpa device
466 * @use_va: indicate whether virtual address must be used by this device
467 *
468 * Return allocated data structure or ERR_PTR upon error
469 */
470 #define vdpa_alloc_device(dev_struct, member, parent, config, map, \
471 ngroups, nas, name, use_va) \
472 container_of((__vdpa_alloc_device( \
473 parent, config, map, ngroups, nas, \
474 (sizeof(dev_struct) + \
475 BUILD_BUG_ON_ZERO(offsetof( \
476 dev_struct, member))), name, use_va)), \
477 dev_struct, member)
478
479 int vdpa_register_device(struct vdpa_device *vdev, u32 nvqs);
480 void vdpa_unregister_device(struct vdpa_device *vdev);
481
482 int _vdpa_register_device(struct vdpa_device *vdev, u32 nvqs);
483 void _vdpa_unregister_device(struct vdpa_device *vdev);
484
485 /**
486 * struct vdpa_driver - operations for a vDPA driver
487 * @driver: underlying device driver
488 * @probe: the function to call when a device is found. Returns 0 or -errno.
489 * @remove: the function to call when a device is removed.
490 */
491 struct vdpa_driver {
492 struct device_driver driver;
493 int (*probe)(struct vdpa_device *vdev);
494 void (*remove)(struct vdpa_device *vdev);
495 };
496
497 #define vdpa_register_driver(drv) \
498 __vdpa_register_driver(drv, THIS_MODULE)
499 int __vdpa_register_driver(struct vdpa_driver *drv, struct module *owner);
500 void vdpa_unregister_driver(struct vdpa_driver *drv);
501
502 #define module_vdpa_driver(__vdpa_driver) \
503 module_driver(__vdpa_driver, vdpa_register_driver, \
504 vdpa_unregister_driver)
505
drv_to_vdpa(struct device_driver * driver)506 static inline struct vdpa_driver *drv_to_vdpa(struct device_driver *driver)
507 {
508 return container_of(driver, struct vdpa_driver, driver);
509 }
510
dev_to_vdpa(struct device * _dev)511 static inline struct vdpa_device *dev_to_vdpa(struct device *_dev)
512 {
513 return container_of(_dev, struct vdpa_device, dev);
514 }
515
vdpa_get_drvdata(const struct vdpa_device * vdev)516 static inline void *vdpa_get_drvdata(const struct vdpa_device *vdev)
517 {
518 return dev_get_drvdata(&vdev->dev);
519 }
520
vdpa_set_drvdata(struct vdpa_device * vdev,void * data)521 static inline void vdpa_set_drvdata(struct vdpa_device *vdev, void *data)
522 {
523 dev_set_drvdata(&vdev->dev, data);
524 }
525
vdpa_get_map(struct vdpa_device * vdev)526 static inline union virtio_map vdpa_get_map(struct vdpa_device *vdev)
527 {
528 return vdev->vmap;
529 }
530
vdpa_reset(struct vdpa_device * vdev,u32 flags)531 static inline int vdpa_reset(struct vdpa_device *vdev, u32 flags)
532 {
533 const struct vdpa_config_ops *ops = vdev->config;
534 int ret;
535
536 down_write(&vdev->cf_lock);
537 vdev->features_valid = false;
538 if (ops->compat_reset && flags)
539 ret = ops->compat_reset(vdev, flags);
540 else
541 ret = ops->reset(vdev);
542 up_write(&vdev->cf_lock);
543 return ret;
544 }
545
vdpa_set_features_unlocked(struct vdpa_device * vdev,u64 features)546 static inline int vdpa_set_features_unlocked(struct vdpa_device *vdev, u64 features)
547 {
548 const struct vdpa_config_ops *ops = vdev->config;
549 int ret;
550
551 vdev->features_valid = true;
552 ret = ops->set_driver_features(vdev, features);
553
554 return ret;
555 }
556
vdpa_set_features(struct vdpa_device * vdev,u64 features)557 static inline int vdpa_set_features(struct vdpa_device *vdev, u64 features)
558 {
559 int ret;
560
561 down_write(&vdev->cf_lock);
562 ret = vdpa_set_features_unlocked(vdev, features);
563 up_write(&vdev->cf_lock);
564
565 return ret;
566 }
567
568 void vdpa_get_config(struct vdpa_device *vdev, unsigned int offset,
569 void *buf, unsigned int len);
570 void vdpa_set_config(struct vdpa_device *dev, unsigned int offset,
571 const void *buf, unsigned int length);
572 void vdpa_set_status(struct vdpa_device *vdev, u8 status);
573
574 /**
575 * struct vdpa_mgmtdev_ops - vdpa device ops
576 * @dev_add: Add a vdpa device using alloc and register
577 * @mdev: parent device to use for device addition
578 * @name: name of the new vdpa device
579 * @config: config attributes to apply to the device under creation
580 * Driver need to add a new device using _vdpa_register_device()
581 * after fully initializing the vdpa device. Driver must return 0
582 * on success or appropriate error code.
583 * @dev_del: Remove a vdpa device using unregister
584 * @mdev: parent device to use for device removal
585 * @dev: vdpa device to remove
586 * Driver need to remove the specified device by calling
587 * _vdpa_unregister_device().
588 * @dev_set_attr: change a vdpa device's attr after it was create
589 * @mdev: parent device to use for device
590 * @dev: vdpa device structure
591 * @config:Attributes to be set for the device.
592 * The driver needs to check the mask of the structure and then set
593 * the related information to the vdpa device. The driver must return 0
594 * if set successfully.
595 */
596 struct vdpa_mgmtdev_ops {
597 int (*dev_add)(struct vdpa_mgmt_dev *mdev, const char *name,
598 const struct vdpa_dev_set_config *config);
599 void (*dev_del)(struct vdpa_mgmt_dev *mdev, struct vdpa_device *dev);
600 int (*dev_set_attr)(struct vdpa_mgmt_dev *mdev, struct vdpa_device *dev,
601 const struct vdpa_dev_set_config *config);
602 };
603
604 /**
605 * struct vdpa_mgmt_dev - vdpa management device
606 * @device: Management parent device
607 * @ops: operations supported by management device
608 * @id_table: Pointer to device id table of supported ids
609 * @config_attr_mask: bit mask of attributes of type enum vdpa_attr that
610 * management device support during dev_add callback
611 * @list: list entry
612 * @supported_features: features supported by device
613 * @max_supported_vqs: maximum number of virtqueues supported by device
614 */
615 struct vdpa_mgmt_dev {
616 struct device *device;
617 const struct vdpa_mgmtdev_ops *ops;
618 struct virtio_device_id *id_table;
619 u64 config_attr_mask;
620 struct list_head list;
621 u64 supported_features;
622 u32 max_supported_vqs;
623 };
624
625 int vdpa_mgmtdev_register(struct vdpa_mgmt_dev *mdev);
626 void vdpa_mgmtdev_unregister(struct vdpa_mgmt_dev *mdev);
627
628 #endif /* _LINUX_VDPA_H */
629