vhost: avoid function call in data path

Previously, get_device() is a function call. It's OK for slow path
configuration, but takes some cycles for data path.

To avoid that, we turn this function to inline type.

Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
This commit is contained in:
Jianfeng Tan 2018-02-14 05:01:00 +01:00 committed by Ferruh Yigit
parent bdf78f9f24
commit ae034edaa6
2 changed files with 12 additions and 14 deletions
lib/librte_vhost

@ -68,19 +68,6 @@ __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
return 0;
}
struct virtio_net *
get_device(int vid)
{
struct virtio_net *dev = vhost_devices[vid];
if (unlikely(!dev)) {
RTE_LOG(ERR, VHOST_CONFIG,
"(%d) device not found.\n", vid);
}
return dev;
}
void
cleanup_vq(struct vhost_virtqueue *vq, int destroy)
{

@ -343,7 +343,18 @@ gpa_to_hpa(struct virtio_net *dev, uint64_t gpa, uint64_t size)
return 0;
}
struct virtio_net *get_device(int vid);
static __rte_always_inline struct virtio_net *
get_device(int vid)
{
struct virtio_net *dev = vhost_devices[vid];
if (unlikely(!dev)) {
RTE_LOG(ERR, VHOST_CONFIG,
"(%d) device not found.\n", vid);
}
return dev;
}
int vhost_new_device(void);
void cleanup_device(struct virtio_net *dev, int destroy);