History

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.

Aleksey Senin committed 15 years ago

Commit da995a81 parent 4979d184 files · +27 −21Browse files

Unified · Split

4 files
  1. drivers/infiniband/hw/mlx4/main.c +5 −4
  2. drivers/net/mlx4/mcg.c +13 −10
  3. include/linux/mlx4/device.h +8 −2
  4. include/linux/mlx4/driver.h +1 −5
drivers/infiniband/hw/mlx4/main.c+5−4
@@ -623,8 +623,9 @@ static int mlx4_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) · 622 unmodified lines
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) · 4 unmodified lines
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) · 23 unmodified lines
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+13−10
@@ -95,7 +95,8 @@ static int mlx4_MGID_HASH(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox · 94 unmodified lines
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, · 32 unmodified lines
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, · 5 unmodified lines
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], · 12 unmodified lines
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], · 15 unmodified lines
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], · 13 unmodified lines
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 @@ out: · 28 unmodified lines
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]) · 11 unmodified lines
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]) · 3 unmodified lines
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]) · 5 unmodified lines
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+8−2
@@ -144,6 +144,11 @@ enum { · 143 unmodified lines
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); · 350 unmodified lines
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+1−5
@@ -34,6 +34,7 @@ · 33 unmodified lines
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 { · 4 unmodified lines
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);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t