diff options
author | Damjan Marion <damarion@cisco.com> | 2020-03-02 17:36:30 +0100 |
---|---|---|
committer | Damjan Marion <damarion@cisco.com> | 2020-03-02 19:27:31 +0100 |
commit | a3188febc0bc690f2dc09e67ac68ad41000dd46c (patch) | |
tree | 392f97fa3b0766a6a4a58fc5be8085571d7f1bb6 /src/plugins | |
parent | 516e4ed668705bdf0fc138f29275db8c152d19f5 (diff) |
rdma: use per-thread buffer template
Type: improvement
Change-Id: Ie6f2c79e0a769f70eab079c75a500b9308dd51e6
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/rdma/device.c | 14 | ||||
-rw-r--r-- | src/plugins/rdma/input.c | 9 | ||||
-rw-r--r-- | src/plugins/rdma/rdma.h | 7 |
3 files changed, 25 insertions, 5 deletions
diff --git a/src/plugins/rdma/device.c b/src/plugins/rdma/device.c index 7316edbaa25..29d9842e2e2 100644 --- a/src/plugins/rdma/device.c +++ b/src/plugins/rdma/device.c @@ -796,9 +796,23 @@ clib_error_t * rdma_init (vlib_main_t * vm) { rdma_main_t *rm = &rdma_main; + vlib_thread_main_t *tm = vlib_get_thread_main (); rm->log_class = vlib_log_register_class ("rdma", 0); + /* vlib_buffer_t template */ + vec_validate_aligned (rm->per_thread_data, tm->n_vlib_mains - 1, + CLIB_CACHE_LINE_BYTES); + + for (int i = 0; i < tm->n_vlib_mains; i++) + { + rdma_per_thread_data_t *ptd = vec_elt_at_index (rm->per_thread_data, i); + clib_memset (&ptd->buffer_template, 0, sizeof (vlib_buffer_t)); + ptd->buffer_template.flags = VLIB_BUFFER_TOTAL_LENGTH_VALID; + ptd->buffer_template.ref_count = 1; + vnet_buffer (&ptd->buffer_template)->sw_if_index[VLIB_TX] = (u32) ~ 0; + } + return 0; } diff --git a/src/plugins/rdma/input.c b/src/plugins/rdma/input.c index 95909f4c251..8f3bdb773e0 100644 --- a/src/plugins/rdma/input.c +++ b/src/plugins/rdma/input.c @@ -269,7 +269,10 @@ static_always_inline uword rdma_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame, rdma_device_t * rd, u16 qid) { + rdma_main_t *rm = &rdma_main; vnet_main_t *vnm = vnet_get_main (); + rdma_per_thread_data_t *ptd = vec_elt_at_index (rm->per_thread_data, + vm->thread_index); rdma_rxq_t *rxq = vec_elt_at_index (rd->rxqs, qid); struct ibv_wc wc[VLIB_FRAME_SIZE]; vlib_buffer_t bt; @@ -290,13 +293,9 @@ rdma_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, } /* init buffer template */ - clib_memset_u64 (&bt, 0, - STRUCT_OFFSET_OF (vlib_buffer_t, - template_end) / sizeof (u64)); + vlib_buffer_copy_template (&bt, &ptd->buffer_template); vnet_buffer (&bt)->sw_if_index[VLIB_RX] = rd->sw_if_index; - vnet_buffer (&bt)->sw_if_index[VLIB_TX] = ~0; bt.buffer_pool_index = rd->pool; - bt.ref_count = 1; /* update buffer template for input feature arcs if any */ next_index = rd->per_interface_next_index; diff --git a/src/plugins/rdma/rdma.h b/src/plugins/rdma/rdma.h index 470309afba7..302d2383cfe 100644 --- a/src/plugins/rdma/rdma.h +++ b/src/plugins/rdma/rdma.h @@ -95,6 +95,13 @@ typedef struct typedef struct { + CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); + vlib_buffer_t buffer_template; +} rdma_per_thread_data_t; + +typedef struct +{ + rdma_per_thread_data_t *per_thread_data; rdma_device_t *devices; vlib_log_class_t log_class; u16 msg_id_base; |