Skip to content

Commit 159b378

Browse files
Wei Lin GuaySomasundaram Krishnasamy
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: 27339270 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]> (cherry picked from commit 045f0597f9ab6aa2750e0ae2c70ad452ced1a0f1) (cherry picked from commit d9ee8414454c745e63f3148d2bfdb7c38f5811be) Signed-off-by: Somasundaram Krishnasamy <[email protected]>
1 parent fb44d8b commit 159b378

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
@@ -226,6 +226,7 @@ struct rds_ib_connection {
226226
u16 i_frag_cache_sz;
227227
u8 i_frag_pages;
228228
u8 i_flags;
229+
u16 i_hca_sge;
229230

230231
/* Batched completions */
231232
unsigned int i_unsignaled_wrs;

net/rds/ib_cm.c

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

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

175-
if (ib_init_frag_size != dp_frag) {
176-
frag = min_t(unsigned int, dp_frag, ib_init_frag_size);
175+
frag = min_t(unsigned int, ib_init_frag_size,
176+
PAGE_ALIGN((ic->i_hca_sge - 1) * PAGE_SIZE));
177+
178+
if (frag != dp_frag) {
179+
frag = min_t(unsigned int, dp_frag, frag);
177180
ic->i_frag_sz = rds_ib_get_frag(conn->c_version, frag);
178181
} else {
179-
ic->i_frag_sz = ib_init_frag_size;
182+
ic->i_frag_sz = frag;
180183
}
181184

182-
ic->i_frag_pages = ic->i_frag_sz / PAGE_SIZE;
183-
if (!ic->i_frag_pages)
184-
ic->i_frag_pages = 1;
185+
ic->i_frag_pages = ceil(ic->i_frag_sz, PAGE_SIZE);
185186

186187
pr_debug("RDS/IB: conn <%pI4, %pI4,%d>, Frags <init,ic,dp>: {%d,%d,%d}, updated {%d -> %d}\n",
187188
&conn->c_laddr, &conn->c_faddr, conn->c_tos,
188189
ib_init_frag_size / SZ_1K, ic->i_frag_sz / SZ_1K, dp_frag / SZ_1K,
189190
current_frag / SZ_1K, ic->i_frag_sz / SZ_1K);
191+
192+
return ic->i_frag_sz;
190193
}
191194

192195
/* Init per IC frag size */
@@ -775,6 +778,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
775778
qp_attr.srq = rds_ibdev->srq->s_srq;
776779
}
777780

781+
ic->i_hca_sge = rds_ibdev->max_sge;
778782
/*
779783
* XXX this can fail if max_*_wr is too large? Are we supposed
780784
* to back off until we get a value that the hardware can support?
@@ -905,6 +909,7 @@ int rds_ib_cm_handle_connect(struct rdma_cm_id *cm_id,
905909
u32 version;
906910
int err = 1, destroy = 1;
907911
int acl_ret = 0;
912+
u16 frag;
908913

909914
/* Check whether the remote protocol version matches ours. */
910915
version = rds_ib_protocol_compatible(event);
@@ -946,7 +951,6 @@ int rds_ib_cm_handle_connect(struct rdma_cm_id *cm_id,
946951
}
947952

948953
rds_ib_set_protocol(conn, version);
949-
rds_ib_set_frag_size(conn, be16_to_cpu(dp->dp_frag_sz));
950954

951955
conn->c_acl_en = acl_ret;
952956
conn->c_acl_init = 1;
@@ -1038,11 +1042,12 @@ int rds_ib_cm_handle_connect(struct rdma_cm_id *cm_id,
10381042
rds_conn_drop(conn, DR_IB_PAS_SETUP_QP_FAIL);
10391043
goto out;
10401044
}
1045+
frag = rds_ib_set_frag_size(conn, be16_to_cpu(dp->dp_frag_sz));
10411046

10421047
rds_ib_cm_fill_conn_param(conn, &conn_param, &dp_rep, version,
10431048
event->param.conn.responder_resources,
10441049
event->param.conn.initiator_depth,
1045-
ib_init_frag_size);
1050+
frag);
10461051

10471052
/* rdma_accept() calls rdma_reject() internally if it fails */
10481053
err = rdma_accept(cm_id, &conn_param);
@@ -1092,6 +1097,7 @@ int rds_ib_cm_initiate_connect(struct rdma_cm_id *cm_id)
10921097
struct rds_ib_connection *ic = conn->c_transport_data;
10931098
struct rdma_conn_param conn_param;
10941099
struct rds_ib_connect_private dp;
1100+
u16 frag;
10951101
int ret;
10961102

10971103
#ifdef CONFIG_RDS_ACL
@@ -1133,10 +1139,10 @@ int rds_ib_cm_initiate_connect(struct rdma_cm_id *cm_id)
11331139
rds_conn_drop(conn, DR_IB_ACT_SETUP_QP_FAIL);
11341140
goto out;
11351141
}
1136-
1142+
frag = rds_ib_set_frag_size(conn, ib_init_frag_size);
11371143
rds_ib_cm_fill_conn_param(conn, &conn_param, &dp,
1138-
conn->c_proposed_version, UINT_MAX, UINT_MAX,
1139-
ib_init_frag_size);
1144+
conn->c_proposed_version, UINT_MAX, UINT_MAX,
1145+
frag);
11401146
ret = rdma_connect(cm_id, &conn_param);
11411147
if (ret) {
11421148
pr_warn("RDS/IB: rdma_connect failed (%d)\n", ret);

0 commit comments

Comments
 (0)