summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vat/api_format.c15
-rw-r--r--src/vnet/CMakeLists.txt3
-rw-r--r--src/vnet/devices/virtio/vhost_user.api57
-rw-r--r--src/vnet/devices/virtio/vhost_user_api.c22
-rw-r--r--src/vnet/devices/virtio/virtio_types.api47
-rw-r--r--src/vnet/devices/virtio/virtio_types_api.c33
-rw-r--r--src/vnet/devices/virtio/virtio_types_api.h38
7 files changed, 186 insertions, 29 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 6e1ebf988b5..e4ef0b4916b 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -13116,11 +13116,18 @@ static void vl_api_sw_interface_vhost_user_details_t_handler
(vl_api_sw_interface_vhost_user_details_t * mp)
{
vat_main_t *vam = &vat_main;
+ u64 features;
+
+ features =
+ clib_net_to_host_u32 (mp->features_first_32) | ((u64)
+ clib_net_to_host_u32
+ (mp->features_last_32) <<
+ 32);
print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %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,
+ features, mp->is_server,
ntohl (mp->num_regions), (char *) mp->sock_filename);
print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
}
@@ -13144,8 +13151,10 @@ static void vl_api_sw_interface_vhost_user_details_t_handler_json
mp->interface_name);
vat_json_object_add_uint (node, "virtio_net_hdr_sz",
ntohl (mp->virtio_net_hdr_sz));
- vat_json_object_add_uint (node, "features",
- clib_net_to_host_u64 (mp->features));
+ vat_json_object_add_uint (node, "features_first_32",
+ clib_net_to_host_u32 (mp->features_first_32));
+ vat_json_object_add_uint (node, "features_last_32",
+ clib_net_to_host_u32 (mp->features_last_32));
vat_json_object_add_uint (node, "is_server", mp->is_server);
vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
diff --git a/src/vnet/CMakeLists.txt b/src/vnet/CMakeLists.txt
index 21653ab7c7a..dcba3c725db 100644
--- a/src/vnet/CMakeLists.txt
+++ b/src/vnet/CMakeLists.txt
@@ -1051,12 +1051,14 @@ list(APPEND VNET_SOURCES
devices/virtio/vhost_user_api.c
devices/virtio/virtio.c
devices/virtio/virtio_api.c
+ devices/virtio/virtio_types_api.c
)
list(APPEND VNET_HEADERS
devices/virtio/pci.h
devices/virtio/virtio.h
devices/virtio/vhost_user.h
+ devices/virtio/virtio_types_api.h
)
list(APPEND VNET_MULTIARCH_SOURCES
@@ -1071,6 +1073,7 @@ list(APPEND VNET_MULTIARCH_SOURCES
list(APPEND VNET_API_FILES
devices/virtio/vhost_user.api
devices/virtio/virtio.api
+ devices/virtio/virtio_types.api
)
##############################################################################
diff --git a/src/vnet/devices/virtio/vhost_user.api b/src/vnet/devices/virtio/vhost_user.api
index e08c7351ddf..9b057552c00 100644
--- a/src/vnet/devices/virtio/vhost_user.api
+++ b/src/vnet/devices/virtio/vhost_user.api
@@ -13,7 +13,11 @@
* limitations under the License.
*/
-option version = "3.0.0";
+option version = "4.0.0";
+
+import "vnet/interface_types.api";
+import "vnet/ethernet/ethernet_types.api";
+import "vnet/devices/virtio/virtio_types.api";
/** \brief vhost-user interface create request
@param client_index - opaque cookie to identify the sender
@@ -29,16 +33,16 @@ define create_vhost_user_if
{
u32 client_index;
u32 context;
- u8 is_server;
- u8 sock_filename[256];
- u8 renumber;
- u8 disable_mrg_rxbuf;
- u8 disable_indirect_desc;
- u8 enable_gso;
+ bool is_server;
+ string sock_filename[256];
+ bool renumber;
+ bool disable_mrg_rxbuf;
+ bool disable_indirect_desc;
+ bool enable_gso;
u32 custom_dev_instance;
- u8 use_custom_mac;
- u8 mac_address[6];
- u8 tag[64];
+ bool use_custom_mac;
+ vl_api_mac_address_t mac_address;
+ string tag[64];
};
/** \brief vhost-user interface create response
@@ -50,7 +54,7 @@ define create_vhost_user_if_reply
{
u32 context;
i32 retval;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
};
/** \brief vhost-user interface modify request
@@ -63,11 +67,11 @@ autoreply define modify_vhost_user_if
{
u32 client_index;
u32 context;
- u32 sw_if_index;
- u8 is_server;
- u8 sock_filename[256];
- u8 renumber;
- u8 enable_gso;
+ vl_api_interface_index_t sw_if_index;
+ bool is_server;
+ string sock_filename[256];
+ bool renumber;
+ bool enable_gso;
u32 custom_dev_instance;
};
@@ -78,35 +82,42 @@ autoreply define delete_vhost_user_if
{
u32 client_index;
u32 context;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
};
/** \brief Vhost-user interface details structure (fix this)
@param sw_if_index - index of the interface
@param interface_name - name of interface
@param virtio_net_hdr_sz - net header size
- @param features - interface features
+ @param features_first_32 - interface features, first 32 bits
+ @param features_last_32 - interface features, last 32 bits
@param is_server - vhost-user server socket
@param sock_filename - socket filename
@param num_regions - number of used memory regions
+ @param sock_errno - socket errno
*/
define sw_interface_vhost_user_details
{
u32 context;
- u32 sw_if_index;
- u8 interface_name[64];
+ vl_api_interface_index_t sw_if_index;
+ string interface_name[64];
u32 virtio_net_hdr_sz;
- u64 features;
- u8 is_server;
- u8 sock_filename[256];
+ vl_api_virtio_net_features_first_32_t features_first_32;
+ vl_api_virtio_net_features_last_32_t features_last_32;
+ bool is_server;
+ string sock_filename[256];
u32 num_regions;
i32 sock_errno;
};
+/** \brief Vhost-user interface dump request
+ @param sw_if_index - filter by sw_if_index UNIMPLEMENTED
+*/
define sw_interface_vhost_user_dump
{
u32 client_index;
u32 context;
+ vl_api_interface_index_t sw_if_index [default=0xffffffff];
};
/*
* Local Variables:
diff --git a/src/vnet/devices/virtio/vhost_user_api.c b/src/vnet/devices/virtio/vhost_user_api.c
index c8c9b59dcc0..2ab87a65690 100644
--- a/src/vnet/devices/virtio/vhost_user_api.c
+++ b/src/vnet/devices/virtio/vhost_user_api.c
@@ -23,6 +23,9 @@
#include <vnet/interface.h>
#include <vnet/api_errno.h>
#include <vnet/devices/virtio/vhost_user.h>
+#include <vnet/ethernet/ethernet.h>
+#include <vnet/ethernet/ethernet_types_api.h>
+#include <vnet/devices/virtio/virtio_types_api.h>
#include <vnet/vnet_msg_enum.h>
@@ -58,6 +61,8 @@ vl_api_create_vhost_user_if_t_handler (vl_api_create_vhost_user_if_t * mp)
vlib_main_t *vm = vlib_get_main ();
u64 features = (u64) ~ (0ULL);
u64 disabled_features = (u64) (0ULL);
+ mac_address_t mac;
+ u8 *mac_p = NULL;
if (mp->disable_mrg_rxbuf)
disabled_features = (1ULL << FEAT_VIRTIO_NET_F_MRG_RXBUF);
@@ -72,11 +77,16 @@ vl_api_create_vhost_user_if_t_handler (vl_api_create_vhost_user_if_t * mp)
disabled_features |= FEATURE_VIRTIO_NET_F_HOST_GUEST_TSO_FEATURE_BITS;
features &= ~disabled_features;
+ if (mp->use_custom_mac)
+ {
+ mac_address_decode (mp->mac_address, &mac);
+ mac_p = (u8 *) & mac;
+ }
+
rv = vhost_user_create_if (vnm, vm, (char *) mp->sock_filename,
mp->is_server, &sw_if_index, features,
mp->renumber, ntohl (mp->custom_dev_instance),
- (mp->use_custom_mac) ? mp->mac_address : NULL,
- mp->enable_gso);
+ mac_p, mp->enable_gso);
/* Remember an interface tag for the new interface */
if (rv == 0)
@@ -163,7 +173,8 @@ send_sw_interface_vhost_user_details (vpe_api_main_t * am,
mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_VHOST_USER_DETAILS);
mp->sw_if_index = ntohl (vui->sw_if_index);
mp->virtio_net_hdr_sz = ntohl (vui->virtio_net_hdr_sz);
- mp->features = clib_net_to_host_u64 (vui->features);
+ virtio_features_encode (vui->features, (u32 *) & mp->features_first_32,
+ (u32 *) & mp->features_last_32);
mp->is_server = vui->is_server;
mp->num_regions = ntohl (vui->num_regions);
mp->sock_errno = ntohl (vui->sock_errno);
@@ -188,11 +199,16 @@ static void
vhost_user_intf_details_t *ifaces = NULL;
vhost_user_intf_details_t *vuid = NULL;
vl_api_registration_t *reg;
+ u32 filter_sw_if_index;
reg = vl_api_client_index_to_registration (mp->client_index);
if (!reg)
return;
+ filter_sw_if_index = htonl (mp->sw_if_index);
+ if (filter_sw_if_index != ~0)
+ return; /* UNIMPLEMENTED */
+
rv = vhost_user_dump_ifs (vnm, vm, &ifaces);
if (rv)
return;
diff --git a/src/vnet/devices/virtio/virtio_types.api b/src/vnet/devices/virtio/virtio_types.api
new file mode 100644
index 00000000000..4ed43cb45e8
--- /dev/null
+++ b/src/vnet/devices/virtio/virtio_types.api
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+option version = "1.0.0";
+
+enum virtio_net_features_first_32
+{
+ VIRTIO_NET_F_API_CSUM = 0x0001, /* 0 */
+ VIRTIO_NET_F_API_GUEST_CSUM = 0x0002, /* 1 */
+ VIRTIO_NET_F_API_GUEST_TSO4 = 0x0080, /* 7 */
+ VIRTIO_NET_F_API_GUEST_TSO6 = 0x0100, /* 8 */
+ VIRTIO_NET_F_API_GUEST_UFO = 0x0400, /* 10 */
+ VIRTIO_NET_F_API_HOST_TSO4 = 0x0800, /* 11 */
+ VIRTIO_NET_F_API_HOST_TSO6 = 0x1000, /* 12 */
+ VIRTIO_NET_F_API_HOST_UFO = 0x4000, /* 14 */
+ VIRTIO_NET_F_API_MRG_RXBUF = 0x8000, /* 15 */
+ VIRTIO_NET_F_API_CTRL_VQ = 0x00020000, /* 17 */
+ VIRTIO_NET_F_API_GUEST_ANNOUNCE = 0x00200000, /* 21 */
+ VIRTIO_NET_F_API_MQ = 0x00400000, /* 22 */
+ VHOST_F_API_LOG_ALL = 0x04000000, /* 26 */
+ VIRTIO_F_API_ANY_LAYOUT = 0x08000000, /* 27 */
+ VIRTIO_F_API_INDIRECT_DESC = 0x10000000, /* 28*/
+ VHOST_USER_F_API_PROTOCOL_FEATURES = 0x40000000, /* 30 */
+};
+
+enum virtio_net_features_last_32
+{
+ VIRTIO_F_API_VERSION_1 = 0x0001, /* 32 */
+};
+
+/*
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet/devices/virtio/virtio_types_api.c b/src/vnet/devices/virtio/virtio_types_api.c
new file mode 100644
index 00000000000..48e0ab93dbf
--- /dev/null
+++ b/src/vnet/devices/virtio/virtio_types_api.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vnet/vnet.h>
+
+#include <vlibapi/api_types.h>
+#include <vnet/devices/virtio/virtio_types_api.h>
+
+
+u64
+virtio_features_decode (u32 first, u32 last)
+{
+ return clib_net_to_host_u32 (first) | ((u64)clib_net_to_host_u32 (last) << 32);
+}
+
+void
+virtio_features_encode (u64 features, u32 *first, u32 *last)
+{
+ *first = clib_net_to_host_u32 (features);
+ *last = clib_net_to_host_u32 (features >> 32);
+}
diff --git a/src/vnet/devices/virtio/virtio_types_api.h b/src/vnet/devices/virtio/virtio_types_api.h
new file mode 100644
index 00000000000..ff35fa3450f
--- /dev/null
+++ b/src/vnet/devices/virtio/virtio_types_api.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __VIRTIO_TYPES_API_H__
+#define __VIRTIO_TYPES_API_H__
+
+/**
+ * Conversion functions to/from (decode/encode) API types to VPP internal types
+ */
+
+/**
+ * These enum decode/encodes use 'u32' as the type for the enum because
+ * one cannot forward declare an enum
+ */
+extern u64 virtio_features_decode (u32 first, u32 last);
+extern void virtio_features_encode (u64 features, u32 * first, u32 * last);
+
+#endif /* __VIRTIO_TYPES_API_H__ */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */