Skip to content

Commit 376ceb3

Browse files
Aharon Landaujgunthorpe
authored andcommitted
RDMA: Fix link active_speed size
According to the IB spec active_speed size should be u16 and not u8 as before. Changing it to allow further extensions in offered speeds. Link: https://lore.kernel.org/r/20200917090223.1018224-4-leon@kernel.org Signed-off-by: Aharon Landau <aharonl@mellanox.com> Reviewed-by: Michael Guralnik <michaelgur@nvidia.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent e27014b commit 376ceb3

10 files changed

Lines changed: 17 additions & 19 deletions

File tree

‎drivers/infiniband/core/uverbs_std_types_device.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ void copy_port_attr_to_resp(struct ib_port_attr *attr,
165165
resp->subnet_timeout = attr->subnet_timeout;
166166
resp->init_type_reply = attr->init_type_reply;
167167
resp->active_width = attr->active_width;
168-
resp->active_speed = attr->active_speed;
168+
/* This ABI needs to be extended to provide any speed more than IB_SPEED_NDR */
169+
resp->active_speed = min_t(u16, attr->active_speed, IB_SPEED_NDR);
169170
resp->phys_state = attr->phys_state;
170171
resp->link_layer = rdma_port_get_link_layer(ib_dev, port_num);
171172
}

‎drivers/infiniband/core/verbs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,7 @@ int ib_modify_qp_with_udata(struct ib_qp *ib_qp, struct ib_qp_attr *attr,
17811781
}
17821782
EXPORT_SYMBOL(ib_modify_qp_with_udata);
17831783

1784-
int ib_get_eth_speed(struct ib_device *dev, u8 port_num, u8 *speed, u8 *width)
1784+
int ib_get_eth_speed(struct ib_device *dev, u8 port_num, u16 *speed, u8 *width)
17851785
{
17861786
int rc;
17871787
u32 netdev_speed;

‎drivers/infiniband/hw/bnxt_re/bnxt_re.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ struct bnxt_re_dev {
150150

151151
struct delayed_work worker;
152152
u8 cur_prio_map;
153-
u8 active_speed;
153+
u16 active_speed;
154154
u8 active_width;
155155

156156
/* FP Notification Queue (CQ & SRQ) */

‎drivers/infiniband/hw/hfi1/verbs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,7 @@ static int query_port(struct rvt_dev_info *rdi, u8 port_num,
14241424
props->gid_tbl_len = HFI1_GUIDS_PER_PORT;
14251425
props->active_width = (u8)opa_width_to_ib(ppd->link_width_active);
14261426
/* see rate_show() in ib core/sysfs.c */
1427-
props->active_speed = (u8)opa_speed_to_ib(ppd->link_speed_active);
1427+
props->active_speed = opa_speed_to_ib(ppd->link_speed_active);
14281428
props->max_vl_num = ppd->vls_supported;
14291429

14301430
/* Once we are a "first class" citizen and have added the OPA MTUs to

‎drivers/infiniband/hw/mlx5/main.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ static int mlx5_query_port_roce(struct ib_device *device, u8 port_num,
457457
bool put_mdev = true;
458458
u16 qkey_viol_cntr;
459459
u32 eth_prot_oper;
460-
u16 active_speed;
461460
u8 mdev_port_num;
462461
bool ext;
463462
int err;
@@ -491,12 +490,9 @@ static int mlx5_query_port_roce(struct ib_device *device, u8 port_num,
491490
props->active_width = IB_WIDTH_4X;
492491
props->active_speed = IB_SPEED_QDR;
493492

494-
translate_eth_proto_oper(eth_prot_oper, &active_speed,
493+
translate_eth_proto_oper(eth_prot_oper, &props->active_speed,
495494
&props->active_width, ext);
496495

497-
WARN_ON_ONCE(active_speed & ~0xFF);
498-
props->active_speed = (u8)active_speed;
499-
500496
props->port_cap_flags |= IB_PORT_CM_SUP;
501497
props->ip_gids = true;
502498

@@ -1307,7 +1303,7 @@ static int mlx5_query_hca_port(struct ib_device *ibdev, u8 port,
13071303
props->port_cap_flags2 = rep->cap_mask2;
13081304

13091305
err = mlx5_query_ib_port_oper(mdev, &ib_link_width_oper,
1310-
(u16 *)&props->active_speed, port);
1306+
&props->active_speed, port);
13111307
if (err)
13121308
goto out;
13131309

‎drivers/infiniband/hw/ocrdma/ocrdma_verbs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ int ocrdma_query_device(struct ib_device *ibdev, struct ib_device_attr *attr,
112112
}
113113

114114
static inline void get_link_speed_and_width(struct ocrdma_dev *dev,
115-
u8 *ib_speed, u8 *ib_width)
115+
u16 *ib_speed, u8 *ib_width)
116116
{
117117
int status;
118118
u8 speed;

‎drivers/infiniband/hw/qedr/verbs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ int qedr_query_device(struct ib_device *ibdev,
163163
return 0;
164164
}
165165

166-
static inline void get_link_speed_and_width(int speed, u8 *ib_speed,
166+
static inline void get_link_speed_and_width(int speed, u16 *ib_speed,
167167
u8 *ib_width)
168168
{
169169
switch (speed) {

‎drivers/infiniband/hw/qib/qib.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,11 +619,11 @@ struct qib_pportdata {
619619
/* LID mask control */
620620
u8 lmc;
621621
u8 link_width_supported;
622-
u8 link_speed_supported;
622+
u16 link_speed_supported;
623623
u8 link_width_enabled;
624-
u8 link_speed_enabled;
624+
u16 link_speed_enabled;
625625
u8 link_width_active;
626-
u8 link_speed_active;
626+
u16 link_speed_active;
627627
u8 vls_supported;
628628
u8 vls_operational;
629629
/* Rx Polarity inversion (compensate for ~tx on partner) */

‎drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ struct pvrdma_port_attr {
176176
u8 subnet_timeout;
177177
u8 init_type_reply;
178178
u8 active_width;
179-
u8 active_speed;
179+
u16 active_speed;
180180
u8 phys_state;
181181
u8 reserved[2];
182182
};

‎include/rdma/ib_verbs.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,8 @@ enum ib_port_speed {
535535
IB_SPEED_FDR10 = 8,
536536
IB_SPEED_FDR = 16,
537537
IB_SPEED_EDR = 32,
538-
IB_SPEED_HDR = 64
538+
IB_SPEED_HDR = 64,
539+
IB_SPEED_NDR = 128,
539540
};
540541

541542
/**
@@ -669,7 +670,7 @@ struct ib_port_attr {
669670
u8 subnet_timeout;
670671
u8 init_type_reply;
671672
u8 active_width;
672-
u8 active_speed;
673+
u16 active_speed;
673674
u8 phys_state;
674675
u16 port_cap_flags2;
675676
};
@@ -4410,7 +4411,7 @@ void ib_drain_rq(struct ib_qp *qp);
44104411
void ib_drain_sq(struct ib_qp *qp);
44114412
void ib_drain_qp(struct ib_qp *qp);
44124413

4413-
int ib_get_eth_speed(struct ib_device *dev, u8 port_num, u8 *speed, u8 *width);
4414+
int ib_get_eth_speed(struct ib_device *dev, u8 port_num, u16 *speed, u8 *width);
44144415

44154416
static inline u8 *rdma_ah_retrieve_dmac(struct rdma_ah_attr *attr)
44164417
{

0 commit comments

Comments
 (0)