aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/dpdk/ipsec
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2017-04-05 19:18:20 +0200
committerDave Barach <openvpp@barachs.net>2017-04-06 11:31:39 +0000
commit586afd762bfa149f5ca167bd5fd5a0cd59ce94fe (patch)
tree808b57c61e0fe1a181871bb1ad94398c5ba42671 /src/plugins/dpdk/ipsec
parentbc799c92d761a2d45105aa6a1685b3663687d2a4 (diff)
Use thread local storage for thread index
This patch deprecates stack-based thread identification, Also removes requirement that thread stacks are adjacent. Finally, possibly annoying for some folks, it renames all occurences of cpu_index and cpu_number with thread index. Using word "cpu" is misleading here as thread can be migrated ti different CPU, and also it is not related to linux cpu index. Change-Id: I68cdaf661e701d2336fc953dcb9978d10a70f7c1 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins/dpdk/ipsec')
-rw-r--r--src/plugins/dpdk/ipsec/cli.c8
-rw-r--r--src/plugins/dpdk/ipsec/crypto_node.c4
-rw-r--r--src/plugins/dpdk/ipsec/esp.h4
-rw-r--r--src/plugins/dpdk/ipsec/esp_decrypt.c4
-rw-r--r--src/plugins/dpdk/ipsec/esp_encrypt.c5
-rw-r--r--src/plugins/dpdk/ipsec/ipsec.c2
-rw-r--r--src/plugins/dpdk/ipsec/ipsec.h4
7 files changed, 16 insertions, 15 deletions
diff --git a/src/plugins/dpdk/ipsec/cli.c b/src/plugins/dpdk/ipsec/cli.c
index cd0a6037e4e..3ae8c9b886d 100644
--- a/src/plugins/dpdk/ipsec/cli.c
+++ b/src/plugins/dpdk/ipsec/cli.c
@@ -42,8 +42,8 @@ dpdk_ipsec_show_mapping (vlib_main_t * vm, u16 detail_display)
for (i = 0; i < tm->n_vlib_mains; i++)
{
uword key, data;
- u32 cpu_index = vlib_mains[i]->cpu_index;
- crypto_worker_main_t *cwm = &dcm->workers_main[cpu_index];
+ u32 thread_index = vlib_mains[i]->thread_index;
+ crypto_worker_main_t *cwm = &dcm->workers_main[thread_index];
u8 *s = 0;
if (skip_master)
@@ -57,7 +57,7 @@ dpdk_ipsec_show_mapping (vlib_main_t * vm, u16 detail_display)
i32 last_cdev = -1;
crypto_qp_data_t *qpd;
- s = format (s, "%u\t", cpu_index);
+ s = format (s, "%u\t", thread_index);
/* *INDENT-OFF* */
vec_foreach (qpd, cwm->qp_data)
@@ -95,7 +95,7 @@ dpdk_ipsec_show_mapping (vlib_main_t * vm, u16 detail_display)
cap.sym.auth.algo = p_key->auth_algo;
check_algo_is_supported (&cap, auth_str);
vlib_cli_output (vm, "%u\t%10s\t%15s\t%3s\t%u\t%u\n",
- vlib_mains[i]->cpu_index, cipher_str, auth_str,
+ vlib_mains[i]->thread_index, cipher_str, auth_str,
p_key->is_outbound ? "out" : "in",
cwm->qp_data[data].dev_id,
cwm->qp_data[data].qp_id);
diff --git a/src/plugins/dpdk/ipsec/crypto_node.c b/src/plugins/dpdk/ipsec/crypto_node.c
index dc3452b286e..a3c459023a3 100644
--- a/src/plugins/dpdk/ipsec/crypto_node.c
+++ b/src/plugins/dpdk/ipsec/crypto_node.c
@@ -171,9 +171,9 @@ static uword
dpdk_crypto_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
dpdk_crypto_main_t *dcm = &dpdk_crypto_main;
- crypto_worker_main_t *cwm = &dcm->workers_main[cpu_index];
+ crypto_worker_main_t *cwm = &dcm->workers_main[thread_index];
crypto_qp_data_t *qpd;
u32 n_deq = 0;
diff --git a/src/plugins/dpdk/ipsec/esp.h b/src/plugins/dpdk/ipsec/esp.h
index 320295b19e6..56f0c756eec 100644
--- a/src/plugins/dpdk/ipsec/esp.h
+++ b/src/plugins/dpdk/ipsec/esp.h
@@ -170,9 +170,9 @@ static_always_inline int
create_sym_sess (ipsec_sa_t * sa, crypto_sa_session_t * sa_sess,
u8 is_outbound)
{
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
dpdk_crypto_main_t *dcm = &dpdk_crypto_main;
- crypto_worker_main_t *cwm = &dcm->workers_main[cpu_index];
+ crypto_worker_main_t *cwm = &dcm->workers_main[thread_index];
struct rte_crypto_sym_xform cipher_xform = { 0 };
struct rte_crypto_sym_xform auth_xform = { 0 };
struct rte_crypto_sym_xform *xfs;
diff --git a/src/plugins/dpdk/ipsec/esp_decrypt.c b/src/plugins/dpdk/ipsec/esp_decrypt.c
index 286e03f85da..bab76e3b665 100644
--- a/src/plugins/dpdk/ipsec/esp_decrypt.c
+++ b/src/plugins/dpdk/ipsec/esp_decrypt.c
@@ -88,7 +88,7 @@ dpdk_esp_decrypt_node_fn (vlib_main_t * vm,
{
u32 n_left_from, *from, *to_next, next_index;
ipsec_main_t *im = &ipsec_main;
- u32 cpu_index = os_get_cpu_number();
+ u32 thread_index = vlib_get_thread_index();
dpdk_crypto_main_t * dcm = &dpdk_crypto_main;
dpdk_esp_main_t * em = &dpdk_esp_main;
u32 i;
@@ -104,7 +104,7 @@ dpdk_esp_decrypt_node_fn (vlib_main_t * vm,
return n_left_from;
}
- crypto_worker_main_t *cwm = vec_elt_at_index(dcm->workers_main, cpu_index);
+ crypto_worker_main_t *cwm = vec_elt_at_index(dcm->workers_main, thread_index);
u32 n_qps = vec_len(cwm->qp_data);
struct rte_crypto_op ** cops_to_enq[n_qps];
u32 n_cop_qp[n_qps], * bi_to_enq[n_qps];
diff --git a/src/plugins/dpdk/ipsec/esp_encrypt.c b/src/plugins/dpdk/ipsec/esp_encrypt.c
index 5b03de73bf2..f996d7df999 100644
--- a/src/plugins/dpdk/ipsec/esp_encrypt.c
+++ b/src/plugins/dpdk/ipsec/esp_encrypt.c
@@ -93,7 +93,7 @@ dpdk_esp_encrypt_node_fn (vlib_main_t * vm,
{
u32 n_left_from, *from, *to_next, next_index;
ipsec_main_t *im = &ipsec_main;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
dpdk_crypto_main_t *dcm = &dpdk_crypto_main;
dpdk_esp_main_t *em = &dpdk_esp_main;
u32 i;
@@ -111,7 +111,8 @@ dpdk_esp_encrypt_node_fn (vlib_main_t * vm,
return n_left_from;
}
- crypto_worker_main_t *cwm = vec_elt_at_index (dcm->workers_main, cpu_index);
+ crypto_worker_main_t *cwm =
+ vec_elt_at_index (dcm->workers_main, thread_index);
u32 n_qps = vec_len (cwm->qp_data);
struct rte_crypto_op **cops_to_enq[n_qps];
u32 n_cop_qp[n_qps], *bi_to_enq[n_qps];
diff --git a/src/plugins/dpdk/ipsec/ipsec.c b/src/plugins/dpdk/ipsec/ipsec.c
index b0aaaaeca17..5d8f4fba7f3 100644
--- a/src/plugins/dpdk/ipsec/ipsec.c
+++ b/src/plugins/dpdk/ipsec/ipsec.c
@@ -289,7 +289,7 @@ dpdk_ipsec_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
if (!map)
{
clib_warning ("unable to create hash table for worker %u",
- vlib_mains[i]->cpu_index);
+ vlib_mains[i]->thread_index);
goto error;
}
cwm->algo_qp_map = map;
diff --git a/src/plugins/dpdk/ipsec/ipsec.h b/src/plugins/dpdk/ipsec/ipsec.h
index 28bffc8021e..f0f793c022b 100644
--- a/src/plugins/dpdk/ipsec/ipsec.h
+++ b/src/plugins/dpdk/ipsec/ipsec.h
@@ -95,8 +95,8 @@ static_always_inline void
crypto_alloc_cops ()
{
dpdk_crypto_main_t *dcm = &dpdk_crypto_main;
- u32 cpu_index = os_get_cpu_number ();
- crypto_worker_main_t *cwm = &dcm->workers_main[cpu_index];
+ u32 thread_index = vlib_get_thread_index ();
+ crypto_worker_main_t *cwm = &dcm->workers_main[thread_index];
unsigned socket_id = rte_socket_id ();
crypto_qp_data_t *qpd;