]> git.droids-corp.org - dpdk.git/commitdiff
vhost: avoid function call in data path
authorJianfeng Tan <jianfeng.tan@intel.com>
Wed, 14 Feb 2018 04:01:00 +0000 (05:01 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 30 Mar 2018 12:08:42 +0000 (14:08 +0200)
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>
lib/librte_vhost/vhost.c
lib/librte_vhost/vhost.h

index a407067e2e6bd7b0070cc14b533bf751e2b021ca..f6f12a03b28a59bfcf6d7ae29a0ec7b32d32c489 100644 (file)
@@ -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)
 {
index ecd5b7b035c2026179b29f70460a7402bf12034c..3fce13bd9c7f9f811dd7e6a8442b9bc9dd7a1fb9 100644 (file)
@@ -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);