mlx4: enable discarding/passing multicast loopback packets by FW/HW.
Multicast (and broadcast) loopback is handled by the network stack
meaning that
all MC or BC packets that need to return into receive sockets on the
machine are
duplicated and put in the rx path handling by the ip network stack.
The HCA loops all multicast outgoing packets so that any attached QP
can get
these multicast packets as well.
The IPoIB module needs to discard all those self QP loopback packets
and does
so by comparing the SLID and QPN.
This patch controls the ConnectX HCA multicast packets block loopback
(blck_lb) for self QP.
The patch is designed to enable or disable blocking of all multicast
packets on self QP
in FW/HW on all QPs created on the ConnectX HCA.
Inter QP multicast packets on the relevant HCA will still be delivered.
The /sys/module/mlx4_core/block_loopback attribute controls the policy
flag.
Its default value is blocking-enabled (non-zero).
The flag can be read and set/unset through sysfs.
Signed-off-by: Alex Rosenbaum <[EMAIL PROTECTED]>
Signed-off-by: Merav Havuv <[EMAIL PROTECTED]>
Signed-off-by: Jack Morgenstein <[EMAIL PROTECTED]>
Index: ofed_kernel/drivers/net/mlx4/mcg.c
===================================================================
--- ofed_kernel.orig/drivers/net/mlx4/mcg.c 2007-12-05
10:34:53.519969000 +0200
+++ ofed_kernel/drivers/net/mlx4/mcg.c 2008-02-19
08:45:33.257352000 +0200
@@ -206,13 +206,14 @@ int mlx4_multicast_attach(struct mlx4_de
}
for (i = 0; i < members_count; ++i)
- if (mgm->qp[i] == cpu_to_be32(qp->qpn)) {
+ if ((be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK) == qp->qpn) {
mlx4_dbg(dev, "QP %06x already a member of MGM\n", qp->qpn);
err = 0;
goto out;
}
- mgm->qp[members_count++] = cpu_to_be32(qp->qpn);
+ mgm->qp[members_count++] = cpu_to_be32((qp->qpn & MGM_QPN_MASK) |
+ (!!mlx4_blck_lb << MGM_BLCK_LB_BIT));
mgm->members_count = cpu_to_be32(members_count);
err = mlx4_WRITE_MCG(dev, index, mailbox);
@@ -287,7 +288,7 @@ int mlx4_multicast_detach(struct mlx4_de
members_count = be32_to_cpu(mgm->members_count);
for (loc = -1, i = 0; i < members_count; ++i)
- if (mgm->qp[i] == cpu_to_be32(qp->qpn))
+ if ((be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK) == qp->qpn)
loc = i;
if (loc == -1) {
Index: ofed_kernel/drivers/net/mlx4/main.c
===================================================================
--- ofed_kernel.orig/drivers/net/mlx4/main.c 2008-02-19
08:38:33.145870000 +0200
+++ ofed_kernel/drivers/net/mlx4/main.c 2008-02-19
08:42:17.836566000 +0200
@@ -59,6 +59,10 @@ MODULE_PARM_DESC(debug_level, "Enable de
#endif /* CONFIG_MLX4_DEBUG */
+int mlx4_blck_lb=1;
+module_param_named(block_loopback, mlx4_blck_lb, int, 0644);
+MODULE_PARM_DESC(block_loopback, "Block multicast loopback packets if
> 0");
+
#ifdef CONFIG_PCI_MSI
static int msi_x = 1;
Index: ofed_kernel/drivers/net/mlx4/mlx4.h
===================================================================
--- ofed_kernel.orig/drivers/net/mlx4/mlx4.h 2008-02-19
08:38:31.356932000 +0200
+++ ofed_kernel/drivers/net/mlx4/mlx4.h 2008-02-19
08:42:17.840568000 +0200
@@ -106,6 +106,10 @@ extern int mlx4_debug_level;
#define mlx4_warn(mdev, format, arg...) \
dev_warn(&mdev->pdev->dev, format, ## arg)
+#define MGM_QPN_MASK 0x00FFFFFF
+#define MGM_BLCK_LB_BIT 30
+extern int mlx4_blck_lb;
+
struct mlx4_bitmap {
u32 last;
u32 top;