DPDK  18.05.1
rte_vdpa.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Intel Corporation
3  */
4 
5 #ifndef _RTE_VDPA_H_
6 #define _RTE_VDPA_H_
7 
14 #include <rte_pci.h>
15 #include "rte_vhost.h"
16 
17 #define MAX_VDPA_NAME_LEN 128
18 
19 enum vdpa_addr_type {
20  PCI_ADDR,
21  VDPA_ADDR_MAX
22 };
23 
24 struct rte_vdpa_dev_addr {
25  enum vdpa_addr_type type;
26  union {
27  uint8_t __dummy[64];
28  struct rte_pci_addr pci_addr;
29  };
30 };
31 
32 struct rte_vdpa_dev_ops {
33  /* Get capabilities of this device */
34  int (*get_queue_num)(int did, uint32_t *queue_num);
35  int (*get_features)(int did, uint64_t *features);
36  int (*get_protocol_features)(int did, uint64_t *protocol_features);
37 
38  /* Driver configure/close the device */
39  int (*dev_conf)(int vid);
40  int (*dev_close)(int vid);
41 
42  /* Enable/disable this vring */
43  int (*set_vring_state)(int vid, int vring, int state);
44 
45  /* Set features when changed */
46  int (*set_features)(int vid);
47 
48  /* Destination operations when migration done */
49  int (*migration_done)(int vid);
50 
51  /* Get the vfio group fd */
52  int (*get_vfio_group_fd)(int vid);
53 
54  /* Get the vfio device fd */
55  int (*get_vfio_device_fd)(int vid);
56 
57  /* Get the notify area info of the queue */
58  int (*get_notify_area)(int vid, int qid,
59  uint64_t *offset, uint64_t *size);
60 
61  /* Reserved for future extension */
62  void *reserved[5];
63 };
64 
65 struct rte_vdpa_device {
66  struct rte_vdpa_dev_addr addr;
67  struct rte_vdpa_dev_ops *ops;
69 
70 /* Register a vdpa device, return did if successful, -1 on failure */
71 int __rte_experimental
72 rte_vdpa_register_device(struct rte_vdpa_dev_addr *addr,
73  struct rte_vdpa_dev_ops *ops);
74 
75 /* Unregister a vdpa device, return -1 on failure */
76 int __rte_experimental
77 rte_vdpa_unregister_device(int did);
78 
79 /* Find did of a vdpa device, return -1 on failure */
80 int __rte_experimental
81 rte_vdpa_find_device_id(struct rte_vdpa_dev_addr *addr);
82 
83 /* Find a vdpa device based on did */
84 struct rte_vdpa_device * __rte_experimental
85 rte_vdpa_get_device(int did);
86 
87 #endif /* _RTE_VDPA_H_ */