diff options
author | Steven <sluong@cisco.com> | 2017-03-08 00:23:13 -0800 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2017-03-08 18:11:04 +0000 |
commit | a1a0901daa6f56039caecbe58e7d7062a145fc98 (patch) | |
tree | a48779fe1982a856a5fce36e05489bac1827f1cf /src/vnet/devices/virtio | |
parent | c6ec8f39240a166a7e04a7834a28107b6353b46a (diff) |
vhost: binary API changes for interrupt mode
Add operation_mode for create_vhost_user_if, modify_vhost_user_if,
and sw_interface_vhost_user_details. Only polling mode is supported
for these APIs. Other mode is rejected and gets
VNET_API_ERROR_UNIMPLEMENTED error.
Change-Id: I0596f4e2c087aa2b6f78eb3e0b63910b1859641e
Signed-off-by: Steven <sluong@cisco.com>
Diffstat (limited to 'src/vnet/devices/virtio')
-rw-r--r-- | src/vnet/devices/virtio/vhost-user.c | 24 | ||||
-rw-r--r-- | src/vnet/devices/virtio/vhost-user.h | 14 | ||||
-rw-r--r-- | src/vnet/devices/virtio/vhost_user.api | 6 | ||||
-rw-r--r-- | src/vnet/devices/virtio/vhost_user_api.c | 7 |
4 files changed, 41 insertions, 10 deletions
diff --git a/src/vnet/devices/virtio/vhost-user.c b/src/vnet/devices/virtio/vhost-user.c index c16e98227db..b6b4c04a067 100644 --- a/src/vnet/devices/virtio/vhost-user.c +++ b/src/vnet/devices/virtio/vhost-user.c @@ -2540,7 +2540,7 @@ vhost_user_vui_init (vnet_main_t * vnm, vhost_user_intf_t * vui, int server_sock_fd, const char *sock_filename, - u64 feature_mask, u32 * sw_if_index) + u64 feature_mask, u32 * sw_if_index, u8 operation_mode) { vnet_sw_interface_t *sw; sw = vnet_get_hw_sw_interface (vnm, vui->hw_if_index); @@ -2567,6 +2567,7 @@ vhost_user_vui_init (vnet_main_t * vnm, vui->feature_mask = feature_mask; vui->unix_file_index = ~0; vui->log_base_addr = 0; + vui->operation_mode = operation_mode; for (q = 0; q < VHOST_VRING_MAX_N; q++) vhost_user_vring_init (vui, q); @@ -2594,13 +2595,17 @@ vhost_user_create_if (vnet_main_t * vnm, vlib_main_t * vm, u8 is_server, u32 * sw_if_index, u64 feature_mask, - u8 renumber, u32 custom_dev_instance, u8 * hwaddr) + u8 renumber, u32 custom_dev_instance, u8 * hwaddr, + u8 operation_mode) { vhost_user_intf_t *vui = NULL; u32 sw_if_idx = ~0; int rv = 0; int server_sock_fd = -1; + if (operation_mode != VHOST_USER_POLLING_MODE) + return VNET_API_ERROR_UNIMPLEMENTED; + if (sock_filename == NULL || !(strlen (sock_filename) > 0)) { return VNET_API_ERROR_INVALID_ARGUMENT; @@ -2619,7 +2624,7 @@ vhost_user_create_if (vnet_main_t * vnm, vlib_main_t * vm, vhost_user_create_ethernet (vnm, vm, vui, hwaddr); vhost_user_vui_init (vnm, vui, server_sock_fd, sock_filename, - feature_mask, &sw_if_idx); + feature_mask, &sw_if_idx, operation_mode); if (renumber) vnet_interface_name_renumber (sw_if_idx, custom_dev_instance); @@ -2637,7 +2642,8 @@ vhost_user_modify_if (vnet_main_t * vnm, vlib_main_t * vm, const char *sock_filename, u8 is_server, u32 sw_if_index, - u64 feature_mask, u8 renumber, u32 custom_dev_instance) + u64 feature_mask, u8 renumber, u32 custom_dev_instance, + u8 operation_mode) { vhost_user_main_t *vum = &vhost_user_main; vhost_user_intf_t *vui = NULL; @@ -2646,6 +2652,8 @@ vhost_user_modify_if (vnet_main_t * vnm, vlib_main_t * vm, int rv = 0; vnet_hw_interface_t *hwif; + if (operation_mode != VHOST_USER_POLLING_MODE) + return VNET_API_ERROR_UNIMPLEMENTED; if (!(hwif = vnet_get_sup_hw_interface (vnm, sw_if_index)) || hwif->dev_class_index != vhost_user_dev_class.index) return VNET_API_ERROR_INVALID_SW_IF_INDEX; @@ -2660,7 +2668,8 @@ vhost_user_modify_if (vnet_main_t * vnm, vlib_main_t * vm, vhost_user_term_if (vui); vhost_user_vui_init (vnm, vui, server_sock_fd, - sock_filename, feature_mask, &sw_if_idx); + sock_filename, feature_mask, &sw_if_idx, + operation_mode); if (renumber) vnet_interface_name_renumber (sw_if_idx, custom_dev_instance); @@ -2685,6 +2694,7 @@ vhost_user_connect_command_fn (vlib_main_t * vm, u8 hwaddr[6]; u8 *hw = NULL; clib_error_t *error = NULL; + u8 operation_mode = VHOST_USER_POLLING_MODE; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -2719,7 +2729,8 @@ vhost_user_connect_command_fn (vlib_main_t * vm, int rv; if ((rv = vhost_user_create_if (vnm, vm, (char *) sock_filename, is_server, &sw_if_index, feature_mask, - renumber, custom_dev_instance, hw))) + renumber, custom_dev_instance, hw, + operation_mode))) { error = clib_error_return (0, "vhost_user_create_if returned %d", rv); goto done; @@ -2809,6 +2820,7 @@ vhost_user_dump_ifs (vnet_main_t * vnm, vlib_main_t * vm, vui = pool_elt_at_index (vum->vhost_user_interfaces, hi->dev_instance); vec_add2 (r_vuids, vuid, 1); + vuid->operation_mode = vui->operation_mode; vuid->sw_if_index = vui->sw_if_index; vuid->virtio_net_hdr_sz = vui->virtio_net_hdr_sz; vuid->features = vui->features; diff --git a/src/vnet/devices/virtio/vhost-user.h b/src/vnet/devices/virtio/vhost-user.h index dd23a909bfa..6b928f05e28 100644 --- a/src/vnet/devices/virtio/vhost-user.h +++ b/src/vnet/devices/virtio/vhost-user.h @@ -42,6 +42,7 @@ #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000 #define VRING_USED_F_NO_NOTIFY 1 +#define VRING_AVAIL_F_NO_INTERRUPT 1 #define foreach_virtio_net_feature \ _ (VIRTIO_NET_F_MRG_RXBUF, 15) \ @@ -65,11 +66,13 @@ typedef enum int vhost_user_create_if (vnet_main_t * vnm, vlib_main_t * vm, const char *sock_filename, u8 is_server, u32 * sw_if_index, u64 feature_mask, - u8 renumber, u32 custom_dev_instance, u8 * hwaddr); + u8 renumber, u32 custom_dev_instance, u8 * hwaddr, + u8 operation_mode); int vhost_user_modify_if (vnet_main_t * vnm, vlib_main_t * vm, const char *sock_filename, u8 is_server, u32 sw_if_index, u64 feature_mask, - u8 renumber, u32 custom_dev_instance); + u8 renumber, u32 custom_dev_instance, + u8 operation_mode); int vhost_user_delete_if (vnet_main_t * vnm, vlib_main_t * vm, u32 sw_if_index); @@ -209,6 +212,10 @@ typedef struct u64 log_guest_addr; } vhost_user_vring_t; +#define VHOST_USER_POLLING_MODE 0 +#define VHOST_USER_INTERRUPT_MODE 1 +#define VHOST_USER_ADAPTIVE_MODE 2 + typedef struct { CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); @@ -249,6 +256,8 @@ typedef struct /* Vector of workers for this interface */ u32 *workers; + + u8 operation_mode; } vhost_user_intf_t; typedef struct @@ -323,6 +332,7 @@ typedef struct u8 sock_filename[256]; u32 num_regions; int sock_errno; + u8 operation_mode; } vhost_user_intf_details_t; int vhost_user_dump_ifs (vnet_main_t * vnm, vlib_main_t * vm, diff --git a/src/vnet/devices/virtio/vhost_user.api b/src/vnet/devices/virtio/vhost_user.api index 21e42298361..4f604e45494 100644 --- a/src/vnet/devices/virtio/vhost_user.api +++ b/src/vnet/devices/virtio/vhost_user.api @@ -19,6 +19,7 @@ @param sock_filename - unix socket filename, used to speak with frontend @param use_custom_mac - enable or disable the use of the provided hardware address @param mac_address - hardware address to use if 'use_custom_mac' is set + @param operation_mode - polling=0, interrupt=1, or adaptive=2 */ define create_vhost_user_if { @@ -31,6 +32,7 @@ define create_vhost_user_if u8 use_custom_mac; u8 mac_address[6]; u8 tag[64]; + u8 operation_mode; }; /** \brief vhost-user interface create response @@ -49,6 +51,7 @@ define create_vhost_user_if_reply @param client_index - opaque cookie to identify the sender @param is_server - our side is socket server @param sock_filename - unix socket filename, used to speak with frontend + @param operation_mode - polling=0, interrupt=1, or adaptive=2 */ define modify_vhost_user_if { @@ -59,6 +62,7 @@ define modify_vhost_user_if u8 sock_filename[256]; u8 renumber; u32 custom_dev_instance; + u8 operation_mode; }; /** \brief vhost-user interface modify response @@ -99,6 +103,7 @@ define delete_vhost_user_if_reply @param is_server - vhost-user server socket @param sock_filename - socket filename @param num_regions - number of used memory regions + @param operation_mode - polling=0, interrupt=1, or adaptive=2 */ define sw_interface_vhost_user_details { @@ -111,6 +116,7 @@ define sw_interface_vhost_user_details u8 sock_filename[256]; u32 num_regions; i32 sock_errno; + u8 operation_mode; }; define sw_interface_vhost_user_dump diff --git a/src/vnet/devices/virtio/vhost_user_api.c b/src/vnet/devices/virtio/vhost_user_api.c index 8dbd032b117..ac7afa611b6 100644 --- a/src/vnet/devices/virtio/vhost_user_api.c +++ b/src/vnet/devices/virtio/vhost_user_api.c @@ -81,7 +81,8 @@ vl_api_create_vhost_user_if_t_handler (vl_api_create_vhost_user_if_t * mp) rv = vhost_user_create_if (vnm, vm, (char *) mp->sock_filename, mp->is_server, &sw_if_index, (u64) ~ 0, mp->renumber, ntohl (mp->custom_dev_instance), - (mp->use_custom_mac) ? mp->mac_address : NULL); + (mp->use_custom_mac) ? mp->mac_address : NULL, + mp->operation_mode); /* Remember an interface tag for the new interface */ if (rv == 0) @@ -116,7 +117,8 @@ vl_api_modify_vhost_user_if_t_handler (vl_api_modify_vhost_user_if_t * mp) rv = vhost_user_modify_if (vnm, vm, (char *) mp->sock_filename, mp->is_server, sw_if_index, (u64) ~ 0, - mp->renumber, ntohl (mp->custom_dev_instance)); + mp->renumber, ntohl (mp->custom_dev_instance), + mp->operation_mode); REPLY_MACRO (VL_API_MODIFY_VHOST_USER_IF_REPLY); } @@ -162,6 +164,7 @@ send_sw_interface_vhost_user_details (vpe_api_main_t * am, mp->virtio_net_hdr_sz = ntohl (vui->virtio_net_hdr_sz); mp->features = clib_net_to_host_u64 (vui->features); mp->is_server = vui->is_server; + mp->operation_mode = vui->operation_mode; mp->num_regions = ntohl (vui->num_regions); mp->sock_errno = ntohl (vui->sock_errno); mp->context = context; |