Skip to content

Commit

Permalink
issue: 4159517 Removing return code from TX poll and process
Browse files Browse the repository at this point in the history
Simplifying TX poll and process by changing return value to void.
TX PE/CQ is always polled until empty.

Signed-off-by: Alexander Grissik <agrissik@nvidia.com>
AlexanderGrissik authored and galnoam committed Dec 22, 2024
1 parent f6b439c commit b9d7f90
Showing 11 changed files with 22 additions and 73 deletions.
6 changes: 1 addition & 5 deletions src/core/dev/cq_mgr_tx.cpp
Original file line number Diff line number Diff line change
@@ -180,15 +180,14 @@ cq_mgr_tx *cq_mgr_tx::get_cq_mgr_from_cq_event(struct ibv_comp_channel *p_cq_cha
return p_cq_mgr;
}

int cq_mgr_tx::poll_and_process_element_tx()
void cq_mgr_tx::poll_and_process_element_tx()
{
cq_logfuncall(LOG_FUNCTION_CALL);

static auto is_error_opcode = [&](uint8_t opcode) {
return opcode == MLX5_CQE_REQ_ERR || opcode == MLX5_CQE_RESP_ERR;
};

int ret = 0;
uint32_t num_polled_cqes = 0;
xlio_mlx5_cqe *cqe = get_cqe_tx(num_polled_cqes);

@@ -202,10 +201,7 @@ int cq_mgr_tx::poll_and_process_element_tx()
}

handle_sq_wqe_prop(index);
ret = 1;
}

return ret;
}

void cq_mgr_tx::log_cqe_error(struct xlio_mlx5_cqe *cqe)
2 changes: 1 addition & 1 deletion src/core/dev/cq_mgr_tx.h
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ class cq_mgr_tx {
*/
bool request_notification();

int poll_and_process_element_tx();
void poll_and_process_element_tx();

void reset_notification_armed() { m_b_notification_armed = false; }

24 changes: 6 additions & 18 deletions src/core/dev/hw_queue_tx.cpp
Original file line number Diff line number Diff line change
@@ -616,14 +616,11 @@ void hw_queue_tx::down()

void hw_queue_tx::release_tx_buffers()
{
int ret;
hwqtx_logdbg("draining cq_mgr_tx %p", m_p_cq_mgr_tx);
while (m_p_cq_mgr_tx && m_mlx5_qp.qp &&
((ret = m_p_cq_mgr_tx->poll_and_process_element_tx()) > 0) &&
(errno != EIO && !m_p_ib_ctx_handler->is_removed())) {
hwqtx_logdbg("draining completed on cq_mgr_tx (%d wce)", ret);
if (m_p_cq_mgr_tx && m_mlx5_qp.qp) {
m_p_cq_mgr_tx->poll_and_process_element_tx();
}
NOT_IN_USE(ret); // Suppress --enable-opt-log=high warning
hwqtx_logdbg("draining completed on cq_mgr_tx");
}

void hw_queue_tx::send_wqe(xlio_ibv_send_wr *p_send_wqe, xlio_wr_tx_packet_attr attr, xlio_tis *tis,
@@ -647,13 +644,7 @@ void hw_queue_tx::send_wqe(xlio_ibv_send_wr *p_send_wqe, xlio_wr_tx_packet_attr
send_to_wire(p_send_wqe, attr, request_comp, tis, credits);

if (!skip_tx_poll && is_signal_requested_for_last_wqe()) {
int ret = m_p_cq_mgr_tx->poll_and_process_element_tx();
BULLSEYE_EXCLUDE_BLOCK_START
if (ret < 0) {
hwqtx_logerr("error from cq_mgr_tx->process_next_element (ret=%d %m)", ret);
}
BULLSEYE_EXCLUDE_BLOCK_END
hwqtx_logfunc("polling succeeded on cq_mgr_tx (%d wce)", ret);
m_p_cq_mgr_tx->poll_and_process_element_tx();
}
}

@@ -2204,14 +2195,11 @@ uint32_t hw_queue_tx::send_doca_lso(struct iovec &h, struct pbuf *p, uint16_t ms
return len_sent;
}

int hw_queue_tx::poll_and_process_doca_tx()
void hw_queue_tx::poll_and_process_doca_tx()
{
int ret = 0;
while (doca_pe_progress(m_doca_pe.get())) {
++ret;
;
}

m_p_ring->return_to_global_pool();

return ret;
}
2 changes: 1 addition & 1 deletion src/core/dev/hw_queue_tx.h
Original file line number Diff line number Diff line change
@@ -224,7 +224,7 @@ class hw_queue_tx : public xlio_ti_owner {

uint32_t send_doca_single(void *ptr, uint32_t len, mem_buf_desc_t *user_data);
uint32_t send_doca_lso(struct iovec &h, struct pbuf *p, uint16_t mss, bool is_zerocopy);
int poll_and_process_doca_tx();
void poll_and_process_doca_tx();
bool request_notification();
void clear_notification();
void put_lso_metadata(doca_lso_metadata *lso_metadata);
2 changes: 1 addition & 1 deletion src/core/dev/net_device_val.cpp
Original file line number Diff line number Diff line change
@@ -1153,7 +1153,7 @@ bool net_device_val::global_ring_poll_and_process_element(void *pv_fd_ready_arra
rings_hash_map_t::iterator ring_iter;
for (ring_iter = m_h_ring_map.begin(); ring_iter != m_h_ring_map.end(); ring_iter++) {
all_drained &= THE_RING->poll_and_process_element_rx(pv_fd_ready_array);
all_drained &= (THE_RING->poll_and_process_element_tx() >= 0);
THE_RING->poll_and_process_element_tx();
}
return all_drained;
}
2 changes: 1 addition & 1 deletion src/core/dev/ring.h
Original file line number Diff line number Diff line change
@@ -108,7 +108,7 @@ class ring {
virtual int drain_and_proccess() = 0;
virtual void clear_rx_notification() = 0;
virtual bool poll_and_process_element_rx(void *pv_fd_ready_array = nullptr) = 0;
virtual int poll_and_process_element_tx() = 0;
virtual void poll_and_process_element_tx() = 0;
virtual void adapt_cq_moderation() = 0;
virtual void mem_buf_desc_return_single_to_owner_tx(mem_buf_desc_t *p_mem_buf_desc) = 0;
virtual void mem_buf_desc_return_single_multi_ref(mem_buf_desc_t *p_mem_buf_desc,
16 changes: 3 additions & 13 deletions src/core/dev/ring_bond.cpp
Original file line number Diff line number Diff line change
@@ -392,29 +392,19 @@ bool ring_bond::poll_and_process_element_rx(void *pv_fd_ready_array /*NULL*/)
return all_drained;
}

int ring_bond::poll_and_process_element_tx()
void ring_bond::poll_and_process_element_tx()
{
if (m_lock_ring_tx.trylock()) {
errno = EAGAIN;
return 0;
return;
}

int temp = 0;
int ret = 0;
for (uint32_t i = 0; i < m_bond_rings.size(); i++) {
if (m_bond_rings[i]->is_up()) {
temp = m_bond_rings[i]->poll_and_process_element_tx();
if (temp > 0) {
ret += temp;
}
m_bond_rings[i]->poll_and_process_element_tx();
}
}
m_lock_ring_tx.unlock();
if (ret > 0) {
return ret;
} else {
return temp;
}
}

int ring_bond::drain_and_proccess()
2 changes: 1 addition & 1 deletion src/core/dev/ring_bond.h
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ class ring_bond : public ring {
virtual bool request_notification(cq_type_t cq_type);
virtual void clear_rx_notification();
virtual bool poll_and_process_element_rx(void *pv_fd_ready_array = nullptr);
virtual int poll_and_process_element_tx();
virtual void poll_and_process_element_tx();
virtual void adapt_cq_moderation();
virtual bool reclaim_recv_buffers(descq_t *rx_reuse);
virtual bool reclaim_recv_buffers(mem_buf_desc_t *rx_reuse_lst);
35 changes: 5 additions & 30 deletions src/core/dev/ring_simple.cpp
Original file line number Diff line number Diff line change
@@ -434,18 +434,11 @@ bool ring_simple::poll_and_process_element_rx(void *pv_fd_ready_array /*NULL*/)
: m_hqrx->poll_and_process_rx());
}

int ring_simple::poll_and_process_element_tx()
void ring_simple::poll_and_process_element_tx()
{
int ret = 0;

std::lock_guard<decltype(m_lock_ring_tx)> lock(m_lock_ring_tx);
if (safe_mce_sys().doca_tx) {
ret = m_hqtx->poll_and_process_doca_tx();
} else {
ret = m_p_cq_mgr_tx->poll_and_process_element_tx();
}

return ret ? 1 : 0;
(safe_mce_sys().doca_tx ? m_hqtx->poll_and_process_doca_tx()
: m_p_cq_mgr_tx->poll_and_process_element_tx());
}

bool ring_simple::reclaim_recv_buffers(descq_t *rx_reuse)
@@ -688,13 +681,7 @@ bool ring_simple::is_available_qp_wr(bool b_block, unsigned credits)

do {
// Try to poll once in the hope that we get space in SQ
ret = m_p_cq_mgr_tx->poll_and_process_element_tx();
if (ret < 0) {
ring_logdbg("failed polling on cq_mgr_tx (hqtx=%p, cq_mgr_tx=%p) (ret=%d %m)", m_hqtx,
m_p_cq_mgr_tx, ret);
/* coverity[missing_unlock] */
return false;
}
m_p_cq_mgr_tx->poll_and_process_element_tx();
granted = m_hqtx->credits_get(credits);
if (granted) {
break;
@@ -750,19 +737,7 @@ bool ring_simple::is_available_qp_wr(bool b_block, unsigned credits)
p_cq_mgr_tx->reset_notification_armed();

// Perform a non blocking event read, clear the fd channel
ret = p_cq_mgr_tx->poll_and_process_element_tx();
if (ret < 0) {
ring_logdbg("failed handling cq_mgr_tx channel (hqtx=%p "
"cq_mgr_tx=%p) (errno=%d %m)",
m_hqtx, m_p_cq_mgr_tx, errno);
/* coverity[double_unlock] TODO: RM#1049980 */
m_lock_ring_tx.unlock();
m_lock_ring_tx_buf_wait.unlock();
/* coverity[double_lock] TODO: RM#1049980 */
m_lock_ring_tx.lock();
return false;
}
ring_logfunc("polling/blocking succeeded on cq_mgr_tx (we got %d wce)", ret);
p_cq_mgr_tx->poll_and_process_element_tx();
}
}

2 changes: 1 addition & 1 deletion src/core/dev/ring_simple.h
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ class ring_simple : public ring_slave {

bool request_notification(cq_type_t cq_type) override;
bool poll_and_process_element_rx(void *pv_fd_ready_array = nullptr) override;
int poll_and_process_element_tx() override;
void poll_and_process_element_tx() override;
void adapt_cq_moderation() override;
bool reclaim_recv_buffers(descq_t *rx_reuse) override;
bool reclaim_recv_buffers(mem_buf_desc_t *rx_reuse_lst) override;
2 changes: 1 addition & 1 deletion src/core/iomux/epfd_info.cpp
Original file line number Diff line number Diff line change
@@ -614,7 +614,7 @@ bool epfd_info::ring_poll_and_process_element(void *pv_fd_ready_array /* = NULL*
bool all_drained = true;
for (ring_map_t::iterator iter = m_ring_map.begin(); iter != m_ring_map.end(); iter++) {
all_drained &= iter->first->poll_and_process_element_rx(pv_fd_ready_array);
all_drained &= (iter->first->poll_and_process_element_tx() >= 0);
iter->first->poll_and_process_element_tx();
}

m_ring_map_lock.unlock();

0 comments on commit b9d7f90

Please sign in to comment.