Skip to content

Commit aee3c14

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
Pull rdma fixes from Jason Gunthorpe: "We had a fairly slow cycle on the rc side this time, here are the accumulated fixes, mostly in drivers: - irdma should not generate extra completions during flushing - Fix several memory leaks - Do not get confused in irdma's iwarp mode if IPv6 is present - Correct a link speed calculation in mlx5 - Increase the EQ/WQ limits on erdma as they are too small for big applications - Use the right math for erdma's inline mtt feature - Make erdma probing more robust to boot time ordering differences - Fix a KMSAN crash in CMA due to uninitialized qkey" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: RDMA/core: Fix GID entry ref leak when create_ah fails RDMA/cma: Allow UD qp_type to join multicast only RDMA/erdma: Defer probing if netdevice can not be found RDMA/erdma: Inline mtt entries into WQE if supported RDMA/erdma: Update default EQ depth to 4096 and max_send_wr to 8192 RDMA/erdma: Fix some typos IB/mlx5: Add support for 400G_8X lane speed RDMA/irdma: Add ipv4 check to irdma_find_listener() RDMA/irdma: Increase iWARP CM default rexmit count RDMA/irdma: Fix memory leak of PBLE objects RDMA/irdma: Do not generate SW completions for NOPs
2 parents 4414975 + aca3b0f commit aee3c14

12 files changed

Lines changed: 65 additions & 41 deletions

File tree

drivers/infiniband/core/cma.c

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -624,22 +624,11 @@ static inline unsigned short cma_family(struct rdma_id_private *id_priv)
624624
return id_priv->id.route.addr.src_addr.ss_family;
625625
}
626626

627-
static int cma_set_qkey(struct rdma_id_private *id_priv, u32 qkey)
627+
static int cma_set_default_qkey(struct rdma_id_private *id_priv)
628628
{
629629
struct ib_sa_mcmember_rec rec;
630630
int ret = 0;
631631

632-
if (id_priv->qkey) {
633-
if (qkey && id_priv->qkey != qkey)
634-
return -EINVAL;
635-
return 0;
636-
}
637-
638-
if (qkey) {
639-
id_priv->qkey = qkey;
640-
return 0;
641-
}
642-
643632
switch (id_priv->id.ps) {
644633
case RDMA_PS_UDP:
645634
case RDMA_PS_IB:
@@ -659,6 +648,16 @@ static int cma_set_qkey(struct rdma_id_private *id_priv, u32 qkey)
659648
return ret;
660649
}
661650

651+
static int cma_set_qkey(struct rdma_id_private *id_priv, u32 qkey)
652+
{
653+
if (!qkey ||
654+
(id_priv->qkey && (id_priv->qkey != qkey)))
655+
return -EINVAL;
656+
657+
id_priv->qkey = qkey;
658+
return 0;
659+
}
660+
662661
static void cma_translate_ib(struct sockaddr_ib *sib, struct rdma_dev_addr *dev_addr)
663662
{
664663
dev_addr->dev_type = ARPHRD_INFINIBAND;
@@ -1229,7 +1228,7 @@ static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv,
12291228
*qp_attr_mask = IB_QP_STATE | IB_QP_PKEY_INDEX | IB_QP_PORT;
12301229

12311230
if (id_priv->id.qp_type == IB_QPT_UD) {
1232-
ret = cma_set_qkey(id_priv, 0);
1231+
ret = cma_set_default_qkey(id_priv);
12331232
if (ret)
12341233
return ret;
12351234

@@ -4569,7 +4568,10 @@ static int cma_send_sidr_rep(struct rdma_id_private *id_priv,
45694568
memset(&rep, 0, sizeof rep);
45704569
rep.status = status;
45714570
if (status == IB_SIDR_SUCCESS) {
4572-
ret = cma_set_qkey(id_priv, qkey);
4571+
if (qkey)
4572+
ret = cma_set_qkey(id_priv, qkey);
4573+
else
4574+
ret = cma_set_default_qkey(id_priv);
45734575
if (ret)
45744576
return ret;
45754577
rep.qp_num = id_priv->qp_num;
@@ -4774,9 +4776,7 @@ static void cma_make_mc_event(int status, struct rdma_id_private *id_priv,
47744776
enum ib_gid_type gid_type;
47754777
struct net_device *ndev;
47764778

4777-
if (!status)
4778-
status = cma_set_qkey(id_priv, be32_to_cpu(multicast->rec.qkey));
4779-
else
4779+
if (status)
47804780
pr_debug_ratelimited("RDMA CM: MULTICAST_ERROR: failed to join multicast. status %d\n",
47814781
status);
47824782

@@ -4804,7 +4804,7 @@ static void cma_make_mc_event(int status, struct rdma_id_private *id_priv,
48044804
}
48054805

48064806
event->param.ud.qp_num = 0xFFFFFF;
4807-
event->param.ud.qkey = be32_to_cpu(multicast->rec.qkey);
4807+
event->param.ud.qkey = id_priv->qkey;
48084808

48094809
out:
48104810
if (ndev)
@@ -4823,8 +4823,11 @@ static int cma_ib_mc_handler(int status, struct ib_sa_multicast *multicast)
48234823
READ_ONCE(id_priv->state) == RDMA_CM_DESTROYING)
48244824
goto out;
48254825

4826-
cma_make_mc_event(status, id_priv, multicast, &event, mc);
4827-
ret = cma_cm_event_handler(id_priv, &event);
4826+
ret = cma_set_qkey(id_priv, be32_to_cpu(multicast->rec.qkey));
4827+
if (!ret) {
4828+
cma_make_mc_event(status, id_priv, multicast, &event, mc);
4829+
ret = cma_cm_event_handler(id_priv, &event);
4830+
}
48284831
rdma_destroy_ah_attr(&event.param.ud.ah_attr);
48294832
WARN_ON(ret);
48304833

@@ -4877,9 +4880,11 @@ static int cma_join_ib_multicast(struct rdma_id_private *id_priv,
48774880
if (ret)
48784881
return ret;
48794882

4880-
ret = cma_set_qkey(id_priv, 0);
4881-
if (ret)
4882-
return ret;
4883+
if (!id_priv->qkey) {
4884+
ret = cma_set_default_qkey(id_priv);
4885+
if (ret)
4886+
return ret;
4887+
}
48834888

48844889
cma_set_mgid(id_priv, (struct sockaddr *) &mc->addr, &rec.mgid);
48854890
rec.qkey = cpu_to_be32(id_priv->qkey);
@@ -4956,9 +4961,6 @@ static int cma_iboe_join_multicast(struct rdma_id_private *id_priv,
49564961
cma_iboe_set_mgid(addr, &ib.rec.mgid, gid_type);
49574962

49584963
ib.rec.pkey = cpu_to_be16(0xffff);
4959-
if (id_priv->id.ps == RDMA_PS_UDP)
4960-
ib.rec.qkey = cpu_to_be32(RDMA_UDP_QKEY);
4961-
49624964
if (dev_addr->bound_dev_if)
49634965
ndev = dev_get_by_index(dev_addr->net, dev_addr->bound_dev_if);
49644966
if (!ndev)
@@ -4984,6 +4986,9 @@ static int cma_iboe_join_multicast(struct rdma_id_private *id_priv,
49844986
if (err || !ib.rec.mtu)
49854987
return err ?: -EINVAL;
49864988

4989+
if (!id_priv->qkey)
4990+
cma_set_default_qkey(id_priv);
4991+
49874992
rdma_ip2gid((struct sockaddr *)&id_priv->id.route.addr.src_addr,
49884993
&ib.rec.port_gid);
49894994
INIT_WORK(&mc->iboe_join.work, cma_iboe_join_work_handler);
@@ -5009,6 +5014,9 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,
50095014
READ_ONCE(id_priv->state) != RDMA_CM_ADDR_RESOLVED))
50105015
return -EINVAL;
50115016

5017+
if (id_priv->id.qp_type != IB_QPT_UD)
5018+
return -EINVAL;
5019+
50125020
mc = kzalloc(sizeof(*mc), GFP_KERNEL);
50135021
if (!mc)
50145022
return -ENOMEM;

drivers/infiniband/core/verbs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,8 @@ static struct ib_ah *_rdma_create_ah(struct ib_pd *pd,
532532
else
533533
ret = device->ops.create_ah(ah, &init_attr, NULL);
534534
if (ret) {
535+
if (ah->sgid_attr)
536+
rdma_put_gid_attr(ah->sgid_attr);
535537
kfree(ah);
536538
return ERR_PTR(ret);
537539
}

drivers/infiniband/hw/erdma/erdma_cq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static const enum ib_wc_opcode wc_mapping_table[ERDMA_NUM_OPCODES] = {
6565
[ERDMA_OP_LOCAL_INV] = IB_WC_LOCAL_INV,
6666
[ERDMA_OP_READ_WITH_INV] = IB_WC_RDMA_READ,
6767
[ERDMA_OP_ATOMIC_CAS] = IB_WC_COMP_SWAP,
68-
[ERDMA_OP_ATOMIC_FAD] = IB_WC_FETCH_ADD,
68+
[ERDMA_OP_ATOMIC_FAA] = IB_WC_FETCH_ADD,
6969
};
7070

7171
static const struct {

drivers/infiniband/hw/erdma/erdma_hw.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ struct erdma_reg_mr_sqe {
441441
};
442442

443443
/* EQ related. */
444-
#define ERDMA_DEFAULT_EQ_DEPTH 256
444+
#define ERDMA_DEFAULT_EQ_DEPTH 4096
445445

446446
/* ceqe */
447447
#define ERDMA_CEQE_HDR_DB_MASK BIT_ULL(63)
@@ -491,7 +491,7 @@ enum erdma_opcode {
491491
ERDMA_OP_LOCAL_INV = 15,
492492
ERDMA_OP_READ_WITH_INV = 16,
493493
ERDMA_OP_ATOMIC_CAS = 17,
494-
ERDMA_OP_ATOMIC_FAD = 18,
494+
ERDMA_OP_ATOMIC_FAA = 18,
495495
ERDMA_NUM_OPCODES = 19,
496496
ERDMA_OP_INVALID = ERDMA_NUM_OPCODES + 1
497497
};

drivers/infiniband/hw/erdma/erdma_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static int erdma_netdev_event(struct notifier_block *nb, unsigned long event,
5656
static int erdma_enum_and_get_netdev(struct erdma_dev *dev)
5757
{
5858
struct net_device *netdev;
59-
int ret = -ENODEV;
59+
int ret = -EPROBE_DEFER;
6060

6161
/* Already binded to a net_device, so we skip. */
6262
if (dev->netdev)

drivers/infiniband/hw/erdma/erdma_qp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ static int erdma_push_one_sqe(struct erdma_qp *qp, u16 *pi,
405405
FIELD_PREP(ERDMA_SQE_MR_MTT_CNT_MASK,
406406
mr->mem.mtt_nents);
407407

408-
if (mr->mem.mtt_nents < ERDMA_MAX_INLINE_MTT_ENTRIES) {
408+
if (mr->mem.mtt_nents <= ERDMA_MAX_INLINE_MTT_ENTRIES) {
409409
attrs |= FIELD_PREP(ERDMA_SQE_MR_MTT_TYPE_MASK, 0);
410410
/* Copy SGLs to SQE content to accelerate */
411411
memcpy(get_queue_entry(qp->kern_qp.sq_buf, idx + 1,
@@ -439,7 +439,7 @@ static int erdma_push_one_sqe(struct erdma_qp *qp, u16 *pi,
439439
cpu_to_le64(atomic_wr(send_wr)->compare_add);
440440
} else {
441441
wqe_hdr |= FIELD_PREP(ERDMA_SQE_HDR_OPCODE_MASK,
442-
ERDMA_OP_ATOMIC_FAD);
442+
ERDMA_OP_ATOMIC_FAA);
443443
atomic_sqe->fetchadd_swap_data =
444444
cpu_to_le64(atomic_wr(send_wr)->compare_add);
445445
}

drivers/infiniband/hw/erdma/erdma_verbs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
/* RDMA Capability. */
1313
#define ERDMA_MAX_PD (128 * 1024)
14-
#define ERDMA_MAX_SEND_WR 4096
14+
#define ERDMA_MAX_SEND_WR 8192
1515
#define ERDMA_MAX_ORD 128
1616
#define ERDMA_MAX_IRD 128
1717
#define ERDMA_MAX_SGE_RD 1

drivers/infiniband/hw/irdma/cm.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,13 +1458,15 @@ static int irdma_send_fin(struct irdma_cm_node *cm_node)
14581458
* irdma_find_listener - find a cm node listening on this addr-port pair
14591459
* @cm_core: cm's core
14601460
* @dst_addr: listener ip addr
1461+
* @ipv4: flag indicating IPv4 when true
14611462
* @dst_port: listener tcp port num
14621463
* @vlan_id: virtual LAN ID
14631464
* @listener_state: state to match with listen node's
14641465
*/
14651466
static struct irdma_cm_listener *
1466-
irdma_find_listener(struct irdma_cm_core *cm_core, u32 *dst_addr, u16 dst_port,
1467-
u16 vlan_id, enum irdma_cm_listener_state listener_state)
1467+
irdma_find_listener(struct irdma_cm_core *cm_core, u32 *dst_addr, bool ipv4,
1468+
u16 dst_port, u16 vlan_id,
1469+
enum irdma_cm_listener_state listener_state)
14681470
{
14691471
struct irdma_cm_listener *listen_node;
14701472
static const u32 ip_zero[4] = { 0, 0, 0, 0 };
@@ -1477,7 +1479,7 @@ irdma_find_listener(struct irdma_cm_core *cm_core, u32 *dst_addr, u16 dst_port,
14771479
list_for_each_entry (listen_node, &cm_core->listen_list, list) {
14781480
memcpy(listen_addr, listen_node->loc_addr, sizeof(listen_addr));
14791481
listen_port = listen_node->loc_port;
1480-
if (listen_port != dst_port ||
1482+
if (listen_node->ipv4 != ipv4 || listen_port != dst_port ||
14811483
!(listener_state & listen_node->listener_state))
14821484
continue;
14831485
/* compare node pair, return node handle if a match */
@@ -2902,9 +2904,10 @@ irdma_make_listen_node(struct irdma_cm_core *cm_core,
29022904
unsigned long flags;
29032905

29042906
/* cannot have multiple matching listeners */
2905-
listener = irdma_find_listener(cm_core, cm_info->loc_addr,
2906-
cm_info->loc_port, cm_info->vlan_id,
2907-
IRDMA_CM_LISTENER_EITHER_STATE);
2907+
listener =
2908+
irdma_find_listener(cm_core, cm_info->loc_addr, cm_info->ipv4,
2909+
cm_info->loc_port, cm_info->vlan_id,
2910+
IRDMA_CM_LISTENER_EITHER_STATE);
29082911
if (listener &&
29092912
listener->listener_state == IRDMA_CM_LISTENER_ACTIVE_STATE) {
29102913
refcount_dec(&listener->refcnt);
@@ -3153,6 +3156,7 @@ void irdma_receive_ilq(struct irdma_sc_vsi *vsi, struct irdma_puda_buf *rbuf)
31533156

31543157
listener = irdma_find_listener(cm_core,
31553158
cm_info.loc_addr,
3159+
cm_info.ipv4,
31563160
cm_info.loc_port,
31573161
cm_info.vlan_id,
31583162
IRDMA_CM_LISTENER_ACTIVE_STATE);

drivers/infiniband/hw/irdma/cm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#define TCP_OPTIONS_PADDING 3
4242

4343
#define IRDMA_DEFAULT_RETRYS 64
44-
#define IRDMA_DEFAULT_RETRANS 8
44+
#define IRDMA_DEFAULT_RETRANS 32
4545
#define IRDMA_DEFAULT_TTL 0x40
4646
#define IRDMA_DEFAULT_RTT_VAR 6
4747
#define IRDMA_DEFAULT_SS_THRESH 0x3fffffff

drivers/infiniband/hw/irdma/hw.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ static enum irdma_hmc_rsrc_type iw_hmc_obj_types[] = {
4141
IRDMA_HMC_IW_XFFL,
4242
IRDMA_HMC_IW_Q1,
4343
IRDMA_HMC_IW_Q1FL,
44+
IRDMA_HMC_IW_PBLE,
4445
IRDMA_HMC_IW_TIMER,
4546
IRDMA_HMC_IW_FSIMC,
4647
IRDMA_HMC_IW_FSIAV,
@@ -827,6 +828,8 @@ static int irdma_create_hmc_objs(struct irdma_pci_f *rf, bool privileged,
827828
info.entry_type = rf->sd_type;
828829

829830
for (i = 0; i < IW_HMC_OBJ_TYPE_NUM; i++) {
831+
if (iw_hmc_obj_types[i] == IRDMA_HMC_IW_PBLE)
832+
continue;
830833
if (dev->hmc_info->hmc_obj[iw_hmc_obj_types[i]].cnt) {
831834
info.rsrc_type = iw_hmc_obj_types[i];
832835
info.count = dev->hmc_info->hmc_obj[info.rsrc_type].cnt;

0 commit comments

Comments
 (0)