aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/linux-cp/lcp_interface.c1
-rw-r--r--src/vnet/devices/tap/cli.c10
-rw-r--r--src/vnet/devices/tap/tap.c2
-rw-r--r--src/vnet/devices/tap/tap.h3
-rw-r--r--src/vnet/devices/tap/tapv2.api76
-rw-r--r--src/vnet/devices/tap/tapv2_api.c95
6 files changed, 182 insertions, 5 deletions
diff --git a/src/plugins/linux-cp/lcp_interface.c b/src/plugins/linux-cp/lcp_interface.c
index b42e5cbce97..d044635334f 100644
--- a/src/plugins/linux-cp/lcp_interface.c
+++ b/src/plugins/linux-cp/lcp_interface.c
@@ -942,6 +942,7 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
{
tap_create_if_args_t args = {
.num_rx_queues = clib_max (1, vlib_num_workers ()),
+ .num_tx_queues = 1,
.id = hw->hw_if_index,
.sw_if_index = ~0,
.rx_ring_sz = 256,
diff --git a/src/vnet/devices/tap/cli.c b/src/vnet/devices/tap/cli.c
index 10f4bb0ee2e..096a2c46970 100644
--- a/src/vnet/devices/tap/cli.c
+++ b/src/vnet/devices/tap/cli.c
@@ -41,6 +41,7 @@ tap_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
args.tap_flags = 0;
args.rv = -1;
args.num_rx_queues = 1;
+ args.num_tx_queues = 1;
/* Get a line of input. */
if (unformat_user (input, unformat_line_input, line_input))
@@ -76,6 +77,8 @@ tap_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
args.host_ip6_gw_set = 1;
else if (unformat (line_input, "num-rx-queues %d", &tmp))
args.num_rx_queues = tmp;
+ else if (unformat (line_input, "num-tx-queues %d", &tmp))
+ args.num_tx_queues = tmp;
else if (unformat (line_input, "rx-ring-size %d", &tmp))
args.rx_ring_sz = tmp;
else if (unformat (line_input, "tx-ring-size %d", &tmp))
@@ -136,9 +139,10 @@ tap_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (tap_create_command, static) = {
.path = "create tap",
- .short_help = "create tap {id <if-id>} [hw-addr <mac-address>] "
- "[num-rx-queues <n>] [rx-ring-size <size>] [tx-ring-size <size>] "
- "[host-ns <netns>] [host-bridge <bridge-name>] "
+ .short_help =
+ "create tap {id <if-id>} [hw-addr <mac-address>] "
+ "[num-rx-queues <n>] [num-tx-queues <n>] [rx-ring-size <size>] "
+ "[tx-ring-size <size>] [host-ns <netns>] [host-bridge <bridge-name>] "
"[host-ip4-addr <ip4addr/mask>] [host-ip6-addr <ip6-addr>] "
"[host-ip4-gw <ip4-addr>] [host-ip6-gw <ip6-addr>] "
"[host-mac-addr <host-mac-address>] [host-if-name <name>] "
diff --git a/src/vnet/devices/tap/tap.c b/src/vnet/devices/tap/tap.c
index 17ce107ac58..93140ec0c3f 100644
--- a/src/vnet/devices/tap/tap.c
+++ b/src/vnet/devices/tap/tap.c
@@ -191,7 +191,7 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args)
vif->dev_instance = vif - vim->interfaces;
vif->id = args->id;
- vif->num_txqs = thm->n_vlib_mains;
+ vif->num_txqs = clib_max (args->num_tx_queues, thm->n_vlib_mains);
vif->num_rxqs = clib_max (args->num_rx_queues, 1);
if (args->tap_flags & TAP_FLAG_ATTACH)
diff --git a/src/vnet/devices/tap/tap.h b/src/vnet/devices/tap/tap.h
index d89809862c0..6b88c34fe41 100644
--- a/src/vnet/devices/tap/tap.h
+++ b/src/vnet/devices/tap/tap.h
@@ -44,7 +44,8 @@ typedef struct
u32 id;
u8 mac_addr_set;
mac_address_t mac_addr;
- u8 num_rx_queues;
+ u16 num_rx_queues;
+ u16 num_tx_queues;
u16 rx_ring_sz;
u16 tx_ring_sz;
u32 tap_flags;
diff --git a/src/vnet/devices/tap/tapv2.api b/src/vnet/devices/tap/tapv2.api
index 6b6618411a6..0ee14511529 100644
--- a/src/vnet/devices/tap/tapv2.api
+++ b/src/vnet/devices/tap/tapv2.api
@@ -43,6 +43,82 @@ enum tap_flags {
@param use_random_mac - let the system generate a unique mac address
@param mac_address - mac addr to assign to the interface if use_random not set
@param num_rx_queues - number of rx queues
+ @param num_tx_queues - number of tx queues
+ @param tx_ring_sz - the number of entries of TX ring, optional, default is 256 entries, must be power of 2
+ @param rx_ring_sz - the number of entries of RX ring, optional, default is 256 entries, must be power of 2
+ @param host_mtu_set - host MTU should be set
+ @param host_mtu_size - host MTU size
+ @param host_mac_addr_set - host side interface mac address should be set
+ @param host_mac_addr - host side interface mac address
+ @param host_ip4_prefix_set - host IPv4 ip address should be set
+ @param host_ip4_prefix - host IPv4 ip address
+ @param host_ip6_prefix_set - host IPv6 ip address should be set
+ @param host_ip6_prefix - host IPv6 ip address
+ @param host_ip4_gw_set - host IPv4 default gateway should be set
+ @param host_ip4_gw - host IPv4 default gateway
+ @param host_ip6_gw_set - host IPv6 default gateway should be set
+ @param host_ip6_gw - host IPv6 default gateway
+ @param tap_flags - flags for the TAP interface creation
+ @param host_if_name_set - host side interface name should be set
+ @param host_if_name - host side interface name
+ @param host_namespace_set - host namespace should be set
+ @param host_namespace - host namespace to attach interface to
+ @param host_bridge_set - host bridge should be set
+ @param host_bridge - host bridge to attach interface to
+ @param tag - tag
+*/
+autoendian define tap_create_v3
+{
+ u32 client_index;
+ u32 context;
+ u32 id [default=0xffffffff];
+ bool use_random_mac [default=true];
+ vl_api_mac_address_t mac_address;
+ u16 num_rx_queues [default=1];
+ u16 num_tx_queues [default=1];
+ u16 tx_ring_sz [default=256];
+ u16 rx_ring_sz [default=256];
+ bool host_mtu_set;
+ u32 host_mtu_size;
+ bool host_mac_addr_set;
+ vl_api_mac_address_t host_mac_addr;
+ bool host_ip4_prefix_set;
+ vl_api_ip4_address_with_prefix_t host_ip4_prefix;
+ bool host_ip6_prefix_set;
+ vl_api_ip6_address_with_prefix_t host_ip6_prefix;
+ bool host_ip4_gw_set;
+ vl_api_ip4_address_t host_ip4_gw;
+ bool host_ip6_gw_set;
+ vl_api_ip6_address_t host_ip6_gw;
+ vl_api_tap_flags_t tap_flags;
+ bool host_namespace_set;
+ string host_namespace[64];
+ bool host_if_name_set;
+ string host_if_name[64];
+ bool host_bridge_set;
+ string host_bridge[64];
+ string tag[];
+};
+
+/** \brief Reply for tap create reply
+ @param context - returned sender context, to match reply w/ request
+ @param retval - return code
+ @param sw_if_index - software index allocated for the new tap interface
+*/
+autoendian define tap_create_v3_reply
+{
+ u32 context;
+ i32 retval;
+ vl_api_interface_index_t sw_if_index;
+};
+
+/** \brief Initialize a new tap interface with the given parameters
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param id - interface id, 0xffffffff means auto
+ @param use_random_mac - let the system generate a unique mac address
+ @param mac_address - mac addr to assign to the interface if use_random not set
+ @param num_rx_queues - number of rx queues
@param tx_ring_sz - the number of entries of TX ring, optional, default is 256 entries, must be power of 2
@param rx_ring_sz - the number of entries of RX ring, optional, default is 256 entries, must be power of 2
@param host_mtu_set - host MTU should be set
diff --git a/src/vnet/devices/tap/tapv2_api.c b/src/vnet/devices/tap/tapv2_api.c
index 64a0088136b..ab4189ab607 100644
--- a/src/vnet/devices/tap/tapv2_api.c
+++ b/src/vnet/devices/tap/tapv2_api.c
@@ -36,6 +36,100 @@
#include <vlibapi/api_helper_macros.h>
static void
+vl_api_tap_create_v3_t_handler (vl_api_tap_create_v3_t *mp)
+{
+ vl_api_registration_t *reg;
+ int rv;
+
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (!reg)
+ return;
+
+ vnet_main_t *vnm = vnet_get_main ();
+ vlib_main_t *vm = vlib_get_main ();
+ vl_api_tap_create_v3_reply_t *rmp;
+
+ tap_create_if_args_t _a, *ap = &_a;
+
+ clib_memset (ap, 0, sizeof (*ap));
+
+ ap->id = mp->id;
+ if (!mp->use_random_mac)
+ {
+ mac_address_decode (mp->mac_address, &ap->mac_addr);
+ ap->mac_addr_set = 1;
+ }
+ ap->rx_ring_sz = mp->rx_ring_sz;
+ ap->tx_ring_sz = mp->tx_ring_sz;
+ ap->sw_if_index = (u32) ~0;
+ ap->num_rx_queues = clib_max (1, mp->num_rx_queues);
+ ap->num_tx_queues = mp->num_tx_queues;
+
+ if (mp->host_if_name_set)
+ ap->host_if_name = format (0, "%s%c", mp->host_if_name, 0);
+
+ if (mp->host_mac_addr_set)
+ {
+ mac_address_decode (mp->host_mac_addr, &ap->host_mac_addr);
+ }
+
+ if (mp->host_namespace_set)
+ ap->host_namespace = format (0, "%s%c", mp->host_namespace, 0);
+
+ if (mp->host_bridge_set)
+ ap->host_bridge = format (0, "%s%c", mp->host_bridge, 0);
+
+ if (mp->host_ip4_prefix_set)
+ {
+ ip4_address_decode (mp->host_ip4_prefix.address, &ap->host_ip4_addr);
+ ap->host_ip4_prefix_len = mp->host_ip4_prefix.len;
+ }
+
+ if (mp->host_ip6_prefix_set)
+ {
+ ip6_address_decode (mp->host_ip6_prefix.address, &ap->host_ip6_addr);
+ ap->host_ip6_prefix_len = mp->host_ip6_prefix.len;
+ }
+
+ if (mp->host_ip4_gw_set)
+ {
+ ip4_address_decode (mp->host_ip4_gw, &ap->host_ip4_gw);
+ ap->host_ip4_gw_set = 1;
+ }
+
+ if (mp->host_ip6_gw_set)
+ {
+ ip6_address_decode (mp->host_ip6_gw, &ap->host_ip6_gw);
+ ap->host_ip6_gw_set = 1;
+ }
+
+ if (mp->host_mtu_set)
+ {
+ ap->host_mtu_size = mp->host_mtu_size;
+ ap->host_mtu_set = 1;
+ }
+
+ ap->tap_flags = mp->tap_flags;
+
+ tap_create_if (vm, ap);
+
+ /* If a tag was supplied... */
+ if (vl_api_string_len (&mp->tag))
+ {
+ u8 *tag = vl_api_from_api_to_new_vec (mp, &mp->tag);
+ vnet_set_sw_interface_tag (vnm, tag, ap->sw_if_index);
+ }
+
+ vec_free (ap->host_if_name);
+ vec_free (ap->host_namespace);
+ vec_free (ap->host_bridge);
+
+ rv = ap->rv;
+ REPLY_MACRO2_END (VL_API_TAP_CREATE_V3_REPLY,
+ ({ rmp->sw_if_index = ap->sw_if_index; }));
+}
+
+static void
vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp)
{
vl_api_registration_t *reg;
@@ -61,6 +155,7 @@ vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp)
ap->tx_ring_sz = ntohs (mp->tx_ring_sz);
ap->sw_if_index = (u32) ~ 0;
ap->num_rx_queues = 1;
+ ap->num_tx_queues = 1;
if (mp->num_rx_queues > 1)
ap->num_rx_queues = mp->num_rx_queues;