mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jindrich Makovicka <makovick@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] forcedeth: reconfigure multicast packet filter only when needed
Date: Thu, 12 Aug 2010 11:54:30 +0200	[thread overview]
Message-ID: <20100812115430.2b5d8683@starbug.prg01.itonis.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 824 bytes --]

Currently, the forcedeth driver reconfigures the packet filter every
time a multicast stream is (un-)subscribed. As the receiving has to be
stopped and started in this case, any multicast subscription can cause
packet loss, allowing userspace applications to disrupt incoming
traffic.

With the following patch, nv_set_multicast first checks the cached
state of the packet filter, and skips the reconfiguration if the state
does not change. With the default settings, this can reduce some
useless reconfiguration attempts. When switched to promiscuous mode,
all reconfigurations are skipped with the patch, which can be used to
mitigate packet loss problems when receiving and re-subscribing many
multicasts simultaneously on a single machine.

Signed-off-by: Jindrich Makovicka <makovick@gmail.com>

-- 
Jindrich Makovicka

[-- Attachment #2: forcedeth.c.diff --]
[-- Type: text/x-patch, Size: 2212 bytes --]

--- forcedeth.c.orig	2010-04-26 16:48:30.000000000 +0200
+++ forcedeth.c	2010-05-21 13:22:25.705907294 +0200
@@ -837,6 +837,11 @@
 	char name_rx[IFNAMSIZ + 3];       /* -rx    */
 	char name_tx[IFNAMSIZ + 3];       /* -tx    */
 	char name_other[IFNAMSIZ + 6];    /* -other */
+
+	/* current packet filter state */
+	u32 cur_pff;
+	u32 cur_addr[2];
+	u32 cur_mask[2];
 };
 
 /*
@@ -3128,17 +3133,28 @@
 	}
 	addr[0] |= NVREG_MCASTADDRA_FORCE;
 	pff |= NVREG_PFF_ALWAYS;
-	spin_lock_irq(&np->lock);
-	nv_stop_rx(dev);
-	writel(addr[0], base + NvRegMulticastAddrA);
-	writel(addr[1], base + NvRegMulticastAddrB);
-	writel(mask[0], base + NvRegMulticastMaskA);
-	writel(mask[1], base + NvRegMulticastMaskB);
-	writel(pff, base + NvRegPacketFilterFlags);
-	dprintk(KERN_INFO "%s: reconfiguration for multicast lists.\n",
-		dev->name);
-	nv_start_rx(dev);
-	spin_unlock_irq(&np->lock);
+	if (np->cur_pff != (pff & ~NVREG_PFF_PAUSE_RX)
+	    || memcmp(np->cur_addr, addr, sizeof(np->cur_addr)) != 0
+	    || memcmp(np->cur_mask, mask, sizeof(np->cur_mask)) != 0)
+	{
+		dprintk(KERN_INFO "%s: reconfiguration for multicast lists.\n",
+			dev->name);
+		spin_lock_irq(&np->lock);
+		nv_stop_rx(dev);
+		writel(addr[0], base + NvRegMulticastAddrA);
+		writel(addr[1], base + NvRegMulticastAddrB);
+		writel(mask[0], base + NvRegMulticastMaskA);
+		writel(mask[1], base + NvRegMulticastMaskB);
+		writel(pff, base + NvRegPacketFilterFlags);
+		nv_start_rx(dev);
+		spin_unlock_irq(&np->lock);
+		memcpy(np->cur_addr, addr, sizeof(np->cur_addr));
+		memcpy(np->cur_mask, mask, sizeof(np->cur_mask));
+		np->cur_pff = pff & ~NVREG_PFF_PAUSE_RX;
+	} else {
+		dprintk(KERN_INFO "%s: pff state unchanged - skipping reconfiguration.\n",
+			dev->name);
+	}
 }
 
 static void nv_update_pause(struct net_device *dev, u32 pause_flags)
@@ -5369,6 +5385,12 @@
 	writel(NVREG_MCASTMASKB_NONE, base + NvRegMulticastMaskB);
 	writel(0, base + NvRegPacketFilterFlags);
 
+	np->cur_pff = 0;
+	np->cur_addr[0] = NVREG_MCASTADDRA_FORCE;
+	np->cur_addr[1] = 0;
+	np->cur_mask[0] = NVREG_MCASTMASKA_NONE;
+	np->cur_mask[1] = NVREG_MCASTMASKB_NONE;
+
 	writel(0, base + NvRegTransmitterControl);
 	writel(0, base + NvRegReceiverControl);
 

             reply	other threads:[~2010-08-12  9:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-12  9:54 Jindrich Makovicka [this message]
2010-10-09 11:26 ` Fwd: " Jindřich Makovička
2010-10-09 18:32   ` Stephen Hemminger
2010-10-09 20:46     ` Jindřich Makovička

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100812115430.2b5d8683@starbug.prg01.itonis.net \
    --to=makovick@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®