Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 1 | /* |
| 2 | *------------------------------------------------------------------ |
| 3 | * crypto_node.c - DPDK Cryptodev input node |
| 4 | * |
Sergio Gonzalez Monroy | db93cd9 | 2017-08-26 15:22:05 +0100 | [diff] [blame] | 5 | * Copyright (c) 2017 Intel and/or its affiliates. |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
Sergio Gonzalez Monroy | db93cd9 | 2017-08-26 15:22:05 +0100 | [diff] [blame] | 8 | * You may obtain a opy of the License at: |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | *------------------------------------------------------------------ |
| 18 | */ |
| 19 | |
| 20 | #include <vlib/vlib.h> |
| 21 | #include <vnet/ip/ip.h> |
| 22 | #include <vnet/ethernet/ethernet.h> |
| 23 | #include <vnet/ipsec/ipsec.h> |
| 24 | |
Damjan Marion | a5c308e | 2019-01-20 02:02:51 +0100 | [diff] [blame] | 25 | #include <dpdk/buffer.h> |
Damjan Marion | c3a814b | 2017-02-28 19:22:22 +0100 | [diff] [blame] | 26 | #include <dpdk/device/dpdk.h> |
| 27 | #include <dpdk/device/dpdk_priv.h> |
| 28 | #include <dpdk/ipsec/ipsec.h> |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 29 | |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 30 | #define foreach_dpdk_crypto_input_error \ |
| 31 | _(DQ_COPS, "Crypto ops dequeued") \ |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 32 | _(AUTH_FAILED, "Crypto verification failed") \ |
Sergio Gonzalez Monroy | db93cd9 | 2017-08-26 15:22:05 +0100 | [diff] [blame] | 33 | _(STATUS, "Crypto operation failed") |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 34 | |
| 35 | typedef enum |
| 36 | { |
| 37 | #define _(f,s) DPDK_CRYPTO_INPUT_ERROR_##f, |
| 38 | foreach_dpdk_crypto_input_error |
| 39 | #undef _ |
| 40 | DPDK_CRYPTO_INPUT_N_ERROR, |
| 41 | } dpdk_crypto_input_error_t; |
| 42 | |
| 43 | static char *dpdk_crypto_input_error_strings[] = { |
| 44 | #define _(n, s) s, |
| 45 | foreach_dpdk_crypto_input_error |
| 46 | #undef _ |
| 47 | }; |
| 48 | |
Kingwel Xie | 040950a | 2018-11-28 02:10:35 -0500 | [diff] [blame] | 49 | extern vlib_node_registration_t dpdk_crypto_input_node; |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 50 | |
| 51 | typedef struct |
| 52 | { |
Kingwel Xie | b8999b1 | 2019-01-25 05:18:51 -0500 | [diff] [blame] | 53 | /* dev id of this cryptodev */ |
| 54 | u16 dev_id; |
| 55 | u16 next_index; |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 56 | } dpdk_crypto_input_trace_t; |
| 57 | |
| 58 | static u8 * |
| 59 | format_dpdk_crypto_input_trace (u8 * s, va_list * args) |
| 60 | { |
| 61 | CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); |
| 62 | CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); |
| 63 | dpdk_crypto_input_trace_t *t = va_arg (*args, dpdk_crypto_input_trace_t *); |
| 64 | |
Kingwel Xie | b8999b1 | 2019-01-25 05:18:51 -0500 | [diff] [blame] | 65 | s = format (s, "cryptodev-id %d next-index %d", t->dev_id, t->next_index); |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 66 | |
| 67 | return s; |
| 68 | } |
| 69 | |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 70 | static_always_inline void |
Kingwel Xie | 4270808 | 2018-12-23 23:54:19 -0500 | [diff] [blame] | 71 | dpdk_crypto_input_check_op (vlib_main_t * vm, vlib_node_runtime_t * node, |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 72 | struct rte_crypto_op *op0, u16 * next) |
| 73 | { |
| 74 | if (PREDICT_FALSE (op0->status != RTE_CRYPTO_OP_STATUS_SUCCESS)) |
| 75 | { |
| 76 | next[0] = DPDK_CRYPTO_INPUT_NEXT_DROP; |
| 77 | vlib_node_increment_counter (vm, |
| 78 | node->node_index, |
| 79 | DPDK_CRYPTO_INPUT_ERROR_STATUS, 1); |
| 80 | /* if auth failed */ |
| 81 | if (op0->status == RTE_CRYPTO_OP_STATUS_AUTH_FAILED) |
| 82 | vlib_node_increment_counter (vm, |
| 83 | node->node_index, |
| 84 | DPDK_CRYPTO_INPUT_ERROR_AUTH_FAILED, 1); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | always_inline void |
| 89 | dpdk_crypto_input_trace (vlib_main_t * vm, vlib_node_runtime_t * node, |
Kingwel Xie | b8999b1 | 2019-01-25 05:18:51 -0500 | [diff] [blame] | 90 | u8 dev_id, u32 * bis, u16 * nexts, u32 n_deq) |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 91 | { |
| 92 | u32 n_left, n_trace; |
Kingwel Xie | b8999b1 | 2019-01-25 05:18:51 -0500 | [diff] [blame] | 93 | |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 94 | if (PREDICT_FALSE ((n_trace = vlib_get_trace_count (vm, node)))) |
| 95 | { |
| 96 | n_left = n_deq; |
| 97 | |
| 98 | while (n_trace && n_left) |
| 99 | { |
| 100 | vlib_buffer_t *b0; |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 101 | u16 next; |
Kingwel Xie | b8999b1 | 2019-01-25 05:18:51 -0500 | [diff] [blame] | 102 | u32 bi; |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 103 | |
Kingwel Xie | b8999b1 | 2019-01-25 05:18:51 -0500 | [diff] [blame] | 104 | bi = bis[0]; |
| 105 | next = nexts[0]; |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 106 | |
Kingwel Xie | b8999b1 | 2019-01-25 05:18:51 -0500 | [diff] [blame] | 107 | b0 = vlib_get_buffer (vm, bi); |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 108 | |
BenoƮt Ganne | 9a3973e | 2020-10-02 19:36:57 +0200 | [diff] [blame] | 109 | if (PREDICT_TRUE |
| 110 | (vlib_trace_buffer (vm, node, next, b0, /* follow_chain */ 0))) |
| 111 | { |
| 112 | dpdk_crypto_input_trace_t *tr = |
| 113 | vlib_add_trace (vm, node, b0, sizeof (*tr)); |
| 114 | tr->dev_id = dev_id; |
| 115 | tr->next_index = next; |
| 116 | n_trace--; |
| 117 | } |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 118 | |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 119 | n_left--; |
Kingwel Xie | b8999b1 | 2019-01-25 05:18:51 -0500 | [diff] [blame] | 120 | nexts++; |
| 121 | bis++; |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 122 | } |
| 123 | vlib_set_trace_count (vm, node, n_trace); |
| 124 | } |
| 125 | } |
| 126 | |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 127 | static_always_inline u32 |
Kingwel Xie | 3b3464e | 2019-02-13 02:48:41 -0500 | [diff] [blame] | 128 | dpdk_crypto_dequeue (vlib_main_t * vm, crypto_worker_main_t * cwm, |
| 129 | vlib_node_runtime_t * node, crypto_resource_t * res) |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 130 | { |
Sergio Gonzalez Monroy | db93cd9 | 2017-08-26 15:22:05 +0100 | [diff] [blame] | 131 | u8 numa = rte_socket_id (); |
Sergio Gonzalez Monroy | d8a34a5 | 2019-05-06 22:44:14 +0200 | [diff] [blame] | 132 | u32 n_ops, total_n_deq, n_deq[2]; |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 133 | u32 bis[VLIB_FRAME_SIZE], *bi; |
| 134 | u16 nexts[VLIB_FRAME_SIZE], *next; |
Sergio Gonzalez Monroy | db93cd9 | 2017-08-26 15:22:05 +0100 | [diff] [blame] | 135 | struct rte_crypto_op **ops; |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 136 | |
Sergio Gonzalez Monroy | d8a34a5 | 2019-05-06 22:44:14 +0200 | [diff] [blame] | 137 | n_deq[0] = 0; |
| 138 | n_deq[1] = 0; |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 139 | bi = bis; |
| 140 | next = nexts; |
| 141 | ops = cwm->ops; |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 142 | |
Sergio Gonzalez Monroy | d8a34a5 | 2019-05-06 22:44:14 +0200 | [diff] [blame] | 143 | n_ops = total_n_deq = rte_cryptodev_dequeue_burst (res->dev_id, |
| 144 | res->qp_id, |
| 145 | ops, VLIB_FRAME_SIZE); |
Kingwel Xie | 955ee28 | 2018-12-25 21:31:28 -0500 | [diff] [blame] | 146 | /* no op dequeued, do not proceed */ |
Sergio Gonzalez Monroy | d8a34a5 | 2019-05-06 22:44:14 +0200 | [diff] [blame] | 147 | if (n_ops == 0) |
Kingwel Xie | 955ee28 | 2018-12-25 21:31:28 -0500 | [diff] [blame] | 148 | return 0; |
| 149 | |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 150 | while (n_ops >= 4) |
| 151 | { |
| 152 | struct rte_crypto_op *op0, *op1, *op2, *op3; |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 153 | |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 154 | /* Prefetch next iteration. */ |
| 155 | if (n_ops >= 8) |
| 156 | { |
| 157 | CLIB_PREFETCH (ops[4], CLIB_CACHE_LINE_BYTES, LOAD); |
| 158 | CLIB_PREFETCH (ops[5], CLIB_CACHE_LINE_BYTES, LOAD); |
| 159 | CLIB_PREFETCH (ops[6], CLIB_CACHE_LINE_BYTES, LOAD); |
| 160 | CLIB_PREFETCH (ops[7], CLIB_CACHE_LINE_BYTES, LOAD); |
Sergio Gonzalez Monroy | db93cd9 | 2017-08-26 15:22:05 +0100 | [diff] [blame] | 161 | |
Kingwel Xie | 955ee28 | 2018-12-25 21:31:28 -0500 | [diff] [blame] | 162 | CLIB_PREFETCH (crypto_op_get_priv (ops[4]), |
| 163 | CLIB_CACHE_LINE_BYTES, LOAD); |
| 164 | CLIB_PREFETCH (crypto_op_get_priv (ops[5]), |
| 165 | CLIB_CACHE_LINE_BYTES, LOAD); |
| 166 | CLIB_PREFETCH (crypto_op_get_priv (ops[6]), |
| 167 | CLIB_CACHE_LINE_BYTES, LOAD); |
| 168 | CLIB_PREFETCH (crypto_op_get_priv (ops[7]), |
| 169 | CLIB_CACHE_LINE_BYTES, LOAD); |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 170 | } |
Sergio Gonzalez Monroy | db93cd9 | 2017-08-26 15:22:05 +0100 | [diff] [blame] | 171 | |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 172 | op0 = ops[0]; |
| 173 | op1 = ops[1]; |
| 174 | op2 = ops[2]; |
| 175 | op3 = ops[3]; |
Sergio Gonzalez Monroy | db93cd9 | 2017-08-26 15:22:05 +0100 | [diff] [blame] | 176 | |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 177 | next[0] = crypto_op_get_priv (op0)->next; |
| 178 | next[1] = crypto_op_get_priv (op1)->next; |
| 179 | next[2] = crypto_op_get_priv (op2)->next; |
| 180 | next[3] = crypto_op_get_priv (op3)->next; |
Sergio Gonzalez Monroy | db93cd9 | 2017-08-26 15:22:05 +0100 | [diff] [blame] | 181 | |
Kingwel Xie | 3b3464e | 2019-02-13 02:48:41 -0500 | [diff] [blame] | 182 | bi[0] = crypto_op_get_priv (op0)->bi; |
| 183 | bi[1] = crypto_op_get_priv (op1)->bi; |
| 184 | bi[2] = crypto_op_get_priv (op2)->bi; |
| 185 | bi[3] = crypto_op_get_priv (op3)->bi; |
| 186 | |
Sergio Gonzalez Monroy | d8a34a5 | 2019-05-06 22:44:14 +0200 | [diff] [blame] | 187 | n_deq[crypto_op_get_priv (op0)->encrypt] += 1; |
| 188 | n_deq[crypto_op_get_priv (op1)->encrypt] += 1; |
| 189 | n_deq[crypto_op_get_priv (op2)->encrypt] += 1; |
| 190 | n_deq[crypto_op_get_priv (op3)->encrypt] += 1; |
| 191 | |
Kingwel Xie | 4270808 | 2018-12-23 23:54:19 -0500 | [diff] [blame] | 192 | dpdk_crypto_input_check_op (vm, node, op0, next + 0); |
| 193 | dpdk_crypto_input_check_op (vm, node, op1, next + 1); |
| 194 | dpdk_crypto_input_check_op (vm, node, op2, next + 2); |
| 195 | dpdk_crypto_input_check_op (vm, node, op3, next + 3); |
Sergio Gonzalez Monroy | db93cd9 | 2017-08-26 15:22:05 +0100 | [diff] [blame] | 196 | |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 197 | op0->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; |
| 198 | op1->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; |
| 199 | op2->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; |
| 200 | op3->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; |
Sergio Gonzalez Monroy | db93cd9 | 2017-08-26 15:22:05 +0100 | [diff] [blame] | 201 | |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 202 | /* next */ |
| 203 | next += 4; |
| 204 | n_ops -= 4; |
| 205 | ops += 4; |
| 206 | bi += 4; |
| 207 | } |
| 208 | while (n_ops > 0) |
| 209 | { |
| 210 | struct rte_crypto_op *op0; |
Sergio Gonzalez Monroy | db93cd9 | 2017-08-26 15:22:05 +0100 | [diff] [blame] | 211 | |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 212 | op0 = ops[0]; |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 213 | |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 214 | next[0] = crypto_op_get_priv (op0)->next; |
Kingwel Xie | 3b3464e | 2019-02-13 02:48:41 -0500 | [diff] [blame] | 215 | bi[0] = crypto_op_get_priv (op0)->bi; |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 216 | |
Sergio Gonzalez Monroy | d8a34a5 | 2019-05-06 22:44:14 +0200 | [diff] [blame] | 217 | n_deq[crypto_op_get_priv (op0)->encrypt] += 1; |
| 218 | |
Kingwel Xie | 4270808 | 2018-12-23 23:54:19 -0500 | [diff] [blame] | 219 | dpdk_crypto_input_check_op (vm, node, op0, next + 0); |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 220 | |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 221 | op0->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; |
| 222 | |
| 223 | /* next */ |
| 224 | next += 1; |
| 225 | n_ops -= 1; |
| 226 | ops += 1; |
| 227 | bi += 1; |
| 228 | } |
| 229 | |
| 230 | vlib_node_increment_counter (vm, node->node_index, |
Sergio Gonzalez Monroy | d8a34a5 | 2019-05-06 22:44:14 +0200 | [diff] [blame] | 231 | DPDK_CRYPTO_INPUT_ERROR_DQ_COPS, total_n_deq); |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 232 | |
Sergio Gonzalez Monroy | d8a34a5 | 2019-05-06 22:44:14 +0200 | [diff] [blame] | 233 | res->inflights[0] -= n_deq[0]; |
| 234 | res->inflights[1] -= n_deq[1]; |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 235 | |
Sergio Gonzalez Monroy | d8a34a5 | 2019-05-06 22:44:14 +0200 | [diff] [blame] | 236 | vlib_buffer_enqueue_to_next (vm, node, bis, nexts, total_n_deq); |
Kingwel Xie | b8999b1 | 2019-01-25 05:18:51 -0500 | [diff] [blame] | 237 | |
Sergio Gonzalez Monroy | d8a34a5 | 2019-05-06 22:44:14 +0200 | [diff] [blame] | 238 | dpdk_crypto_input_trace (vm, node, res->dev_id, bis, nexts, total_n_deq); |
Kingwel Xie | b9894ee | 2018-12-22 03:17:15 -0500 | [diff] [blame] | 239 | |
Sergio Gonzalez Monroy | d8a34a5 | 2019-05-06 22:44:14 +0200 | [diff] [blame] | 240 | crypto_free_ops (numa, cwm->ops, total_n_deq); |
| 241 | |
| 242 | return total_n_deq; |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 243 | } |
| 244 | |
Kingwel Xie | 040950a | 2018-11-28 02:10:35 -0500 | [diff] [blame] | 245 | static_always_inline uword |
| 246 | dpdk_crypto_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, |
| 247 | vlib_frame_t * frame) |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 248 | { |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 249 | dpdk_crypto_main_t *dcm = &dpdk_crypto_main; |
Kingwel Xie | 3b3464e | 2019-02-13 02:48:41 -0500 | [diff] [blame] | 250 | crypto_worker_main_t *cwm = &dcm->workers_main[vm->thread_index]; |
Sergio Gonzalez Monroy | db93cd9 | 2017-08-26 15:22:05 +0100 | [diff] [blame] | 251 | crypto_resource_t *res; |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 252 | u32 n_deq = 0; |
Sergio Gonzalez Monroy | db93cd9 | 2017-08-26 15:22:05 +0100 | [diff] [blame] | 253 | u16 *remove = NULL, *res_idx; |
| 254 | word i; |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 255 | |
| 256 | /* *INDENT-OFF* */ |
Sergio Gonzalez Monroy | db93cd9 | 2017-08-26 15:22:05 +0100 | [diff] [blame] | 257 | vec_foreach (res_idx, cwm->resource_idx) |
| 258 | { |
| 259 | res = vec_elt_at_index (dcm->resource, res_idx[0]); |
Sergio Gonzalez Monroy | d8a34a5 | 2019-05-06 22:44:14 +0200 | [diff] [blame] | 260 | u32 inflights = res->inflights[0] + res->inflights[1]; |
Sergio Gonzalez Monroy | db93cd9 | 2017-08-26 15:22:05 +0100 | [diff] [blame] | 261 | |
Sergio Gonzalez Monroy | d8a34a5 | 2019-05-06 22:44:14 +0200 | [diff] [blame] | 262 | if (inflights) |
Kingwel Xie | 3b3464e | 2019-02-13 02:48:41 -0500 | [diff] [blame] | 263 | n_deq += dpdk_crypto_dequeue (vm, cwm, node, res); |
Sergio Gonzalez Monroy | db93cd9 | 2017-08-26 15:22:05 +0100 | [diff] [blame] | 264 | |
Sergio Gonzalez Monroy | d8a34a5 | 2019-05-06 22:44:14 +0200 | [diff] [blame] | 265 | inflights = res->inflights[0] + res->inflights[1]; |
| 266 | if (PREDICT_FALSE (res->remove && !(inflights))) |
Sergio Gonzalez Monroy | db93cd9 | 2017-08-26 15:22:05 +0100 | [diff] [blame] | 267 | vec_add1 (remove, res_idx[0]); |
| 268 | } |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 269 | /* *INDENT-ON* */ |
| 270 | |
Sergio Gonzalez Monroy | db93cd9 | 2017-08-26 15:22:05 +0100 | [diff] [blame] | 271 | /* TODO removal on master thread? */ |
| 272 | if (PREDICT_FALSE (remove != NULL)) |
| 273 | { |
| 274 | /* *INDENT-OFF* */ |
| 275 | vec_foreach (res_idx, remove) |
| 276 | { |
| 277 | i = vec_search (cwm->resource_idx, res_idx[0]); |
| 278 | vec_del1 (cwm->resource_idx, i); |
| 279 | |
| 280 | res = vec_elt_at_index (dcm->resource, res_idx[0]); |
| 281 | res->thread_idx = (u16) ~0; |
| 282 | res->remove = 0; |
| 283 | |
| 284 | i = vec_search (dcm->dev[res->dev_id].used_resources, res_idx[0]); |
| 285 | ASSERT (i != (u16) ~0); |
| 286 | vec_del1 (dcm->dev[res->dev_id].used_resources, i); |
| 287 | vec_add1 (dcm->dev[res->dev_id].free_resources, res_idx[0]); |
| 288 | } |
| 289 | /* *INDENT-ON* */ |
| 290 | |
| 291 | vec_free (remove); |
| 292 | } |
| 293 | |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 294 | return n_deq; |
| 295 | } |
| 296 | |
Kingwel Xie | 040950a | 2018-11-28 02:10:35 -0500 | [diff] [blame] | 297 | VLIB_NODE_FN (dpdk_crypto_input_node) (vlib_main_t * vm, |
| 298 | vlib_node_runtime_t * node, |
| 299 | vlib_frame_t * from_frame) |
| 300 | { |
| 301 | return dpdk_crypto_input_inline (vm, node, from_frame); |
| 302 | } |
| 303 | |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 304 | /* *INDENT-OFF* */ |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 305 | VLIB_REGISTER_NODE (dpdk_crypto_input_node) = |
| 306 | { |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 307 | .name = "dpdk-crypto-input", |
Damjan Marion | 7ca5aaa | 2019-09-24 18:10:49 +0200 | [diff] [blame] | 308 | .flags = VLIB_NODE_FLAG_TRACE_SUPPORTED, |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 309 | .format_trace = format_dpdk_crypto_input_trace, |
| 310 | .type = VLIB_NODE_TYPE_INPUT, |
| 311 | .state = VLIB_NODE_STATE_DISABLED, |
| 312 | .n_errors = DPDK_CRYPTO_INPUT_N_ERROR, |
| 313 | .error_strings = dpdk_crypto_input_error_strings, |
| 314 | .n_next_nodes = DPDK_CRYPTO_INPUT_N_NEXT, |
| 315 | .next_nodes = |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 316 | { |
| 317 | #define _(s,n) [DPDK_CRYPTO_INPUT_NEXT_##s] = n, |
| 318 | foreach_dpdk_crypto_input_next |
| 319 | #undef _ |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 320 | }, |
| 321 | }; |
| 322 | /* *INDENT-ON* */ |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 323 | |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 324 | /* |
| 325 | * fd.io coding-style-patch-verification: ON |
| 326 | * |
| 327 | * Local Variables: |
| 328 | * eval: (c-set-style "gnu") |
| 329 | * End: |
| 330 | */ |