Commit da995a8a authored by Aleksey Senin's avatar Aleksey Senin Committed by Roland Dreier

IB/mlx4: Handle protocol field in multicast table

The newest device firmware stores IB vs. Ethernet protocol in two bits
in members_count field of multicast group table (0: Infiniband, 1:
Ethernet).  When changing the QP members count for a multicast group,
it important not to reset this information.  When calling multicast
attach first time, the protocol type should be specified.  In this
patch we always set it IB, but in the future we will handle Ethernet
too.  When looking for a QP, the protocol type shoud be checked too.
Signed-off-by: default avatarAleksey Senin <alekseys@voltaire.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 4979d18f
...@@ -623,8 +623,9 @@ static int mlx4_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) ...@@ -623,8 +623,9 @@ static int mlx4_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
struct mlx4_ib_dev *mdev = to_mdev(ibqp->device); struct mlx4_ib_dev *mdev = to_mdev(ibqp->device);
struct mlx4_ib_qp *mqp = to_mqp(ibqp); struct mlx4_ib_qp *mqp = to_mqp(ibqp);
err = mlx4_multicast_attach(mdev->dev, &mqp->mqp, gid->raw, !!(mqp->flags & err = mlx4_multicast_attach(mdev->dev, &mqp->mqp, gid->raw,
MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK)); !!(mqp->flags & MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK),
MLX4_PROTOCOL_IB);
if (err) if (err)
return err; return err;
...@@ -635,7 +636,7 @@ static int mlx4_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) ...@@ -635,7 +636,7 @@ static int mlx4_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
return 0; return 0;
err_add: err_add:
mlx4_multicast_detach(mdev->dev, &mqp->mqp, gid->raw); mlx4_multicast_detach(mdev->dev, &mqp->mqp, gid->raw, MLX4_PROTOCOL_IB);
return err; return err;
} }
...@@ -665,7 +666,7 @@ static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) ...@@ -665,7 +666,7 @@ static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
struct mlx4_ib_gid_entry *ge; struct mlx4_ib_gid_entry *ge;
err = mlx4_multicast_detach(mdev->dev, err = mlx4_multicast_detach(mdev->dev,
&mqp->mqp, gid->raw); &mqp->mqp, gid->raw, MLX4_PROTOCOL_IB);
if (err) if (err)
return err; return err;
......
...@@ -95,7 +95,8 @@ static int mlx4_MGID_HASH(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox ...@@ -95,7 +95,8 @@ static int mlx4_MGID_HASH(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox
* entry in hash chain and *mgm holds end of hash chain. * entry in hash chain and *mgm holds end of hash chain.
*/ */
static int find_mgm(struct mlx4_dev *dev, static int find_mgm(struct mlx4_dev *dev,
u8 *gid, struct mlx4_cmd_mailbox *mgm_mailbox, u8 *gid, enum mlx4_protocol protocol,
struct mlx4_cmd_mailbox *mgm_mailbox,
u16 *hash, int *prev, int *index) u16 *hash, int *prev, int *index)
{ {
struct mlx4_cmd_mailbox *mailbox; struct mlx4_cmd_mailbox *mailbox;
...@@ -134,7 +135,8 @@ static int find_mgm(struct mlx4_dev *dev, ...@@ -134,7 +135,8 @@ static int find_mgm(struct mlx4_dev *dev,
return err; return err;
} }
if (!memcmp(mgm->gid, gid, 16)) if (!memcmp(mgm->gid, gid, 16) &&
be32_to_cpu(mgm->members_count) >> 30 == protocol)
return err; return err;
*prev = *index; *prev = *index;
...@@ -146,7 +148,7 @@ static int find_mgm(struct mlx4_dev *dev, ...@@ -146,7 +148,7 @@ static int find_mgm(struct mlx4_dev *dev,
} }
int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
int block_mcast_loopback) int block_mcast_loopback, enum mlx4_protocol protocol)
{ {
struct mlx4_priv *priv = mlx4_priv(dev); struct mlx4_priv *priv = mlx4_priv(dev);
struct mlx4_cmd_mailbox *mailbox; struct mlx4_cmd_mailbox *mailbox;
...@@ -165,7 +167,7 @@ int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], ...@@ -165,7 +167,7 @@ int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
mutex_lock(&priv->mcg_table.mutex); mutex_lock(&priv->mcg_table.mutex);
err = find_mgm(dev, gid, mailbox, &hash, &prev, &index); err = find_mgm(dev, gid, protocol, mailbox, &hash, &prev, &index);
if (err) if (err)
goto out; goto out;
...@@ -187,7 +189,7 @@ int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], ...@@ -187,7 +189,7 @@ int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
memcpy(mgm->gid, gid, 16); memcpy(mgm->gid, gid, 16);
} }
members_count = be32_to_cpu(mgm->members_count); members_count = be32_to_cpu(mgm->members_count) & 0xffffff;
if (members_count == MLX4_QP_PER_MGM) { if (members_count == MLX4_QP_PER_MGM) {
mlx4_err(dev, "MGM at index %x is full.\n", index); mlx4_err(dev, "MGM at index %x is full.\n", index);
err = -ENOMEM; err = -ENOMEM;
...@@ -207,7 +209,7 @@ int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], ...@@ -207,7 +209,7 @@ int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
else else
mgm->qp[members_count++] = cpu_to_be32(qp->qpn & MGM_QPN_MASK); mgm->qp[members_count++] = cpu_to_be32(qp->qpn & MGM_QPN_MASK);
mgm->members_count = cpu_to_be32(members_count); mgm->members_count = cpu_to_be32(members_count | (u32) protocol << 30);
err = mlx4_WRITE_MCG(dev, index, mailbox); err = mlx4_WRITE_MCG(dev, index, mailbox);
if (err) if (err)
...@@ -242,7 +244,8 @@ int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], ...@@ -242,7 +244,8 @@ int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
} }
EXPORT_SYMBOL_GPL(mlx4_multicast_attach); EXPORT_SYMBOL_GPL(mlx4_multicast_attach);
int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16]) int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
enum mlx4_protocol protocol)
{ {
struct mlx4_priv *priv = mlx4_priv(dev); struct mlx4_priv *priv = mlx4_priv(dev);
struct mlx4_cmd_mailbox *mailbox; struct mlx4_cmd_mailbox *mailbox;
...@@ -260,7 +263,7 @@ int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16]) ...@@ -260,7 +263,7 @@ int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16])
mutex_lock(&priv->mcg_table.mutex); mutex_lock(&priv->mcg_table.mutex);
err = find_mgm(dev, gid, mailbox, &hash, &prev, &index); err = find_mgm(dev, gid, protocol, mailbox, &hash, &prev, &index);
if (err) if (err)
goto out; goto out;
...@@ -270,7 +273,7 @@ int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16]) ...@@ -270,7 +273,7 @@ int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16])
goto out; goto out;
} }
members_count = be32_to_cpu(mgm->members_count); members_count = be32_to_cpu(mgm->members_count) & 0xffffff;
for (loc = -1, i = 0; i < members_count; ++i) for (loc = -1, i = 0; i < members_count; ++i)
if ((be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK) == qp->qpn) if ((be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK) == qp->qpn)
loc = i; loc = i;
...@@ -282,7 +285,7 @@ int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16]) ...@@ -282,7 +285,7 @@ int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16])
} }
mgm->members_count = cpu_to_be32(--members_count); mgm->members_count = cpu_to_be32(--members_count | (u32) protocol << 30);
mgm->qp[loc] = mgm->qp[i - 1]; mgm->qp[loc] = mgm->qp[i - 1];
mgm->qp[i - 1] = 0; mgm->qp[i - 1] = 0;
......
...@@ -144,6 +144,11 @@ enum { ...@@ -144,6 +144,11 @@ enum {
MLX4_STAT_RATE_OFFSET = 5 MLX4_STAT_RATE_OFFSET = 5
}; };
enum mlx4_protocol {
MLX4_PROTOCOL_IB,
MLX4_PROTOCOL_EN,
};
enum { enum {
MLX4_MTT_FLAG_PRESENT = 1 MLX4_MTT_FLAG_PRESENT = 1
}; };
...@@ -500,8 +505,9 @@ int mlx4_INIT_PORT(struct mlx4_dev *dev, int port); ...@@ -500,8 +505,9 @@ int mlx4_INIT_PORT(struct mlx4_dev *dev, int port);
int mlx4_CLOSE_PORT(struct mlx4_dev *dev, int port); int mlx4_CLOSE_PORT(struct mlx4_dev *dev, int port);
int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
int block_mcast_loopback); int block_mcast_loopback, enum mlx4_protocol protocol);
int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16]); int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
enum mlx4_protocol protocol);
int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *index); int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *index);
void mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, int index); void mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, int index);
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#define MLX4_DRIVER_H #define MLX4_DRIVER_H
#include <linux/device.h> #include <linux/device.h>
#include <linux/mlx4/device.h>
struct mlx4_dev; struct mlx4_dev;
...@@ -44,11 +45,6 @@ enum mlx4_dev_event { ...@@ -44,11 +45,6 @@ enum mlx4_dev_event {
MLX4_DEV_EVENT_PORT_REINIT, MLX4_DEV_EVENT_PORT_REINIT,
}; };
enum mlx4_protocol {
MLX4_PROTOCOL_IB,
MLX4_PROTOCOL_EN,
};
struct mlx4_interface { struct mlx4_interface {
void * (*add) (struct mlx4_dev *dev); void * (*add) (struct mlx4_dev *dev);
void (*remove)(struct mlx4_dev *dev, void *context); void (*remove)(struct mlx4_dev *dev, void *context);
......
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