summaryrefslogtreecommitdiffstats
path: root/vnet/vnet/interface_format.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2016-08-08 09:51:21 -0400
committerKeith Burns <alagalah@gmail.com>2016-08-08 15:25:14 +0000
commitba868bb7898edc46ad5f8cd4925af6c8b92e7c89 (patch)
treea6f4092a3373e0a8d4f4a67da6e60f78331fe37f /vnet/vnet/interface_format.c
parentda62e1a1d84728094c427a4a7ec03e76e2df988c (diff)
VPP-311 Coding standards cleanup for vnet/vnet/*.[ch]
Change-Id: I08ed983f594072bc8c72202e77205a7789eea599 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'vnet/vnet/interface_format.c')
-rw-r--r--vnet/vnet/interface_format.c210
1 files changed, 115 insertions, 95 deletions
diff --git a/vnet/vnet/interface_format.c b/vnet/vnet/interface_format.c
index 319113f594a..b3a30622031 100644
--- a/vnet/vnet/interface_format.c
+++ b/vnet/vnet/interface_format.c
@@ -40,35 +40,36 @@
#include <vnet/vnet.h>
#include <vppinfra/bitmap.h>
-u8 * format_vnet_sw_interface_flags (u8 * s, va_list * args)
+u8 *
+format_vnet_sw_interface_flags (u8 * s, va_list * args)
{
u32 flags = va_arg (*args, u32);
- if (flags & VNET_SW_INTERFACE_FLAG_BOND_SLAVE)
+ if (flags & VNET_SW_INTERFACE_FLAG_BOND_SLAVE)
s = format (s, "bond-slave");
- else
+ else
{
- s = format (s, "%s",
+ s = format (s, "%s",
(flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? "up" : "down");
- if (flags & VNET_SW_INTERFACE_FLAG_PUNT)
+ if (flags & VNET_SW_INTERFACE_FLAG_PUNT)
s = format (s, "/punt");
}
return s;
}
-u8 * format_vnet_hw_interface (u8 * s, va_list * args)
+u8 *
+format_vnet_hw_interface (u8 * s, va_list * args)
{
- vnet_main_t * vnm = va_arg (*args, vnet_main_t *);
- vnet_hw_interface_t * hi = va_arg (*args, vnet_hw_interface_t *);
- vnet_hw_interface_class_t * hw_class;
- vnet_device_class_t * dev_class;
+ vnet_main_t *vnm = va_arg (*args, vnet_main_t *);
+ vnet_hw_interface_t *hi = va_arg (*args, vnet_hw_interface_t *);
+ vnet_hw_interface_class_t *hw_class;
+ vnet_device_class_t *dev_class;
int verbose = va_arg (*args, int);
uword indent;
- if (! hi)
- return format (s, "%=32s%=6s%=8s%s",
- "Name", "Idx", "Link", "Hardware");
+ if (!hi)
+ return format (s, "%=32s%=6s%=8s%s", "Name", "Idx", "Link", "Hardware");
indent = format_get_indent (s);
@@ -77,19 +78,20 @@ u8 * format_vnet_hw_interface (u8 * s, va_list * args)
if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE)
s = format (s, "%=8s", "slave");
else
- s = format (s, "%=8s",
+ s = format (s, "%=8s",
hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP ? "up" : "down");
hw_class = vnet_get_hw_interface_class (vnm, hi->hw_class_index);
dev_class = vnet_get_device_class (vnm, hi->dev_class_index);
- if (hi->bond_info && (hi->bond_info != VNET_HW_INTERFACE_BOND_INFO_SLAVE))
+ if (hi->bond_info && (hi->bond_info != VNET_HW_INTERFACE_BOND_INFO_SLAVE))
{
int hw_idx;
s = format (s, "Slave-Idx:");
- clib_bitmap_foreach (hw_idx, hi->bond_info, s = format(s, " %d", hw_idx));
+ clib_bitmap_foreach (hw_idx, hi->bond_info, s =
+ format (s, " %d", hw_idx));
}
- else if (dev_class->format_device_name)
+ else if (dev_class->format_device_name)
s = format (s, "%U", dev_class->format_device_name, hi->dev_instance);
else
s = format (s, "%s%d", dev_class->name, hi->dev_instance);
@@ -103,10 +105,11 @@ u8 * format_vnet_hw_interface (u8 * s, va_list * args)
else
{
s = format (s, "\n%U%s",
- format_white_space, indent + 2,
- hw_class->name);
+ format_white_space, indent + 2, hw_class->name);
if (hw_class->format_address && vec_len (hi->hw_address) > 0)
- s = format (s, " address %U", hw_class->format_address, hi->hw_address);
+ s =
+ format (s, " address %U", hw_class->format_address,
+ hi->hw_address);
}
if (dev_class->format_device)
@@ -118,12 +121,14 @@ u8 * format_vnet_hw_interface (u8 * s, va_list * args)
return s;
}
-u8 * format_vnet_sw_interface_name (u8 * s, va_list * args)
+u8 *
+format_vnet_sw_interface_name (u8 * s, va_list * args)
{
- vnet_main_t * vnm = va_arg (*args, vnet_main_t *);
- vnet_sw_interface_t * si = va_arg (*args, vnet_sw_interface_t *);
- vnet_sw_interface_t * si_sup = vnet_get_sup_sw_interface (vnm, si->sw_if_index);
- vnet_hw_interface_t * hi_sup;
+ vnet_main_t *vnm = va_arg (*args, vnet_main_t *);
+ vnet_sw_interface_t *si = va_arg (*args, vnet_sw_interface_t *);
+ vnet_sw_interface_t *si_sup =
+ vnet_get_sup_sw_interface (vnm, si->sw_if_index);
+ vnet_hw_interface_t *hi_sup;
ASSERT (si_sup->type == VNET_SW_INTERFACE_TYPE_HARDWARE);
hi_sup = vnet_get_hw_interface (vnm, si_sup->hw_if_index);
@@ -136,21 +141,23 @@ u8 * format_vnet_sw_interface_name (u8 * s, va_list * args)
return s;
}
-u8 * format_vnet_sw_if_index_name (u8 * s, va_list * args)
+u8 *
+format_vnet_sw_if_index_name (u8 * s, va_list * args)
{
- vnet_main_t * vnm = va_arg (*args, vnet_main_t *);
+ vnet_main_t *vnm = va_arg (*args, vnet_main_t *);
u32 sw_if_index = va_arg (*args, u32);
return format (s, "%U",
format_vnet_sw_interface_name, vnm,
vnet_get_sw_interface (vnm, sw_if_index));
}
-u8 * format_vnet_sw_interface_cntrs (u8 * s, vnet_interface_main_t * im,
- vnet_sw_interface_t * si)
+u8 *
+format_vnet_sw_interface_cntrs (u8 * s, vnet_interface_main_t * im,
+ vnet_sw_interface_t * si)
{
uword indent, n_printed;
int i, j, n_counters;
- static vnet_main_t ** my_vnet_mains;
+ static vnet_main_t **my_vnet_mains;
vec_reset_length (my_vnet_mains);
@@ -158,18 +165,18 @@ u8 * format_vnet_sw_interface_cntrs (u8 * s, vnet_interface_main_t * im,
n_printed = 0;
{
- vlib_combined_counter_main_t * cm;
+ vlib_combined_counter_main_t *cm;
vlib_counter_t v, vtotal;
- u8 * n = 0;
+ u8 *n = 0;
for (i = 0; i < vec_len (vnet_mains); i++)
{
- if (vnet_mains[i])
- vec_add1 (my_vnet_mains, vnet_mains[i]);
+ if (vnet_mains[i])
+ vec_add1 (my_vnet_mains, vnet_mains[i]);
}
- if (vec_len(my_vnet_mains) == 0)
- vec_add1 (my_vnet_mains, &vnet_main);
+ if (vec_len (my_vnet_mains) == 0)
+ vec_add1 (my_vnet_mains, &vnet_main);
/* Each vnet_main_t has its own copy of the interface counters */
n_counters = vec_len (im->combined_sw_if_counters);
@@ -177,17 +184,17 @@ u8 * format_vnet_sw_interface_cntrs (u8 * s, vnet_interface_main_t * im,
/* rx, tx counters... */
for (j = 0; j < n_counters; j++)
{
- vtotal.packets = 0;
- vtotal.bytes = 0;
-
- for (i = 0; i < vec_len(my_vnet_mains); i++)
- {
- im = &my_vnet_mains[i]->interface_main;
- cm = im->combined_sw_if_counters + j;
- vlib_get_combined_counter (cm, si->sw_if_index, &v);
- vtotal.packets += v.packets;
- vtotal.bytes += v.bytes;
- }
+ vtotal.packets = 0;
+ vtotal.bytes = 0;
+
+ for (i = 0; i < vec_len (my_vnet_mains); i++)
+ {
+ im = &my_vnet_mains[i]->interface_main;
+ cm = im->combined_sw_if_counters + j;
+ vlib_get_combined_counter (cm, si->sw_if_index, &v);
+ vtotal.packets += v.packets;
+ vtotal.bytes += v.bytes;
+ }
/* Only display non-zero counters. */
if (vtotal.packets == 0)
@@ -205,30 +212,29 @@ u8 * format_vnet_sw_interface_cntrs (u8 * s, vnet_interface_main_t * im,
_vec_len (n) = 0;
n = format (n, "%s bytes", cm->name);
s = format (s, "\n%U%-16v%16Ld",
- format_white_space, indent,
- n, vtotal.bytes);
+ format_white_space, indent, n, vtotal.bytes);
}
vec_free (n);
}
{
- vlib_simple_counter_main_t * cm;
- u64 v, vtotal ;
+ vlib_simple_counter_main_t *cm;
+ u64 v, vtotal;
n_counters = vec_len (im->sw_if_counters);
for (j = 0; j < n_counters; j++)
{
- vtotal = 0;
+ vtotal = 0;
- for (i = 0; i < vec_len(my_vnet_mains); i++)
- {
- im = &my_vnet_mains[i]->interface_main;
- cm = im->sw_if_counters + j;
+ for (i = 0; i < vec_len (my_vnet_mains); i++)
+ {
+ im = &my_vnet_mains[i]->interface_main;
+ cm = im->sw_if_counters + j;
- v = vlib_get_simple_counter (cm, si->sw_if_index);
- vtotal += v;
- }
+ v = vlib_get_simple_counter (cm, si->sw_if_index);
+ vtotal += v;
+ }
/* Only display non-zero counters. */
if (vtotal == 0)
@@ -245,13 +251,14 @@ u8 * format_vnet_sw_interface_cntrs (u8 * s, vnet_interface_main_t * im,
return s;
}
-u8 * format_vnet_sw_interface (u8 * s, va_list * args)
+u8 *
+format_vnet_sw_interface (u8 * s, va_list * args)
{
- vnet_main_t * vnm = va_arg (*args, vnet_main_t *);
- vnet_sw_interface_t * si = va_arg (*args, vnet_sw_interface_t *);
- vnet_interface_main_t * im = &vnm->interface_main;
+ vnet_main_t *vnm = va_arg (*args, vnet_main_t *);
+ vnet_sw_interface_t *si = va_arg (*args, vnet_sw_interface_t *);
+ vnet_interface_main_t *im = &vnm->interface_main;
- if (! si)
+ if (!si)
return format (s, "%=32s%=5s%=16s%=16s%=16s",
"Name", "Idx", "State", "Counter", "Count");
@@ -259,21 +266,22 @@ u8 * format_vnet_sw_interface (u8 * s, va_list * args)
format_vnet_sw_interface_name, vnm, si, si->sw_if_index,
format_vnet_sw_interface_flags, si->flags);
- s = format_vnet_sw_interface_cntrs(s, im, si);
+ s = format_vnet_sw_interface_cntrs (s, im, si);
return s;
}
-u8 * format_vnet_sw_interface_name_override (u8 * s, va_list * args)
+u8 *
+format_vnet_sw_interface_name_override (u8 * s, va_list * args)
{
- vnet_main_t * vnm = va_arg (*args, vnet_main_t *);
- vnet_sw_interface_t * si = va_arg (*args, vnet_sw_interface_t *);
+ vnet_main_t *vnm = va_arg (*args, vnet_main_t *);
+ vnet_sw_interface_t *si = va_arg (*args, vnet_sw_interface_t *);
/* caller supplied display name for this interface */
- u8* name = va_arg (*args, u8*);
- vnet_interface_main_t * im = &vnm->interface_main;
+ u8 *name = va_arg (*args, u8 *);
+ vnet_interface_main_t *im = &vnm->interface_main;
- if (! si)
+ if (!si)
return format (s, "%=32s%=5s%=16s%=16s%=16s",
"Name", "Idx", "State", "Counter", "Count");
@@ -281,38 +289,40 @@ u8 * format_vnet_sw_interface_name_override (u8 * s, va_list * args)
name, si->sw_if_index,
format_vnet_sw_interface_flags, si->flags);
- s = format_vnet_sw_interface_cntrs(s, im, si);
+ s = format_vnet_sw_interface_cntrs (s, im, si);
return s;
}
-uword unformat_vnet_hw_interface (unformat_input_t * input, va_list * args)
+uword
+unformat_vnet_hw_interface (unformat_input_t * input, va_list * args)
{
- vnet_main_t * vnm = va_arg (*args, vnet_main_t *);
- u32 * hw_if_index = va_arg (*args, u32 *);
- vnet_interface_main_t * im = &vnm->interface_main;
- vnet_device_class_t * c;
+ vnet_main_t *vnm = va_arg (*args, vnet_main_t *);
+ u32 *hw_if_index = va_arg (*args, u32 *);
+ vnet_interface_main_t *im = &vnm->interface_main;
+ vnet_device_class_t *c;
/* Try per device class functions first. */
vec_foreach (c, im->device_classes)
- {
- if (c->unformat_device_name
- && unformat_user (input, c->unformat_device_name, hw_if_index))
+ {
+ if (c->unformat_device_name
+ && unformat_user (input, c->unformat_device_name, hw_if_index))
return 1;
- }
+ }
return unformat_user (input, unformat_hash_vec_string,
im->hw_interface_by_name, hw_if_index);
}
-uword unformat_vnet_sw_interface (unformat_input_t * input, va_list * args)
+uword
+unformat_vnet_sw_interface (unformat_input_t * input, va_list * args)
{
- vnet_main_t * vnm = va_arg (*args, vnet_main_t *);
- u32 * result = va_arg (*args, u32 *);
- vnet_hw_interface_t * hi;
+ vnet_main_t *vnm = va_arg (*args, vnet_main_t *);
+ u32 *result = va_arg (*args, u32 *);
+ vnet_hw_interface_t *hi;
u32 hw_if_index, id, id_specified;
- u8 * if_name = 0;
- uword * p, error = 0;
+ u8 *if_name = 0;
+ uword *p, error = 0;
id = ~0;
if (unformat (input, "%_%v.%d%_", &if_name, &id)
@@ -321,31 +331,33 @@ uword unformat_vnet_sw_interface (unformat_input_t * input, va_list * args)
hw_if_index = p[0];
id_specified = 1;
}
- else if (unformat (input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
+ else
+ if (unformat (input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
id_specified = 0;
else
goto done;
hi = vnet_get_hw_interface (vnm, hw_if_index);
- if (! id_specified)
+ if (!id_specified)
{
*result = hi->sw_if_index;
}
else
{
- if (! (p = hash_get (hi->sub_interface_sw_if_index_by_id, id)))
+ if (!(p = hash_get (hi->sub_interface_sw_if_index_by_id, id)))
return 0;
*result = p[0];
}
error = 1;
- done:
+done:
vec_free (if_name);
return error;
}
-uword unformat_vnet_sw_interface_flags (unformat_input_t * input, va_list * args)
+uword
+unformat_vnet_sw_interface_flags (unformat_input_t * input, va_list * args)
{
- u32 * result = va_arg (*args, u32 *);
+ u32 *result = va_arg (*args, u32 *);
u32 flags = 0;
if (unformat (input, "up"))
@@ -363,9 +375,10 @@ uword unformat_vnet_sw_interface_flags (unformat_input_t * input, va_list * args
return 1;
}
-uword unformat_vnet_hw_interface_flags (unformat_input_t * input, va_list * args)
+uword
+unformat_vnet_hw_interface_flags (unformat_input_t * input, va_list * args)
{
- u32 * result = va_arg (*args, u32 *);
+ u32 *result = va_arg (*args, u32 *);
u32 flags = 0;
if (unformat (input, "up"))
@@ -379,3 +392,10 @@ uword unformat_vnet_hw_interface_flags (unformat_input_t * input, va_list * args
return 1;
}
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */