aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbuild-root/emacs-lisp/fix-coding-style.el8
-rw-r--r--vnet/vnet/api_errno.h13
-rw-r--r--vnet/vnet/buffer.h217
-rw-r--r--vnet/vnet/config.c192
-rw-r--r--vnet/vnet/config.h63
-rw-r--r--vnet/vnet/dpdk_replication.h122
-rw-r--r--vnet/vnet/global_funcs.h10
-rw-r--r--vnet/vnet/handoff.c387
-rw-r--r--vnet/vnet/handoff.h276
-rw-r--r--vnet/vnet/interface.c817
-rw-r--r--vnet/vnet/interface.h231
-rw-r--r--vnet/vnet/interface_cli.c820
-rw-r--r--vnet/vnet/interface_format.c210
-rw-r--r--vnet/vnet/interface_funcs.h113
-rw-r--r--vnet/vnet/interface_output.c936
-rw-r--r--vnet/vnet/l3_types.h11
-rw-r--r--vnet/vnet/misc.c24
-rw-r--r--vnet/vnet/pipeline.h639
-rw-r--r--vnet/vnet/replication.c316
-rw-r--r--vnet/vnet/replication.h112
-rw-r--r--vnet/vnet/rewrite.c165
-rw-r--r--vnet/vnet/rewrite.h115
-rw-r--r--vnet/vnet/vnet.h30
23 files changed, 3185 insertions, 2642 deletions
diff --git a/build-root/emacs-lisp/fix-coding-style.el b/build-root/emacs-lisp/fix-coding-style.el
index 3b5ff561af5..3c927970104 100755
--- a/build-root/emacs-lisp/fix-coding-style.el
+++ b/build-root/emacs-lisp/fix-coding-style.el
@@ -74,6 +74,12 @@
(defun fix-reply-macro2 () (interactive)
(fix-initializer "REPLY_MACRO2 *("))
+(defun fix-vnet-device-class () (interactive)
+ (fix-initializer "VNET_DEVICE_CLASS *("))
+
+(defun fix-vnet-hw-interface-class () (interactive)
+ (fix-initializer "VNET_HW_INTERFACE_CLASS *("))
+
;; Driver routine which runs the set of functions
;; defined above, as well as the bottom boilerplate function
@@ -90,6 +96,8 @@
(fix-vlib-cli-command)
(fix-vlib-register-node)
(fix-reply-macro2)
+ (fix-vnet-device-class)
+ (fix-vnet-hw-interface-class)
(insert-style-boilerplate))
diff --git a/vnet/vnet/api_errno.h b/vnet/vnet/api_errno.h
index 2b18ef56d54..c534b4bc6ab 100644
--- a/vnet/vnet/api_errno.h
+++ b/vnet/vnet/api_errno.h
@@ -88,11 +88,20 @@ _(INCORRECT_ADJACENCY_TYPE, -94, "Invalid adjacency type for this operation") \
_(EXCEEDED_NUMBER_OF_RANGES_CAPACITY, -95, "Operation would exceed configured capacity of ranges") \
_(EXCEEDED_NUMBER_OF_PORTS_CAPACITY, -96, "Operation would exceed capacity of number of ports")
-typedef enum {
+typedef enum
+{
#define _(a,b,c) VNET_API_ERROR_##a = (b),
- foreach_vnet_api_error
+ foreach_vnet_api_error
#undef _
VNET_API_N_ERROR,
} vnet_api_error_t;
#endif /* included_vnet_api_errno_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/buffer.h b/vnet/vnet/buffer.h
index 742fe32b25f..3fcdf074e36 100644
--- a/vnet/vnet/buffer.h
+++ b/vnet/vnet/buffer.h
@@ -83,7 +83,7 @@ _(map) \
_(map_t) \
_(ip_frag)
-/*
+/*
* vnet stack buffer opaque array overlay structure.
* The vnet_buffer_opaque_t *must* be the same size as the
* vlib_buffer_t "opaque" structure member, 32 bytes.
@@ -94,35 +94,42 @@ _(ip_frag)
* of the union, and will announce any deviations in an
* impossible-to-miss manner.
*/
-typedef struct {
+typedef struct
+{
u32 sw_if_index[VLIB_N_RX_TX];
- union {
+ union
+ {
/* Ethernet. */
- struct {
+ struct
+ {
/* Saved value of current header by ethernet-input. */
i32 start_of_ethernet_header;
} ethernet;
/* IP4/6 buffer opaque. */
- struct {
+ struct
+ {
/* Adjacency from destination IP address lookup [VLIB_TX].
- Adjacency from source IP address lookup [VLIB_RX].
- This gets set to ~0 until source lookup is performed. */
+ Adjacency from source IP address lookup [VLIB_RX].
+ This gets set to ~0 until source lookup is performed. */
u32 adj_index[VLIB_N_RX_TX];
- union {
- struct {
+ union
+ {
+ struct
+ {
/* Flow hash value for this packet computed from IP src/dst address
protocol and ports. */
u32 flow_hash;
- /* next protocol */
- u32 save_protocol;
+ /* next protocol */
+ u32 save_protocol;
};
/* Alternate used for local TCP packets. */
- struct {
+ struct
+ {
u32 listener_index;
u32 established_connection_index;
@@ -133,7 +140,8 @@ typedef struct {
} tcp;
/* ICMP */
- struct {
+ struct
+ {
u8 type;
u8 code;
u32 data;
@@ -142,40 +150,46 @@ typedef struct {
} ip;
/* Multicast replication */
- struct {
- u32 pad[3];
+ struct
+ {
+ u32 pad[3];
u32 mcast_group_index;
u32 mcast_current_index;
u32 original_free_list_index;
} mcast;
/* ip4-in-ip6 softwire termination, only valid there */
- struct {
+ struct
+ {
u8 swt_disable;
u32 mapping_index;
} swt;
/* l2 bridging path, only valid there */
- struct {
+ struct
+ {
u32 feature_bitmap;
- u16 bd_index; // bridge-domain index
- u8 l2_len; // ethernet header length
- u8 shg; // split-horizon group
+ u16 bd_index; // bridge-domain index
+ u8 l2_len; // ethernet header length
+ u8 shg; // split-horizon group
} l2;
/* l2tpv3 softwire encap, only valid there */
- struct {
- u32 pad[4]; /* do not overlay w/ ip.adj_index[0,1] */
+ struct
+ {
+ u32 pad[4]; /* do not overlay w/ ip.adj_index[0,1] */
u8 next_index;
u32 session_index;
} l2t;
- struct {
+ struct
+ {
u32 src, dst;
} gre;
/* L2 classify */
- struct {
+ struct
+ {
u64 pad;
u32 opaque_index;
u32 table_index;
@@ -183,18 +197,21 @@ typedef struct {
} l2_classify;
/* IO - worker thread handoff */
- struct {
+ struct
+ {
u32 next_index;
} handoff;
/* vnet policer */
- struct {
- u32 pad[8 -VLIB_N_RX_TX -1]; /* to end of opaque */
+ struct
+ {
+ u32 pad[8 - VLIB_N_RX_TX - 1]; /* to end of opaque */
u32 index;
} policer;
/* interface output features */
- struct {
+ struct
+ {
u32 ipsec_spd_index;
u32 ipsec_sad_index;
u32 unused[3];
@@ -202,99 +219,111 @@ typedef struct {
} output_features;
/* vcgn udp inside input, only valid there */
- struct {
+ struct
+ {
/* This part forms context of the packet. The structure should be
- * exactly same as spp_ctx_t. Also this should be the first
+ * exactly same as spp_ctx_t. Also this should be the first
* element of this vcgn_uii structure.
*/
/****** BEGIN spp_ctx_t section ***********************/
- union { /* Roddick specific */
- u32 roddick_info;
- struct _tx_pkt_info { /* Used by PI to PI communication for TX */
- u32 uidb_index:16; /* uidb_index to transmit */
- u32 packet_type:2; /* 1-IPv4, 2-Ipv6, - 0,3 - Unused */
- u32 ipv4_defrag:1; /* 0 - Normal, 1 - update first
- * segment size
- * (set by 6rd defrag node)
- */
-
- u32 dst_ip_port_idx:4;/* Index to dst_ip_port_table */
- u32 from_node:4;
- u32 calc_chksum:1;
- u32 reserved:4;
- } tx;
- struct _rx_pkt_info { /* Used by PD / PI communication */
- u32 uidb_index:16; /* uidb_index received in packet */
- u32 packet_type:2; /* 1-IPv4, 2-Ipv6, - 0,3 - Unused */
- u32 icmp_type:1; /* 0-ICMP query type, 1-ICMP error type */
- u32 protocol_type:2; /* 1-TCP, 2-UDP, 3-ICMP, 0 - Unused */
- u32 ipv4_defrag:1; /* 0 - Normal, 1 - update first
- * segment size
- * (set by 6rd defrag node)
- */
-
- u32 direction:1; /* 0-Outside, 1-Inside */
- u32 frag:1; /*IP fragment-1, Otherwise-0*/
- u32 option:1; /* 0-No IP option (v4) present, non-fragHdr
- * option hdr present (v6)
- */
- u32 df_bit:1; /* IPv4 DF bit copied here */
- u32 reserved1:6;
- } rx;
+ union
+ { /* Roddick specific */
+ u32 roddick_info;
+ struct _tx_pkt_info
+ { /* Used by PI to PI communication for TX */
+ u32 uidb_index:16; /* uidb_index to transmit */
+ u32 packet_type:2; /* 1-IPv4, 2-Ipv6, - 0,3 - Unused */
+ u32 ipv4_defrag:1; /* 0 - Normal, 1 - update first
+ * segment size
+ * (set by 6rd defrag node)
+ */
+
+ u32 dst_ip_port_idx:4; /* Index to dst_ip_port_table */
+ u32 from_node:4;
+ u32 calc_chksum:1;
+ u32 reserved:4;
+ } tx;
+ struct _rx_pkt_info
+ { /* Used by PD / PI communication */
+ u32 uidb_index:16; /* uidb_index received in packet */
+ u32 packet_type:2; /* 1-IPv4, 2-Ipv6, - 0,3 - Unused */
+ u32 icmp_type:1; /* 0-ICMP query type, 1-ICMP error type */
+ u32 protocol_type:2; /* 1-TCP, 2-UDP, 3-ICMP, 0 - Unused */
+ u32 ipv4_defrag:1; /* 0 - Normal, 1 - update first
+ * segment size
+ * (set by 6rd defrag node)
+ */
+
+ u32 direction:1; /* 0-Outside, 1-Inside */
+ u32 frag:1; /*IP fragment-1, Otherwise-0 */
+ u32 option:1; /* 0-No IP option (v4) present, non-fragHdr
+ * option hdr present (v6)
+ */
+ u32 df_bit:1; /* IPv4 DF bit copied here */
+ u32 reserved1:6;
+ } rx;
} ru;
/****** END spp_ctx_t section ***********************/
- union {
- struct {
- u32 ipv4;
- u16 port;
- u16 vrf; //bit0-13:i/f, bit14-15:protocol
- } k;
+ union
+ {
+ struct
+ {
+ u32 ipv4;
+ u16 port;
+ u16 vrf; //bit0-13:i/f, bit14-15:protocol
+ } k;
- u64 key64;
+ u64 key64;
} key;
u32 bucket;
- u16 ovrf; /* Exit interface */
+ u16 ovrf; /* Exit interface */
u8 frag_pkt;
u8 vcgn_unused1;
} vcgn_uii;
/* MAP */
- struct {
+ struct
+ {
u16 mtu;
} map;
/* MAP-T */
- struct {
+ struct
+ {
u32 map_domain_index;
- struct {
- u32 saddr, daddr;
- u16 frag_offset; //Fragmentation header offset
- u16 l4_offset; //L4 header overall offset
- u8 l4_protocol; //The final protocol number
- } v6; //Used by ip6_map_t only
- u16 checksum_offset; //L4 checksum overall offset
- u16 mtu; //Exit MTU
+ struct
+ {
+ u32 saddr, daddr;
+ u16 frag_offset; //Fragmentation header offset
+ u16 l4_offset; //L4 header overall offset
+ u8 l4_protocol; //The final protocol number
+ } v6; //Used by ip6_map_t only
+ u16 checksum_offset; //L4 checksum overall offset
+ u16 mtu; //Exit MTU
} map_t;
/* IP Fragmentation */
- struct {
+ struct
+ {
u16 header_offset;
u16 mtu;
u8 next_index;
- u8 flags; //See ip_frag.h
+ u8 flags; //See ip_frag.h
} ip_frag;
/* COP - configurable junk filter(s) */
- struct {
- /* Current configuration index. */
- u32 current_config_index;
+ struct
+ {
+ /* Current configuration index. */
+ u32 current_config_index;
} cop;
/* LISP */
- struct {
+ struct
+ {
/* overlay address family */
u16 overlay_afi;
} lisp;
@@ -306,11 +335,21 @@ typedef struct {
#define vnet_buffer(b) ((vnet_buffer_opaque_t *) (b)->opaque)
/* Full cache line (64 bytes) of additional space */
-typedef struct {
- union {
+typedef struct
+{
+ union
+ {
};
} vnet_buffer_opaque2_t;
#endif /* included_vnet_buffer_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/config.c b/vnet/vnet/config.c
index 2e056c83738..be48df69a84 100644
--- a/vnet/vnet/config.c
+++ b/vnet/vnet/config.c
@@ -42,11 +42,10 @@
static vnet_config_feature_t *
duplicate_feature_vector (vnet_config_feature_t * feature_vector)
{
- vnet_config_feature_t * result, * f;
+ vnet_config_feature_t *result, *f;
result = vec_dup (feature_vector);
- vec_foreach (f, result)
- f->feature_config = vec_dup (f->feature_config);
+ vec_foreach (f, result) f->feature_config = vec_dup (f->feature_config);
return result;
}
@@ -54,18 +53,15 @@ duplicate_feature_vector (vnet_config_feature_t * feature_vector)
static void
free_feature_vector (vnet_config_feature_t * feature_vector)
{
- vnet_config_feature_t * f;
+ vnet_config_feature_t *f;
- vec_foreach (f, feature_vector)
- vnet_config_feature_free (f);
+ vec_foreach (f, feature_vector) vnet_config_feature_free (f);
vec_free (feature_vector);
}
static u32
add_next (vlib_main_t * vm,
- vnet_config_main_t * cm,
- u32 last_node_index,
- u32 this_node_index)
+ vnet_config_main_t * cm, u32 last_node_index, u32 this_node_index)
{
u32 i, ni = ~0;
@@ -75,7 +71,8 @@ add_next (vlib_main_t * vm,
for (i = 0; i < vec_len (cm->start_node_indices); i++)
{
u32 tmp;
- tmp = vlib_node_add_next (vm, cm->start_node_indices[i], this_node_index);
+ tmp =
+ vlib_node_add_next (vm, cm->start_node_indices[i], this_node_index);
if (ni == ~0)
ni = tmp;
/* Start nodes to first must agree on next indices. */
@@ -91,10 +88,10 @@ find_config_with_features (vlib_main_t * vm,
vnet_config_feature_t * feature_vector)
{
u32 last_node_index = ~0;
- vnet_config_feature_t * f;
- u32 * config_string;
- uword * p;
- vnet_config_t * c;
+ vnet_config_feature_t *f;
+ u32 *config_string;
+ uword *p;
+ vnet_config_t *c;
config_string = cm->config_string_temp;
cm->config_string_temp = 0;
@@ -102,17 +99,17 @@ find_config_with_features (vlib_main_t * vm,
_vec_len (config_string) = 0;
vec_foreach (f, feature_vector)
- {
- /* Connect node graph. */
- f->next_index = add_next (vm, cm, last_node_index, f->node_index);
- last_node_index = f->node_index;
+ {
+ /* Connect node graph. */
+ f->next_index = add_next (vm, cm, last_node_index, f->node_index);
+ last_node_index = f->node_index;
- /* Store next index in config string. */
- vec_add1 (config_string, f->next_index);
+ /* Store next index in config string. */
+ vec_add1 (config_string, f->next_index);
- /* Store feature config. */
- vec_add (config_string, f->feature_config, vec_len (f->feature_config));
- }
+ /* Store feature config. */
+ vec_add (config_string, f->feature_config, vec_len (f->feature_config));
+ }
/* Terminate config string with next for end node. */
if (last_node_index == ~0 || last_node_index != cm->end_node_index)
@@ -126,13 +123,13 @@ find_config_with_features (vlib_main_t * vm,
if (p)
{
/* Not unique. Share existing config. */
- cm->config_string_temp = config_string; /* we'll use it again later. */
+ cm->config_string_temp = config_string; /* we'll use it again later. */
free_feature_vector (feature_vector);
c = pool_elt_at_index (cm->config_pool, p[0]);
}
else
{
- u32 * d;
+ u32 *d;
pool_get (cm->config_pool, c);
c->index = c - cm->config_pool;
@@ -140,37 +137,42 @@ find_config_with_features (vlib_main_t * vm,
c->config_string_vector = config_string;
/* Allocate copy of config string in heap.
- VLIB buffers will maintain pointers to heap as they read out
- configuration data. */
+ VLIB buffers will maintain pointers to heap as they read out
+ configuration data. */
c->config_string_heap_index
= heap_alloc (cm->config_string_heap, vec_len (config_string) + 1,
c->config_string_heap_handle);
/* First element in heap points back to pool index. */
- d = vec_elt_at_index (cm->config_string_heap, c->config_string_heap_index);
+ d =
+ vec_elt_at_index (cm->config_string_heap,
+ c->config_string_heap_index);
d[0] = c->index;
clib_memcpy (d + 1, config_string, vec_bytes (config_string));
hash_set_mem (cm->config_string_hash, config_string, c->index);
- c->reference_count = 0; /* will be incremented by caller. */
+ c->reference_count = 0; /* will be incremented by caller. */
}
return c;
}
-void vnet_config_init (vlib_main_t * vm,
- vnet_config_main_t * cm,
- char * start_node_names[],
- int n_start_node_names,
- char * feature_node_names[],
- int n_feature_node_names)
+void
+vnet_config_init (vlib_main_t * vm,
+ vnet_config_main_t * cm,
+ char *start_node_names[],
+ int n_start_node_names,
+ char *feature_node_names[], int n_feature_node_names)
{
- vlib_node_t * n;
+ vlib_node_t *n;
u32 i;
memset (cm, 0, sizeof (cm[0]));
- cm->config_string_hash = hash_create_vec (0, STRUCT_SIZE_OF (vnet_config_t, config_string_vector[0]), sizeof (uword));
+ cm->config_string_hash =
+ hash_create_vec (0,
+ STRUCT_SIZE_OF (vnet_config_t, config_string_vector[0]),
+ sizeof (uword));
ASSERT (n_start_node_names >= 1);
ASSERT (n_feature_node_names >= 1);
@@ -187,7 +189,7 @@ void vnet_config_init (vlib_main_t * vm,
vec_resize (cm->node_index_by_feature_index, n_feature_node_names);
for (i = 0; i < n_feature_node_names; i++)
{
- if (! feature_node_names[i])
+ if (!feature_node_names[i])
cm->node_index_by_feature_index[i] = ~0;
else
{
@@ -198,8 +200,9 @@ void vnet_config_init (vlib_main_t * vm,
if (i + 1 == n_feature_node_names)
cm->end_node_index = n->index;
cm->node_index_by_feature_index[i] = n->index;
- }
- else cm->node_index_by_feature_index[i] = ~0;
+ }
+ else
+ cm->node_index_by_feature_index[i] = ~0;
}
}
}
@@ -218,32 +221,34 @@ remove_reference (vnet_config_main_t * cm, vnet_config_t * c)
}
static int
-feature_cmp (void * a1, void * a2)
+feature_cmp (void *a1, void *a2)
{
- vnet_config_feature_t * f1 = a1;
- vnet_config_feature_t * f2 = a2;
+ vnet_config_feature_t *f1 = a1;
+ vnet_config_feature_t *f2 = a2;
return (int) f1->feature_index - f2->feature_index;
}
always_inline u32 *
vnet_get_config_heap (vnet_config_main_t * cm, u32 ci)
-{ return heap_elt_at_index (cm->config_string_heap, ci); }
-
-u32 vnet_config_add_feature (vlib_main_t * vm,
- vnet_config_main_t * cm,
- u32 config_string_heap_index,
- u32 feature_index,
- void * feature_config,
- u32 n_feature_config_bytes)
{
- vnet_config_t * old, * new;
- vnet_config_feature_t * new_features, * f;
+ return heap_elt_at_index (cm->config_string_heap, ci);
+}
+
+u32
+vnet_config_add_feature (vlib_main_t * vm,
+ vnet_config_main_t * cm,
+ u32 config_string_heap_index,
+ u32 feature_index,
+ void *feature_config, u32 n_feature_config_bytes)
+{
+ vnet_config_t *old, *new;
+ vnet_config_feature_t *new_features, *f;
u32 n_feature_config_u32s;
u32 node_index = vec_elt (cm->node_index_by_feature_index, feature_index);
- if (node_index == ~0) // feature node does not exist
- return config_string_heap_index; // return original config index
+ if (node_index == ~0) // feature node does not exist
+ return config_string_heap_index; // return original config index
if (config_string_heap_index == ~0)
{
@@ -252,7 +257,7 @@ u32 vnet_config_add_feature (vlib_main_t * vm,
}
else
{
- u32 * p = vnet_get_config_heap (cm, config_string_heap_index);
+ u32 *p = vnet_get_config_heap (cm, config_string_heap_index);
old = pool_elt_at_index (cm->config_pool, p[-1]);
new_features = old->features;
if (new_features)
@@ -263,9 +268,12 @@ u32 vnet_config_add_feature (vlib_main_t * vm,
f->feature_index = feature_index;
f->node_index = node_index;
- n_feature_config_u32s = round_pow2 (n_feature_config_bytes, sizeof (f->feature_config[0])) / sizeof (f->feature_config[0]);
+ n_feature_config_u32s =
+ round_pow2 (n_feature_config_bytes,
+ sizeof (f->feature_config[0])) /
+ sizeof (f->feature_config[0]);
vec_add (f->feature_config, feature_config, n_feature_config_u32s);
-
+
/* Sort (prioritize) features. */
if (vec_len (new_features) > 1)
vec_sort_with_function (new_features, feature_cmp);
@@ -276,50 +284,54 @@ u32 vnet_config_add_feature (vlib_main_t * vm,
new = find_config_with_features (vm, cm, new_features);
new->reference_count += 1;
- /*
- * User gets pointer to config string first element
+ /*
+ * User gets pointer to config string first element
* (which defines the pool index
- * this config string comes from).
+ * this config string comes from).
*/
vec_validate (cm->config_pool_index_by_user_index,
- new->config_string_heap_index + 1);
- cm->config_pool_index_by_user_index [new->config_string_heap_index + 1]
- = new - cm->config_pool;
+ new->config_string_heap_index + 1);
+ cm->config_pool_index_by_user_index[new->config_string_heap_index + 1]
+ = new - cm->config_pool;
return new->config_string_heap_index + 1;
}
-u32 vnet_config_del_feature (vlib_main_t * vm,
- vnet_config_main_t * cm,
- u32 config_string_heap_index,
- u32 feature_index,
- void * feature_config,
- u32 n_feature_config_bytes)
+u32
+vnet_config_del_feature (vlib_main_t * vm,
+ vnet_config_main_t * cm,
+ u32 config_string_heap_index,
+ u32 feature_index,
+ void *feature_config, u32 n_feature_config_bytes)
{
- vnet_config_t * old, * new;
- vnet_config_feature_t * new_features, * f;
+ vnet_config_t *old, *new;
+ vnet_config_feature_t *new_features, *f;
u32 n_feature_config_u32s;
{
- u32 * p = vnet_get_config_heap (cm, config_string_heap_index);
+ u32 *p = vnet_get_config_heap (cm, config_string_heap_index);
old = pool_elt_at_index (cm->config_pool, p[-1]);
}
- n_feature_config_u32s = round_pow2 (n_feature_config_bytes, sizeof (f->feature_config[0])) / sizeof (f->feature_config[0]);
+ n_feature_config_u32s =
+ round_pow2 (n_feature_config_bytes,
+ sizeof (f->feature_config[0])) /
+ sizeof (f->feature_config[0]);
/* Find feature with same index and opaque data. */
vec_foreach (f, old->features)
- {
- if (f->feature_index == feature_index
- && vec_len (f->feature_config) == n_feature_config_u32s
- && (n_feature_config_u32s == 0
- || ! memcmp (f->feature_config, feature_config, n_feature_config_bytes)))
- break;
- }
+ {
+ if (f->feature_index == feature_index
+ && vec_len (f->feature_config) == n_feature_config_u32s
+ && (n_feature_config_u32s == 0
+ || !memcmp (f->feature_config, feature_config,
+ n_feature_config_bytes)))
+ break;
+ }
/* Feature not found. */
if (f >= vec_end (old->features))
- return config_string_heap_index; // return original config index
+ return config_string_heap_index; // return original config index
new_features = duplicate_feature_vector (old->features);
f = new_features + (f - old->features);
@@ -327,7 +339,7 @@ u32 vnet_config_del_feature (vlib_main_t * vm,
vec_delete (new_features, 1, f - new_features);
/* must remove old from config_pool now as it may be expanded and change
- memory location if the following function find_config_with_features()
+ memory location if the following function find_config_with_features()
adds a new config because none of existing config's has matching features
and so can be reused */
remove_reference (cm, old);
@@ -335,8 +347,16 @@ u32 vnet_config_del_feature (vlib_main_t * vm,
new->reference_count += 1;
vec_validate (cm->config_pool_index_by_user_index,
- new->config_string_heap_index + 1);
- cm->config_pool_index_by_user_index [new->config_string_heap_index + 1]
- = new - cm->config_pool;
+ new->config_string_heap_index + 1);
+ cm->config_pool_index_by_user_index[new->config_string_heap_index + 1]
+ = new - cm->config_pool;
return new->config_string_heap_index + 1;
}
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/config.h b/vnet/vnet/config.h
index 3d507c7bf34..d80ff19ec28 100644
--- a/vnet/vnet/config.h
+++ b/vnet/vnet/config.h
@@ -43,7 +43,8 @@
#include <vlib/vlib.h>
#include <vppinfra/heap.h>
-typedef struct {
+typedef struct
+{
/* Features are prioritized by index. Smaller indices get
performed first. */
u32 feature_index;
@@ -55,19 +56,22 @@ typedef struct {
u32 next_index;
/* Opaque per feature configuration data. */
- u32 * feature_config;
+ u32 *feature_config;
} vnet_config_feature_t;
always_inline void
vnet_config_feature_free (vnet_config_feature_t * f)
-{ vec_free (f->feature_config); }
+{
+ vec_free (f->feature_config);
+}
-typedef struct {
+typedef struct
+{
/* Sorted vector of features for this configuration. */
- vnet_config_feature_t * features;
+ vnet_config_feature_t *features;
/* Config string as vector for hashing. */
- u32 * config_string_vector;
+ u32 *config_string_vector;
/* Config string including all next indices and feature data as a vector. */
u32 config_string_heap_index, config_string_heap_handle;
@@ -79,36 +83,36 @@ typedef struct {
u32 reference_count;
} vnet_config_t;
-typedef struct {
+typedef struct
+{
/* Pool of configs. Index 0 is always null config and is never deleted. */
- vnet_config_t * config_pool;
+ vnet_config_t *config_pool;
/* Hash table mapping vector config string to config pool index. */
- uword * config_string_hash;
+ uword *config_string_hash;
- /* Global heap of configuration data. */
- u32 * config_string_heap;
+ /* Global heap of configuration data. */
+ u32 *config_string_heap;
/* Node index which starts/ends feature processing. */
- u32 * start_node_indices, end_node_index;
+ u32 *start_node_indices, end_node_index;
/* Interior feature processing nodes (not including start and end nodes). */
- u32 * node_index_by_feature_index;
+ u32 *node_index_by_feature_index;
/* vnet_config pool index by user index */
- u32 * config_pool_index_by_user_index;
+ u32 *config_pool_index_by_user_index;
/* Temporary vector for holding config strings. Used to avoid continually
allocating vectors. */
- u32 * config_string_temp;
+ u32 *config_string_temp;
} vnet_config_main_t;
always_inline void
vnet_config_free (vnet_config_main_t * cm, vnet_config_t * c)
{
- vnet_config_feature_t * f;
- vec_foreach (f, c->features)
- vnet_config_feature_free (f);
+ vnet_config_feature_t *f;
+ vec_foreach (f, c->features) vnet_config_feature_free (f);
vec_free (c->features);
heap_dealloc (cm->config_string_heap, c->config_string_heap_handle);
vec_free (c->config_string_vector);
@@ -116,11 +120,9 @@ vnet_config_free (vnet_config_main_t * cm, vnet_config_t * c)
always_inline void *
vnet_get_config_data (vnet_config_main_t * cm,
- u32 * config_index,
- u32 * next_index,
- u32 n_data_bytes)
+ u32 * config_index, u32 * next_index, u32 n_data_bytes)
{
- u32 i, n, * d;
+ u32 i, n, *d;
i = *config_index;
@@ -140,24 +142,31 @@ vnet_get_config_data (vnet_config_main_t * cm,
void vnet_config_init (vlib_main_t * vm,
vnet_config_main_t * cm,
- char * start_node_names[],
+ char *start_node_names[],
int n_start_node_names,
- char * feature_node_names[],
- int n_feature_node_names);
+ char *feature_node_names[], int n_feature_node_names);
/* Calls to add/delete features from configurations. */
u32 vnet_config_add_feature (vlib_main_t * vm,
vnet_config_main_t * cm,
u32 config_id,
u32 feature_index,
- void * feature_config,
+ void *feature_config,
u32 n_feature_config_bytes);
u32 vnet_config_del_feature (vlib_main_t * vm,
vnet_config_main_t * cm,
u32 config_id,
u32 feature_index,
- void * feature_config,
+ void *feature_config,
u32 n_feature_config_bytes);
#endif /* included_vnet_config_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/dpdk_replication.h b/vnet/vnet/dpdk_replication.h
index bf9bf99fba0..07a076c1c7f 100644
--- a/vnet/vnet/dpdk_replication.h
+++ b/vnet/vnet/dpdk_replication.h
@@ -3,12 +3,12 @@
#include <vnet/devices/dpdk/dpdk.h>
/*
- * vlib_dpdk_clone_buffer - clone a buffer
+ * vlib_dpdk_clone_buffer - clone a buffer
* for port mirroring, lawful intercept, etc.
* rte_pktmbuf_clone (...) requires that the forwarding path
* not touch any of the cloned data. The hope is that we'll
- * figure out how to relax that restriction.
- *
+ * figure out how to relax that restriction.
+ *
* For the moment, copy packet data.
*/
@@ -16,92 +16,100 @@ static inline vlib_buffer_t *
vlib_dpdk_clone_buffer (vlib_main_t * vm, vlib_buffer_t * b)
{
u32 new_buffers_needed = 1;
- unsigned socket_id = rte_socket_id();
+ unsigned socket_id = rte_socket_id ();
struct rte_mempool *rmp = vm->buffer_main->pktmbuf_pools[socket_id];
struct rte_mbuf *rte_mbufs[5];
- vlib_buffer_free_list_t * fl;
- vlib_buffer_t * rv;
- u8 * copy_src, * copy_dst;
+ vlib_buffer_free_list_t *fl;
+ vlib_buffer_t *rv;
+ u8 *copy_src, *copy_dst;
vlib_buffer_t *src_buf, *dst_buf;
fl = vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- if (PREDICT_FALSE(b->flags & VLIB_BUFFER_NEXT_PRESENT))
+ if (PREDICT_FALSE (b->flags & VLIB_BUFFER_NEXT_PRESENT))
{
vlib_buffer_t *tmp = b;
int i;
while (tmp->flags & VLIB_BUFFER_NEXT_PRESENT)
- {
- new_buffers_needed ++;
- tmp = vlib_get_buffer (vm, tmp->next_buffer);
- }
+ {
+ new_buffers_needed++;
+ tmp = vlib_get_buffer (vm, tmp->next_buffer);
+ }
/* Should never happen... */
- if (PREDICT_FALSE(new_buffers_needed > ARRAY_LEN(rte_mbufs)))
- {
- clib_warning ("need %d buffers", new_buffers_needed);
- return 0;
- }
-
- if (rte_mempool_get_bulk (rmp, (void **)rte_mbufs,
- new_buffers_needed) < 0)
- return 0;
+ if (PREDICT_FALSE (new_buffers_needed > ARRAY_LEN (rte_mbufs)))
+ {
+ clib_warning ("need %d buffers", new_buffers_needed);
+ return 0;
+ }
+
+ if (rte_mempool_get_bulk (rmp, (void **) rte_mbufs,
+ new_buffers_needed) < 0)
+ return 0;
src_buf = b;
- rv = dst_buf = vlib_buffer_from_rte_mbuf(rte_mbufs[0]);
+ rv = dst_buf = vlib_buffer_from_rte_mbuf (rte_mbufs[0]);
vlib_buffer_init_for_free_list (dst_buf, fl);
copy_src = b->data + src_buf->current_data;
copy_dst = dst_buf->data + src_buf->current_data;
for (i = 0; i < new_buffers_needed; i++)
- {
- clib_memcpy (copy_src, copy_dst, src_buf->current_length);
- dst_buf->current_data = src_buf->current_data;
- dst_buf->current_length = src_buf->current_length;
- dst_buf->flags = src_buf->flags;
-
- if (i == 0)
- {
- dst_buf->total_length_not_including_first_buffer =
- src_buf->total_length_not_including_first_buffer;
- vnet_buffer(dst_buf)->sw_if_index[VLIB_RX] =
- vnet_buffer(src_buf)->sw_if_index[VLIB_RX];
- vnet_buffer(dst_buf)->sw_if_index[VLIB_TX] =
- vnet_buffer(src_buf)->sw_if_index[VLIB_TX];
- vnet_buffer(dst_buf)->l2 = vnet_buffer(b)->l2;
- }
-
- if (i < new_buffers_needed - 1)
- {
- src_buf = vlib_get_buffer (vm, src_buf->next_buffer);
- dst_buf = vlib_buffer_from_rte_mbuf(rte_mbufs[i+1]);
- vlib_buffer_init_for_free_list (dst_buf, fl);
- copy_src = src_buf->data;
- copy_dst = dst_buf->data;
- }
- }
+ {
+ clib_memcpy (copy_src, copy_dst, src_buf->current_length);
+ dst_buf->current_data = src_buf->current_data;
+ dst_buf->current_length = src_buf->current_length;
+ dst_buf->flags = src_buf->flags;
+
+ if (i == 0)
+ {
+ dst_buf->total_length_not_including_first_buffer =
+ src_buf->total_length_not_including_first_buffer;
+ vnet_buffer (dst_buf)->sw_if_index[VLIB_RX] =
+ vnet_buffer (src_buf)->sw_if_index[VLIB_RX];
+ vnet_buffer (dst_buf)->sw_if_index[VLIB_TX] =
+ vnet_buffer (src_buf)->sw_if_index[VLIB_TX];
+ vnet_buffer (dst_buf)->l2 = vnet_buffer (b)->l2;
+ }
+
+ if (i < new_buffers_needed - 1)
+ {
+ src_buf = vlib_get_buffer (vm, src_buf->next_buffer);
+ dst_buf = vlib_buffer_from_rte_mbuf (rte_mbufs[i + 1]);
+ vlib_buffer_init_for_free_list (dst_buf, fl);
+ copy_src = src_buf->data;
+ copy_dst = dst_buf->data;
+ }
+ }
return rv;
}
- if (rte_mempool_get_bulk (rmp, (void **)rte_mbufs, 1) < 0)
+ if (rte_mempool_get_bulk (rmp, (void **) rte_mbufs, 1) < 0)
return 0;
- rv = vlib_buffer_from_rte_mbuf(rte_mbufs[0]);
+ rv = vlib_buffer_from_rte_mbuf (rte_mbufs[0]);
vlib_buffer_init_for_free_list (rv, fl);
- clib_memcpy(rv->data + b->current_data, b->data + b->current_data,
- b->current_length);
+ clib_memcpy (rv->data + b->current_data, b->data + b->current_data,
+ b->current_length);
rv->current_data = b->current_data;
rv->current_length = b->current_length;
- vnet_buffer(rv)->sw_if_index[VLIB_RX] =
- vnet_buffer(b)->sw_if_index[VLIB_RX];
- vnet_buffer(rv)->sw_if_index[VLIB_TX] =
- vnet_buffer(b)->sw_if_index[VLIB_TX];
- vnet_buffer(rv)->l2 = vnet_buffer(b)->l2;
+ vnet_buffer (rv)->sw_if_index[VLIB_RX] =
+ vnet_buffer (b)->sw_if_index[VLIB_RX];
+ vnet_buffer (rv)->sw_if_index[VLIB_TX] =
+ vnet_buffer (b)->sw_if_index[VLIB_TX];
+ vnet_buffer (rv)->l2 = vnet_buffer (b)->l2;
return (rv);
}
#endif /* __included_dpdk_replication_h__ */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/global_funcs.h b/vnet/vnet/global_funcs.h
index 3958d88fc1e..92a5c04de1f 100644
--- a/vnet/vnet/global_funcs.h
+++ b/vnet/vnet/global_funcs.h
@@ -19,6 +19,14 @@
#ifndef included_vnet_global_funcs_h_
#define included_vnet_global_funcs_h_
-vnet_main_t * vnet_get_main (void);
+vnet_main_t *vnet_get_main (void);
#endif /* included_vnet_global_funcs_h_ */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/handoff.c b/vnet/vnet/handoff.c
index 28968c9020a..67fc6417414 100644
--- a/vnet/vnet/handoff.c
+++ b/vnet/vnet/handoff.c
@@ -19,40 +19,45 @@
#include <vlib/threads.h>
#include <vnet/handoff.h>
-typedef struct {
- uword * workers_bitmap;
- u32 * workers;
+typedef struct
+{
+ uword *workers_bitmap;
+ u32 *workers;
} per_inteface_handoff_data_t;
-typedef struct {
+typedef struct
+{
u32 cached_next_index;
u32 num_workers;
u32 first_worker_index;
- per_inteface_handoff_data_t * if_data;
+ per_inteface_handoff_data_t *if_data;
/* convenience variables */
- vlib_main_t * vlib_main;
- vnet_main_t * vnet_main;
+ vlib_main_t *vlib_main;
+ vnet_main_t *vnet_main;
} handoff_main_t;
handoff_main_t handoff_main;
-typedef struct {
+typedef struct
+{
u32 sw_if_index;
u32 next_worker_index;
u32 buffer_index;
} worker_handoff_trace_t;
/* packet trace format function */
-static u8 * format_worker_handoff_trace (u8 * s, va_list * args)
+static u8 *
+format_worker_handoff_trace (u8 * s, va_list * args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- worker_handoff_trace_t * t = va_arg (*args, worker_handoff_trace_t *);
+ worker_handoff_trace_t *t = va_arg (*args, worker_handoff_trace_t *);
- s = format (s, "worker-handoff: sw_if_index %d, next_worker %d, buffer 0x%x",
- t->sw_if_index, t->next_worker_index, t->buffer_index);
+ s =
+ format (s, "worker-handoff: sw_if_index %d, next_worker %d, buffer 0x%x",
+ t->sw_if_index, t->next_worker_index, t->buffer_index);
return s;
}
@@ -60,27 +65,27 @@ vlib_node_registration_t handoff_node;
static uword
worker_handoff_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+ vlib_node_runtime_t * node, vlib_frame_t * frame)
{
- handoff_main_t * hm = &handoff_main;
- vlib_thread_main_t * tm = vlib_get_thread_main();
- u32 n_left_from, * from;
- static __thread vlib_frame_queue_elt_t ** handoff_queue_elt_by_worker_index;
- static __thread vlib_frame_queue_t ** congested_handoff_queue_by_worker_index = 0;
- vlib_frame_queue_elt_t * hf = 0;
+ handoff_main_t *hm = &handoff_main;
+ vlib_thread_main_t *tm = vlib_get_thread_main ();
+ u32 n_left_from, *from;
+ static __thread vlib_frame_queue_elt_t **handoff_queue_elt_by_worker_index;
+ static __thread vlib_frame_queue_t **congested_handoff_queue_by_worker_index
+ = 0;
+ vlib_frame_queue_elt_t *hf = 0;
int i;
- u32 n_left_to_next_worker = 0, * to_next_worker = 0;
+ u32 n_left_to_next_worker = 0, *to_next_worker = 0;
u32 next_worker_index = 0;
u32 current_worker_index = ~0;
- if (PREDICT_FALSE(handoff_queue_elt_by_worker_index == 0))
+ if (PREDICT_FALSE (handoff_queue_elt_by_worker_index == 0))
{
vec_validate (handoff_queue_elt_by_worker_index, tm->n_vlib_mains - 1);
vec_validate_init_empty (congested_handoff_queue_by_worker_index,
- hm->first_worker_index + hm->num_workers - 1,
- (vlib_frame_queue_t *)(~0));
+ hm->first_worker_index + hm->num_workers - 1,
+ (vlib_frame_queue_t *) (~0));
}
from = vlib_frame_vector_args (frame);
@@ -89,11 +94,11 @@ worker_handoff_node_fn (vlib_main_t * vm,
while (n_left_from > 0)
{
u32 bi0;
- vlib_buffer_t * b0;
+ vlib_buffer_t *b0;
u32 sw_if_index0;
u32 hash;
u64 hash_key;
- per_inteface_handoff_data_t * ihd0;
+ per_inteface_handoff_data_t *ihd0;
u32 index0;
bi0 = from[0];
@@ -101,7 +106,7 @@ worker_handoff_node_fn (vlib_main_t * vm,
n_left_from -= 1;
b0 = vlib_get_buffer (vm, bi0);
- sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX];
+ sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
ASSERT (hm->if_data);
ihd0 = vec_elt_at_index (hm->if_data, sw_if_index0);
@@ -117,13 +122,17 @@ worker_handoff_node_fn (vlib_main_t * vm,
hash = (u32) clib_xxhash (hash_key);
/* if input node did not specify next index, then packet
- should go to eternet-input */
+ should go to eternet-input */
if (PREDICT_FALSE ((b0->flags & BUFFER_HANDOFF_NEXT_VALID) == 0))
- vnet_buffer(b0)->handoff.next_index = HANDOFF_DISPATCH_NEXT_ETHERNET_INPUT;
- else if (vnet_buffer(b0)->handoff.next_index == HANDOFF_DISPATCH_NEXT_IP4_INPUT ||
- vnet_buffer(b0)->handoff.next_index == HANDOFF_DISPATCH_NEXT_IP6_INPUT ||
- vnet_buffer(b0)->handoff.next_index == HANDOFF_DISPATCH_NEXT_MPLS_INPUT)
- vlib_buffer_advance (b0, (sizeof(ethernet_header_t)));
+ vnet_buffer (b0)->handoff.next_index =
+ HANDOFF_DISPATCH_NEXT_ETHERNET_INPUT;
+ else if (vnet_buffer (b0)->handoff.next_index ==
+ HANDOFF_DISPATCH_NEXT_IP4_INPUT
+ || vnet_buffer (b0)->handoff.next_index ==
+ HANDOFF_DISPATCH_NEXT_IP6_INPUT
+ || vnet_buffer (b0)->handoff.next_index ==
+ HANDOFF_DISPATCH_NEXT_MPLS_INPUT)
+ vlib_buffer_advance (b0, (sizeof (ethernet_header_t)));
if (PREDICT_TRUE (is_pow2 (vec_len (ihd0->workers))))
index0 = hash & (vec_len (ihd0->workers) - 1);
@@ -137,8 +146,8 @@ worker_handoff_node_fn (vlib_main_t * vm,
if (hf)
hf->n_vectors = VLIB_FRAME_SIZE - n_left_to_next_worker;
- hf = dpdk_get_handoff_queue_elt(next_worker_index,
- handoff_queue_elt_by_worker_index);
+ hf = dpdk_get_handoff_queue_elt (next_worker_index,
+ handoff_queue_elt_by_worker_index);
n_left_to_next_worker = VLIB_FRAME_SIZE - hf->n_vectors;
to_next_worker = &hf->buffer_index[hf->n_vectors];
@@ -153,17 +162,17 @@ worker_handoff_node_fn (vlib_main_t * vm,
if (n_left_to_next_worker == 0)
{
hf->n_vectors = VLIB_FRAME_SIZE;
- vlib_put_handoff_queue_elt(hf);
+ vlib_put_handoff_queue_elt (hf);
current_worker_index = ~0;
handoff_queue_elt_by_worker_index[next_worker_index] = 0;
hf = 0;
}
- if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE)
- && (b0->flags & VLIB_BUFFER_IS_TRACED)))
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
+ && (b0->flags & VLIB_BUFFER_IS_TRACED)))
{
worker_handoff_trace_t *t =
- vlib_add_trace (vm, node, b0, sizeof (*t));
+ vlib_add_trace (vm, node, b0, sizeof (*t));
t->sw_if_index = sw_if_index0;
t->next_worker_index = next_worker_index - hm->first_worker_index;
t->buffer_index = bi0;
@@ -178,27 +187,29 @@ worker_handoff_node_fn (vlib_main_t * vm,
for (i = 0; i < vec_len (handoff_queue_elt_by_worker_index); i++)
{
if (handoff_queue_elt_by_worker_index[i])
- {
- hf = handoff_queue_elt_by_worker_index[i];
- /*
- * It works better to let the handoff node
- * rate-adapt, always ship the handoff queue element.
- */
- if (1 || hf->n_vectors == hf->last_n_vectors)
- {
- vlib_put_handoff_queue_elt(hf);
- handoff_queue_elt_by_worker_index[i] = 0;
- }
- else
- hf->last_n_vectors = hf->n_vectors;
- }
- congested_handoff_queue_by_worker_index[i] = (vlib_frame_queue_t *)(~0);
+ {
+ hf = handoff_queue_elt_by_worker_index[i];
+ /*
+ * It works better to let the handoff node
+ * rate-adapt, always ship the handoff queue element.
+ */
+ if (1 || hf->n_vectors == hf->last_n_vectors)
+ {
+ vlib_put_handoff_queue_elt (hf);
+ handoff_queue_elt_by_worker_index[i] = 0;
+ }
+ else
+ hf->last_n_vectors = hf->n_vectors;
+ }
+ congested_handoff_queue_by_worker_index[i] =
+ (vlib_frame_queue_t *) (~0);
}
hf = 0;
current_worker_index = ~0;
return frame->n_vectors;
}
+/* *INDENT-OFF* */
VLIB_REGISTER_NODE (worker_handoff_node) = {
.function = worker_handoff_node_fn,
.name = "worker-handoff",
@@ -208,35 +219,34 @@ VLIB_REGISTER_NODE (worker_handoff_node) = {
.n_next_nodes = 1,
.next_nodes = {
- [0] = "error-drop",
+ [0] = "error-drop",
},
};
+/* *INDENT-ON* */
VLIB_NODE_FUNCTION_MULTIARCH (worker_handoff_node, worker_handoff_node_fn)
-
-int interface_handoff_enable_disable (vlib_main_t * vm, u32 sw_if_index,
- uword * bitmap, int enable_disable)
+ int interface_handoff_enable_disable (vlib_main_t * vm, u32 sw_if_index,
+ uword * bitmap, int enable_disable)
{
- handoff_main_t * hm = &handoff_main;
- vnet_sw_interface_t * sw;
- vnet_main_t * vnm = vnet_get_main();
- per_inteface_handoff_data_t * d;
+ handoff_main_t *hm = &handoff_main;
+ vnet_sw_interface_t *sw;
+ vnet_main_t *vnm = vnet_get_main ();
+ per_inteface_handoff_data_t *d;
int i, rv;
u32 node_index = enable_disable ? worker_handoff_node.index : ~0;
- if (pool_is_free_index (vnm->interface_main.sw_interfaces,
- sw_if_index))
+ if (pool_is_free_index (vnm->interface_main.sw_interfaces, sw_if_index))
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
sw = vnet_get_sw_interface (vnm, sw_if_index);
if (sw->type != VNET_SW_INTERFACE_TYPE_HARDWARE)
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
- if (clib_bitmap_last_set(bitmap) >= hm->num_workers)
+ if (clib_bitmap_last_set (bitmap) >= hm->num_workers)
return VNET_API_ERROR_INVALID_WORKER;
vec_validate (hm->if_data, sw_if_index);
- d = vec_elt_at_index(hm->if_data, sw_if_index);
+ d = vec_elt_at_index (hm->if_data, sw_if_index);
vec_free (d->workers);
vec_free (d->workers_bitmap);
@@ -244,10 +254,12 @@ int interface_handoff_enable_disable (vlib_main_t * vm, u32 sw_if_index,
if (enable_disable)
{
d->workers_bitmap = bitmap;
+ /* *INDENT-OFF* */
clib_bitmap_foreach (i, bitmap,
({
vec_add1(d->workers, i);
}));
+ /* *INDENT-ON* */
}
rv = vnet_hw_interface_rx_redirect_to_node (vnm, sw_if_index, node_index);
@@ -256,27 +268,27 @@ int interface_handoff_enable_disable (vlib_main_t * vm, u32 sw_if_index,
static clib_error_t *
set_interface_handoff_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
{
u32 sw_if_index = ~0;
int enable_disable = 1;
- uword * bitmap = 0;
+ uword *bitmap = 0;
int rv = 0;
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
- if (unformat (input, "disable"))
- enable_disable = 0;
- else if (unformat (input, "workers %U", unformat_bitmap_list,
- &bitmap))
- ;
- else if (unformat (input, "%U", unformat_vnet_sw_interface,
- vnet_get_main(), &sw_if_index))
- ;
- else
- break;
- }
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "disable"))
+ enable_disable = 0;
+ else if (unformat (input, "workers %U", unformat_bitmap_list, &bitmap))
+ ;
+ else if (unformat (input, "%U", unformat_vnet_sw_interface,
+ vnet_get_main (), &sw_if_index))
+ ;
+ else
+ break;
+ }
if (sw_if_index == ~0)
return clib_error_return (0, "Please specify an interface...");
@@ -284,9 +296,12 @@ set_interface_handoff_command_fn (vlib_main_t * vm,
if (bitmap == 0)
return clib_error_return (0, "Please specify list of workers...");
- rv = interface_handoff_enable_disable (vm, sw_if_index, bitmap, enable_disable);
+ rv =
+ interface_handoff_enable_disable (vm, sw_if_index, bitmap,
+ enable_disable);
- switch(rv) {
+ switch (rv)
+ {
case 0:
break;
@@ -299,39 +314,42 @@ set_interface_handoff_command_fn (vlib_main_t * vm,
break;
case VNET_API_ERROR_UNIMPLEMENTED:
- return clib_error_return (0, "Device driver doesn't support redirection");
+ return clib_error_return (0,
+ "Device driver doesn't support redirection");
break;
default:
return clib_error_return (0, "unknown return value %d", rv);
- }
+ }
return 0;
}
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (set_interface_handoff_command, static) = {
- .path = "set interface handoff",
- .short_help =
- "set interface handoff <interface-name> workers <workers-list>",
- .function = set_interface_handoff_command_fn,
+ .path = "set interface handoff",
+ .short_help =
+ "set interface handoff <interface-name> workers <workers-list>",
+ .function = set_interface_handoff_command_fn,
};
+/* *INDENT-ON* */
-typedef struct {
+typedef struct
+{
u32 buffer_index;
u32 next_index;
u32 sw_if_index;
} handoff_dispatch_trace_t;
/* packet trace format function */
-static u8 * format_handoff_dispatch_trace (u8 * s, va_list * args)
+static u8 *
+format_handoff_dispatch_trace (u8 * s, va_list * args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- handoff_dispatch_trace_t * t = va_arg (*args, handoff_dispatch_trace_t *);
+ handoff_dispatch_trace_t *t = va_arg (*args, handoff_dispatch_trace_t *);
s = format (s, "handoff-dispatch: sw_if_index %d next_index %d buffer 0x%x",
- t->sw_if_index,
- t->next_index,
- t->buffer_index);
+ t->sw_if_index, t->next_index, t->buffer_index);
return s;
}
@@ -341,14 +359,15 @@ vlib_node_registration_t handoff_dispatch_node;
#define foreach_handoff_dispatch_error \
_(EXAMPLE, "example packets")
-typedef enum {
+typedef enum
+{
#define _(sym,str) HANDOFF_DISPATCH_ERROR_##sym,
foreach_handoff_dispatch_error
#undef _
- HANDOFF_DISPATCH_N_ERROR,
+ HANDOFF_DISPATCH_N_ERROR,
} handoff_dispatch_error_t;
-static char * handoff_dispatch_error_strings[] = {
+static char *handoff_dispatch_error_strings[] = {
#define _(sym,string) string,
foreach_handoff_dispatch_error
#undef _
@@ -356,10 +375,9 @@ static char * handoff_dispatch_error_strings[] = {
static uword
handoff_dispatch_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+ vlib_node_runtime_t * node, vlib_frame_t * frame)
{
- u32 n_left_from, * from, * to_next;
+ u32 n_left_from, *from, *to_next;
handoff_dispatch_next_t next_index;
from = vlib_frame_vector_args (frame);
@@ -370,19 +388,18 @@ handoff_dispatch_node_fn (vlib_main_t * vm,
{
u32 n_left_to_next;
- vlib_get_next_frame (vm, node, next_index,
- to_next, n_left_to_next);
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
while (n_left_from >= 4 && n_left_to_next >= 2)
{
- u32 bi0, bi1;
- vlib_buffer_t * b0, * b1;
- u32 next0, next1;
- u32 sw_if_index0, sw_if_index1;
+ u32 bi0, bi1;
+ vlib_buffer_t *b0, *b1;
+ u32 next0, next1;
+ u32 sw_if_index0, sw_if_index1;
/* Prefetch next iteration. */
{
- vlib_buffer_t * p2, * p3;
+ vlib_buffer_t *p2, *p3;
p2 = vlib_get_buffer (vm, from[2]);
p3 = vlib_get_buffer (vm, from[3]);
@@ -391,7 +408,7 @@ handoff_dispatch_node_fn (vlib_main_t * vm,
vlib_prefetch_buffer_header (p3, LOAD);
}
- /* speculatively enqueue b0 and b1 to the current next frame */
+ /* speculatively enqueue b0 and b1 to the current next frame */
to_next[0] = bi0 = from[0];
to_next[1] = bi1 = from[1];
from += 2;
@@ -402,47 +419,49 @@ handoff_dispatch_node_fn (vlib_main_t * vm,
b0 = vlib_get_buffer (vm, bi0);
b1 = vlib_get_buffer (vm, bi1);
- next0 = vnet_buffer(b0)->handoff.next_index;
- next1 = vnet_buffer(b1)->handoff.next_index;
-
- if (PREDICT_FALSE(vm->trace_main.trace_active_hint))
- {
- if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
- {
- vlib_trace_buffer (vm, node, next0, b0, /* follow_chain */ 0);
- handoff_dispatch_trace_t *t =
- vlib_add_trace (vm, node, b0, sizeof (*t));
- sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX];
- t->sw_if_index = sw_if_index0;
- t->next_index = next0;
- t->buffer_index = bi0;
- }
- if (PREDICT_FALSE(b1->flags & VLIB_BUFFER_IS_TRACED))
- {
- vlib_trace_buffer (vm, node, next1, b1, /* follow_chain */ 0);
- handoff_dispatch_trace_t *t =
- vlib_add_trace (vm, node, b1, sizeof (*t));
- sw_if_index1 = vnet_buffer(b1)->sw_if_index[VLIB_RX];
- t->sw_if_index = sw_if_index1;
- t->next_index = next1;
- t->buffer_index = bi1;
- }
- }
-
- /* verify speculative enqueues, maybe switch current next frame */
- vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
- to_next, n_left_to_next,
- bi0, bi1, next0, next1);
- }
+ next0 = vnet_buffer (b0)->handoff.next_index;
+ next1 = vnet_buffer (b1)->handoff.next_index;
+
+ if (PREDICT_FALSE (vm->trace_main.trace_active_hint))
+ {
+ if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
+ {
+ vlib_trace_buffer (vm, node, next0, b0, /* follow_chain */
+ 0);
+ handoff_dispatch_trace_t *t =
+ vlib_add_trace (vm, node, b0, sizeof (*t));
+ sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
+ t->sw_if_index = sw_if_index0;
+ t->next_index = next0;
+ t->buffer_index = bi0;
+ }
+ if (PREDICT_FALSE (b1->flags & VLIB_BUFFER_IS_TRACED))
+ {
+ vlib_trace_buffer (vm, node, next1, b1, /* follow_chain */
+ 0);
+ handoff_dispatch_trace_t *t =
+ vlib_add_trace (vm, node, b1, sizeof (*t));
+ sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_RX];
+ t->sw_if_index = sw_if_index1;
+ t->next_index = next1;
+ t->buffer_index = bi1;
+ }
+ }
+
+ /* verify speculative enqueues, maybe switch current next frame */
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
+ to_next, n_left_to_next,
+ bi0, bi1, next0, next1);
+ }
while (n_left_from > 0 && n_left_to_next > 0)
{
- u32 bi0;
- vlib_buffer_t * b0;
- u32 next0;
- u32 sw_if_index0;
+ u32 bi0;
+ vlib_buffer_t *b0;
+ u32 next0;
+ u32 sw_if_index0;
- /* speculatively enqueue b0 to the current next frame */
+ /* speculatively enqueue b0 to the current next frame */
bi0 = from[0];
to_next[0] = bi0;
from += 1;
@@ -452,23 +471,24 @@ handoff_dispatch_node_fn (vlib_main_t * vm,
b0 = vlib_get_buffer (vm, bi0);
- next0 = vnet_buffer(b0)->handoff.next_index;
-
- if (PREDICT_FALSE(vm->trace_main.trace_active_hint))
- {
- if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
- {
- vlib_trace_buffer (vm, node, next0, b0, /* follow_chain */ 0);
- handoff_dispatch_trace_t *t =
- vlib_add_trace (vm, node, b0, sizeof (*t));
- sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX];
- t->sw_if_index = sw_if_index0;
- t->next_index = next0;
- t->buffer_index = bi0;
- }
- }
-
- /* verify speculative enqueue, maybe switch current next frame */
+ next0 = vnet_buffer (b0)->handoff.next_index;
+
+ if (PREDICT_FALSE (vm->trace_main.trace_active_hint))
+ {
+ if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
+ {
+ vlib_trace_buffer (vm, node, next0, b0, /* follow_chain */
+ 0);
+ handoff_dispatch_trace_t *t =
+ vlib_add_trace (vm, node, b0, sizeof (*t));
+ sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
+ t->sw_if_index = sw_if_index0;
+ t->next_index = next0;
+ t->buffer_index = bi0;
+ }
+ }
+
+ /* verify speculative enqueue, maybe switch current next frame */
vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
to_next, n_left_to_next,
bi0, next0);
@@ -480,6 +500,7 @@ handoff_dispatch_node_fn (vlib_main_t * vm,
return frame->n_vectors;
}
+/* *INDENT-OFF* */
VLIB_REGISTER_NODE (handoff_dispatch_node) = {
.function = handoff_dispatch_node_fn,
.name = "handoff-dispatch",
@@ -494,37 +515,37 @@ VLIB_REGISTER_NODE (handoff_dispatch_node) = {
.n_next_nodes = HANDOFF_DISPATCH_N_NEXT,
.next_nodes = {
- [HANDOFF_DISPATCH_NEXT_DROP] = "error-drop",
- [HANDOFF_DISPATCH_NEXT_ETHERNET_INPUT] = "ethernet-input",
- [HANDOFF_DISPATCH_NEXT_IP4_INPUT] = "ip4-input-no-checksum",
- [HANDOFF_DISPATCH_NEXT_IP6_INPUT] = "ip6-input",
- [HANDOFF_DISPATCH_NEXT_MPLS_INPUT] = "mpls-gre-input",
+ [HANDOFF_DISPATCH_NEXT_DROP] = "error-drop",
+ [HANDOFF_DISPATCH_NEXT_ETHERNET_INPUT] = "ethernet-input",
+ [HANDOFF_DISPATCH_NEXT_IP4_INPUT] = "ip4-input-no-checksum",
+ [HANDOFF_DISPATCH_NEXT_IP6_INPUT] = "ip6-input",
+ [HANDOFF_DISPATCH_NEXT_MPLS_INPUT] = "mpls-gre-input",
},
};
+/* *INDENT-ON* */
VLIB_NODE_FUNCTION_MULTIARCH (handoff_dispatch_node, handoff_dispatch_node_fn)
-
-clib_error_t *handoff_init (vlib_main_t *vm)
+ clib_error_t *handoff_init (vlib_main_t * vm)
{
- handoff_main_t * hm = &handoff_main;
- vlib_thread_main_t * tm = vlib_get_thread_main();
- clib_error_t * error;
- uword * p;
+ handoff_main_t *hm = &handoff_main;
+ vlib_thread_main_t *tm = vlib_get_thread_main ();
+ clib_error_t *error;
+ uword *p;
if ((error = vlib_call_init_function (vm, threads_init)))
return error;
- vlib_thread_registration_t * tr;
+ vlib_thread_registration_t *tr;
/* Only the standard vnet worker threads are supported */
p = hash_get_mem (tm->thread_registrations_by_name, "workers");
if (p)
{
tr = (vlib_thread_registration_t *) p[0];
if (tr)
- {
- hm->num_workers = tr->count;
- hm->first_worker_index = tr->first_index;
- }
+ {
+ hm->num_workers = tr->count;
+ hm->first_worker_index = tr->first_index;
+ }
}
hm->vlib_main = vm;
@@ -537,3 +558,11 @@ clib_error_t *handoff_init (vlib_main_t *vm)
}
VLIB_INIT_FUNCTION (handoff_init);
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/handoff.h b/vnet/vnet/handoff.h
index e0938ebfb2e..00832635a5a 100644
--- a/vnet/vnet/handoff.h
+++ b/vnet/vnet/handoff.h
@@ -22,7 +22,8 @@
#include <vnet/ip/ip6_packet.h>
#include <vnet/mpls-gre/packet.h>
-typedef enum {
+typedef enum
+{
HANDOFF_DISPATCH_NEXT_IP4_INPUT,
HANDOFF_DISPATCH_NEXT_IP6_INPUT,
HANDOFF_DISPATCH_NEXT_MPLS_INPUT,
@@ -31,10 +32,10 @@ typedef enum {
HANDOFF_DISPATCH_N_NEXT,
} handoff_dispatch_next_t;
-static inline
-void vlib_put_handoff_queue_elt (vlib_frame_queue_elt_t * hf)
+static inline void
+vlib_put_handoff_queue_elt (vlib_frame_queue_elt_t * hf)
{
- CLIB_MEMORY_BARRIER();
+ CLIB_MEMORY_BARRIER ();
hf->valid = 1;
}
@@ -52,9 +53,9 @@ vlib_get_handoff_queue_elt (u32 vlib_worker_index)
/* Wait until a ring slot is available */
while (new_tail >= fq->head_hint + fq->nelts)
- vlib_worker_thread_barrier_check ();
+ vlib_worker_thread_barrier_check ();
- elt = fq->elts + (new_tail & (fq->nelts-1));
+ elt = fq->elts + (new_tail & (fq->nelts - 1));
/* this would be very bad... */
while (elt->valid)
@@ -67,28 +68,29 @@ vlib_get_handoff_queue_elt (u32 vlib_worker_index)
}
static inline vlib_frame_queue_t *
-is_vlib_handoff_queue_congested (
- u32 vlib_worker_index,
- u32 queue_hi_thresh,
- vlib_frame_queue_t ** handoff_queue_by_worker_index)
+is_vlib_handoff_queue_congested (u32 vlib_worker_index,
+ u32 queue_hi_thresh,
+ vlib_frame_queue_t **
+ handoff_queue_by_worker_index)
{
vlib_frame_queue_t *fq;
- fq = handoff_queue_by_worker_index [vlib_worker_index];
- if (fq != (vlib_frame_queue_t *)(~0))
- return fq;
+ fq = handoff_queue_by_worker_index[vlib_worker_index];
+ if (fq != (vlib_frame_queue_t *) (~0))
+ return fq;
fq = vlib_frame_queues[vlib_worker_index];
ASSERT (fq);
- if (PREDICT_FALSE(fq->tail >= (fq->head_hint + queue_hi_thresh))) {
- /* a valid entry in the array will indicate the queue has reached
- * the specified threshold and is congested
- */
- handoff_queue_by_worker_index [vlib_worker_index] = fq;
- fq->enqueue_full_events++;
- return fq;
- }
+ if (PREDICT_FALSE (fq->tail >= (fq->head_hint + queue_hi_thresh)))
+ {
+ /* a valid entry in the array will indicate the queue has reached
+ * the specified threshold and is congested
+ */
+ handoff_queue_by_worker_index[vlib_worker_index] = fq;
+ fq->enqueue_full_events++;
+ return fq;
+ }
return NULL;
}
@@ -96,133 +98,175 @@ is_vlib_handoff_queue_congested (
static inline vlib_frame_queue_elt_t *
dpdk_get_handoff_queue_elt (u32 vlib_worker_index,
vlib_frame_queue_elt_t **
- handoff_queue_elt_by_worker_index)
+ handoff_queue_elt_by_worker_index)
{
vlib_frame_queue_elt_t *elt;
- if (handoff_queue_elt_by_worker_index [vlib_worker_index])
- return handoff_queue_elt_by_worker_index [vlib_worker_index];
+ if (handoff_queue_elt_by_worker_index[vlib_worker_index])
+ return handoff_queue_elt_by_worker_index[vlib_worker_index];
elt = vlib_get_handoff_queue_elt (vlib_worker_index);
- handoff_queue_elt_by_worker_index [vlib_worker_index] = elt;
+ handoff_queue_elt_by_worker_index[vlib_worker_index] = elt;
return elt;
}
-static inline u64 ipv4_get_key (ip4_header_t *ip)
+static inline u64
+ipv4_get_key (ip4_header_t * ip)
{
- u64 hash_key;
+ u64 hash_key;
- hash_key = *((u64*)(&ip->address_pair)) ^ ip->protocol;
+ hash_key = *((u64 *) (&ip->address_pair)) ^ ip->protocol;
- return hash_key;
+ return hash_key;
}
-static inline u64 ipv6_get_key (ip6_header_t *ip)
+static inline u64
+ipv6_get_key (ip6_header_t * ip)
{
- u64 hash_key;
+ u64 hash_key;
- hash_key = ip->src_address.as_u64[0] ^
- rotate_left(ip->src_address.as_u64[1],13) ^
- rotate_left(ip->dst_address.as_u64[0],26) ^
- rotate_left(ip->dst_address.as_u64[1],39) ^
- ip->protocol;
+ hash_key = ip->src_address.as_u64[0] ^
+ rotate_left (ip->src_address.as_u64[1], 13) ^
+ rotate_left (ip->dst_address.as_u64[0], 26) ^
+ rotate_left (ip->dst_address.as_u64[1], 39) ^ ip->protocol;
- return hash_key;
+ return hash_key;
}
#define MPLS_BOTTOM_OF_STACK_BIT_MASK 0x00000100U
#define MPLS_LABEL_MASK 0xFFFFF000U
-static inline u64 mpls_get_key (mpls_unicast_header_t *m)
+static inline u64
+mpls_get_key (mpls_unicast_header_t * m)
{
- u64 hash_key;
- u8 ip_ver;
-
-
- /* find the bottom of the MPLS label stack. */
- if (PREDICT_TRUE(m->label_exp_s_ttl &
- clib_net_to_host_u32(MPLS_BOTTOM_OF_STACK_BIT_MASK))) {
- goto bottom_lbl_found;
- }
- m++;
-
- if (PREDICT_TRUE(m->label_exp_s_ttl &
- clib_net_to_host_u32(MPLS_BOTTOM_OF_STACK_BIT_MASK))) {
- goto bottom_lbl_found;
- }
- m++;
-
- if (m->label_exp_s_ttl & clib_net_to_host_u32(MPLS_BOTTOM_OF_STACK_BIT_MASK)) {
- goto bottom_lbl_found;
- }
- m++;
-
- if (m->label_exp_s_ttl & clib_net_to_host_u32(MPLS_BOTTOM_OF_STACK_BIT_MASK)) {
- goto bottom_lbl_found;
- }
- m++;
-
- if (m->label_exp_s_ttl & clib_net_to_host_u32(MPLS_BOTTOM_OF_STACK_BIT_MASK)) {
- goto bottom_lbl_found;
- }
-
- /* the bottom label was not found - use the last label */
- hash_key = m->label_exp_s_ttl & clib_net_to_host_u32(MPLS_LABEL_MASK);
-
- return hash_key;
+ u64 hash_key;
+ u8 ip_ver;
+
+
+ /* find the bottom of the MPLS label stack. */
+ if (PREDICT_TRUE (m->label_exp_s_ttl &
+ clib_net_to_host_u32 (MPLS_BOTTOM_OF_STACK_BIT_MASK)))
+ {
+ goto bottom_lbl_found;
+ }
+ m++;
+
+ if (PREDICT_TRUE (m->label_exp_s_ttl &
+ clib_net_to_host_u32 (MPLS_BOTTOM_OF_STACK_BIT_MASK)))
+ {
+ goto bottom_lbl_found;
+ }
+ m++;
+
+ if (m->label_exp_s_ttl &
+ clib_net_to_host_u32 (MPLS_BOTTOM_OF_STACK_BIT_MASK))
+ {
+ goto bottom_lbl_found;
+ }
+ m++;
+
+ if (m->label_exp_s_ttl &
+ clib_net_to_host_u32 (MPLS_BOTTOM_OF_STACK_BIT_MASK))
+ {
+ goto bottom_lbl_found;
+ }
+ m++;
+
+ if (m->label_exp_s_ttl &
+ clib_net_to_host_u32 (MPLS_BOTTOM_OF_STACK_BIT_MASK))
+ {
+ goto bottom_lbl_found;
+ }
+
+ /* the bottom label was not found - use the last label */
+ hash_key = m->label_exp_s_ttl & clib_net_to_host_u32 (MPLS_LABEL_MASK);
+
+ return hash_key;
bottom_lbl_found:
- m++;
- ip_ver = (*((u8 *)m) >> 4);
-
- /* find out if it is IPV4 or IPV6 header */
- if (PREDICT_TRUE(ip_ver == 4)) {
- hash_key = ipv4_get_key((ip4_header_t *)m);
- } else if (PREDICT_TRUE(ip_ver == 6)) {
- hash_key = ipv6_get_key((ip6_header_t *)m);
- } else {
- /* use the bottom label */
- hash_key = (m-1)->label_exp_s_ttl & clib_net_to_host_u32(MPLS_LABEL_MASK);
- }
-
- return hash_key;
+ m++;
+ ip_ver = (*((u8 *) m) >> 4);
+
+ /* find out if it is IPV4 or IPV6 header */
+ if (PREDICT_TRUE (ip_ver == 4))
+ {
+ hash_key = ipv4_get_key ((ip4_header_t *) m);
+ }
+ else if (PREDICT_TRUE (ip_ver == 6))
+ {
+ hash_key = ipv6_get_key ((ip6_header_t *) m);
+ }
+ else
+ {
+ /* use the bottom label */
+ hash_key =
+ (m - 1)->label_exp_s_ttl & clib_net_to_host_u32 (MPLS_LABEL_MASK);
+ }
+
+ return hash_key;
}
static inline u64
-eth_get_key (ethernet_header_t *h0)
+eth_get_key (ethernet_header_t * h0)
{
- u64 hash_key;
-
- if (PREDICT_TRUE(h0->type) == clib_host_to_net_u16(ETHERNET_TYPE_IP4)) {
- hash_key = ipv4_get_key((ip4_header_t *)(h0+1));
- } else if (h0->type == clib_host_to_net_u16(ETHERNET_TYPE_IP6)) {
- hash_key = ipv6_get_key((ip6_header_t *)(h0+1));
- } else if (h0->type == clib_host_to_net_u16(ETHERNET_TYPE_MPLS_UNICAST)) {
- hash_key = mpls_get_key((mpls_unicast_header_t *)(h0+1));
- } else if ((h0->type == clib_host_to_net_u16(ETHERNET_TYPE_VLAN)) ||
- (h0->type == clib_host_to_net_u16(ETHERNET_TYPE_DOT1AD))) {
- ethernet_vlan_header_t * outer = (ethernet_vlan_header_t *)(h0 + 1);
-
- outer = (outer->type == clib_host_to_net_u16(ETHERNET_TYPE_VLAN)) ?
- outer+1 : outer;
- if (PREDICT_TRUE(outer->type) == clib_host_to_net_u16(ETHERNET_TYPE_IP4)) {
- hash_key = ipv4_get_key((ip4_header_t *)(outer+1));
- } else if (outer->type == clib_host_to_net_u16 (ETHERNET_TYPE_IP6)) {
- hash_key = ipv6_get_key((ip6_header_t *)(outer+1));
- } else if (outer->type == clib_host_to_net_u16(ETHERNET_TYPE_MPLS_UNICAST)) {
- hash_key = mpls_get_key((mpls_unicast_header_t *)(outer+1));
- } else {
- hash_key = outer->type;
- }
- } else {
- hash_key = 0;
- }
-
- return hash_key;
+ u64 hash_key;
+
+ if (PREDICT_TRUE (h0->type) == clib_host_to_net_u16 (ETHERNET_TYPE_IP4))
+ {
+ hash_key = ipv4_get_key ((ip4_header_t *) (h0 + 1));
+ }
+ else if (h0->type == clib_host_to_net_u16 (ETHERNET_TYPE_IP6))
+ {
+ hash_key = ipv6_get_key ((ip6_header_t *) (h0 + 1));
+ }
+ else if (h0->type == clib_host_to_net_u16 (ETHERNET_TYPE_MPLS_UNICAST))
+ {
+ hash_key = mpls_get_key ((mpls_unicast_header_t *) (h0 + 1));
+ }
+ else if ((h0->type == clib_host_to_net_u16 (ETHERNET_TYPE_VLAN)) ||
+ (h0->type == clib_host_to_net_u16 (ETHERNET_TYPE_DOT1AD)))
+ {
+ ethernet_vlan_header_t *outer = (ethernet_vlan_header_t *) (h0 + 1);
+
+ outer = (outer->type == clib_host_to_net_u16 (ETHERNET_TYPE_VLAN)) ?
+ outer + 1 : outer;
+ if (PREDICT_TRUE (outer->type) ==
+ clib_host_to_net_u16 (ETHERNET_TYPE_IP4))
+ {
+ hash_key = ipv4_get_key ((ip4_header_t *) (outer + 1));
+ }
+ else if (outer->type == clib_host_to_net_u16 (ETHERNET_TYPE_IP6))
+ {
+ hash_key = ipv6_get_key ((ip6_header_t *) (outer + 1));
+ }
+ else if (outer->type ==
+ clib_host_to_net_u16 (ETHERNET_TYPE_MPLS_UNICAST))
+ {
+ hash_key = mpls_get_key ((mpls_unicast_header_t *) (outer + 1));
+ }
+ else
+ {
+ hash_key = outer->type;
+ }
+ }
+ else
+ {
+ hash_key = 0;
+ }
+
+ return hash_key;
}
#endif /* included_vnet_handoff_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/interface.c b/vnet/vnet/interface.c
index 24f9cbc9aff..3a12085da29 100644
--- a/vnet/vnet/interface.c
+++ b/vnet/vnet/interface.c
@@ -43,18 +43,23 @@
#define VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE (1 << 0)
#define VNET_INTERFACE_SET_FLAGS_HELPER_WANT_REDISTRIBUTE (1 << 1)
-static clib_error_t *
-vnet_hw_interface_set_flags_helper (vnet_main_t * vnm, u32 hw_if_index, u32 flags,
- u32 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);
-
-static clib_error_t *
-vnet_hw_interface_set_class_helper (vnet_main_t * vnm, u32 hw_if_index, u32 hw_class_index, u32 redistribute);
-
-typedef struct {
+static clib_error_t *vnet_hw_interface_set_flags_helper (vnet_main_t * vnm,
+ u32 hw_if_index,
+ u32 flags,
+ u32 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);
+
+static clib_error_t *vnet_hw_interface_set_class_helper (vnet_main_t * vnm,
+ u32 hw_if_index,
+ u32 hw_class_index,
+ u32 redistribute);
+
+typedef struct
+{
/* Either sw or hw interface index. */
u32 sw_hw_if_index;
@@ -62,35 +67,47 @@ typedef struct {
u32 flags;
} vnet_sw_hw_interface_state_t;
-static void serialize_vec_vnet_sw_hw_interface_state (serialize_main_t * m, va_list * va)
+static void
+serialize_vec_vnet_sw_hw_interface_state (serialize_main_t * m, va_list * va)
{
- vnet_sw_hw_interface_state_t * s = va_arg (*va, vnet_sw_hw_interface_state_t *);
- u32 n = va_arg (*va, u32);
- u32 i;
- for (i = 0; i < n; i++) {
- serialize_integer (m, s[i].sw_hw_if_index, sizeof (s[i].sw_hw_if_index));
- serialize_integer (m, s[i].flags, sizeof (s[i].flags));
+ vnet_sw_hw_interface_state_t *s =
+ va_arg (*va, vnet_sw_hw_interface_state_t *);
+ u32 n = va_arg (*va, u32);
+ u32 i;
+ for (i = 0; i < n; i++)
+ {
+ serialize_integer (m, s[i].sw_hw_if_index,
+ sizeof (s[i].sw_hw_if_index));
+ serialize_integer (m, s[i].flags, sizeof (s[i].flags));
}
}
-static void unserialize_vec_vnet_sw_hw_interface_state (serialize_main_t * m, va_list * va)
+static void
+unserialize_vec_vnet_sw_hw_interface_state (serialize_main_t * m,
+ va_list * va)
{
- vnet_sw_hw_interface_state_t * s = va_arg (*va, vnet_sw_hw_interface_state_t *);
- u32 n = va_arg (*va, u32);
- u32 i;
- for (i = 0; i < n; i++) {
- unserialize_integer (m, &s[i].sw_hw_if_index, sizeof (s[i].sw_hw_if_index));
- unserialize_integer (m, &s[i].flags, sizeof (s[i].flags));
+ vnet_sw_hw_interface_state_t *s =
+ va_arg (*va, vnet_sw_hw_interface_state_t *);
+ u32 n = va_arg (*va, u32);
+ u32 i;
+ for (i = 0; i < n; i++)
+ {
+ unserialize_integer (m, &s[i].sw_hw_if_index,
+ sizeof (s[i].sw_hw_if_index));
+ unserialize_integer (m, &s[i].flags, sizeof (s[i].flags));
}
}
-static void serialize_vnet_sw_hw_interface_set_flags (serialize_main_t * m, va_list * va)
+static void
+serialize_vnet_sw_hw_interface_set_flags (serialize_main_t * m, va_list * va)
{
- vnet_sw_hw_interface_state_t * s = va_arg (*va, vnet_sw_hw_interface_state_t *);
+ vnet_sw_hw_interface_state_t *s =
+ va_arg (*va, vnet_sw_hw_interface_state_t *);
serialize (m, serialize_vec_vnet_sw_hw_interface_state, s, 1);
}
-static void unserialize_vnet_sw_interface_set_flags (serialize_main_t * m, va_list * va)
+static void
+unserialize_vnet_sw_interface_set_flags (serialize_main_t * m, va_list * va)
{
CLIB_UNUSED (mc_main_t * mc) = va_arg (*va, mc_main_t *);
vnet_sw_hw_interface_state_t s;
@@ -98,11 +115,12 @@ static void unserialize_vnet_sw_interface_set_flags (serialize_main_t * m, va_li
unserialize (m, unserialize_vec_vnet_sw_hw_interface_state, &s, 1);
vnet_sw_interface_set_flags_helper
- (vnet_get_main(), s.sw_hw_if_index, s.flags,
+ (vnet_get_main (), s.sw_hw_if_index, s.flags,
/* helper_flags no redistribution */ 0);
}
-static void unserialize_vnet_hw_interface_set_flags (serialize_main_t * m, va_list * va)
+static void
+unserialize_vnet_hw_interface_set_flags (serialize_main_t * m, va_list * va)
{
CLIB_UNUSED (mc_main_t * mc) = va_arg (*va, mc_main_t *);
vnet_sw_hw_interface_state_t s;
@@ -110,38 +128,42 @@ static void unserialize_vnet_hw_interface_set_flags (serialize_main_t * m, va_li
unserialize (m, unserialize_vec_vnet_sw_hw_interface_state, &s, 1);
vnet_hw_interface_set_flags_helper
- (vnet_get_main(), s.sw_hw_if_index, s.flags,
+ (vnet_get_main (), s.sw_hw_if_index, s.flags,
/* helper_flags no redistribution */ 0);
}
-MC_SERIALIZE_MSG (vnet_sw_interface_set_flags_msg, static) = {
- .name = "vnet_sw_interface_set_flags",
- .serialize = serialize_vnet_sw_hw_interface_set_flags,
- .unserialize = unserialize_vnet_sw_interface_set_flags,
-};
+MC_SERIALIZE_MSG (vnet_sw_interface_set_flags_msg, static) =
+{
+.name = "vnet_sw_interface_set_flags",.serialize =
+ serialize_vnet_sw_hw_interface_set_flags,.unserialize =
+ unserialize_vnet_sw_interface_set_flags,};
-MC_SERIALIZE_MSG (vnet_hw_interface_set_flags_msg, static) = {
- .name = "vnet_hw_interface_set_flags",
- .serialize = serialize_vnet_sw_hw_interface_set_flags,
- .unserialize = unserialize_vnet_hw_interface_set_flags,
-};
+MC_SERIALIZE_MSG (vnet_hw_interface_set_flags_msg, static) =
+{
+.name = "vnet_hw_interface_set_flags",.serialize =
+ serialize_vnet_sw_hw_interface_set_flags,.unserialize =
+ unserialize_vnet_hw_interface_set_flags,};
-void serialize_vnet_interface_state (serialize_main_t * m, va_list * va)
+void
+serialize_vnet_interface_state (serialize_main_t * m, va_list * va)
{
- vnet_main_t * vnm = va_arg (*va, vnet_main_t *);
- vnet_sw_hw_interface_state_t * sts = 0, * st;
- vnet_sw_interface_t * sif;
- vnet_hw_interface_t * hif;
- vnet_interface_main_t * im = &vnm->interface_main;
+ vnet_main_t *vnm = va_arg (*va, vnet_main_t *);
+ vnet_sw_hw_interface_state_t *sts = 0, *st;
+ vnet_sw_interface_t *sif;
+ vnet_hw_interface_t *hif;
+ vnet_interface_main_t *im = &vnm->interface_main;
/* Serialize hardware interface classes since they may have changed.
Must do this before sending up/down flags. */
+ /* *INDENT-OFF* */
pool_foreach (hif, im->hw_interfaces, ({
vnet_hw_interface_class_t * hw_class = vnet_get_hw_interface_class (vnm, hif->hw_class_index);
serialize_cstring (m, hw_class->name);
}));
+ /* *INDENT-ON* */
/* Send sw/hw interface state when non-zero. */
+ /* *INDENT-OFF* */
pool_foreach (sif, im->sw_interfaces, ({
if (sif->flags != 0)
{
@@ -150,12 +172,14 @@ void serialize_vnet_interface_state (serialize_main_t * m, va_list * va)
st->flags = sif->flags;
}
}));
+ /* *INDENT-ON* */
vec_serialize (m, sts, serialize_vec_vnet_sw_hw_interface_state);
if (sts)
_vec_len (sts) = 0;
+ /* *INDENT-OFF* */
pool_foreach (hif, im->hw_interfaces, ({
if (hif->flags != 0)
{
@@ -164,25 +188,28 @@ void serialize_vnet_interface_state (serialize_main_t * m, va_list * va)
st->flags = hif->flags;
}
}));
+ /* *INDENT-ON* */
vec_serialize (m, sts, serialize_vec_vnet_sw_hw_interface_state);
vec_free (sts);
}
-void unserialize_vnet_interface_state (serialize_main_t * m, va_list * va)
+void
+unserialize_vnet_interface_state (serialize_main_t * m, va_list * va)
{
- vnet_main_t * vnm = va_arg (*va, vnet_main_t *);
- vnet_sw_hw_interface_state_t * sts = 0, * st;
+ vnet_main_t *vnm = va_arg (*va, vnet_main_t *);
+ vnet_sw_hw_interface_state_t *sts = 0, *st;
/* First set interface hardware class. */
{
- vnet_interface_main_t * im = &vnm->interface_main;
- vnet_hw_interface_t * hif;
- char * class_name;
- uword * p;
- clib_error_t * error;
+ vnet_interface_main_t *im = &vnm->interface_main;
+ vnet_hw_interface_t *hif;
+ char *class_name;
+ uword *p;
+ clib_error_t *error;
+ /* *INDENT-OFF* */
pool_foreach (hif, im->hw_interfaces, ({
unserialize_cstring (m, &class_name);
p = hash_get_mem (im->hw_interface_class_by_name, class_name);
@@ -192,6 +219,7 @@ void unserialize_vnet_interface_state (serialize_main_t * m, va_list * va)
clib_error_report (error);
vec_free (class_name);
}));
+ /* *INDENT-ON* */
}
vec_unserialize (m, &sts, unserialize_vec_vnet_sw_hw_interface_state);
@@ -208,48 +236,56 @@ void unserialize_vnet_interface_state (serialize_main_t * m, va_list * va)
}
static clib_error_t *
-call_elf_section_interface_callbacks (vnet_main_t * vnm, u32 if_index,
- u32 flags,
- _vnet_interface_function_list_elt_t *elt)
+call_elf_section_interface_callbacks (vnet_main_t * vnm, u32 if_index,
+ u32 flags,
+ _vnet_interface_function_list_elt_t *
+ elt)
{
- clib_error_t * error = 0;
+ clib_error_t *error = 0;
while (elt)
{
- error = elt->fp(vnm, if_index, flags);
+ error = elt->fp (vnm, if_index, flags);
if (error)
- return error;
+ return error;
elt = elt->next_interface_function;
}
return error;
}
static clib_error_t *
-call_hw_interface_add_del_callbacks (vnet_main_t * vnm, u32 hw_if_index, u32 is_create)
+call_hw_interface_add_del_callbacks (vnet_main_t * vnm, u32 hw_if_index,
+ u32 is_create)
{
- vnet_hw_interface_t * hi = vnet_get_hw_interface (vnm, hw_if_index);
- vnet_hw_interface_class_t * hw_class = vnet_get_hw_interface_class (vnm, hi->hw_class_index);
- vnet_device_class_t * dev_class = vnet_get_device_class (vnm, hi->dev_class_index);
- clib_error_t * error = 0;
+ vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
+ vnet_hw_interface_class_t *hw_class =
+ vnet_get_hw_interface_class (vnm, hi->hw_class_index);
+ vnet_device_class_t *dev_class =
+ vnet_get_device_class (vnm, hi->dev_class_index);
+ clib_error_t *error = 0;
if (hw_class->interface_add_del_function
- && (error = hw_class->interface_add_del_function (vnm, hw_if_index, is_create)))
+ && (error =
+ hw_class->interface_add_del_function (vnm, hw_if_index, is_create)))
return error;
if (dev_class->interface_add_del_function
- && (error = dev_class->interface_add_del_function (vnm, hw_if_index, is_create)))
+ && (error =
+ dev_class->interface_add_del_function (vnm, hw_if_index,
+ is_create)))
return error;
- error = call_elf_section_interface_callbacks
+ error = call_elf_section_interface_callbacks
(vnm, hw_if_index, is_create, vnm->hw_interface_add_del_functions);
return error;
}
static clib_error_t *
-call_sw_interface_add_del_callbacks (vnet_main_t * vnm, u32 sw_if_index, u32 is_create)
+call_sw_interface_add_del_callbacks (vnet_main_t * vnm, u32 sw_if_index,
+ u32 is_create)
{
- return call_elf_section_interface_callbacks
+ return call_elf_section_interface_callbacks
(vnm, sw_if_index, is_create, vnm->sw_interface_add_del_functions);
}
@@ -257,19 +293,23 @@ call_sw_interface_add_del_callbacks (vnet_main_t * vnm, u32 sw_if_index, u32 is_
#define VNET_INTERFACE_SET_FLAGS_HELPER_WANT_REDISTRIBUTE (1 << 1)
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_set_flags_helper (vnet_main_t * vnm, u32 hw_if_index,
+ u32 flags, u32 helper_flags)
{
- vnet_hw_interface_t * hi = vnet_get_hw_interface (vnm, hw_if_index);
- vnet_hw_interface_class_t * hw_class = vnet_get_hw_interface_class (vnm, hi->hw_class_index);
- vnet_device_class_t * dev_class = vnet_get_device_class (vnm, hi->dev_class_index);
- vlib_main_t * vm = vnm->vlib_main;
+ vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
+ vnet_hw_interface_class_t *hw_class =
+ vnet_get_hw_interface_class (vnm, hi->hw_class_index);
+ vnet_device_class_t *dev_class =
+ vnet_get_device_class (vnm, hi->dev_class_index);
+ vlib_main_t *vm = vnm->vlib_main;
u32 mask;
- clib_error_t * error = 0;
- u32 is_create = (helper_flags & VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE) != 0;
+ clib_error_t *error = 0;
+ u32 is_create =
+ (helper_flags & VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE) != 0;
- mask = (VNET_HW_INTERFACE_FLAG_LINK_UP | VNET_HW_INTERFACE_FLAG_DUPLEX_MASK |
- VNET_HW_INTERFACE_FLAG_SPEED_MASK);
+ mask =
+ (VNET_HW_INTERFACE_FLAG_LINK_UP | VNET_HW_INTERFACE_FLAG_DUPLEX_MASK |
+ VNET_HW_INTERFACE_FLAG_SPEED_MASK);
flags &= mask;
/* Call hardware interface add/del callbacks. */
@@ -277,12 +317,12 @@ vnet_hw_interface_set_flags_helper (vnet_main_t * vnm, u32 hw_if_index, u32 flag
call_hw_interface_add_del_callbacks (vnm, hw_if_index, is_create);
/* Already in the desired state? */
- if (! is_create && (hi->flags & mask) == flags)
+ if (!is_create && (hi->flags & mask) == flags)
goto done;
/* Some interface classes do not redistribute (e.g. are local). */
- if (! dev_class->redistribute)
- helper_flags &= ~ VNET_INTERFACE_SET_FLAGS_HELPER_WANT_REDISTRIBUTE;
+ if (!dev_class->redistribute)
+ helper_flags &= ~VNET_INTERFACE_SET_FLAGS_HELPER_WANT_REDISTRIBUTE;
if (vm->mc_main
&& (helper_flags & VNET_INTERFACE_SET_FLAGS_HELPER_WANT_REDISTRIBUTE))
@@ -302,9 +342,10 @@ vnet_hw_interface_set_flags_helper (vnet_main_t * vnm, u32 hw_if_index, u32 flag
flags)))
goto done;
- error = call_elf_section_interface_callbacks
- (vnm, hw_if_index, is_create, vnm->hw_interface_link_up_down_functions);
-
+ error = call_elf_section_interface_callbacks
+ (vnm, hw_if_index, is_create,
+ vnm->hw_interface_link_up_down_functions);
+
if (error)
goto done;
}
@@ -312,19 +353,20 @@ vnet_hw_interface_set_flags_helper (vnet_main_t * vnm, u32 hw_if_index, u32 flag
hi->flags &= ~mask;
hi->flags |= flags;
- done:
+done:
return error;
}
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_set_flags_helper (vnet_main_t * vnm, u32 sw_if_index,
+ u32 flags, u32 helper_flags)
{
- vnet_sw_interface_t * si = vnet_get_sw_interface (vnm, sw_if_index);
- vlib_main_t * vm = vnm->vlib_main;
+ vnet_sw_interface_t *si = vnet_get_sw_interface (vnm, sw_if_index);
+ vlib_main_t *vm = vnm->vlib_main;
u32 mask;
- clib_error_t * error = 0;
- u32 is_create = (helper_flags & VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE) != 0;
+ clib_error_t *error = 0;
+ u32 is_create =
+ (helper_flags & VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE) != 0;
u32 old_flags;
mask = VNET_SW_INTERFACE_FLAG_ADMIN_UP | VNET_SW_INTERFACE_FLAG_PUNT;
@@ -332,22 +374,25 @@ vnet_sw_interface_set_flags_helper (vnet_main_t * vnm, u32 sw_if_index, u32 flag
if (is_create)
{
- error = call_sw_interface_add_del_callbacks (vnm, sw_if_index, is_create);
+ error =
+ call_sw_interface_add_del_callbacks (vnm, sw_if_index, is_create);
if (error)
goto done;
if (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)
- {
- /* Notify everyone when the interface is created as admin up */
- error = call_elf_section_interface_callbacks (vnm, sw_if_index,
- flags, vnm->sw_interface_admin_up_down_functions);
- if (error)
- goto done;
- }
+ {
+ /* Notify everyone when the interface is created as admin up */
+ error = call_elf_section_interface_callbacks (vnm, sw_if_index,
+ flags,
+ vnm->
+ sw_interface_admin_up_down_functions);
+ if (error)
+ goto done;
+ }
}
else
{
- vnet_sw_interface_t * si_sup = si;
+ vnet_sw_interface_t *si_sup = si;
/* Check that super interface is in correct state. */
if (si->type == VNET_SW_INTERFACE_TYPE_SUB)
@@ -355,41 +400,49 @@ vnet_sw_interface_set_flags_helper (vnet_main_t * vnm, u32 sw_if_index, u32 flag
si_sup = vnet_get_sw_interface (vnm, si->sup_sw_if_index);
/* Check to see if we're bringing down the soft interface and if it's parent is up */
- if ((flags != (si_sup->flags & mask)) &&
- (!((flags == 0) && ((si_sup->flags & mask) == VNET_SW_INTERFACE_FLAG_ADMIN_UP))))
+ if ((flags != (si_sup->flags & mask)) &&
+ (!((flags == 0)
+ && ((si_sup->flags & mask) ==
+ VNET_SW_INTERFACE_FLAG_ADMIN_UP))))
{
error = clib_error_return (0, "super-interface %U must be %U",
- format_vnet_sw_interface_name, vnm, si_sup,
- format_vnet_sw_interface_flags, flags);
+ format_vnet_sw_interface_name, vnm,
+ si_sup,
+ format_vnet_sw_interface_flags,
+ flags);
goto done;
}
}
/* Donot change state for slave link of bonded interfaces */
if (si->flags & VNET_SW_INTERFACE_FLAG_BOND_SLAVE)
- {
- error = clib_error_return
- (0, "not allowed as %U belong to a BondEthernet interface",
- format_vnet_sw_interface_name, vnm, si);
+ {
+ error = clib_error_return
+ (0, "not allowed as %U belong to a BondEthernet interface",
+ format_vnet_sw_interface_name, vnm, si);
goto done;
- }
+ }
/* Already in the desired state? */
if ((si->flags & mask) == flags)
goto done;
/* Sub-interfaces of hardware interfaces that do no redistribute,
- do not redistribute themselves. */
+ do not redistribute themselves. */
if (si_sup->type == VNET_SW_INTERFACE_TYPE_HARDWARE)
{
- vnet_hw_interface_t * hi = vnet_get_hw_interface (vnm, si_sup->hw_if_index);
- vnet_device_class_t * dev_class = vnet_get_device_class (vnm, hi->dev_class_index);
- if (! dev_class->redistribute)
- helper_flags &= ~ VNET_INTERFACE_SET_FLAGS_HELPER_WANT_REDISTRIBUTE;
+ vnet_hw_interface_t *hi =
+ vnet_get_hw_interface (vnm, si_sup->hw_if_index);
+ vnet_device_class_t *dev_class =
+ vnet_get_device_class (vnm, hi->dev_class_index);
+ if (!dev_class->redistribute)
+ helper_flags &=
+ ~VNET_INTERFACE_SET_FLAGS_HELPER_WANT_REDISTRIBUTE;
}
if (vm->mc_main
- && (helper_flags & VNET_INTERFACE_SET_FLAGS_HELPER_WANT_REDISTRIBUTE))
+ && (helper_flags &
+ VNET_INTERFACE_SET_FLAGS_HELPER_WANT_REDISTRIBUTE))
{
vnet_sw_hw_interface_state_t s;
s.sw_hw_if_index = sw_if_index;
@@ -397,50 +450,54 @@ vnet_sw_interface_set_flags_helper (vnet_main_t * vnm, u32 sw_if_index, u32 flag
mc_serialize (vm->mc_main, &vnet_sw_interface_set_flags_msg, &s);
}
- error = call_elf_section_interface_callbacks
- (vnm, sw_if_index, flags, vnm->sw_interface_admin_up_down_functions);
+ error = call_elf_section_interface_callbacks
+ (vnm, sw_if_index, flags, vnm->sw_interface_admin_up_down_functions);
if (error)
- goto done;
+ goto done;
if (si->type == VNET_SW_INTERFACE_TYPE_HARDWARE)
{
- vnet_hw_interface_t * hi = vnet_get_hw_interface (vnm, si->hw_if_index);
- vnet_hw_interface_class_t * hw_class = vnet_get_hw_interface_class (vnm, hi->hw_class_index);
- vnet_device_class_t * dev_class = vnet_get_device_class (vnm, hi->dev_class_index);
-
- /* save the si admin up flag */
- old_flags = si->flags;
-
- /* update si admin up flag in advance if we are going admin down */
- if (!(flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP))
- si->flags &= ~VNET_SW_INTERFACE_FLAG_ADMIN_UP;
-
- if (dev_class->admin_up_down_function
- && (error = dev_class->admin_up_down_function(vnm,
- si->hw_if_index,
- flags)))
- {
- /* restore si admin up flag to it's original state on errors */
- si->flags = old_flags;
- goto done;
- }
-
- if (hw_class->admin_up_down_function
- && (error = hw_class->admin_up_down_function(vnm,
- si->hw_if_index,
- flags)))
- {
- /* restore si admin up flag to it's original state on errors */
- si->flags = old_flags;
- goto done;
- }
+ vnet_hw_interface_t *hi =
+ vnet_get_hw_interface (vnm, si->hw_if_index);
+ vnet_hw_interface_class_t *hw_class =
+ vnet_get_hw_interface_class (vnm, hi->hw_class_index);
+ vnet_device_class_t *dev_class =
+ vnet_get_device_class (vnm, hi->dev_class_index);
+
+ /* save the si admin up flag */
+ old_flags = si->flags;
+
+ /* update si admin up flag in advance if we are going admin down */
+ if (!(flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP))
+ si->flags &= ~VNET_SW_INTERFACE_FLAG_ADMIN_UP;
+
+ if (dev_class->admin_up_down_function
+ && (error = dev_class->admin_up_down_function (vnm,
+ si->hw_if_index,
+ flags)))
+ {
+ /* restore si admin up flag to it's original state on errors */
+ si->flags = old_flags;
+ goto done;
+ }
+
+ if (hw_class->admin_up_down_function
+ && (error = hw_class->admin_up_down_function (vnm,
+ si->hw_if_index,
+ flags)))
+ {
+ /* restore si admin up flag to it's original state on errors */
+ si->flags = old_flags;
+ goto done;
+ }
/* Admin down implies link down. */
- if (! (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)
+ if (!(flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)
&& (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP))
vnet_hw_interface_set_flags_helper (vnm, si->hw_if_index,
- hi->flags &~ VNET_HW_INTERFACE_FLAG_LINK_UP,
+ hi->flags &
+ ~VNET_HW_INTERFACE_FLAG_LINK_UP,
helper_flags);
}
}
@@ -448,7 +505,7 @@ vnet_sw_interface_set_flags_helper (vnet_main_t * vnm, u32 sw_if_index, u32 flag
si->flags &= ~mask;
si->flags |= flags;
- done:
+done:
return error;
}
@@ -469,10 +526,11 @@ vnet_sw_interface_set_flags (vnet_main_t * vnm, u32 sw_if_index, u32 flags)
}
static u32
-vnet_create_sw_interface_no_callbacks (vnet_main_t * vnm, vnet_sw_interface_t * template)
+vnet_create_sw_interface_no_callbacks (vnet_main_t * vnm,
+ vnet_sw_interface_t * template)
{
- vnet_interface_main_t * im = &vnm->interface_main;
- vnet_sw_interface_t * sw;
+ vnet_interface_main_t *im = &vnm->interface_main;
+ vnet_sw_interface_t *sw;
u32 sw_if_index;
pool_get (im->sw_interfaces, sw);
@@ -489,7 +547,7 @@ vnet_create_sw_interface_no_callbacks (vnet_main_t * vnm, vnet_sw_interface_t *
{
u32 i;
- vnet_interface_counter_lock(im);
+ vnet_interface_counter_lock (im);
for (i = 0; i < vec_len (im->sw_if_counters); i++)
{
@@ -499,55 +557,62 @@ vnet_create_sw_interface_no_callbacks (vnet_main_t * vnm, vnet_sw_interface_t *
for (i = 0; i < vec_len (im->combined_sw_if_counters); i++)
{
- vlib_validate_combined_counter (&im->combined_sw_if_counters[i],
- sw_if_index);
- vlib_zero_combined_counter (&im->combined_sw_if_counters[i],
- sw_if_index);
+ vlib_validate_combined_counter (&im->combined_sw_if_counters[i],
+ sw_if_index);
+ vlib_zero_combined_counter (&im->combined_sw_if_counters[i],
+ sw_if_index);
}
- vnet_interface_counter_unlock(im);
+ vnet_interface_counter_unlock (im);
}
return sw_if_index;
}
clib_error_t *
-vnet_create_sw_interface (vnet_main_t * vnm, vnet_sw_interface_t * template, u32 * sw_if_index)
+vnet_create_sw_interface (vnet_main_t * vnm, vnet_sw_interface_t * template,
+ u32 * sw_if_index)
{
- clib_error_t * error;
- vnet_hw_interface_t * hi;
- vnet_device_class_t * dev_class;
+ clib_error_t *error;
+ vnet_hw_interface_t *hi;
+ vnet_device_class_t *dev_class;
hi = vnet_get_sup_hw_interface (vnm, template->sup_sw_if_index);
dev_class = vnet_get_device_class (vnm, hi->dev_class_index);
if (template->type == VNET_SW_INTERFACE_TYPE_SUB &&
- dev_class->subif_add_del_function) {
- error = dev_class->subif_add_del_function (vnm, hi->hw_if_index,
- (struct vnet_sw_interface_t *) template, 1);
- if (error)
- return error;
- }
+ dev_class->subif_add_del_function)
+ {
+ error = dev_class->subif_add_del_function (vnm, hi->hw_if_index,
+ (struct vnet_sw_interface_t
+ *) template, 1);
+ if (error)
+ return error;
+ }
*sw_if_index = vnet_create_sw_interface_no_callbacks (vnm, template);
error = vnet_sw_interface_set_flags_helper
(vnm, *sw_if_index, template->flags,
VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE);
- if (error) {
- // undo the work done by vnet_create_sw_interface_no_callbacks()
- vnet_interface_main_t * im = &vnm->interface_main;
- vnet_sw_interface_t * sw = pool_elt_at_index (im->sw_interfaces, *sw_if_index);
- pool_put (im->sw_interfaces, sw);
- }
+ if (error)
+ {
+ /* undo the work done by vnet_create_sw_interface_no_callbacks() */
+ vnet_interface_main_t *im = &vnm->interface_main;
+ vnet_sw_interface_t *sw =
+ pool_elt_at_index (im->sw_interfaces, *sw_if_index);
+ pool_put (im->sw_interfaces, sw);
+ }
return error;
}
-void vnet_delete_sw_interface (vnet_main_t * vnm, u32 sw_if_index)
+void
+vnet_delete_sw_interface (vnet_main_t * vnm, u32 sw_if_index)
{
- vnet_interface_main_t * im = &vnm->interface_main;
- vnet_sw_interface_t * sw = pool_elt_at_index (im->sw_interfaces, sw_if_index);
+ vnet_interface_main_t *im = &vnm->interface_main;
+ vnet_sw_interface_t *sw =
+ pool_elt_at_index (im->sw_interfaces, sw_if_index);
/* Bring down interface in case it is up. */
if (sw->flags != 0)
@@ -558,24 +623,24 @@ void vnet_delete_sw_interface (vnet_main_t * vnm, u32 sw_if_index)
pool_put (im->sw_interfaces, sw);
}
-static void setup_tx_node (vlib_main_t * vm,
- u32 node_index,
- vnet_device_class_t * dev_class)
+static void
+setup_tx_node (vlib_main_t * vm,
+ u32 node_index, vnet_device_class_t * dev_class)
{
- vlib_node_t * n = vlib_get_node (vm, node_index);
+ vlib_node_t *n = vlib_get_node (vm, node_index);
n->function = dev_class->tx_function;
n->format_trace = dev_class->format_tx_trace;
- vlib_register_errors (vm, node_index,
- dev_class->tx_function_n_errors,
- dev_class->tx_function_error_strings);
+ vlib_register_errors (vm, node_index,
+ dev_class->tx_function_n_errors,
+ dev_class->tx_function_error_strings);
}
-static void setup_output_node (vlib_main_t * vm,
- u32 node_index,
- vnet_hw_interface_class_t * hw_class)
+static void
+setup_output_node (vlib_main_t * vm,
+ u32 node_index, vnet_hw_interface_class_t * hw_class)
{
- vlib_node_t * n = vlib_get_node (vm, node_index);
+ vlib_node_t *n = vlib_get_node (vm, node_index);
n->format_buffer = hw_class->format_header;
n->unformat_buffer = hw_class->unformat_header;
}
@@ -585,16 +650,17 @@ u32
vnet_register_interface (vnet_main_t * vnm,
u32 dev_class_index,
u32 dev_instance,
- u32 hw_class_index,
- u32 hw_instance)
+ u32 hw_class_index, u32 hw_instance)
{
- vnet_interface_main_t * im = &vnm->interface_main;
- vnet_hw_interface_t * hw;
- vnet_device_class_t * dev_class = vnet_get_device_class (vnm, dev_class_index);
- vnet_hw_interface_class_t * hw_class = vnet_get_hw_interface_class (vnm, hw_class_index);
- vlib_main_t * vm = vnm->vlib_main;
+ vnet_interface_main_t *im = &vnm->interface_main;
+ vnet_hw_interface_t *hw;
+ vnet_device_class_t *dev_class =
+ vnet_get_device_class (vnm, dev_class_index);
+ vnet_hw_interface_class_t *hw_class =
+ vnet_get_hw_interface_class (vnm, hw_class_index);
+ vlib_main_t *vm = vnm->vlib_main;
u32 hw_index;
- char * tx_node_name, * output_node_name;
+ char *tx_node_name, *output_node_name;
pool_get (im->hw_interfaces, hw);
@@ -602,16 +668,15 @@ vnet_register_interface (vnet_main_t * vnm,
hw->hw_if_index = hw_index;
if (dev_class->format_device_name)
- hw->name = format (0, "%U",
- dev_class->format_device_name, dev_instance);
+ hw->name = format (0, "%U", dev_class->format_device_name, dev_instance);
else if (hw_class->format_interface_name)
hw->name = format (0, "%U", hw_class->format_interface_name,
dev_instance);
else
hw->name = format (0, "%s%x", hw_class->name, dev_instance);
- if (! im->hw_interface_by_name)
- im->hw_interface_by_name = hash_create_vec (/* size */ 0,
+ if (!im->hw_interface_by_name)
+ im->hw_interface_by_name = hash_create_vec ( /* size */ 0,
sizeof (hw->name[0]),
sizeof (uword));
@@ -644,8 +709,8 @@ vnet_register_interface (vnet_main_t * vnm,
/* If we have previously deleted interface nodes, re-use them. */
if (vec_len (im->deleted_hw_interface_nodes) > 0)
{
- vnet_hw_interface_nodes_t * hn;
- vnet_interface_output_runtime_t * rt;
+ vnet_hw_interface_nodes_t *hn;
+ vnet_interface_output_runtime_t *rt;
hn = vec_end (im->deleted_hw_interface_nodes) - 1;
@@ -658,7 +723,7 @@ vnet_register_interface (vnet_main_t * vnm,
rt = vlib_node_get_runtime_data (vm, hw->output_node_index);
ASSERT (rt->is_deleted == 1);
rt->is_deleted = 0;
- rt->hw_if_index = hw_index;
+ rt->hw_if_index = hw_index;
rt->sw_if_index = hw->sw_if_index;
rt->dev_instance = hw->dev_instance;
@@ -667,7 +732,7 @@ vnet_register_interface (vnet_main_t * vnm,
rt->sw_if_index = hw->sw_if_index;
rt->dev_instance = hw->dev_instance;
- vlib_worker_thread_node_runtime_update();
+ vlib_worker_thread_node_runtime_update ();
_vec_len (im->deleted_hw_interface_nodes) -= 1;
}
else
@@ -699,13 +764,13 @@ vnet_register_interface (vnet_main_t * vnm,
r.flags = 0;
r.name = output_node_name;
- r.function = dev_class->no_flatten_output_chains ?
- vnet_interface_output_node_no_flatten_multiarch_select() :
- vnet_interface_output_node_multiarch_select() ;
+ r.function = dev_class->no_flatten_output_chains ?
+ vnet_interface_output_node_no_flatten_multiarch_select () :
+ vnet_interface_output_node_multiarch_select ();
r.format_trace = format_vnet_interface_output_trace;
{
- static char * e[] = {
+ static char *e[] = {
"interface is down",
"interface is deleted",
};
@@ -713,7 +778,6 @@ vnet_register_interface (vnet_main_t * vnm,
r.n_errors = ARRAY_LEN (e);
r.error_strings = e;
}
-
hw->output_node_index = vlib_register_node (vm, &r);
#define _(sym,str) vlib_node_add_named_next_with_slot (vm, \
@@ -721,10 +785,9 @@ vnet_register_interface (vnet_main_t * vnm,
VNET_INTERFACE_OUTPUT_NEXT_##sym);
foreach_intf_output_feat
#undef _
-
- vlib_node_add_named_next_with_slot (vm, hw->output_node_index,
- "error-drop",
- VNET_INTERFACE_OUTPUT_NEXT_DROP);
+ vlib_node_add_named_next_with_slot (vm, hw->output_node_index,
+ "error-drop",
+ VNET_INTERFACE_OUTPUT_NEXT_DROP);
vlib_node_add_next_with_slot (vm, hw->output_node_index,
hw->tx_node_index,
VNET_INTERFACE_OUTPUT_NEXT_TX);
@@ -734,21 +797,20 @@ vnet_register_interface (vnet_main_t * vnm,
setup_tx_node (vm, hw->tx_node_index, dev_class);
/* Call all up/down callbacks with zero flags when interface is created. */
- vnet_sw_interface_set_flags_helper
- (vnm, hw->sw_if_index, /* flags */ 0,
- VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE);
- vnet_hw_interface_set_flags_helper
- (vnm, hw_index, /* flags */ 0,
- VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE);
+ vnet_sw_interface_set_flags_helper (vnm, hw->sw_if_index, /* flags */ 0,
+ VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE);
+ vnet_hw_interface_set_flags_helper (vnm, hw_index, /* flags */ 0,
+ VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE);
return hw_index;
}
-void vnet_delete_hw_interface (vnet_main_t * vnm, u32 hw_if_index)
+void
+vnet_delete_hw_interface (vnet_main_t * vnm, u32 hw_if_index)
{
- vnet_interface_main_t * im = &vnm->interface_main;
- vnet_hw_interface_t * hw = vnet_get_hw_interface (vnm, hw_if_index);
- vlib_main_t * vm = vnm->vlib_main;
+ vnet_interface_main_t *im = &vnm->interface_main;
+ vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
+ vlib_main_t *vm = vnm->vlib_main;
/* If it is up, mark it down. */
if (hw->flags != 0)
@@ -763,20 +825,25 @@ void vnet_delete_hw_interface (vnet_main_t * vnm, u32 hw_if_index)
/* Delete any sub-interfaces. */
{
u32 id, sw_if_index;
+ /* *INDENT-OFF* */
hash_foreach (id, sw_if_index, hw->sub_interface_sw_if_index_by_id, ({
vnet_delete_sw_interface (vnm, sw_if_index);
}));
+ /* *INDENT-ON* */
}
{
- vnet_hw_interface_nodes_t * dn;
- vnet_interface_output_runtime_t * rt = vlib_node_get_runtime_data (vm, hw->output_node_index);
+ vnet_hw_interface_nodes_t *dn;
+ vnet_interface_output_runtime_t *rt =
+ vlib_node_get_runtime_data (vm, hw->output_node_index);
/* Mark node runtime as deleted so output node (if called) will drop packets. */
rt->is_deleted = 1;
- vlib_node_rename (vm, hw->output_node_index, "interface-%d-output-deleted", hw_if_index);
- vlib_node_rename (vm, hw->tx_node_index, "interface-%d-tx-deleted", hw_if_index);
+ vlib_node_rename (vm, hw->output_node_index,
+ "interface-%d-output-deleted", hw_if_index);
+ vlib_node_rename (vm, hw->tx_node_index, "interface-%d-tx-deleted",
+ hw_if_index);
vec_add2 (im->deleted_hw_interface_nodes, dn, 1);
dn->tx_node_index = hw->tx_node_index;
dn->output_node_index = hw->output_node_index;
@@ -788,42 +855,49 @@ void vnet_delete_hw_interface (vnet_main_t * vnm, u32 hw_if_index)
pool_put (im->hw_interfaces, hw);
}
-static void serialize_vnet_hw_interface_set_class (serialize_main_t * m, va_list * va)
+static void
+serialize_vnet_hw_interface_set_class (serialize_main_t * m, va_list * va)
{
u32 hw_if_index = va_arg (*va, u32);
- char * hw_class_name = va_arg (*va, char *);
+ char *hw_class_name = va_arg (*va, char *);
serialize_integer (m, hw_if_index, sizeof (hw_if_index));
serialize_cstring (m, hw_class_name);
}
-static void unserialize_vnet_hw_interface_set_class (serialize_main_t * m, va_list * va)
+static void
+unserialize_vnet_hw_interface_set_class (serialize_main_t * m, va_list * va)
{
CLIB_UNUSED (mc_main_t * mc) = va_arg (*va, mc_main_t *);
- vnet_main_t * vnm = vnet_get_main();
+ vnet_main_t *vnm = vnet_get_main ();
u32 hw_if_index;
- char * hw_class_name;
- uword * p;
- clib_error_t * error;
+ char *hw_class_name;
+ uword *p;
+ clib_error_t *error;
unserialize_integer (m, &hw_if_index, sizeof (hw_if_index));
unserialize_cstring (m, &hw_class_name);
- p = hash_get (vnm->interface_main.hw_interface_class_by_name, hw_class_name);
+ p =
+ hash_get (vnm->interface_main.hw_interface_class_by_name, hw_class_name);
ASSERT (p != 0);
- error = vnet_hw_interface_set_class_helper (vnm, hw_if_index, p[0], /* redistribute */ 0);
+ error = vnet_hw_interface_set_class_helper (vnm, hw_if_index, p[0],
+ /* redistribute */ 0);
if (error)
clib_error_report (error);
}
-MC_SERIALIZE_MSG (vnet_hw_interface_set_class_msg, static) = {
- .name = "vnet_hw_interface_set_class",
- .serialize = serialize_vnet_hw_interface_set_class,
- .unserialize = unserialize_vnet_hw_interface_set_class,
-};
+MC_SERIALIZE_MSG (vnet_hw_interface_set_class_msg, static) =
+{
+.name = "vnet_hw_interface_set_class",.serialize =
+ serialize_vnet_hw_interface_set_class,.unserialize =
+ unserialize_vnet_hw_interface_set_class,};
-void vnet_hw_interface_init_for_class (vnet_main_t * vnm, u32 hw_if_index, u32 hw_class_index, u32 hw_instance)
+void
+vnet_hw_interface_init_for_class (vnet_main_t * vnm, u32 hw_if_index,
+ u32 hw_class_index, u32 hw_instance)
{
- vnet_hw_interface_t * hi = vnet_get_hw_interface (vnm, hw_if_index);
- vnet_hw_interface_class_t * hc = vnet_get_hw_interface_class (vnm, hw_class_index);
+ vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
+ vnet_hw_interface_class_t *hc =
+ vnet_get_hw_interface_class (vnm, hw_class_index);
hi->hw_class_index = hw_class_index;
hi->hw_instance = hw_instance;
@@ -831,14 +905,18 @@ void vnet_hw_interface_init_for_class (vnet_main_t * vnm, u32 hw_if_index, u32 h
}
static clib_error_t *
-vnet_hw_interface_set_class_helper (vnet_main_t * vnm, u32 hw_if_index, u32 hw_class_index, u32 redistribute)
+vnet_hw_interface_set_class_helper (vnet_main_t * vnm, u32 hw_if_index,
+ u32 hw_class_index, u32 redistribute)
{
- vnet_hw_interface_t * hi = vnet_get_hw_interface (vnm, hw_if_index);
- vnet_sw_interface_t * si = vnet_get_sw_interface (vnm, hi->sw_if_index);
- vnet_hw_interface_class_t * old_class = vnet_get_hw_interface_class (vnm, hi->hw_class_index);
- vnet_hw_interface_class_t * new_class = vnet_get_hw_interface_class (vnm, hw_class_index);
- vnet_device_class_t * dev_class = vnet_get_device_class (vnm, hi->dev_class_index);
- clib_error_t * error = 0;
+ vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
+ vnet_sw_interface_t *si = vnet_get_sw_interface (vnm, hi->sw_if_index);
+ vnet_hw_interface_class_t *old_class =
+ vnet_get_hw_interface_class (vnm, hi->hw_class_index);
+ vnet_hw_interface_class_t *new_class =
+ vnet_get_hw_interface_class (vnm, hw_class_index);
+ vnet_device_class_t *dev_class =
+ vnet_get_device_class (vnm, hi->dev_class_index);
+ clib_error_t *error = 0;
/* New class equals old class? Nothing to do. */
if (hi->hw_class_index == hw_class_index)
@@ -849,31 +927,40 @@ vnet_hw_interface_set_class_helper (vnet_main_t * vnm, u32 hw_if_index, u32 hw_c
if (redistribute)
{
if (si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)
- return clib_error_return (0, "%v must be admin down to change class from %s to %s",
+ return clib_error_return (0,
+ "%v must be admin down to change class from %s to %s",
hi->name, old_class->name, new_class->name);
/* Make sure interface supports given class. */
if ((new_class->is_valid_class_for_interface
- && ! new_class->is_valid_class_for_interface (vnm, hw_if_index, hw_class_index))
- || (dev_class ->is_valid_class_for_interface
- && ! dev_class->is_valid_class_for_interface (vnm, hw_if_index, hw_class_index)))
- return clib_error_return (0, "%v class cannot be changed from %s to %s",
+ && !new_class->is_valid_class_for_interface (vnm, hw_if_index,
+ hw_class_index))
+ || (dev_class->is_valid_class_for_interface
+ && !dev_class->is_valid_class_for_interface (vnm, hw_if_index,
+ hw_class_index)))
+ return clib_error_return (0,
+ "%v class cannot be changed from %s to %s",
hi->name, old_class->name, new_class->name);
if (vnm->vlib_main->mc_main)
{
- mc_serialize (vnm->vlib_main->mc_main, &vnet_hw_interface_set_class_msg, hw_if_index, new_class->name);
+ mc_serialize (vnm->vlib_main->mc_main,
+ &vnet_hw_interface_set_class_msg, hw_if_index,
+ new_class->name);
return 0;
}
}
if (old_class->hw_class_change)
- old_class->hw_class_change (vnm, hw_if_index, old_class->index, new_class->index);
+ old_class->hw_class_change (vnm, hw_if_index, old_class->index,
+ new_class->index);
- vnet_hw_interface_init_for_class (vnm, hw_if_index, new_class->index, /* instance */ ~0);
+ vnet_hw_interface_init_for_class (vnm, hw_if_index, new_class->index,
+ /* instance */ ~0);
if (new_class->hw_class_change)
- new_class->hw_class_change (vnm, hw_if_index, old_class->index, new_class->index);
+ new_class->hw_class_change (vnm, hw_if_index, old_class->index,
+ new_class->index);
if (dev_class->hw_class_change)
dev_class->hw_class_change (vnm, hw_if_index, new_class->index);
@@ -882,23 +969,27 @@ vnet_hw_interface_set_class_helper (vnet_main_t * vnm, u32 hw_if_index, u32 hw_c
}
clib_error_t *
-vnet_hw_interface_set_class (vnet_main_t * vnm, u32 hw_if_index, u32 hw_class_index)
-{ return vnet_hw_interface_set_class_helper (vnm, hw_if_index, hw_class_index, /* redistribute */ 1); }
+vnet_hw_interface_set_class (vnet_main_t * vnm, u32 hw_if_index,
+ u32 hw_class_index)
+{
+ return vnet_hw_interface_set_class_helper (vnm, hw_if_index, hw_class_index,
+ /* redistribute */ 1);
+}
static int
-vnet_hw_interface_rx_redirect_to_node_helper (vnet_main_t * vnm,
- u32 hw_if_index,
- u32 node_index,
- u32 redistribute)
+vnet_hw_interface_rx_redirect_to_node_helper (vnet_main_t * vnm,
+ u32 hw_if_index,
+ u32 node_index,
+ u32 redistribute)
{
- vnet_hw_interface_t * hi = vnet_get_hw_interface (vnm, hw_if_index);
- vnet_device_class_t * dev_class = vnet_get_device_class
+ vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
+ vnet_device_class_t *dev_class = vnet_get_device_class
(vnm, hi->dev_class_index);
if (redistribute)
{
/* $$$$ fixme someday maybe */
- ASSERT(vnm->vlib_main->mc_main == 0);
+ ASSERT (vnm->vlib_main->mc_main == 0);
}
if (dev_class->rx_redirect_to_node)
{
@@ -909,20 +1000,23 @@ vnet_hw_interface_rx_redirect_to_node_helper (vnet_main_t * vnm,
return VNET_API_ERROR_UNIMPLEMENTED;
}
-int vnet_hw_interface_rx_redirect_to_node (vnet_main_t * vnm, u32 hw_if_index,
- u32 node_index)
-{ return vnet_hw_interface_rx_redirect_to_node_helper (vnm, hw_if_index,
- node_index,
- 1 /* redistribute */); }
+int
+vnet_hw_interface_rx_redirect_to_node (vnet_main_t * vnm, u32 hw_if_index,
+ u32 node_index)
+{
+ return vnet_hw_interface_rx_redirect_to_node_helper (vnm, hw_if_index,
+ node_index,
+ 1 /* redistribute */ );
+}
word
vnet_sw_interface_compare (vnet_main_t * vnm,
uword sw_if_index0, uword sw_if_index1)
{
- vnet_sw_interface_t * sup0 = vnet_get_sup_sw_interface (vnm, sw_if_index0);
- vnet_sw_interface_t * sup1 = vnet_get_sup_sw_interface (vnm, sw_if_index1);
- vnet_hw_interface_t * h0 = vnet_get_hw_interface (vnm, sup0->hw_if_index);
- vnet_hw_interface_t * h1 = vnet_get_hw_interface (vnm, sup1->hw_if_index);
+ vnet_sw_interface_t *sup0 = vnet_get_sup_sw_interface (vnm, sw_if_index0);
+ vnet_sw_interface_t *sup1 = vnet_get_sup_sw_interface (vnm, sw_if_index1);
+ vnet_hw_interface_t *h0 = vnet_get_hw_interface (vnm, sup0->hw_if_index);
+ vnet_hw_interface_t *h1 = vnet_get_hw_interface (vnm, sup1->hw_if_index);
if (h0 != h1)
return vec_cmp (h0->name, h1->name);
@@ -933,8 +1027,8 @@ word
vnet_hw_interface_compare (vnet_main_t * vnm,
uword hw_if_index0, uword hw_if_index1)
{
- vnet_hw_interface_t * h0 = vnet_get_hw_interface (vnm, hw_if_index0);
- vnet_hw_interface_t * h1 = vnet_get_hw_interface (vnm, hw_if_index1);
+ vnet_hw_interface_t *h0 = vnet_get_hw_interface (vnm, hw_if_index0);
+ vnet_hw_interface_t *h1 = vnet_get_hw_interface (vnm, hw_if_index1);
if (h0 != h1)
return vec_cmp (h0->name, h1->name);
@@ -944,38 +1038,37 @@ vnet_hw_interface_compare (vnet_main_t * vnm,
clib_error_t *
vnet_interface_init (vlib_main_t * vm)
{
- vnet_main_t * vnm = vnet_get_main();
- vnet_interface_main_t * im = &vnm->interface_main;
- vlib_buffer_t * b = 0;
- vnet_buffer_opaque_t * o = 0;
+ vnet_main_t *vnm = vnet_get_main ();
+ vnet_interface_main_t *im = &vnm->interface_main;
+ vlib_buffer_t *b = 0;
+ vnet_buffer_opaque_t *o = 0;
/*
* Keep people from shooting themselves in the foot.
*/
- if (sizeof(b->opaque) != sizeof (vnet_buffer_opaque_t))
+ if (sizeof (b->opaque) != sizeof (vnet_buffer_opaque_t))
{
#define _(a) if (sizeof(o->a) > sizeof (o->unused)) \
clib_warning \
("FATAL: size of opaque union subtype %s is %d (max %d)", \
#a, sizeof(o->a), sizeof (o->unused));
- foreach_buffer_opaque_union_subtype;
+ foreach_buffer_opaque_union_subtype;
#undef _
- return clib_error_return
- (0, "FATAL: size of vlib buffer opaque %d, size of vnet opaque %d",
- sizeof(b->opaque), sizeof (vnet_buffer_opaque_t));
+ return clib_error_return
+ (0, "FATAL: size of vlib buffer opaque %d, size of vnet opaque %d",
+ sizeof (b->opaque), sizeof (vnet_buffer_opaque_t));
}
- im->sw_if_counter_lock = clib_mem_alloc_aligned (CLIB_CACHE_LINE_BYTES,
- CLIB_CACHE_LINE_BYTES);
- im->sw_if_counter_lock[0] = 1; /* should be no need */
+ im->sw_if_counter_lock = clib_mem_alloc_aligned (CLIB_CACHE_LINE_BYTES,
+ CLIB_CACHE_LINE_BYTES);
+ im->sw_if_counter_lock[0] = 1; /* should be no need */
- vec_validate (im->sw_if_counters,
- VNET_N_SIMPLE_INTERFACE_COUNTER - 1);
+ vec_validate (im->sw_if_counters, VNET_N_SIMPLE_INTERFACE_COUNTER - 1);
im->sw_if_counters[VNET_INTERFACE_COUNTER_DROP].name = "drops";
im->sw_if_counters[VNET_INTERFACE_COUNTER_PUNT].name = "punts";
- im->sw_if_counters[VNET_INTERFACE_COUNTER_IP4].name = "ip4";
- im->sw_if_counters[VNET_INTERFACE_COUNTER_IP6].name = "ip6";
+ im->sw_if_counters[VNET_INTERFACE_COUNTER_IP4].name = "ip4";
+ im->sw_if_counters[VNET_INTERFACE_COUNTER_IP6].name = "ip6";
im->sw_if_counters[VNET_INTERFACE_COUNTER_RX_NO_BUF].name = "rx-no-buf";
im->sw_if_counters[VNET_INTERFACE_COUNTER_RX_MISS].name = "rx-miss";
im->sw_if_counters[VNET_INTERFACE_COUNTER_RX_ERROR].name = "rx-error";
@@ -988,43 +1081,43 @@ vnet_interface_init (vlib_main_t * vm)
im->sw_if_counter_lock[0] = 0;
- im->device_class_by_name = hash_create_string (/* size */ 0,
+ im->device_class_by_name = hash_create_string ( /* size */ 0,
sizeof (uword));
{
- vnet_device_class_t * c;
+ vnet_device_class_t *c;
c = vnm->device_class_registrations;
while (c)
{
- c->index = vec_len (im->device_classes);
- hash_set_mem (im->device_class_by_name, c->name, c->index);
- vec_add1 (im->device_classes, c[0]);
- c = c->next_class_registration;
+ c->index = vec_len (im->device_classes);
+ hash_set_mem (im->device_class_by_name, c->name, c->index);
+ vec_add1 (im->device_classes, c[0]);
+ c = c->next_class_registration;
}
}
- im->hw_interface_class_by_name = hash_create_string (/* size */ 0,
+ im->hw_interface_class_by_name = hash_create_string ( /* size */ 0,
sizeof (uword));
- im->sw_if_index_by_sup_and_sub = hash_create_mem (0, sizeof(u64),
- sizeof (uword));
+ im->sw_if_index_by_sup_and_sub = hash_create_mem (0, sizeof (u64),
+ sizeof (uword));
{
- vnet_hw_interface_class_t * c;
+ vnet_hw_interface_class_t *c;
c = vnm->hw_interface_class_registrations;
-
+
while (c)
{
- c->index = vec_len (im->hw_interface_classes);
- hash_set_mem (im->hw_interface_class_by_name, c->name, c->index);
- vec_add1 (im->hw_interface_classes, c[0]);
- c = c->next_class_registration;
+ c->index = vec_len (im->hw_interface_classes);
+ hash_set_mem (im->hw_interface_class_by_name, c->name, c->index);
+ vec_add1 (im->hw_interface_classes, c[0]);
+ c = c->next_class_registration;
}
}
{
- clib_error_t * error;
+ clib_error_t *error;
if ((error = vlib_call_init_function (vm, vnet_interface_cli_init)))
return error;
@@ -1036,18 +1129,19 @@ vnet_interface_init (vlib_main_t * vm)
VLIB_INIT_FUNCTION (vnet_interface_init);
/* Kludge to renumber interface names [only!] */
-int vnet_interface_name_renumber (u32 sw_if_index, u32 new_show_dev_instance)
+int
+vnet_interface_name_renumber (u32 sw_if_index, u32 new_show_dev_instance)
{
int rv;
- vnet_main_t * vnm = vnet_get_main();
- vnet_interface_main_t * im = &vnm->interface_main;
- vnet_hw_interface_t * hi = vnet_get_sup_hw_interface (vnm, sw_if_index);
+ vnet_main_t *vnm = vnet_get_main ();
+ vnet_interface_main_t *im = &vnm->interface_main;
+ vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (vnm, sw_if_index);
- vnet_device_class_t * dev_class = vnet_get_device_class
+ vnet_device_class_t *dev_class = vnet_get_device_class
(vnm, hi->dev_class_index);
if (dev_class->name_renumber == 0 || dev_class->format_device_name == 0)
- return VNET_API_ERROR_UNIMPLEMENTED;
+ return VNET_API_ERROR_UNIMPLEMENTED;
rv = dev_class->name_renumber (hi, new_show_dev_instance);
@@ -1057,72 +1151,81 @@ int vnet_interface_name_renumber (u32 sw_if_index, u32 new_show_dev_instance)
hash_unset_mem (im->hw_interface_by_name, hi->name);
vec_free (hi->name);
/* Use the mapping we set up to call it Ishmael */
- hi->name = format (0, "%U", dev_class->format_device_name,
- hi->dev_instance);
-
+ hi->name = format (0, "%U", dev_class->format_device_name,
+ hi->dev_instance);
+
hash_set_mem (im->hw_interface_by_name, hi->name, hi->hw_if_index);
return rv;
}
-int vnet_interface_add_del_feature(vnet_main_t * vnm,
- vlib_main_t *vm,
- u32 sw_if_index,
- intf_output_feat_t feature,
- int is_add)
+int
+vnet_interface_add_del_feature (vnet_main_t * vnm,
+ vlib_main_t * vm,
+ u32 sw_if_index,
+ intf_output_feat_t feature, int is_add)
{
- vnet_sw_interface_t * sw;
+ vnet_sw_interface_t *sw;
- sw = vnet_get_sw_interface(vnm, sw_if_index);
+ sw = vnet_get_sw_interface (vnm, sw_if_index);
- if (is_add) {
+ if (is_add)
+ {
- sw->output_feature_bitmap |= (1 << feature);
- sw->output_feature_bitmap |= (1<< INTF_OUTPUT_FEAT_DONE);
+ sw->output_feature_bitmap |= (1 << feature);
+ sw->output_feature_bitmap |= (1 << INTF_OUTPUT_FEAT_DONE);
- } else { /* delete */
+ }
+ else
+ { /* delete */
- sw->output_feature_bitmap &= ~(1<<feature);
- if (sw->output_feature_bitmap == (1 << INTF_OUTPUT_FEAT_DONE))
- sw->output_feature_bitmap = 0;
+ sw->output_feature_bitmap &= ~(1 << feature);
+ if (sw->output_feature_bitmap == (1 << INTF_OUTPUT_FEAT_DONE))
+ sw->output_feature_bitmap = 0;
- }
+ }
return 0;
}
clib_error_t *
-vnet_rename_interface (vnet_main_t * vnm,
- u32 hw_if_index,
- char * new_name)
+vnet_rename_interface (vnet_main_t * vnm, u32 hw_if_index, char *new_name)
{
- vnet_interface_main_t * im = &vnm->interface_main;
- vlib_main_t * vm = vnm->vlib_main;
- vnet_hw_interface_t* hw;
- u8* old_name;
- clib_error_t * error = 0;
+ vnet_interface_main_t *im = &vnm->interface_main;
+ vlib_main_t *vm = vnm->vlib_main;
+ vnet_hw_interface_t *hw;
+ u8 *old_name;
+ clib_error_t *error = 0;
- hw = vnet_get_hw_interface(vnm, hw_if_index);
+ hw = vnet_get_hw_interface (vnm, hw_if_index);
if (!hw)
{
return clib_error_return (0,
- "unable to find hw interface for index %u",
- hw_if_index);
+ "unable to find hw interface for index %u",
+ hw_if_index);
}
old_name = hw->name;
- // set new hw->name
+ /* set new hw->name */
hw->name = format (0, "%s", new_name);
- // remove the old name to hw_if_index mapping and install the new one
+ /* remove the old name to hw_if_index mapping and install the new one */
hash_unset_mem (im->hw_interface_by_name, old_name);
hash_set_mem (im->hw_interface_by_name, hw->name, hw_if_index);
- // rename tx/output nodes
+ /* rename tx/output nodes */
vlib_node_rename (vm, hw->tx_node_index, "%v-tx", hw->name);
vlib_node_rename (vm, hw->output_node_index, "%v-output", hw->name);
- // free the old name vector
+ /* free the old name vector */
vec_free (old_name);
return error;
}
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/interface.h b/vnet/vnet/interface.h
index 11bb2346185..7738bb6edc7 100644
--- a/vnet/vnet/interface.h
+++ b/vnet/vnet/interface.h
@@ -47,18 +47,18 @@ struct vnet_hw_interface_t;
struct vnet_sw_interface_t;
/* Interface up/down callback. */
-typedef clib_error_t * (vnet_interface_function_t)
+typedef clib_error_t *(vnet_interface_function_t)
(struct vnet_main_t * vnm, u32 if_index, u32 flags);
/* Sub-interface add/del callback. */
-typedef clib_error_t * (vnet_subif_add_del_function_t)
+typedef clib_error_t *(vnet_subif_add_del_function_t)
(struct vnet_main_t * vnm, u32 if_index,
- struct vnet_sw_interface_t * template,
- int is_add);
+ struct vnet_sw_interface_t * template, int is_add);
-typedef struct _vnet_interface_function_list_elt {
- struct _vnet_interface_function_list_elt * next_interface_function;
- clib_error_t * (*fp) (struct vnet_main_t * vnm, u32 if_index, u32 flags);
+typedef struct _vnet_interface_function_list_elt
+{
+ struct _vnet_interface_function_list_elt *next_interface_function;
+ clib_error_t *(*fp) (struct vnet_main_t * vnm, u32 if_index, u32 flags);
} _vnet_interface_function_list_elt_t;
#define _VNET_INTERFACE_FUNCTION_DECL(f,tag) \
@@ -73,7 +73,7 @@ static void __vnet_interface_function_init_##tag##_##f (void) \
init_function.next_interface_function = vnm->tag##_functions; \
vnm->tag##_functions = &init_function; \
init_function.fp = (void *) &f; \
-}
+}
#define VNET_HW_INTERFACE_ADD_DEL_FUNCTION(f) \
_VNET_INTERFACE_FUNCTION_DECL(f,hw_interface_add_del)
@@ -85,66 +85,68 @@ static void __vnet_interface_function_init_##tag##_##f (void) \
_VNET_INTERFACE_FUNCTION_DECL(f,sw_interface_admin_up_down)
/* A class of hardware interface devices. */
-typedef struct _vnet_device_class {
+typedef struct _vnet_device_class
+{
/* Index into main vector. */
u32 index;
/* Device name (e.g. "FOOBAR 1234a"). */
- char * name;
+ char *name;
/* Function to call when hardware interface is added/deleted. */
- vnet_interface_function_t * interface_add_del_function;
+ vnet_interface_function_t *interface_add_del_function;
/* Function to bring device administratively up/down. */
- vnet_interface_function_t * admin_up_down_function;
+ vnet_interface_function_t *admin_up_down_function;
/* Function to call when sub-interface is added/deleted */
- vnet_subif_add_del_function_t * subif_add_del_function;
+ vnet_subif_add_del_function_t *subif_add_del_function;
/* Redistribute flag changes/existence of this interface class. */
u32 redistribute;
/* Transmit function. */
- vlib_node_function_t * tx_function;
+ vlib_node_function_t *tx_function;
/* Error strings indexed by error code for this node. */
- char ** tx_function_error_strings;
+ char **tx_function_error_strings;
/* Number of error codes used by this node. */
u32 tx_function_n_errors;
/* Renumber device name [only!] support, a control-plane kludge */
- int (*name_renumber) (struct vnet_hw_interface_t * hi, u32 new_dev_instance);
+ int (*name_renumber) (struct vnet_hw_interface_t * hi,
+ u32 new_dev_instance);
/* Format device instance as name. */
- format_function_t * format_device_name;
+ format_function_t *format_device_name;
/* Parse function for device name. */
- unformat_function_t * unformat_device_name;
+ unformat_function_t *unformat_device_name;
/* Format device verbosely for this class. */
- format_function_t * format_device;
+ format_function_t *format_device;
/* Trace buffer format for TX function. */
- format_function_t * format_tx_trace;
+ format_function_t *format_tx_trace;
/* Function to clear hardware counters for device. */
- void (* clear_counters) (u32 dev_class_instance);
+ void (*clear_counters) (u32 dev_class_instance);
- uword (* is_valid_class_for_interface) (struct vnet_main_t * vnm, u32 hw_if_index, u32 hw_class_index);
+ uword (*is_valid_class_for_interface) (struct vnet_main_t * vnm,
+ u32 hw_if_index,
+ u32 hw_class_index);
/* Called when hardware class of an interface changes. */
- void ( * hw_class_change) (struct vnet_main_t * vnm,
- u32 hw_if_index,
- u32 new_hw_class_index);
+ void (*hw_class_change) (struct vnet_main_t * vnm,
+ u32 hw_if_index, u32 new_hw_class_index);
/* Called to redirect traffic from a specific interface instance */
- void (* rx_redirect_to_node) (struct vnet_main_t * vnm,
- u32 hw_if_index,
- u32 node_index);
+ void (*rx_redirect_to_node) (struct vnet_main_t * vnm,
+ u32 hw_if_index, u32 node_index);
/* Link-list of all device classes set up by constructors created below */
- struct _vnet_device_class * next_class_registration;
+ struct _vnet_device_class *next_class_registration;
/* Do not splice vnet_interface_output_node into TX path */
u8 no_flatten_output_chains;
@@ -161,7 +163,7 @@ static void __vnet_add_device_class_registration_##x (void) \
x.next_class_registration = vnm->device_class_registrations; \
vnm->device_class_registrations = &x; \
} \
-__VA_ARGS__ vnet_device_class_t x
+__VA_ARGS__ vnet_device_class_t x
#define VLIB_DEVICE_TX_FUNCTION_CLONE_TEMPLATE(arch, fn, tgt) \
uword \
@@ -190,57 +192,60 @@ __VA_ARGS__ vnet_device_class_t x
/* Layer-2 (e.g. Ethernet) interface class. */
-typedef struct _vnet_hw_interface_class {
+typedef struct _vnet_hw_interface_class
+{
/* Index into main vector. */
u32 index;
/* Class name (e.g. "Ethernet"). */
- char * name;
+ char *name;
/* Function to call when hardware interface is added/deleted. */
- vnet_interface_function_t * interface_add_del_function;
+ vnet_interface_function_t *interface_add_del_function;
/* Function to bring interface administratively up/down. */
- vnet_interface_function_t * admin_up_down_function;
+ vnet_interface_function_t *admin_up_down_function;
/* Function to call when link state changes. */
- vnet_interface_function_t * link_up_down_function;
+ vnet_interface_function_t *link_up_down_function;
/* Format function to display interface name. */
- format_function_t * format_interface_name;
+ format_function_t *format_interface_name;
/* Format function to display interface address. */
- format_function_t * format_address;
+ format_function_t *format_address;
/* Format packet header for this interface class. */
- format_function_t * format_header;
+ format_function_t *format_header;
/* Format device verbosely for this class. */
- format_function_t * format_device;
+ format_function_t *format_device;
/* Parser for hardware (e.g. ethernet) address. */
- unformat_function_t * unformat_hw_address;
+ unformat_function_t *unformat_hw_address;
/* Parser for packet header for e.g. rewrite string. */
- unformat_function_t * unformat_header;
+ unformat_function_t *unformat_header;
/* Forms adjacency for given l3 packet type and destination address.
Returns number of bytes in adjacency. */
- uword (* set_rewrite) (struct vnet_main_t * vnm,
- u32 sw_if_index,
- u32 l3_packet_type,
- void * dst_address,
- void * rewrite,
- uword max_rewrite_bytes);
+ uword (*set_rewrite) (struct vnet_main_t * vnm,
+ u32 sw_if_index,
+ u32 l3_packet_type,
+ void *dst_address,
+ void *rewrite, uword max_rewrite_bytes);
- uword (* is_valid_class_for_interface) (struct vnet_main_t * vnm, u32 hw_if_index, u32 hw_class_index);
+ uword (*is_valid_class_for_interface) (struct vnet_main_t * vnm,
+ u32 hw_if_index,
+ u32 hw_class_index);
/* Called when hw interface class is changed and old hardware instance
may want to be deleted. */
- void (* hw_class_change) (struct vnet_main_t * vnm, u32 hw_if_index, u32 old_class_index, u32 new_class_index);
+ void (*hw_class_change) (struct vnet_main_t * vnm, u32 hw_if_index,
+ u32 old_class_index, u32 new_class_index);
/* List of hw interface classes, built by constructors */
- struct _vnet_hw_interface_class * next_class_registration;
+ struct _vnet_hw_interface_class *next_class_registration;
} vnet_hw_interface_class_t;
@@ -258,9 +263,10 @@ __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 struct vnet_hw_interface_t
+{
/* Interface name. */
- u8 * name;
+ u8 *name;
u32 flags;
/* Hardware link state is up. */
@@ -295,7 +301,7 @@ typedef struct vnet_hw_interface_t {
/* Hardware address as vector. Zero (e.g. zero-length vector) if no
address for this class (e.g. PPP). */
- u8 * hw_address;
+ u8 *hw_address;
/* Interface is up as far as software is concerned. */
/* NAME.{output,tx} nodes for this interface. */
@@ -339,7 +345,7 @@ typedef struct vnet_hw_interface_t {
u32 max_l3_packet_bytes[VLIB_N_RX_TX];
/* Hash table mapping sub interface id to sw_if_index. */
- uword * sub_interface_sw_if_index_by_id;
+ uword *sub_interface_sw_if_index_by_id;
/* Count of number of L2 subinterfaces */
u32 l2_if_count;
@@ -356,7 +362,8 @@ typedef struct vnet_hw_interface_t {
extern vnet_device_class_t vnet_local_interface_device_class;
-typedef enum {
+typedef enum
+{
/* A hw interface. */
VNET_SW_INTERFACE_TYPE_HARDWARE,
@@ -364,26 +371,32 @@ typedef enum {
VNET_SW_INTERFACE_TYPE_SUB,
} vnet_sw_interface_type_t;
-typedef struct {
- // Subinterface ID. A number 0-N to uniquely identify this subinterface under the
- // main (parent?) interface
- u32 id;
-
- // Classification data. Used to associate packet header with subinterface.
- struct {
+typedef struct
+{
+ /*
+ * Subinterface ID. A number 0-N to uniquely identify
+ * this subinterface under the main (parent?) interface
+ */
+ u32 id;
+
+ /* Classification data. Used to associate packet header with subinterface. */
+ struct
+ {
u16 outer_vlan_id;
u16 inner_vlan_id;
- union {
+ union
+ {
u16 raw_flags;
- struct {
- u16 no_tags:1;
- u16 one_tag:1;
- u16 two_tags:1;
- u16 dot1ad:1; // 0 = dot1q, 1=dot1ad
- u16 exact_match:1;
- u16 default_sub:1;
- u16 outer_vlan_id_any:1;
- u16 inner_vlan_id_any:1;
+ struct
+ {
+ u16 no_tags:1;
+ u16 one_tag:1;
+ u16 two_tags:1;
+ u16 dot1ad:1; /* 0 = dot1q, 1=dot1ad */
+ u16 exact_match:1;
+ u16 default_sub:1;
+ u16 outer_vlan_id_any:1;
+ u16 inner_vlan_id_any:1;
} flags;
};
} eth;
@@ -392,8 +405,9 @@ typedef struct {
/* Software-interface. This corresponds to a Ethernet VLAN, ATM vc, a
tunnel, etc. Configuration (e.g. IP address) gets attached to
software interface. */
-typedef struct {
- vnet_sw_interface_type_t type : 16;
+typedef struct
+{
+ vnet_sw_interface_type_t type:16;
u16 flags;
/* Interface is "up" meaning adminstratively up.
@@ -424,19 +438,18 @@ typedef struct {
u32 output_feature_bitmap;
- union {
+ union
+ {
/* VNET_SW_INTERFACE_TYPE_HARDWARE. */
u32 hw_if_index;
/* VNET_SW_INTERFACE_TYPE_SUB. */
vnet_sub_interface_t sub;
-
- /* SW interfaces are sorted by type and key. */
- // u32 sort_key;
};
} vnet_sw_interface_t;
-typedef enum {
+typedef enum
+{
/* Simple counters. */
VNET_INTERFACE_COUNTER_DROP = 0,
VNET_INTERFACE_COUNTER_PUNT = 1,
@@ -453,57 +466,62 @@ typedef enum {
VNET_N_COMBINED_INTERFACE_COUNTER = 2,
} vnet_interface_counter_type_t;
-typedef struct {
+typedef struct
+{
u32 output_node_index;
u32 tx_node_index;
} vnet_hw_interface_nodes_t;
-typedef struct {
+typedef struct
+{
/* Hardware interfaces. */
- vnet_hw_interface_t * hw_interfaces;
+ vnet_hw_interface_t *hw_interfaces;
/* Hash table mapping HW interface name to index. */
- uword * hw_interface_by_name;
+ uword *hw_interface_by_name;
/* Vectors if hardware interface classes and device classes. */
- vnet_hw_interface_class_t * hw_interface_classes;
- vnet_device_class_t * device_classes;
+ vnet_hw_interface_class_t *hw_interface_classes;
+ vnet_device_class_t *device_classes;
/* Hash table mapping name to hw interface/device class. */
- uword * hw_interface_class_by_name;
- uword * device_class_by_name;
+ uword *hw_interface_class_by_name;
+ uword *device_class_by_name;
/* Software interfaces. */
- vnet_sw_interface_t * sw_interfaces;
+ vnet_sw_interface_t *sw_interfaces;
/* Hash table mapping sub intfc sw_if_index by sup sw_if_index and sub id */
- uword * sw_if_index_by_sup_and_sub;
+ uword *sw_if_index_by_sup_and_sub;
/* Software interface counters both simple and combined
packet and byte counters. */
volatile u32 *sw_if_counter_lock;
- vlib_simple_counter_main_t * sw_if_counters;
- vlib_combined_counter_main_t * combined_sw_if_counters;
+ vlib_simple_counter_main_t *sw_if_counters;
+ vlib_combined_counter_main_t *combined_sw_if_counters;
- vnet_hw_interface_nodes_t * deleted_hw_interface_nodes;
+ vnet_hw_interface_nodes_t *deleted_hw_interface_nodes;
/* pcap drop tracing */
int drop_pcap_enable;
pcap_main_t pcap_main;
- u8 * pcap_filename;
+ u8 *pcap_filename;
u32 pcap_sw_if_index;
u32 pcap_pkts_to_capture;
- uword * pcap_drop_filter_hash;
+ uword *pcap_drop_filter_hash;
} vnet_interface_main_t;
-static inline void vnet_interface_counter_lock (vnet_interface_main_t *im)
+static inline void
+vnet_interface_counter_lock (vnet_interface_main_t * im)
{
if (im->sw_if_counter_lock)
while (__sync_lock_test_and_set (im->sw_if_counter_lock, 1))
/* zzzz */ ;
}
-static inline void vnet_interface_counter_unlock (vnet_interface_main_t *im)
+
+static inline void
+vnet_interface_counter_unlock (vnet_interface_main_t * im)
{
if (im->sw_if_counter_lock)
*im->sw_if_counter_lock = 0;
@@ -521,19 +539,28 @@ int vnet_interface_name_renumber (u32 sw_if_index, u32 new_show_dev_instance);
#define foreach_intf_output_feat \
_(IPSEC, "ipsec-output")
-// Feature bitmap positions
-typedef enum {
+/* Feature bitmap positions */
+typedef enum
+{
#define _(sym,str) INTF_OUTPUT_FEAT_##sym,
foreach_intf_output_feat
#undef _
- INTF_OUTPUT_N_FEAT,
+ INTF_OUTPUT_N_FEAT,
} intf_output_feat_t;
/* flag that we are done with feature path */
#define INTF_OUTPUT_FEAT_DONE INTF_OUTPUT_N_FEAT
-int vnet_interface_add_del_feature(struct vnet_main_t * vnm, vlib_main_t * vm,
- u32 sw_if_index,
- intf_output_feat_t feature, int is_add);
+int vnet_interface_add_del_feature (struct vnet_main_t *vnm, vlib_main_t * vm,
+ u32 sw_if_index,
+ intf_output_feat_t feature, int is_add);
#endif /* included_vnet_interface_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/interface_cli.c b/vnet/vnet/interface_cli.c
index 9052f623444..7b9f5458eb5 100644
--- a/vnet/vnet/interface_cli.c
+++ b/vnet/vnet/interface_cli.c
@@ -41,12 +41,13 @@
#include <vnet/ip/ip.h>
#include <vppinfra/bitmap.h>
-static int compare_interface_names (void *a1, void *a2)
+static int
+compare_interface_names (void *a1, void *a2)
{
- u32 * hi1 = a1;
- u32 * hi2 = a2;
+ u32 *hi1 = a1;
+ u32 *hi2 = a2;
- return vnet_hw_interface_compare (vnet_get_main(), *hi1, *hi2);
+ return vnet_hw_interface_compare (vnet_get_main (), *hi1, *hi2);
}
static clib_error_t *
@@ -54,26 +55,27 @@ show_or_clear_hw_interfaces (vlib_main_t * vm,
unformat_input_t * input,
vlib_cli_command_t * cmd)
{
- clib_error_t * error = 0;
- vnet_main_t * vnm = vnet_get_main();
- vnet_interface_main_t * im = &vnm->interface_main;
- vnet_hw_interface_t * hi;
- u32 hw_if_index, * hw_if_indices = 0;
+ clib_error_t *error = 0;
+ vnet_main_t *vnm = vnet_get_main ();
+ vnet_interface_main_t *im = &vnm->interface_main;
+ vnet_hw_interface_t *hi;
+ u32 hw_if_index, *hw_if_indices = 0;
int i, verbose = -1, is_show, show_bond = 0;
is_show = strstr (cmd->path, "show") != 0;
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
/* See if user wants to show a specific interface. */
- if (unformat (input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
- vec_add1 (hw_if_indices, hw_if_index);
+ if (unformat
+ (input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
+ vec_add1 (hw_if_indices, hw_if_index);
/* See if user wants to show an interface with a specific hw_if_index. */
else if (unformat (input, "%u", &hw_if_index))
- vec_add1 (hw_if_indices, hw_if_index);
+ vec_add1 (hw_if_indices, hw_if_index);
else if (unformat (input, "verbose"))
- verbose = 1; /* this is also the default */
+ verbose = 1; /* this is also the default */
else if (unformat (input, "detail"))
verbose = 2;
@@ -82,10 +84,11 @@ show_or_clear_hw_interfaces (vlib_main_t * vm,
verbose = 0;
else if (unformat (input, "bond"))
- {
- show_bond = 1;
- if (verbose < 0) verbose = 0; /* default to brief for link bonding */
- }
+ {
+ show_bond = 1;
+ if (verbose < 0)
+ verbose = 0; /* default to brief for link bonding */
+ }
else
{
@@ -94,13 +97,14 @@ show_or_clear_hw_interfaces (vlib_main_t * vm,
goto done;
}
}
-
+
/* Gather interfaces. */
if (vec_len (hw_if_indices) == 0)
pool_foreach (hi, im->hw_interfaces,
vec_add1 (hw_if_indices, hi - im->hw_interfaces));
- if (verbose < 0) verbose = 1; /* default to verbose (except bond) */
+ if (verbose < 0)
+ verbose = 1; /* default to verbose (except bond) */
if (is_show)
{
@@ -111,22 +115,25 @@ show_or_clear_hw_interfaces (vlib_main_t * vm,
for (i = 0; i < vec_len (hw_if_indices); i++)
{
hi = vnet_get_hw_interface (vnm, hw_if_indices[i]);
- if (show_bond == 0) /* show all interfaces */
- vlib_cli_output (vm, "%U\n", format_vnet_hw_interface, vnm,
- hi, verbose);
- else if ((hi->bond_info) &&
+ if (show_bond == 0) /* show all interfaces */
+ vlib_cli_output (vm, "%U\n", format_vnet_hw_interface, vnm,
+ hi, verbose);
+ else if ((hi->bond_info) &&
(hi->bond_info != VNET_HW_INTERFACE_BOND_INFO_SLAVE))
- { /* show only bonded interface and all its slave interfaces */
+ { /* show only bonded interface and all its slave interfaces */
int hw_idx;
- vnet_hw_interface_t * shi;
- vlib_cli_output (vm, "%U\n", format_vnet_hw_interface, vnm,
+ vnet_hw_interface_t *shi;
+ vlib_cli_output (vm, "%U\n", format_vnet_hw_interface, vnm,
hi, verbose);
+
+ /* *INDENT-OFF* */
clib_bitmap_foreach (hw_idx, hi->bond_info,
- ({
- shi = vnet_get_hw_interface(vnm, hw_idx);
- vlib_cli_output (vm, "%U\n",
- format_vnet_hw_interface, vnm, shi, verbose);
- }));
+ ({
+ shi = vnet_get_hw_interface(vnm, hw_idx);
+ vlib_cli_output (vm, "%U\n",
+ format_vnet_hw_interface, vnm, shi, verbose);
+ }));
+ /* *INDENT-ON* */
}
}
}
@@ -134,84 +141,92 @@ show_or_clear_hw_interfaces (vlib_main_t * vm,
{
for (i = 0; i < vec_len (hw_if_indices); i++)
{
- vnet_device_class_t * dc;
+ vnet_device_class_t *dc;
hi = vnet_get_hw_interface (vnm, hw_if_indices[i]);
dc = vec_elt_at_index (im->device_classes, hi->dev_class_index);
-
+
if (dc->clear_counters)
dc->clear_counters (hi->dev_instance);
}
}
- done:
+done:
vec_free (hw_if_indices);
return error;
}
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (show_hw_interfaces_command, static) = {
.path = "show hardware-interfaces",
.short_help = "show hardware-interfaces [brief|verbose|detail] [bond] [<if-name1> <if-name2> ...]",
.function = show_or_clear_hw_interfaces,
};
+/* *INDENT-ON* */
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (clear_hw_interface_counters_command, static) = {
.path = "clear hardware-interfaces",
.short_help = "Clear hardware interfaces statistics",
.function = show_or_clear_hw_interfaces,
};
+/* *INDENT-ON* */
-static int sw_interface_name_compare (void *a1, void *a2)
+static int
+sw_interface_name_compare (void *a1, void *a2)
{
vnet_sw_interface_t *si1 = a1;
vnet_sw_interface_t *si2 = a2;
- return vnet_sw_interface_compare (vnet_get_main(),
- si1->sw_if_index, si2->sw_if_index);
+ return vnet_sw_interface_compare (vnet_get_main (),
+ si1->sw_if_index, si2->sw_if_index);
}
static clib_error_t *
show_sw_interfaces (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
+ unformat_input_t * input, vlib_cli_command_t * cmd)
{
- clib_error_t * error = 0;
- vnet_main_t * vnm = vnet_get_main();
- vnet_interface_main_t * im = &vnm->interface_main;
- vnet_sw_interface_t * si, * sorted_sis = 0;
+ clib_error_t *error = 0;
+ vnet_main_t *vnm = vnet_get_main ();
+ vnet_interface_main_t *im = &vnm->interface_main;
+ vnet_sw_interface_t *si, *sorted_sis = 0;
u8 show_addresses = 0;
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
- u32 sw_if_index;
+ u32 sw_if_index;
/* See if user wants to show specific interface */
- if (unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
+ if (unformat
+ (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
{
- si = pool_elt_at_index (im->sw_interfaces, sw_if_index);
+ si = pool_elt_at_index (im->sw_interfaces, sw_if_index);
vec_add1 (sorted_sis, si[0]);
}
-
else if (unformat (input, "address") || unformat (input, "addr"))
- show_addresses = 1;
-
+ show_addresses = 1;
else
- {
+ {
error = clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
goto done;
- }
+ }
}
if (!show_addresses)
- vlib_cli_output (vm, "%U\n", format_vnet_sw_interface, vnm, 0);
+ vlib_cli_output (vm, "%U\n", format_vnet_sw_interface, vnm, 0);
- if (vec_len (sorted_sis) == 0) /* Get all interfaces */
+ if (vec_len (sorted_sis) == 0) /* Get all interfaces */
{
/* Gather interfaces. */
- sorted_sis = vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
+ sorted_sis =
+ vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
_vec_len (sorted_sis) = 0;
- pool_foreach (si, im->sw_interfaces, ({ vec_add1 (sorted_sis, si[0]); }));
+ pool_foreach (si, im->sw_interfaces, (
+ {
+ vec_add1 (sorted_sis, si[0]);
+ }
+ ));
/* Sort by name. */
vec_sort_with_function (sorted_sis, sw_interface_name_compare);
@@ -220,154 +235,163 @@ show_sw_interfaces (vlib_main_t * vm,
if (show_addresses)
{
vec_foreach (si, sorted_sis)
- {
- l2input_main_t * l2m = &l2input_main;
- ip4_main_t * im4 = &ip4_main;
- ip6_main_t * im6 = &ip6_main;
- ip_lookup_main_t * lm4 = &im4->lookup_main;
- ip_lookup_main_t * lm6 = &im6->lookup_main;
- ip_interface_address_t * ia = 0;
- ip4_address_t * r4;
- ip6_address_t * r6;
- u32 fib_index4 = 0, fib_index6 = 0;
- ip4_fib_t * fib4;
- ip6_fib_t * fib6;
- l2_input_config_t * config;
-
- if (vec_len (im4->fib_index_by_sw_if_index) > si->sw_if_index)
- fib_index4 = vec_elt (im4->fib_index_by_sw_if_index,
- si->sw_if_index);
-
- if (vec_len (im6->fib_index_by_sw_if_index) > si->sw_if_index)
- fib_index6 = vec_elt (im6->fib_index_by_sw_if_index,
- si->sw_if_index);
-
- fib4 = vec_elt_at_index (im4->fibs, fib_index4);
- fib6 = vec_elt_at_index (im6->fibs, fib_index6);
-
- if (si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED)
- vlib_cli_output
- (vm, "%U (%s): \n unnumbered, use %U",
- format_vnet_sw_if_index_name,
- vnm, si->sw_if_index,
- (si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? "up" : "dn",
- format_vnet_sw_if_index_name,
- vnm, si->unnumbered_sw_if_index);
-
- else
- {
- vlib_cli_output (vm, "%U (%s):",
- format_vnet_sw_if_index_name,
- vnm, si->sw_if_index,
- (si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)
- ? "up" : "dn");
- }
-
- /* Display any L2 addressing info */
- vec_validate(l2m->configs, si->sw_if_index);
- config = vec_elt_at_index(l2m->configs, si->sw_if_index);
- if (config->bridge)
- {
- u32 bd_id = l2input_main.bd_configs[config->bd_index].bd_id;
- vlib_cli_output (vm, " l2 bridge bd_id %d%s%d", bd_id,
- config->bvi ? " bvi shg " : " shg ", config->shg);
- }
- else if (config->xconnect)
- {
- vlib_cli_output (vm, " l2 xconnect %U",
- format_vnet_sw_if_index_name,
- vnm, config->output_sw_if_index);
- }
-
- /* Display any IP4 addressing info */
- foreach_ip_interface_address (lm4, ia, si->sw_if_index,
+ {
+ l2input_main_t *l2m = &l2input_main;
+ ip4_main_t *im4 = &ip4_main;
+ ip6_main_t *im6 = &ip6_main;
+ ip_lookup_main_t *lm4 = &im4->lookup_main;
+ ip_lookup_main_t *lm6 = &im6->lookup_main;
+ ip_interface_address_t *ia = 0;
+ ip4_address_t *r4;
+ ip6_address_t *r6;
+ u32 fib_index4 = 0, fib_index6 = 0;
+ ip4_fib_t *fib4;
+ ip6_fib_t *fib6;
+ l2_input_config_t *config;
+
+ if (vec_len (im4->fib_index_by_sw_if_index) > si->sw_if_index)
+ fib_index4 = vec_elt (im4->fib_index_by_sw_if_index,
+ si->sw_if_index);
+
+ if (vec_len (im6->fib_index_by_sw_if_index) > si->sw_if_index)
+ fib_index6 = vec_elt (im6->fib_index_by_sw_if_index,
+ si->sw_if_index);
+
+ fib4 = vec_elt_at_index (im4->fibs, fib_index4);
+ fib6 = vec_elt_at_index (im6->fibs, fib_index6);
+
+ if (si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED)
+ vlib_cli_output
+ (vm, "%U (%s): \n unnumbered, use %U",
+ format_vnet_sw_if_index_name,
+ vnm, si->sw_if_index,
+ (si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? "up" : "dn",
+ format_vnet_sw_if_index_name, vnm, si->unnumbered_sw_if_index);
+
+ else
+ {
+ vlib_cli_output (vm, "%U (%s):",
+ format_vnet_sw_if_index_name,
+ vnm, si->sw_if_index,
+ (si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)
+ ? "up" : "dn");
+ }
+
+ /* Display any L2 addressing info */
+ vec_validate (l2m->configs, si->sw_if_index);
+ config = vec_elt_at_index (l2m->configs, si->sw_if_index);
+ if (config->bridge)
+ {
+ u32 bd_id = l2input_main.bd_configs[config->bd_index].bd_id;
+ vlib_cli_output (vm, " l2 bridge bd_id %d%s%d", bd_id,
+ config->bvi ? " bvi shg " : " shg ",
+ config->shg);
+ }
+ else if (config->xconnect)
+ {
+ vlib_cli_output (vm, " l2 xconnect %U",
+ format_vnet_sw_if_index_name,
+ vnm, config->output_sw_if_index);
+ }
+
+ /* Display any IP4 addressing info */
+ /* *INDENT-OFF* */
+ foreach_ip_interface_address (lm4, ia, si->sw_if_index,
1 /* honor unnumbered */,
({
r4 = ip_interface_address_get_address (lm4, ia);
if (fib4->table_id)
{
- vlib_cli_output (vm, " %U/%d table %d",
- format_ip4_address, r4,
+ vlib_cli_output (vm, " %U/%d table %d",
+ format_ip4_address, r4,
ia->address_length,
fib4->table_id);
}
else
{
- vlib_cli_output (vm, " %U/%d",
- format_ip4_address, r4,
+ vlib_cli_output (vm, " %U/%d",
+ format_ip4_address, r4,
ia->address_length);
}
}));
+ /* *INDENT-ON* */
- /* Display any IP6 addressing info */
- foreach_ip_interface_address (lm6, ia, si->sw_if_index,
+ /* Display any IP6 addressing info */
+ /* *INDENT-OFF* */
+ foreach_ip_interface_address (lm6, ia, si->sw_if_index,
1 /* honor unnumbered */,
({
r6 = ip_interface_address_get_address (lm6, ia);
if (fib6->table_id)
{
- vlib_cli_output (vm, " %U/%d table %d",
- format_ip6_address, r6,
+ vlib_cli_output (vm, " %U/%d table %d",
+ format_ip6_address, r6,
ia->address_length,
fib6->table_id);
}
else
{
- vlib_cli_output (vm, " %U/%d",
- format_ip6_address, r6,
+ vlib_cli_output (vm, " %U/%d",
+ format_ip6_address, r6,
ia->address_length);
}
}));
- }
+ /* *INDENT-ON* */
+ }
}
else
{
vec_foreach (si, sorted_sis)
- {
- vlib_cli_output (vm, "%U\n", format_vnet_sw_interface, vnm, si);
- }
+ {
+ vlib_cli_output (vm, "%U\n", format_vnet_sw_interface, vnm, si);
+ }
}
- done:
+done:
vec_free (sorted_sis);
return error;
}
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (show_sw_interfaces_command, static) = {
.path = "show interfaces",
.short_help = "show interfaces [address|addr] [<if-name1> <if-name2> ...]",
.function = show_sw_interfaces,
};
+/* *INDENT-ON* */
/* Root of all interface commands. */
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (vnet_cli_interface_command, static) = {
.path = "interface",
.short_help = "Interface commands",
};
+/* *INDENT-ON* */
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (vnet_cli_set_interface_command, static) = {
.path = "set interface",
.short_help = "Interface commands",
};
+/* *INDENT-ON* */
static clib_error_t *
clear_interface_counters (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
+ unformat_input_t * input, vlib_cli_command_t * cmd)
{
- vnet_main_t * vnm = vnet_get_main();
- vnet_interface_main_t * im = &vnm->interface_main;
- vlib_simple_counter_main_t * sm;
- vlib_combined_counter_main_t * cm;
- static vnet_main_t ** my_vnet_mains;
+ vnet_main_t *vnm = vnet_get_main ();
+ vnet_interface_main_t *im = &vnm->interface_main;
+ vlib_simple_counter_main_t *sm;
+ vlib_combined_counter_main_t *cm;
+ static vnet_main_t **my_vnet_mains;
int i, j, n_counters;
vec_reset_length (my_vnet_mains);
-
+
for (i = 0; i < vec_len (vnet_mains); i++)
{
if (vnet_mains[i])
- vec_add1 (my_vnet_mains, vnet_mains[i]);
+ vec_add1 (my_vnet_mains, vnet_mains[i]);
}
if (vec_len (vnet_mains) == 0)
@@ -377,149 +401,164 @@ clear_interface_counters (vlib_main_t * vm,
for (j = 0; j < n_counters; j++)
{
- 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_clear_combined_counters (cm);
- }
+ 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_clear_combined_counters (cm);
+ }
}
n_counters = vec_len (im->sw_if_counters);
for (j = 0; j < n_counters; j++)
{
- for (i = 0; i < vec_len(my_vnet_mains); i++)
- {
- im = &my_vnet_mains[i]->interface_main;
- sm = im->sw_if_counters + j;
- vlib_clear_simple_counters (sm);
- }
+ for (i = 0; i < vec_len (my_vnet_mains); i++)
+ {
+ im = &my_vnet_mains[i]->interface_main;
+ sm = im->sw_if_counters + j;
+ vlib_clear_simple_counters (sm);
+ }
}
return 0;
}
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (clear_interface_counters_command, static) = {
.path = "clear interfaces",
.short_help = "Clear interfaces statistics",
.function = clear_interface_counters,
};
+/* *INDENT-ON* */
-// The following subinterface syntax is supported. The first two are for
-// backwards compatability:
-//
-// <intf-name> <id>
-// - a subinterface with the name <intf-name>.<id>. The subinterface
-// is a single dot1q vlan with vlan id <id> and exact-match semantics.
-//
-// <intf-name> <min_id>-<max_id>
-// - a set of the above subinterfaces, repeating for each id
-// in the range <min_id> to <max_id>
-//
-// In the following, exact-match semantics (i.e. the number of vlan tags on the
-// packet must match the number of tags in the configuration) are used only if
-// the keyword exact-match is present. Non-exact match is the default.
-//
-// <intf-name> <id> dot1q <outer_id> [exact-match]
-// - a subinterface with the name <intf-name>.<id>. The subinterface
-// is a single dot1q vlan with vlan id <outer_id>.
-//
-// <intf-name> <id> dot1q any [exact-match]
-// - a subinterface with the name <intf-name>.<id>. The subinterface
-// is a single dot1q vlan with any vlan id.
-//
-// <intf-name> <id> dot1q <outer_id> inner-dot1q <inner_id> [exact-match]
-// - a subinterface with the name <intf-name>.<id>. The subinterface
-// is a double dot1q vlan with outer vlan id <outer_id> and inner vlan id
-// <inner_id>.
-//
-// <intf-name> <id> dot1q <outer_id> inner-dot1q any [exact-match]
-// - a subinterface with the name <intf-name>.<id>. The subinterface
-// is a double dot1q vlan with outer vlan id <id> and any inner vlan id.
-//
-// <intf-name> <id> dot1q any inner-dot1q any [exact-match]
-//
-// - a subinterface with the name <intf-name>.<id>. The subinterface
-// is a double dot1q vlan with any outer vlan id and any inner vlan id.
-//
-// For each of the above CLI, there is a duplicate that uses the keyword
-// "dot1ad" in place of the first "dot1q". These interfaces use ethertype
-// 0x88ad in place of 0x8100 for the outer ethertype. Note that for double-
-// tagged packets the inner ethertype is always 0x8100. Also note that
-// the dot1q and dot1ad naming spaces are independent, so it is legal to
-// have both "Gig3/0/0.1 dot1q 100" and "Gig3/0/0.2 dot1ad 100". For example:
-//
-// <intf-name> <id> dot1ad <outer_id> inner-dot1q <inner_id> [exact-match]
-// - a subinterface with the name <intf-name>.<id>. The subinterface
-// is a double dot1ad vlan with outer vlan id <outer_id> and inner vlan
-// id <inner_id>.
-//
-// <intf-name> <id> untagged
-// - a subinterface with the name <intf-name>.<id>. The subinterface
-// has no vlan tags. Only one can be specified per interface.
-//
-// <intf-name> <id> default
-// - a subinterface with the name <intf-name>.<id>. This is associated
-// with a packet that did not match any other configured subinterface
-// on this interface. Only one can be specified per interface.
-
+/** \detail
+ * The following subinterface syntax is supported. The first two are for
+ * backwards compatability:
+ *
+ * <intf-name> <id>
+ * - a subinterface with the name <intf-name>.<id>. The subinterface
+ * is a single dot1q vlan with vlan id <id> and exact-match semantics.
+ *
+ * <intf-name> <min_id>-<max_id>
+ * - a set of the above subinterfaces, repeating for each id
+ * in the range <min_id> to <max_id>
+ *
+ * In the following, exact-match semantics (i.e. the number of vlan tags on the
+ * packet must match the number of tags in the configuration) are used only if
+ * the keyword exact-match is present. Non-exact match is the default.
+ *
+ * <intf-name> <id> dot1q <outer_id> [exact-match]
+ * - a subinterface with the name <intf-name>.<id>. The subinterface
+ * is a single dot1q vlan with vlan id <outer_id>.
+ *
+ * <intf-name> <id> dot1q any [exact-match]
+ * - a subinterface with the name <intf-name>.<id>. The subinterface
+ * is a single dot1q vlan with any vlan id.
+ *
+ * <intf-name> <id> dot1q <outer_id> inner-dot1q <inner_id> [exact-match]
+ * - a subinterface with the name <intf-name>.<id>. The subinterface
+ * is a double dot1q vlan with outer vlan id <outer_id> and inner vlan id
+ * <inner_id>.
+ *
+ * <intf-name> <id> dot1q <outer_id> inner-dot1q any [exact-match]
+ * - a subinterface with the name <intf-name>.<id>. The subinterface
+ * is a double dot1q vlan with outer vlan id <id> and any inner vlan id.
+ *
+ * <intf-name> <id> dot1q any inner-dot1q any [exact-match]
+ *
+ * - a subinterface with the name <intf-name>.<id>. The subinterface
+ * is a double dot1q vlan with any outer vlan id and any inner vlan id.
+ *
+ * For each of the above CLI, there is a duplicate that uses the keyword
+ * "dot1ad" in place of the first "dot1q". These interfaces use ethertype
+ * 0x88ad in place of 0x8100 for the outer ethertype. Note that for double-
+ * tagged packets the inner ethertype is always 0x8100. Also note that
+ * the dot1q and dot1ad naming spaces are independent, so it is legal to
+ * have both "Gig3/0/0.1 dot1q 100" and "Gig3/0/0.2 dot1ad 100". For example:
+ *
+ * <intf-name> <id> dot1ad <outer_id> inner-dot1q <inner_id> [exact-match]
+ * - a subinterface with the name <intf-name>.<id>. The subinterface
+ * is a double dot1ad vlan with outer vlan id <outer_id> and inner vlan
+ * id <inner_id>.
+ *
+ * <intf-name> <id> untagged
+ * - a subinterface with the name <intf-name>.<id>. The subinterface
+ * has no vlan tags. Only one can be specified per interface.
+ *
+ * <intf-name> <id> default
+ * - a subinterface with the name <intf-name>.<id>. This is associated
+ * with a packet that did not match any other configured subinterface
+ * on this interface. Only one can be specified per interface.
+ */
static clib_error_t *
-parse_vlan_sub_interfaces (unformat_input_t * input,
- vnet_sw_interface_t * template)
+parse_vlan_sub_interfaces (unformat_input_t * input,
+ vnet_sw_interface_t * template)
{
- clib_error_t * error = 0;
+ clib_error_t *error = 0;
u32 inner_vlan, outer_vlan;
- if (unformat (input, "any inner-dot1q any")) {
- template->sub.eth.flags.two_tags = 1;
- template->sub.eth.flags.outer_vlan_id_any = 1;
- template->sub.eth.flags.inner_vlan_id_any = 1;
- } else if (unformat (input, "any")) {
- template->sub.eth.flags.one_tag = 1;
- template->sub.eth.flags.outer_vlan_id_any = 1;
- } else if (unformat (input, "%d inner-dot1q any", &outer_vlan)) {
- template->sub.eth.flags.two_tags = 1;
- template->sub.eth.flags.inner_vlan_id_any = 1;
- template->sub.eth.outer_vlan_id = outer_vlan;
- } else if (unformat (input, "%d inner-dot1q %d", &outer_vlan, &inner_vlan)) {
- template->sub.eth.flags.two_tags = 1;
- template->sub.eth.outer_vlan_id = outer_vlan;
- template->sub.eth.inner_vlan_id = inner_vlan;
- } else if (unformat (input, "%d", &outer_vlan)) {
- template->sub.eth.flags.one_tag = 1;
- template->sub.eth.outer_vlan_id = outer_vlan;
- } else {
- error = clib_error_return (0, "expected dot1q config, got `%U'",
- format_unformat_error, input);
- goto done;
- }
+ if (unformat (input, "any inner-dot1q any"))
+ {
+ template->sub.eth.flags.two_tags = 1;
+ template->sub.eth.flags.outer_vlan_id_any = 1;
+ template->sub.eth.flags.inner_vlan_id_any = 1;
+ }
+ else if (unformat (input, "any"))
+ {
+ template->sub.eth.flags.one_tag = 1;
+ template->sub.eth.flags.outer_vlan_id_any = 1;
+ }
+ else if (unformat (input, "%d inner-dot1q any", &outer_vlan))
+ {
+ template->sub.eth.flags.two_tags = 1;
+ template->sub.eth.flags.inner_vlan_id_any = 1;
+ template->sub.eth.outer_vlan_id = outer_vlan;
+ }
+ else if (unformat (input, "%d inner-dot1q %d", &outer_vlan, &inner_vlan))
+ {
+ template->sub.eth.flags.two_tags = 1;
+ template->sub.eth.outer_vlan_id = outer_vlan;
+ template->sub.eth.inner_vlan_id = inner_vlan;
+ }
+ else if (unformat (input, "%d", &outer_vlan))
+ {
+ template->sub.eth.flags.one_tag = 1;
+ template->sub.eth.outer_vlan_id = outer_vlan;
+ }
+ else
+ {
+ error = clib_error_return (0, "expected dot1q config, got `%U'",
+ format_unformat_error, input);
+ goto done;
+ }
- if (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
- if (unformat (input, "exact-match")) {
- template->sub.eth.flags.exact_match = 1;
+ if (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "exact-match"))
+ {
+ template->sub.eth.flags.exact_match = 1;
+ }
}
- }
- done:
+done:
return error;
}
static clib_error_t *
create_sub_interfaces (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
+ unformat_input_t * input, vlib_cli_command_t * cmd)
{
- vnet_main_t * vnm = vnet_get_main();
- clib_error_t * error = 0;
+ vnet_main_t *vnm = vnet_get_main ();
+ clib_error_t *error = 0;
u32 hw_if_index, sw_if_index;
- vnet_hw_interface_t * hi;
+ vnet_hw_interface_t *hi;
u32 id, id_min, id_max;
vnet_sw_interface_t template;
hw_if_index = ~0;
- if (! unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
+ if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
{
error = clib_error_return (0, "unknown interface `%U'",
format_unformat_error, input);
@@ -529,74 +568,83 @@ create_sub_interfaces (vlib_main_t * vm,
memset (&template, 0, sizeof (template));
template.sub.eth.raw_flags = 0;
- if (unformat (input, "%d default", &id_min)) {
- id_max = id_min;
- template.sub.eth.flags.default_sub = 1;
- } else if (unformat (input, "%d untagged", &id_min)) {
- id_max = id_min;
- template.sub.eth.flags.no_tags = 1;
- template.sub.eth.flags.exact_match = 1;
- } else if (unformat (input, "%d dot1q", &id_min)) {
- // parse dot1q config
- id_max = id_min;
- error = parse_vlan_sub_interfaces(input, &template);
- if (error) goto done;
- } else if (unformat (input, "%d dot1ad", &id_min)) {
- // parse dot1ad config
- id_max = id_min;
- template.sub.eth.flags.dot1ad = 1;
- error = parse_vlan_sub_interfaces(input, &template);
- if (error) goto done;
- } else if (unformat (input, "%d-%d", &id_min, &id_max)) {
- template.sub.eth.flags.one_tag = 1;
- template.sub.eth.outer_vlan_id = id_min;
- template.sub.eth.flags.exact_match = 1;
- if (id_min > id_max)
- goto id_error;
- } else if (unformat (input, "%d", &id_min)) {
- id_max = id_min;
- template.sub.eth.flags.one_tag = 1;
- template.sub.eth.outer_vlan_id = id_min;
- template.sub.eth.flags.exact_match = 1;
- } else {
+ if (unformat (input, "%d default", &id_min))
+ {
+ id_max = id_min;
+ template.sub.eth.flags.default_sub = 1;
+ }
+ else if (unformat (input, "%d untagged", &id_min))
+ {
+ id_max = id_min;
+ template.sub.eth.flags.no_tags = 1;
+ template.sub.eth.flags.exact_match = 1;
+ }
+ else if (unformat (input, "%d dot1q", &id_min))
+ {
+ /* parse dot1q config */
+ id_max = id_min;
+ error = parse_vlan_sub_interfaces (input, &template);
+ if (error)
+ goto done;
+ }
+ else if (unformat (input, "%d dot1ad", &id_min))
+ {
+ /* parse dot1ad config */
+ id_max = id_min;
+ template.sub.eth.flags.dot1ad = 1;
+ error = parse_vlan_sub_interfaces (input, &template);
+ if (error)
+ goto done;
+ }
+ else if (unformat (input, "%d-%d", &id_min, &id_max))
+ {
+ template.sub.eth.flags.one_tag = 1;
+ template.sub.eth.outer_vlan_id = id_min;
+ template.sub.eth.flags.exact_match = 1;
+ if (id_min > id_max)
+ goto id_error;
+ }
+ else if (unformat (input, "%d", &id_min))
+ {
+ id_max = id_min;
+ template.sub.eth.flags.one_tag = 1;
+ template.sub.eth.outer_vlan_id = id_min;
+ template.sub.eth.flags.exact_match = 1;
+ }
+ else
+ {
id_error:
error = clib_error_return (0, "expected ID or ID MIN-MAX, got `%U'",
format_unformat_error, input);
goto done;
- }
-
- /*
- if (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
- error = clib_error_return (0, "unexpected text `%U'",
- format_unformat_error, input);
- goto done;
- }
- */
+ }
hi = vnet_get_hw_interface (vnm, hw_if_index);
- if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE) {
- error = clib_error_return (
- 0, "not allowed as %v belong to a BondEthernet interface", hi->name);
- goto done;
- }
+ if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE)
+ {
+ error =
+ clib_error_return (0,
+ "not allowed as %v belong to a BondEthernet interface",
+ hi->name);
+ goto done;
+ }
for (id = id_min; id <= id_max; id++)
{
- uword * p;
- vnet_interface_main_t * im = &vnm->interface_main;
- u64 sup_and_sub_key = ((u64)(hi->sw_if_index) << 32) |
- (u64) id;
- u64 * kp;
+ uword *p;
+ vnet_interface_main_t *im = &vnm->interface_main;
+ u64 sup_and_sub_key = ((u64) (hi->sw_if_index) << 32) | (u64) id;
+ u64 *kp;
p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
if (p)
- {
- if (CLIB_DEBUG > 0)
- clib_warning ("sup sw_if_index %d, sub id %d already exists\n",
- hi->sw_if_index, id);
- continue;
- }
+ {
+ if (CLIB_DEBUG > 0)
+ clib_warning ("sup sw_if_index %d, sub id %d already exists\n",
+ hi->sw_if_index, id);
+ continue;
+ }
kp = clib_mem_alloc (sizeof (*kp));
*kp = sup_and_sub_key;
@@ -605,43 +653,44 @@ create_sub_interfaces (vlib_main_t * vm,
template.sup_sw_if_index = hi->sw_if_index;
template.sub.id = id;
error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
- if (error)
- goto done;
+ if (error)
+ goto done;
hash_set (hi->sub_interface_sw_if_index_by_id, id, sw_if_index);
hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
- vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name,
- vnet_get_main(), sw_if_index);
+ vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name,
+ vnet_get_main (), sw_if_index);
}
- done:
+done:
return error;
}
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (create_sub_interfaces_command, static) = {
.path = "create sub-interface",
.short_help = "create sub-interfaces <nn>[-<nn>] [dot1q|dot1ad|default|untagged]",
.function = create_sub_interfaces,
};
+/* *INDENT-ON* */
static clib_error_t *
set_state (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
+ unformat_input_t * input, vlib_cli_command_t * cmd)
{
- vnet_main_t * vnm = vnet_get_main();
- clib_error_t * error;
+ vnet_main_t *vnm = vnet_get_main ();
+ clib_error_t *error;
u32 sw_if_index, flags;
sw_if_index = ~0;
- if (! unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
+ if (!unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
{
error = clib_error_return (0, "unknown interface `%U'",
format_unformat_error, input);
goto done;
}
- if (! unformat (input, "%U", unformat_vnet_sw_interface_flags, &flags))
+ if (!unformat (input, "%U", unformat_vnet_sw_interface_flags, &flags))
{
error = clib_error_return (0, "unknown flags `%U'",
format_unformat_error, input);
@@ -652,89 +701,95 @@ set_state (vlib_main_t * vm,
if (error)
goto done;
- done:
+done:
return error;
}
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (set_state_command, static) = {
.path = "set interface state",
.short_help = "Set interface state",
.function = set_state,
};
+/* *INDENT-ON* */
static clib_error_t *
set_unnumbered (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
+ unformat_input_t * input, vlib_cli_command_t * cmd)
{
- vnet_main_t * vnm = vnet_get_main();
+ vnet_main_t *vnm = vnet_get_main ();
u32 unnumbered_sw_if_index;
u32 inherit_from_sw_if_index;
- vnet_sw_interface_t * si;
+ vnet_sw_interface_t *si;
int is_set = 0;
int is_del = 0;
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
+ {
- if (unformat (input, "%U use %U",
- unformat_vnet_sw_interface, vnm, &unnumbered_sw_if_index,
- unformat_vnet_sw_interface, vnm, &inherit_from_sw_if_index))
- is_set = 1;
+ if (unformat (input, "%U use %U",
+ unformat_vnet_sw_interface, vnm, &unnumbered_sw_if_index,
+ unformat_vnet_sw_interface, vnm,
+ &inherit_from_sw_if_index))
+ is_set = 1;
else if (unformat (input, "del %U",
- unformat_vnet_sw_interface,
- vnm, &unnumbered_sw_if_index))
- is_del = 1;
+ unformat_vnet_sw_interface,
+ vnm, &unnumbered_sw_if_index))
+ is_del = 1;
else
- {
- if (is_set || is_del)
- break;
- else
- return clib_error_return
- (0, "parse error '%U'", format_unformat_error, input);
- }
- }
+ {
+ if (is_set || is_del)
+ break;
+ else
+ return clib_error_return
+ (0, "parse error '%U'", format_unformat_error, input);
+ }
+ }
si = vnet_get_sw_interface (vnm, unnumbered_sw_if_index);
- if (is_del) {
+ if (is_del)
+ {
si->flags &= ~(VNET_SW_INTERFACE_FLAG_UNNUMBERED);
- si->unnumbered_sw_if_index = (u32)~0;
- } else {
+ si->unnumbered_sw_if_index = (u32) ~ 0;
+ }
+ else
+ {
si->flags |= VNET_SW_INTERFACE_FLAG_UNNUMBERED;
si->unnumbered_sw_if_index = inherit_from_sw_if_index;
- }
-
+ }
+
return 0;
}
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (set_unnumbered_command, static) = {
.path = "set interface unnumbered",
.short_help = "set interface unnumbered [<intfc> use <intfc>][del <intfc>]",
.function = set_unnumbered,
};
+/* *INDENT-ON* */
static clib_error_t *
set_hw_class (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
+ unformat_input_t * input, vlib_cli_command_t * cmd)
{
- vnet_main_t * vnm = vnet_get_main();
- vnet_interface_main_t * im = &vnm->interface_main;
- clib_error_t * error;
+ vnet_main_t *vnm = vnet_get_main ();
+ vnet_interface_main_t *im = &vnm->interface_main;
+ clib_error_t *error;
u32 hw_if_index, hw_class_index;
hw_if_index = ~0;
- if (! unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
+ if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
{
error = clib_error_return (0, "unknown hardware interface `%U'",
format_unformat_error, input);
goto done;
}
- if (! unformat_user (input, unformat_hash_string,
- im->hw_interface_class_by_name, &hw_class_index))
+ if (!unformat_user (input, unformat_hash_string,
+ im->hw_interface_class_by_name, &hw_class_index))
{
error = clib_error_return (0, "unknown hardware class `%U'",
format_unformat_error, input);
@@ -745,36 +800,41 @@ set_hw_class (vlib_main_t * vm,
if (error)
goto done;
- done:
+done:
return error;
}
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (set_hw_class_command, static) = {
.path = "set interface hw-class",
.short_help = "Set interface hardware class",
.function = set_hw_class,
};
+/* *INDENT-ON* */
-static clib_error_t * vnet_interface_cli_init (vlib_main_t * vm)
-{ return 0; }
+static clib_error_t *
+vnet_interface_cli_init (vlib_main_t * vm)
+{
+ return 0;
+}
VLIB_INIT_FUNCTION (vnet_interface_cli_init);
-static clib_error_t *
+static clib_error_t *
renumber_interface_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
{
u32 hw_if_index;
u32 new_dev_instance;
- vnet_main_t * vnm = vnet_get_main();
+ vnet_main_t *vnm = vnet_get_main ();
int rv;
- if (! unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
+ if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
return clib_error_return (0, "unknown hardware interface `%U'",
- format_unformat_error, input);
+ format_unformat_error, input);
- if (! unformat (input, "%d", &new_dev_instance))
+ if (!unformat (input, "%d", &new_dev_instance))
return clib_error_return (0, "new dev instance missing");
rv = vnet_interface_name_renumber (hw_if_index, new_dev_instance);
@@ -786,7 +846,7 @@ renumber_interface_command_fn (vlib_main_t * vm,
default:
return clib_error_return (0, "vnet_interface_name_renumber returned %d",
- rv);
+ rv);
}
@@ -794,32 +854,33 @@ renumber_interface_command_fn (vlib_main_t * vm,
}
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (renumber_interface_command, static) = {
.path = "renumber interface",
.short_help = "renumber interface <if-name> <new-dev-instance>",
.function = renumber_interface_command_fn,
};
+/* *INDENT-ON* */
static clib_error_t *
promiscuous_cmd (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
+ unformat_input_t * input, vlib_cli_command_t * cmd)
{
- vnet_main_t * vnm = vnet_get_main();
+ vnet_main_t *vnm = vnet_get_main ();
u32 hw_if_index;
u32 flags = ETHERNET_INTERFACE_FLAG_ACCEPT_ALL;
- ethernet_main_t * em = &ethernet_main;
- ethernet_interface_t * eif;
+ ethernet_main_t *em = &ethernet_main;
+ ethernet_interface_t *eif;
if (unformat (input, "on %U",
- unformat_vnet_hw_interface, vnm, &hw_if_index))
+ unformat_vnet_hw_interface, vnm, &hw_if_index))
;
else if (unformat (input, "off %U",
- unformat_ethernet_interface, vnm, &hw_if_index))
+ unformat_ethernet_interface, vnm, &hw_if_index))
flags = 0;
else
return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ format_unformat_error, input);
eif = ethernet_get_interface (em, hw_if_index);
if (!eif)
@@ -829,28 +890,30 @@ promiscuous_cmd (vlib_main_t * vm,
return 0;
}
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (set_interface_promiscuous_cmd, static) = {
.path = "set interface promiscuous",
.short_help = "set interface promiscuous [on | off] <intfc>",
.function = promiscuous_cmd,
};
+/* *INDENT-ON* */
static clib_error_t *
mtu_cmd (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
{
- vnet_main_t * vnm = vnet_get_main();
+ vnet_main_t *vnm = vnet_get_main ();
u32 hw_if_index, mtu;
u32 flags = ETHERNET_INTERFACE_FLAG_MTU;
- ethernet_main_t * em = &ethernet_main;
+ ethernet_main_t *em = &ethernet_main;
if (unformat (input, "%d %U", &mtu,
- unformat_vnet_hw_interface, vnm, &hw_if_index))
+ unformat_vnet_hw_interface, vnm, &hw_if_index))
{
- vnet_hw_interface_t * hi = vnet_get_hw_interface (vnm, hw_if_index);
- ethernet_interface_t * eif = ethernet_get_interface (em, hw_if_index);
+ vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
+ ethernet_interface_t *eif = ethernet_get_interface (em, hw_if_index);
if (!eif)
- return clib_error_return (0, "not supported");
+ return clib_error_return (0, "not supported");
if (mtu < hi->min_supported_packet_bytes)
return clib_error_return (0, "Invalid mtu (%d): "
@@ -859,7 +922,7 @@ mtu_cmd (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
if (mtu > hi->max_supported_packet_bytes)
return clib_error_return (0, "Invalid mtu (%d): must be <= (%d)", mtu,
- hi->max_supported_packet_bytes);
+ hi->max_supported_packet_bytes);
if (hi->max_packet_bytes != mtu)
{
@@ -869,13 +932,22 @@ mtu_cmd (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
}
else
return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ format_unformat_error, input);
return 0;
}
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (set_interface_mtu_cmd, static) = {
.path = "set interface mtu",
.short_help = "set interface mtu <value> <intfc>",
.function = mtu_cmd,
};
+/* *INDENT-ON* */
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
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:
+ */
diff --git a/vnet/vnet/interface_funcs.h b/vnet/vnet/interface_funcs.h
index 7832afcc7c4..81a819a64bd 100644
--- a/vnet/vnet/interface_funcs.h
+++ b/vnet/vnet/interface_funcs.h
@@ -42,17 +42,21 @@
always_inline vnet_hw_interface_t *
vnet_get_hw_interface (vnet_main_t * vnm, u32 hw_if_index)
-{ return pool_elt_at_index (vnm->interface_main.hw_interfaces, hw_if_index); }
+{
+ return pool_elt_at_index (vnm->interface_main.hw_interfaces, hw_if_index);
+}
always_inline vnet_sw_interface_t *
vnet_get_sw_interface (vnet_main_t * vnm, u32 sw_if_index)
-{ return pool_elt_at_index (vnm->interface_main.sw_interfaces, sw_if_index); }
+{
+ return pool_elt_at_index (vnm->interface_main.sw_interfaces, sw_if_index);
+}
always_inline vnet_sw_interface_t *
vnet_get_hw_sw_interface (vnet_main_t * vnm, u32 hw_if_index)
{
- vnet_hw_interface_t * hw = vnet_get_hw_interface (vnm, hw_if_index);
- vnet_sw_interface_t * sw = vnet_get_sw_interface (vnm, hw->sw_if_index);
+ vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
+ vnet_sw_interface_t *sw = vnet_get_sw_interface (vnm, hw->sw_if_index);
ASSERT (sw->type == VNET_SW_INTERFACE_TYPE_HARDWARE);
return sw;
}
@@ -60,7 +64,7 @@ vnet_get_hw_sw_interface (vnet_main_t * vnm, u32 hw_if_index)
always_inline vnet_sw_interface_t *
vnet_get_sup_sw_interface (vnet_main_t * vnm, u32 sw_if_index)
{
- vnet_sw_interface_t * sw = vnet_get_sw_interface (vnm, sw_if_index);
+ vnet_sw_interface_t *sw = vnet_get_sw_interface (vnm, sw_if_index);
if (sw->type == VNET_SW_INTERFACE_TYPE_SUB)
sw = vnet_get_sw_interface (vnm, sw->sup_sw_if_index);
return sw;
@@ -69,29 +73,35 @@ vnet_get_sup_sw_interface (vnet_main_t * vnm, u32 sw_if_index)
always_inline vnet_hw_interface_t *
vnet_get_sup_hw_interface (vnet_main_t * vnm, u32 sw_if_index)
{
- vnet_sw_interface_t * sw = vnet_get_sup_sw_interface (vnm, sw_if_index);
+ vnet_sw_interface_t *sw = vnet_get_sup_sw_interface (vnm, sw_if_index);
ASSERT (sw->type == VNET_SW_INTERFACE_TYPE_HARDWARE);
return vnet_get_hw_interface (vnm, sw->hw_if_index);
}
always_inline vnet_hw_interface_class_t *
vnet_get_hw_interface_class (vnet_main_t * vnm, u32 hw_class_index)
-{ return vec_elt_at_index (vnm->interface_main.hw_interface_classes, hw_class_index); }
+{
+ return vec_elt_at_index (vnm->interface_main.hw_interface_classes,
+ hw_class_index);
+}
always_inline vnet_device_class_t *
vnet_get_device_class (vnet_main_t * vnm, u32 dev_class_index)
-{ return vec_elt_at_index (vnm->interface_main.device_classes, dev_class_index); }
+{
+ return vec_elt_at_index (vnm->interface_main.device_classes,
+ dev_class_index);
+}
/* Register a hardware interface instance. */
u32 vnet_register_interface (vnet_main_t * vnm,
u32 dev_class_index,
u32 dev_instance,
- u32 hw_class_index,
- u32 hw_instance);
+ u32 hw_class_index, u32 hw_instance);
/* Creates a software interface given template. */
-clib_error_t *
-vnet_create_sw_interface (vnet_main_t * vnm, vnet_sw_interface_t * template, u32 * sw_if_index);
+clib_error_t *vnet_create_sw_interface (vnet_main_t * vnm,
+ vnet_sw_interface_t * template,
+ u32 * sw_if_index);
void vnet_delete_hw_interface (vnet_main_t * vnm, u32 hw_if_index);
void vnet_delete_sw_interface (vnet_main_t * vnm, u32 sw_if_index);
@@ -99,60 +109,68 @@ void vnet_delete_sw_interface (vnet_main_t * vnm, u32 sw_if_index);
always_inline uword
vnet_sw_interface_get_flags (vnet_main_t * vnm, u32 sw_if_index)
{
- vnet_sw_interface_t * sw = vnet_get_sw_interface (vnm, sw_if_index);
+ vnet_sw_interface_t *sw = vnet_get_sw_interface (vnm, sw_if_index);
return sw->flags;
}
always_inline uword
vnet_sw_interface_is_admin_up (vnet_main_t * vnm, u32 sw_if_index)
-{ return (vnet_sw_interface_get_flags (vnm, sw_if_index) & VNET_SW_INTERFACE_FLAG_ADMIN_UP) != 0; }
+{
+ return (vnet_sw_interface_get_flags (vnm, sw_if_index) &
+ VNET_SW_INTERFACE_FLAG_ADMIN_UP) != 0;
+}
always_inline uword
vnet_hw_interface_get_flags (vnet_main_t * vnm, u32 hw_if_index)
{
- vnet_hw_interface_t * hw = vnet_get_hw_interface (vnm, hw_if_index);
+ vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
return hw->flags;
}
always_inline uword
vnet_hw_interface_is_link_up (vnet_main_t * vnm, u32 hw_if_index)
-{ return (vnet_hw_interface_get_flags (vnm, hw_if_index) & VNET_HW_INTERFACE_FLAG_LINK_UP) != 0; }
+{
+ return (vnet_hw_interface_get_flags (vnm, hw_if_index) &
+ VNET_HW_INTERFACE_FLAG_LINK_UP) != 0;
+}
always_inline vlib_frame_t *
vnet_get_frame_to_sw_interface (vnet_main_t * vnm, u32 sw_if_index)
{
- vnet_hw_interface_t * hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
+ vnet_hw_interface_t *hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
return vlib_get_frame_to_node (vnm->vlib_main, hw->output_node_index);
}
always_inline void
-vnet_put_frame_to_sw_interface (vnet_main_t * vnm, u32 sw_if_index, vlib_frame_t * f)
+vnet_put_frame_to_sw_interface (vnet_main_t * vnm, u32 sw_if_index,
+ vlib_frame_t * f)
{
- vnet_hw_interface_t * hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
+ vnet_hw_interface_t *hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
return vlib_put_frame_to_node (vnm->vlib_main, hw->output_node_index, f);
}
/* 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);
+clib_error_t *vnet_hw_interface_set_flags (vnet_main_t * vnm, u32 hw_if_index,
+ u32 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);
+clib_error_t *vnet_sw_interface_set_flags (vnet_main_t * vnm, u32 sw_if_index,
+ u32 flags);
/* Change interface class. */
-clib_error_t *
-vnet_hw_interface_set_class (vnet_main_t * vnm, u32 hw_if_index, u32 new_hw_class_index);
+clib_error_t *vnet_hw_interface_set_class (vnet_main_t * vnm, u32 hw_if_index,
+ u32 new_hw_class_index);
/* Redirect rx pkts to node */
int vnet_hw_interface_rx_redirect_to_node (vnet_main_t * vnm, u32 hw_if_index,
- u32 node_index);
+ u32 node_index);
-void vnet_hw_interface_init_for_class (vnet_main_t * vnm, u32 hw_if_index, u32 hw_class_index, u32 hw_instance);
+void vnet_hw_interface_init_for_class (vnet_main_t * vnm, u32 hw_if_index,
+ u32 hw_class_index, u32 hw_instance);
/* Rename interface */
-clib_error_t *
-vnet_rename_interface (vnet_main_t * vnm, u32 hw_if_index, char * new_name);
+clib_error_t *vnet_rename_interface (vnet_main_t * vnm, u32 hw_if_index,
+ char *new_name);
/* Formats sw/hw interface. */
format_function_t format_vnet_hw_interface;
@@ -171,7 +189,8 @@ unformat_function_t unformat_vnet_hw_interface_flags;
unformat_function_t unformat_vnet_sw_interface_flags;
/* Node runtime for interface output function. */
-typedef struct {
+typedef struct
+{
u32 hw_if_index;
u32 sw_if_index;
u32 dev_instance;
@@ -179,35 +198,49 @@ typedef struct {
} vnet_interface_output_runtime_t;
/* Interface output functions. */
-void * vnet_interface_output_node_multiarch_select (void);
-void * vnet_interface_output_node_no_flatten_multiarch_select (void);
+void *vnet_interface_output_node_multiarch_select (void);
+void *vnet_interface_output_node_no_flatten_multiarch_select (void);
-word vnet_sw_interface_compare (vnet_main_t * vnm, uword sw_if_index0, uword sw_if_index1);
-word vnet_hw_interface_compare (vnet_main_t * vnm, uword hw_if_index0, uword hw_if_index1);
+word vnet_sw_interface_compare (vnet_main_t * vnm, uword sw_if_index0,
+ uword sw_if_index1);
+word vnet_hw_interface_compare (vnet_main_t * vnm, uword hw_if_index0,
+ uword hw_if_index1);
-typedef enum {
+typedef enum
+{
#define _(sym,str) VNET_INTERFACE_OUTPUT_NEXT_##sym,
foreach_intf_output_feat
#undef _
- VNET_INTERFACE_OUTPUT_NEXT_DROP,
+ VNET_INTERFACE_OUTPUT_NEXT_DROP,
VNET_INTERFACE_OUTPUT_NEXT_TX,
} vnet_interface_output_next_t;
-typedef enum {
+typedef enum
+{
VNET_INTERFACE_TX_NEXT_DROP,
VNET_INTERFACE_TX_N_NEXT,
} vnet_interface_tx_next_t;
#define VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT VNET_INTERFACE_TX_N_NEXT
-typedef enum {
+typedef enum
+{
VNET_INTERFACE_OUTPUT_ERROR_INTERFACE_DOWN,
VNET_INTERFACE_OUTPUT_ERROR_INTERFACE_DELETED,
} vnet_interface_output_error_t;
/* Format for interface output traces. */
-u8 * format_vnet_interface_output_trace (u8 * s, va_list * va);
+u8 *format_vnet_interface_output_trace (u8 * s, va_list * va);
-serialize_function_t serialize_vnet_interface_state, unserialize_vnet_interface_state;
+serialize_function_t serialize_vnet_interface_state,
+ unserialize_vnet_interface_state;
#endif /* included_vnet_interface_funcs_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/interface_output.c b/vnet/vnet/interface_output.c
index b19ca7c50c3..173bb75cf1c 100644
--- a/vnet/vnet/interface_output.c
+++ b/vnet/vnet/interface_output.c
@@ -39,30 +39,34 @@
#include <vnet/vnet.h>
-typedef struct {
+typedef struct
+{
u32 sw_if_index;
u8 data[128 - sizeof (u32)];
-} interface_output_trace_t;
+}
+interface_output_trace_t;
-u8 * format_vnet_interface_output_trace (u8 * s, va_list * va)
+u8 *
+format_vnet_interface_output_trace (u8 * s, va_list * va)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *);
- vlib_node_t * node = va_arg (*va, vlib_node_t *);
- interface_output_trace_t * t = va_arg (*va, interface_output_trace_t *);
- vnet_main_t * vnm = vnet_get_main();
- vnet_sw_interface_t * si;
+ vlib_node_t *node = va_arg (*va, vlib_node_t *);
+ interface_output_trace_t *t = va_arg (*va, interface_output_trace_t *);
+ vnet_main_t *vnm = vnet_get_main ();
+ vnet_sw_interface_t *si;
uword indent;
- if (t->sw_if_index != (u32)~0)
+ if (t->sw_if_index != (u32) ~ 0)
{
si = vnet_get_sw_interface (vnm, t->sw_if_index);
indent = format_get_indent (s);
-
+
s = format (s, "%U\n%U%U",
- format_vnet_sw_interface_name, vnm, si,
- format_white_space, indent,
- node->format_buffer ? node->format_buffer : format_hex_bytes,
- t->data, sizeof (t->data));
+ format_vnet_sw_interface_name, vnm, si,
+ format_white_space, indent,
+ node->format_buffer ? node->
+ format_buffer : format_hex_bytes, t->data,
+ sizeof (t->data));
}
return s;
}
@@ -70,19 +74,18 @@ u8 * format_vnet_interface_output_trace (u8 * s, va_list * va)
static void
vnet_interface_output_trace (vlib_main_t * vm,
vlib_node_runtime_t * node,
- vlib_frame_t * frame,
- uword n_buffers)
+ vlib_frame_t * frame, uword n_buffers)
{
- u32 n_left, * from;
+ u32 n_left, *from;
n_left = n_buffers;
from = vlib_frame_args (frame);
-
+
while (n_left >= 4)
{
u32 bi0, bi1;
- vlib_buffer_t * b0, * b1;
- interface_output_trace_t * t0, * t1;
+ vlib_buffer_t *b0, *b1;
+ interface_output_trace_t *t0, *t1;
/* Prefetch next iteration. */
vlib_prefetch_buffer_with_index (vm, from[2], LOAD);
@@ -99,14 +102,14 @@ vnet_interface_output_trace (vlib_main_t * vm,
t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0]));
t0->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX];
clib_memcpy (t0->data, vlib_buffer_get_current (b0),
- sizeof (t0->data));
+ sizeof (t0->data));
}
if (b1->flags & VLIB_BUFFER_IS_TRACED)
{
t1 = vlib_add_trace (vm, node, b1, sizeof (t1[0]));
t1->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_TX];
clib_memcpy (t1->data, vlib_buffer_get_current (b1),
- sizeof (t1->data));
+ sizeof (t1->data));
}
from += 2;
n_left -= 2;
@@ -115,8 +118,8 @@ vnet_interface_output_trace (vlib_main_t * vm,
while (n_left >= 1)
{
u32 bi0;
- vlib_buffer_t * b0;
- interface_output_trace_t * t0;
+ vlib_buffer_t *b0;
+ interface_output_trace_t *t0;
bi0 = from[0];
@@ -127,7 +130,7 @@ vnet_interface_output_trace (vlib_main_t * vm,
t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0]));
t0->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX];
clib_memcpy (t0->data, vlib_buffer_get_current (b0),
- sizeof (t0->data));
+ sizeof (t0->data));
}
from += 1;
n_left -= 1;
@@ -138,9 +141,7 @@ static never_inline u32
slow_path (vlib_main_t * vm,
u32 bi,
vlib_buffer_t * b,
- u32 n_left_to_tx,
- u32 * to_tx,
- u32 * n_slow_bytes_result)
+ u32 n_left_to_tx, u32 * to_tx, u32 * n_slow_bytes_result)
{
/* We've already enqueued a single buffer. */
u32 n_buffers = 0;
@@ -155,10 +156,10 @@ slow_path (vlib_main_t * vm,
n_slow_bytes += vlib_buffer_length_in_chain (vm, b);
/* Be grumpy about zero length buffers for benefit of
- driver tx function. */
+ driver tx function. */
ASSERT (b->current_length > 0);
- if (! (b->flags & VLIB_BUFFER_NEXT_PRESENT))
+ if (!(b->flags & VLIB_BUFFER_NEXT_PRESENT))
break;
bi = b->next_buffer;
@@ -173,52 +174,53 @@ slow_path (vlib_main_t * vm,
return n_buffers;
}
-/*
- * Increment TX stats. Roll up consecutive increments to the same sw_if_index
+/*
+ * Increment TX stats. Roll up consecutive increments to the same sw_if_index
* into one increment.
*/
-static_always_inline
-void incr_output_stats (vnet_main_t * vnm,
- u32 cpu_index,
- u32 length,
- u32 sw_if_index,
- u32 * last_sw_if_index,
- u32 * n_packets,
- u32 * n_bytes) {
- vnet_interface_main_t * im;
-
- if (PREDICT_TRUE (sw_if_index == *last_sw_if_index)) {
- *n_packets += 1;
- *n_bytes += length;
- } else {
- if (PREDICT_TRUE (*last_sw_if_index != ~0)) {
- im = &vnm->interface_main;
-
- vlib_increment_combined_counter (im->combined_sw_if_counters
- + VNET_INTERFACE_COUNTER_TX,
- cpu_index,
- *last_sw_if_index,
- *n_packets,
- *n_bytes);
+static_always_inline void
+incr_output_stats (vnet_main_t * vnm,
+ u32 cpu_index,
+ u32 length,
+ u32 sw_if_index,
+ u32 * last_sw_if_index, u32 * n_packets, u32 * n_bytes)
+{
+ vnet_interface_main_t *im;
+
+ if (PREDICT_TRUE (sw_if_index == *last_sw_if_index))
+ {
+ *n_packets += 1;
+ *n_bytes += length;
+ }
+ else
+ {
+ if (PREDICT_TRUE (*last_sw_if_index != ~0))
+ {
+ im = &vnm->interface_main;
+
+ vlib_increment_combined_counter (im->combined_sw_if_counters
+ + VNET_INTERFACE_COUNTER_TX,
+ cpu_index,
+ *last_sw_if_index,
+ *n_packets, *n_bytes);
+ }
+ *last_sw_if_index = sw_if_index;
+ *n_packets = 1;
+ *n_bytes = length;
}
- *last_sw_if_index = sw_if_index;
- *n_packets = 1;
- *n_bytes = length;
- }
}
/* Interface output functions. */
uword
vnet_interface_output_node (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+ vlib_node_runtime_t * node, vlib_frame_t * frame)
{
- vnet_main_t * vnm = vnet_get_main();
- vnet_interface_output_runtime_t * rt = (void *) node->runtime_data;
- vnet_sw_interface_t * si;
- vnet_hw_interface_t * hi;
- u32 n_left_to_tx, * from, * from_end, * to_tx;
+ vnet_main_t *vnm = vnet_get_main ();
+ vnet_interface_output_runtime_t *rt = (void *) node->runtime_data;
+ vnet_sw_interface_t *si;
+ vnet_hw_interface_t *hi;
+ u32 n_left_to_tx, *from, *from_end, *to_tx;
u32 n_bytes, n_buffers, n_packets;
u32 last_sw_if_index;
u32 cpu_index = vm->cpu_index;
@@ -231,8 +233,7 @@ vnet_interface_output_node (vlib_main_t * vm,
from = vlib_frame_args (frame);
if (rt->is_deleted)
- return vlib_error_drop_buffers (vm, node,
- from,
+ return vlib_error_drop_buffers (vm, node, from,
/* buffer stride */ 1,
n_buffers,
VNET_INTERFACE_OUTPUT_NEXT_DROP,
@@ -241,22 +242,21 @@ vnet_interface_output_node (vlib_main_t * vm,
si = vnet_get_sw_interface (vnm, rt->sw_if_index);
hi = vnet_get_sup_hw_interface (vnm, rt->sw_if_index);
- if (! (si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ||
- ! (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP))
+ if (!(si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ||
+ !(hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP))
{
- vlib_simple_counter_main_t * cm;
-
+ vlib_simple_counter_main_t *cm;
+
cm = vec_elt_at_index (vnm->interface_main.sw_if_counters,
- VNET_INTERFACE_COUNTER_TX_ERROR);
+ VNET_INTERFACE_COUNTER_TX_ERROR);
vlib_increment_simple_counter (cm, cpu_index,
- rt->sw_if_index, n_buffers);
- return vlib_error_drop_buffers (vm, node,
- from,
- /* buffer stride */ 1,
- n_buffers,
- VNET_INTERFACE_OUTPUT_NEXT_DROP,
- node->node_index,
- VNET_INTERFACE_OUTPUT_ERROR_INTERFACE_DOWN);
+ rt->sw_if_index, n_buffers);
+ return vlib_error_drop_buffers (vm, node, from,
+ /* buffer stride */ 1,
+ n_buffers,
+ VNET_INTERFACE_OUTPUT_NEXT_DROP,
+ node->node_index,
+ VNET_INTERFACE_OUTPUT_ERROR_INTERFACE_DOWN);
}
from_end = from + n_buffers;
@@ -269,14 +269,14 @@ vnet_interface_output_node (vlib_main_t * vm,
while (from < from_end)
{
/* Get new next frame since previous incomplete frame may have less
- than VNET_FRAME_SIZE vectors in it. */
+ than VNET_FRAME_SIZE vectors in it. */
vlib_get_new_next_frame (vm, node, VNET_INTERFACE_OUTPUT_NEXT_TX,
to_tx, n_left_to_tx);
while (from + 4 <= from_end && n_left_to_tx >= 2)
{
u32 bi0, bi1;
- vlib_buffer_t * b0, * b1;
+ vlib_buffer_t *b0, *b1;
/* Prefetch next iteration. */
vlib_prefetch_buffer_with_index (vm, from[2], LOAD);
@@ -298,7 +298,8 @@ vnet_interface_output_node (vlib_main_t * vm,
ASSERT (b0->current_length > 0);
ASSERT (b1->current_length > 0);
- if (PREDICT_FALSE ((b0->flags | b1->flags) & VLIB_BUFFER_NEXT_PRESENT))
+ if (PREDICT_FALSE
+ ((b0->flags | b1->flags) & VLIB_BUFFER_NEXT_PRESENT))
{
u32 n_buffers, n_slow_bytes, i;
@@ -311,7 +312,7 @@ vnet_interface_output_node (vlib_main_t * vm,
for (i = 0; i < 2; i++)
{
u32 bi = i ? bi1 : bi0;
- vlib_buffer_t * b = i ? b1 : b0;
+ vlib_buffer_t *b = i ? b1 : b0;
n_buffers = slow_path (vm, bi, b,
n_left_to_tx, to_tx, &n_slow_bytes);
@@ -324,25 +325,27 @@ vnet_interface_output_node (vlib_main_t * vm,
to_tx += n_buffers;
n_left_to_tx -= n_buffers;
incr_output_stats (vnm, cpu_index, n_slow_bytes,
- vnet_buffer(b)->sw_if_index[VLIB_TX],
- &last_sw_if_index, &n_packets, &n_bytes);
+ vnet_buffer (b)->sw_if_index[VLIB_TX],
+ &last_sw_if_index, &n_packets, &n_bytes);
}
- } else {
- incr_output_stats (vnm, cpu_index,
- vlib_buffer_length_in_chain (vm, b0),
- vnet_buffer(b0)->sw_if_index[VLIB_TX],
- &last_sw_if_index, &n_packets, &n_bytes);
- incr_output_stats (vnm, cpu_index,
- vlib_buffer_length_in_chain (vm, b0),
- vnet_buffer(b1)->sw_if_index[VLIB_TX],
- &last_sw_if_index, &n_packets, &n_bytes);
- }
+ }
+ else
+ {
+ incr_output_stats (vnm, cpu_index,
+ vlib_buffer_length_in_chain (vm, b0),
+ vnet_buffer (b0)->sw_if_index[VLIB_TX],
+ &last_sw_if_index, &n_packets, &n_bytes);
+ incr_output_stats (vnm, cpu_index,
+ vlib_buffer_length_in_chain (vm, b0),
+ vnet_buffer (b1)->sw_if_index[VLIB_TX],
+ &last_sw_if_index, &n_packets, &n_bytes);
+ }
}
while (from + 1 <= from_end && n_left_to_tx >= 1)
{
u32 bi0;
- vlib_buffer_t * b0;
+ vlib_buffer_t *b0;
bi0 = from[0];
to_tx[0] = bi0;
@@ -376,41 +379,42 @@ vnet_interface_output_node (vlib_main_t * vm,
to_tx += n_buffers;
n_left_to_tx -= n_buffers;
}
- incr_output_stats (vnm, cpu_index,
- vlib_buffer_length_in_chain (vm, b0),
- vnet_buffer(b0)->sw_if_index[VLIB_TX],
- &last_sw_if_index, &n_packets, &n_bytes);
+ incr_output_stats (vnm, cpu_index,
+ vlib_buffer_length_in_chain (vm, b0),
+ vnet_buffer (b0)->sw_if_index[VLIB_TX],
+ &last_sw_if_index, &n_packets, &n_bytes);
}
put:
- vlib_put_next_frame (vm, node, VNET_INTERFACE_OUTPUT_NEXT_TX, n_left_to_tx);
+ vlib_put_next_frame (vm, node, VNET_INTERFACE_OUTPUT_NEXT_TX,
+ n_left_to_tx);
}
/* Final update of interface stats. */
- incr_output_stats (vnm, cpu_index, 0, ~0, /* ~0 will flush stats */
- &last_sw_if_index, &n_packets, &n_bytes);
+ incr_output_stats (vnm, cpu_index, 0, ~0, /* ~0 will flush stats */
+ &last_sw_if_index, &n_packets, &n_bytes);
return n_buffers;
}
-VLIB_NODE_FUNCTION_MULTIARCH_CLONE (vnet_interface_output_node)
-CLIB_MULTIARCH_SELECT_FN (vnet_interface_output_node)
+VLIB_NODE_FUNCTION_MULTIARCH_CLONE (vnet_interface_output_node);
+CLIB_MULTIARCH_SELECT_FN (vnet_interface_output_node);
always_inline uword
-vnet_interface_output_node_no_flatten_inline (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame,
- int with_features)
+vnet_interface_output_node_no_flatten_inline (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame,
+ int with_features)
{
- vnet_main_t * vnm = vnet_get_main();
- vnet_interface_output_runtime_t * rt = (void *) node->runtime_data;
- vnet_sw_interface_t * si;
- vnet_hw_interface_t * hi;
- u32 n_left_to_tx, * from, * from_end, * to_tx;
+ vnet_main_t *vnm = vnet_get_main ();
+ vnet_interface_output_runtime_t *rt = (void *) node->runtime_data;
+ vnet_sw_interface_t *si;
+ vnet_hw_interface_t *hi;
+ u32 n_left_to_tx, *from, *from_end, *to_tx;
u32 n_bytes, n_buffers, n_packets;
u32 n_bytes_b0, n_bytes_b1;
u32 cpu_index = vm->cpu_index;
- vnet_interface_main_t * im = &vnm->interface_main;
+ vnet_interface_main_t *im = &vnm->interface_main;
u32 next_index = VNET_INTERFACE_OUTPUT_NEXT_TX;
n_buffers = frame->n_vectors;
@@ -421,8 +425,7 @@ vnet_interface_output_node_no_flatten_inline (vlib_main_t * vm,
from = vlib_frame_args (frame);
if (rt->is_deleted)
- return vlib_error_drop_buffers (vm, node,
- from,
+ return vlib_error_drop_buffers (vm, node, from,
/* buffer stride */ 1,
n_buffers,
VNET_INTERFACE_OUTPUT_NEXT_DROP,
@@ -431,23 +434,22 @@ vnet_interface_output_node_no_flatten_inline (vlib_main_t * vm,
si = vnet_get_sw_interface (vnm, rt->sw_if_index);
hi = vnet_get_sup_hw_interface (vnm, rt->sw_if_index);
- if (! (si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ||
- ! (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP))
+ if (!(si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ||
+ !(hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP))
{
- vlib_simple_counter_main_t * cm;
-
+ vlib_simple_counter_main_t *cm;
+
cm = vec_elt_at_index (vnm->interface_main.sw_if_counters,
- VNET_INTERFACE_COUNTER_TX_ERROR);
+ VNET_INTERFACE_COUNTER_TX_ERROR);
vlib_increment_simple_counter (cm, cpu_index,
- rt->sw_if_index, n_buffers);
-
- return vlib_error_drop_buffers (vm, node,
- from,
- /* buffer stride */ 1,
- n_buffers,
- VNET_INTERFACE_OUTPUT_NEXT_DROP,
- node->node_index,
- VNET_INTERFACE_OUTPUT_ERROR_INTERFACE_DOWN);
+ rt->sw_if_index, n_buffers);
+
+ return vlib_error_drop_buffers (vm, node, from,
+ /* buffer stride */ 1,
+ n_buffers,
+ VNET_INTERFACE_OUTPUT_NEXT_DROP,
+ node->node_index,
+ VNET_INTERFACE_OUTPUT_ERROR_INTERFACE_DOWN);
}
from_end = from + n_buffers;
@@ -459,16 +461,15 @@ vnet_interface_output_node_no_flatten_inline (vlib_main_t * vm,
while (from < from_end)
{
/* Get new next frame since previous incomplete frame may have less
- than VNET_FRAME_SIZE vectors in it. */
- vlib_get_new_next_frame (vm, node, next_index,
- to_tx, n_left_to_tx);
+ than VNET_FRAME_SIZE vectors in it. */
+ vlib_get_new_next_frame (vm, node, next_index, to_tx, n_left_to_tx);
while (from + 4 <= from_end && n_left_to_tx >= 2)
{
u32 bi0, bi1;
- vlib_buffer_t * b0, * b1;
- u32 tx_swif0, tx_swif1;
- u32 next0, next1;
+ vlib_buffer_t *b0, *b1;
+ u32 tx_swif0, tx_swif1;
+ u32 next0, next1;
/* Prefetch next iteration. */
vlib_prefetch_buffer_with_index (vm, from[2], LOAD);
@@ -490,71 +491,74 @@ vnet_interface_output_node_no_flatten_inline (vlib_main_t * vm,
ASSERT (b0->current_length > 0);
ASSERT (b1->current_length > 0);
- n_bytes_b0 = vlib_buffer_length_in_chain (vm, b0);
- n_bytes_b1 = vlib_buffer_length_in_chain (vm, b1);
- tx_swif0 = vnet_buffer(b0)->sw_if_index[VLIB_TX];
- tx_swif1 = vnet_buffer(b1)->sw_if_index[VLIB_TX];
+ n_bytes_b0 = vlib_buffer_length_in_chain (vm, b0);
+ n_bytes_b1 = vlib_buffer_length_in_chain (vm, b1);
+ tx_swif0 = vnet_buffer (b0)->sw_if_index[VLIB_TX];
+ tx_swif1 = vnet_buffer (b1)->sw_if_index[VLIB_TX];
n_bytes += n_bytes_b0 + n_bytes_b1;
n_packets += 2;
- if (with_features)
- {
- b0->flags |= BUFFER_OUTPUT_FEAT_DONE;
- vnet_buffer(b0)->output_features.bitmap = si->output_feature_bitmap;
- count_trailing_zeros(next0, vnet_buffer(b0)->output_features.bitmap);
- vnet_buffer(b0)->output_features.bitmap &= ~(1 << next0);
- }
- else
- {
+ if (with_features)
+ {
+ b0->flags |= BUFFER_OUTPUT_FEAT_DONE;
+ vnet_buffer (b0)->output_features.bitmap =
+ si->output_feature_bitmap;
+ count_trailing_zeros (next0,
+ vnet_buffer (b0)->output_features.bitmap);
+ vnet_buffer (b0)->output_features.bitmap &= ~(1 << next0);
+ }
+ else
+ {
next0 = VNET_INTERFACE_OUTPUT_NEXT_TX;
- vnet_buffer(b0)->output_features.bitmap = 0;
-
- if (PREDICT_FALSE(tx_swif0 != rt->sw_if_index))
- {
- /* update vlan subif tx counts, if required */
- vlib_increment_combined_counter (im->combined_sw_if_counters
- + VNET_INTERFACE_COUNTER_TX,
- cpu_index,
- tx_swif0,
- 1,
- n_bytes_b0);
- }
- }
-
- if (with_features)
- {
- b1->flags |= BUFFER_OUTPUT_FEAT_DONE;
- vnet_buffer(b1)->output_features.bitmap = si->output_feature_bitmap;
- count_trailing_zeros(next1, vnet_buffer(b1)->output_features.bitmap);
- vnet_buffer(b1)->output_features.bitmap &= ~(1 << next1);
- }
- else
- {
+ vnet_buffer (b0)->output_features.bitmap = 0;
+
+ if (PREDICT_FALSE (tx_swif0 != rt->sw_if_index))
+ {
+ /* update vlan subif tx counts, if required */
+ vlib_increment_combined_counter (im->combined_sw_if_counters
+ +
+ VNET_INTERFACE_COUNTER_TX,
+ cpu_index, tx_swif0, 1,
+ n_bytes_b0);
+ }
+ }
+
+ if (with_features)
+ {
+ b1->flags |= BUFFER_OUTPUT_FEAT_DONE;
+ vnet_buffer (b1)->output_features.bitmap =
+ si->output_feature_bitmap;
+ count_trailing_zeros (next1,
+ vnet_buffer (b1)->output_features.bitmap);
+ vnet_buffer (b1)->output_features.bitmap &= ~(1 << next1);
+ }
+ else
+ {
next1 = VNET_INTERFACE_OUTPUT_NEXT_TX;
- vnet_buffer(b1)->output_features.bitmap = 0;
-
- /* update vlan subif tx counts, if required */
- if (PREDICT_FALSE(tx_swif1 != rt->sw_if_index))
- {
-
- vlib_increment_combined_counter (im->combined_sw_if_counters
- + VNET_INTERFACE_COUNTER_TX,
- cpu_index,
- tx_swif1,
- 1,
- n_bytes_b1);
- }
- }
+ vnet_buffer (b1)->output_features.bitmap = 0;
+
+ /* update vlan subif tx counts, if required */
+ if (PREDICT_FALSE (tx_swif1 != rt->sw_if_index))
+ {
+
+ vlib_increment_combined_counter (im->combined_sw_if_counters
+ +
+ VNET_INTERFACE_COUNTER_TX,
+ cpu_index, tx_swif1, 1,
+ n_bytes_b1);
+ }
+ }
if (with_features)
- vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_tx,
- n_left_to_tx, bi0, bi1, next0, next1);
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_tx,
+ n_left_to_tx, bi0, bi1, next0,
+ next1);
}
while (from + 1 <= from_end && n_left_to_tx >= 1)
{
u32 bi0;
- vlib_buffer_t * b0;
- u32 tx_swif0;
+ vlib_buffer_t *b0;
+ u32 tx_swif0;
bi0 = from[0];
to_tx[0] = bi0;
@@ -568,78 +572,77 @@ vnet_interface_output_node_no_flatten_inline (vlib_main_t * vm,
driver tx function. */
ASSERT (b0->current_length > 0);
- n_bytes_b0 = vlib_buffer_length_in_chain (vm, b0);
- tx_swif0 = vnet_buffer(b0)->sw_if_index[VLIB_TX];
+ n_bytes_b0 = vlib_buffer_length_in_chain (vm, b0);
+ tx_swif0 = vnet_buffer (b0)->sw_if_index[VLIB_TX];
n_bytes += n_bytes_b0;
n_packets += 1;
- if (with_features)
- {
- u32 next0;
- b0->flags |= BUFFER_OUTPUT_FEAT_DONE;
- vnet_buffer(b0)->output_features.bitmap = si->output_feature_bitmap;
- count_trailing_zeros(next0, vnet_buffer(b0)->output_features.bitmap);
- vnet_buffer(b0)->output_features.bitmap &= ~(1 << next0);
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_tx,
- n_left_to_tx, bi0, next0);
- }
- else
- {
- vnet_buffer(b0)->output_features.bitmap = 0;
-
- if (PREDICT_FALSE(tx_swif0 != rt->sw_if_index))
- {
-
- vlib_increment_combined_counter (im->combined_sw_if_counters
- + VNET_INTERFACE_COUNTER_TX,
- cpu_index,
- tx_swif0,
- 1,
- n_bytes_b0);
- }
- }
+ if (with_features)
+ {
+ u32 next0;
+ b0->flags |= BUFFER_OUTPUT_FEAT_DONE;
+ vnet_buffer (b0)->output_features.bitmap =
+ si->output_feature_bitmap;
+ count_trailing_zeros (next0,
+ vnet_buffer (b0)->output_features.bitmap);
+ vnet_buffer (b0)->output_features.bitmap &= ~(1 << next0);
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_tx,
+ n_left_to_tx, bi0, next0);
+ }
+ else
+ {
+ vnet_buffer (b0)->output_features.bitmap = 0;
+
+ if (PREDICT_FALSE (tx_swif0 != rt->sw_if_index))
+ {
+
+ vlib_increment_combined_counter (im->combined_sw_if_counters
+ +
+ VNET_INTERFACE_COUNTER_TX,
+ cpu_index, tx_swif0, 1,
+ n_bytes_b0);
+ }
+ }
}
- vlib_put_next_frame (vm, node, next_index,
- n_left_to_tx);
+ vlib_put_next_frame (vm, node, next_index, n_left_to_tx);
}
/* Update main interface stats. */
vlib_increment_combined_counter (im->combined_sw_if_counters
- + VNET_INTERFACE_COUNTER_TX,
- cpu_index,
- rt->sw_if_index,
- n_packets,
- n_bytes);
+ + VNET_INTERFACE_COUNTER_TX,
+ cpu_index,
+ rt->sw_if_index, n_packets, n_bytes);
return n_buffers;
}
uword
vnet_interface_output_node_no_flatten (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
- vnet_main_t * vnm = vnet_get_main ();
- vnet_interface_output_runtime_t * rt = (void *) node->runtime_data;
- vnet_sw_interface_t * si;
+ vnet_main_t *vnm = vnet_get_main ();
+ vnet_interface_output_runtime_t *rt = (void *) node->runtime_data;
+ vnet_sw_interface_t *si;
si = vnet_get_sw_interface (vnm, rt->sw_if_index);
- if (PREDICT_FALSE(si->output_feature_bitmap))
+ if (PREDICT_FALSE (si->output_feature_bitmap))
{
/* if first pakcet in the frame have BUFFER_OUTPUT_FEAT_DONE flag set
- then whole frame is arriving from feature node */
+ then whole frame is arriving from feature node */
- u32 * from = vlib_frame_args (frame);
- vlib_buffer_t * b = vlib_get_buffer (vm, from[0]);
+ u32 *from = vlib_frame_args (frame);
+ vlib_buffer_t *b = vlib_get_buffer (vm, from[0]);
if ((b->flags & BUFFER_OUTPUT_FEAT_DONE) == 0)
- return vnet_interface_output_node_no_flatten_inline (vm, node, frame, 1);
+ return vnet_interface_output_node_no_flatten_inline (vm, node, frame,
+ 1);
}
- return vnet_interface_output_node_no_flatten_inline (vm, node, frame, 0);
+ return vnet_interface_output_node_no_flatten_inline (vm, node, frame, 0);
}
-VLIB_NODE_FUNCTION_MULTIARCH_CLONE (vnet_interface_output_node_no_flatten)
-CLIB_MULTIARCH_SELECT_FN (vnet_interface_output_node_no_flatten)
+VLIB_NODE_FUNCTION_MULTIARCH_CLONE (vnet_interface_output_node_no_flatten);
+CLIB_MULTIARCH_SELECT_FN (vnet_interface_output_node_no_flatten);
/* Use buffer's sw_if_index[VNET_TX] to choose output interface. */
static uword
@@ -647,8 +650,8 @@ vnet_per_buffer_interface_output (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
- vnet_main_t * vnm = vnet_get_main();
- u32 n_left_to_next, * from, * to_next;
+ vnet_main_t *vnm = vnet_get_main ();
+ u32 n_left_to_next, *from, *to_next;
u32 n_left_from, next_index;
n_left_from = frame->n_vectors;
@@ -663,8 +666,8 @@ vnet_per_buffer_interface_output (vlib_main_t * vm,
while (n_left_from >= 4 && n_left_to_next >= 2)
{
u32 bi0, bi1, next0, next1;
- vlib_buffer_t * b0, * b1;
- vnet_hw_interface_t * hi0, * hi1;
+ vlib_buffer_t *b0, *b1;
+ vnet_hw_interface_t *hi0, *hi1;
/* Prefetch next iteration. */
vlib_prefetch_buffer_with_index (vm, from[2], LOAD);
@@ -682,21 +685,28 @@ vnet_per_buffer_interface_output (vlib_main_t * vm,
b0 = vlib_get_buffer (vm, bi0);
b1 = vlib_get_buffer (vm, bi1);
- hi0 = vnet_get_sup_hw_interface (vnm, vnet_buffer (b0)->sw_if_index[VLIB_TX]);
- hi1 = vnet_get_sup_hw_interface (vnm, vnet_buffer (b1)->sw_if_index[VLIB_TX]);
+ hi0 =
+ vnet_get_sup_hw_interface (vnm,
+ vnet_buffer (b0)->sw_if_index
+ [VLIB_TX]);
+ hi1 =
+ vnet_get_sup_hw_interface (vnm,
+ vnet_buffer (b1)->sw_if_index
+ [VLIB_TX]);
next0 = hi0->hw_if_index;
next1 = hi1->hw_if_index;
- vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next, n_left_to_next,
- bi0, bi1, next0, next1);
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, bi1, next0,
+ next1);
}
while (n_left_from > 0 && n_left_to_next > 0)
{
u32 bi0, next0;
- vlib_buffer_t * b0;
- vnet_hw_interface_t * hi0;
+ vlib_buffer_t *b0;
+ vnet_hw_interface_t *hi0;
bi0 = from[0];
to_next[0] = bi0;
@@ -707,12 +717,15 @@ vnet_per_buffer_interface_output (vlib_main_t * vm,
b0 = vlib_get_buffer (vm, bi0);
- hi0 = vnet_get_sup_hw_interface (vnm, vnet_buffer (b0)->sw_if_index[VLIB_TX]);
+ hi0 =
+ vnet_get_sup_hw_interface (vnm,
+ vnet_buffer (b0)->sw_if_index
+ [VLIB_TX]);
next0 = hi0->hw_if_index;
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, n_left_to_next,
- bi0, next0);
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, next0);
}
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
@@ -724,7 +737,7 @@ vnet_per_buffer_interface_output (vlib_main_t * vm,
always_inline u32
counter_index (vlib_main_t * vm, vlib_error_t e)
{
- vlib_node_t * n;
+ vlib_node_t *n;
u32 ci, ni;
ni = vlib_error_get_node (e);
@@ -738,13 +751,14 @@ counter_index (vlib_main_t * vm, vlib_error_t e)
return ci;
}
-static u8 * format_vnet_error_trace (u8 * s, va_list * va)
+static u8 *
+format_vnet_error_trace (u8 * s, va_list * va)
{
- vlib_main_t * vm = va_arg (*va, vlib_main_t *);
+ vlib_main_t *vm = va_arg (*va, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *);
- vlib_error_t * e = va_arg (*va, vlib_error_t *);
- vlib_node_t * error_node;
- vlib_error_main_t * em = &vm->error_main;
+ vlib_error_t *e = va_arg (*va, vlib_error_t *);
+ vlib_node_t *error_node;
+ vlib_error_main_t *em = &vm->error_main;
u32 i;
error_node = vlib_get_node (vm, vlib_error_get_node (e[0]));
@@ -756,19 +770,18 @@ static u8 * format_vnet_error_trace (u8 * s, va_list * va)
static void
trace_errors_with_buffers (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+ vlib_node_runtime_t * node, vlib_frame_t * frame)
{
- u32 n_left, * buffers;
+ u32 n_left, *buffers;
buffers = vlib_frame_vector_args (frame);
n_left = frame->n_vectors;
-
+
while (n_left >= 4)
{
u32 bi0, bi1;
- vlib_buffer_t * b0, * b1;
- vlib_error_t * t0, * t1;
+ vlib_buffer_t *b0, *b1;
+ vlib_error_t *t0, *t1;
/* Prefetch next iteration. */
vlib_prefetch_buffer_with_index (vm, buffers[2], LOAD);
@@ -797,8 +810,8 @@ trace_errors_with_buffers (vlib_main_t * vm,
while (n_left >= 1)
{
u32 bi0;
- vlib_buffer_t * b0;
- vlib_error_t * t0;
+ vlib_buffer_t *b0;
+ vlib_error_t *t0;
bi0 = buffers[0];
@@ -819,7 +832,7 @@ validate_error (vlib_main_t * vm, vlib_error_t * e, u32 index)
{
uword node_index = vlib_error_get_node (e[0]);
uword code = vlib_error_get_code (e[0]);
- vlib_node_t * n;
+ vlib_node_t *n;
if (node_index >= vec_len (vm->node_main.nodes))
return format (0, "[%d], node index out of range 0x%x, error 0x%x",
@@ -835,12 +848,11 @@ validate_error (vlib_main_t * vm, vlib_error_t * e, u32 index)
static u8 *
validate_error_frame (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * f)
+ vlib_node_runtime_t * node, vlib_frame_t * f)
{
- u32 * buffers = vlib_frame_args (f);
- vlib_buffer_t * b;
- u8 * msg = 0;
+ u32 *buffers = vlib_frame_args (f);
+ vlib_buffer_t *b;
+ u8 *msg = 0;
uword i;
for (i = 0; i < f->n_vectors; i++)
@@ -854,7 +866,8 @@ validate_error_frame (vlib_main_t * vm,
return msg;
}
-typedef enum {
+typedef enum
+{
VNET_ERROR_DISPOSITION_DROP,
VNET_ERROR_DISPOSITION_PUNT,
VNET_ERROR_N_DISPOSITION,
@@ -863,26 +876,25 @@ typedef enum {
always_inline void
do_packet (vlib_main_t * vm, vlib_error_t a)
{
- vlib_error_main_t * em = &vm->error_main;
+ vlib_error_main_t *em = &vm->error_main;
u32 i = counter_index (vm, a);
em->counters[i] += 1;
vlib_error_elog_count (vm, i, 1);
}
-
+
static_always_inline uword
process_drop_punt (vlib_main_t * vm,
vlib_node_runtime_t * node,
- vlib_frame_t * frame,
- vnet_error_disposition_t disposition)
+ vlib_frame_t * frame, vnet_error_disposition_t disposition)
{
- vnet_main_t * vnm = vnet_get_main();
- vlib_error_main_t * em = &vm->error_main;
- u32 * buffers, * first_buffer;
+ vnet_main_t *vnm = vnet_get_main ();
+ vlib_error_main_t *em = &vm->error_main;
+ u32 *buffers, *first_buffer;
vlib_error_t current_error;
u32 current_counter_index, n_errors_left;
u32 current_sw_if_index, n_errors_current_sw_if_index;
u64 current_counter;
- vlib_simple_counter_main_t * cm;
+ vlib_simple_counter_main_t *cm;
u32 cpu_index = vm->cpu_index;
static vlib_error_t memory[VNET_ERROR_N_DISPOSITION];
@@ -892,9 +904,9 @@ process_drop_punt (vlib_main_t * vm,
first_buffer = buffers;
{
- vlib_buffer_t * b = vlib_get_buffer (vm, first_buffer[0]);
+ vlib_buffer_t *b = vlib_get_buffer (vm, first_buffer[0]);
- if (! memory_init[disposition])
+ if (!memory_init[disposition])
{
memory_init[disposition] = 1;
memory[disposition] = b->error;
@@ -910,7 +922,7 @@ process_drop_punt (vlib_main_t * vm,
if (node->flags & VLIB_NODE_FLAG_TRACE)
trace_errors_with_buffers (vm, node, frame);
-
+
n_errors_left = frame->n_vectors;
cm = vec_elt_at_index (vnm->interface_main.sw_if_counters,
(disposition == VNET_ERROR_DISPOSITION_PUNT
@@ -919,8 +931,8 @@ process_drop_punt (vlib_main_t * vm,
while (n_errors_left >= 2)
{
- vlib_buffer_t * b0, * b1;
- vnet_sw_interface_t * sw_if0, * sw_if1;
+ vlib_buffer_t *b0, *b1;
+ vnet_sw_interface_t *sw_if0, *sw_if1;
vlib_error_t e0, e1;
u32 bi0, bi1;
u32 sw_if_index0, sw_if_index1;
@@ -944,7 +956,7 @@ process_drop_punt (vlib_main_t * vm,
n_errors_current_sw_if_index += 2;
/* Speculatively assume all 2 (node, code) pairs are equal
- to current (node, code). */
+ to current (node, code). */
current_counter += 2;
if (PREDICT_FALSE (e0 != current_error
@@ -962,13 +974,13 @@ process_drop_punt (vlib_main_t * vm,
sub-interfaces. */
sw_if0 = vnet_get_sw_interface (vnm, sw_if_index0);
vlib_increment_simple_counter
- (cm, cpu_index, sw_if0->sup_sw_if_index,
- sw_if0->sup_sw_if_index != sw_if_index0);
+ (cm, cpu_index, sw_if0->sup_sw_if_index,
+ sw_if0->sup_sw_if_index != sw_if_index0);
sw_if1 = vnet_get_sw_interface (vnm, sw_if_index1);
vlib_increment_simple_counter
- (cm, cpu_index, sw_if1->sup_sw_if_index,
- sw_if1->sup_sw_if_index != sw_if_index1);
+ (cm, cpu_index, sw_if1->sup_sw_if_index,
+ sw_if1->sup_sw_if_index != sw_if_index1);
em->counters[current_counter_index] = current_counter;
do_packet (vm, e0);
@@ -986,8 +998,8 @@ process_drop_punt (vlib_main_t * vm,
while (n_errors_left >= 1)
{
- vlib_buffer_t * b0;
- vnet_sw_interface_t * sw_if0;
+ vlib_buffer_t *b0;
+ vnet_sw_interface_t *sw_if0;
vlib_error_t e0;
u32 bi0, sw_if_index0;
@@ -1007,7 +1019,7 @@ process_drop_punt (vlib_main_t * vm,
/* Increment super-interface drop/punt counters for sub-interfaces. */
sw_if0 = vnet_get_sw_interface (vnm, sw_if_index0);
- vlib_increment_simple_counter (cm, cpu_index, sw_if0->sup_sw_if_index,
+ vlib_increment_simple_counter (cm, cpu_index, sw_if0->sup_sw_if_index,
sw_if0->sup_sw_if_index != sw_if_index0);
if (PREDICT_FALSE (e0 != current_error))
@@ -1017,7 +1029,7 @@ process_drop_punt (vlib_main_t * vm,
vlib_error_elog_count (vm, current_counter_index,
(current_counter
- em->counters[current_counter_index]));
-
+
em->counters[current_counter_index] = current_counter;
do_packet (vm, e0);
@@ -1029,15 +1041,15 @@ process_drop_punt (vlib_main_t * vm,
if (n_errors_current_sw_if_index > 0)
{
- vnet_sw_interface_t * si;
+ vnet_sw_interface_t *si;
vlib_increment_simple_counter (cm, cpu_index, current_sw_if_index,
n_errors_current_sw_if_index);
si = vnet_get_sw_interface (vnm, current_sw_if_index);
if (si->sup_sw_if_index != current_sw_if_index)
- vlib_increment_simple_counter (cm, cpu_index, si->sup_sw_if_index,
- n_errors_current_sw_if_index);
+ vlib_increment_simple_counter (cm, cpu_index, si->sup_sw_if_index,
+ n_errors_current_sw_if_index);
}
vlib_error_elog_count (vm, current_counter_index,
@@ -1050,16 +1062,12 @@ process_drop_punt (vlib_main_t * vm,
/* Save memory for next iteration. */
memory[disposition] = current_error;
- if (disposition == VNET_ERROR_DISPOSITION_DROP
- || ! vm->os_punt_frame)
+ if (disposition == VNET_ERROR_DISPOSITION_DROP || !vm->os_punt_frame)
{
- vlib_buffer_free
- (vm,
- first_buffer,
- frame->n_vectors);
+ vlib_buffer_free (vm, first_buffer, frame->n_vectors);
/* If there is no punt function, free the frame as well. */
- if (disposition == VNET_ERROR_DISPOSITION_PUNT && ! vm->os_punt_frame)
+ if (disposition == VNET_ERROR_DISPOSITION_PUNT && !vm->os_punt_frame)
vlib_frame_free (vm, node, frame);
}
else
@@ -1068,14 +1076,13 @@ process_drop_punt (vlib_main_t * vm,
return frame->n_vectors;
}
-static inline void
-pcap_drop_trace (vlib_main_t * vm,
- vnet_interface_main_t * im,
- vlib_frame_t * f)
+static inline void
+pcap_drop_trace (vlib_main_t * vm,
+ vnet_interface_main_t * im, vlib_frame_t * f)
{
- u32 * from;
+ u32 *from;
u32 n_left = f->n_vectors;
- vlib_buffer_t * b0, * p1;
+ vlib_buffer_t *b0, *p1;
u32 bi0;
i16 save_current_data;
u16 save_current_length;
@@ -1085,48 +1092,49 @@ pcap_drop_trace (vlib_main_t * vm,
while (n_left > 0)
{
if (PREDICT_TRUE (n_left > 1))
- {
- p1 = vlib_get_buffer (vm, from[1]);
- vlib_prefetch_buffer_header (p1, LOAD);
- }
-
+ {
+ p1 = vlib_get_buffer (vm, from[1]);
+ vlib_prefetch_buffer_header (p1, LOAD);
+ }
+
bi0 = from[0];
b0 = vlib_get_buffer (vm, bi0);
from++;
n_left--;
-
+
/* See if we're pointedly ignoring this specific error */
- if (im->pcap_drop_filter_hash
- && hash_get (im->pcap_drop_filter_hash, b0->error))
- continue;
+ if (im->pcap_drop_filter_hash
+ && hash_get (im->pcap_drop_filter_hash, b0->error))
+ continue;
/* Trace all drops, or drops received on a specific interface */
if (im->pcap_sw_if_index == 0 ||
- im->pcap_sw_if_index == vnet_buffer(b0)->sw_if_index [VLIB_RX])
- {
- save_current_data = b0->current_data;
- save_current_length = b0->current_length;
-
- /*
- * Typically, we'll need to rewind the buffer
- */
- if (b0->current_data > 0)
- vlib_buffer_advance (b0, (word) -b0->current_data);
-
- pcap_add_buffer (&im->pcap_main, vm, bi0, 512);
-
- b0->current_data = save_current_data;
- b0->current_length = save_current_length;
- }
+ im->pcap_sw_if_index == vnet_buffer (b0)->sw_if_index[VLIB_RX])
+ {
+ save_current_data = b0->current_data;
+ save_current_length = b0->current_length;
+
+ /*
+ * Typically, we'll need to rewind the buffer
+ */
+ if (b0->current_data > 0)
+ vlib_buffer_advance (b0, (word) - b0->current_data);
+
+ pcap_add_buffer (&im->pcap_main, vm, bi0, 512);
+
+ b0->current_data = save_current_data;
+ b0->current_length = save_current_length;
+ }
}
}
-void vnet_pcap_drop_trace_filter_add_del (u32 error_index, int is_add)
+void
+vnet_pcap_drop_trace_filter_add_del (u32 error_index, int is_add)
{
- vnet_interface_main_t * im = &vnet_get_main()->interface_main;
+ vnet_interface_main_t *im = &vnet_get_main ()->interface_main;
if (im->pcap_drop_filter_hash == 0)
- im->pcap_drop_filter_hash = hash_create (0, sizeof (uword));
+ im->pcap_drop_filter_hash = hash_create (0, sizeof (uword));
if (is_add)
hash_set (im->pcap_drop_filter_hash, error_index, 1);
@@ -1136,10 +1144,9 @@ void vnet_pcap_drop_trace_filter_add_del (u32 error_index, int is_add)
static uword
process_drop (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+ vlib_node_runtime_t * node, vlib_frame_t * frame)
{
- vnet_interface_main_t * im = &vnet_get_main()->interface_main;
+ vnet_interface_main_t *im = &vnet_get_main ()->interface_main;
if (PREDICT_FALSE (im->drop_pcap_enable))
pcap_drop_trace (vm, im, frame);
@@ -1149,12 +1156,12 @@ process_drop (vlib_main_t * vm,
static uword
process_punt (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+ vlib_node_runtime_t * node, vlib_frame_t * frame)
{
return process_drop_punt (vm, node, frame, VNET_ERROR_DISPOSITION_PUNT);
}
+/* *INDENT-OFF* */
VLIB_REGISTER_NODE (drop_buffers,static) = {
.function = process_drop,
.name = "error-drop",
@@ -1163,9 +1170,11 @@ VLIB_REGISTER_NODE (drop_buffers,static) = {
.format_trace = format_vnet_error_trace,
.validate_frame = validate_error_frame,
};
+/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (drop_buffers, process_drop)
+VLIB_NODE_FUNCTION_MULTIARCH (drop_buffers, process_drop);
+/* *INDENT-OFF* */
VLIB_REGISTER_NODE (punt_buffers,static) = {
.function = process_punt,
.flags = (VLIB_NODE_FLAG_FRAME_NO_FREE_AFTER_DISPATCH
@@ -1175,23 +1184,27 @@ VLIB_REGISTER_NODE (punt_buffers,static) = {
.format_trace = format_vnet_error_trace,
.validate_frame = validate_error_frame,
};
+/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (punt_buffers, process_punt)
+VLIB_NODE_FUNCTION_MULTIARCH (punt_buffers, process_punt);
+/* *INDENT-OFF* */
VLIB_REGISTER_NODE (vnet_per_buffer_interface_output_node,static) = {
.function = vnet_per_buffer_interface_output,
.name = "interface-output",
.vector_size = sizeof (u32),
};
+/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (vnet_per_buffer_interface_output_node, vnet_per_buffer_interface_output)
+VLIB_NODE_FUNCTION_MULTIARCH (vnet_per_buffer_interface_output_node,
+ vnet_per_buffer_interface_output);
clib_error_t *
vnet_per_buffer_interface_output_hw_interface_add_del (vnet_main_t * vnm,
u32 hw_if_index,
u32 is_create)
{
- vnet_hw_interface_t * hi = vnet_get_hw_interface (vnm, hw_if_index);
+ vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
u32 next_index;
next_index = vlib_node_add_next_with_slot
@@ -1204,136 +1217,147 @@ vnet_per_buffer_interface_output_hw_interface_add_del (vnet_main_t * vnm,
return 0;
}
-VNET_HW_INTERFACE_ADD_DEL_FUNCTION
-(vnet_per_buffer_interface_output_hw_interface_add_del);
+VNET_HW_INTERFACE_ADD_DEL_FUNCTION
+ (vnet_per_buffer_interface_output_hw_interface_add_del);
static clib_error_t *
pcap_drop_trace_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
{
- vnet_main_t * vnm = vnet_get_main();
- vnet_interface_main_t * im = &vnm->interface_main;
- u8 * filename;
+ vnet_main_t *vnm = vnet_get_main ();
+ vnet_interface_main_t *im = &vnm->interface_main;
+ u8 *filename;
u32 max;
int matched = 0;
- clib_error_t * error = 0;
+ clib_error_t *error = 0;
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (input, "on"))
- {
- if (im->drop_pcap_enable == 0)
- {
- if (im->pcap_filename == 0)
- im->pcap_filename = format (0, "/tmp/drop.pcap%c", 0);
-
- memset (&im->pcap_main, 0, sizeof (im->pcap_main));
- im->pcap_main.file_name = (char *) im->pcap_filename;
- im->pcap_main.n_packets_to_capture = 100;
- if (im->pcap_pkts_to_capture)
- im->pcap_main.n_packets_to_capture = im->pcap_pkts_to_capture;
-
- im->pcap_main.packet_type = PCAP_PACKET_TYPE_ethernet;
- im->drop_pcap_enable = 1;
- matched = 1;
- vlib_cli_output (vm, "pcap drop capture on...");
- }
- else
- {
- vlib_cli_output (vm, "pcap drop capture already on...");
- }
- matched = 1;
- }
+ {
+ if (im->drop_pcap_enable == 0)
+ {
+ if (im->pcap_filename == 0)
+ im->pcap_filename = format (0, "/tmp/drop.pcap%c", 0);
+
+ memset (&im->pcap_main, 0, sizeof (im->pcap_main));
+ im->pcap_main.file_name = (char *) im->pcap_filename;
+ im->pcap_main.n_packets_to_capture = 100;
+ if (im->pcap_pkts_to_capture)
+ im->pcap_main.n_packets_to_capture = im->pcap_pkts_to_capture;
+
+ im->pcap_main.packet_type = PCAP_PACKET_TYPE_ethernet;
+ im->drop_pcap_enable = 1;
+ matched = 1;
+ vlib_cli_output (vm, "pcap drop capture on...");
+ }
+ else
+ {
+ vlib_cli_output (vm, "pcap drop capture already on...");
+ }
+ matched = 1;
+ }
else if (unformat (input, "off"))
- {
- matched = 1;
-
- if (im->drop_pcap_enable)
- {
- vlib_cli_output (vm, "captured %d pkts...",
- im->pcap_main.n_packets_captured);
- if (im->pcap_main.n_packets_captured)
- {
- im->pcap_main.n_packets_to_capture =
- im->pcap_main.n_packets_captured;
- error = pcap_write (&im->pcap_main);
- if (error)
- clib_error_report (error);
- else
- vlib_cli_output (vm, "saved to %s...", im->pcap_filename);
- }
- }
- else
- {
- vlib_cli_output (vm, "pcap drop capture already off...");
- }
-
- im->drop_pcap_enable = 0;
- }
+ {
+ matched = 1;
+
+ if (im->drop_pcap_enable)
+ {
+ vlib_cli_output (vm, "captured %d pkts...",
+ im->pcap_main.n_packets_captured);
+ if (im->pcap_main.n_packets_captured)
+ {
+ im->pcap_main.n_packets_to_capture =
+ im->pcap_main.n_packets_captured;
+ error = pcap_write (&im->pcap_main);
+ if (error)
+ clib_error_report (error);
+ else
+ vlib_cli_output (vm, "saved to %s...", im->pcap_filename);
+ }
+ }
+ else
+ {
+ vlib_cli_output (vm, "pcap drop capture already off...");
+ }
+
+ im->drop_pcap_enable = 0;
+ }
else if (unformat (input, "max %d", &max))
- {
- im->pcap_pkts_to_capture = max;
- matched = 1;
- }
-
- else if (unformat (input, "intfc %U",
- unformat_vnet_sw_interface, vnm,
- &im->pcap_sw_if_index))
- matched = 1;
+ {
+ im->pcap_pkts_to_capture = max;
+ matched = 1;
+ }
+
+ else if (unformat (input, "intfc %U",
+ unformat_vnet_sw_interface, vnm,
+ &im->pcap_sw_if_index))
+ matched = 1;
else if (unformat (input, "intfc any"))
- {
- im->pcap_sw_if_index = 0;
- matched = 1;
- }
+ {
+ im->pcap_sw_if_index = 0;
+ matched = 1;
+ }
else if (unformat (input, "file %s", &filename))
- {
- u8 * chroot_filename;
- /* Brain-police user path input */
- if (strstr((char *)filename, "..") || index((char *)filename, '/'))
- {
- vlib_cli_output (vm, "illegal characters in filename '%s'",
- filename);
- continue;
- }
-
- chroot_filename = format (0, "/tmp/%s%c", filename, 0);
- vec_free (filename);
-
- if (im->pcap_filename)
- vec_free (im->pcap_filename);
- vec_add1 (filename, 0);
- im->pcap_filename = chroot_filename;
- matched = 1;
- }
+ {
+ u8 *chroot_filename;
+ /* Brain-police user path input */
+ if (strstr ((char *) filename, "..")
+ || index ((char *) filename, '/'))
+ {
+ vlib_cli_output (vm, "illegal characters in filename '%s'",
+ filename);
+ continue;
+ }
+
+ chroot_filename = format (0, "/tmp/%s%c", filename, 0);
+ vec_free (filename);
+
+ if (im->pcap_filename)
+ vec_free (im->pcap_filename);
+ vec_add1 (filename, 0);
+ im->pcap_filename = chroot_filename;
+ matched = 1;
+ }
else if (unformat (input, "status"))
- {
- if (im->drop_pcap_enable == 0)
- {
- vlib_cli_output (vm, "pcap drop capture is off...");
- continue;
- }
-
- vlib_cli_output (vm, "pcap drop capture: %d of %d pkts...",
- im->pcap_main.n_packets_captured,
- im->pcap_main.n_packets_to_capture);
- matched = 1;
- }
+ {
+ if (im->drop_pcap_enable == 0)
+ {
+ vlib_cli_output (vm, "pcap drop capture is off...");
+ continue;
+ }
+
+ vlib_cli_output (vm, "pcap drop capture: %d of %d pkts...",
+ im->pcap_main.n_packets_captured,
+ im->pcap_main.n_packets_to_capture);
+ matched = 1;
+ }
else
- break;
+ break;
}
if (matched == 0)
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ return clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, input);
return 0;
}
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (pcap_trace_command, static) = {
- .path = "pcap drop trace",
- .short_help =
- "pcap drop trace on off max <nn> intfc <intfc> file <name> status",
- .function = pcap_drop_trace_command_fn,
+ .path = "pcap drop trace",
+ .short_help =
+ "pcap drop trace on off max <nn> intfc <intfc> file <name> status",
+ .function = pcap_drop_trace_command_fn,
};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/l3_types.h b/vnet/vnet/l3_types.h
index 2902072148c..28b0891e715 100644
--- a/vnet/vnet/l3_types.h
+++ b/vnet/vnet/l3_types.h
@@ -41,10 +41,19 @@
#define included_vnet_l3_types_h
/* Inherit generic L3 packet types from ethernet. */
-typedef enum {
+typedef enum
+{
#define ethernet_type(n,f) VNET_L3_PACKET_TYPE_##f,
#include <vnet/ethernet/types.def>
#undef ethernet_type
} vnet_l3_packet_type_t;
#endif /* included_vnet_l3_types_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/misc.c b/vnet/vnet/misc.c
index 89bc15c13ca..c0729f73c16 100644
--- a/vnet/vnet/misc.c
+++ b/vnet/vnet/misc.c
@@ -49,29 +49,32 @@ vnet_get_main (void)
static uword
vnet_local_interface_tx (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * f)
+ vlib_node_runtime_t * node, vlib_frame_t * f)
{
ASSERT (0);
return f->n_vectors;
}
+/* *INDENT-OFF* */
VNET_DEVICE_CLASS (vnet_local_interface_device_class) = {
.name = "local",
.tx_function = vnet_local_interface_tx,
};
+/* *INDENT-ON* */
+/* *INDENT-OFF* */
VNET_HW_INTERFACE_CLASS (vnet_local_interface_hw_class,static) = {
.name = "local",
};
+/* *INDENT-ON* */
clib_error_t *
vnet_main_init (vlib_main_t * vm)
{
- vnet_main_t * vnm = vnet_get_main();
- clib_error_t * error;
+ vnet_main_t *vnm = vnet_get_main ();
+ clib_error_t *error;
u32 hw_if_index;
- vnet_hw_interface_t * hw;
+ vnet_hw_interface_t *hw;
if ((error = vlib_call_init_function (vm, vnet_interface_init)))
return error;
@@ -88,8 +91,7 @@ vnet_main_init (vlib_main_t * vm)
vnm->vlib_main = vm;
hw_if_index = vnet_register_interface
- (vnm,
- vnet_local_interface_device_class.index, /* instance */ 0,
+ (vnm, vnet_local_interface_device_class.index, /* instance */ 0,
vnet_local_interface_hw_class.index, /* instance */ 0);
hw = vnet_get_hw_interface (vnm, hw_if_index);
@@ -100,3 +102,11 @@ vnet_main_init (vlib_main_t * vm)
}
VLIB_INIT_FUNCTION (vnet_main_init);
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/pipeline.h b/vnet/vnet/pipeline.h
index 5a0d4dcc616..a4aa5cf5277 100644
--- a/vnet/vnet/pipeline.h
+++ b/vnet/vnet/pipeline.h
@@ -23,14 +23,14 @@
* <Define pipeline stages>
*
* #include <vnet/pipeline.h>
- *
+ *
* static uword my_node_fn (vlib_main_t * vm,
* vlib_node_runtime_t * node,
* vlib_frame_t * frame)
* {
* return dispatch_pipeline (vm, node, frame);
* }
- *
+ *
*/
#ifndef NSTAGES
@@ -41,20 +41,20 @@
#define STAGE_INLINE inline
#endif
-/*
+/*
* A prefetch stride of 2 is quasi-equivalent to doubling the number
* of stages with every other pipeline stage empty.
*/
-/*
- * This is a typical first pipeline stage, which prefetches
- * buffer metadata and the first line of pkt data.
+/*
+ * This is a typical first pipeline stage, which prefetches
+ * buffer metadata and the first line of pkt data.
* To use it:
* #define stage0 generic_stage0
*/
-static STAGE_INLINE void generic_stage0 (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- u32 buffer_index)
+static STAGE_INLINE void
+generic_stage0 (vlib_main_t * vm,
+ vlib_node_runtime_t * node, u32 buffer_index)
{
/* generic default stage 0 here */
vlib_buffer_t *b = vlib_get_buffer (vm, buffer_index);
@@ -66,62 +66,61 @@ static STAGE_INLINE void generic_stage0 (vlib_main_t * vm,
static STAGE_INLINE uword
dispatch_pipeline (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+ vlib_node_runtime_t * node, vlib_frame_t * frame)
{
- u32 * from = vlib_frame_vector_args (frame);
- u32 n_left_from, n_left_to_next, * to_next, next_index, next0;
+ u32 *from = vlib_frame_vector_args (frame);
+ u32 n_left_from, n_left_to_next, *to_next, next_index, next0;
int pi, pi_limit;
-
+
n_left_from = frame->n_vectors;
next_index = node->cached_next_index;
-
- while (n_left_from > 0)
+
+ while (n_left_from > 0)
{
vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-
+
pi_limit = clib_min (n_left_from, n_left_to_next);
-
- for (pi = 0; pi < NSTAGES-1; pi++)
- {
- if(pi == pi_limit)
- break;
- stage0 (vm, node, from[pi]);
- }
-
- for (; pi < pi_limit; pi++)
- {
- stage0 (vm, node, from[pi]);
- to_next[0] = from [pi - 1];
- to_next++;
- n_left_to_next--;
- next0 = last_stage (vm, node, from [pi - 1]);
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next,
- from[pi - 1], next0);
- n_left_from--;
- if ((int) n_left_to_next < 0 && n_left_from > 0)
- vlib_get_next_frame (vm, node, next_index, to_next,
- n_left_to_next);
- }
-
- for (; pi < (pi_limit + (NSTAGES-1)); pi++)
- {
- if (((pi - 1) >= 0) && ((pi - 1) < pi_limit))
- {
- to_next[0] = from [pi - 1];
- to_next++;
- n_left_to_next--;
- next0 = last_stage (vm, node, from [pi - 1]);
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next,
- from[pi - 1], next0);
- n_left_from--;
- if ((int) n_left_to_next < 0 && n_left_from > 0)
- vlib_get_next_frame (vm, node, next_index, to_next,
- n_left_to_next);
- }
- }
+
+ for (pi = 0; pi < NSTAGES - 1; pi++)
+ {
+ if (pi == pi_limit)
+ break;
+ stage0 (vm, node, from[pi]);
+ }
+
+ for (; pi < pi_limit; pi++)
+ {
+ stage0 (vm, node, from[pi]);
+ to_next[0] = from[pi - 1];
+ to_next++;
+ n_left_to_next--;
+ next0 = last_stage (vm, node, from[pi - 1]);
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
+ to_next, n_left_to_next,
+ from[pi - 1], next0);
+ n_left_from--;
+ if ((int) n_left_to_next < 0 && n_left_from > 0)
+ vlib_get_next_frame (vm, node, next_index, to_next,
+ n_left_to_next);
+ }
+
+ for (; pi < (pi_limit + (NSTAGES - 1)); pi++)
+ {
+ if (((pi - 1) >= 0) && ((pi - 1) < pi_limit))
+ {
+ to_next[0] = from[pi - 1];
+ to_next++;
+ n_left_to_next--;
+ next0 = last_stage (vm, node, from[pi - 1]);
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
+ to_next, n_left_to_next,
+ from[pi - 1], next0);
+ n_left_from--;
+ if ((int) n_left_to_next < 0 && n_left_from > 0)
+ vlib_get_next_frame (vm, node, next_index, to_next,
+ n_left_to_next);
+ }
+ }
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
from += pi_limit;
}
@@ -132,69 +131,68 @@ dispatch_pipeline (vlib_main_t * vm,
#if NSTAGES == 3
static STAGE_INLINE uword
dispatch_pipeline (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+ vlib_node_runtime_t * node, vlib_frame_t * frame)
{
- u32 * from = vlib_frame_vector_args (frame);
- u32 n_left_from, n_left_to_next, * to_next, next_index, next0;
+ u32 *from = vlib_frame_vector_args (frame);
+ u32 n_left_from, n_left_to_next, *to_next, next_index, next0;
int pi, pi_limit;
-
+
n_left_from = frame->n_vectors;
next_index = node->cached_next_index;
-
- while (n_left_from > 0)
+
+ while (n_left_from > 0)
{
vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-
+
pi_limit = clib_min (n_left_from, n_left_to_next);
-
- for (pi = 0; pi < NSTAGES-1; pi++)
- {
- if(pi == pi_limit)
- break;
- stage0 (vm, node, from[pi]);
- if (pi-1 >= 0)
- stage1 (vm, node, from[pi-1]);
- }
-
- for (; pi < pi_limit; pi++)
- {
- stage0 (vm, node, from[pi]);
- stage1 (vm, node, from[pi-1]);
- to_next[0] = from [pi - 2];
- to_next++;
- n_left_to_next--;
- next0 = last_stage (vm, node, from [pi - 2]);
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next,
- from[pi - 2], next0);
- n_left_from--;
- if ((int) n_left_to_next < 0 && n_left_from > 0)
- vlib_get_next_frame (vm, node, next_index, to_next,
- n_left_to_next);
- }
-
-
- for (; pi < (pi_limit + (NSTAGES-1)); pi++)
- {
- if (((pi - 1) >= 0) && ((pi - 1) < pi_limit))
- stage1 (vm, node, from[pi-1]);
- if (((pi - 2) >= 0) && ((pi - 2) < pi_limit))
- {
- to_next[0] = from[pi - 2];
- to_next++;
- n_left_to_next--;
- next0 = last_stage (vm, node, from [pi - 2]);
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next,
- from[pi - 2], next0);
- n_left_from--;
- if ((int) n_left_to_next < 0 && n_left_from > 0)
- vlib_get_next_frame (vm, node, next_index, to_next,
- n_left_to_next);
- }
- }
-
+
+ for (pi = 0; pi < NSTAGES - 1; pi++)
+ {
+ if (pi == pi_limit)
+ break;
+ stage0 (vm, node, from[pi]);
+ if (pi - 1 >= 0)
+ stage1 (vm, node, from[pi - 1]);
+ }
+
+ for (; pi < pi_limit; pi++)
+ {
+ stage0 (vm, node, from[pi]);
+ stage1 (vm, node, from[pi - 1]);
+ to_next[0] = from[pi - 2];
+ to_next++;
+ n_left_to_next--;
+ next0 = last_stage (vm, node, from[pi - 2]);
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
+ to_next, n_left_to_next,
+ from[pi - 2], next0);
+ n_left_from--;
+ if ((int) n_left_to_next < 0 && n_left_from > 0)
+ vlib_get_next_frame (vm, node, next_index, to_next,
+ n_left_to_next);
+ }
+
+
+ for (; pi < (pi_limit + (NSTAGES - 1)); pi++)
+ {
+ if (((pi - 1) >= 0) && ((pi - 1) < pi_limit))
+ stage1 (vm, node, from[pi - 1]);
+ if (((pi - 2) >= 0) && ((pi - 2) < pi_limit))
+ {
+ to_next[0] = from[pi - 2];
+ to_next++;
+ n_left_to_next--;
+ next0 = last_stage (vm, node, from[pi - 2]);
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
+ to_next, n_left_to_next,
+ from[pi - 2], next0);
+ n_left_from--;
+ if ((int) n_left_to_next < 0 && n_left_from > 0)
+ vlib_get_next_frame (vm, node, next_index, to_next,
+ n_left_to_next);
+ }
+ }
+
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
from += pi_limit;
}
@@ -205,76 +203,75 @@ dispatch_pipeline (vlib_main_t * vm,
#if NSTAGES == 4
static STAGE_INLINE uword
dispatch_pipeline (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+ vlib_node_runtime_t * node, vlib_frame_t * frame)
{
- u32 * from = vlib_frame_vector_args (frame);
- u32 n_left_from, n_left_to_next, * to_next, next_index, next0;
+ u32 *from = vlib_frame_vector_args (frame);
+ u32 n_left_from, n_left_to_next, *to_next, next_index, next0;
int pi, pi_limit;
-
+
n_left_from = frame->n_vectors;
next_index = node->cached_next_index;
-
- while (n_left_from > 0)
+
+ while (n_left_from > 0)
{
vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-
+
pi_limit = clib_min (n_left_from, n_left_to_next);
-
- for (pi = 0; pi < NSTAGES-1; pi++)
- {
- if(pi == pi_limit)
- break;
- stage0 (vm, node, from[pi]);
- if (pi-1 >= 0)
- stage1 (vm, node, from[pi-1]);
- if (pi-2 >= 0)
- stage2 (vm, node, from[pi-2]);
- }
-
- for (; pi < pi_limit; pi++)
- {
- stage0 (vm, node, from[pi]);
- stage1 (vm, node, from[pi-1]);
- stage2 (vm, node, from[pi-2]);
- to_next[0] = from [pi - 3];
- to_next++;
- n_left_to_next--;
- next0 = last_stage (vm, node, from [pi - 3]);
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next,
- from[pi - 3], next0);
- n_left_from--;
- if ((int) n_left_to_next < 0 && n_left_from > 0)
- vlib_get_next_frame (vm, node, next_index, to_next,
- n_left_to_next);
- }
-
-
- for (; pi < (pi_limit + (NSTAGES-1)); pi++)
- {
- if (((pi - 1) >= 0) && ((pi - 1) < pi_limit))
- stage1 (vm, node, from[pi-1]);
- if (((pi - 2) >= 0) && ((pi - 2) < pi_limit))
- stage2 (vm, node, from[pi-2]);
- if (((pi - 3) >= 0) && ((pi - 3) < pi_limit))
- {
- to_next[0] = from[pi - 3];
- to_next++;
- n_left_to_next--;
- next0 = last_stage (vm, node, from [pi - 3]);
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next,
- from[pi - 3], next0);
- n_left_from--;
- if ((int) n_left_to_next < 0 && n_left_from > 0)
- vlib_get_next_frame (vm, node, next_index, to_next,
- n_left_to_next);
- }
- }
-
- vlib_put_next_frame (vm, node, next_index, n_left_to_next);
- from += pi_limit;
+
+ for (pi = 0; pi < NSTAGES - 1; pi++)
+ {
+ if (pi == pi_limit)
+ break;
+ stage0 (vm, node, from[pi]);
+ if (pi - 1 >= 0)
+ stage1 (vm, node, from[pi - 1]);
+ if (pi - 2 >= 0)
+ stage2 (vm, node, from[pi - 2]);
+ }
+
+ for (; pi < pi_limit; pi++)
+ {
+ stage0 (vm, node, from[pi]);
+ stage1 (vm, node, from[pi - 1]);
+ stage2 (vm, node, from[pi - 2]);
+ to_next[0] = from[pi - 3];
+ to_next++;
+ n_left_to_next--;
+ next0 = last_stage (vm, node, from[pi - 3]);
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
+ to_next, n_left_to_next,
+ from[pi - 3], next0);
+ n_left_from--;
+ if ((int) n_left_to_next < 0 && n_left_from > 0)
+ vlib_get_next_frame (vm, node, next_index, to_next,
+ n_left_to_next);
+ }
+
+
+ for (; pi < (pi_limit + (NSTAGES - 1)); pi++)
+ {
+ if (((pi - 1) >= 0) && ((pi - 1) < pi_limit))
+ stage1 (vm, node, from[pi - 1]);
+ if (((pi - 2) >= 0) && ((pi - 2) < pi_limit))
+ stage2 (vm, node, from[pi - 2]);
+ if (((pi - 3) >= 0) && ((pi - 3) < pi_limit))
+ {
+ to_next[0] = from[pi - 3];
+ to_next++;
+ n_left_to_next--;
+ next0 = last_stage (vm, node, from[pi - 3]);
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
+ to_next, n_left_to_next,
+ from[pi - 3], next0);
+ n_left_from--;
+ if ((int) n_left_to_next < 0 && n_left_from > 0)
+ vlib_get_next_frame (vm, node, next_index, to_next,
+ n_left_to_next);
+ }
+ }
+
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ from += pi_limit;
}
return frame->n_vectors;
}
@@ -284,81 +281,80 @@ dispatch_pipeline (vlib_main_t * vm,
#if NSTAGES == 5
static STAGE_INLINE uword
dispatch_pipeline (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+ vlib_node_runtime_t * node, vlib_frame_t * frame)
{
- u32 * from = vlib_frame_vector_args (frame);
- u32 n_left_from, n_left_to_next, * to_next, next_index, next0;
+ u32 *from = vlib_frame_vector_args (frame);
+ u32 n_left_from, n_left_to_next, *to_next, next_index, next0;
int pi, pi_limit;
-
+
n_left_from = frame->n_vectors;
next_index = node->cached_next_index;
-
- while (n_left_from > 0)
+
+ while (n_left_from > 0)
{
vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-
+
pi_limit = clib_min (n_left_from, n_left_to_next);
-
- for (pi = 0; pi < NSTAGES-1; pi++)
- {
- if(pi == pi_limit)
- break;
- stage0 (vm, node, from[pi]);
- if (pi-1 >= 0)
- stage1 (vm, node, from[pi-1]);
- if (pi-2 >= 0)
- stage2 (vm, node, from[pi-2]);
- if (pi-3 >= 0)
- stage3 (vm, node, from[pi-3]);
- }
-
- for (; pi < pi_limit; pi++)
- {
- stage0 (vm, node, from[pi]);
- stage1 (vm, node, from[pi-1]);
- stage2 (vm, node, from[pi-2]);
- stage3 (vm, node, from[pi-3]);
- to_next[0] = from [pi - 4];
- to_next++;
- n_left_to_next--;
- next0 = last_stage (vm, node, from [pi - 4]);
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next,
- from[pi - 4], next0);
- n_left_from--;
- if ((int) n_left_to_next < 0 && n_left_from > 0)
- vlib_get_next_frame (vm, node, next_index, to_next,
- n_left_to_next);
- }
-
-
- for (; pi < (pi_limit + (NSTAGES-1)); pi++)
- {
- if (((pi - 1) >= 0) && ((pi - 1) < pi_limit))
- stage1 (vm, node, from[pi-1]);
- if (((pi - 2) >= 0) && ((pi - 2) < pi_limit))
- stage2 (vm, node, from[pi - 2]);
- if (((pi - 3) >= 0) && ((pi - 3) < pi_limit))
- stage3 (vm, node, from[pi - 3]);
- if (((pi - 4) >= 0) && ((pi - 4) < pi_limit))
- {
- to_next[0] = from[pi - 4];
- to_next++;
- n_left_to_next--;
- next0 = last_stage (vm, node, from [pi - 4]);
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next,
- from[pi - 4], next0);
- n_left_from--;
- if ((int) n_left_to_next < 0 && n_left_from > 0)
- vlib_get_next_frame (vm, node, next_index, to_next,
- n_left_to_next);
- }
- }
-
- vlib_put_next_frame (vm, node, next_index, n_left_to_next);
- from += pi_limit;
+
+ for (pi = 0; pi < NSTAGES - 1; pi++)
+ {
+ if (pi == pi_limit)
+ break;
+ stage0 (vm, node, from[pi]);
+ if (pi - 1 >= 0)
+ stage1 (vm, node, from[pi - 1]);
+ if (pi - 2 >= 0)
+ stage2 (vm, node, from[pi - 2]);
+ if (pi - 3 >= 0)
+ stage3 (vm, node, from[pi - 3]);
+ }
+
+ for (; pi < pi_limit; pi++)
+ {
+ stage0 (vm, node, from[pi]);
+ stage1 (vm, node, from[pi - 1]);
+ stage2 (vm, node, from[pi - 2]);
+ stage3 (vm, node, from[pi - 3]);
+ to_next[0] = from[pi - 4];
+ to_next++;
+ n_left_to_next--;
+ next0 = last_stage (vm, node, from[pi - 4]);
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
+ to_next, n_left_to_next,
+ from[pi - 4], next0);
+ n_left_from--;
+ if ((int) n_left_to_next < 0 && n_left_from > 0)
+ vlib_get_next_frame (vm, node, next_index, to_next,
+ n_left_to_next);
+ }
+
+
+ for (; pi < (pi_limit + (NSTAGES - 1)); pi++)
+ {
+ if (((pi - 1) >= 0) && ((pi - 1) < pi_limit))
+ stage1 (vm, node, from[pi - 1]);
+ if (((pi - 2) >= 0) && ((pi - 2) < pi_limit))
+ stage2 (vm, node, from[pi - 2]);
+ if (((pi - 3) >= 0) && ((pi - 3) < pi_limit))
+ stage3 (vm, node, from[pi - 3]);
+ if (((pi - 4) >= 0) && ((pi - 4) < pi_limit))
+ {
+ to_next[0] = from[pi - 4];
+ to_next++;
+ n_left_to_next--;
+ next0 = last_stage (vm, node, from[pi - 4]);
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
+ to_next, n_left_to_next,
+ from[pi - 4], next0);
+ n_left_from--;
+ if ((int) n_left_to_next < 0 && n_left_from > 0)
+ vlib_get_next_frame (vm, node, next_index, to_next,
+ n_left_to_next);
+ }
+ }
+
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ from += pi_limit;
}
return frame->n_vectors;
}
@@ -367,87 +363,94 @@ dispatch_pipeline (vlib_main_t * vm,
#if NSTAGES == 6
static STAGE_INLINE uword
dispatch_pipeline (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+ vlib_node_runtime_t * node, vlib_frame_t * frame)
{
- u32 * from = vlib_frame_vector_args (frame);
- u32 n_left_from, n_left_to_next, * to_next, next_index, next0;
+ u32 *from = vlib_frame_vector_args (frame);
+ u32 n_left_from, n_left_to_next, *to_next, next_index, next0;
int pi, pi_limit;
-
+
n_left_from = frame->n_vectors;
next_index = node->cached_next_index;
-
- while (n_left_from > 0)
+
+ while (n_left_from > 0)
{
vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-
+
pi_limit = clib_min (n_left_from, n_left_to_next);
-
- for (pi = 0; pi < NSTAGES-1; pi++)
- {
- if(pi == pi_limit)
- break;
- stage0 (vm, node, from[pi]);
- if (pi-1 >= 0)
- stage1 (vm, node, from[pi-1]);
- if (pi-2 >= 0)
- stage2 (vm, node, from[pi-2]);
- if (pi-3 >= 0)
- stage3 (vm, node, from[pi-3]);
- if (pi-4 >= 0)
- stage4 (vm, node, from[pi-4]);
- }
-
- for (; pi < pi_limit; pi++)
- {
- stage0 (vm, node, from[pi]);
- stage1 (vm, node, from[pi-1]);
- stage2 (vm, node, from[pi-2]);
- stage3 (vm, node, from[pi-3]);
- stage4 (vm, node, from[pi-4]);
- to_next[0] = from [pi - 5];
- to_next++;
- n_left_to_next--;
- next0 = last_stage (vm, node, from [pi - 5]);
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next,
- from[pi - 5], next0);
- n_left_from--;
- if ((int) n_left_to_next < 0 && n_left_from > 0)
- vlib_get_next_frame (vm, node, next_index, to_next,
- n_left_to_next);
- }
-
-
- for (; pi < (pi_limit + (NSTAGES-1)); pi++)
- {
- if (((pi - 1) >= 0) && ((pi - 1) < pi_limit))
- stage1 (vm, node, from[pi-1]);
- if (((pi - 2) >= 0) && ((pi - 2) < pi_limit))
- stage2 (vm, node, from[pi - 2]);
- if (((pi - 3) >= 0) && ((pi - 3) < pi_limit))
- stage3 (vm, node, from[pi - 3]);
- if (((pi - 4) >= 0) && ((pi - 4) < pi_limit))
- stage4 (vm, node, from[pi - 4]);
- if (((pi - 5) >= 0) && ((pi - 5) < pi_limit))
- {
- to_next[0] = from[pi - 5];
- to_next++;
- n_left_to_next--;
- next0 = last_stage (vm, node, from [pi - 5]);
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next,
- from[pi - 5], next0);
- n_left_from--;
- if ((int) n_left_to_next < 0 && n_left_from > 0)
- vlib_get_next_frame (vm, node, next_index, to_next,
- n_left_to_next);
- }
- }
-
- vlib_put_next_frame (vm, node, next_index, n_left_to_next);
- from += pi_limit;
+
+ for (pi = 0; pi < NSTAGES - 1; pi++)
+ {
+ if (pi == pi_limit)
+ break;
+ stage0 (vm, node, from[pi]);
+ if (pi - 1 >= 0)
+ stage1 (vm, node, from[pi - 1]);
+ if (pi - 2 >= 0)
+ stage2 (vm, node, from[pi - 2]);
+ if (pi - 3 >= 0)
+ stage3 (vm, node, from[pi - 3]);
+ if (pi - 4 >= 0)
+ stage4 (vm, node, from[pi - 4]);
+ }
+
+ for (; pi < pi_limit; pi++)
+ {
+ stage0 (vm, node, from[pi]);
+ stage1 (vm, node, from[pi - 1]);
+ stage2 (vm, node, from[pi - 2]);
+ stage3 (vm, node, from[pi - 3]);
+ stage4 (vm, node, from[pi - 4]);
+ to_next[0] = from[pi - 5];
+ to_next++;
+ n_left_to_next--;
+ next0 = last_stage (vm, node, from[pi - 5]);
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
+ to_next, n_left_to_next,
+ from[pi - 5], next0);
+ n_left_from--;
+ if ((int) n_left_to_next < 0 && n_left_from > 0)
+ vlib_get_next_frame (vm, node, next_index, to_next,
+ n_left_to_next);
+ }
+
+
+ for (; pi < (pi_limit + (NSTAGES - 1)); pi++)
+ {
+ if (((pi - 1) >= 0) && ((pi - 1) < pi_limit))
+ stage1 (vm, node, from[pi - 1]);
+ if (((pi - 2) >= 0) && ((pi - 2) < pi_limit))
+ stage2 (vm, node, from[pi - 2]);
+ if (((pi - 3) >= 0) && ((pi - 3) < pi_limit))
+ stage3 (vm, node, from[pi - 3]);
+ if (((pi - 4) >= 0) && ((pi - 4) < pi_limit))
+ stage4 (vm, node, from[pi - 4]);
+ if (((pi - 5) >= 0) && ((pi - 5) < pi_limit))
+ {
+ to_next[0] = from[pi - 5];
+ to_next++;
+ n_left_to_next--;
+ next0 = last_stage (vm, node, from[pi - 5]);
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
+ to_next, n_left_to_next,
+ from[pi - 5], next0);
+ n_left_from--;
+ if ((int) n_left_to_next < 0 && n_left_from > 0)
+ vlib_get_next_frame (vm, node, next_index, to_next,
+ n_left_to_next);
+ }
+ }
+
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ from += pi_limit;
}
return frame->n_vectors;
}
#endif
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/replication.c b/vnet/vnet/replication.c
index fc2cbd1d860..571be7d807c 100644
--- a/vnet/vnet/replication.c
+++ b/vnet/vnet/replication.c
@@ -27,57 +27,62 @@ replication_main_t replication_main;
replication_context_t *
replication_prep (vlib_main_t * vm,
- vlib_buffer_t * b0,
- u32 recycle_node_index,
- u32 l2_packet)
+ vlib_buffer_t * b0, u32 recycle_node_index, u32 l2_packet)
{
- replication_main_t * rm = &replication_main;
- replication_context_t * ctx;
+ replication_main_t *rm = &replication_main;
+ replication_context_t *ctx;
uword cpu_number = vm->cpu_index;
- ip4_header_t * ip;
+ ip4_header_t *ip;
u32 ctx_id;
- // Allocate a context, reserve context 0
- if (PREDICT_FALSE(rm->contexts[cpu_number] == 0))
+ /* Allocate a context, reserve context 0 */
+ if (PREDICT_FALSE (rm->contexts[cpu_number] == 0))
pool_get_aligned (rm->contexts[cpu_number], ctx, CLIB_CACHE_LINE_BYTES);
-
+
pool_get_aligned (rm->contexts[cpu_number], ctx, CLIB_CACHE_LINE_BYTES);
ctx_id = ctx - rm->contexts[cpu_number];
- // Save state from vlib buffer
+ /* Save state from vlib buffer */
ctx->saved_free_list_index = b0->free_list_index;
ctx->current_data = b0->current_data;
- // Set up vlib buffer hooks
+ /* Set up vlib buffer hooks */
b0->recycle_count = ctx_id;
b0->free_list_index = rm->recycle_list_index;
b0->flags |= VLIB_BUFFER_RECYCLE;
- // Save feature state
+ /* Save feature state */
ctx->recycle_node_index = recycle_node_index;
- // Save vnet state
- clib_memcpy (ctx->vnet_buffer, vnet_buffer(b0), sizeof(vnet_buffer_opaque_t));
+ /* Save vnet state */
+ clib_memcpy (ctx->vnet_buffer, vnet_buffer (b0),
+ sizeof (vnet_buffer_opaque_t));
- // Save packet contents
+ /* Save packet contents */
ctx->l2_packet = l2_packet;
- ip = (ip4_header_t *)vlib_buffer_get_current (b0);
- if (l2_packet) {
- // Save ethernet header
- ctx->l2_header[0] = ((u64 *)ip)[0];
- ctx->l2_header[1] = ((u64 *)ip)[1];
- ctx->l2_header[2] = ((u64 *)ip)[2];
- // set ip to the true ip header
- ip = (ip4_header_t *)(((u8 *)ip) + vnet_buffer(b0)->l2.l2_len);
- }
-
- // Copy L3 fields.
- // We need to save TOS for ip4 and ip6 packets. Fortunately the TOS field is
- // in the first two bytes of both the ip4 and ip6 headers.
- ctx->ip_tos = *((u16 *)(ip));
-
- // Save the ip4 checksum as well. We just blindly save the corresponding two
- // bytes even for ip6 packets.
+ ip = (ip4_header_t *) vlib_buffer_get_current (b0);
+ if (l2_packet)
+ {
+ /* Save ethernet header */
+ ctx->l2_header[0] = ((u64 *) ip)[0];
+ ctx->l2_header[1] = ((u64 *) ip)[1];
+ ctx->l2_header[2] = ((u64 *) ip)[2];
+ /* set ip to the true ip header */
+ ip = (ip4_header_t *) (((u8 *) ip) + vnet_buffer (b0)->l2.l2_len);
+ }
+
+ /*
+ * Copy L3 fields.
+ * We need to save TOS for ip4 and ip6 packets.
+ * Fortunately the TOS field is
+ * in the first two bytes of both the ip4 and ip6 headers.
+ */
+ ctx->ip_tos = *((u16 *) (ip));
+
+ /*
+ * Save the ip4 checksum as well. We just blindly save the corresponding two
+ * bytes even for ip6 packets.
+ */
ctx->ip4_checksum = ip->checksum;
return ctx;
@@ -85,48 +90,51 @@ replication_prep (vlib_main_t * vm,
replication_context_t *
-replication_recycle (vlib_main_t * vm,
- vlib_buffer_t * b0,
- u32 is_last)
+replication_recycle (vlib_main_t * vm, vlib_buffer_t * b0, u32 is_last)
{
- replication_main_t * rm = &replication_main;
- replication_context_t * ctx;
+ replication_main_t *rm = &replication_main;
+ replication_context_t *ctx;
uword cpu_number = vm->cpu_index;
- ip4_header_t * ip;
+ ip4_header_t *ip;
- // Get access to the replication context
+ /* Get access to the replication context */
ctx = pool_elt_at_index (rm->contexts[cpu_number], b0->recycle_count);
- // Restore vnet buffer state
- clib_memcpy (vnet_buffer(b0), ctx->vnet_buffer, sizeof(vnet_buffer_opaque_t));
+ /* Restore vnet buffer state */
+ clib_memcpy (vnet_buffer (b0), ctx->vnet_buffer,
+ sizeof (vnet_buffer_opaque_t));
- // Restore the packet start (current_data) and length
- vlib_buffer_advance(b0, ctx->current_data - b0->current_data);
+ /* Restore the packet start (current_data) and length */
+ vlib_buffer_advance (b0, ctx->current_data - b0->current_data);
- // Restore packet contents
- ip = (ip4_header_t *)vlib_buffer_get_current (b0);
- if (ctx->l2_packet) {
- // Restore ethernet header
- ((u64 *)ip)[0] = ctx->l2_header[0];
- ((u64 *)ip)[1] = ctx->l2_header[1];
- ((u64 *)ip)[2] = ctx->l2_header[2];
- // set ip to the true ip header
- ip = (ip4_header_t *)(((u8 *)ip) + vnet_buffer(b0)->l2.l2_len);
- }
+ /* Restore packet contents */
+ ip = (ip4_header_t *) vlib_buffer_get_current (b0);
+ if (ctx->l2_packet)
+ {
+ /* Restore ethernet header */
+ ((u64 *) ip)[0] = ctx->l2_header[0];
+ ((u64 *) ip)[1] = ctx->l2_header[1];
+ ((u64 *) ip)[2] = ctx->l2_header[2];
+ /* set ip to the true ip header */
+ ip = (ip4_header_t *) (((u8 *) ip) + vnet_buffer (b0)->l2.l2_len);
+ }
// Restore L3 fields
- *((u16 *)(ip)) = ctx->ip_tos;
+ *((u16 *) (ip)) = ctx->ip_tos;
ip->checksum = ctx->ip4_checksum;
- if (is_last) {
- // This is the last replication in the list.
- // Restore original buffer free functionality.
- b0->free_list_index = ctx->saved_free_list_index;
- b0->flags &= ~VLIB_BUFFER_RECYCLE;
-
- // Free context back to its pool
- pool_put (rm->contexts[cpu_number], ctx);
- }
+ if (is_last)
+ {
+ /*
+ * This is the last replication in the list.
+ * Restore original buffer free functionality.
+ */
+ b0->free_list_index = ctx->saved_free_list_index;
+ b0->flags &= ~VLIB_BUFFER_RECYCLE;
+
+ /* Free context back to its pool */
+ pool_put (rm->contexts[cpu_number], ctx);
+ }
return ctx;
}
@@ -137,133 +145,143 @@ replication_recycle (vlib_main_t * vm,
* fish pkts back from the recycle queue/freelist
* un-flatten the context chains
*/
-static void replication_recycle_callback (vlib_main_t *vm,
- vlib_buffer_free_list_t * fl)
+static void
+replication_recycle_callback (vlib_main_t * vm, vlib_buffer_free_list_t * fl)
{
- vlib_frame_t * f = 0;
+ vlib_frame_t *f = 0;
u32 n_left_from;
u32 n_left_to_next = 0;
u32 n_this_frame = 0;
- u32 * from;
- u32 * to_next = 0;
+ u32 *from;
+ u32 *to_next = 0;
u32 bi0, pi0;
vlib_buffer_t *b0;
int i;
- replication_main_t * rm = &replication_main;
- replication_context_t * ctx;
- u32 feature_node_index = 0;
+ replication_main_t *rm = &replication_main;
+ replication_context_t *ctx;
+ u32 feature_node_index = 0;
uword cpu_number = vm->cpu_index;
- // All buffers in the list are destined to the same recycle node.
- // Pull the recycle node index from the first buffer.
- // Note: this could be sped up if the node index were stuffed into
- // the freelist itself.
- if (vec_len (fl->aligned_buffers) > 0) {
- bi0 = fl->aligned_buffers[0];
- b0 = vlib_get_buffer (vm, bi0);
- ctx = pool_elt_at_index (rm->contexts[cpu_number],
- b0->recycle_count);
- feature_node_index = ctx->recycle_node_index;
- } else if (vec_len (fl->unaligned_buffers) > 0) {
- bi0 = fl->unaligned_buffers[0];
- b0 = vlib_get_buffer (vm, bi0);
- ctx = pool_elt_at_index (rm->contexts[cpu_number], b0->recycle_count);
- feature_node_index = ctx->recycle_node_index;
- }
+ /*
+ * All buffers in the list are destined to the same recycle node.
+ * Pull the recycle node index from the first buffer.
+ * Note: this could be sped up if the node index were stuffed into
+ * the freelist itself.
+ */
+ if (vec_len (fl->aligned_buffers) > 0)
+ {
+ bi0 = fl->aligned_buffers[0];
+ b0 = vlib_get_buffer (vm, bi0);
+ ctx = pool_elt_at_index (rm->contexts[cpu_number], b0->recycle_count);
+ feature_node_index = ctx->recycle_node_index;
+ }
+ else if (vec_len (fl->unaligned_buffers) > 0)
+ {
+ bi0 = fl->unaligned_buffers[0];
+ b0 = vlib_get_buffer (vm, bi0);
+ ctx = pool_elt_at_index (rm->contexts[cpu_number], b0->recycle_count);
+ feature_node_index = ctx->recycle_node_index;
+ }
/* aligned, unaligned buffers */
- for (i = 0; i < 2; i++)
+ for (i = 0; i < 2; i++)
{
if (i == 0)
- {
- from = fl->aligned_buffers;
- n_left_from = vec_len (from);
- }
+ {
+ from = fl->aligned_buffers;
+ n_left_from = vec_len (from);
+ }
else
- {
- from = fl->unaligned_buffers;
- n_left_from = vec_len (from);
- }
-
+ {
+ from = fl->unaligned_buffers;
+ n_left_from = vec_len (from);
+ }
+
while (n_left_from > 0)
- {
- if (PREDICT_FALSE(n_left_to_next == 0))
- {
- if (f)
- {
- f->n_vectors = n_this_frame;
- vlib_put_frame_to_node (vm, feature_node_index, f);
- }
-
- f = vlib_get_frame_to_node (vm, feature_node_index);
- to_next = vlib_frame_vector_args (f);
- n_left_to_next = VLIB_FRAME_SIZE;
- n_this_frame = 0;
- }
-
- bi0 = from[0];
- if (PREDICT_TRUE(n_left_from > 1))
- {
- pi0 = from[1];
- vlib_prefetch_buffer_with_index(vm,pi0,LOAD);
- }
+ {
+ if (PREDICT_FALSE (n_left_to_next == 0))
+ {
+ if (f)
+ {
+ f->n_vectors = n_this_frame;
+ vlib_put_frame_to_node (vm, feature_node_index, f);
+ }
+
+ f = vlib_get_frame_to_node (vm, feature_node_index);
+ to_next = vlib_frame_vector_args (f);
+ n_left_to_next = VLIB_FRAME_SIZE;
+ n_this_frame = 0;
+ }
+
+ bi0 = from[0];
+ if (PREDICT_TRUE (n_left_from > 1))
+ {
+ pi0 = from[1];
+ vlib_prefetch_buffer_with_index (vm, pi0, LOAD);
+ }
b0 = vlib_get_buffer (vm, bi0);
- // Mark that this buffer was just recycled
- b0->flags |= VLIB_BUFFER_IS_RECYCLED;
+ /* Mark that this buffer was just recycled */
+ b0->flags |= VLIB_BUFFER_IS_RECYCLED;
- // If buffer is traced, mark frame as traced
- if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
- f->flags |= VLIB_FRAME_TRACE;
+ /* If buffer is traced, mark frame as traced */
+ if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
+ f->flags |= VLIB_FRAME_TRACE;
- to_next[0] = bi0;
+ to_next[0] = bi0;
- from++;
- to_next++;
- n_this_frame++;
- n_left_to_next--;
- n_left_from--;
- }
+ from++;
+ to_next++;
+ n_this_frame++;
+ n_left_to_next--;
+ n_left_from--;
+ }
}
-
+
vec_reset_length (fl->aligned_buffers);
vec_reset_length (fl->unaligned_buffers);
if (f)
{
- ASSERT(n_this_frame);
+ ASSERT (n_this_frame);
f->n_vectors = n_this_frame;
vlib_put_frame_to_node (vm, feature_node_index, f);
}
}
-
-
-clib_error_t *replication_init (vlib_main_t *vm)
+clib_error_t *
+replication_init (vlib_main_t * vm)
{
- replication_main_t * rm = &replication_main;
- vlib_buffer_main_t * bm = vm->buffer_main;
- vlib_buffer_free_list_t * fl;
- __attribute__((unused)) replication_context_t * ctx;
- vlib_thread_main_t * tm = vlib_get_thread_main();
-
+ replication_main_t *rm = &replication_main;
+ vlib_buffer_main_t *bm = vm->buffer_main;
+ vlib_buffer_free_list_t *fl;
+ __attribute__ ((unused)) replication_context_t *ctx;
+ vlib_thread_main_t *tm = vlib_get_thread_main ();
+
rm->vlib_main = vm;
- rm->vnet_main = vnet_get_main();
- rm->recycle_list_index =
- vlib_buffer_create_free_list (vm, 1024 /* fictional */,
- "replication-recycle");
+ rm->vnet_main = vnet_get_main ();
+ rm->recycle_list_index =
+ vlib_buffer_create_free_list (vm, 1024 /* fictional */ ,
+ "replication-recycle");
- fl = pool_elt_at_index (bm->buffer_free_list_pool,
- rm->recycle_list_index);
+ fl = pool_elt_at_index (bm->buffer_free_list_pool, rm->recycle_list_index);
fl->buffers_added_to_freelist_function = replication_recycle_callback;
- // Verify the replication context is the expected size
- ASSERT(sizeof(replication_context_t) == 128); // 2 cache lines
+ /* Verify the replication context is the expected size */
+ ASSERT (sizeof (replication_context_t) == 128); /* 2 cache lines */
vec_validate (rm->contexts, tm->n_vlib_mains - 1);
return 0;
}
VLIB_INIT_FUNCTION (replication_init);
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/replication.h b/vnet/vnet/replication.h
index b16d5dc430d..5dc554c97b3 100644
--- a/vnet/vnet/replication.h
+++ b/vnet/vnet/replication.h
@@ -24,42 +24,46 @@
#include <vnet/replication.h>
-typedef struct {
-
- // The entire vnet buffer header restored for each replica
- u8 vnet_buffer[32]; // 16B aligned to allow vector unit copy
- u8 reserved[32]; // space for future expansion of vnet buffer header
+typedef struct
+{
+ /* The entire vnet buffer header restored for each replica */
+ u8 vnet_buffer[32]; /* 16B aligned to allow vector unit copy */
+ u8 reserved[32]; /* space for future expansion of vnet buffer header */
- // feature state used during this replication
- u64 feature_replicas; // feature's id for its set of replicas
- u32 feature_counter; // feature's current index into set of replicas
- u32 recycle_node_index; // feature's recycle node index
+ /* feature state used during this replication */
+ u64 feature_replicas; /* feature's id for its set of replicas */
+ u32 feature_counter; /* feature's current index into set of replicas */
+ u32 recycle_node_index; /* feature's recycle node index */
- // data saved from the start of replication and restored at the end of replication
- u32 saved_free_list_index; // from vlib buffer
+ /*
+ * data saved from the start of replication and restored
+ * at the end of replication
+ */
+ u32 saved_free_list_index; /* from vlib buffer */
- // data saved from the original packet and restored for each replica
- u64 l2_header[3]; // 24B (must be at least 22B for l2 packets)
- u16 ip_tos; // v4 and v6
- u16 ip4_checksum; // needed for v4 only
+ /* data saved from the original packet and restored for each replica */
+ u64 l2_header[3]; /* 24B (must be at least 22B for l2 packets) */
+ u16 ip_tos; /* v4 and v6 */
+ u16 ip4_checksum; /* needed for v4 only */
- // data saved from the vlib buffer header and restored for each replica
- i16 current_data; // offset of first byte of packet in packet data
- u8 pad[6]; // to 64B
- u8 l2_packet; // flag for l2 vs l3 packet data
+ /* data saved from the vlib buffer header and restored for each replica */
+ i16 current_data; /* offset of first byte of packet in packet data */
+ u8 pad[6]; /* to 64B */
+ u8 l2_packet; /* flag for l2 vs l3 packet data */
-} replication_context_t; // 128B
+} replication_context_t; /* 128B */
-typedef struct {
+typedef struct
+{
u32 recycle_list_index;
- // per-thread pools of replication contexts
- replication_context_t ** contexts;
+ /* per-thread pools of replication contexts */
+ replication_context_t **contexts;
- vlib_main_t * vlib_main;
- vnet_main_t * vnet_main;
+ vlib_main_t *vlib_main;
+ vnet_main_t *vnet_main;
} replication_main_t;
@@ -67,56 +71,66 @@ typedef struct {
extern replication_main_t replication_main;
-// Return 1 if this buffer just came from the replication recycle handler.
+/* Return 1 if this buffer just came from the replication recycle handler. */
always_inline u32
replication_is_recycled (vlib_buffer_t * b0)
{
return b0->flags & VLIB_BUFFER_IS_RECYCLED;
}
-// Clear the recycle flag. If buffer came from the replication recycle
-// handler, this flag must be cleared before the packet is transmitted again.
+/*
+ * Clear the recycle flag. If buffer came from the replication recycle
+ * handler, this flag must be cleared before the packet is transmitted again.
+ */
always_inline void
replication_clear_recycled (vlib_buffer_t * b0)
{
b0->flags &= ~VLIB_BUFFER_IS_RECYCLED;
}
-// Return the active replication context if this buffer has
-// been recycled, otherwise return 0. (Note that this essentially
-// restricts access to the replication context to the replication
-// feature's prep and recycle nodes.)
+/*
+ * Return the active replication context if this buffer has
+ * been recycled, otherwise return 0. (Note that this essentially
+ * restricts access to the replication context to the replication
+ * feature's prep and recycle nodes.)
+ */
always_inline replication_context_t *
replication_get_ctx (vlib_buffer_t * b0)
{
- replication_main_t * rm = &replication_main;
+ replication_main_t *rm = &replication_main;
- return replication_is_recycled (b0) ?
- pool_elt_at_index (rm->contexts[os_get_cpu_number()], b0->recycle_count) :
- 0;
+ return replication_is_recycled (b0) ?
+ pool_elt_at_index (rm->contexts[os_get_cpu_number ()],
+ b0->recycle_count) : 0;
}
-// Prefetch the replication context for this buffer, if it exists
+/* Prefetch the replication context for this buffer, if it exists */
always_inline void
replication_prefetch_ctx (vlib_buffer_t * b0)
{
replication_context_t *ctx = replication_get_ctx (b0);
- if (ctx) {
- CLIB_PREFETCH (ctx, (2*CLIB_CACHE_LINE_BYTES), STORE);
- }
+ if (ctx)
+ {
+ CLIB_PREFETCH (ctx, (2 * CLIB_CACHE_LINE_BYTES), STORE);
+ }
}
-replication_context_t *
-replication_prep (vlib_main_t * vm,
- vlib_buffer_t * b0,
- u32 recycle_node_index,
- u32 l2_packet);
+replication_context_t *replication_prep (vlib_main_t * vm,
+ vlib_buffer_t * b0,
+ u32 recycle_node_index,
+ u32 l2_packet);
-replication_context_t *
-replication_recycle (vlib_main_t * vm,
- vlib_buffer_t * b0,
- u32 is_last);
+replication_context_t *replication_recycle (vlib_main_t * vm,
+ vlib_buffer_t * b0, u32 is_last);
#endif
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/rewrite.c b/vnet/vnet/rewrite.c
index 3435b0f2d18..0dcec408424 100644
--- a/vnet/vnet/rewrite.c
+++ b/vnet/vnet/rewrite.c
@@ -40,18 +40,19 @@
#include <vnet/vnet.h>
#include <vnet/ip/lookup.h>
-void vnet_rewrite_copy_slow_path (vnet_rewrite_data_t * p0,
- vnet_rewrite_data_t * rw0,
- word n_left,
- uword most_likely_size)
+void
+vnet_rewrite_copy_slow_path (vnet_rewrite_data_t * p0,
+ vnet_rewrite_data_t * rw0,
+ word n_left, uword most_likely_size)
{
- uword n_done = round_pow2 (most_likely_size, sizeof (rw0[0])) / sizeof (rw0[0]);
+ uword n_done =
+ round_pow2 (most_likely_size, sizeof (rw0[0])) / sizeof (rw0[0]);
p0 -= n_done;
rw0 -= n_done;
/* As we enter the cleanup loop, p0 and rw0 point to the last chunk written
- by the fast path. Hence, the constant 1, which the
+ by the fast path. Hence, the constant 1, which the
vnet_rewrite_copy_one macro renders as p0[-1] = rw0[-1]. */
while (n_left > 0)
@@ -63,13 +64,14 @@ void vnet_rewrite_copy_slow_path (vnet_rewrite_data_t * p0,
}
}
-u8 * format_vnet_rewrite (u8 * s, va_list * args)
+u8 *
+format_vnet_rewrite (u8 * s, va_list * args)
{
- vlib_main_t * vm = va_arg (*args, vlib_main_t *);
- vnet_rewrite_header_t * rw = va_arg (*args, vnet_rewrite_header_t *);
+ vlib_main_t *vm = va_arg (*args, vlib_main_t *);
+ vnet_rewrite_header_t *rw = va_arg (*args, vnet_rewrite_header_t *);
u32 max_data_bytes = va_arg (*args, u32);
- vnet_main_t * vnm = vnet_get_main();
- vlib_node_t * next;
+ vnet_main_t *vnm = vnet_get_main ();
+ vlib_node_t *next;
uword indent;
next = vlib_get_next_node (vm, rw->node_index, rw->next_index);
@@ -78,7 +80,7 @@ u8 * format_vnet_rewrite (u8 * s, va_list * args)
if (rw->sw_if_index != ~0)
{
- vnet_sw_interface_t * si;
+ vnet_sw_interface_t *si;
si = vnet_get_sw_interface (vnm, rw->sw_if_index);
s = format (s, "%U", format_vnet_sw_interface_name, vnm, si);
}
@@ -90,19 +92,19 @@ u8 * format_vnet_rewrite (u8 * s, va_list * args)
s = format (s, "\n%U%U",
format_white_space, indent,
next->format_buffer ? next->format_buffer : format_hex_bytes,
- rw->data + max_data_bytes - rw->data_bytes,
- rw->data_bytes);
+ rw->data + max_data_bytes - rw->data_bytes, rw->data_bytes);
return s;
}
-u8 * format_vnet_rewrite_header (u8 * s, va_list * args)
+u8 *
+format_vnet_rewrite_header (u8 * s, va_list * args)
{
- vlib_main_t * vm = va_arg (*args, vlib_main_t *);
- vnet_rewrite_header_t * rw = va_arg (*args, vnet_rewrite_header_t *);
- u8 * packet_data = va_arg (*args, u8 *);
+ vlib_main_t *vm = va_arg (*args, vlib_main_t *);
+ vnet_rewrite_header_t *rw = va_arg (*args, vnet_rewrite_header_t *);
+ u8 *packet_data = va_arg (*args, u8 *);
u32 packet_data_bytes = va_arg (*args, u32);
- vlib_node_t * next;
+ vlib_node_t *next;
next = vlib_get_next_node (vm, rw->node_index, rw->next_index);
@@ -114,15 +116,16 @@ u8 * format_vnet_rewrite_header (u8 * s, va_list * args)
return s;
}
-uword unformat_vnet_rewrite (unformat_input_t * input, va_list * args)
+uword
+unformat_vnet_rewrite (unformat_input_t * input, va_list * args)
{
- vlib_main_t * vm = va_arg (*args, vlib_main_t *);
- vnet_rewrite_header_t * rw = va_arg (*args, vnet_rewrite_header_t *);
+ vlib_main_t *vm = va_arg (*args, vlib_main_t *);
+ vnet_rewrite_header_t *rw = va_arg (*args, vnet_rewrite_header_t *);
u32 max_data_bytes = va_arg (*args, u32);
- vnet_main_t * vnm = vnet_get_main();
- vlib_node_t * next;
+ vnet_main_t *vnm = vnet_get_main ();
+ vlib_node_t *next;
u32 next_index, sw_if_index, max_packet_bytes, error;
- u8 * rw_data;
+ u8 *rw_data;
rw_data = 0;
sw_if_index = ~0;
@@ -130,10 +133,9 @@ uword unformat_vnet_rewrite (unformat_input_t * input, va_list * args)
error = 1;
/* Parse sw interface. */
- if (unformat (input, "%U",
- unformat_vnet_sw_interface, vnm, &sw_if_index))
+ if (unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
{
- vnet_hw_interface_t * hi;
+ vnet_hw_interface_t *hi;
hi = vnet_get_sup_hw_interface (vnm, sw_if_index);
@@ -141,8 +143,7 @@ uword unformat_vnet_rewrite (unformat_input_t * input, va_list * args)
max_packet_bytes = hi->max_l3_packet_bytes[VLIB_RX];
}
- else if (unformat (input, "%U",
- unformat_vlib_node, vm, &next_index))
+ else if (unformat (input, "%U", unformat_vlib_node, vm, &next_index))
;
else
@@ -157,7 +158,7 @@ uword unformat_vnet_rewrite (unformat_input_t * input, va_list * args)
else if (unformat_user (input, unformat_hex_string, &rw_data)
|| unformat (input, "0x%U", unformat_hex_string, &rw_data))
;
-
+
else
goto done;
@@ -177,29 +178,33 @@ uword unformat_vnet_rewrite (unformat_input_t * input, va_list * args)
rw->sw_if_index = sw_if_index;
rw->max_l3_packet_bytes = max_packet_bytes;
rw->next_index = vlib_node_add_next (vm, rw->node_index, next_index);
- vnet_rewrite_set_data_internal (rw, max_data_bytes, rw_data, vec_len (rw_data));
+ vnet_rewrite_set_data_internal (rw, max_data_bytes, rw_data,
+ vec_len (rw_data));
- done:
+done:
vec_free (rw_data);
return error == 0;
}
-void vnet_rewrite_for_sw_interface (vnet_main_t * vnm,
- vnet_l3_packet_type_t packet_type,
- u32 sw_if_index,
- u32 node_index,
- void * dst_address,
- vnet_rewrite_header_t * rw,
- u32 max_rewrite_bytes)
+void
+vnet_rewrite_for_sw_interface (vnet_main_t * vnm,
+ vnet_l3_packet_type_t packet_type,
+ u32 sw_if_index,
+ u32 node_index,
+ void *dst_address,
+ vnet_rewrite_header_t * rw,
+ u32 max_rewrite_bytes)
{
- vnet_hw_interface_t * hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
- vnet_hw_interface_class_t * hc = vnet_get_hw_interface_class (vnm, hw->hw_class_index);
- static u8 * rw_tmp = 0;
+ vnet_hw_interface_t *hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
+ vnet_hw_interface_class_t *hc =
+ vnet_get_hw_interface_class (vnm, hw->hw_class_index);
+ static u8 *rw_tmp = 0;
uword n_rw_tmp;
rw->sw_if_index = sw_if_index;
rw->node_index = node_index;
- rw->next_index = vlib_node_add_next (vnm->vlib_main, node_index, hw->output_node_index);
+ rw->next_index =
+ vlib_node_add_next (vnm->vlib_main, node_index, hw->output_node_index);
rw->max_l3_packet_bytes = hw->max_l3_packet_bytes[VLIB_TX];
ASSERT (max_rewrite_bytes > 0);
@@ -207,56 +212,62 @@ void vnet_rewrite_for_sw_interface (vnet_main_t * vnm,
vec_validate (rw_tmp, max_rewrite_bytes - 1);
ASSERT (hc->set_rewrite);
- n_rw_tmp = hc->set_rewrite (vnm, sw_if_index, packet_type, dst_address, rw_tmp, max_rewrite_bytes);
+ n_rw_tmp =
+ hc->set_rewrite (vnm, sw_if_index, packet_type, dst_address, rw_tmp,
+ max_rewrite_bytes);
ASSERT (n_rw_tmp < max_rewrite_bytes);
vnet_rewrite_set_data_internal (rw, max_rewrite_bytes, rw_tmp, n_rw_tmp);
}
-void vnet_rewrite_for_tunnel (vnet_main_t * vnm,
- u32 tx_sw_if_index,
- u32 rewrite_node_index,
- u32 post_rewrite_node_index,
- vnet_rewrite_header_t * rw,
- u8 *rewrite_data,
- u32 rewrite_length)
+void
+vnet_rewrite_for_tunnel (vnet_main_t * vnm,
+ u32 tx_sw_if_index,
+ u32 rewrite_node_index,
+ u32 post_rewrite_node_index,
+ vnet_rewrite_header_t * rw,
+ u8 * rewrite_data, u32 rewrite_length)
{
- ip_adjacency_t * adj = 0;
- /*
+ ip_adjacency_t *adj = 0;
+ /*
* Installed into vnet_buffer(b)->sw_if_index[VLIB_TX] e.g.
- * by ip4_rewrite_inline. If the post-rewrite node injects into
- * ipX-forward, this will be interpreted as a FIB number.
+ * by ip4_rewrite_inline. If the post-rewrite node injects into
+ * ipX-forward, this will be interpreted as a FIB number.
*/
- rw->sw_if_index = tx_sw_if_index;
+ rw->sw_if_index = tx_sw_if_index;
rw->node_index = rewrite_node_index;
- rw->next_index = vlib_node_add_next (vnm->vlib_main, rewrite_node_index,
- post_rewrite_node_index);
- rw->max_l3_packet_bytes = (u16) ~0; /* we can't know at this point */
+ rw->next_index = vlib_node_add_next (vnm->vlib_main, rewrite_node_index,
+ post_rewrite_node_index);
+ rw->max_l3_packet_bytes = (u16) ~ 0; /* we can't know at this point */
ASSERT (rewrite_length < sizeof (adj->rewrite_data));
/* Leave room for ethernet + VLAN tag */
- vnet_rewrite_set_data_internal (rw, sizeof(adj->rewrite_data),
- rewrite_data, rewrite_length);
+ vnet_rewrite_set_data_internal (rw, sizeof (adj->rewrite_data),
+ rewrite_data, rewrite_length);
}
-void serialize_vnet_rewrite (serialize_main_t * m, va_list * va)
+void
+serialize_vnet_rewrite (serialize_main_t * m, va_list * va)
{
- vnet_rewrite_header_t * rw = va_arg (*va, vnet_rewrite_header_t *);
+ vnet_rewrite_header_t *rw = va_arg (*va, vnet_rewrite_header_t *);
u32 max_data_bytes = va_arg (*va, u32);
- u8 * p;
+ u8 *p;
serialize_integer (m, rw->sw_if_index, sizeof (rw->sw_if_index));
serialize_integer (m, rw->data_bytes, sizeof (rw->data_bytes));
- serialize_integer (m, rw->max_l3_packet_bytes, sizeof (rw->max_l3_packet_bytes));
+ serialize_integer (m, rw->max_l3_packet_bytes,
+ sizeof (rw->max_l3_packet_bytes));
p = serialize_get (m, rw->data_bytes);
- clib_memcpy (p, vnet_rewrite_get_data_internal (rw, max_data_bytes), rw->data_bytes);
+ clib_memcpy (p, vnet_rewrite_get_data_internal (rw, max_data_bytes),
+ rw->data_bytes);
}
-void unserialize_vnet_rewrite (serialize_main_t * m, va_list * va)
+void
+unserialize_vnet_rewrite (serialize_main_t * m, va_list * va)
{
- vnet_rewrite_header_t * rw = va_arg (*va, vnet_rewrite_header_t *);
+ vnet_rewrite_header_t *rw = va_arg (*va, vnet_rewrite_header_t *);
u32 max_data_bytes = va_arg (*va, u32);
- u8 * p;
+ u8 *p;
/* It is up to user to fill these in. */
rw->node_index = ~0;
@@ -264,7 +275,17 @@ void unserialize_vnet_rewrite (serialize_main_t * m, va_list * va)
unserialize_integer (m, &rw->sw_if_index, sizeof (rw->sw_if_index));
unserialize_integer (m, &rw->data_bytes, sizeof (rw->data_bytes));
- unserialize_integer (m, &rw->max_l3_packet_bytes, sizeof (rw->max_l3_packet_bytes));
+ unserialize_integer (m, &rw->max_l3_packet_bytes,
+ sizeof (rw->max_l3_packet_bytes));
p = unserialize_get (m, rw->data_bytes);
- clib_memcpy (vnet_rewrite_get_data_internal (rw, max_data_bytes), p, rw->data_bytes);
+ clib_memcpy (vnet_rewrite_get_data_internal (rw, max_data_bytes), p,
+ rw->data_bytes);
}
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/rewrite.h b/vnet/vnet/rewrite.h
index 7ae33ba6f67..fb800da7b37 100644
--- a/vnet/vnet/rewrite.h
+++ b/vnet/vnet/rewrite.h
@@ -46,6 +46,7 @@
/* Consider using vector types for speed? */
typedef uword vnet_rewrite_data_t;
+/* *INDENT-OFF* */
typedef CLIB_PACKED (struct {
/* Interface to mark re-written packets with. */
u32 sw_if_index;
@@ -66,13 +67,14 @@ typedef CLIB_PACKED (struct {
/* Rewrite string starting at end and going backwards. */
u8 data[0];
}) vnet_rewrite_header_t;
+/* *INDENT-ON* */
/*
Helper macro for declaring rewrite string w/ given max-size.
Typical usage:
typedef struct {
- // User data.
+ //
int a, b;
// Total adjacency is 64 bytes.
@@ -88,11 +90,9 @@ struct { \
always_inline void
vnet_rewrite_set_data_internal (vnet_rewrite_header_t * rw,
- int max_size,
- void * data,
- int data_bytes)
+ int max_size, void *data, int data_bytes)
{
- /* Sanity check values carefully for this memset operation*/
+ /* Sanity check values carefully for this memset operation */
ASSERT ((max_size > 0) && (max_size < VLIB_BUFFER_PRE_DATA_SIZE));
ASSERT ((data_bytes >= 0) && (data_bytes < max_size));
@@ -118,30 +118,30 @@ vnet_rewrite_get_data_internal (vnet_rewrite_header_t * rw, int max_size)
vnet_rewrite_get_data_internal (&((rw).rewrite_header), sizeof ((rw).rewrite_data))
always_inline void
-vnet_rewrite_copy_one (vnet_rewrite_data_t * p0, vnet_rewrite_data_t * rw0, int i)
+vnet_rewrite_copy_one (vnet_rewrite_data_t * p0, vnet_rewrite_data_t * rw0,
+ int i)
{
p0[-i] = rw0[-i];
}
void vnet_rewrite_copy_slow_path (vnet_rewrite_data_t * p0,
vnet_rewrite_data_t * rw0,
- word n_left,
- uword most_likely_size);
+ word n_left, uword most_likely_size);
+/* *INDENT-OFF* */
typedef CLIB_PACKED (struct {
u64 a;
u32 b;
u16 c;
}) eh_copy_t;
+/* *INDENT-ON* */
always_inline void
_vnet_rewrite_one_header (vnet_rewrite_header_t * h0,
- void * packet0,
- int max_size,
- int most_likely_size)
+ void *packet0, int max_size, int most_likely_size)
{
- vnet_rewrite_data_t * p0 = packet0;
- vnet_rewrite_data_t * rw0 = (vnet_rewrite_data_t *) (h0->data + max_size);
+ vnet_rewrite_data_t *p0 = packet0;
+ vnet_rewrite_data_t *rw0 = (vnet_rewrite_data_t *) (h0->data + max_size);
word n_left0;
/* 0xfefe => poisoned adjacency => crash */
@@ -149,13 +149,13 @@ _vnet_rewrite_one_header (vnet_rewrite_header_t * h0,
if (PREDICT_TRUE (h0->data_bytes == sizeof (eh_copy_t)))
{
- eh_copy_t * s, * d;
- s = (eh_copy_t *)(h0->data + max_size - sizeof (eh_copy_t));
- d = (eh_copy_t *)(((u8 *)packet0) - sizeof (eh_copy_t));
+ eh_copy_t *s, *d;
+ s = (eh_copy_t *) (h0->data + max_size - sizeof (eh_copy_t));
+ d = (eh_copy_t *) (((u8 *) packet0) - sizeof (eh_copy_t));
clib_memcpy (d, s, sizeof (eh_copy_t));
return;
}
-
+
#define _(i) \
do { \
@@ -163,16 +163,16 @@ _vnet_rewrite_one_header (vnet_rewrite_header_t * h0,
vnet_rewrite_copy_one (p0, rw0, (i)); \
} while (0)
- _ (4);
- _ (3);
- _ (2);
- _ (1);
+ _(4);
+ _(3);
+ _(2);
+ _(1);
#undef _
-
+
n_left0 = (int)
- (((int) h0->data_bytes - most_likely_size) + (sizeof(rw0[0])-1))
- / (int) sizeof (rw0[0]);
+ (((int) h0->data_bytes - most_likely_size) + (sizeof (rw0[0]) - 1))
+ / (int) sizeof (rw0[0]);
if (PREDICT_FALSE (n_left0 > 0))
vnet_rewrite_copy_slow_path (p0, rw0, n_left0, most_likely_size);
}
@@ -180,15 +180,13 @@ _vnet_rewrite_one_header (vnet_rewrite_header_t * h0,
always_inline void
_vnet_rewrite_two_headers (vnet_rewrite_header_t * h0,
vnet_rewrite_header_t * h1,
- void * packet0,
- void * packet1,
- int max_size,
- int most_likely_size)
+ void *packet0,
+ void *packet1, int max_size, int most_likely_size)
{
- vnet_rewrite_data_t * p0 = packet0;
- vnet_rewrite_data_t * p1 = packet1;
- vnet_rewrite_data_t * rw0 = (vnet_rewrite_data_t *) (h0->data + max_size);
- vnet_rewrite_data_t * rw1 = (vnet_rewrite_data_t *) (h1->data + max_size);
+ vnet_rewrite_data_t *p0 = packet0;
+ vnet_rewrite_data_t *p1 = packet1;
+ vnet_rewrite_data_t *rw0 = (vnet_rewrite_data_t *) (h0->data + max_size);
+ vnet_rewrite_data_t *rw1 = (vnet_rewrite_data_t *) (h1->data + max_size);
word n_left0, n_left1;
int slow_path;
@@ -202,12 +200,12 @@ _vnet_rewrite_two_headers (vnet_rewrite_header_t * h0,
if (PREDICT_TRUE (slow_path == 0))
{
- eh_copy_t * s0, * d0, * s1, * d1;
- s0 = (eh_copy_t *)(h0->data + max_size - sizeof (eh_copy_t));
- d0 = (eh_copy_t *)(((u8 *)packet0) - sizeof (eh_copy_t));
+ eh_copy_t *s0, *d0, *s1, *d1;
+ s0 = (eh_copy_t *) (h0->data + max_size - sizeof (eh_copy_t));
+ d0 = (eh_copy_t *) (((u8 *) packet0) - sizeof (eh_copy_t));
clib_memcpy (d0, s0, sizeof (eh_copy_t));
- s1 = (eh_copy_t *)(h1->data + max_size - sizeof (eh_copy_t));
- d1 = (eh_copy_t *)(((u8 *)packet1) - sizeof (eh_copy_t));
+ s1 = (eh_copy_t *) (h1->data + max_size - sizeof (eh_copy_t));
+ d1 = (eh_copy_t *) (((u8 *) packet1) - sizeof (eh_copy_t));
clib_memcpy (d1, s1, sizeof (eh_copy_t));
return;
}
@@ -221,19 +219,19 @@ _vnet_rewrite_two_headers (vnet_rewrite_header_t * h0,
} \
} while (0)
- _ (4);
- _ (3);
- _ (2);
- _ (1);
+ _(4);
+ _(3);
+ _(2);
+ _(1);
#undef _
-
+
n_left0 = (int)
- (((int) h0->data_bytes - most_likely_size) + (sizeof(rw0[0])-1))
- / (int) sizeof (rw0[0]);
+ (((int) h0->data_bytes - most_likely_size) + (sizeof (rw0[0]) - 1))
+ / (int) sizeof (rw0[0]);
n_left1 = (int)
- (((int) h1->data_bytes - most_likely_size) + (sizeof(rw1[0])-1))
- / (int) sizeof (rw1[0]);
+ (((int) h1->data_bytes - most_likely_size) + (sizeof (rw1[0]) - 1))
+ / (int) sizeof (rw1[0]);
if (PREDICT_FALSE (n_left0 > 0 || n_left1 > 0))
{
@@ -254,21 +252,20 @@ _vnet_rewrite_two_headers (vnet_rewrite_header_t * h0,
(most_likely_size))
#define VNET_REWRITE_FOR_SW_INTERFACE_ADDRESS_BROADCAST ((void *) 0)
-void vnet_rewrite_for_sw_interface (struct vnet_main_t * vnm,
+void vnet_rewrite_for_sw_interface (struct vnet_main_t *vnm,
vnet_l3_packet_type_t packet_type,
u32 sw_if_index,
u32 node_index,
- void * dst_address,
+ void *dst_address,
vnet_rewrite_header_t * rw,
u32 max_rewrite_bytes);
-void vnet_rewrite_for_tunnel (struct vnet_main_t * vnm,
- u32 tx_sw_if_index,
- u32 rewrite_node_index,
- u32 post_rewrite_node_index,
- vnet_rewrite_header_t * rw,
- u8 *rewrite_data,
- u32 rewrite_length);
+void vnet_rewrite_for_tunnel (struct vnet_main_t *vnm,
+ u32 tx_sw_if_index,
+ u32 rewrite_node_index,
+ u32 post_rewrite_node_index,
+ vnet_rewrite_header_t * rw,
+ u8 * rewrite_data, u32 rewrite_length);
/* Parser for unformat header & rewrite string. */
unformat_function_t unformat_vnet_rewrite;
@@ -279,3 +276,11 @@ format_function_t format_vnet_rewrite_header;
serialize_function_t serialize_vnet_rewrite, unserialize_vnet_rewrite;
#endif /* included_vnet_rewrite_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/vnet.h b/vnet/vnet/vnet.h
index 9254da62372..3bca6bf4f3d 100644
--- a/vnet/vnet/vnet.h
+++ b/vnet/vnet/vnet.h
@@ -42,7 +42,8 @@
#include <vppinfra/types.h>
-typedef enum {
+typedef enum
+{
VNET_UNICAST,
VNET_MULTICAST,
VNET_N_CAST,
@@ -55,27 +56,28 @@ typedef enum {
#include <vnet/rewrite.h>
#include <vnet/api_errno.h>
-typedef struct vnet_main_t {
+typedef struct vnet_main_t
+{
u32 local_interface_hw_if_index;
u32 local_interface_sw_if_index;
vnet_interface_main_t interface_main;
/* set up by constructors */
- vnet_device_class_t * device_class_registrations;
- vnet_hw_interface_class_t * hw_interface_class_registrations;
- _vnet_interface_function_list_elt_t * hw_interface_add_del_functions;
- _vnet_interface_function_list_elt_t * hw_interface_link_up_down_functions;
- _vnet_interface_function_list_elt_t * sw_interface_add_del_functions;
- _vnet_interface_function_list_elt_t * sw_interface_admin_up_down_functions;
+ vnet_device_class_t *device_class_registrations;
+ vnet_hw_interface_class_t *hw_interface_class_registrations;
+ _vnet_interface_function_list_elt_t *hw_interface_add_del_functions;
+ _vnet_interface_function_list_elt_t *hw_interface_link_up_down_functions;
+ _vnet_interface_function_list_elt_t *sw_interface_add_del_functions;
+ _vnet_interface_function_list_elt_t *sw_interface_admin_up_down_functions;
- /*
+ /*
* Last "api" error, preserved so we can issue reasonable diagnostics
* at or near the top of the food chain
*/
vnet_api_error_t api_errno;
- vlib_main_t * vlib_main;
+ vlib_main_t *vlib_main;
} vnet_main_t;
vnet_main_t vnet_main;
@@ -85,3 +87,11 @@ vnet_main_t **vnet_mains;
#include <vnet/global_funcs.h>
#endif /* included_vnet_vnet_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */