Commit d0de1362 authored by Eli Cohen's avatar Eli Cohen Committed by Roland Dreier

IPoIB: Only set Q_Key once: after joining broadcast group

The current code will set the Q_Key for any join of a non-sendonly
multicast group.  The operation involves a modify QP operation, which
is fairly heavyweight, and is only really required after the join of
the broadcast group.  Fix this by adding a parameter to ipoib_mcast_attach()
to control when the Q_Key is set.
Signed-off-by: default avatarEli Cohen <eli@mellanox.co.il>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 5892eff9
...@@ -485,7 +485,7 @@ void ipoib_path_iter_read(struct ipoib_path_iter *iter, ...@@ -485,7 +485,7 @@ void ipoib_path_iter_read(struct ipoib_path_iter *iter,
#endif #endif
int ipoib_mcast_attach(struct net_device *dev, u16 mlid, int ipoib_mcast_attach(struct net_device *dev, u16 mlid,
union ib_gid *mgid); union ib_gid *mgid, int set_qkey);
int ipoib_mcast_detach(struct net_device *dev, u16 mlid, int ipoib_mcast_detach(struct net_device *dev, u16 mlid,
union ib_gid *mgid); union ib_gid *mgid);
......
...@@ -186,6 +186,7 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast, ...@@ -186,6 +186,7 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
struct ipoib_dev_priv *priv = netdev_priv(dev); struct ipoib_dev_priv *priv = netdev_priv(dev);
struct ipoib_ah *ah; struct ipoib_ah *ah;
int ret; int ret;
int set_qkey = 0;
mcast->mcmember = *mcmember; mcast->mcmember = *mcmember;
...@@ -200,6 +201,7 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast, ...@@ -200,6 +201,7 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
priv->qkey = be32_to_cpu(priv->broadcast->mcmember.qkey); priv->qkey = be32_to_cpu(priv->broadcast->mcmember.qkey);
spin_unlock_irq(&priv->lock); spin_unlock_irq(&priv->lock);
priv->tx_wr.wr.ud.remote_qkey = priv->qkey; priv->tx_wr.wr.ud.remote_qkey = priv->qkey;
set_qkey = 1;
} }
if (!test_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags)) { if (!test_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags)) {
...@@ -212,7 +214,7 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast, ...@@ -212,7 +214,7 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
} }
ret = ipoib_mcast_attach(dev, be16_to_cpu(mcast->mcmember.mlid), ret = ipoib_mcast_attach(dev, be16_to_cpu(mcast->mcmember.mlid),
&mcast->mcmember.mgid); &mcast->mcmember.mgid, set_qkey);
if (ret < 0) { if (ret < 0) {
ipoib_warn(priv, "couldn't attach QP to multicast group " ipoib_warn(priv, "couldn't attach QP to multicast group "
IPOIB_GID_FMT "\n", IPOIB_GID_FMT "\n",
......
...@@ -33,18 +33,13 @@ ...@@ -33,18 +33,13 @@
#include "ipoib.h" #include "ipoib.h"
int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid) int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid, int set_qkey)
{ {
struct ipoib_dev_priv *priv = netdev_priv(dev); struct ipoib_dev_priv *priv = netdev_priv(dev);
struct ib_qp_attr *qp_attr; struct ib_qp_attr *qp_attr = NULL;
int ret; int ret;
u16 pkey_index; u16 pkey_index;
ret = -ENOMEM;
qp_attr = kmalloc(sizeof *qp_attr, GFP_KERNEL);
if (!qp_attr)
goto out;
if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &pkey_index)) { if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &pkey_index)) {
clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
ret = -ENXIO; ret = -ENXIO;
...@@ -52,6 +47,12 @@ int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid) ...@@ -52,6 +47,12 @@ int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid)
} }
set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
if (set_qkey) {
ret = -ENOMEM;
qp_attr = kmalloc(sizeof *qp_attr, GFP_KERNEL);
if (!qp_attr)
goto out;
/* set correct QKey for QP */ /* set correct QKey for QP */
qp_attr->qkey = priv->qkey; qp_attr->qkey = priv->qkey;
ret = ib_modify_qp(priv->qp, qp_attr, IB_QP_QKEY); ret = ib_modify_qp(priv->qp, qp_attr, IB_QP_QKEY);
...@@ -59,6 +60,7 @@ int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid) ...@@ -59,6 +60,7 @@ int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid)
ipoib_warn(priv, "failed to modify QP, ret = %d\n", ret); ipoib_warn(priv, "failed to modify QP, ret = %d\n", ret);
goto out; goto out;
} }
}
/* attach QP to multicast group */ /* attach QP to multicast group */
ret = ib_attach_mcast(priv->qp, mgid, mlid); ret = ib_attach_mcast(priv->qp, mgid, mlid);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment