Commit Graph

20 Commits

Author SHA1 Message Date
Huawei Xie
1c01d52392 vhost: add debug print
Define PRINT_PACKET and LOG_DEBUG macros.

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
2014-10-13 19:16:54 +02:00
Huawei Xie
a58f905514 vhost: add private context field
priv field could be used to store application specific context.

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
2014-10-13 19:16:54 +02:00
Huawei Xie
3d671af711 vhost: supported features
VHOST_SUPPORTED_FEATURES is the feature mask that vhost lib supports.
VHOST_FEATURES is the feature mask vhost currently supports after some features are turned on/off.

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
[Thomas: split patch]
2014-10-13 19:16:54 +02:00
Huawei Xie
9eed6bfd2e vhost: allow to enable or disable features
Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
[Thomas: split patch]
2014-10-13 19:16:54 +02:00
Huawei Xie
7202b0a824 vhost: get available vring entries
Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
[Thomas: split patch]
2014-10-13 19:16:54 +02:00
Huawei Xie
28689ff04d vhost: rename ops registering function
Rename init_virtio_net as rte_vhost_callback_register API.
rte_vhost_callback_register register the callbacks called when a
vhost device is created and ready to be added to data processing core
or is de-actived by guest.

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
2014-10-13 19:16:54 +02:00
Huawei Xie
e5c2ded503 vhost: expose register and start functions
Rename register_cuse_device as rte_vhost_driver_register API.
Rename start_session_loop as rte_vhost_driver_session_start API.

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
2014-10-13 19:16:54 +02:00
Huawei Xie
f782576959 vhost: get internal ops when registering
vhost_net_device_ops is internal implementation in vhost lib.
register_cuse_device will be vhost driver register API.
There is no need for it to know the internal vhost ops.
Instead, that ops is retrieved in register_cuse_device
through get_virtio_net_callbacks.

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
2014-10-13 19:16:54 +02:00
Huawei Xie
17b8320a3e vhost: remove index parameter
Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
2014-10-13 19:16:54 +02:00
Huawei Xie
a4fff3bba8 vhost: enqueue/dequeue burst
rte_vhost_enqueue_burst copies host packets to guest.
rte_vhost_enqueue_burst will call virtio_dev_rx and virtio_dev_merge_rx
respectively depending on whether merge-able feature is negotiated or not
in the vhost device.

virtio_dev_merge_tx is renamed to rte_vhost_dequeue_burst.
rte_vhost_dequeue_burst gets to-be-sent packets from guest.

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
[Thomas: merged patches]
2014-10-13 19:16:54 +02:00
Huawei Xie
830bea8bc4 vhost: add queue id parameter
queue_id parameter is added to Rx/Tx functions for multiple queue support
in future.

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
2014-10-13 19:16:54 +02:00
Huawei Xie
fa325fa413 vhost: calculate mbuf size
As a lib, we have no idea the app defined mbuf size.
This patch will calculate mbuf size dynamically.

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
2014-10-13 19:16:53 +02:00
Huawei Xie
20f16ce646 vhost: return packets to upper layer
This patch makes virtio_dev_merge_tx return the received packets to app layer.
Previously virtio_tx_route was called to route these packets and then free them.

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
2014-10-13 19:16:53 +02:00
Huawei Xie
7f456f6d61 vhost: move address translation function
Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
[Thomas: split from a previous patch]
2014-10-13 19:16:04 +02:00
Huawei Xie
c19dc7db15 vhost: move internal structure
The structure virtio_net_config_ll is moved to virtio_net.c.
It is related to internal virtio device management,
so it should not be exposed to other files.

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
2014-10-13 19:13:10 +02:00
Huawei Xie
8a7576c3dc vhost: remove retry logic
It was used to wait some time and retry when there are not enough descriptors.
App could implement this policy easily if it needs.

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
2014-10-13 19:13:10 +02:00
Huawei Xie
0a739691fc vhost: remove zero copy memory region generation logic
Currently zero copy feature isn't generic as it couples closely with nic.
It isn't put in the vhost lib in this version.
gpa(guest physical address) to hpa(host physical address) mapping region
logic is removed.

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
2014-10-13 19:13:10 +02:00
Huawei Xie
68e6490476 vhost: remove switching related logics
The following logics will be moved to vhost example:
 1. mac learning, which is used to learn the mac address from the first
transmitted packet of guest and bind the vhost device to a queue in a
pool of VMDQ.
 2. VMDQ mac/vlan filter: Each pool the vhost device is bind to is
assigned a mac/vlan filter.
 3. num_devices is used to specify the maximum vhost devices the nic supports.

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
2014-10-13 19:13:10 +02:00
Huawei Xie
f14c0b4db8 vhost: remove useless code for Rx/Tx
Remove all other codes and only keep virtio_dev_rx, copy_from_mbuf_to_vring,
virtio_dev_merge_rx, virtio_dev_merge_tx.

Previous vhost merge-able feature introduces another version of tx function,
virtio_dev_merge_tx. Actually it is not related to merge-able feature but is
the fix for memcpy between mbuf and vring descriptors.
This lib will create the tx functions based on virtio_dev_merge_tx.

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
[Thomas: do not remove code used or moved later]
2014-10-13 19:11:38 +02:00
Huawei Xie
5c7a80aec3 vhost: move from examples to dedicated library
Those files will be refactored in subsequent patches to form user space
vhost library.
Makefile and main.h are removed.
main.c is renamed to vhost_rxtx.c and will provide vring enqueue/dequeue API.
virtio-net.h is renamed to rte_virtio_net.h which is the API header file.

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
[Thomas: remove from examples Makefile and merge file renaming]
2014-10-13 19:10:09 +02:00