#include <rte_tailq.h>
#include "rte_vdpa.h"
+#include "rte_vdpa_dev.h"
#include "vhost.h"
/** Double linked list of vDPA devices. */
static struct vdpa_device_list vdpa_device_list =
TAILQ_HEAD_INITIALIZER(vdpa_device_list);
static rte_spinlock_t vdpa_device_list_lock = RTE_SPINLOCK_INITIALIZER;
-static uint32_t vdpa_device_num;
/* Unsafe, needs to be called with vdpa_device_list_lock held */
if (ops == NULL)
return NULL;
+ /* Check mandatory ops are implemented */
+ if (!ops->get_queue_num || !ops->get_features ||
+ !ops->get_protocol_features || !ops->dev_conf ||
+ !ops->dev_close || !ops->set_vring_state ||
+ !ops->set_features) {
+ VHOST_LOG_CONFIG(ERR,
+ "Some mandatory vDPA ops aren't implemented\n");
+ return NULL;
+ }
+
rte_spinlock_lock(&vdpa_device_list_lock);
/* Check the device hasn't been register already */
dev = __vdpa_find_device_by_name(rte_dev->name);
dev->device = rte_dev;
dev->ops = ops;
TAILQ_INSERT_TAIL(&vdpa_device_list, dev, next);
- vdpa_device_num++;
out_unlock:
rte_spinlock_unlock(&vdpa_device_list_lock);
TAILQ_REMOVE(&vdpa_device_list, dev, next);
rte_free(dev);
- vdpa_device_num--;
ret = 0;
break;
}
return ret;
}
-int
-rte_vdpa_get_device_num(void)
-{
- return vdpa_device_num;
-}
-
int
rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m)
{
idx++;
}
- rte_smp_wmb();
- vq->used->idx = idx_m;
+ /* used idx is the synchronization point for the split vring */
+ __atomic_store_n(&vq->used->idx, idx_m, __ATOMIC_RELEASE);
if (dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX))
vring_used_event(s_vring) = idx_m;
return -1;
}
+int
+rte_vdpa_get_queue_num(struct rte_vdpa_device *dev, uint32_t *queue_num)
+{
+ if (dev == NULL || dev->ops == NULL || dev->ops->get_queue_num == NULL)
+ return -1;
+
+ return dev->ops->get_queue_num(dev, queue_num);
+}
+
+int
+rte_vdpa_get_features(struct rte_vdpa_device *dev, uint64_t *features)
+{
+ if (dev == NULL || dev->ops == NULL || dev->ops->get_features == NULL)
+ return -1;
+
+ return dev->ops->get_features(dev, features);
+}
+
+int
+rte_vdpa_get_protocol_features(struct rte_vdpa_device *dev, uint64_t *features)
+{
+ if (dev == NULL || dev->ops == NULL ||
+ dev->ops->get_protocol_features == NULL)
+ return -1;
+
+ return dev->ops->get_protocol_features(dev, features);
+}
+
int
rte_vdpa_get_stats_names(struct rte_vdpa_device *dev,
struct rte_vdpa_stat_name *stats_names,