Skip to content

Commit da995a8

Browse files
Aleksey SeninRoland Dreier
authored andcommitted
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: Aleksey Senin <alekseys@voltaire.com> Signed-off-by: Roland Dreier <rolandd@cisco.com>
1 parent 4979d18 commit da995a8

4 files changed

Lines changed: 27 additions & 21 deletions

File tree

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,9 @@ static int mlx4_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
623623
struct mlx4_ib_dev *mdev = to_mdev(ibqp->device);
624624
struct mlx4_ib_qp *mqp = to_mqp(ibqp);
625625

626-
err = mlx4_multicast_attach(mdev->dev, &mqp->mqp, gid->raw, !!(mqp->flags &
627-
MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK));
626+
err = mlx4_multicast_attach(mdev->dev, &mqp->mqp, gid->raw,
627+
!!(mqp->flags & MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK),
628+
MLX4_PROTOCOL_IB);
628629
if (err)
629630
return err;
630631

@@ -635,7 +636,7 @@ static int mlx4_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
635636
return 0;
636637

637638
err_add:
638-
mlx4_multicast_detach(mdev->dev, &mqp->mqp, gid->raw);
639+
mlx4_multicast_detach(mdev->dev, &mqp->mqp, gid->raw, MLX4_PROTOCOL_IB);
639640
return err;
640641
}
641642

@@ -665,7 +666,7 @@ static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
665666
struct mlx4_ib_gid_entry *ge;
666667

667668
err = mlx4_multicast_detach(mdev->dev,
668-
&mqp->mqp, gid->raw);
669+
&mqp->mqp, gid->raw, MLX4_PROTOCOL_IB);
669670
if (err)
670671
return err;
671672

‎drivers/net/mlx4/mcg.c‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ static int mlx4_MGID_HASH(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox
9595
* entry in hash chain and *mgm holds end of hash chain.
9696
*/
9797
static int find_mgm(struct mlx4_dev *dev,
98-
u8 *gid, struct mlx4_cmd_mailbox *mgm_mailbox,
98+
u8 *gid, enum mlx4_protocol protocol,
99+
struct mlx4_cmd_mailbox *mgm_mailbox,
99100
u16 *hash, int *prev, int *index)
100101
{
101102
struct mlx4_cmd_mailbox *mailbox;
@@ -134,7 +135,8 @@ static int find_mgm(struct mlx4_dev *dev,
134135
return err;
135136
}
136137

137-
if (!memcmp(mgm->gid, gid, 16))
138+
if (!memcmp(mgm->gid, gid, 16) &&
139+
be32_to_cpu(mgm->members_count) >> 30 == protocol)
138140
return err;
139141

140142
*prev = *index;
@@ -146,7 +148,7 @@ static int find_mgm(struct mlx4_dev *dev,
146148
}
147149

148150
int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
149-
int block_mcast_loopback)
151+
int block_mcast_loopback, enum mlx4_protocol protocol)
150152
{
151153
struct mlx4_priv *priv = mlx4_priv(dev);
152154
struct mlx4_cmd_mailbox *mailbox;
@@ -165,7 +167,7 @@ int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
165167

166168
mutex_lock(&priv->mcg_table.mutex);
167169

168-
err = find_mgm(dev, gid, mailbox, &hash, &prev, &index);
170+
err = find_mgm(dev, gid, protocol, mailbox, &hash, &prev, &index);
169171
if (err)
170172
goto out;
171173

@@ -187,7 +189,7 @@ int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
187189
memcpy(mgm->gid, gid, 16);
188190
}
189191

190-
members_count = be32_to_cpu(mgm->members_count);
192+
members_count = be32_to_cpu(mgm->members_count) & 0xffffff;
191193
if (members_count == MLX4_QP_PER_MGM) {
192194
mlx4_err(dev, "MGM at index %x is full.\n", index);
193195
err = -ENOMEM;
@@ -207,7 +209,7 @@ int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
207209
else
208210
mgm->qp[members_count++] = cpu_to_be32(qp->qpn & MGM_QPN_MASK);
209211

210-
mgm->members_count = cpu_to_be32(members_count);
212+
mgm->members_count = cpu_to_be32(members_count | (u32) protocol << 30);
211213

212214
err = mlx4_WRITE_MCG(dev, index, mailbox);
213215
if (err)
@@ -242,7 +244,8 @@ int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
242244
}
243245
EXPORT_SYMBOL_GPL(mlx4_multicast_attach);
244246

245-
int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16])
247+
int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
248+
enum mlx4_protocol protocol)
246249
{
247250
struct mlx4_priv *priv = mlx4_priv(dev);
248251
struct mlx4_cmd_mailbox *mailbox;
@@ -260,7 +263,7 @@ int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16])
260263

261264
mutex_lock(&priv->mcg_table.mutex);
262265

263-
err = find_mgm(dev, gid, mailbox, &hash, &prev, &index);
266+
err = find_mgm(dev, gid, protocol, mailbox, &hash, &prev, &index);
264267
if (err)
265268
goto out;
266269

@@ -270,7 +273,7 @@ int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16])
270273
goto out;
271274
}
272275

273-
members_count = be32_to_cpu(mgm->members_count);
276+
members_count = be32_to_cpu(mgm->members_count) & 0xffffff;
274277
for (loc = -1, i = 0; i < members_count; ++i)
275278
if ((be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK) == qp->qpn)
276279
loc = i;
@@ -282,7 +285,7 @@ int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16])
282285
}
283286

284287

285-
mgm->members_count = cpu_to_be32(--members_count);
288+
mgm->members_count = cpu_to_be32(--members_count | (u32) protocol << 30);
286289
mgm->qp[loc] = mgm->qp[i - 1];
287290
mgm->qp[i - 1] = 0;
288291

‎include/linux/mlx4/device.h‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ enum {
144144
MLX4_STAT_RATE_OFFSET = 5
145145
};
146146

147+
enum mlx4_protocol {
148+
MLX4_PROTOCOL_IB,
149+
MLX4_PROTOCOL_EN,
150+
};
151+
147152
enum {
148153
MLX4_MTT_FLAG_PRESENT = 1
149154
};
@@ -500,8 +505,9 @@ int mlx4_INIT_PORT(struct mlx4_dev *dev, int port);
500505
int mlx4_CLOSE_PORT(struct mlx4_dev *dev, int port);
501506

502507
int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
503-
int block_mcast_loopback);
504-
int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16]);
508+
int block_mcast_loopback, enum mlx4_protocol protocol);
509+
int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
510+
enum mlx4_protocol protocol);
505511

506512
int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *index);
507513
void mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, int index);

‎include/linux/mlx4/driver.h‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#define MLX4_DRIVER_H
3535

3636
#include <linux/device.h>
37+
#include <linux/mlx4/device.h>
3738

3839
struct mlx4_dev;
3940

@@ -44,11 +45,6 @@ enum mlx4_dev_event {
4445
MLX4_DEV_EVENT_PORT_REINIT,
4546
};
4647

47-
enum mlx4_protocol {
48-
MLX4_PROTOCOL_IB,
49-
MLX4_PROTOCOL_EN,
50-
};
51-
5248
struct mlx4_interface {
5349
void * (*add) (struct mlx4_dev *dev);
5450
void (*remove)(struct mlx4_dev *dev, void *context);

0 commit comments

Comments
 (0)