FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
nat44_ei_hairpinning.h
Go to the documentation of this file.
1 #ifndef __included_nat44_ei_hairpinning_h__
2 #define __included_nat44_ei_hairpinning_h__
3 
5 
6 #define foreach_nat44_ei_hairpinning_handoff_error \
7  _ (CONGESTION_DROP, "congestion drop")
8 
9 typedef enum
10 {
11 #define _(sym, str) NAT44_EI_HAIRPINNING_HANDOFF_ERROR_##sym,
13 #undef _
16 
18 #define _(sym, string) string,
20 #undef _
21 };
22 
23 typedef struct
24 {
27 
28 static u8 *
30 {
31  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
32  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
34  va_arg (*args, nat44_ei_hairpinning_handoff_trace_t *);
35 
36  s = format (s, "nat44-ei-hairpinning-handoff: next-worker %d",
38 
39  return s;
40 }
41 
45  vlib_frame_t *frame, u32 fq_index)
46 {
48  u32 n_enq, n_left_from, *from;
49  u16 thread_indices[VLIB_FRAME_SIZE], *ti;
50 
52  n_left_from = frame->n_vectors;
54 
55  b = bufs;
56  ti = thread_indices;
57 
58  while (n_left_from > 0)
59  {
60  ti[0] = vnet_buffer (b[0])->snat.required_thread_index;
61 
62  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
63  (b[0]->flags & VLIB_BUFFER_IS_TRACED)))
64  {
66  vlib_add_trace (vm, node, b[0], sizeof (*t));
67  t->next_worker_index = ti[0];
68  }
69 
70  n_left_from -= 1;
71  ti += 1;
72  b += 1;
73  }
74  n_enq = vlib_buffer_enqueue_to_thread (vm, node, fq_index, from,
75  thread_indices, frame->n_vectors, 1);
76 
77  if (n_enq < frame->n_vectors)
79  vm, node->node_index, NAT44_EI_HAIRPINNING_HANDOFF_ERROR_CONGESTION_DROP,
80  frame->n_vectors - n_enq);
81  return frame->n_vectors;
82 }
83 
84 #endif // __included_nat44_ei_hairpinning_h__
85 
86 /*
87  * fd.io coding-style-patch-verification: ON
88  *
89  * Local Variables:
90  * eval: (c-set-style "gnu")
91  * End:
92  */
nat44_ei_hairpinning_handoff_error_strings
static char * nat44_ei_hairpinning_handoff_error_strings[]
Definition: nat44_ei_hairpinning.h:17
bufs
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
Definition: nat44_ei_out2in.c:717
vlib_buffer_enqueue_to_thread
static_always_inline u32 vlib_buffer_enqueue_to_thread(vlib_main_t *vm, vlib_node_runtime_t *node, u32 frame_queue_index, u32 *buffer_indices, u16 *thread_indices, u32 n_packets, int drop_on_congestion)
Definition: buffer_node.h:358
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
vlib_get_buffers
vlib_get_buffers(vm, from, b, n_left_from)
VLIB_FRAME_SIZE
#define VLIB_FRAME_SIZE
Definition: node.h:368
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
u16
unsigned short u16
Definition: types.h:57
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
vlib_frame_t
Definition: node.h:372
nat44_ei_hairpinning_handoff_error_t
nat44_ei_hairpinning_handoff_error_t
Definition: nat44_ei_hairpinning.h:9
nat44_ei_hairpinning_handoff_trace_t::next_worker_index
u32 next_worker_index
Definition: nat44_ei_hairpinning.h:25
ti
u32 ti
Definition: interface_output.c:405
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:437
VLIB_NODE_FLAG_TRACE
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:291
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
vlib_frame_vector_args
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:301
uword
u64 uword
Definition: types.h:112
vlib_node_increment_counter
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1244
format_nat44_ei_hairpinning_handoff_trace
static u8 * format_nat44_ei_hairpinning_handoff_trace(u8 *s, va_list *args)
Definition: nat44_ei_hairpinning.h:29
nat44_ei_hairpinning_handoff_fn_inline
static uword nat44_ei_hairpinning_handoff_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u32 fq_index)
Definition: nat44_ei_hairpinning.h:43
nat44_ei.h
foreach_nat44_ei_hairpinning_handoff_error
#define foreach_nat44_ei_hairpinning_handoff_error
Definition: nat44_ei_hairpinning.h:6
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
format
description fragment has unexpected format
Definition: map.api:433
NAT44_EI_HAIRPINNING_HANDOFF_N_ERROR
@ NAT44_EI_HAIRPINNING_HANDOFF_N_ERROR
Definition: nat44_ei_hairpinning.h:14
u32
unsigned int u32
Definition: types.h:88
n_vectors
return frame n_vectors
Definition: nat44_ei_hairpinning.c:485
vlib_main_t
Definition: main.h:102
vlib_node_t
Definition: node.h:247
vlib_add_trace
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace.c:628
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
u8
unsigned char u8
Definition: types.h:56
vlib_node_runtime_t
Definition: node.h:454
from
from
Definition: nat44_ei_hairpinning.c:415
n_left_from
n_left_from
Definition: nat44_ei_hairpinning.c:416
nat44_ei_hairpinning_handoff_trace_t
Definition: nat44_ei_hairpinning.h:23
vlib_buffer_t::flags
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
Definition: buffer.h:133
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111