tap: refactor existing flags

Type: refactor

This patch refactor the existing flags and also add a new
flag for packet coalescing.

Change-Id: Ic826e4c81313f26d87c475cdf666b06cbed60a3a
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
This commit is contained in:
Mohsin Kazmi
2020-04-30 19:05:56 +02:00
committed by Damjan Marion
parent 6bb080f1e5
commit d88fc0fced
6 changed files with 44 additions and 23 deletions
+10 -6
View File
@@ -7360,15 +7360,19 @@ api_tap_create_v2 (vat_main_t * vam)
else if (unformat (i, "host-mtu-size %u", &host_mtu_size))
host_mtu_set = 1;
else if (unformat (i, "no-gso"))
tap_flags &= ~TAP_FLAG_GSO;
tap_flags &= ~TAP_API_FLAG_GSO;
else if (unformat (i, "gso"))
tap_flags |= TAP_FLAG_GSO;
tap_flags |= TAP_API_FLAG_GSO;
else if (unformat (i, "csum-offload"))
tap_flags |= TAP_FLAG_CSUM_OFFLOAD;
tap_flags |= TAP_API_FLAG_CSUM_OFFLOAD;
else if (unformat (i, "persist"))
tap_flags |= TAP_FLAG_PERSIST;
tap_flags |= TAP_API_FLAG_PERSIST;
else if (unformat (i, "attach"))
tap_flags |= TAP_FLAG_ATTACH;
tap_flags |= TAP_API_FLAG_ATTACH;
else if (unformat (i, "tun"))
tap_flags |= TAP_API_FLAG_TUN;
else if (unformat (i, "gro-coalesce"))
tap_flags |= TAP_API_FLAG_GRO_COALESCE;
else
break;
}
@@ -20587,7 +20591,7 @@ _(l2_flags, \
_(bridge_flags, \
"bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
_(tap_create_v2, \
"id <num> [hw-addr <mac-addr>] [host-if-name <name>] [host-ns <name>] [num-rx-queues <num>] [rx-ring-size <num>] [tx-ring-size <num>] [host-bridge <name>] [host-mac-addr <mac-addr>] [host-ip4-addr <ip4addr/mask>] [host-ip6-addr <ip6addr/mask>] [host-mtu-size <mtu>] [gso | no-gso | csum-offload] [persist] [attach]") \
"id <num> [hw-addr <mac-addr>] [host-if-name <name>] [host-ns <name>] [num-rx-queues <num>] [rx-ring-size <num>] [tx-ring-size <num>] [host-bridge <name>] [host-mac-addr <mac-addr>] [host-ip4-addr <ip4addr/mask>] [host-ip6-addr <ip6addr/mask>] [host-mtu-size <mtu>] [gso | no-gso | csum-offload | gro-coalesce] [persist] [attach] [tun]") \
_(tap_delete_v2, \
"<vpp-if-name> | sw_if_index <id>") \
_(sw_interface_tap_v2_dump, "") \
+4 -1
View File
@@ -90,6 +90,8 @@ tap_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
args.tap_flags &= ~TAP_FLAG_GSO;
else if (unformat (line_input, "gso"))
args.tap_flags |= TAP_FLAG_GSO;
else if (unformat (line_input, "gro-coalesce"))
args.tap_flags |= TAP_FLAG_GRO_COALESCE;
else if (unformat (line_input, "csum-offload"))
args.tap_flags |= TAP_FLAG_CSUM_OFFLOAD;
else if (unformat (line_input, "persist"))
@@ -138,7 +140,8 @@ VLIB_CLI_COMMAND (tap_create_command, static) = {
"[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>] "
"[host-mtu-size <size>] [no-gso|gso|csum-offload] [persist] [attach] [tun]",
"[host-mtu-size <size>] [no-gso|gso|csum-offload|gro-coalesce] "
"[persist] [attach] [tun]",
.function = tap_create_command_fn,
};
/* *INDENT-ON* */
+15 -5
View File
@@ -22,6 +22,21 @@
#define MIN(x,y) (((x)<(y))?(x):(y))
#endif
#define foreach_tapv2_flags \
_ (GSO, 0) \
_ (CSUM_OFFLOAD, 1) \
_ (PERSIST, 2) \
_ (ATTACH, 3) \
_ (TUN, 4) \
_ (GRO_COALESCE, 5)
typedef enum
{
#define _(a, b) TAP_FLAG_##a = (1 << b),
foreach_tapv2_flags
#undef _
} tap_flag_t;
typedef struct
{
u32 id;
@@ -31,11 +46,6 @@ typedef struct
u16 rx_ring_sz;
u16 tx_ring_sz;
u32 tap_flags;
#define TAP_FLAG_GSO (1 << 0)
#define TAP_FLAG_CSUM_OFFLOAD (1 << 1)
#define TAP_FLAG_PERSIST (1 << 2)
#define TAP_FLAG_ATTACH (1 << 3)
#define TAP_FLAG_TUN (1 << 4)
u8 *host_namespace;
u8 *host_if_name;
mac_address_t host_mac_addr;
+7 -6
View File
@@ -19,18 +19,19 @@
the Linux kernel TAP device driver
*/
option version = "3.0.0";
option version = "4.0.0";
import "vnet/interface_types.api";
import "vnet/ethernet/ethernet_types.api";
import "vnet/ip/ip_types.api";
enum tap_flags {
TAP_FLAG_GSO = 1,
TAP_FLAG_CSUM_OFFLOAD = 2,
TAP_FLAG_PERSIST = 4,
TAP_FLAG_ATTACH = 8,
TAP_FLAG_TUN = 16,
TAP_API_FLAG_GSO = 1, /* enable gso on the interface */
TAP_API_FLAG_CSUM_OFFLOAD = 2, /* enable checksum offload without gso on the interface */
TAP_API_FLAG_PERSIST = 4, /* make the interface persistence to exist in linux even vpp crash/restart */
TAP_API_FLAG_ATTACH = 8, /* attach to the existing persistence interface after vpp crash/restart */
TAP_API_FLAG_TUN = 16, /* create TUN interface instead of tap */
TAP_API_FLAG_GRO_COALESCE = 32, /* enable packet coalescing on tx side, provided gso enabled */
};
/** \brief Initialize a new tap interface with the given parameters
+4 -5
View File
@@ -58,7 +58,6 @@
_ (VHOST_USER_F_PROTOCOL_FEATURES, 30) \
_ (VIRTIO_F_VERSION_1, 32)
#define foreach_virtio_if_flag \
_(0, ADMIN_UP, "admin-up") \
_(1, DELETING, "deleting")
@@ -81,16 +80,16 @@ typedef enum
#define RX_QUEUE_ACCESS(X) (X/2)
#define foreach_virtio_if_types \
_ (TAP, 1) \
_ (TUN, 2) \
_ (PCI, 3)
_ (TAP, 0) \
_ (TUN, 1) \
_ (PCI, 2)
typedef enum
{
#define _(a, b) VIRTIO_IF_TYPE_##a = (1 << b),
foreach_virtio_if_types
#undef _
VIRTIO_IF_N_TYPES = (1 << 4),
VIRTIO_IF_N_TYPES = (1 << 3),
} virtio_if_type_t;
+4
View File
@@ -587,6 +587,10 @@ static void *vl_api_tap_create_v2_t_print
s = format (s, "persist ");
if ((mp->tap_flags) & 0x8)
s = format (s, "attach ");
if ((mp->tap_flags) & 0x16)
s = format (s, "tun ");
if ((mp->tap_flags) & 0x32)
s = format (s, "gro-coalesce-enabled ");
FINISH;
}