aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2018-10-26 05:17:03 -0700
committerDamjan Marion <dmarion@me.com>2018-10-27 09:06:06 +0000
commit6e43e0680fc21c6a986289cec4406c3624d3bbe6 (patch)
tree8cf2c1340739e8e6f08da2bc0ee70e22eca5a96d /src
parentf9dafebc44c7b52605eed393a418f47ca3ce6990 (diff)
Enumify interface flags
clang will emit a warning when the wrong enum type is passed to a function whose arguments are an enum type. free bug finding... Change-Id: I62215d8ef22c7527a31272e31f5d190e4e762e53 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vnet/interface.c33
-rw-r--r--src/vnet/interface.h67
-rw-r--r--src/vnet/interface_funcs.h4
3 files changed, 62 insertions, 42 deletions
diff --git a/src/vnet/interface.c b/src/vnet/interface.c
index dba5a667b22..dff1793712a 100644
--- a/src/vnet/interface.c
+++ b/src/vnet/interface.c
@@ -44,18 +44,25 @@
#include <vnet/adj/adj_mcast.h>
#include <vnet/l2/l2_input.h>
-#define VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE (1 << 0)
-#define VNET_INTERFACE_SET_FLAGS_HELPER_WANT_REDISTRIBUTE (1 << 1)
+typedef enum vnet_interface_helper_flags_t_
+{
+ VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE = (1 << 0),
+ VNET_INTERFACE_SET_FLAGS_HELPER_WANT_REDISTRIBUTE = (1 << 1),
+} vnet_interface_helper_flags_t;
static clib_error_t *vnet_hw_interface_set_flags_helper (vnet_main_t * vnm,
u32 hw_if_index,
- u32 flags,
- u32 helper_flags);
+ vnet_hw_interface_flags_t
+ flags,
+ vnet_interface_helper_flags_t
+ helper_flags);
static clib_error_t *vnet_sw_interface_set_flags_helper (vnet_main_t * vnm,
u32 sw_if_index,
- u32 flags,
- u32 helper_flags);
+ vnet_sw_interface_flags_t
+ flags,
+ vnet_interface_helper_flags_t
+ helper_flags);
static clib_error_t *vnet_hw_interface_set_class_helper (vnet_main_t * vnm,
u32 hw_if_index,
@@ -260,7 +267,9 @@ call_sw_interface_add_del_callbacks (vnet_main_t * vnm, u32 sw_if_index,
static clib_error_t *
vnet_hw_interface_set_flags_helper (vnet_main_t * vnm, u32 hw_if_index,
- u32 flags, u32 helper_flags)
+ vnet_hw_interface_flags_t flags,
+ vnet_interface_helper_flags_t
+ helper_flags)
{
vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
vnet_hw_interface_class_t *hw_class =
@@ -308,7 +317,9 @@ done:
static clib_error_t *
vnet_sw_interface_set_flags_helper (vnet_main_t * vnm, u32 sw_if_index,
- u32 flags, u32 helper_flags)
+ vnet_sw_interface_flags_t flags,
+ vnet_interface_helper_flags_t
+ helper_flags)
{
vnet_sw_interface_t *si = vnet_get_sw_interface (vnm, sw_if_index);
u32 mask;
@@ -466,7 +477,8 @@ done:
}
clib_error_t *
-vnet_hw_interface_set_flags (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
+vnet_hw_interface_set_flags (vnet_main_t * vnm, u32 hw_if_index,
+ vnet_hw_interface_flags_t flags)
{
return vnet_hw_interface_set_flags_helper
(vnm, hw_if_index, flags,
@@ -474,7 +486,8 @@ vnet_hw_interface_set_flags (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
}
clib_error_t *
-vnet_sw_interface_set_flags (vnet_main_t * vnm, u32 sw_if_index, u32 flags)
+vnet_sw_interface_set_flags (vnet_main_t * vnm, u32 sw_if_index,
+ vnet_sw_interface_flags_t flags)
{
return vnet_sw_interface_set_flags_helper
(vnm, sw_if_index, flags,
diff --git a/src/vnet/interface.h b/src/vnet/interface.h
index 7ce6aafdf54..5c15d29f453 100644
--- a/src/vnet/interface.h
+++ b/src/vnet/interface.h
@@ -482,38 +482,40 @@ static void __vnet_rm_hw_interface_class_registration_##x (void) \
} \
__VA_ARGS__ vnet_hw_interface_class_t x
-/* Hardware-interface. This corresponds to a physical wire
- that packets flow over. */
-typedef struct vnet_hw_interface_t
+typedef enum vnet_hw_interface_flags_t_
{
- /* Interface name. */
- u8 *name;
-
- u32 flags;
/* Hardware link state is up. */
-#define VNET_HW_INTERFACE_FLAG_LINK_UP (1 << 0)
+ VNET_HW_INTERFACE_FLAG_LINK_UP = (1 << 0),
/* Hardware duplex state */
-#define VNET_HW_INTERFACE_FLAG_DUPLEX_SHIFT 1
-#define VNET_HW_INTERFACE_FLAG_HALF_DUPLEX (1 << 1)
-#define VNET_HW_INTERFACE_FLAG_FULL_DUPLEX (1 << 2)
+ VNET_HW_INTERFACE_FLAG_HALF_DUPLEX = (1 << 1),
+ VNET_HW_INTERFACE_FLAG_FULL_DUPLEX = (1 << 2),
+
+ /* Hardware link speed */
+ VNET_HW_INTERFACE_FLAG_SPEED_10M = (1 << 3),
+ VNET_HW_INTERFACE_FLAG_SPEED_100M = (1 << 4),
+ VNET_HW_INTERFACE_FLAG_SPEED_1G = (1 << 5),
+ VNET_HW_INTERFACE_FLAG_SPEED_2_5G = (1 << 6),
+ VNET_HW_INTERFACE_FLAG_SPEED_5G = (1 << 7),
+ VNET_HW_INTERFACE_FLAG_SPEED_10G = (1 << 8),
+ VNET_HW_INTERFACE_FLAG_SPEED_20G = (1 << 9),
+ VNET_HW_INTERFACE_FLAG_SPEED_25G = (1 << 10),
+ VNET_HW_INTERFACE_FLAG_SPEED_40G = (1 << 11),
+ VNET_HW_INTERFACE_FLAG_SPEED_50G = (1 << 12),
+ VNET_HW_INTERFACE_FLAG_SPEED_56G = (1 << 13),
+ VNET_HW_INTERFACE_FLAG_SPEED_100G = (1 << 14),
+
+ /* rx mode flags */
+ VNET_HW_INTERFACE_FLAG_SUPPORTS_INT_MODE = (1 << 16),
+
+ /* tx checksum offload */
+ VNET_HW_INTERFACE_FLAG_SUPPORTS_TX_L4_CKSUM_OFFLOAD = (1 << 17),
+} vnet_hw_interface_flags_t;
+
+#define VNET_HW_INTERFACE_FLAG_DUPLEX_SHIFT 1
+#define VNET_HW_INTERFACE_FLAG_SPEED_SHIFT 3
#define VNET_HW_INTERFACE_FLAG_DUPLEX_MASK \
(VNET_HW_INTERFACE_FLAG_HALF_DUPLEX | \
VNET_HW_INTERFACE_FLAG_FULL_DUPLEX)
-
- /* Hardware link speed */
-#define VNET_HW_INTERFACE_FLAG_SPEED_SHIFT 3
-#define VNET_HW_INTERFACE_FLAG_SPEED_10M (1 << 3)
-#define VNET_HW_INTERFACE_FLAG_SPEED_100M (1 << 4)
-#define VNET_HW_INTERFACE_FLAG_SPEED_1G (1 << 5)
-#define VNET_HW_INTERFACE_FLAG_SPEED_2_5G (1 << 6)
-#define VNET_HW_INTERFACE_FLAG_SPEED_5G (1 << 7)
-#define VNET_HW_INTERFACE_FLAG_SPEED_10G (1 << 8)
-#define VNET_HW_INTERFACE_FLAG_SPEED_20G (1 << 9)
-#define VNET_HW_INTERFACE_FLAG_SPEED_25G (1 << 10)
-#define VNET_HW_INTERFACE_FLAG_SPEED_40G (1 << 11)
-#define VNET_HW_INTERFACE_FLAG_SPEED_50G (1 << 12)
-#define VNET_HW_INTERFACE_FLAG_SPEED_56G (1 << 13)
-#define VNET_HW_INTERFACE_FLAG_SPEED_100G (1 << 14)
#define VNET_HW_INTERFACE_FLAG_SPEED_MASK \
(VNET_HW_INTERFACE_FLAG_SPEED_10M | \
VNET_HW_INTERFACE_FLAG_SPEED_100M | \
@@ -528,11 +530,15 @@ typedef struct vnet_hw_interface_t
VNET_HW_INTERFACE_FLAG_SPEED_56G | \
VNET_HW_INTERFACE_FLAG_SPEED_100G)
- /* rx mode flags */
-#define VNET_HW_INTERFACE_FLAG_SUPPORTS_INT_MODE (1 << 16)
+/* Hardware-interface. This corresponds to a physical wire
+ that packets flow over. */
+typedef struct vnet_hw_interface_t
+{
+ /* Interface name. */
+ u8 *name;
- /* tx checksum offload */
-#define VNET_HW_INTERFACE_FLAG_SUPPORTS_TX_L4_CKSUM_OFFLOAD (1 << 17)
+ /* flags */
+ vnet_hw_interface_flags_t flags;
/* Hardware address as vector. Zero (e.g. zero-length vector) if no
address for this class (e.g. PPP). */
@@ -686,6 +692,7 @@ extern vnet_mtu_t vnet_link_to_mtu (vnet_link_t link);
typedef enum vnet_sw_interface_flags_t_
{
+ VNET_SW_INTERFACE_FLAG_ADMIN_NONE = 0,
/* Interface is "up" meaning administratively up.
Up in the sense of link state being up is maintained by hardware interface. */
VNET_SW_INTERFACE_FLAG_ADMIN_UP = (1 << 0),
diff --git a/src/vnet/interface_funcs.h b/src/vnet/interface_funcs.h
index 557ed146a3a..00fc289b46a 100644
--- a/src/vnet/interface_funcs.h
+++ b/src/vnet/interface_funcs.h
@@ -320,11 +320,11 @@ vnet_put_frame_to_sw_interface (vnet_main_t * vnm, u32 sw_if_index,
/* Change interface flags (e.g. up, down, enable, disable). */
clib_error_t *vnet_hw_interface_set_flags (vnet_main_t * vnm, u32 hw_if_index,
- u32 flags);
+ vnet_hw_interface_flags_t flags);
/* Change interface flags (e.g. up, down, enable, disable). */
clib_error_t *vnet_sw_interface_set_flags (vnet_main_t * vnm, u32 sw_if_index,
- u32 flags);
+ vnet_sw_interface_flags_t flags);
/* Change interface class. */
clib_error_t *vnet_hw_interface_set_class (vnet_main_t * vnm, u32 hw_if_index,