Skip to content

Commit e0e6d06

Browse files
Zhu Yanjundavem330
authored andcommitted
net: rds: add service level support in rds-info
>From IB specific 7.6.5 SERVICE LEVEL, Service Level (SL) is used to identify different flows within an IBA subnet. It is carried in the local route header of the packet. Before this commit, run "rds-info -I". The outputs are as below: " RDS IB Connections: LocalAddr RemoteAddr Tos SL LocalDev RemoteDev 192.2.95.3 192.2.95.1 2 0 fe80::21:28:1a:39 fe80::21:28:10:b9 192.2.95.3 192.2.95.1 1 0 fe80::21:28:1a:39 fe80::21:28:10:b9 192.2.95.3 192.2.95.1 0 0 fe80::21:28:1a:39 fe80::21:28:10:b9 " After this commit, the output is as below: " RDS IB Connections: LocalAddr RemoteAddr Tos SL LocalDev RemoteDev 192.2.95.3 192.2.95.1 2 2 fe80::21:28:1a:39 fe80::21:28:10:b9 192.2.95.3 192.2.95.1 1 1 fe80::21:28:1a:39 fe80::21:28:10:b9 192.2.95.3 192.2.95.1 0 0 fe80::21:28:1a:39 fe80::21:28:10:b9 " The commit fe3475a ("net: rds: add per rds connection cache statistics") adds cache_allocs in struct rds_info_rdma_connection as below: struct rds_info_rdma_connection { ... __u32 rdma_mr_max; __u32 rdma_mr_size; __u8 tos; __u32 cache_allocs; }; The peer struct in rds-tools of struct rds_info_rdma_connection is as below: struct rds_info_rdma_connection { ... uint32_t rdma_mr_max; uint32_t rdma_mr_size; uint8_t tos; uint8_t sl; uint32_t cache_allocs; }; The difference between userspace and kernel is the member variable sl. In the kernel struct, the member variable sl is missing. This will introduce risks. So it is necessary to use this commit to avoid this risk. Fixes: fe3475a ("net: rds: add per rds connection cache statistics") CC: Joe Jin <[email protected]> CC: JUNXIAO_BI <[email protected]> Suggested-by: Gerd Rausch <[email protected]> Signed-off-by: Zhu Yanjun <[email protected]> Acked-by: Santosh Shilimkar <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e93fb3e commit e0e6d06

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed

include/uapi/linux/rds.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ struct rds_info_rdma_connection {
250250
__u32 rdma_mr_max;
251251
__u32 rdma_mr_size;
252252
__u8 tos;
253+
__u8 sl;
253254
__u32 cache_allocs;
254255
};
255256

@@ -265,6 +266,7 @@ struct rds6_info_rdma_connection {
265266
__u32 rdma_mr_max;
266267
__u32 rdma_mr_size;
267268
__u8 tos;
269+
__u8 sl;
268270
__u32 cache_allocs;
269271
};
270272

net/rds/ib.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ static int rds_ib_conn_info_visitor(struct rds_connection *conn,
291291
void *buffer)
292292
{
293293
struct rds_info_rdma_connection *iinfo = buffer;
294-
struct rds_ib_connection *ic;
294+
struct rds_ib_connection *ic = conn->c_transport_data;
295295

296296
/* We will only ever look at IB transports */
297297
if (conn->c_trans != &rds_ib_transport)
@@ -301,15 +301,16 @@ static int rds_ib_conn_info_visitor(struct rds_connection *conn,
301301

302302
iinfo->src_addr = conn->c_laddr.s6_addr32[3];
303303
iinfo->dst_addr = conn->c_faddr.s6_addr32[3];
304-
iinfo->tos = conn->c_tos;
304+
if (ic) {
305+
iinfo->tos = conn->c_tos;
306+
iinfo->sl = ic->i_sl;
307+
}
305308

306309
memset(&iinfo->src_gid, 0, sizeof(iinfo->src_gid));
307310
memset(&iinfo->dst_gid, 0, sizeof(iinfo->dst_gid));
308311
if (rds_conn_state(conn) == RDS_CONN_UP) {
309312
struct rds_ib_device *rds_ibdev;
310313

311-
ic = conn->c_transport_data;
312-
313314
rdma_read_gids(ic->i_cm_id, (union ib_gid *)&iinfo->src_gid,
314315
(union ib_gid *)&iinfo->dst_gid);
315316

@@ -329,22 +330,25 @@ static int rds6_ib_conn_info_visitor(struct rds_connection *conn,
329330
void *buffer)
330331
{
331332
struct rds6_info_rdma_connection *iinfo6 = buffer;
332-
struct rds_ib_connection *ic;
333+
struct rds_ib_connection *ic = conn->c_transport_data;
333334

334335
/* We will only ever look at IB transports */
335336
if (conn->c_trans != &rds_ib_transport)
336337
return 0;
337338

338339
iinfo6->src_addr = conn->c_laddr;
339340
iinfo6->dst_addr = conn->c_faddr;
341+
if (ic) {
342+
iinfo6->tos = conn->c_tos;
343+
iinfo6->sl = ic->i_sl;
344+
}
340345

341346
memset(&iinfo6->src_gid, 0, sizeof(iinfo6->src_gid));
342347
memset(&iinfo6->dst_gid, 0, sizeof(iinfo6->dst_gid));
343348

344349
if (rds_conn_state(conn) == RDS_CONN_UP) {
345350
struct rds_ib_device *rds_ibdev;
346351

347-
ic = conn->c_transport_data;
348352
rdma_read_gids(ic->i_cm_id, (union ib_gid *)&iinfo6->src_gid,
349353
(union ib_gid *)&iinfo6->dst_gid);
350354
rds_ibdev = ic->rds_ibdev;

net/rds/ib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ struct rds_ib_connection {
220220
/* Send/Recv vectors */
221221
int i_scq_vector;
222222
int i_rcq_vector;
223+
u8 i_sl;
223224
};
224225

225226
/* This assumes that atomic_t is at least 32 bits */

net/rds/ib_cm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ void rds_ib_cm_connect_complete(struct rds_connection *conn, struct rdma_cm_even
152152
RDS_PROTOCOL_MINOR(conn->c_version),
153153
ic->i_flowctl ? ", flow control" : "");
154154

155+
/* receive sl from the peer */
156+
ic->i_sl = ic->i_cm_id->route.path_rec->sl;
157+
155158
atomic_set(&ic->i_cq_quiesce, 0);
156159

157160
/* Init rings and fill recv. this needs to wait until protocol

net/rds/rdma_transport.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ static struct rdma_cm_id *rds_rdma_listen_id;
4343
static struct rdma_cm_id *rds6_rdma_listen_id;
4444
#endif
4545

46+
/* Per IB specification 7.7.3, service level is a 4-bit field. */
47+
#define TOS_TO_SL(tos) ((tos) & 0xF)
48+
4649
static int rds_rdma_cm_event_handler_cmn(struct rdma_cm_id *cm_id,
4750
struct rdma_cm_event *event,
4851
bool isv6)
@@ -97,10 +100,13 @@ static int rds_rdma_cm_event_handler_cmn(struct rdma_cm_id *cm_id,
97100
struct rds_ib_connection *ibic;
98101

99102
ibic = conn->c_transport_data;
100-
if (ibic && ibic->i_cm_id == cm_id)
103+
if (ibic && ibic->i_cm_id == cm_id) {
104+
cm_id->route.path_rec[0].sl =
105+
TOS_TO_SL(conn->c_tos);
101106
ret = trans->cm_initiate_connect(cm_id, isv6);
102-
else
107+
} else {
103108
rds_conn_drop(conn);
109+
}
104110
}
105111
break;
106112

0 commit comments

Comments
 (0)