Skip to content

Commit eecd0fd

Browse files
Wei Lin GuayDhaval Giani
authored andcommitted
net/rds: set the rds_ib_init_frag based on supported sge
The large fragment size requires the underlying HCA to support N sge. Thus, this patch sets the rds_ib_init_frag based on the minimal of (rds_ibdev->max_sge - 1) * PAGE_SIZE and the rds_ib_max_frag module_param. Orabug: 26770234 Signed-off-by: Wei Lin Guay <[email protected]> Reviewed-by: Håkon Bugge <[email protected]> Tested-by: Shih-Yu Huang <[email protected]> Acked-by: Santosh Shilimkar <[email protected]> Signed-off-by: Dhaval Giani <[email protected]>
1 parent 2736f99 commit eecd0fd

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

net/rds/ib.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,6 +2032,7 @@ void rds_ib_add_one(struct ib_device *device)
20322032
rds_ibdev->max_wrs = dev_attr->max_qp_wr;
20332033
rds_ibdev->max_sge = min(dev_attr->max_sge, RDS_IB_MAX_SGE);
20342034

2035+
WARN_ON(rds_ibdev->max_sge < 2);
20352036
rds_ibdev->fmr_max_remaps = dev_attr->max_map_per_fmr?: 32;
20362037

20372038
rds_ibdev->max_1m_fmrs = dev_attr->max_mr ?

net/rds/ib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ struct rds_ib_connection {
222222
u16 i_frag_cache_sz;
223223
u8 i_frag_pages;
224224
u8 i_flags;
225+
u16 i_hca_sge;
225226

226227
/* Batched completions */
227228
unsigned int i_unsignaled_wrs;

net/rds/ib_cm.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,27 +164,30 @@ void rds_ib_init_frag(unsigned int version)
164164
}
165165

166166
/* Update the RDS IB frag size */
167-
static void rds_ib_set_frag_size(struct rds_connection *conn, u16 dp_frag)
167+
static u16 rds_ib_set_frag_size(struct rds_connection *conn, u16 dp_frag)
168168
{
169169
struct rds_ib_connection *ic = conn->c_transport_data;
170170
u16 current_frag = ic->i_frag_sz;
171171
u16 frag;
172172

173-
if (ib_init_frag_size != dp_frag) {
174-
frag = min_t(unsigned int, dp_frag, ib_init_frag_size);
173+
frag = min_t(unsigned int, ib_init_frag_size,
174+
PAGE_ALIGN((ic->i_hca_sge - 1) * PAGE_SIZE));
175+
176+
if (frag != dp_frag) {
177+
frag = min_t(unsigned int, dp_frag, frag);
175178
ic->i_frag_sz = rds_ib_get_frag(conn->c_version, frag);
176179
} else {
177-
ic->i_frag_sz = ib_init_frag_size;
180+
ic->i_frag_sz = frag;
178181
}
179182

180-
ic->i_frag_pages = ic->i_frag_sz / PAGE_SIZE;
181-
if (!ic->i_frag_pages)
182-
ic->i_frag_pages = 1;
183+
ic->i_frag_pages = ceil(ic->i_frag_sz, PAGE_SIZE);
183184

184185
pr_debug("RDS/IB: conn <%pI4, %pI4,%d>, Frags <init,ic,dp>: {%d,%d,%d}, updated {%d -> %d}\n",
185186
&conn->c_laddr, &conn->c_faddr, conn->c_tos,
186187
ib_init_frag_size / SZ_1K, ic->i_frag_sz / SZ_1K, dp_frag / SZ_1K,
187188
current_frag / SZ_1K, ic->i_frag_sz / SZ_1K);
189+
190+
return ic->i_frag_sz;
188191
}
189192

190193
/* Init per IC frag size */
@@ -762,6 +765,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
762765
attr.srq = rds_ibdev->srq->s_srq;
763766
}
764767

768+
ic->i_hca_sge = rds_ibdev->max_sge;
765769
/*
766770
* XXX this can fail if max_*_wr is too large? Are we supposed
767771
* to back off until we get a value that the hardware can support?
@@ -892,6 +896,7 @@ int rds_ib_cm_handle_connect(struct rdma_cm_id *cm_id,
892896
u32 version;
893897
int err = 1, destroy = 1;
894898
int acl_ret = 0;
899+
u16 frag;
895900

896901
/* Check whether the remote protocol version matches ours. */
897902
version = rds_ib_protocol_compatible(event);
@@ -925,7 +930,6 @@ int rds_ib_cm_handle_connect(struct rdma_cm_id *cm_id,
925930
}
926931

927932
rds_ib_set_protocol(conn, version);
928-
rds_ib_set_frag_size(conn, be16_to_cpu(dp->dp_frag_sz));
929933

930934
conn->c_acl_en = acl_ret;
931935
conn->c_acl_init = 1;
@@ -1017,11 +1021,12 @@ int rds_ib_cm_handle_connect(struct rdma_cm_id *cm_id,
10171021
rds_conn_drop(conn, DR_IB_PAS_SETUP_QP_FAIL);
10181022
goto out;
10191023
}
1024+
frag = rds_ib_set_frag_size(conn, be16_to_cpu(dp->dp_frag_sz));
10201025

10211026
rds_ib_cm_fill_conn_param(conn, &conn_param, &dp_rep, version,
10221027
event->param.conn.responder_resources,
10231028
event->param.conn.initiator_depth,
1024-
ib_init_frag_size);
1029+
frag);
10251030

10261031
/* rdma_accept() calls rdma_reject() internally if it fails */
10271032
err = rdma_accept(cm_id, &conn_param);
@@ -1071,6 +1076,7 @@ int rds_ib_cm_initiate_connect(struct rdma_cm_id *cm_id)
10711076
struct rds_ib_connection *ic = conn->c_transport_data;
10721077
struct rdma_conn_param conn_param;
10731078
struct rds_ib_connect_private dp;
1079+
u16 frag;
10741080
int ret;
10751081

10761082
ret = rds_ib_match_acl(ic->i_cm_id, conn->c_faddr);
@@ -1104,10 +1110,10 @@ int rds_ib_cm_initiate_connect(struct rdma_cm_id *cm_id)
11041110
rds_conn_drop(conn, DR_IB_ACT_SETUP_QP_FAIL);
11051111
goto out;
11061112
}
1107-
1113+
frag = rds_ib_set_frag_size(conn, ib_init_frag_size);
11081114
rds_ib_cm_fill_conn_param(conn, &conn_param, &dp,
1109-
conn->c_proposed_version, UINT_MAX, UINT_MAX,
1110-
ib_init_frag_size);
1115+
conn->c_proposed_version, UINT_MAX, UINT_MAX,
1116+
frag);
11111117
ret = rdma_connect(cm_id, &conn_param);
11121118
if (ret) {
11131119
pr_warn("RDS/IB: rdma_connect failed (%d)\n", ret);

0 commit comments

Comments
 (0)