Netdev List
 help / color / mirror / Atom feed
* Re: Unable to flush ICMP redirect routes in kernel 3.0+
From: Flavio Leitner @ 2011-11-17  0:33 UTC (permalink / raw)
  To: Ivan Zahariev; +Cc: netdev
In-Reply-To: <4EC439F2.3080809@icdsoft.com>

On Thu, 17 Nov 2011 00:32:18 +0200
Ivan Zahariev <famzah@icdsoft.com> wrote:

> On 11/15/2011 11:09 PM, Eric Dumazet wrote:
> > Le mardi 15 novembre 2011 à 22:23 +0200, Ivan Zahariev a écrit :
> >> Hello,
> >>
> >> We have changed nothing in our network infrastructure but only
> >> upgraded from Linux kernel 2.6.36.2 to 3.0.3. Here is the problem
> >> we are experiencing:
> >>
> >> ICMP redirected routes are cached forever, and they can be cleared
> >> only by a reboot.
> >> 
> ### (bug #1) even though we flushed the route cache, the <redirected> 
> route resurrects from somewhere; even without making any TCP requests
> ### this time what "ip" returns is consistent with the real
> (incorrect) routing behavior of machine5
> root@machine5:~# ip route flush cache
> root@machine5:~# ip route list cache match 8.8.4.4
> root@machine5:~# ip route get 8.8.4.4
> 8.8.4.4 via 192.168.0.120 dev eth0  src 192.168.0.244
>      cache <redirected>  ipid 0x303a
> 
> ### only a reboot clears the cached <redirected> routes

IIRC, the cache flush doesn't affect the inetpeer where the
redirected gateway is now stored, so even after flushing the
route cache, the inetpeer will restore the old info later.

fbl

^ permalink raw reply

* [PATCH] net: ethtool: fix coding style
From: Michał Mirosław @ 2011-11-17  0:32 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Ben Hutchings

Add missing spaces around multiplication operator.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 net/core/ethtool.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index d2eff9e..31b0b7f 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -87,13 +87,14 @@ static int ethtool_get_features(struct net_device *dev, void __user *useraddr)
 	int i;
 
 	/* in case feature bits run out again */
-	BUILD_BUG_ON(ETHTOOL_DEV_FEATURE_WORDS*sizeof(u32) > sizeof(netdev_features_t));
+	BUILD_BUG_ON(ETHTOOL_DEV_FEATURE_WORDS * sizeof(u32) > sizeof(netdev_features_t));
 
 	for (i = 0; i < ETHTOOL_DEV_FEATURE_WORDS; ++i) {
-		features[i].available = (u32)(dev->hw_features >> (32*i));
-		features[i].requested = (u32)(dev->wanted_features >> (32*i));
-		features[i].active = (u32)(dev->features >> (32*i));
-		features[i].never_changed = (u32)(NETIF_F_NEVER_CHANGE >> (32*i));
+		features[i].available = (u32)(dev->hw_features >> (32 * i));
+		features[i].requested = (u32)(dev->wanted_features >> (32 * i));
+		features[i].active = (u32)(dev->features >> (32 * i));
+		features[i].never_changed =
+			(u32)(NETIF_F_NEVER_CHANGE >> (32 * i));
 	}
 
 	sizeaddr = useraddr + offsetof(struct ethtool_gfeatures, size);
@@ -130,8 +131,8 @@ static int ethtool_set_features(struct net_device *dev, void __user *useraddr)
 		return -EFAULT;
 
 	for (i = 0; i < ETHTOOL_DEV_FEATURE_WORDS; ++i) {
-		valid |= (netdev_features_t)features[i].valid << (32*i);
-		wanted |= (netdev_features_t)features[i].requested << (32*i);
+		valid |= (netdev_features_t)features[i].valid << (32 * i);
+		wanted |= (netdev_features_t)features[i].requested << (32 * i);
 	}
 
 	if (valid & ~NETIF_F_ETHTOOL_BITS)
-- 
1.7.7.1

^ permalink raw reply related

* Re: [PATCH] iproute2: Display closed UDP sockets on 'ss -ul'
From: Stephen Hemminger @ 2011-11-17  0:25 UTC (permalink / raw)
  To: Petr Šabata; +Cc: netdev
In-Reply-To: <1321370366-18832-1-git-send-email-contyk@redhat.com>

On Tue, 15 Nov 2011 16:19:26 +0100
Petr Šabata <contyk@redhat.com> wrote:

> This patch emulates 'netstat -ul' behavior, showing 'closed'
> (state 07) UDP sockets when ss is called with '-ul' options.
> Although dirty, this seems like the least invasive way to fix
> it and shouldn't really break anything.
> 
> Signed-off-by: Petr Šabata <contyk@redhat.com>

Applied

^ permalink raw reply

* Re: [PATCH 2/2] net: verify GSO flag bits against netdev features
From: Michał Mirosław @ 2011-11-17  0:13 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: netdev, David S. Miller
In-Reply-To: <1321488596.2709.68.camel@bwh-desktop>

On Thu, Nov 17, 2011 at 12:09:56AM +0000, Ben Hutchings wrote:
> On Thu, 2011-11-17 at 01:05 +0100, Michał Mirosław wrote:
> > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> > ---
> >  include/linux/netdevice.h |    9 +++++++++
> >  1 files changed, 9 insertions(+), 0 deletions(-)
> > 
> > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> > index b35ffd7..31da3bb 100644
> > --- a/include/linux/netdevice.h
> > +++ b/include/linux/netdevice.h
> > @@ -2492,6 +2492,15 @@ netdev_features_t netif_skb_features(struct sk_buff *skb);
> >  static inline int net_gso_ok(netdev_features_t features, int gso_type)
> >  {
> >  	netdev_features_t feature = gso_type << NETIF_F_GSO_SHIFT;
> > +
> > +	/* check flags correspondence */
> > +	BUILD_BUG_ON(SKB_GSO_TCPV4   != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
> > +	BUILD_BUG_ON(SKB_GSO_UDP     != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
> > +	BUILD_BUG_ON(SKB_GSO_DODGY   != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
> > +	BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
> > +	BUILD_BUG_ON(SKB_GSO_TCPV6   != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
> > +	BUILD_BUG_ON(SKB_GSO_FCOE    != (NETIF_F_FSO >> NETIF_F_GSO_SHIFT));
> > +
> >  	return (features & feature) == feature;
> >  }
> This is fine but should still be done at the same time as changing the
> definitions.

Agreed. But as Dave was quicker, we need to fix this in separate patch.

Best Regards,
Michał Mirosław

^ permalink raw reply

* Re: [PATCH v5 5/9] net: Define enum for net device features.
From: Michał Mirosław @ 2011-11-17  0:11 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: netdev, David S. Miller
In-Reply-To: <1321488024.2709.66.camel@bwh-desktop>

On Thu, Nov 17, 2011 at 12:00:24AM +0000, Ben Hutchings wrote:
> On Thu, 2011-11-17 at 00:34 +0100, Michał Mirosław wrote:
> > On Wed, Nov 16, 2011 at 10:39:37PM +0000, Ben Hutchings wrote:
> > > On Wed, 2011-11-16 at 02:29 +0100, Michał Mirosław wrote:
> > > > Define feature values by bit position instead of direct 2**i values
> > > > and force the values to be of type netdev_features_t.
> > > > 
> > > > Cleaned and extended from patch by Mahesh Bandewar <maheshb@google.com>:
> > > > + added netdev_features_t casts
> > > > + included bits under NETIF_F_GSO_MASK
> > > > + moved feature #defines out of struct net_device definition
> > > > 
> > > > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> > > > ---
> > > >  include/linux/netdev_features.h |  129 +++++++++++++++++++++++++++-----------
> > > >  1 files changed, 91 insertions(+), 38 deletions(-)
> > > > 
> > > > diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
> > > > index af52381..04ac8f8 100644
> > > > --- a/include/linux/netdev_features.h
> > > > +++ b/include/linux/netdev_features.h
> > > [...]
> > > > +	/**/NETIF_F_GSO_SHIFT,		/* keep the order of SKB_GSO_* bits */
> > > > +	NETIF_F_TSO_BIT			/* ... TCPv4 segmentation */
> > > > +		= NETIF_F_GSO_SHIFT,
> > > > +	NETIF_F_UFO_BIT,		/* ... UDPv4 fragmentation */
> > > > +	NETIF_F_GSO_ROBUST_BIT,		/* ... ->SKB_GSO_DODGY */
> > > > +	NETIF_F_TSO_ECN_BIT,		/* ... TCP ECN support */
> > > > +	NETIF_F_TSO6_BIT,		/* ... TCPv6 segmentation */
> > > > +	NETIF_F_FSO_BIT,		/* ... FCoE segmentation */
> > > > +	NETIF_F_GSO_RESERVED1,		/* ... free (fill GSO_MASK to 8 bits) */
> > > > +	/**/NETIF_F_GSO_LAST,		/* [can't be last bit, see GSO_MASK] */
> > > > +	NETIF_F_GSO_RESERVED2		/* ... free (fill GSO_MASK to 8 bits) */
> > > > +		= NETIF_F_GSO_LAST,
> > > >  
> > > > -/* Segmentation offload features */
> > > > -#define NETIF_F_GSO_SHIFT	16
> > > > -#define NETIF_F_GSO_MASK	0x00ff0000
> > > > -#define NETIF_F_TSO		(SKB_GSO_TCPV4 << NETIF_F_GSO_SHIFT)
> > > > -#define NETIF_F_UFO		(SKB_GSO_UDP << NETIF_F_GSO_SHIFT)
> > > > -#define NETIF_F_GSO_ROBUST	(SKB_GSO_DODGY << NETIF_F_GSO_SHIFT)
> > > > -#define NETIF_F_TSO_ECN		(SKB_GSO_TCP_ECN << NETIF_F_GSO_SHIFT)
> > > > -#define NETIF_F_TSO6		(SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT)
> > > > -#define NETIF_F_FSO		(SKB_GSO_FCOE << NETIF_F_GSO_SHIFT)
> > > [...]
> > > 
> > > You should either add BUILD_BUG_ON()s somewhere to ensure that the
> > > netdev feature and skb GSO flags remain in sync, or redefine the skb GSO
> > > flags using the netdev feature flags (which I thought was the reason for
> > > moving features to their own header).
> > 
> > Main motiviation for the moving out of features to separate headers was
> > to avoid circular inclusion of linux/netdevice.h from linux/skbuff.h.
> > We get readability for free.
> > 
> > BUILD_BUG_ON() is a good idea. It should go to skbuff.h and as separate
> > patch as it's something new and independent.
> It may be functionally independent, but this change is unsafe without
> the addition of such assertions.

Please take a look at a patch I just sent ("net: verify GSO flag bits against
netdev features") other way would be to define SKB_GSO_* in terms of
corresponding NETIF_F_* flags.

Best Regards,
Michał Mirosław

^ permalink raw reply

* Re: [PATCH 2/2] net: verify GSO flag bits against netdev features
From: Ben Hutchings @ 2011-11-17  0:09 UTC (permalink / raw)
  To: Michał Mirosław; +Cc: netdev, David S. Miller
In-Reply-To: <d4513ed885d62d13873f9b7310fc20cbfa55f634.1321488025.git.mirq-linux@rere.qmqm.pl>

On Thu, 2011-11-17 at 01:05 +0100, Michał Mirosław wrote:
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
>  include/linux/netdevice.h |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index b35ffd7..31da3bb 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -2492,6 +2492,15 @@ netdev_features_t netif_skb_features(struct sk_buff *skb);
>  static inline int net_gso_ok(netdev_features_t features, int gso_type)
>  {
>  	netdev_features_t feature = gso_type << NETIF_F_GSO_SHIFT;
> +
> +	/* check flags correspondence */
> +	BUILD_BUG_ON(SKB_GSO_TCPV4   != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
> +	BUILD_BUG_ON(SKB_GSO_UDP     != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
> +	BUILD_BUG_ON(SKB_GSO_DODGY   != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
> +	BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
> +	BUILD_BUG_ON(SKB_GSO_TCPV6   != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
> +	BUILD_BUG_ON(SKB_GSO_FCOE    != (NETIF_F_FSO >> NETIF_F_GSO_SHIFT));
> +
>  	return (features & feature) == feature;
>  }

This is fine but should still be done at the same time as changing the
definitions.

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

^ permalink raw reply

* Re: under-performing bonded interfaces
From: Ben Greear @ 2011-11-17  0:07 UTC (permalink / raw)
  To: Simon Chen; +Cc: netdev
In-Reply-To: <CANj2EbfrtbysEbj+gMa+fOhWo0EWjBXVyGkw8WyiPAV9nPduuQ@mail.gmail.com>

On 11/16/2011 04:05 PM, Simon Chen wrote:
> If used independently, I can get around 9.8Gbps.

On each of them concurrently, or just one at a time?

> [   11.572857] ixgbe 0000:03:00.0: Multiqueue Enabled: Rx Queue count
> = 24, Tx Queue count = 24
> [   11.572861] ixgbe 0000:03:00.0: (PCI Express:5.0Gb/s:Width x4)
> e8:9a:8f:23:42:1a
> [   11.572943] ixgbe 0000:03:00.0: MAC: 2, PHY: 8, SFP+: 3, PBA No: FFFFFF-0FF
> [   11.572944] ixgbe 0000:03:00.0: PCI-Express bandwidth available for
> this card is not sufficient for optimal performance.
> [   11.572946] ixgbe 0000:03:00.0: For optimal performance a x8
> PCI-Express slot is required.

Looks to me like it may be hardware related unless you are certain you
can get both NICs running at high-speed independently of any bonding
code...

Thanks,
Ben

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

^ permalink raw reply

* [PATCH 2/2] net: verify GSO flag bits against netdev features
From: Michał Mirosław @ 2011-11-17  0:05 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Ben Hutchings
In-Reply-To: <2ec988cd27c6eb5162ea2e41416edcaae207bb5e.1321488025.git.mirq-linux@rere.qmqm.pl>

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 include/linux/netdevice.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index b35ffd7..31da3bb 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2492,6 +2492,15 @@ netdev_features_t netif_skb_features(struct sk_buff *skb);
 static inline int net_gso_ok(netdev_features_t features, int gso_type)
 {
 	netdev_features_t feature = gso_type << NETIF_F_GSO_SHIFT;
+
+	/* check flags correspondence */
+	BUILD_BUG_ON(SKB_GSO_TCPV4   != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_UDP     != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_DODGY   != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_TCPV6   != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_FCOE    != (NETIF_F_FSO >> NETIF_F_GSO_SHIFT));
+
 	return (features & feature) == feature;
 }
 
-- 
1.7.7.1

^ permalink raw reply related

* [PATCH 1/2] net: drivers: use bool type instead of double negation
From: Michał Mirosław @ 2011-11-17  0:05 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Ben Hutchings

Save some punctuation by using bool type's property equivalent to
doubled negation operator.

Reported-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/net/ethernet/jme.c                 |    4 ++--
 drivers/net/ethernet/marvell/mv643xx_eth.c |    2 +-
 drivers/net/ethernet/marvell/sky2.c        |    2 +-
 drivers/net/xen-netfront.c                 |    4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c
index df3ab83..5c0b531 100644
--- a/drivers/net/ethernet/jme.c
+++ b/drivers/net/ethernet/jme.c
@@ -1883,7 +1883,7 @@ jme_fill_tx_map(struct pci_dev *pdev,
 		struct page *page,
 		u32 page_offset,
 		u32 len,
-		u8 hidma)
+		bool hidma)
 {
 	dma_addr_t dmaaddr;
 
@@ -1917,7 +1917,7 @@ jme_map_tx_skb(struct jme_adapter *jme, struct sk_buff *skb, int idx)
 	struct jme_ring *txring = &(jme->txring[0]);
 	struct txdesc *txdesc = txring->desc, *ctxdesc;
 	struct jme_buffer_info *txbi = txring->bufinf, *ctxbi;
-	u8 hidma = !!(jme->dev->features & NETIF_F_HIGHDMA);
+	bool hidma = jme->dev->features & NETIF_F_HIGHDMA;
 	int i, nr_frags = skb_shinfo(skb)->nr_frags;
 	int mask = jme->tx_ring_mask;
 	const struct skb_frag_struct *frag;
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 157c5c1..43e3e61 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -1582,7 +1582,7 @@ static int
 mv643xx_eth_set_features(struct net_device *dev, netdev_features_t features)
 {
 	struct mv643xx_eth_private *mp = netdev_priv(dev);
-	int rx_csum = !!(features & NETIF_F_RXCSUM);
+	bool rx_csum = features & NETIF_F_RXCSUM;
 
 	wrlp(mp, PORT_CONFIG, rx_csum ? 0x02000000 : 0x00000000);
 
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index c79dc54..7db6e36 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -4313,7 +4313,7 @@ static int sky2_set_features(struct net_device *dev, netdev_features_t features)
 	netdev_features_t changed = dev->features ^ features;
 
 	if (changed & NETIF_F_RXCSUM) {
-		int on = !!(features & NETIF_F_RXCSUM);
+		bool on = features & NETIF_F_RXCSUM;
 		sky2_write32(sky2->hw, Q_ADDR(rxqaddr[sky2->port], Q_CSR),
 			     on ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM);
 	}
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index a6e379f..4312db8 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -201,9 +201,9 @@ static void xennet_sysfs_delif(struct net_device *netdev);
 #define xennet_sysfs_delif(dev) do { } while (0)
 #endif
 
-static int xennet_can_sg(struct net_device *dev)
+static bool xennet_can_sg(struct net_device *dev)
 {
-	return !!(dev->features & NETIF_F_SG);
+	return dev->features & NETIF_F_SG;
 }
 
 
-- 
1.7.7.1

^ permalink raw reply related

* Re: under-performing bonded interfaces
From: Simon Chen @ 2011-11-17  0:05 UTC (permalink / raw)
  To: Ben Greear; +Cc: netdev
In-Reply-To: <4EC44ECB.4050201@candelatech.com>

If used independently, I can get around 9.8Gbps.

Here is from dmesg:
[   11.386736] ixgbe: Intel(R) 10 Gigabit PCI Express Network Driver -
version 3.2.9-k2
[   11.386738] ixgbe: Copyright (c) 1999-2010 Intel Corporation.
[   11.386778] ixgbe 0000:03:00.0: PCI INT A -> GSI 24 (level, low) -> IRQ 24
[   11.386788] ixgbe 0000:03:00.0: setting latency timer to 64
[   11.572715] ixgbe 0000:03:00.0: irq 75 for MSI/MSI-X
[   11.572720] ixgbe 0000:03:00.0: irq 76 for MSI/MSI-X
[   11.572728] ixgbe 0000:03:00.0: irq 77 for MSI/MSI-X
[   11.572733] ixgbe 0000:03:00.0: irq 78 for MSI/MSI-X
[   11.572737] ixgbe 0000:03:00.0: irq 79 for MSI/MSI-X
[   11.572741] ixgbe 0000:03:00.0: irq 80 for MSI/MSI-X
[   11.572745] ixgbe 0000:03:00.0: irq 81 for MSI/MSI-X
[   11.572750] ixgbe 0000:03:00.0: irq 82 for MSI/MSI-X
[   11.572755] ixgbe 0000:03:00.0: irq 83 for MSI/MSI-X
[   11.572759] ixgbe 0000:03:00.0: irq 84 for MSI/MSI-X
[   11.572766] ixgbe 0000:03:00.0: irq 85 for MSI/MSI-X
[   11.572770] ixgbe 0000:03:00.0: irq 86 for MSI/MSI-X
[   11.572775] ixgbe 0000:03:00.0: irq 87 for MSI/MSI-X
[   11.572779] ixgbe 0000:03:00.0: irq 88 for MSI/MSI-X
[   11.572783] ixgbe 0000:03:00.0: irq 89 for MSI/MSI-X
[   11.572787] ixgbe 0000:03:00.0: irq 90 for MSI/MSI-X
[   11.572791] ixgbe 0000:03:00.0: irq 91 for MSI/MSI-X
[   11.572795] ixgbe 0000:03:00.0: irq 92 for MSI/MSI-X
[   11.572799] ixgbe 0000:03:00.0: irq 93 for MSI/MSI-X
[   11.572803] ixgbe 0000:03:00.0: irq 94 for MSI/MSI-X
[   11.572807] ixgbe 0000:03:00.0: irq 95 for MSI/MSI-X
[   11.572812] ixgbe 0000:03:00.0: irq 96 for MSI/MSI-X
[   11.572816] ixgbe 0000:03:00.0: irq 97 for MSI/MSI-X
[   11.572820] ixgbe 0000:03:00.0: irq 98 for MSI/MSI-X
[   11.572825] ixgbe 0000:03:00.0: irq 99 for MSI/MSI-X
[   11.572857] ixgbe 0000:03:00.0: Multiqueue Enabled: Rx Queue count
= 24, Tx Queue count = 24
[   11.572861] ixgbe 0000:03:00.0: (PCI Express:5.0Gb/s:Width x4)
e8:9a:8f:23:42:1a
[   11.572943] ixgbe 0000:03:00.0: MAC: 2, PHY: 8, SFP+: 3, PBA No: FFFFFF-0FF
[   11.572944] ixgbe 0000:03:00.0: PCI-Express bandwidth available for
this card is not sufficient for optimal performance.
[   11.572946] ixgbe 0000:03:00.0: For optimal performance a x8
PCI-Express slot is required.
[   11.573815] ixgbe 0000:03:00.0: Intel(R) 10 Gigabit Network Connection
[   11.573833] ixgbe 0000:03:00.1: PCI INT B -> GSI 34 (level, low) -> IRQ 34
[   11.573839] ixgbe 0000:03:00.1: setting latency timer to 64
[   11.743748] ixgbe 0000:03:00.1: irq 100 for MSI/MSI-X
[   11.743753] ixgbe 0000:03:00.1: irq 101 for MSI/MSI-X
[   11.743758] ixgbe 0000:03:00.1: irq 102 for MSI/MSI-X
[   11.743762] ixgbe 0000:03:00.1: irq 103 for MSI/MSI-X
[   11.743769] ixgbe 0000:03:00.1: irq 104 for MSI/MSI-X
[   11.743773] ixgbe 0000:03:00.1: irq 105 for MSI/MSI-X
[   11.743777] ixgbe 0000:03:00.1: irq 106 for MSI/MSI-X
[   11.743781] ixgbe 0000:03:00.1: irq 107 for MSI/MSI-X
[   11.743785] ixgbe 0000:03:00.1: irq 108 for MSI/MSI-X
[   11.743789] ixgbe 0000:03:00.1: irq 109 for MSI/MSI-X
[   11.743793] ixgbe 0000:03:00.1: irq 110 for MSI/MSI-X
[   11.743796] ixgbe 0000:03:00.1: irq 111 for MSI/MSI-X
[   11.743800] ixgbe 0000:03:00.1: irq 112 for MSI/MSI-X
[   11.743804] ixgbe 0000:03:00.1: irq 113 for MSI/MSI-X
[   11.743808] ixgbe 0000:03:00.1: irq 114 for MSI/MSI-X
[   11.743815] ixgbe 0000:03:00.1: irq 115 for MSI/MSI-X
[   11.743819] ixgbe 0000:03:00.1: irq 116 for MSI/MSI-X
[   11.743823] ixgbe 0000:03:00.1: irq 117 for MSI/MSI-X
[   11.743827] ixgbe 0000:03:00.1: irq 118 for MSI/MSI-X
[   11.743831] ixgbe 0000:03:00.1: irq 119 for MSI/MSI-X
[   11.743835] ixgbe 0000:03:00.1: irq 120 for MSI/MSI-X
[   11.743839] ixgbe 0000:03:00.1: irq 121 for MSI/MSI-X
[   11.743843] ixgbe 0000:03:00.1: irq 122 for MSI/MSI-X
[   11.743847] ixgbe 0000:03:00.1: irq 123 for MSI/MSI-X
[   11.743851] ixgbe 0000:03:00.1: irq 124 for MSI/MSI-X
[   11.743882] ixgbe 0000:03:00.1: Multiqueue Enabled: Rx Queue count
= 24, Tx Queue count = 24
[   11.743886] ixgbe 0000:03:00.1: (PCI Express:5.0Gb/s:Width x4)
e8:9a:8f:23:42:1b

I have a 24 cores (just showing the last one).

processor       : 23
vendor_id       : GenuineIntel
cpu family      : 6
model           : 44
model name      : Intel(R) Xeon(R) CPU           X5650  @ 2.67GHz
stepping        : 2
cpu MHz         : 2668.000
cache size      : 12288 KB
physical id     : 1
siblings        : 12
core id         : 10
cpu cores       : 6
apicid          : 53
initial apicid  : 53
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe
syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts
rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64
monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2
popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept
vpid
bogomips        : 5333.52
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

thanks!
-Simon

On Wed, Nov 16, 2011 at 7:01 PM, Ben Greear <greearb@candelatech.com> wrote:
> On 11/16/2011 03:44 PM, Simon Chen wrote:
>>
>> Hello,
>>
>> I am bonding two 10G interfaces (ixgbe driver) under Debian 6.0.2. The
>> bonded interface for some reason can only achieve 12Gbps aggregated
>> throughput. If a single NIC is used, I can get close to 10Gbps.
>>
>> I've tried different bonding modes (balance-xor, 802.3ad, balance-alb,
>> balance-tlb), and different xmit hashing policy (layer2, layer2+3,
>> layer3+4). I've increased all types of kernel parameters for TCP. MTU
>> on the physical and bonded interface is set to 8000 and 9000. The MTU
>> on the switch is 9200+.
>>
>> Instead of nperf (a single server), I also tried my own TCP sender and
>> receivers.
>>
>> All those done, still only 12Gbps... How can I really achieve close to
>> 20Gbps?
>>
>> (I also tried cutting loose the switch in between, and also getting
>> 12G, so not an issue with the switch.)
>
> How much can you get if you run each of the NIC ports independently
> w/out bonding?  Plz send the 'dmesg' messages about ixgbe (ie, how
> many lanes, how many GT/s).  What is your processor?
>
> Thanks,
> Ben
>
>
> --
> Ben Greear <greearb@candelatech.com>
> Candela Technologies Inc  http://www.candelatech.com
>
>

^ permalink raw reply

* Re: under-performing bonded interfaces
From: Ben Greear @ 2011-11-17  0:01 UTC (permalink / raw)
  To: Simon Chen; +Cc: netdev
In-Reply-To: <CANj2EbeMRzicixHwrKpCQ3mMqQ1qbyjbRCxpW+CmVRREAhyeRQ@mail.gmail.com>

On 11/16/2011 03:44 PM, Simon Chen wrote:
> Hello,
>
> I am bonding two 10G interfaces (ixgbe driver) under Debian 6.0.2. The
> bonded interface for some reason can only achieve 12Gbps aggregated
> throughput. If a single NIC is used, I can get close to 10Gbps.
>
> I've tried different bonding modes (balance-xor, 802.3ad, balance-alb,
> balance-tlb), and different xmit hashing policy (layer2, layer2+3,
> layer3+4). I've increased all types of kernel parameters for TCP. MTU
> on the physical and bonded interface is set to 8000 and 9000. The MTU
> on the switch is 9200+.
>
> Instead of nperf (a single server), I also tried my own TCP sender and
> receivers.
>
> All those done, still only 12Gbps... How can I really achieve close to 20Gbps?
>
> (I also tried cutting loose the switch in between, and also getting
> 12G, so not an issue with the switch.)

How much can you get if you run each of the NIC ports independently
w/out bonding?  Plz send the 'dmesg' messages about ixgbe (ie, how
many lanes, how many GT/s).  What is your processor?

Thanks,
Ben


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

^ permalink raw reply

* Re: [PATCH v5 5/9] net: Define enum for net device features.
From: Ben Hutchings @ 2011-11-17  0:00 UTC (permalink / raw)
  To: Michał Mirosław; +Cc: netdev, David S. Miller
In-Reply-To: <20111116233408.GB8476@rere.qmqm.pl>

On Thu, 2011-11-17 at 00:34 +0100, Michał Mirosław wrote:
> On Wed, Nov 16, 2011 at 10:39:37PM +0000, Ben Hutchings wrote:
> > On Wed, 2011-11-16 at 02:29 +0100, Michał Mirosław wrote:
> > > Define feature values by bit position instead of direct 2**i values
> > > and force the values to be of type netdev_features_t.
> > > 
> > > Cleaned and extended from patch by Mahesh Bandewar <maheshb@google.com>:
> > > + added netdev_features_t casts
> > > + included bits under NETIF_F_GSO_MASK
> > > + moved feature #defines out of struct net_device definition
> > > 
> > > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> > > ---
> > >  include/linux/netdev_features.h |  129 +++++++++++++++++++++++++++-----------
> > >  1 files changed, 91 insertions(+), 38 deletions(-)
> > > 
> > > diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
> > > index af52381..04ac8f8 100644
> > > --- a/include/linux/netdev_features.h
> > > +++ b/include/linux/netdev_features.h
> > [...]
> > > +	/**/NETIF_F_GSO_SHIFT,		/* keep the order of SKB_GSO_* bits */
> > > +	NETIF_F_TSO_BIT			/* ... TCPv4 segmentation */
> > > +		= NETIF_F_GSO_SHIFT,
> > > +	NETIF_F_UFO_BIT,		/* ... UDPv4 fragmentation */
> > > +	NETIF_F_GSO_ROBUST_BIT,		/* ... ->SKB_GSO_DODGY */
> > > +	NETIF_F_TSO_ECN_BIT,		/* ... TCP ECN support */
> > > +	NETIF_F_TSO6_BIT,		/* ... TCPv6 segmentation */
> > > +	NETIF_F_FSO_BIT,		/* ... FCoE segmentation */
> > > +	NETIF_F_GSO_RESERVED1,		/* ... free (fill GSO_MASK to 8 bits) */
> > > +	/**/NETIF_F_GSO_LAST,		/* [can't be last bit, see GSO_MASK] */
> > > +	NETIF_F_GSO_RESERVED2		/* ... free (fill GSO_MASK to 8 bits) */
> > > +		= NETIF_F_GSO_LAST,
> > >  
> > > -/* Segmentation offload features */
> > > -#define NETIF_F_GSO_SHIFT	16
> > > -#define NETIF_F_GSO_MASK	0x00ff0000
> > > -#define NETIF_F_TSO		(SKB_GSO_TCPV4 << NETIF_F_GSO_SHIFT)
> > > -#define NETIF_F_UFO		(SKB_GSO_UDP << NETIF_F_GSO_SHIFT)
> > > -#define NETIF_F_GSO_ROBUST	(SKB_GSO_DODGY << NETIF_F_GSO_SHIFT)
> > > -#define NETIF_F_TSO_ECN		(SKB_GSO_TCP_ECN << NETIF_F_GSO_SHIFT)
> > > -#define NETIF_F_TSO6		(SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT)
> > > -#define NETIF_F_FSO		(SKB_GSO_FCOE << NETIF_F_GSO_SHIFT)
> > [...]
> > 
> > You should either add BUILD_BUG_ON()s somewhere to ensure that the
> > netdev feature and skb GSO flags remain in sync, or redefine the skb GSO
> > flags using the netdev feature flags (which I thought was the reason for
> > moving features to their own header).
> 
> Main motiviation for the moving out of features to separate headers was
> to avoid circular inclusion of linux/netdevice.h from linux/skbuff.h.
> We get readability for free.
> 
> BUILD_BUG_ON() is a good idea. It should go to skbuff.h and as separate
> patch as it's something new and independent.

It may be functionally independent, but this change is unsafe without
the addition of such assertions.

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

^ permalink raw reply

* [PATCH 5/6] sky2: used fixed RSS key
From: Stephen Hemminger @ 2011-11-16 23:42 UTC (permalink / raw)
  To: davem; +Cc: netdev
In-Reply-To: <20111116234254.319625694@vyatta.com>

[-- Attachment #1: sky2-fixed-key.patch --]
[-- Type: text/plain, Size: 1294 bytes --]

Rather than generating a different RSS key on each boot, just use
a predetermined value that will map same flow to same value on
every device.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>


--- a/drivers/net/ethernet/marvell/sky2.c	2011-11-16 15:19:40.990692544 -0800
+++ b/drivers/net/ethernet/marvell/sky2.c	2011-11-16 15:19:42.254721076 -0800
@@ -1275,6 +1275,14 @@ static void rx_set_checksum(struct sky2_
 		     ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM);
 }
 
+/*
+ * Fixed initial key as seed to RSS.
+ */
+static const uint32_t rss_init_key[10] = {
+	0x7c3351da, 0x51c5cf4e,	0x44adbdd1, 0xe8d38d18,	0x48897c43,
+	0xb1d60e7e, 0x6a3dd760, 0x01a2e453, 0x16f46f13, 0x1a0e7b30
+};
+
 /* Enable/disable receive hash calculation (RSS) */
 static void rx_set_rss(struct net_device *dev, netdev_features_t features)
 {
@@ -1290,12 +1298,9 @@ static void rx_set_rss(struct net_device
 
 	/* Program RSS initial values */
 	if (features & NETIF_F_RXHASH) {
-		u32 key[nkeys];
-
-		get_random_bytes(key, nkeys * sizeof(u32));
 		for (i = 0; i < nkeys; i++)
 			sky2_write32(hw, SK_REG(sky2->port, RSS_KEY + i * 4),
-				     key[i]);
+				     rss_init_key[i]);
 
 		/* Need to turn on (undocumented) flag to make hashing work  */
 		sky2_write32(hw, SK_REG(sky2->port, RX_GMF_CTRL_T),

^ permalink raw reply

* [PATCH 6/6] sky2: version 1.30
From: Stephen Hemminger @ 2011-11-16 23:43 UTC (permalink / raw)
  To: davem; +Cc: netdev
In-Reply-To: <20111116234254.319625694@vyatta.com>

[-- Attachment #1: sky2-1.30-version.patch --]
[-- Type: text/plain, Size: 444 bytes --]

Update version number.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>


--- a/drivers/net/ethernet/marvell/sky2.c	2011-11-16 15:08:36.031104340 -0800
+++ b/drivers/net/ethernet/marvell/sky2.c	2011-11-16 15:11:24.728913165 -0800
@@ -50,7 +50,7 @@
 #include "sky2.h"
 
 #define DRV_NAME		"sky2"
-#define DRV_VERSION		"1.29"
+#define DRV_VERSION		"1.30"
 
 /*
  * The Yukon II chipset takes 64 bit command blocks (called list elements)

^ permalink raw reply

* [PATCH 2/6] sky2: pci posting issues
From: Stephen Hemminger @ 2011-11-16 23:42 UTC (permalink / raw)
  To: davem; +Cc: netdev
In-Reply-To: <20111116234254.319625694@vyatta.com>

[-- Attachment #1: sky2-pci-posting-wol.patch --]
[-- Type: text/plain, Size: 937 bytes --]

A couple of the reset and setup paths have possible PCI posting issues.
When setting registers, a read is necessary to force the writes to complete.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

---
This needs to be applied to net-next and -net

--- a/drivers/net/ethernet/marvell/sky2.c	2011-11-16 15:19:32.898508932 -0800
+++ b/drivers/net/ethernet/marvell/sky2.c	2011-11-16 15:19:38.282631277 -0800
@@ -869,6 +869,7 @@ static void sky2_wol_init(struct sky2_po
 
 	/* block receiver */
 	sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET);
+	sky2_read32(hw, B0_CTST);
 }
 
 static void sky2_set_tx_stfwd(struct sky2_hw *hw, unsigned port)
@@ -2045,6 +2046,8 @@ static void sky2_tx_reset(struct sky2_hw
 
 	sky2_write32(hw, RB_ADDR(txqaddr[port], RB_CTRL), RB_RST_SET);
 	sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_SET);
+
+	sky2_read32(hw, B0_CTST);
 }
 
 static void sky2_hw_down(struct sky2_port *sky2)

^ permalink raw reply

* [PATCH 0/6] sky2 patches for net-next
From: Stephen Hemminger @ 2011-11-16 23:42 UTC (permalink / raw)
  To: davem; +Cc: netdev

This includes fix for recent regression and other bug fixes (in order
of decreasing importance). Only the first one is critical to get
into 3.2.

^ permalink raw reply

* [PATCH 4/6] sky2: reduce default Tx ring size
From: Stephen Hemminger @ 2011-11-16 23:42 UTC (permalink / raw)
  To: davem; +Cc: netdev
In-Reply-To: <20111116234254.319625694@vyatta.com>

[-- Attachment #1: sky2-tx-debloat.patch --]
[-- Type: text/plain, Size: 814 bytes --]

The default Tx ring size for the sky2 driver is quite large and could
cause excess buffer bloat for many users. The minimum ring size 
possible and still allow handling  the worst case packet on 64bit platforms
is 38 which gets rounded up to a power of 2. But most packets only require
a couple of ring elements.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

--- a/drivers/net/ethernet/marvell/sky2.c	2011-11-16 15:19:39.518659262 -0800
+++ b/drivers/net/ethernet/marvell/sky2.c	2011-11-16 15:19:40.990692544 -0800
@@ -68,7 +68,7 @@
 #define MAX_SKB_TX_LE	(2 + (sizeof(dma_addr_t)/sizeof(u32))*(MAX_SKB_FRAGS+1))
 #define TX_MIN_PENDING		(MAX_SKB_TX_LE+1)
 #define TX_MAX_PENDING		1024
-#define TX_DEF_PENDING		127
+#define TX_DEF_PENDING		63
 
 #define TX_WATCHDOG		(5 * HZ)
 #define NAPI_WEIGHT		64

^ permalink raw reply

* [PATCH 3/6] sky2: rename up/down functions
From: Stephen Hemminger @ 2011-11-16 23:42 UTC (permalink / raw)
  To: davem; +Cc: netdev
In-Reply-To: <20111116234254.319625694@vyatta.com>

[-- Attachment #1: sky2-open-stop-rename.patch --]
[-- Type: text/plain, Size: 2639 bytes --]

The code is clearer if the up/down functions are renamed to
open/close like other drivers.  Purely syntax change.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

--- a/drivers/net/ethernet/marvell/sky2.c	2011-11-16 15:19:38.282631277 -0800
+++ b/drivers/net/ethernet/marvell/sky2.c	2011-11-16 15:19:39.518659262 -0800
@@ -1728,7 +1728,7 @@ static int sky2_setup_irq(struct sky2_hw
 
 
 /* Bring up network interface. */
-static int sky2_up(struct net_device *dev)
+static int sky2_open(struct net_device *dev)
 {
 	struct sky2_port *sky2 = netdev_priv(dev);
 	struct sky2_hw *hw = sky2->hw;
@@ -2098,7 +2098,7 @@ static void sky2_hw_down(struct sky2_por
 }
 
 /* Network shutdown */
-static int sky2_down(struct net_device *dev)
+static int sky2_close(struct net_device *dev)
 {
 	struct sky2_port *sky2 = netdev_priv(dev);
 	struct sky2_hw *hw = sky2->hw;
@@ -2601,7 +2601,7 @@ static inline void sky2_tx_done(struct n
 	if (netif_running(dev)) {
 		sky2_tx_complete(sky2, last);
 
-		/* Wake unless it's detached, and called e.g. from sky2_down() */
+		/* Wake unless it's detached, and called e.g. from sky2_close() */
 		if (tx_avail(sky2) > MAX_SKB_TX_LE + 4)
 			netif_wake_queue(dev);
 	}
@@ -3391,7 +3391,7 @@ static void sky2_detach(struct net_devic
 		netif_tx_lock(dev);
 		netif_device_detach(dev);	/* stop txq */
 		netif_tx_unlock(dev);
-		sky2_down(dev);
+		sky2_close(dev);
 	}
 }
 
@@ -3401,7 +3401,7 @@ static int sky2_reattach(struct net_devi
 	int err = 0;
 
 	if (netif_running(dev)) {
-		err = sky2_up(dev);
+		err = sky2_open(dev);
 		if (err) {
 			netdev_info(dev, "could not restart %d\n", err);
 			dev_close(dev);
@@ -4570,7 +4570,7 @@ static int sky2_device_event(struct noti
 	struct net_device *dev = ptr;
 	struct sky2_port *sky2 = netdev_priv(dev);
 
-	if (dev->netdev_ops->ndo_open != sky2_up || !sky2_debug)
+	if (dev->netdev_ops->ndo_open != sky2_open || !sky2_debug)
 		return NOTIFY_DONE;
 
 	switch (event) {
@@ -4635,8 +4635,8 @@ static __exit void sky2_debug_cleanup(vo
    not allowing netpoll on second port */
 static const struct net_device_ops sky2_netdev_ops[2] = {
   {
-	.ndo_open		= sky2_up,
-	.ndo_stop		= sky2_down,
+	.ndo_open		= sky2_open,
+	.ndo_stop		= sky2_close,
 	.ndo_start_xmit		= sky2_xmit_frame,
 	.ndo_do_ioctl		= sky2_ioctl,
 	.ndo_validate_addr	= eth_validate_addr,
@@ -4652,8 +4652,8 @@ static const struct net_device_ops sky2_
 #endif
   },
   {
-	.ndo_open		= sky2_up,
-	.ndo_stop		= sky2_down,
+	.ndo_open		= sky2_open,
+	.ndo_stop		= sky2_close,
 	.ndo_start_xmit		= sky2_xmit_frame,
 	.ndo_do_ioctl		= sky2_ioctl,
 	.ndo_validate_addr	= eth_validate_addr,

^ permalink raw reply

* [PATCH 1/6] sky2: fix hang on shutdown (and other irq issues)
From: Stephen Hemminger @ 2011-11-16 23:42 UTC (permalink / raw)
  To: davem; +Cc: netdev
In-Reply-To: <20111116234254.319625694@vyatta.com>

[-- Attachment #1: sky2-sync-irq-shutdown.patch --]
[-- Type: text/plain, Size: 3460 bytes --]

There are several problems with recent change to how IRQ's are setup.
   * synchronize_irq in sky2_shutdown would hang because there
     was no IRQ setup.
   * when device was set to down, some IRQ bits left enabled so a
     hardware error would produce IRQ with no handler
   * quick link on Optima chip set was enabled without handler
   * suspend/resume would leave IRQ on with no handler if device
     was down

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

---
This needs to be applied to net-next and -net

--- a/drivers/net/ethernet/marvell/sky2.c	2011-11-16 15:15:48.212513321 -0800
+++ b/drivers/net/ethernet/marvell/sky2.c	2011-11-16 15:19:32.898508932 -0800
@@ -1747,6 +1747,11 @@ static int sky2_up(struct net_device *de
 
 	sky2_hw_up(sky2);
 
+	if (hw->chip_id == CHIP_ID_YUKON_OPT ||
+	    hw->chip_id == CHIP_ID_YUKON_PRM ||
+	    hw->chip_id == CHIP_ID_YUKON_OP_2)
+		imask |= Y2_IS_PHY_QLNK;	/* enable PHY Quick Link */
+
 	/* Enable interrupts from phy/mac for port */
 	imask = sky2_read32(hw, B0_IMSK);
 	imask |= portirq_msk[port];
@@ -2101,15 +2106,21 @@ static int sky2_down(struct net_device *
 
 	netif_info(sky2, ifdown, dev, "disabling interface\n");
 
-	/* Disable port IRQ */
-	sky2_write32(hw, B0_IMSK,
-		     sky2_read32(hw, B0_IMSK) & ~portirq_msk[sky2->port]);
-	sky2_read32(hw, B0_IMSK);
-
 	if (hw->ports == 1) {
+		sky2_write32(hw, B0_IMSK, 0);
+		sky2_read32(hw, B0_IMSK);
+
 		napi_disable(&hw->napi);
 		free_irq(hw->pdev->irq, hw);
 	} else {
+		u32 imask;
+
+		/* Disable port IRQ */
+		imask  = sky2_read32(hw, B0_IMSK);
+		imask &= ~portirq_msk[sky2->port];
+		sky2_write32(hw, B0_IMSK, imask);
+		sky2_read32(hw, B0_IMSK);
+
 		synchronize_irq(hw->pdev->irq);
 		napi_synchronize(&hw->napi);
 	}
@@ -3258,7 +3269,6 @@ static void sky2_reset(struct sky2_hw *h
 	    hw->chip_id == CHIP_ID_YUKON_PRM ||
 	    hw->chip_id == CHIP_ID_YUKON_OP_2) {
 		u16 reg;
-		u32 msk;
 
 		if (hw->chip_id == CHIP_ID_YUKON_OPT && hw->chip_rev == 0) {
 			/* disable PCI-E PHY power down (set PHY reg 0x80, bit 7 */
@@ -3281,11 +3291,6 @@ static void sky2_reset(struct sky2_hw *h
 		sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
 		sky2_pci_write16(hw, PSM_CONFIG_REG4, reg);
 
-		/* enable PHY Quick Link */
-		msk = sky2_read32(hw, B0_IMSK);
-		msk |= Y2_IS_PHY_QLNK;
-		sky2_write32(hw, B0_IMSK, msk);
-
 		/* check if PSMv2 was running before */
 		reg = sky2_pci_read16(hw, PSM_CONFIG_REG3);
 		if (reg & PCI_EXP_LNKCTL_ASPMC)
@@ -3412,7 +3417,9 @@ static void sky2_all_down(struct sky2_hw
 
 	sky2_read32(hw, B0_IMSK);
 	sky2_write32(hw, B0_IMSK, 0);
-	synchronize_irq(hw->pdev->irq);
+
+	if (hw->ports > 1 || netif_running(hw->dev[0]))
+		synchronize_irq(hw->pdev->irq);
 	napi_disable(&hw->napi);
 
 	for (i = 0; i < hw->ports; i++) {
@@ -3430,7 +3437,7 @@ static void sky2_all_down(struct sky2_hw
 
 static void sky2_all_up(struct sky2_hw *hw)
 {
-	u32 imask = Y2_IS_BASE;
+	u32 imask = 0;
 	int i;
 
 	for (i = 0; i < hw->ports; i++) {
@@ -3446,11 +3453,13 @@ static void sky2_all_up(struct sky2_hw *
 		netif_wake_queue(dev);
 	}
 
-	sky2_write32(hw, B0_IMSK, imask);
-	sky2_read32(hw, B0_IMSK);
-
-	sky2_read32(hw, B0_Y2_SP_LISR);
-	napi_enable(&hw->napi);
+	if (imask || hw->ports > 1) {
+		imask |= Y2_IS_BASE;
+		sky2_write32(hw, B0_IMSK, imask);
+		sky2_read32(hw, B0_IMSK);
+		sky2_read32(hw, B0_Y2_SP_LISR);
+		napi_enable(&hw->napi);
+	}
 }
 
 static void sky2_restart(struct work_struct *work)

^ permalink raw reply

* under-performing bonded interfaces
From: Simon Chen @ 2011-11-16 23:44 UTC (permalink / raw)
  To: netdev

Hello,

I am bonding two 10G interfaces (ixgbe driver) under Debian 6.0.2. The
bonded interface for some reason can only achieve 12Gbps aggregated
throughput. If a single NIC is used, I can get close to 10Gbps.

I've tried different bonding modes (balance-xor, 802.3ad, balance-alb,
balance-tlb), and different xmit hashing policy (layer2, layer2+3,
layer3+4). I've increased all types of kernel parameters for TCP. MTU
on the physical and bonded interface is set to 8000 and 9000. The MTU
on the switch is 9200+.

Instead of nperf (a single server), I also tried my own TCP sender and
receivers.

All those done, still only 12Gbps... How can I really achieve close to 20Gbps?

(I also tried cutting loose the switch in between, and also getting
12G, so not an issue with the switch.)

Thanks.
-Simon

^ permalink raw reply

* Re: [PATCH V2] Add ethtool to mii advertisment conversion helpers
From: David Miller @ 2011-11-16 23:40 UTC (permalink / raw)
  To: mcarlson; +Cc: netdev, mchan
In-Reply-To: <1321486057-30968-1-git-send-email-mcarlson@broadcom.com>

From: "Matt Carlson" <mcarlson@broadcom.com>
Date: Wed, 16 Nov 2011 15:27:37 -0800

> Translating between ethtool advertisement settings and MII
> advertisements are common operations for ethernet drivers.  This patch
> adds a set of helper functions that implements the conversion.  The
> patch then modifies a couple of the drivers to use the new functions.
> 
> Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
> Signed-off-by: Michael Chan <mchan@broadcom.com>

Looks better, applied, thanks :)

^ permalink raw reply

* Re: [PATCH v5 5/9] net: Define enum for net device features.
From: Michał Mirosław @ 2011-11-16 23:34 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: netdev, David S. Miller
In-Reply-To: <1321483177.2709.28.camel@bwh-desktop>

On Wed, Nov 16, 2011 at 10:39:37PM +0000, Ben Hutchings wrote:
> On Wed, 2011-11-16 at 02:29 +0100, Michał Mirosław wrote:
> > Define feature values by bit position instead of direct 2**i values
> > and force the values to be of type netdev_features_t.
> > 
> > Cleaned and extended from patch by Mahesh Bandewar <maheshb@google.com>:
> > + added netdev_features_t casts
> > + included bits under NETIF_F_GSO_MASK
> > + moved feature #defines out of struct net_device definition
> > 
> > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> > ---
> >  include/linux/netdev_features.h |  129 +++++++++++++++++++++++++++-----------
> >  1 files changed, 91 insertions(+), 38 deletions(-)
> > 
> > diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
> > index af52381..04ac8f8 100644
> > --- a/include/linux/netdev_features.h
> > +++ b/include/linux/netdev_features.h
> [...]
> > +	/**/NETIF_F_GSO_SHIFT,		/* keep the order of SKB_GSO_* bits */
> > +	NETIF_F_TSO_BIT			/* ... TCPv4 segmentation */
> > +		= NETIF_F_GSO_SHIFT,
> > +	NETIF_F_UFO_BIT,		/* ... UDPv4 fragmentation */
> > +	NETIF_F_GSO_ROBUST_BIT,		/* ... ->SKB_GSO_DODGY */
> > +	NETIF_F_TSO_ECN_BIT,		/* ... TCP ECN support */
> > +	NETIF_F_TSO6_BIT,		/* ... TCPv6 segmentation */
> > +	NETIF_F_FSO_BIT,		/* ... FCoE segmentation */
> > +	NETIF_F_GSO_RESERVED1,		/* ... free (fill GSO_MASK to 8 bits) */
> > +	/**/NETIF_F_GSO_LAST,		/* [can't be last bit, see GSO_MASK] */
> > +	NETIF_F_GSO_RESERVED2		/* ... free (fill GSO_MASK to 8 bits) */
> > +		= NETIF_F_GSO_LAST,
> >  
> > -/* Segmentation offload features */
> > -#define NETIF_F_GSO_SHIFT	16
> > -#define NETIF_F_GSO_MASK	0x00ff0000
> > -#define NETIF_F_TSO		(SKB_GSO_TCPV4 << NETIF_F_GSO_SHIFT)
> > -#define NETIF_F_UFO		(SKB_GSO_UDP << NETIF_F_GSO_SHIFT)
> > -#define NETIF_F_GSO_ROBUST	(SKB_GSO_DODGY << NETIF_F_GSO_SHIFT)
> > -#define NETIF_F_TSO_ECN		(SKB_GSO_TCP_ECN << NETIF_F_GSO_SHIFT)
> > -#define NETIF_F_TSO6		(SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT)
> > -#define NETIF_F_FSO		(SKB_GSO_FCOE << NETIF_F_GSO_SHIFT)
> [...]
> 
> You should either add BUILD_BUG_ON()s somewhere to ensure that the
> netdev feature and skb GSO flags remain in sync, or redefine the skb GSO
> flags using the netdev feature flags (which I thought was the reason for
> moving features to their own header).

Main motiviation for the moving out of features to separate headers was
to avoid circular inclusion of linux/netdevice.h from linux/skbuff.h.
We get readability for free.

BUILD_BUG_ON() is a good idea. It should go to skbuff.h and as separate
patch as it's something new and independent.

Best Regards,
Michał Mirosław

^ permalink raw reply

* Re: [net-next 0/8][pull request] Intel Wired LAN Driver Updates
From: David Miller @ 2011-11-16 23:32 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: netdev, gospo, sassmann
In-Reply-To: <1321485682.2304.17.camel@jtkirshe-mobl>

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Wed, 16 Nov 2011 15:21:22 -0800

> On Wed, 2011-11-16 at 15:12 -0800, David Miller wrote:
>> From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
>> Date: Wed, 16 Nov 2011 04:51:24 -0800
>> 
>> > The following are changes since commit 229a66e3bec97563aa92e25dfe0bc60b0d468619:
>> >   IPv6: Removing unnecessary NULL checks.
>> > and are available in the git repository at:
>> >   git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-organize master
>> 
>> This tree doesn't exist.
> 
> That was supposed to be
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-next master

That works better, pulled, thanks!

^ permalink raw reply

* [PATCH V2] Add ethtool to mii advertisment conversion helpers
From: Matt Carlson @ 2011-11-16 23:27 UTC (permalink / raw)
  To: davem; +Cc: netdev, mcarlson, Michael Chan

Translating between ethtool advertisement settings and MII
advertisements are common operations for ethernet drivers.  This patch
adds a set of helper functions that implements the conversion.  The
patch then modifies a couple of the drivers to use the new functions.

Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
---

Changes in V2:
	* Added '#include <linux/ethtool.h>' to mii.h

 drivers/net/ethernet/broadcom/bnx2.c |   15 +---
 drivers/net/ethernet/broadcom/tg3.c  |   53 +++--------
 drivers/net/ethernet/sun/niu.c       |   15 +---
 drivers/net/mii.c                    |   48 ++--------
 drivers/net/phy/phy_device.c         |   20 +----
 include/linux/mii.h                  |  166 ++++++++++++++++++++++++++++++++++
 6 files changed, 197 insertions(+), 120 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
index 32d1f92..e82b981 100644
--- a/drivers/net/ethernet/broadcom/bnx2.c
+++ b/drivers/net/ethernet/broadcom/bnx2.c
@@ -2064,21 +2064,12 @@ __acquires(&bp->phy_lock)
 		bnx2_read_phy(bp, MII_CTRL1000, &adv1000_reg);
 		adv1000_reg &= PHY_ALL_1000_SPEED;
 
-		if (bp->advertising & ADVERTISED_10baseT_Half)
-			new_adv_reg |= ADVERTISE_10HALF;
-		if (bp->advertising & ADVERTISED_10baseT_Full)
-			new_adv_reg |= ADVERTISE_10FULL;
-		if (bp->advertising & ADVERTISED_100baseT_Half)
-			new_adv_reg |= ADVERTISE_100HALF;
-		if (bp->advertising & ADVERTISED_100baseT_Full)
-			new_adv_reg |= ADVERTISE_100FULL;
-		if (bp->advertising & ADVERTISED_1000baseT_Full)
-			new_adv1000_reg |= ADVERTISE_1000FULL;
-
+		new_adv_reg = ethtool_adv_to_mii_100bt(bp->advertising);
 		new_adv_reg |= ADVERTISE_CSMA;
-
 		new_adv_reg |= bnx2_phy_get_pause_adv(bp);
 
+		new_adv1000_reg |= ethtool_adv_to_mii_1000T(bp->advertising);
+
 		if ((adv1000_reg != new_adv1000_reg) ||
 			(adv_reg != new_adv_reg) ||
 			((bmcr & BMCR_ANENABLE) == 0)) {
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index cd36234..b329459 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -3594,15 +3594,7 @@ static int tg3_phy_autoneg_cfg(struct tg3 *tp, u32 advertise, u32 flowctrl)
 	u32 val, new_adv;
 
 	new_adv = ADVERTISE_CSMA;
-	if (advertise & ADVERTISED_10baseT_Half)
-		new_adv |= ADVERTISE_10HALF;
-	if (advertise & ADVERTISED_10baseT_Full)
-		new_adv |= ADVERTISE_10FULL;
-	if (advertise & ADVERTISED_100baseT_Half)
-		new_adv |= ADVERTISE_100HALF;
-	if (advertise & ADVERTISED_100baseT_Full)
-		new_adv |= ADVERTISE_100FULL;
-
+	new_adv |= ethtool_adv_to_mii_100bt(advertise);
 	new_adv |= tg3_advert_flowctrl_1000T(flowctrl);
 
 	err = tg3_writephy(tp, MII_ADVERTISE, new_adv);
@@ -3612,11 +3604,7 @@ static int tg3_phy_autoneg_cfg(struct tg3 *tp, u32 advertise, u32 flowctrl)
 	if (tp->phy_flags & TG3_PHYFLG_10_100_ONLY)
 		goto done;
 
-	new_adv = 0;
-	if (advertise & ADVERTISED_1000baseT_Half)
-		new_adv |= ADVERTISE_1000HALF;
-	if (advertise & ADVERTISED_1000baseT_Full)
-		new_adv |= ADVERTISE_1000FULL;
+	new_adv = ethtool_adv_to_mii_1000T(advertise);
 
 	if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0 ||
 	    tp->pci_chip_rev_id == CHIPREV_ID_5701_B0)
@@ -3790,14 +3778,7 @@ static int tg3_copper_is_advertising_all(struct tg3 *tp, u32 mask)
 {
 	u32 adv_reg, all_mask = 0;
 
-	if (mask & ADVERTISED_10baseT_Half)
-		all_mask |= ADVERTISE_10HALF;
-	if (mask & ADVERTISED_10baseT_Full)
-		all_mask |= ADVERTISE_10FULL;
-	if (mask & ADVERTISED_100baseT_Half)
-		all_mask |= ADVERTISE_100HALF;
-	if (mask & ADVERTISED_100baseT_Full)
-		all_mask |= ADVERTISE_100FULL;
+	all_mask = ethtool_adv_to_mii_100bt(mask);
 
 	if (tg3_readphy(tp, MII_ADVERTISE, &adv_reg))
 		return 0;
@@ -3808,11 +3789,7 @@ static int tg3_copper_is_advertising_all(struct tg3 *tp, u32 mask)
 	if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY)) {
 		u32 tg3_ctrl;
 
-		all_mask = 0;
-		if (mask & ADVERTISED_1000baseT_Half)
-			all_mask |= ADVERTISE_1000HALF;
-		if (mask & ADVERTISED_1000baseT_Full)
-			all_mask |= ADVERTISE_1000FULL;
+		all_mask = ethtool_adv_to_mii_1000T(mask);
 
 		if (tg3_readphy(tp, MII_CTRL1000, &tg3_ctrl))
 			return 0;
@@ -4903,23 +4880,19 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset)
 	    (tp->phy_flags & TG3_PHYFLG_PARALLEL_DETECT)) {
 		/* do nothing, just check for link up at the end */
 	} else if (tp->link_config.autoneg == AUTONEG_ENABLE) {
-		u32 adv, new_adv;
+		u32 adv, newadv;
 
 		err |= tg3_readphy(tp, MII_ADVERTISE, &adv);
-		new_adv = adv & ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF |
-				  ADVERTISE_1000XPAUSE |
-				  ADVERTISE_1000XPSE_ASYM |
-				  ADVERTISE_SLCT);
-
-		new_adv |= tg3_advert_flowctrl_1000X(tp->link_config.flowctrl);
+		newadv = adv & ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF |
+				 ADVERTISE_1000XPAUSE |
+				 ADVERTISE_1000XPSE_ASYM |
+				 ADVERTISE_SLCT);
 
-		if (tp->link_config.advertising & ADVERTISED_1000baseT_Half)
-			new_adv |= ADVERTISE_1000XHALF;
-		if (tp->link_config.advertising & ADVERTISED_1000baseT_Full)
-			new_adv |= ADVERTISE_1000XFULL;
+		newadv |= tg3_advert_flowctrl_1000X(tp->link_config.flowctrl);
+		newadv |= ethtool_adv_to_mii_1000X(tp->link_config.advertising);
 
-		if ((new_adv != adv) || !(bmcr & BMCR_ANENABLE)) {
-			tg3_writephy(tp, MII_ADVERTISE, new_adv);
+		if ((newadv != adv) || !(bmcr & BMCR_ANENABLE)) {
+			tg3_writephy(tp, MII_ADVERTISE, newadv);
 			bmcr |= BMCR_ANENABLE | BMCR_ANRESTART;
 			tg3_writephy(tp, MII_BMCR, bmcr);
 
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
index 3ebeb9d..9997be5 100644
--- a/drivers/net/ethernet/sun/niu.c
+++ b/drivers/net/ethernet/sun/niu.c
@@ -1151,19 +1151,8 @@ static int link_status_mii(struct niu *np, int *link_up_p)
 		supported |= SUPPORTED_1000baseT_Full;
 	lp->supported = supported;
 
-	advertising = 0;
-	if (advert & ADVERTISE_10HALF)
-		advertising |= ADVERTISED_10baseT_Half;
-	if (advert & ADVERTISE_10FULL)
-		advertising |= ADVERTISED_10baseT_Full;
-	if (advert & ADVERTISE_100HALF)
-		advertising |= ADVERTISED_100baseT_Half;
-	if (advert & ADVERTISE_100FULL)
-		advertising |= ADVERTISED_100baseT_Full;
-	if (ctrl1000 & ADVERTISE_1000HALF)
-		advertising |= ADVERTISED_1000baseT_Half;
-	if (ctrl1000 & ADVERTISE_1000FULL)
-		advertising |= ADVERTISED_1000baseT_Full;
+	advertising = mii_adv_to_ethtool_100bt(advert);
+	advertising |= mii_adv_to_ethtool_1000T(ctrl1000);
 
 	if (bmcr & BMCR_ANENABLE) {
 		int neg, neg1000;
diff --git a/drivers/net/mii.c b/drivers/net/mii.c
index c62e781..d0a2962 100644
--- a/drivers/net/mii.c
+++ b/drivers/net/mii.c
@@ -41,20 +41,8 @@ static u32 mii_get_an(struct mii_if_info *mii, u16 addr)
 	advert = mii->mdio_read(mii->dev, mii->phy_id, addr);
 	if (advert & LPA_LPACK)
 		result |= ADVERTISED_Autoneg;
-	if (advert & ADVERTISE_10HALF)
-		result |= ADVERTISED_10baseT_Half;
-	if (advert & ADVERTISE_10FULL)
-		result |= ADVERTISED_10baseT_Full;
-	if (advert & ADVERTISE_100HALF)
-		result |= ADVERTISED_100baseT_Half;
-	if (advert & ADVERTISE_100FULL)
-		result |= ADVERTISED_100baseT_Full;
-	if (advert & ADVERTISE_PAUSE_CAP)
-		result |= ADVERTISED_Pause;
-	if (advert & ADVERTISE_PAUSE_ASYM)
-		result |= ADVERTISED_Asym_Pause;
-
-	return result;
+
+	return result | mii_adv_to_ethtool_100bt(advert);
 }
 
 /**
@@ -104,19 +92,13 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
 		ecmd->autoneg = AUTONEG_ENABLE;
 
 		ecmd->advertising |= mii_get_an(mii, MII_ADVERTISE);
-		if (ctrl1000 & ADVERTISE_1000HALF)
-			ecmd->advertising |= ADVERTISED_1000baseT_Half;
-		if (ctrl1000 & ADVERTISE_1000FULL)
-			ecmd->advertising |= ADVERTISED_1000baseT_Full;
+		if (mii->supports_gmii)
+			ecmd->advertising |= mii_adv_to_ethtool_1000T(ctrl1000);
 
 		if (bmsr & BMSR_ANEGCOMPLETE) {
 			ecmd->lp_advertising = mii_get_an(mii, MII_LPA);
-			if (stat1000 & LPA_1000HALF)
-				ecmd->lp_advertising |=
-					ADVERTISED_1000baseT_Half;
-			if (stat1000 & LPA_1000FULL)
-				ecmd->lp_advertising |=
-					ADVERTISED_1000baseT_Full;
+			ecmd->lp_advertising |=
+					     mii_lpa_to_ethtool_1000T(stat1000);
 		} else {
 			ecmd->lp_advertising = 0;
 		}
@@ -204,20 +186,10 @@ int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
 			advert2 = mii->mdio_read(dev, mii->phy_id, MII_CTRL1000);
 			tmp2 = advert2 & ~(ADVERTISE_1000HALF | ADVERTISE_1000FULL);
 		}
-		if (ecmd->advertising & ADVERTISED_10baseT_Half)
-			tmp |= ADVERTISE_10HALF;
-		if (ecmd->advertising & ADVERTISED_10baseT_Full)
-			tmp |= ADVERTISE_10FULL;
-		if (ecmd->advertising & ADVERTISED_100baseT_Half)
-			tmp |= ADVERTISE_100HALF;
-		if (ecmd->advertising & ADVERTISED_100baseT_Full)
-			tmp |= ADVERTISE_100FULL;
-		if (mii->supports_gmii) {
-			if (ecmd->advertising & ADVERTISED_1000baseT_Half)
-				tmp2 |= ADVERTISE_1000HALF;
-			if (ecmd->advertising & ADVERTISED_1000baseT_Full)
-				tmp2 |= ADVERTISE_1000FULL;
-		}
+		tmp |= ethtool_adv_to_mii_100bt(ecmd->advertising);
+
+		if (mii->supports_gmii)
+			tmp2 |= ethtool_adv_to_mii_1000T(ecmd->advertising);
 		if (advert != tmp) {
 			mii->mdio_write(dev, mii->phy_id, MII_ADVERTISE, tmp);
 			mii->advertising = tmp;
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 83a5a5a..edb905f 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -563,20 +563,9 @@ static int genphy_config_advert(struct phy_device *phydev)
 	if (adv < 0)
 		return adv;
 
-	adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_PAUSE_CAP | 
+	adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_PAUSE_CAP |
 		 ADVERTISE_PAUSE_ASYM);
-	if (advertise & ADVERTISED_10baseT_Half)
-		adv |= ADVERTISE_10HALF;
-	if (advertise & ADVERTISED_10baseT_Full)
-		adv |= ADVERTISE_10FULL;
-	if (advertise & ADVERTISED_100baseT_Half)
-		adv |= ADVERTISE_100HALF;
-	if (advertise & ADVERTISED_100baseT_Full)
-		adv |= ADVERTISE_100FULL;
-	if (advertise & ADVERTISED_Pause)
-		adv |= ADVERTISE_PAUSE_CAP;
-	if (advertise & ADVERTISED_Asym_Pause)
-		adv |= ADVERTISE_PAUSE_ASYM;
+	adv |= ethtool_adv_to_mii_100bt(advertise);
 
 	if (adv != oldadv) {
 		err = phy_write(phydev, MII_ADVERTISE, adv);
@@ -595,10 +584,7 @@ static int genphy_config_advert(struct phy_device *phydev)
 			return adv;
 
 		adv &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF);
-		if (advertise & SUPPORTED_1000baseT_Half)
-			adv |= ADVERTISE_1000HALF;
-		if (advertise & SUPPORTED_1000baseT_Full)
-			adv |= ADVERTISE_1000FULL;
+		adv |= ethtool_adv_to_mii_1000T(advertise);
 
 		if (adv != oldadv) {
 			err = phy_write(phydev, MII_CTRL1000, adv);
diff --git a/include/linux/mii.h b/include/linux/mii.h
index 2774823..6697b91 100644
--- a/include/linux/mii.h
+++ b/include/linux/mii.h
@@ -9,6 +9,7 @@
 #define __LINUX_MII_H__
 
 #include <linux/types.h>
+#include <linux/ethtool.h>
 
 /* Generic MII registers. */
 #define MII_BMCR		0x00	/* Basic mode control register */
@@ -240,6 +241,171 @@ static inline unsigned int mii_duplex (unsigned int duplex_lock,
 }
 
 /**
+ * ethtool_adv_to_mii_100bt
+ * @ethadv: the ethtool advertisement settings
+ *
+ * A small helper function that translates ethtool advertisement
+ * settings to phy autonegotiation advertisements for the
+ * MII_ADVERTISE register.
+ */
+static inline u32 ethtool_adv_to_mii_100bt(u32 ethadv)
+{
+	u32 result = 0;
+
+	if (ethadv & ADVERTISED_10baseT_Half)
+		result |= ADVERTISE_10HALF;
+	if (ethadv & ADVERTISED_10baseT_Full)
+		result |= ADVERTISE_10FULL;
+	if (ethadv & ADVERTISED_100baseT_Half)
+		result |= ADVERTISE_100HALF;
+	if (ethadv & ADVERTISED_100baseT_Full)
+		result |= ADVERTISE_100FULL;
+	if (ethadv & ADVERTISED_Pause)
+		result |= ADVERTISE_PAUSE_CAP;
+	if (ethadv & ADVERTISED_Asym_Pause)
+		result |= ADVERTISE_PAUSE_ASYM;
+
+	return result;
+}
+
+/**
+ * mii_adv_to_ethtool_100bt
+ * @adv: value of the MII_ADVERTISE register
+ *
+ * A small helper function that translates MII_ADVERTISE bits
+ * to ethtool advertisement settings.
+ */
+static inline u32 mii_adv_to_ethtool_100bt(u32 adv)
+{
+	u32 result = 0;
+
+	if (adv & ADVERTISE_10HALF)
+		result |= ADVERTISED_10baseT_Half;
+	if (adv & ADVERTISE_10FULL)
+		result |= ADVERTISED_10baseT_Full;
+	if (adv & ADVERTISE_100HALF)
+		result |= ADVERTISED_100baseT_Half;
+	if (adv & ADVERTISE_100FULL)
+		result |= ADVERTISED_100baseT_Full;
+	if (adv & ADVERTISE_PAUSE_CAP)
+		result |= ADVERTISED_Pause;
+	if (adv & ADVERTISE_PAUSE_ASYM)
+		result |= ADVERTISED_Asym_Pause;
+
+	return result;
+}
+
+/**
+ * ethtool_adv_to_mii_1000T
+ * @ethadv: the ethtool advertisement settings
+ *
+ * A small helper function that translates ethtool advertisement
+ * settings to phy autonegotiation advertisements for the
+ * MII_CTRL1000 register when in 1000T mode.
+ */
+static inline u32 ethtool_adv_to_mii_1000T(u32 ethadv)
+{
+	u32 result = 0;
+
+	if (ethadv & ADVERTISED_1000baseT_Half)
+		result |= ADVERTISE_1000HALF;
+	if (ethadv & ADVERTISED_1000baseT_Full)
+		result |= ADVERTISE_1000FULL;
+
+	return result;
+}
+
+/**
+ * mii_adv_to_ethtool_1000T
+ * @adv: value of the MII_CTRL1000 register
+ *
+ * A small helper function that translates MII_CTRL1000
+ * bits, when in 1000Base-T mode, to ethtool
+ * advertisement settings.
+ */
+static inline u32 mii_adv_to_ethtool_1000T(u32 adv)
+{
+	u32 result = 0;
+
+	if (adv & ADVERTISE_1000HALF)
+		result |= ADVERTISED_1000baseT_Half;
+	if (adv & ADVERTISE_1000FULL)
+		result |= ADVERTISED_1000baseT_Full;
+
+	return result;
+}
+
+#define mii_lpa_to_ethtool_100bt(lpa)	mii_adv_to_ethtool_100bt(lpa)
+
+/**
+ * mii_lpa_to_ethtool_1000T
+ * @adv: value of the MII_STAT1000 register
+ *
+ * A small helper function that translates MII_STAT1000
+ * bits, when in 1000Base-T mode, to ethtool
+ * advertisement settings.
+ */
+static inline u32 mii_lpa_to_ethtool_1000T(u32 lpa)
+{
+	u32 result = 0;
+
+	if (lpa & LPA_1000HALF)
+		result |= ADVERTISED_1000baseT_Half;
+	if (lpa & LPA_1000FULL)
+		result |= ADVERTISED_1000baseT_Full;
+
+	return result;
+}
+
+/**
+ * ethtool_adv_to_mii_1000X
+ * @ethadv: the ethtool advertisement settings
+ *
+ * A small helper function that translates ethtool advertisement
+ * settings to phy autonegotiation advertisements for the
+ * MII_CTRL1000 register when in 1000Base-X mode.
+ */
+static inline u32 ethtool_adv_to_mii_1000X(u32 ethadv)
+{
+	u32 result = 0;
+
+	if (ethadv & ADVERTISED_1000baseT_Half)
+		result |= ADVERTISE_1000XHALF;
+	if (ethadv & ADVERTISED_1000baseT_Full)
+		result |= ADVERTISE_1000XFULL;
+	if (ethadv & ADVERTISED_Pause)
+		result |= ADVERTISE_1000XPAUSE;
+	if (ethadv & ADVERTISED_Asym_Pause)
+		result |= ADVERTISE_1000XPSE_ASYM;
+
+	return result;
+}
+
+/**
+ * mii_adv_to_ethtool_1000X
+ * @adv: value of the MII_CTRL1000 register
+ *
+ * A small helper function that translates MII_CTRL1000
+ * bits, when in 1000Base-X mode, to ethtool
+ * advertisement settings.
+ */
+static inline u32 mii_adv_to_ethtool_1000X(u32 adv)
+{
+	u32 result = 0;
+
+	if (adv & ADVERTISE_1000XHALF)
+		result |= ADVERTISED_1000baseT_Half;
+	if (adv & ADVERTISE_1000XFULL)
+		result |= ADVERTISED_1000baseT_Full;
+	if (adv & ADVERTISE_1000XPAUSE)
+		result |= ADVERTISED_Pause;
+	if (adv & ADVERTISE_1000XPSE_ASYM)
+		result |= ADVERTISED_Asym_Pause;
+
+	return result;
+}
+
+/**
  * mii_advertise_flowctrl - get flow control advertisement flags
  * @cap: Flow control capabilities (FLOW_CTRL_RX, FLOW_CTRL_TX or both)
  */
-- 
1.7.3.4

^ permalink raw reply related

* Re: [net-next 0/8][pull request] Intel Wired LAN Driver Updates
From: Jeff Kirsher @ 2011-11-16 23:21 UTC (permalink / raw)
  To: David Miller
  Cc: netdev@vger.kernel.org, gospo@redhat.com, sassmann@redhat.com
In-Reply-To: <20111116.181256.1949478047386386920.davem@davemloft.net>

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

On Wed, 2011-11-16 at 15:12 -0800, David Miller wrote:
> From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> Date: Wed, 16 Nov 2011 04:51:24 -0800
> 
> > The following are changes since commit 229a66e3bec97563aa92e25dfe0bc60b0d468619:
> >   IPv6: Removing unnecessary NULL checks.
> > and are available in the git repository at:
> >   git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-organize master
> 
> This tree doesn't exist.

That was supposed to be

git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-next master

sorry Dave.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox