Skip to content

Commit 1103579

Browse files
mrgolinrleon
authored andcommitted
RDMA/efa: Report link speed according to device attributes
Set port link speed and width based on max bandwidth acquired from the device instead of using constant 100 Gbps. Use a default value in case the device didn't set the field. Reviewed-by: Daniel Kranzdorf <[email protected]> Reviewed-by: Firas Jahjah <[email protected]> Signed-off-by: Michael Margolin <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 808ca6d commit 1103579

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

drivers/infiniband/hw/efa/efa_admin_cmds_defs.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,15 @@ struct efa_admin_feature_device_attr_desc {
718718

719719
/* Unique global ID for an EFA device */
720720
u64 guid;
721+
722+
/* The device maximum link speed in Gbit/sec */
723+
u16 max_link_speed_gbps;
724+
725+
/* MBZ */
726+
u16 reserved0;
727+
728+
/* MBZ */
729+
u32 reserved1;
721730
};
722731

723732
struct efa_admin_feature_queue_attr_desc {

drivers/infiniband/hw/efa/efa_com_cmd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ int efa_com_get_device_attr(struct efa_com_dev *edev,
467467
result->max_rdma_size = resp.u.device_attr.max_rdma_size;
468468
result->device_caps = resp.u.device_attr.device_caps;
469469
result->guid = resp.u.device_attr.guid;
470+
result->max_link_speed_gbps = resp.u.device_attr.max_link_speed_gbps;
470471

471472
if (result->admin_api_version < 1) {
472473
ibdev_err_ratelimited(

drivers/infiniband/hw/efa/efa_com_cmd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ struct efa_com_get_device_attr_result {
142142
u16 max_wr_rdma_sge;
143143
u16 max_tx_batch;
144144
u16 min_sq_depth;
145+
u16 max_link_speed_gbps;
145146
u8 db_bar;
146147
};
147148

drivers/infiniband/hw/efa/efa_verbs.c

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ static const struct rdma_stat_desc efa_port_stats_descs[] = {
8585
EFA_DEFINE_PORT_STATS(EFA_STATS_STR)
8686
};
8787

88+
#define EFA_DEFAULT_LINK_SPEED_GBPS 100
89+
8890
#define EFA_CHUNK_PAYLOAD_SHIFT 12
8991
#define EFA_CHUNK_PAYLOAD_SIZE BIT(EFA_CHUNK_PAYLOAD_SHIFT)
9092
#define EFA_CHUNK_PAYLOAD_PTR_SIZE 8
@@ -277,19 +279,58 @@ int efa_query_device(struct ib_device *ibdev,
277279
return 0;
278280
}
279281

282+
static void efa_link_gbps_to_speed_and_width(u16 gbps,
283+
enum ib_port_speed *speed,
284+
enum ib_port_width *width)
285+
{
286+
if (gbps >= 400) {
287+
*width = IB_WIDTH_8X;
288+
*speed = IB_SPEED_HDR;
289+
} else if (gbps >= 200) {
290+
*width = IB_WIDTH_4X;
291+
*speed = IB_SPEED_HDR;
292+
} else if (gbps >= 120) {
293+
*width = IB_WIDTH_12X;
294+
*speed = IB_SPEED_FDR10;
295+
} else if (gbps >= 100) {
296+
*width = IB_WIDTH_4X;
297+
*speed = IB_SPEED_EDR;
298+
} else if (gbps >= 60) {
299+
*width = IB_WIDTH_12X;
300+
*speed = IB_SPEED_DDR;
301+
} else if (gbps >= 50) {
302+
*width = IB_WIDTH_1X;
303+
*speed = IB_SPEED_HDR;
304+
} else if (gbps >= 40) {
305+
*width = IB_WIDTH_4X;
306+
*speed = IB_SPEED_FDR10;
307+
} else if (gbps >= 30) {
308+
*width = IB_WIDTH_12X;
309+
*speed = IB_SPEED_SDR;
310+
} else {
311+
*width = IB_WIDTH_1X;
312+
*speed = IB_SPEED_EDR;
313+
}
314+
}
315+
280316
int efa_query_port(struct ib_device *ibdev, u32 port,
281317
struct ib_port_attr *props)
282318
{
283319
struct efa_dev *dev = to_edev(ibdev);
320+
enum ib_port_speed link_speed;
321+
enum ib_port_width link_width;
322+
u16 link_gbps;
284323

285324
props->lmc = 1;
286325

287326
props->state = IB_PORT_ACTIVE;
288327
props->phys_state = IB_PORT_PHYS_STATE_LINK_UP;
289328
props->gid_tbl_len = 1;
290329
props->pkey_tbl_len = 1;
291-
props->active_speed = IB_SPEED_EDR;
292-
props->active_width = IB_WIDTH_4X;
330+
link_gbps = dev->dev_attr.max_link_speed_gbps ?: EFA_DEFAULT_LINK_SPEED_GBPS;
331+
efa_link_gbps_to_speed_and_width(link_gbps, &link_speed, &link_width);
332+
props->active_speed = link_speed;
333+
props->active_width = link_width;
293334
props->max_mtu = ib_mtu_int_to_enum(dev->dev_attr.mtu);
294335
props->active_mtu = ib_mtu_int_to_enum(dev->dev_attr.mtu);
295336
props->max_msg_sz = dev->dev_attr.mtu;

0 commit comments

Comments
 (0)