aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Sliwa <szs@semihalf.com>2018-02-19 16:03:21 +0100
committerSzymon Sliwa <szs@semihalf.com>2018-02-21 16:43:46 +0100
commitd1679209973fe7ddfbe2e3a4f9c44ed023832bad (patch)
tree2b66efce339b79009cf654d9ec19a4166bee6c0e
parent2c8d4cb2c7ed986f084e393259a0fec89072ef3d (diff)
plugins: odp: ipsec: fix style of crypto_inpuc.c
Change-Id: I89cdac40c9f768f42443406cebf7257c3e139b47 Signed-off-by: Szymon Sliwa <szs@semihalf.com>
-rw-r--r--src/plugins/odp/ipsec/crypto_input.c131
1 files changed, 73 insertions, 58 deletions
diff --git a/src/plugins/odp/ipsec/crypto_input.c b/src/plugins/odp/ipsec/crypto_input.c
index 4e580c7..a522b22 100644
--- a/src/plugins/odp/ipsec/crypto_input.c
+++ b/src/plugins/odp/ipsec/crypto_input.c
@@ -23,9 +23,9 @@ typedef enum
foreach_odp_crypto_input_next
#undef _
#define _(f, s) ODP_IPSEC_INPUT_NEXT_##f,
- foreach_odp_ipsec_input_next
+ foreach_odp_ipsec_input_next
#undef _
-ODP_CRYPTO_INPUT_N_NEXT,
+ ODP_CRYPTO_INPUT_N_NEXT,
} odp_crypto_input_next_t;
#define foreach_crypto_input_error \
@@ -133,69 +133,73 @@ odp_dequeue_cops (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
vlib_node_increment_counter (vm, odp_crypto_input_node.index,
- CRYPTO_INPUT_ERROR_DEQUE_COP,
- n_deq);
+ CRYPTO_INPUT_ERROR_DEQUE_COP, n_deq);
return n_deq;
}
static uword
odp_dequeue_ipsec_ops (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame, odp_queue_t queue, u32 next_node_index)
+ vlib_frame_t * frame, odp_queue_t queue,
+ u32 next_node_index)
{
u32 next_index = next_node_index, n_deq, n_cops, *to_next = 0;
- const int MAX_EVENTS = (1<<8);
+ const int MAX_EVENTS = (1 << 8);
odp_event_t events[MAX_EVENTS];
- n_deq = odp_queue_deq_multi(queue, events, MAX_EVENTS);
+ n_deq = odp_queue_deq_multi (queue, events, MAX_EVENTS);
n_cops = n_deq;
int index = 0;
- while(n_cops > 0) {
- u32 n_left_to_next;
-
- vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-
- while(n_cops > 0 && n_left_to_next > 0) {
- odp_event_t event = events[index++];
-
- odp_packet_t pkt;
- vlib_buffer_t *b0;
- u32 bi0;
-
- pkt = odp_packet_from_event(event);
-
- b0 = vlib_buffer_from_odp_packet(pkt);
- bi0 = vlib_get_buffer_index (vm, b0);
-
- b0->current_data =
- (i16) ((intptr_t) odp_packet_data (pkt) -
- (intptr_t) b0->data +
- (intptr_t) odp_packet_l3_offset (pkt));
- if (next_index == ODP_IPSEC_INPUT_NEXT_DECRYPT_POST)
- b0->current_length = odp_packet_len (pkt) - sizeof (ethernet_header_t);
- else
- b0->current_length = odp_packet_len (pkt);
-
- to_next[0] = bi0;
- to_next += 1;
-
- n_cops -= 1;
- n_left_to_next -= 1;
-
- if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
- {
- odp_packet_crypto_trace_t *tr;
- tr = vlib_add_trace (vm, node, b0, sizeof (*tr));
- tr->next_index = next_index;
- }
-
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next, bi0, next_node_index);
- }
- vlib_put_next_frame (vm, node, next_index, n_left_to_next);
- }
+ while (n_cops > 0)
+ {
+ u32 n_left_to_next;
+
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+ while (n_cops > 0 && n_left_to_next > 0)
+ {
+ odp_event_t event = events[index++];
+
+ odp_packet_t pkt;
+ vlib_buffer_t *b0;
+ u32 bi0;
+
+ pkt = odp_packet_from_event (event);
+
+ b0 = vlib_buffer_from_odp_packet (pkt);
+ bi0 = vlib_get_buffer_index (vm, b0);
+
+ b0->current_data =
+ (i16) ((intptr_t) odp_packet_data (pkt) -
+ (intptr_t) b0->data +
+ (intptr_t) odp_packet_l3_offset (pkt));
+ if (next_index == ODP_IPSEC_INPUT_NEXT_DECRYPT_POST)
+ b0->current_length =
+ odp_packet_len (pkt) - sizeof (ethernet_header_t);
+ else
+ b0->current_length = odp_packet_len (pkt);
+
+ to_next[0] = bi0;
+ to_next += 1;
+
+ n_cops -= 1;
+ n_left_to_next -= 1;
+
+ if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
+ {
+ odp_packet_crypto_trace_t *tr;
+ tr = vlib_add_trace (vm, node, b0, sizeof (*tr));
+ tr->next_index = next_index;
+ }
+
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
+ to_next, n_left_to_next, bi0,
+ next_node_index);
+ }
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ }
vlib_node_increment_counter (vm, odp_crypto_input_node.index,
CRYPTO_INPUT_ERROR_DEQUE_COP, n_deq);
@@ -211,13 +215,24 @@ odp_crypto_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
odp_crypto_worker_main_t *cwm =
vec_elt_at_index (ocm->workers, thread_index);
u32 n_cops_dequeued = 0;
- if (!enable_odp_ipsec) {
- n_cops_dequeued += odp_dequeue_cops(vm, node, frame, cwm->post_encrypt, ODP_CRYPTO_INPUT_NEXT_ENCRYPT_POST);
- n_cops_dequeued += odp_dequeue_cops(vm, node, frame, cwm->post_decrypt, ODP_CRYPTO_INPUT_NEXT_DECRYPT_POST);
- } else {
- n_cops_dequeued += odp_dequeue_ipsec_ops(vm, node, frame, cwm->post_encrypt, ODP_IPSEC_INPUT_NEXT_ENCRYPT_POST);
- n_cops_dequeued += odp_dequeue_ipsec_ops(vm, node, frame, cwm->post_decrypt, ODP_IPSEC_INPUT_NEXT_DECRYPT_POST);
- }
+ if (!enable_odp_ipsec)
+ {
+ n_cops_dequeued +=
+ odp_dequeue_cops (vm, node, frame, cwm->post_encrypt,
+ ODP_CRYPTO_INPUT_NEXT_ENCRYPT_POST);
+ n_cops_dequeued +=
+ odp_dequeue_cops (vm, node, frame, cwm->post_decrypt,
+ ODP_CRYPTO_INPUT_NEXT_DECRYPT_POST);
+ }
+ else
+ {
+ n_cops_dequeued +=
+ odp_dequeue_ipsec_ops (vm, node, frame, cwm->post_encrypt,
+ ODP_IPSEC_INPUT_NEXT_ENCRYPT_POST);
+ n_cops_dequeued +=
+ odp_dequeue_ipsec_ops (vm, node, frame, cwm->post_decrypt,
+ ODP_IPSEC_INPUT_NEXT_DECRYPT_POST);
+ }
return n_cops_dequeued;
}