* [PATCH for-rc 0/2] RDMA/irdma: Bug fixes
@ 2023-05-22 15:56 Shiraz Saleem
2023-05-22 15:56 ` [PATCH for-next] RDMA/irdma: Implement egress VLAN priority Shiraz Saleem
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Shiraz Saleem @ 2023-05-22 15:56 UTC (permalink / raw)
To: jgg, leon; +Cc: linux-rdma, Shiraz Saleem
This series adds a couple of minor driver fixes for irdma.
Mustafa Ismail (2):
RDMA/irdma: Prevent QP use after free
RDMA/irdma: Fix Local Invalidate fencing
drivers/infiniband/hw/irdma/verbs.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH for-next] RDMA/irdma: Implement egress VLAN priority
2023-05-22 15:56 [PATCH for-rc 0/2] RDMA/irdma: Bug fixes Shiraz Saleem
@ 2023-05-22 15:56 ` Shiraz Saleem
2023-06-01 15:56 ` Jason Gunthorpe
2023-05-22 15:56 ` [PATCH for-rc 1/2] RDMA/irdma: Prevent QP use after free Shiraz Saleem
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Shiraz Saleem @ 2023-05-22 15:56 UTC (permalink / raw)
To: jgg, leon; +Cc: linux-rdma, Mustafa Ismail, Shiraz Saleem
From: Mustafa Ismail <mustafa.ismail@intel.com>
When a VLAN interface is in use, get and use the VLAN
egress mapping.
Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
---
drivers/infiniband/hw/irdma/cm.c | 50 +++++++++++++++++++++++++++++++++++--
drivers/infiniband/hw/irdma/verbs.c | 45 ++++++++++++++++++++++++++-------
2 files changed, 84 insertions(+), 11 deletions(-)
diff --git a/drivers/infiniband/hw/irdma/cm.c b/drivers/infiniband/hw/irdma/cm.c
index 70009b9..926823f 100644
--- a/drivers/infiniband/hw/irdma/cm.c
+++ b/drivers/infiniband/hw/irdma/cm.c
@@ -1555,6 +1555,26 @@ static int irdma_del_multiple_qhash(struct irdma_device *iwdev,
return ret;
}
+static u8 irdma_iw_get_vlan_prio(u32 *loc_addr, u8 prio, bool ipv4)
+{
+ struct net_device *ndev;
+
+ if (ipv4)
+ ndev = ip_dev_find(&init_net, htonl(loc_addr[0]));
+ else
+ ndev = irdma_netdev_vlan_ipv6(loc_addr, NULL, NULL);
+
+ if (!ndev)
+ return prio;
+ if (is_vlan_dev(ndev))
+ prio = (vlan_dev_get_egress_qos_mask(ndev, prio) & VLAN_PRIO_MASK)
+ >> VLAN_PRIO_SHIFT;
+ if (ipv4)
+ dev_put(ndev);
+
+ return prio;
+}
+
/**
* irdma_netdev_vlan_ipv6 - Gets the netdev and mac
* @addr: local IPv6 address
@@ -1667,6 +1687,12 @@ static int irdma_add_mqh_6(struct irdma_device *iwdev,
ifp->addr.in6_u.u6_addr32);
memcpy(cm_info->loc_addr, child_listen_node->loc_addr,
sizeof(cm_info->loc_addr));
+ if (!iwdev->vsi.dscp_mode)
+ cm_info->user_pri =
+ irdma_iw_get_vlan_prio(child_listen_node->loc_addr,
+ cm_info->user_pri,
+ false);
+
ret = irdma_manage_qhash(iwdev, cm_info,
IRDMA_QHASH_TYPE_TCP_SYN,
IRDMA_QHASH_MANAGE_TYPE_ADD,
@@ -1751,6 +1777,11 @@ static int irdma_add_mqh_4(struct irdma_device *iwdev,
ntohl(ifa->ifa_address);
memcpy(cm_info->loc_addr, child_listen_node->loc_addr,
sizeof(cm_info->loc_addr));
+ if (!iwdev->vsi.dscp_mode)
+ cm_info->user_pri =
+ irdma_iw_get_vlan_prio(child_listen_node->loc_addr,
+ cm_info->user_pri,
+ true);
ret = irdma_manage_qhash(iwdev, cm_info,
IRDMA_QHASH_TYPE_TCP_SYN,
IRDMA_QHASH_MANAGE_TYPE_ADD,
@@ -2219,6 +2250,10 @@ static void irdma_cm_free_ah(struct irdma_cm_node *cm_node)
} else {
cm_node->tos = max(listener->tos, cm_info->tos);
cm_node->user_pri = rt_tos2priority(cm_node->tos);
+ cm_node->user_pri =
+ irdma_iw_get_vlan_prio(cm_info->loc_addr,
+ cm_node->user_pri,
+ cm_info->ipv4);
}
ibdev_dbg(&iwdev->ibdev,
"DCB: listener: TOS:[%d] UP:[%d]\n", cm_node->tos,
@@ -3832,11 +3867,15 @@ int irdma_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
cm_info.cm_id = cm_id;
cm_info.qh_qpid = iwdev->vsi.ilq->qp_id;
cm_info.tos = cm_id->tos;
- if (iwdev->vsi.dscp_mode)
+ if (iwdev->vsi.dscp_mode) {
cm_info.user_pri =
iwqp->sc_qp.vsi->dscp_map[irdma_tos2dscp(cm_info.tos)];
- else
+ } else {
cm_info.user_pri = rt_tos2priority(cm_id->tos);
+ cm_info.user_pri = irdma_iw_get_vlan_prio(cm_info.loc_addr,
+ cm_info.user_pri,
+ cm_info.ipv4);
+ }
if (iwqp->sc_qp.dev->ws_add(iwqp->sc_qp.vsi, cm_info.user_pri))
return -ENOMEM;
@@ -3990,6 +4029,13 @@ int irdma_create_listen(struct iw_cm_id *cm_id, int backlog)
if (err)
goto error;
} else {
+ if (!iwdev->vsi.dscp_mode) {
+ cm_listen_node->user_pri =
+ irdma_iw_get_vlan_prio(cm_info.loc_addr,
+ cm_info.user_pri,
+ cm_info.ipv4);
+ cm_info.user_pri = cm_listen_node->user_pri;
+ }
err = irdma_manage_qhash(iwdev, &cm_info,
IRDMA_QHASH_TYPE_TCP_SYN,
IRDMA_QHASH_MANAGE_TYPE_ADD,
diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/irdma/verbs.c
index ab5cdf7..52084651 100644
--- a/drivers/infiniband/hw/irdma/verbs.c
+++ b/drivers/infiniband/hw/irdma/verbs.c
@@ -1097,6 +1097,24 @@ static int irdma_query_pkey(struct ib_device *ibdev, u32 port, u16 index,
return 0;
}
+static u8 irdma_roce_get_vlan_prio(struct net_device __rcu *ndev_rcu, u8 prio)
+{
+ struct net_device *ndev;
+
+ rcu_read_lock();
+ ndev = rcu_dereference(ndev_rcu);
+ if (!ndev)
+ goto exit;
+ if (is_vlan_dev(ndev)) {
+ u16 vlan_qos = vlan_dev_get_egress_qos_mask(ndev, prio);
+
+ prio = (vlan_qos & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT;
+ }
+exit:
+ rcu_read_unlock();
+ return prio;
+}
+
/**
* irdma_modify_qp_roce - modify qp request
* @ibqp: qp's pointer for modify
@@ -1173,7 +1191,8 @@ int irdma_modify_qp_roce(struct ib_qp *ibqp, struct ib_qp_attr *attr,
if (attr_mask & IB_QP_AV) {
struct irdma_av *av = &iwqp->roce_ah.av;
- const struct ib_gid_attr *sgid_attr;
+ const struct ib_gid_attr *sgid_attr =
+ attr->ah_attr.grh.sgid_attr;
u16 vlan_id = VLAN_N_VID;
u32 local_ip[4];
@@ -1188,17 +1207,22 @@ int irdma_modify_qp_roce(struct ib_qp *ibqp, struct ib_qp_attr *attr,
roce_info->dest_qp);
irdma_qp_rem_qos(&iwqp->sc_qp);
dev->ws_remove(iwqp->sc_qp.vsi, ctx_info->user_pri);
- ctx_info->user_pri = rt_tos2priority(udp_info->tos);
- iwqp->sc_qp.user_pri = ctx_info->user_pri;
- if (dev->ws_add(iwqp->sc_qp.vsi, ctx_info->user_pri))
- return -ENOMEM;
- irdma_qp_add_qos(&iwqp->sc_qp);
+ if (iwqp->sc_qp.vsi->dscp_mode)
+ ctx_info->user_pri =
+ iwqp->sc_qp.vsi->dscp_map[irdma_tos2dscp(udp_info->tos)];
+ else
+ ctx_info->user_pri = rt_tos2priority(udp_info->tos);
}
- sgid_attr = attr->ah_attr.grh.sgid_attr;
ret = rdma_read_gid_l2_fields(sgid_attr, &vlan_id,
ctx_info->roce_info->mac_addr);
if (ret)
return ret;
+ ctx_info->user_pri = irdma_roce_get_vlan_prio(sgid_attr->ndev,
+ ctx_info->user_pri);
+ if (dev->ws_add(iwqp->sc_qp.vsi, ctx_info->user_pri))
+ return -ENOMEM;
+ iwqp->sc_qp.user_pri = ctx_info->user_pri;
+ irdma_qp_add_qos(&iwqp->sc_qp);
if (vlan_id >= VLAN_N_VID && iwdev->dcb_vlan_mode)
vlan_id = 0;
@@ -4259,9 +4283,12 @@ static int irdma_setup_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *attr)
ah_info->vlan_tag = 0;
if (ah_info->vlan_tag < VLAN_N_VID) {
+ u8 prio = rt_tos2priority(ah_info->tc_tos);
+
+ prio = irdma_roce_get_vlan_prio(sgid_attr->ndev, prio);
+
+ ah_info->vlan_tag |= (u16)prio << VLAN_PRIO_SHIFT;
ah_info->insert_vlan_tag = true;
- ah_info->vlan_tag |=
- rt_tos2priority(ah_info->tc_tos) << VLAN_PRIO_SHIFT;
}
return 0;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH for-rc 1/2] RDMA/irdma: Prevent QP use after free
2023-05-22 15:56 [PATCH for-rc 0/2] RDMA/irdma: Bug fixes Shiraz Saleem
2023-05-22 15:56 ` [PATCH for-next] RDMA/irdma: Implement egress VLAN priority Shiraz Saleem
@ 2023-05-22 15:56 ` Shiraz Saleem
2023-05-22 15:56 ` [PATCH for-rc 2/2] RDMA/irdma: Fix Local Invalidate fencing Shiraz Saleem
2023-05-29 17:10 ` [PATCH for-rc 0/2] RDMA/irdma: Bug fixes Jason Gunthorpe
3 siblings, 0 replies; 6+ messages in thread
From: Shiraz Saleem @ 2023-05-22 15:56 UTC (permalink / raw)
To: jgg, leon; +Cc: linux-rdma, Mustafa Ismail, Shiraz Saleem
From: Mustafa Ismail <mustafa.ismail@intel.com>
There is a window where the poll cq may use a QP that has been freed.
This can happen if a CQE is polled before irdma_clean_cqes() can clear
the CQE's related to the QP and the destroy QP races to free the QP memory.
then the QP structures are used in irdma_poll_cq.
Fix this by moving the clearing of CQE's before the reference is removed
and the QP is destroyed.
Fixes: b48c24c2d710 ("RDMA/irdma: Implement device supported verb APIs")
Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
---
drivers/infiniband/hw/irdma/verbs.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/irdma/verbs.c
index 52084651..6a1c266 100644
--- a/drivers/infiniband/hw/irdma/verbs.c
+++ b/drivers/infiniband/hw/irdma/verbs.c
@@ -522,11 +522,6 @@ static int irdma_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata)
if (!iwqp->user_mode)
cancel_delayed_work_sync(&iwqp->dwork_flush);
- irdma_qp_rem_ref(&iwqp->ibqp);
- wait_for_completion(&iwqp->free_qp);
- irdma_free_lsmm_rsrc(iwqp);
- irdma_cqp_qp_destroy_cmd(&iwdev->rf->sc_dev, &iwqp->sc_qp);
-
if (!iwqp->user_mode) {
if (iwqp->iwscq) {
irdma_clean_cqes(iwqp, iwqp->iwscq);
@@ -534,6 +529,12 @@ static int irdma_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata)
irdma_clean_cqes(iwqp, iwqp->iwrcq);
}
}
+
+ irdma_qp_rem_ref(&iwqp->ibqp);
+ wait_for_completion(&iwqp->free_qp);
+ irdma_free_lsmm_rsrc(iwqp);
+ irdma_cqp_qp_destroy_cmd(&iwdev->rf->sc_dev, &iwqp->sc_qp);
+
irdma_remove_push_mmap_entries(iwqp);
irdma_free_qp_rsrc(iwqp);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH for-rc 2/2] RDMA/irdma: Fix Local Invalidate fencing
2023-05-22 15:56 [PATCH for-rc 0/2] RDMA/irdma: Bug fixes Shiraz Saleem
2023-05-22 15:56 ` [PATCH for-next] RDMA/irdma: Implement egress VLAN priority Shiraz Saleem
2023-05-22 15:56 ` [PATCH for-rc 1/2] RDMA/irdma: Prevent QP use after free Shiraz Saleem
@ 2023-05-22 15:56 ` Shiraz Saleem
2023-05-29 17:10 ` [PATCH for-rc 0/2] RDMA/irdma: Bug fixes Jason Gunthorpe
3 siblings, 0 replies; 6+ messages in thread
From: Shiraz Saleem @ 2023-05-22 15:56 UTC (permalink / raw)
To: jgg, leon; +Cc: linux-rdma, Mustafa Ismail, Shiraz Saleem
From: Mustafa Ismail <mustafa.ismail@intel.com>
If the local invalidate fence is indicated in the WR, only the read
fence is currently being set in WQE. Fix this to set both the read and
local fence in the WQE.
Fixes: b48c24c2d710 ("RDMA/irdma: Implement device supported verb APIs")
Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
---
drivers/infiniband/hw/irdma/verbs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/irdma/verbs.c
index 6a1c266..996e1c9 100644
--- a/drivers/infiniband/hw/irdma/verbs.c
+++ b/drivers/infiniband/hw/irdma/verbs.c
@@ -3316,6 +3316,7 @@ static int irdma_post_send(struct ib_qp *ibqp,
break;
case IB_WR_LOCAL_INV:
info.op_type = IRDMA_OP_TYPE_INV_STAG;
+ info.local_fence = info.read_fence;
info.op.inv_local_stag.target_stag = ib_wr->ex.invalidate_rkey;
err = irdma_uk_stag_local_invalidate(ukqp, &info, true);
break;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH for-rc 0/2] RDMA/irdma: Bug fixes
2023-05-22 15:56 [PATCH for-rc 0/2] RDMA/irdma: Bug fixes Shiraz Saleem
` (2 preceding siblings ...)
2023-05-22 15:56 ` [PATCH for-rc 2/2] RDMA/irdma: Fix Local Invalidate fencing Shiraz Saleem
@ 2023-05-29 17:10 ` Jason Gunthorpe
3 siblings, 0 replies; 6+ messages in thread
From: Jason Gunthorpe @ 2023-05-29 17:10 UTC (permalink / raw)
To: Shiraz Saleem; +Cc: leon, linux-rdma
On Mon, May 22, 2023 at 10:56:51AM -0500, Shiraz Saleem wrote:
> This series adds a couple of minor driver fixes for irdma.
>
> Mustafa Ismail (2):
> RDMA/irdma: Prevent QP use after free
> RDMA/irdma: Fix Local Invalidate fencing
Applied to for-rc, thanks
Jason
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH for-next] RDMA/irdma: Implement egress VLAN priority
2023-05-22 15:56 ` [PATCH for-next] RDMA/irdma: Implement egress VLAN priority Shiraz Saleem
@ 2023-06-01 15:56 ` Jason Gunthorpe
0 siblings, 0 replies; 6+ messages in thread
From: Jason Gunthorpe @ 2023-06-01 15:56 UTC (permalink / raw)
To: Shiraz Saleem; +Cc: leon, linux-rdma, Mustafa Ismail
On Mon, May 22, 2023 at 10:56:52AM -0500, Shiraz Saleem wrote:
> diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/irdma/verbs.c
> index ab5cdf7..52084651 100644
> --- a/drivers/infiniband/hw/irdma/verbs.c
> +++ b/drivers/infiniband/hw/irdma/verbs.c
> @@ -1097,6 +1097,24 @@ static int irdma_query_pkey(struct ib_device *ibdev, u32 port, u16 index,
> return 0;
> }
>
> +static u8 irdma_roce_get_vlan_prio(struct net_device __rcu *ndev_rcu, u8 prio)
> +{
> + struct net_device *ndev;
> +
> + rcu_read_lock();
> + ndev = rcu_dereference(ndev_rcu);
Well that can't be right
You have to call rcu_derference on the actual original load to get the
pointer, not on a function argument.
Jason
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-06-01 15:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-22 15:56 [PATCH for-rc 0/2] RDMA/irdma: Bug fixes Shiraz Saleem
2023-05-22 15:56 ` [PATCH for-next] RDMA/irdma: Implement egress VLAN priority Shiraz Saleem
2023-06-01 15:56 ` Jason Gunthorpe
2023-05-22 15:56 ` [PATCH for-rc 1/2] RDMA/irdma: Prevent QP use after free Shiraz Saleem
2023-05-22 15:56 ` [PATCH for-rc 2/2] RDMA/irdma: Fix Local Invalidate fencing Shiraz Saleem
2023-05-29 17:10 ` [PATCH for-rc 0/2] RDMA/irdma: Bug fixes Jason Gunthorpe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.