aboutsummaryrefslogtreecommitdiffstats
path: root/src/vat/api_format.c
diff options
context:
space:
mode:
authorSteven <sluong@cisco.com>2017-03-15 21:18:55 -0700
committerDamjan Marion <dmarion.lists@gmail.com>2017-03-22 08:54:33 +0000
commit7312cc7785a9d1198519e1091a645fecc019a6b8 (patch)
tree7f46d3e5b36c766949ddfc37329cffeeebcc7323 /src/vat/api_format.c
parentb616e9fdc270e786c31b9ee9de5464497f0b1f6d (diff)
vhost: support interrupt mode
vhost currently supports only polling mode. This patch is to add interrupt mode. When the interface is configured for interrupt mode, our input node does not get called unless there is a packet in the vring. If a particular CPU has one interface configured for polling mode and another in interrupt, the input node is set to polling for that CPU. This diffs also includes two crashes in vlib's dispatch_node. One is included in https://gerrit.fd.io/r/#/c/5516. The other crash is in the ASSERT. The ASSERT can become true when the caller of dispatch_node is in a loop. The first call converted the node to polling. The second call thereafter will hit the ASSERT. Change-Id: If17b6d48b20d7d8605c6a161459828637173cd32 Signed-off-by: Steven <sluong@cisco.com>
Diffstat (limited to 'src/vat/api_format.c')
-rw-r--r--src/vat/api_format.c67
1 files changed, 62 insertions, 5 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 37b7f93e879..3b57ac61717 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -403,6 +403,46 @@ api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
}
#endif /* VPP_API_TEST_BUILTIN */
+#define VHOST_USER_POLLING_MODE 0
+#define VHOST_USER_INTERRUPT_MODE 1
+#define VHOST_USER_ADAPTIVE_MODE 2
+
+static u8 *
+api_format_vhost_user_operation_mode (u8 * s, va_list * va)
+{
+ int operation_mode = va_arg (*va, int);
+
+ switch (operation_mode)
+ {
+ case VHOST_USER_POLLING_MODE:
+ s = format (s, "%-9s", "polling");
+ break;
+ case VHOST_USER_INTERRUPT_MODE:
+ s = format (s, "%-9s", "interrupt");
+ break;
+ default:
+ s = format (s, "%-9s", "invalid");
+ }
+ return s;
+}
+
+static uword
+api_unformat_vhost_user_operation_mode (unformat_input_t * input,
+ va_list * args)
+{
+ u8 *operation_mode = va_arg (*args, u8 *);
+ uword rc = 1;
+
+ if (unformat (input, "interrupt"))
+ *operation_mode = VHOST_USER_INTERRUPT_MODE;
+ else if (unformat (input, "polling"))
+ *operation_mode = VHOST_USER_POLLING_MODE;
+ else
+ rc = 0;
+
+ return rc;
+}
+
static uword
unformat_policer_rate_type (unformat_input_t * input, va_list * args)
{
@@ -11174,6 +11214,7 @@ api_create_vhost_user_if (vat_main_t * vam)
u8 use_custom_mac = 0;
u8 *tag = 0;
int ret;
+ u8 operation_mode = VHOST_USER_POLLING_MODE;
/* Shut up coverity */
memset (hwaddr, 0, sizeof (hwaddr));
@@ -11192,6 +11233,10 @@ api_create_vhost_user_if (vat_main_t * vam)
is_server = 1;
else if (unformat (i, "tag %s", &tag))
;
+ else if (unformat (i, "mode %U",
+ api_unformat_vhost_user_operation_mode,
+ &operation_mode))
+ ;
else
break;
}
@@ -11211,6 +11256,7 @@ api_create_vhost_user_if (vat_main_t * vam)
M (CREATE_VHOST_USER_IF, mp);
+ mp->operation_mode = operation_mode;
mp->is_server = is_server;
clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
vec_free (file_name);
@@ -11242,6 +11288,7 @@ api_modify_vhost_user_if (vat_main_t * vam)
u8 sw_if_index_set = 0;
u32 sw_if_index = (u32) ~ 0;
int ret;
+ u8 operation_mode = VHOST_USER_POLLING_MODE;
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
@@ -11257,6 +11304,10 @@ api_modify_vhost_user_if (vat_main_t * vam)
;
else if (unformat (i, "server"))
is_server = 1;
+ else if (unformat (i, "mode %U",
+ api_unformat_vhost_user_operation_mode,
+ &operation_mode))
+ ;
else
break;
}
@@ -11282,6 +11333,7 @@ api_modify_vhost_user_if (vat_main_t * vam)
M (MODIFY_VHOST_USER_IF, mp);
+ mp->operation_mode = operation_mode;
mp->sw_if_index = ntohl (sw_if_index);
mp->is_server = is_server;
clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
@@ -11337,11 +11389,12 @@ static void vl_api_sw_interface_vhost_user_details_t_handler
{
vat_main_t *vam = &vat_main;
- print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
+ print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %U %s",
(char *) mp->interface_name,
ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
clib_net_to_host_u64 (mp->features), mp->is_server,
- ntohl (mp->num_regions), (char *) mp->sock_filename);
+ ntohl (mp->num_regions), api_format_vhost_user_operation_mode,
+ mp->operation_mode, (char *) mp->sock_filename);
print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
}
@@ -11370,6 +11423,7 @@ static void vl_api_sw_interface_vhost_user_details_t_handler_json
vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
+ vat_json_object_add_uint (node, "mode", mp->operation_mode);
}
static int
@@ -11379,7 +11433,8 @@ api_sw_interface_vhost_user_dump (vat_main_t * vam)
vl_api_control_ping_t *mp_ping;
int ret;
print (vam->ofp,
- "Interface name idx hdr_sz features server regions filename");
+ "Interface name idx hdr_sz features server regions mode"
+ " filename");
/* Get list of vhost-user interfaces */
M (SW_INTERFACE_VHOST_USER_DUMP, mp);
@@ -18492,10 +18547,12 @@ _(l2_interface_vlan_tag_rewrite, \
"[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
_(create_vhost_user_if, \
"socket <filename> [server] [renumber <dev_instance>] " \
- "[mac <mac_address>]") \
+ "[mac <mac_address>] " \
+ "[mode <interrupt | polling>]") \
_(modify_vhost_user_if, \
"<intfc> | sw_if_index <nn> socket <filename>\n" \
- "[server] [renumber <dev_instance>]") \
+ "[server] [renumber <dev_instance>] " \
+ "[mode <interrupt | polling>]") \
_(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
_(sw_interface_vhost_user_dump, "") \
_(show_version, "") \