From fbf9372e681316d2f4cff54c4b13b72e742ec3e9 Mon Sep 17 00:00:00 2001 From: Bang Nguyen Date: Fri, 13 Apr 2012 17:16:31 -0700 Subject: [PATCH] RDS SRQ optional Signed-off-by: Bang Nguyen --- net/rds/ib.h | 1 + net/rds/ib_cm.c | 18 +++++++++--------- net/rds/ib_recv.c | 17 +++++++++++++---- net/rds/threads.c | 3 +-- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/net/rds/ib.h b/net/rds/ib.h index 543c43262578..98ff7ea23392 100644 --- a/net/rds/ib.h +++ b/net/rds/ib.h @@ -434,6 +434,7 @@ unsigned int rds_ib_stats_info_copy(struct rds_info_iterator *iter, extern unsigned int rds_ib_srq_max_wr; extern unsigned int rds_ib_srq_refill_wr; extern unsigned int rds_ib_srq_low_wr; +extern unsigned int rds_ib_srq_enabled; /* ib_sysctl.c */ int rds_ib_sysctl_init(void); diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c index 0ece35d042b1..875fb6bb16e4 100644 --- a/net/rds/ib_cm.c +++ b/net/rds/ib_cm.c @@ -186,12 +186,12 @@ void rds_ib_cm_connect_complete(struct rds_connection *conn, struct rdma_cm_even */ rds_ib_send_init_ring(ic); - if (!ic->conn->c_tos) + if (!rds_ib_srq_enabled) rds_ib_recv_init_ring(ic); /* Post receive buffers - as a side effect, this will update * the posted credit count. */ - if (!ic->conn->c_tos) + if (!rds_ib_srq_enabled) rds_ib_recv_refill(conn, 1, GFP_KERNEL); /* Tune RNR behavior */ @@ -357,7 +357,7 @@ void rds_ib_tasklet_fn_recv(unsigned long data) if (rds_conn_up(conn)) rds_ib_attempt_ack(ic); - if (conn->c_tos) + if (rds_ib_srq_enabled) if ((atomic_read(&rds_ibdev->srq->s_num_posted) < rds_ib_srq_refill_wr) && !test_and_set_bit(0, &rds_ibdev->srq->s_refill_gate)) @@ -432,7 +432,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn) goto out; } - if (ic->conn->c_tos) + if (rds_ib_srq_enabled) ic->i_rcq = ib_create_cq(dev, rds_ib_cq_comp_handler_recv, rds_ib_cq_event_handler, conn, rds_ib_srq_max_wr - 1, @@ -475,7 +475,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn) attr.send_cq = ic->i_scq; attr.recv_cq = ic->i_rcq; - if (ic->conn->c_tos) { + if (rds_ib_srq_enabled) { attr.cap.max_recv_wr = 0; attr.srq = rds_ibdev->srq->s_srq; } @@ -500,7 +500,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn) goto out; } - if (!ic->conn->c_tos) { + if (!rds_ib_srq_enabled) { ic->i_recv_hdrs = ib_dma_alloc_coherent(dev, ic->i_recv_ring.w_nr * sizeof(struct rds_header), @@ -529,7 +529,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn) } memset(ic->i_sends, 0, ic->i_send_ring.w_nr * sizeof(struct rds_ib_send_work)); - if (!ic->conn->c_tos) { + if (!rds_ib_srq_enabled) { ic->i_recvs = vmalloc(ic->i_recv_ring.w_nr * sizeof(struct rds_ib_recv_work)); if (!ic->i_recvs) { @@ -820,7 +820,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn) */ rdsdebug("failed to disconnect, cm: %p err %d\n", ic->i_cm_id, err); - } else if (ic->conn->c_tos && ic->rds_ibdev) { + } else if (rds_ib_srq_enabled && ic->rds_ibdev) { /* wait for the last wqe to complete, then schedule the recv tasklet to drain the RX CQ. @@ -919,7 +919,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn) vfree(ic->i_sends); ic->i_sends = NULL; - if (!ic->conn->c_tos) + if (!rds_ib_srq_enabled) vfree(ic->i_recvs); ic->i_recvs = NULL; diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c index 8acde3eb0c98..74294ca90b92 100644 --- a/net/rds/ib_recv.c +++ b/net/rds/ib_recv.c @@ -41,7 +41,10 @@ unsigned int rds_ib_srq_max_wr = RDS_IB_DEFAULT_SRQ_MAX_WR; unsigned int rds_ib_srq_refill_wr = RDS_IB_DEFAULT_SRQ_REFILL_WR; unsigned int rds_ib_srq_low_wr = RDS_IB_DEFAULT_SRQ_LOW_WR; +unsigned int rds_ib_srq_enabled = 0; +module_param(rds_ib_srq_enabled, int, 0444); +MODULE_PARM_DESC(rds_ib_srq_enabled, "Set to enabled SRQ"); module_param(rds_ib_srq_max_wr, int, 0444); MODULE_PARM_DESC(rds_ib_srq_max_wr, "Max number of SRQ WRs"); module_param(rds_ib_srq_refill_wr, int, 0444); @@ -1262,7 +1265,7 @@ void rds_ib_recv_cqe_handler(struct rds_ib_connection *ic, rds_ib_stats_inc(s_ib_rx_cq_event); - if (conn->c_tos) { + if (rds_ib_srq_enabled) { recv = &rds_ibdev->srq->s_recvs[wc->wr_id]; atomic_dec(&rds_ibdev->srq->s_num_posted); } else @@ -1271,7 +1274,7 @@ void rds_ib_recv_cqe_handler(struct rds_ib_connection *ic, ib_dma_unmap_sg(ic->i_cm_id->device, &recv->r_frag->f_sg, 1, DMA_FROM_DEVICE); if (wc->status == IB_WC_SUCCESS) { - if (ic->conn->c_tos) + if (rds_ib_srq_enabled) rds_ib_srq_process_recv(conn, recv, wc->byte_len, state); else rds_ib_process_recv(conn, recv, wc->byte_len, state); @@ -1297,7 +1300,7 @@ void rds_ib_recv_cqe_handler(struct rds_ib_connection *ic, recv->r_frag = NULL; } - if (!ic->conn->c_tos) { + if (!rds_ib_srq_enabled) { rds_ib_ring_free(&ic->i_recv_ring, 1); rds_ib_recv_refill(conn, 0, GFP_NOWAIT); } else { @@ -1427,7 +1430,7 @@ int rds_ib_recv(struct rds_connection *conn) int ret = 0; rdsdebug("conn %p\n", conn); - if (rds_conn_up(conn)) { + if (!rds_ib_srq_enabled && rds_conn_up(conn)) { rds_ib_attempt_ack(ic); rds_ib_recv_refill(conn, 0, GFP_KERNEL); } @@ -1563,6 +1566,9 @@ int rds_ib_srqs_init(void) struct rds_ib_device *rds_ibdev; int ret; + if (!rds_ib_srq_enabled) + return; + list_for_each_entry(rds_ibdev, &rds_ib_devices, list) { ret = rds_ib_srq_init(rds_ibdev); if (ret) @@ -1597,6 +1603,9 @@ void rds_ib_srqs_exit(void) { struct rds_ib_device *rds_ibdev; + if (!rds_ib_srq_enabled) + return; + list_for_each_entry(rds_ibdev, &rds_ib_devices, list) { rds_ib_srq_exit(rds_ibdev); } diff --git a/net/rds/threads.c b/net/rds/threads.c index dc1896e731b1..2c4948a98931 100644 --- a/net/rds/threads.c +++ b/net/rds/threads.c @@ -88,8 +88,7 @@ void rds_connect_complete(struct rds_connection *conn) conn->c_reconnect_jiffies = 0; set_bit(0, &conn->c_map_queued); queue_delayed_work(rds_wq, &conn->c_send_w, 0); - if (!conn->c_tos) - queue_delayed_work(rds_wq, &conn->c_recv_w, 0); + queue_delayed_work(rds_wq, &conn->c_recv_w, 0); conn->c_connection_start = get_seconds(); } -- 2.50.1