Skip to content

Commit 9c9c072

Browse files
committed
issue: 1792164 Force tx completion for zerocopy buffers
ZCOPY packets should notify application as soon as possible to confirm one that user buffers are free to reuse. So force completion signal for such work requests. Signed-off-by: Igor Ivanov <[email protected]>
1 parent 2e94b10 commit 9c9c072

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

src/vma/dev/qp_mgr.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ qp_mgr::qp_mgr(const ring_simple* p_ring, const ib_ctx_handler* p_context,
100100
m_ibv_rx_sg_array = new ibv_sge[m_n_sysvar_rx_num_wr_to_post_recv];
101101
m_ibv_rx_wr_array = new ibv_recv_wr[m_n_sysvar_rx_num_wr_to_post_recv];
102102

103-
set_unsignaled_count();
104103
memset(&m_rate_limit, 0, sizeof(struct vma_rate_limit_t));
105104

106105
qp_logfunc("");
@@ -336,7 +335,6 @@ void qp_mgr::up()
336335
release_tx_buffers();
337336

338337
/* clean any link to completions with error we might have */
339-
set_unsignaled_count();
340338
m_p_last_tx_mem_buf_desc = NULL;
341339

342340
modify_qp_to_ready_state();
@@ -497,7 +495,6 @@ void qp_mgr::trigger_completion_for_all_sent_packets()
497495

498496
// Close the Tx unsignaled send list
499497
set_unsignaled_count();
500-
m_p_last_tx_mem_buf_desc = NULL;
501498

502499
if (!m_p_ring->m_tx_num_wr_free) {
503500
qp_logdbg("failed to trigger completion for all packets due to no available wr");
@@ -599,9 +596,19 @@ inline int qp_mgr::send_to_wire(vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_at
599596
int qp_mgr::send(vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr)
600597
{
601598
mem_buf_desc_t* p_mem_buf_desc = (mem_buf_desc_t *)p_send_wqe->wr_id;
599+
/* Control tx completions:
600+
* - VMA_TX_WRE_BATCHING - The number of Tx Work Request Elements used
601+
* until a completion signal is requested.
602+
* - ZCOPY packets should notify application as soon as possible to
603+
* confirm one that user buffers are free to reuse. So force completion
604+
* signal for such work requests.
605+
* - First call of send() should do completion. It means that
606+
* m_n_unsignaled_count must be zero for this time.
607+
*/
608+
bool request_comp = (is_completion_need() ||
609+
(p_mem_buf_desc->m_flags & mem_buf_desc_t::ZCOPY));
602610

603611
qp_logfunc("VERBS send, unsignaled_count: %d", m_n_unsignaled_count);
604-
bool request_comp = is_completion_need();
605612

606613
#ifdef VMA_TIME_MEASURE
607614
TAKE_T_TX_POST_SEND_START;
@@ -636,7 +643,6 @@ int qp_mgr::send(vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr)
636643
int ret;
637644

638645
set_unsignaled_count();
639-
m_p_last_tx_mem_buf_desc = NULL;
640646

641647
// Poll the Tx CQ
642648
uint64_t dummy_poll_sn = 0;

src/vma/dev/qp_mgr.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,10 @@ friend class cq_mgr_mp;
172172

173173
int configure(struct ibv_comp_channel* p_rx_comp_event_channel);
174174
virtual int prepare_ibv_qp(vma_ibv_qp_init_attr& qp_init_attr) = 0;
175-
inline void set_unsignaled_count(void) { m_n_unsignaled_count = m_n_sysvar_tx_num_wr_to_signal - 1; }
175+
inline void set_unsignaled_count(void) {
176+
m_n_unsignaled_count = m_n_sysvar_tx_num_wr_to_signal - 1;
177+
m_p_last_tx_mem_buf_desc = NULL;
178+
}
176179

177180
virtual cq_mgr* init_rx_cq_mgr(struct ibv_comp_channel* p_rx_comp_event_channel);
178181
virtual cq_mgr* init_tx_cq_mgr(void);

src/vma/dev/qp_mgr_eth_mlx5.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,6 @@ void qp_mgr_eth_mlx5::trigger_completion_for_all_sent_packets()
887887

888888
// Close the Tx unsignaled send list
889889
set_unsignaled_count();
890-
m_p_last_tx_mem_buf_desc = NULL;
891890

892891
if (!m_p_ring->m_tx_num_wr_free) {
893892
qp_logdbg("failed to trigger completion for all packets due to no available wr");

0 commit comments

Comments
 (0)