Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH net-next] net: napi_frags_skb() is static
From: David Miller @ 2012-05-19  6:51 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev
In-Reply-To: <1337410146.7029.71.camel@edumazet-glaptop>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Sat, 19 May 2012 08:49:06 +0200

> From: Eric Dumazet <edumazet@google.com>
> 
> No need to export napi_frags_skb()
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Applied.

^ permalink raw reply

* [PATCH net-next] net: napi_frags_skb() is static
From: Eric Dumazet @ 2012-05-19  6:49 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

From: Eric Dumazet <edumazet@google.com>

No need to export napi_frags_skb()

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/linux/netdevice.h |    1 -
 net/core/dev.c            |    3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 9c710bd..e7fd468 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2142,7 +2142,6 @@ extern struct sk_buff *	napi_get_frags(struct napi_struct *napi);
 extern gro_result_t	napi_frags_finish(struct napi_struct *napi,
 					  struct sk_buff *skb,
 					  gro_result_t ret);
-extern struct sk_buff *	napi_frags_skb(struct napi_struct *napi);
 extern gro_result_t	napi_gro_frags(struct napi_struct *napi);
 
 static inline void napi_free_frags(struct napi_struct *napi)
diff --git a/net/core/dev.c b/net/core/dev.c
index 33684b6..cd09819 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3602,7 +3602,7 @@ gro_result_t napi_frags_finish(struct napi_struct *napi, struct sk_buff *skb,
 }
 EXPORT_SYMBOL(napi_frags_finish);
 
-struct sk_buff *napi_frags_skb(struct napi_struct *napi)
+static struct sk_buff *napi_frags_skb(struct napi_struct *napi)
 {
 	struct sk_buff *skb = napi->skb;
 	struct ethhdr *eth;
@@ -3637,7 +3637,6 @@ struct sk_buff *napi_frags_skb(struct napi_struct *napi)
 out:
 	return skb;
 }
-EXPORT_SYMBOL(napi_frags_skb);
 
 gro_result_t napi_gro_frags(struct napi_struct *napi)
 {

^ permalink raw reply related

* Re: ppp/l2tp doing oversized allocations ?
From: David Miller @ 2012-05-19  6:34 UTC (permalink / raw)
  To: eric.dumazet; +Cc: davej, netdev, kernel-team, edumazet
In-Reply-To: <1337408730.7029.69.camel@edumazet-glaptop>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Sat, 19 May 2012 08:25:30 +0200

> On Sat, 2012-05-19 at 07:01 +0200, Eric Dumazet wrote:
>> On Sat, 2012-05-19 at 00:46 -0400, David Miller wrote:
>> 
>> > So it's ESP encapsulated IPSEC over L2tp.
>> > 
>> > Eric, I wonder if session->hdr_len can take on undesirable values and
>> > thus trip up the skb COW'ing calculations you added?
>> 
>> I take a look, thanks
>> 
> 
> hdr_len is u16, I have no idea how we can reach MAX_ORDER page
> allocations... (more than 2 Mbytes...)
> 
> Maybe a memory corruption, or a signed/unsigned mismatch.

Yes, the trace looks really weird to me too.

It's also possible that the big length comes accidently from IPSEC
too.

If this can be readily reproduced, we can construct some debugging
patches for the user to try.

^ permalink raw reply

* Re: [PATCH net-next] ppp: avoid false drop_monitor false positives
From: David Miller @ 2012-05-19  6:33 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev
In-Reply-To: <1337408580.7029.66.camel@edumazet-glaptop>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Sat, 19 May 2012 08:23:00 +0200

> From: Eric Dumazet <edumazet@google.com>
> 
> Call consume_skb() in place of kfree_skb() were appropriate.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Applied, thanks Eric.

^ permalink raw reply

* Re: ppp/l2tp doing oversized allocations ?
From: Eric Dumazet @ 2012-05-19  6:25 UTC (permalink / raw)
  To: David Miller; +Cc: davej, netdev, kernel-team, edumazet
In-Reply-To: <1337403685.7029.63.camel@edumazet-glaptop>

On Sat, 2012-05-19 at 07:01 +0200, Eric Dumazet wrote:
> On Sat, 2012-05-19 at 00:46 -0400, David Miller wrote:
> 
> > So it's ESP encapsulated IPSEC over L2tp.
> > 
> > Eric, I wonder if session->hdr_len can take on undesirable values and
> > thus trip up the skb COW'ing calculations you added?
> 
> I take a look, thanks
> 

hdr_len is u16, I have no idea how we can reach MAX_ORDER page
allocations... (more than 2 Mbytes...)

Maybe a memory corruption, or a signed/unsigned mismatch.

^ permalink raw reply

* [PATCH net-next] ppp: avoid false drop_monitor false positives
From: Eric Dumazet @ 2012-05-19  6:23 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

From: Eric Dumazet <edumazet@google.com>

Call consume_skb() in place of kfree_skb() were appropriate.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 drivers/net/ppp/ppp_async.c   |    2 +-
 drivers/net/ppp/ppp_generic.c |   14 +++++++-------
 drivers/net/ppp/ppp_synctty.c |    4 ++--
 drivers/net/ppp/pppoe.c       |    6 ++++--
 drivers/net/ppp/pptp.c        |    2 +-
 5 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c
index af95a98..a031f6b 100644
--- a/drivers/net/ppp/ppp_async.c
+++ b/drivers/net/ppp/ppp_async.c
@@ -613,7 +613,7 @@ ppp_async_encode(struct asyncppp *ap)
 	*buf++ = PPP_FLAG;
 	ap->olim = buf;
 
-	kfree_skb(ap->tpkt);
+	consume_skb(ap->tpkt);
 	ap->tpkt = NULL;
 	return 1;
 }
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 21d7151..5c05572 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -1092,13 +1092,13 @@ pad_compress_skb(struct ppp *ppp, struct sk_buff *skb)
 				   new_skb->data, skb->len + 2,
 				   compressor_skb_size);
 	if (len > 0 && (ppp->flags & SC_CCP_UP)) {
-		kfree_skb(skb);
+		consume_skb(skb);
 		skb = new_skb;
 		skb_put(skb, len);
 		skb_pull(skb, 2);	/* pull off A/C bytes */
 	} else if (len == 0) {
 		/* didn't compress, or CCP not up yet */
-		kfree_skb(new_skb);
+		consume_skb(new_skb);
 		new_skb = skb;
 	} else {
 		/*
@@ -1112,7 +1112,7 @@ pad_compress_skb(struct ppp *ppp, struct sk_buff *skb)
 		if (net_ratelimit())
 			netdev_err(ppp->dev, "ppp: compressor dropped pkt\n");
 		kfree_skb(skb);
-		kfree_skb(new_skb);
+		consume_skb(new_skb);
 		new_skb = NULL;
 	}
 	return new_skb;
@@ -1178,7 +1178,7 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
 				    !(ppp->flags & SC_NO_TCP_CCID));
 		if (cp == skb->data + 2) {
 			/* didn't compress */
-			kfree_skb(new_skb);
+			consume_skb(new_skb);
 		} else {
 			if (cp[0] & SL_TYPE_COMPRESSED_TCP) {
 				proto = PPP_VJC_COMP;
@@ -1187,7 +1187,7 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
 				proto = PPP_VJC_UNCOMP;
 				cp[0] = skb->data[2];
 			}
-			kfree_skb(skb);
+			consume_skb(skb);
 			skb = new_skb;
 			cp = skb_put(skb, len + 2);
 			cp[0] = 0;
@@ -1703,7 +1703,7 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
 			}
 			skb_reserve(ns, 2);
 			skb_copy_bits(skb, 0, skb_put(ns, skb->len), skb->len);
-			kfree_skb(skb);
+			consume_skb(skb);
 			skb = ns;
 		}
 		else
@@ -1851,7 +1851,7 @@ ppp_decompress_frame(struct ppp *ppp, struct sk_buff *skb)
 			goto err;
 		}
 
-		kfree_skb(skb);
+		consume_skb(skb);
 		skb = ns;
 		skb_put(skb, len);
 		skb_pull(skb, 2);	/* pull off the A/C bytes */
diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c
index 55e466c..1a12033 100644
--- a/drivers/net/ppp/ppp_synctty.c
+++ b/drivers/net/ppp/ppp_synctty.c
@@ -588,7 +588,7 @@ ppp_sync_txmunge(struct syncppp *ap, struct sk_buff *skb)
 			skb_reserve(npkt,2);
 			skb_copy_from_linear_data(skb,
 				      skb_put(npkt, skb->len), skb->len);
-			kfree_skb(skb);
+			consume_skb(skb);
 			skb = npkt;
 		}
 		skb_push(skb,2);
@@ -656,7 +656,7 @@ ppp_sync_push(struct syncppp *ap)
 			if (sent < ap->tpkt->len) {
 				tty_stuffed = 1;
 			} else {
-				kfree_skb(ap->tpkt);
+				consume_skb(ap->tpkt);
 				ap->tpkt = NULL;
 				clear_bit(XMIT_FULL, &ap->xmit_flags);
 				done = 1;
diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
index dd15b8f..cbf7047 100644
--- a/drivers/net/ppp/pppoe.c
+++ b/drivers/net/ppp/pppoe.c
@@ -984,8 +984,10 @@ static int pppoe_recvmsg(struct kiocb *iocb, struct socket *sock,
 	if (skb) {
 		total_len = min_t(size_t, total_len, skb->len);
 		error = skb_copy_datagram_iovec(skb, 0, m->msg_iov, total_len);
-		if (error == 0)
-			error = total_len;
+		if (error == 0) {
+			consume_skb(skb);
+			return total_len;
+		}
 	}
 
 	kfree_skb(skb);
diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
index 72b50f5..1c98321 100644
--- a/drivers/net/ppp/pptp.c
+++ b/drivers/net/ppp/pptp.c
@@ -209,7 +209,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
 		}
 		if (skb->sk)
 			skb_set_owner_w(new_skb, skb->sk);
-		kfree_skb(skb);
+		consume_skb(skb);
 		skb = new_skb;
 	}
 

^ permalink raw reply related

* Re: [PATCH v2 4/5] staging: octeon_ethernet: Convert to use device tree.
From: Grant Likely @ 2012-05-19  6:07 UTC (permalink / raw)
  To: David Daney, linux-mips, ralf, devicetree-discuss, Rob Herring
  Cc: linux-kernel, David Daney, netdev, Greg Kroah-Hartman,
	David S. Miller
In-Reply-To: <1335489630-27017-5-git-send-email-ddaney.cavm@gmail.com>

On Thu, 26 Apr 2012 18:20:29 -0700, David Daney <ddaney.cavm@gmail.com> wrote:
> From: David Daney <david.daney@cavium.com>
> 
> Get MAC address and PHY connection from the device tree.  The driver
> is converted to a platform driver.
> 
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: David Daney <david.daney@cavium.com>
> Cc: netdev@vger.kernel.org
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: David S. Miller <davem@davemloft.net>

Acked-by: Grant Likely <grant.likely@secretlab.ca>

^ permalink raw reply

* Re: [PATCH v2 2/5] netdev: mdio-octeon.c: Convert to use device tree.
From: Grant Likely @ 2012-05-19  6:06 UTC (permalink / raw)
  To: David Daney, linux-mips-6z/3iImG2C8G8FEW9MqTrA,
	ralf-6z/3iImG2C8G8FEW9MqTrA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Rob Herring
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, David S. Miller,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, David Daney
In-Reply-To: <1335489630-27017-3-git-send-email-ddaney.cavm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

On Thu, 26 Apr 2012 18:20:27 -0700, David Daney <ddaney.cavm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> From: David Daney <david.daney-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
> 
> Get the MDIO bus controller addresses from the device tree, small
> clean up in use of devm_*
> 
> Remove, now unused, platform device setup code.

Ditto on this one (and the others); make sure the new compatible value
is documented.  Otherwise looks good.

g.

^ permalink raw reply

* Re: [PATCH net-next] ipv6: bool/const conversions phase2
From: David Miller @ 2012-05-19  5:08 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev
In-Reply-To: <1337403454.7029.62.camel@edumazet-glaptop>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Sat, 19 May 2012 06:57:34 +0200

> From: Eric Dumazet <edumazet@google.com>
> 
> Mostly bool conversions, some inline removals and const additions.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Applied, thanks Eric.

^ permalink raw reply

* Re: ppp/l2tp doing oversized allocations ?
From: Eric Dumazet @ 2012-05-19  5:01 UTC (permalink / raw)
  To: David Miller; +Cc: davej, netdev, kernel-team, edumazet
In-Reply-To: <20120519.004652.2261671316587735315.davem@davemloft.net>

On Sat, 2012-05-19 at 00:46 -0400, David Miller wrote:

> So it's ESP encapsulated IPSEC over L2tp.
> 
> Eric, I wonder if session->hdr_len can take on undesirable values and
> thus trip up the skb COW'ing calculations you added?

I take a look, thanks

^ permalink raw reply

* [PATCH net-next] ipv6: bool/const conversions phase2
From: Eric Dumazet @ 2012-05-19  4:57 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

From: Eric Dumazet <edumazet@google.com>

Mostly bool conversions, some inline removals and const additions.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/net/addrconf.h   |   18 +++++-----
 include/net/ip6_route.h  |    2 -
 include/net/ipv6.h       |    2 -
 include/net/rawv6.h      |    2 -
 net/ipv6/addrlabel.c     |   24 ++++++-------
 net/ipv6/ah6.c           |    6 +--
 net/ipv6/anycast.c       |   12 +++---
 net/ipv6/datagram.c      |    4 +-
 net/ipv6/exthdrs.c       |   54 +++++++++++++++---------------
 net/ipv6/exthdrs_core.c  |    2 -
 net/ipv6/icmp.c          |   14 +++----
 net/ipv6/ip6_flowlabel.c |   24 ++++++-------
 net/ipv6/ip6_input.c     |    9 ++---
 net/ipv6/mcast.c         |   66 ++++++++++++++++++-------------------
 net/ipv6/ndisc.c         |    4 +-
 net/ipv6/raw.c           |   10 ++---
 net/ipv6/route.c         |    8 ++--
 17 files changed, 131 insertions(+), 130 deletions(-)

diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 27f450b..f2b801c 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -131,9 +131,9 @@ extern int ipv6_sock_mc_join(struct sock *sk, int ifindex,
 extern int ipv6_sock_mc_drop(struct sock *sk, int ifindex,
 			     const struct in6_addr *addr);
 extern void ipv6_sock_mc_close(struct sock *sk);
-extern int inet6_mc_check(struct sock *sk,
-			  const struct in6_addr *mc_addr,
-			  const struct in6_addr *src_addr);
+extern bool inet6_mc_check(struct sock *sk,
+			   const struct in6_addr *mc_addr,
+			   const struct in6_addr *src_addr);
 
 extern int ipv6_dev_mc_inc(struct net_device *dev, const struct in6_addr *addr);
 extern int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr);
@@ -146,10 +146,10 @@ extern void ipv6_mc_init_dev(struct inet6_dev *idev);
 extern void ipv6_mc_destroy_dev(struct inet6_dev *idev);
 extern void addrconf_dad_failure(struct inet6_ifaddr *ifp);
 
-extern int ipv6_chk_mcast_addr(struct net_device *dev,
-			       const struct in6_addr *group,
-			       const struct in6_addr *src_addr);
-extern int ipv6_is_mld(struct sk_buff *skb, int nexthdr);
+extern bool ipv6_chk_mcast_addr(struct net_device *dev,
+				const struct in6_addr *group,
+				const struct in6_addr *src_addr);
+extern bool ipv6_is_mld(struct sk_buff *skb, int nexthdr);
 
 extern void addrconf_prefix_rcv(struct net_device *dev,
 				u8 *opt, int len, bool sllao);
@@ -163,8 +163,8 @@ extern void ipv6_sock_ac_close(struct sock *sk);
 
 extern int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr);
 extern int __ipv6_dev_ac_dec(struct inet6_dev *idev, const struct in6_addr *addr);
-extern int ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
-			       const struct in6_addr *addr);
+extern bool ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
+				const struct in6_addr *addr);
 
 
 /* Device notifier */
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index c062b67..37c1a1e 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -175,7 +175,7 @@ static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst,
 	spin_unlock(&sk->sk_dst_lock);
 }
 
-static inline int ipv6_unicast_destination(struct sk_buff *skb)
+static inline bool ipv6_unicast_destination(const struct sk_buff *skb)
 {
 	struct rt6_info *rt = (struct rt6_info *) skb_dst(skb);
 
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 1402139..aecf884 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -559,7 +559,7 @@ extern void			ipv6_push_frag_opts(struct sk_buff *skb,
 extern int			ipv6_skip_exthdr(const struct sk_buff *, int start,
 					         u8 *nexthdrp, __be16 *frag_offp);
 
-extern int 			ipv6_ext_hdr(u8 nexthdr);
+extern bool			ipv6_ext_hdr(u8 nexthdr);
 
 extern int ipv6_find_tlv(struct sk_buff *skb, int offset, int type);
 
diff --git a/include/net/rawv6.h b/include/net/rawv6.h
index cf75772..e7ea660 100644
--- a/include/net/rawv6.h
+++ b/include/net/rawv6.h
@@ -5,7 +5,7 @@
 
 void raw6_icmp_error(struct sk_buff *, int nexthdr,
 		u8 type, u8 code, int inner_offset, __be32);
-int raw6_local_deliver(struct sk_buff *, int);
+bool raw6_local_deliver(struct sk_buff *, int);
 
 extern int			rawv6_rcv(struct sock *sk,
 					  struct sk_buff *skb);
diff --git a/net/ipv6/addrlabel.c b/net/ipv6/addrlabel.c
index 95aea16..eb6a636 100644
--- a/net/ipv6/addrlabel.c
+++ b/net/ipv6/addrlabel.c
@@ -129,7 +129,7 @@ static void ip6addrlbl_free_rcu(struct rcu_head *h)
 	ip6addrlbl_free(container_of(h, struct ip6addrlbl_entry, rcu));
 }
 
-static inline int ip6addrlbl_hold(struct ip6addrlbl_entry *p)
+static bool ip6addrlbl_hold(struct ip6addrlbl_entry *p)
 {
 	return atomic_inc_not_zero(&p->refcnt);
 }
@@ -141,20 +141,20 @@ static inline void ip6addrlbl_put(struct ip6addrlbl_entry *p)
 }
 
 /* Find label */
-static int __ip6addrlbl_match(struct net *net,
-			      struct ip6addrlbl_entry *p,
-			      const struct in6_addr *addr,
-			      int addrtype, int ifindex)
+static bool __ip6addrlbl_match(struct net *net,
+			       const struct ip6addrlbl_entry *p,
+			       const struct in6_addr *addr,
+			       int addrtype, int ifindex)
 {
 	if (!net_eq(ip6addrlbl_net(p), net))
-		return 0;
+		return false;
 	if (p->ifindex && p->ifindex != ifindex)
-		return 0;
+		return false;
 	if (p->addrtype && p->addrtype != addrtype)
-		return 0;
+		return false;
 	if (!ipv6_prefix_equal(addr, &p->prefix, p->prefixlen))
-		return 0;
-	return 1;
+		return false;
+	return true;
 }
 
 static struct ip6addrlbl_entry *__ipv6_addr_label(struct net *net,
@@ -456,8 +456,8 @@ static int ip6addrlbl_newdel(struct sk_buff *skb, struct nlmsghdr *nlh,
 	return err;
 }
 
-static inline void ip6addrlbl_putmsg(struct nlmsghdr *nlh,
-				     int prefixlen, int ifindex, u32 lseq)
+static void ip6addrlbl_putmsg(struct nlmsghdr *nlh,
+			      int prefixlen, int ifindex, u32 lseq)
 {
 	struct ifaddrlblmsg *ifal = nlmsg_data(nlh);
 	ifal->ifal_family = AF_INET6;
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c
index 5d32e7a..f1a4a2c 100644
--- a/net/ipv6/ah6.c
+++ b/net/ipv6/ah6.c
@@ -113,7 +113,7 @@ static inline struct scatterlist *ah_req_sg(struct crypto_ahash *ahash,
 			     __alignof__(struct scatterlist));
 }
 
-static int zero_out_mutable_opts(struct ipv6_opt_hdr *opthdr)
+static bool zero_out_mutable_opts(struct ipv6_opt_hdr *opthdr)
 {
 	u8 *opt = (u8 *)opthdr;
 	int len = ipv6_optlen(opthdr);
@@ -145,10 +145,10 @@ static int zero_out_mutable_opts(struct ipv6_opt_hdr *opthdr)
 		len -= optlen;
 	}
 	if (len == 0)
-		return 1;
+		return true;
 
 bad:
-	return 0;
+	return false;
 }
 
 #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c
index db00d27..cdf02be 100644
--- a/net/ipv6/anycast.c
+++ b/net/ipv6/anycast.c
@@ -342,7 +342,7 @@ static int ipv6_dev_ac_dec(struct net_device *dev, const struct in6_addr *addr)
  *	check if the interface has this anycast address
  *	called with rcu_read_lock()
  */
-static int ipv6_chk_acast_dev(struct net_device *dev, const struct in6_addr *addr)
+static bool ipv6_chk_acast_dev(struct net_device *dev, const struct in6_addr *addr)
 {
 	struct inet6_dev *idev;
 	struct ifacaddr6 *aca;
@@ -356,16 +356,16 @@ static int ipv6_chk_acast_dev(struct net_device *dev, const struct in6_addr *add
 		read_unlock_bh(&idev->lock);
 		return aca != NULL;
 	}
-	return 0;
+	return false;
 }
 
 /*
  *	check if given interface (or any, if dev==0) has this anycast address
  */
-int ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
-			const struct in6_addr *addr)
+bool ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
+			 const struct in6_addr *addr)
 {
-	int found = 0;
+	bool found = false;
 
 	rcu_read_lock();
 	if (dev)
@@ -373,7 +373,7 @@ int ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
 	else
 		for_each_netdev_rcu(net, dev)
 			if (ipv6_chk_acast_dev(dev, addr)) {
-				found = 1;
+				found = true;
 				break;
 			}
 	rcu_read_unlock();
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index b8b61ac..be2b67d6 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -34,9 +34,9 @@
 #include <linux/errqueue.h>
 #include <asm/uaccess.h>
 
-static inline int ipv6_mapped_addr_any(const struct in6_addr *a)
+static bool ipv6_mapped_addr_any(const struct in6_addr *a)
 {
-	return (ipv6_addr_v4mapped(a) && (a->s6_addr32[3] == 0));
+	return ipv6_addr_v4mapped(a) && (a->s6_addr32[3] == 0);
 }
 
 int ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index a3cded6..50ec95f 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -96,14 +96,14 @@ EXPORT_SYMBOL_GPL(ipv6_find_tlv);
 /*
  *	Parsing tlv encoded headers.
  *
- *	Parsing function "func" returns 1, if parsing succeed
- *	and 0, if it failed.
+ *	Parsing function "func" returns true, if parsing succeed
+ *	and false, if it failed.
  *	It MUST NOT touch skb->h.
  */
 
 struct tlvtype_proc {
 	int	type;
-	int	(*func)(struct sk_buff *skb, int offset);
+	bool	(*func)(struct sk_buff *skb, int offset);
 };
 
 /*********************
@@ -112,11 +112,11 @@ struct tlvtype_proc {
 
 /* An unknown option is detected, decide what to do */
 
-static int ip6_tlvopt_unknown(struct sk_buff *skb, int optoff)
+static bool ip6_tlvopt_unknown(struct sk_buff *skb, int optoff)
 {
 	switch ((skb_network_header(skb)[optoff] & 0xC0) >> 6) {
 	case 0: /* ignore */
-		return 1;
+		return true;
 
 	case 1: /* drop packet */
 		break;
@@ -129,18 +129,18 @@ static int ip6_tlvopt_unknown(struct sk_buff *skb, int optoff)
 			break;
 	case 2: /* send ICMP PARM PROB regardless and drop packet */
 		icmpv6_param_prob(skb, ICMPV6_UNK_OPTION, optoff);
-		return 0;
+		return false;
 	}
 
 	kfree_skb(skb);
-	return 0;
+	return false;
 }
 
 /* Parse tlv encoded option header (hop-by-hop or destination) */
 
-static int ip6_parse_tlv(struct tlvtype_proc *procs, struct sk_buff *skb)
+static bool ip6_parse_tlv(const struct tlvtype_proc *procs, struct sk_buff *skb)
 {
-	struct tlvtype_proc *curr;
+	const struct tlvtype_proc *curr;
 	const unsigned char *nh = skb_network_header(skb);
 	int off = skb_network_header_len(skb);
 	int len = (skb_transport_header(skb)[1] + 1) << 3;
@@ -186,14 +186,14 @@ static int ip6_parse_tlv(struct tlvtype_proc *procs, struct sk_buff *skb)
 					/* type specific length/alignment
 					   checks will be performed in the
 					   func(). */
-					if (curr->func(skb, off) == 0)
-						return 0;
+					if (curr->func(skb, off) == false)
+						return false;
 					break;
 				}
 			}
 			if (curr->type < 0) {
 				if (ip6_tlvopt_unknown(skb, off) == 0)
-					return 0;
+					return false;
 			}
 			break;
 		}
@@ -201,10 +201,10 @@ static int ip6_parse_tlv(struct tlvtype_proc *procs, struct sk_buff *skb)
 		len -= optlen;
 	}
 	if (len == 0)
-		return 1;
+		return true;
 bad:
 	kfree_skb(skb);
-	return 0;
+	return false;
 }
 
 /*****************************
@@ -212,7 +212,7 @@ bad:
  *****************************/
 
 #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
-static int ipv6_dest_hao(struct sk_buff *skb, int optoff)
+static bool ipv6_dest_hao(struct sk_buff *skb, int optoff)
 {
 	struct ipv6_destopt_hao *hao;
 	struct inet6_skb_parm *opt = IP6CB(skb);
@@ -266,15 +266,15 @@ static int ipv6_dest_hao(struct sk_buff *skb, int optoff)
 	if (skb->tstamp.tv64 == 0)
 		__net_timestamp(skb);
 
-	return 1;
+	return true;
 
  discard:
 	kfree_skb(skb);
-	return 0;
+	return false;
 }
 #endif
 
-static struct tlvtype_proc tlvprocdestopt_lst[] = {
+static const struct tlvtype_proc tlvprocdestopt_lst[] = {
 #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
 	{
 		.type	= IPV6_TLV_HAO,
@@ -579,23 +579,23 @@ static inline struct net *ipv6_skb_net(struct sk_buff *skb)
 
 /* Router Alert as of RFC 2711 */
 
-static int ipv6_hop_ra(struct sk_buff *skb, int optoff)
+static bool ipv6_hop_ra(struct sk_buff *skb, int optoff)
 {
 	const unsigned char *nh = skb_network_header(skb);
 
 	if (nh[optoff + 1] == 2) {
 		IP6CB(skb)->ra = optoff;
-		return 1;
+		return true;
 	}
 	LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_ra: wrong RA length %d\n",
 		       nh[optoff + 1]);
 	kfree_skb(skb);
-	return 0;
+	return false;
 }
 
 /* Jumbo payload */
 
-static int ipv6_hop_jumbo(struct sk_buff *skb, int optoff)
+static bool ipv6_hop_jumbo(struct sk_buff *skb, int optoff)
 {
 	const unsigned char *nh = skb_network_header(skb);
 	struct net *net = ipv6_skb_net(skb);
@@ -614,13 +614,13 @@ static int ipv6_hop_jumbo(struct sk_buff *skb, int optoff)
 		IP6_INC_STATS_BH(net, ipv6_skb_idev(skb),
 				 IPSTATS_MIB_INHDRERRORS);
 		icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff+2);
-		return 0;
+		return false;
 	}
 	if (ipv6_hdr(skb)->payload_len) {
 		IP6_INC_STATS_BH(net, ipv6_skb_idev(skb),
 				 IPSTATS_MIB_INHDRERRORS);
 		icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff);
-		return 0;
+		return false;
 	}
 
 	if (pkt_len > skb->len - sizeof(struct ipv6hdr)) {
@@ -632,14 +632,14 @@ static int ipv6_hop_jumbo(struct sk_buff *skb, int optoff)
 	if (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr)))
 		goto drop;
 
-	return 1;
+	return true;
 
 drop:
 	kfree_skb(skb);
-	return 0;
+	return false;
 }
 
-static struct tlvtype_proc tlvprochopopt_lst[] = {
+static const struct tlvtype_proc tlvprochopopt_lst[] = {
 	{
 		.type	= IPV6_TLV_ROUTERALERT,
 		.func	= ipv6_hop_ra,
diff --git a/net/ipv6/exthdrs_core.c b/net/ipv6/exthdrs_core.c
index 7b1a884..f73d59a 100644
--- a/net/ipv6/exthdrs_core.c
+++ b/net/ipv6/exthdrs_core.c
@@ -9,7 +9,7 @@
  * find out if nexthdr is a well-known extension header or a protocol
  */
 
-int ipv6_ext_hdr(u8 nexthdr)
+bool ipv6_ext_hdr(u8 nexthdr)
 {
 	/*
 	 * find out if nexthdr is an extension header or a protocol
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 23c56ce..091a297 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -131,7 +131,7 @@ void icmpv6_param_prob(struct sk_buff *skb, u8 code, int pos)
  *	--ANK (980726)
  */
 
-static int is_ineligible(struct sk_buff *skb)
+static bool is_ineligible(const struct sk_buff *skb)
 {
 	int ptr = (u8 *)(ipv6_hdr(skb) + 1) - skb->data;
 	int len = skb->len - ptr;
@@ -139,11 +139,11 @@ static int is_ineligible(struct sk_buff *skb)
 	__be16 frag_off;
 
 	if (len < 0)
-		return 1;
+		return true;
 
 	ptr = ipv6_skip_exthdr(skb, ptr, &nexthdr, &frag_off);
 	if (ptr < 0)
-		return 0;
+		return false;
 	if (nexthdr == IPPROTO_ICMPV6) {
 		u8 _type, *tp;
 		tp = skb_header_pointer(skb,
@@ -151,9 +151,9 @@ static int is_ineligible(struct sk_buff *skb)
 			sizeof(_type), &_type);
 		if (tp == NULL ||
 		    !(*tp & ICMPV6_INFOMSG_MASK))
-			return 1;
+			return true;
 	}
-	return 0;
+	return false;
 }
 
 /*
@@ -208,14 +208,14 @@ static inline bool icmpv6_xrlim_allow(struct sock *sk, u8 type,
  *	highest-order two bits set to 10
  */
 
-static __inline__ int opt_unrec(struct sk_buff *skb, __u32 offset)
+static bool opt_unrec(struct sk_buff *skb, __u32 offset)
 {
 	u8 _optval, *op;
 
 	offset += skb_network_offset(skb);
 	op = skb_header_pointer(skb, offset, sizeof(_optval), &_optval);
 	if (op == NULL)
-		return 1;
+		return true;
 	return (*op & 0xC0) == 0x80;
 }
 
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index cb43df6..9772fbd 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -433,32 +433,32 @@ static int mem_check(struct sock *sk)
 	return 0;
 }
 
-static int ipv6_hdr_cmp(struct ipv6_opt_hdr *h1, struct ipv6_opt_hdr *h2)
+static bool ipv6_hdr_cmp(struct ipv6_opt_hdr *h1, struct ipv6_opt_hdr *h2)
 {
 	if (h1 == h2)
-		return 0;
+		return false;
 	if (h1 == NULL || h2 == NULL)
-		return 1;
+		return true;
 	if (h1->hdrlen != h2->hdrlen)
-		return 1;
+		return true;
 	return memcmp(h1+1, h2+1, ((h1->hdrlen+1)<<3) - sizeof(*h1));
 }
 
-static int ipv6_opt_cmp(struct ipv6_txoptions *o1, struct ipv6_txoptions *o2)
+static bool ipv6_opt_cmp(struct ipv6_txoptions *o1, struct ipv6_txoptions *o2)
 {
 	if (o1 == o2)
-		return 0;
+		return false;
 	if (o1 == NULL || o2 == NULL)
-		return 1;
+		return true;
 	if (o1->opt_nflen != o2->opt_nflen)
-		return 1;
+		return true;
 	if (ipv6_hdr_cmp(o1->hopopt, o2->hopopt))
-		return 1;
+		return true;
 	if (ipv6_hdr_cmp(o1->dst0opt, o2->dst0opt))
-		return 1;
+		return true;
 	if (ipv6_hdr_cmp((struct ipv6_opt_hdr *)o1->srcrt, (struct ipv6_opt_hdr *)o2->srcrt))
-		return 1;
-	return 0;
+		return true;
+	return false;
 }
 
 static inline void fl_link(struct ipv6_pinfo *np, struct ipv6_fl_socklist *sfl,
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index 1ca5d45..21a15df 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -170,7 +170,8 @@ static int ip6_input_finish(struct sk_buff *skb)
 {
 	const struct inet6_protocol *ipprot;
 	unsigned int nhoff;
-	int nexthdr, raw;
+	int nexthdr;
+	bool raw;
 	u8 hash;
 	struct inet6_dev *idev;
 	struct net *net = dev_net(skb_dst(skb)->dev);
@@ -251,7 +252,7 @@ int ip6_input(struct sk_buff *skb)
 int ip6_mc_input(struct sk_buff *skb)
 {
 	const struct ipv6hdr *hdr;
-	int deliver;
+	bool deliver;
 
 	IP6_UPD_PO_STATS_BH(dev_net(skb_dst(skb)->dev),
 			 ip6_dst_idev(skb_dst(skb)), IPSTATS_MIB_INMCAST,
@@ -287,7 +288,7 @@ int ip6_mc_input(struct sk_buff *skb)
 			 * is for MLD (0x0000).
 			 */
 			if ((ptr[2] | ptr[3]) == 0) {
-				deliver = 0;
+				deliver = false;
 
 				if (!ipv6_ext_hdr(nexthdr)) {
 					/* BUG */
@@ -312,7 +313,7 @@ int ip6_mc_input(struct sk_buff *skb)
 				case ICMPV6_MGM_REPORT:
 				case ICMPV6_MGM_REDUCTION:
 				case ICMPV6_MLD2_REPORT:
-					deliver = 1;
+					deliver = true;
 					break;
 				}
 				goto out;
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 2a3a22c..6d0f5dc 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -606,13 +606,13 @@ done:
 	return err;
 }
 
-int inet6_mc_check(struct sock *sk, const struct in6_addr *mc_addr,
-		   const struct in6_addr *src_addr)
+bool inet6_mc_check(struct sock *sk, const struct in6_addr *mc_addr,
+		    const struct in6_addr *src_addr)
 {
 	struct ipv6_pinfo *np = inet6_sk(sk);
 	struct ipv6_mc_socklist *mc;
 	struct ip6_sf_socklist *psl;
-	int rv = 1;
+	bool rv = true;
 
 	rcu_read_lock();
 	for_each_pmc_rcu(np, mc) {
@@ -621,7 +621,7 @@ int inet6_mc_check(struct sock *sk, const struct in6_addr *mc_addr,
 	}
 	if (!mc) {
 		rcu_read_unlock();
-		return 1;
+		return true;
 	}
 	read_lock(&mc->sflock);
 	psl = mc->sflist;
@@ -635,9 +635,9 @@ int inet6_mc_check(struct sock *sk, const struct in6_addr *mc_addr,
 				break;
 		}
 		if (mc->sfmode == MCAST_INCLUDE && i >= psl->sl_count)
-			rv = 0;
+			rv = false;
 		if (mc->sfmode == MCAST_EXCLUDE && i < psl->sl_count)
-			rv = 0;
+			rv = false;
 	}
 	read_unlock(&mc->sflock);
 	rcu_read_unlock();
@@ -931,15 +931,15 @@ int ipv6_dev_mc_dec(struct net_device *dev, const struct in6_addr *addr)
 /*
  * identify MLD packets for MLD filter exceptions
  */
-int ipv6_is_mld(struct sk_buff *skb, int nexthdr)
+bool ipv6_is_mld(struct sk_buff *skb, int nexthdr)
 {
 	struct icmp6hdr *pic;
 
 	if (nexthdr != IPPROTO_ICMPV6)
-		return 0;
+		return false;
 
 	if (!pskb_may_pull(skb, sizeof(struct icmp6hdr)))
-		return 0;
+		return false;
 
 	pic = icmp6_hdr(skb);
 
@@ -948,22 +948,22 @@ int ipv6_is_mld(struct sk_buff *skb, int nexthdr)
 	case ICMPV6_MGM_REPORT:
 	case ICMPV6_MGM_REDUCTION:
 	case ICMPV6_MLD2_REPORT:
-		return 1;
+		return true;
 	default:
 		break;
 	}
-	return 0;
+	return false;
 }
 
 /*
  *	check if the interface/address pair is valid
  */
-int ipv6_chk_mcast_addr(struct net_device *dev, const struct in6_addr *group,
-			const struct in6_addr *src_addr)
+bool ipv6_chk_mcast_addr(struct net_device *dev, const struct in6_addr *group,
+			 const struct in6_addr *src_addr)
 {
 	struct inet6_dev *idev;
 	struct ifmcaddr6 *mc;
-	int rv = 0;
+	bool rv = false;
 
 	rcu_read_lock();
 	idev = __in6_dev_get(dev);
@@ -990,7 +990,7 @@ int ipv6_chk_mcast_addr(struct net_device *dev, const struct in6_addr *group,
 					rv = mc->mca_sfcount[MCAST_EXCLUDE] !=0;
 				spin_unlock_bh(&mc->mca_lock);
 			} else
-				rv = 1; /* don't filter unspecified source */
+				rv = true; /* don't filter unspecified source */
 		}
 		read_unlock_bh(&idev->lock);
 	}
@@ -1046,8 +1046,8 @@ static void igmp6_group_queried(struct ifmcaddr6 *ma, unsigned long resptime)
 }
 
 /* mark EXCLUDE-mode sources */
-static int mld_xmarksources(struct ifmcaddr6 *pmc, int nsrcs,
-	const struct in6_addr *srcs)
+static bool mld_xmarksources(struct ifmcaddr6 *pmc, int nsrcs,
+			     const struct in6_addr *srcs)
 {
 	struct ip6_sf_list *psf;
 	int i, scount;
@@ -1070,12 +1070,12 @@ static int mld_xmarksources(struct ifmcaddr6 *pmc, int nsrcs,
 	}
 	pmc->mca_flags &= ~MAF_GSQUERY;
 	if (scount == nsrcs)	/* all sources excluded */
-		return 0;
-	return 1;
+		return false;
+	return true;
 }
 
-static int mld_marksources(struct ifmcaddr6 *pmc, int nsrcs,
-	const struct in6_addr *srcs)
+static bool mld_marksources(struct ifmcaddr6 *pmc, int nsrcs,
+			    const struct in6_addr *srcs)
 {
 	struct ip6_sf_list *psf;
 	int i, scount;
@@ -1099,10 +1099,10 @@ static int mld_marksources(struct ifmcaddr6 *pmc, int nsrcs,
 	}
 	if (!scount) {
 		pmc->mca_flags &= ~MAF_GSQUERY;
-		return 0;
+		return false;
 	}
 	pmc->mca_flags |= MAF_GSQUERY;
-	return 1;
+	return true;
 }
 
 /* called with rcu_read_lock() */
@@ -1276,17 +1276,17 @@ int igmp6_event_report(struct sk_buff *skb)
 	return 0;
 }
 
-static int is_in(struct ifmcaddr6 *pmc, struct ip6_sf_list *psf, int type,
-	int gdeleted, int sdeleted)
+static bool is_in(struct ifmcaddr6 *pmc, struct ip6_sf_list *psf, int type,
+		  int gdeleted, int sdeleted)
 {
 	switch (type) {
 	case MLD2_MODE_IS_INCLUDE:
 	case MLD2_MODE_IS_EXCLUDE:
 		if (gdeleted || sdeleted)
-			return 0;
+			return false;
 		if (!((pmc->mca_flags & MAF_GSQUERY) && !psf->sf_gsresp)) {
 			if (pmc->mca_sfmode == MCAST_INCLUDE)
-				return 1;
+				return true;
 			/* don't include if this source is excluded
 			 * in all filters
 			 */
@@ -1295,29 +1295,29 @@ static int is_in(struct ifmcaddr6 *pmc, struct ip6_sf_list *psf, int type,
 			return pmc->mca_sfcount[MCAST_EXCLUDE] ==
 				psf->sf_count[MCAST_EXCLUDE];
 		}
-		return 0;
+		return false;
 	case MLD2_CHANGE_TO_INCLUDE:
 		if (gdeleted || sdeleted)
-			return 0;
+			return false;
 		return psf->sf_count[MCAST_INCLUDE] != 0;
 	case MLD2_CHANGE_TO_EXCLUDE:
 		if (gdeleted || sdeleted)
-			return 0;
+			return false;
 		if (pmc->mca_sfcount[MCAST_EXCLUDE] == 0 ||
 		    psf->sf_count[MCAST_INCLUDE])
-			return 0;
+			return false;
 		return pmc->mca_sfcount[MCAST_EXCLUDE] ==
 			psf->sf_count[MCAST_EXCLUDE];
 	case MLD2_ALLOW_NEW_SOURCES:
 		if (gdeleted || !psf->sf_crcount)
-			return 0;
+			return false;
 		return (pmc->mca_sfmode == MCAST_INCLUDE) ^ sdeleted;
 	case MLD2_BLOCK_OLD_SOURCES:
 		if (pmc->mca_sfmode == MCAST_INCLUDE)
 			return gdeleted || (psf->sf_crcount && sdeleted);
 		return psf->sf_crcount && !gdeleted && !sdeleted;
 	}
-	return 0;
+	return false;
 }
 
 static int
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index c7a27ac..54f62d3 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -348,7 +348,7 @@ static int ndisc_constructor(struct neighbour *neigh)
 	struct net_device *dev = neigh->dev;
 	struct inet6_dev *in6_dev;
 	struct neigh_parms *parms;
-	int is_multicast = ipv6_addr_is_multicast(addr);
+	bool is_multicast = ipv6_addr_is_multicast(addr);
 
 	in6_dev = in6_dev_get(dev);
 	if (in6_dev == NULL) {
@@ -725,7 +725,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
 	struct inet6_dev *idev = NULL;
 	struct neighbour *neigh;
 	int dad = ipv6_addr_any(saddr);
-	int inc;
+	bool inc;
 	int is_router = -1;
 
 	if (ipv6_addr_is_multicast(&msg->target)) {
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 5bddea7..93d6983 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -72,7 +72,7 @@ static struct sock *__raw_v6_lookup(struct net *net, struct sock *sk,
 		const struct in6_addr *rmt_addr, int dif)
 {
 	struct hlist_node *node;
-	int is_multicast = ipv6_addr_is_multicast(loc_addr);
+	bool is_multicast = ipv6_addr_is_multicast(loc_addr);
 
 	sk_for_each_from(sk, node)
 		if (inet_sk(sk)->inet_num == num) {
@@ -153,12 +153,12 @@ EXPORT_SYMBOL(rawv6_mh_filter_unregister);
  *
  *	Caller owns SKB so we must make clones.
  */
-static int ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
+static bool ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
 {
 	const struct in6_addr *saddr;
 	const struct in6_addr *daddr;
 	struct sock *sk;
-	int delivered = 0;
+	bool delivered = false;
 	__u8 hash;
 	struct net *net;
 
@@ -179,7 +179,7 @@ static int ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
 	while (sk) {
 		int filtered;
 
-		delivered = 1;
+		delivered = true;
 		switch (nexthdr) {
 		case IPPROTO_ICMPV6:
 			filtered = icmpv6_filter(sk, skb);
@@ -225,7 +225,7 @@ out:
 	return delivered;
 }
 
-int raw6_local_deliver(struct sk_buff *skb, int nexthdr)
+bool raw6_local_deliver(struct sk_buff *skb, int nexthdr)
 {
 	struct sock *raw_sk;
 
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 90119a3..999a982 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -333,22 +333,22 @@ static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
 	}
 }
 
-static __inline__ int rt6_check_expired(const struct rt6_info *rt)
+static bool rt6_check_expired(const struct rt6_info *rt)
 {
 	struct rt6_info *ort = NULL;
 
 	if (rt->rt6i_flags & RTF_EXPIRES) {
 		if (time_after(jiffies, rt->dst.expires))
-			return 1;
+			return true;
 	} else if (rt->dst.from) {
 		ort = (struct rt6_info *) rt->dst.from;
 		return (ort->rt6i_flags & RTF_EXPIRES) &&
 			time_after(jiffies, ort->dst.expires);
 	}
-	return 0;
+	return false;
 }
 
-static inline int rt6_need_strict(const struct in6_addr *daddr)
+static bool rt6_need_strict(const struct in6_addr *daddr)
 {
 	return ipv6_addr_type(daddr) &
 		(IPV6_ADDR_MULTICAST | IPV6_ADDR_LINKLOCAL | IPV6_ADDR_LOOPBACK);

^ permalink raw reply related

* Re: inconsistent null checking in ipx_ioctl()
From: David Miller @ 2012-05-19  4:51 UTC (permalink / raw)
  To: dan.carpenter; +Cc: netdev
In-Reply-To: <20120514205618.GB20836@elgon.mountain>

From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Mon, 14 May 2012 23:56:18 +0300

> Hi, I'm working on some new Smatch stuff and going through some warnings
> in old code.
> 
> ----
> This is a semi-automatic email about new static checker warnings.
> 
> The patch b0d0d915d1d1: "ipx: remove the BKL" from Jan 25, 2011, 
> leads to the following Smatch complaint:
> 
> net/ipx/af_ipx.c:1928 ipx_ioctl()
> 	 error: we previously assumed 'sk' could be null (see line 1913)

Thanks Dan, I've commited the following:

--------------------
ipx: Remove spurious NULL checking in ipx_ioctl().

We already unconditionally dereference 'sk' via lock_sock(sk) earlier
in this function, and our caller (sock_do_ioctl()) makes takes similar
liberties.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
 net/ipx/af_ipx.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c
index 824d4a3..dfd6faa 100644
--- a/net/ipx/af_ipx.c
+++ b/net/ipx/af_ipx.c
@@ -1901,9 +1901,7 @@ static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
 			      (const unsigned short __user *)argp);
 		break;
 	case SIOCGSTAMP:
-		rc = -EINVAL;
-		if (sk)
-			rc = sock_get_timestamp(sk, argp);
+		rc = sock_get_timestamp(sk, argp);
 		break;
 	case SIOCGIFDSTADDR:
 	case SIOCSIFDSTADDR:
-- 
1.7.10.1

^ permalink raw reply related

* Re: ppp/l2tp doing oversized allocations ?
From: David Miller @ 2012-05-19  4:46 UTC (permalink / raw)
  To: davej; +Cc: netdev, kernel-team, edumazet
In-Reply-To: <20120514162923.GA4439@redhat.com>

From: Dave Jones <davej@redhat.com>
Date: Mon, 14 May 2012 12:29:23 -0400

> We just got this trace from reported by a Fedora user running 3.3.4
> 
> :WARNING: at mm/page_alloc.c:2204 __alloc_pages_nodemask+0x231/0x8f0()
> :Call Trace:
> : [<ffffffff81057abf>] warn_slowpath_common+0x7f/0xc0
> : [<ffffffff81057b1a>] warn_slowpath_null+0x1a/0x20
> : [<ffffffff81129671>] __alloc_pages_nodemask+0x231/0x8f0
> : [<ffffffff814e84db>] ? dev_queue_xmit+0x1db/0x640
> : [<ffffffff8151f210>] ? ip_forward_options+0x1f0/0x1f0
> : [<ffffffff814ef7a1>] ? neigh_direct_output+0x11/0x20
> : [<ffffffff81520dee>] ? ip_finish_output+0x17e/0x2f0
> : [<ffffffff8151f210>] ? ip_forward_options+0x1f0/0x1f0
> : [<ffffffff811608d3>] alloc_pages_current+0xa3/0x110
> : [<ffffffff811254b4>] __get_free_pages+0x14/0x50
> : [<ffffffff8116b99f>] kmalloc_order_trace+0x3f/0xd0
> : [<ffffffff8156d137>] ? xfrm4_output_finish+0x27/0x40
> : [<ffffffff8116c8c7>] __kmalloc+0x177/0x1a0
> : [<ffffffff81521196>] ? ip_queue_xmit+0x156/0x400
> : [<ffffffff814dab07>] pskb_expand_head+0x87/0x310
> : [<ffffffff8113dbf9>] ? __mod_zone_page_state+0x49/0x50
> : [<ffffffffa05e84dd>] pppol2tp_xmit+0x1ed/0x220 [l2tp_ppp]

So it's ESP encapsulated IPSEC over L2tp.

Eric, I wonder if session->hdr_len can take on undesirable values and
thus trip up the skb COW'ing calculations you added?

^ permalink raw reply

* Re: [PATCH net-next] ipv6: ip6_fragment() should check CHECKSUM_PARTIAL
From: David Miller @ 2012-05-19  3:54 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev, tore
In-Reply-To: <1337374935.7029.60.camel@edumazet-glaptop>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 18 May 2012 23:02:15 +0200

> From: Eric Dumazet <edumazet@google.com>
> 
> Quoting Tore Anderson from :
> 
> If the allfrag feature has been set on a host route (due to an ICMPv6
> Packet Too Big received indicating a MTU of less than 1280),
> TCP SYN/ACK packets to that destination appears to get an incorrect
> TCP checksum. This in turn means they are thrown away as invalid.
> 
> In the case of an IPv4 client behind a link with a MTU of less than
> 1260, accessing an IPv6 server through a stateless translator,
> this means that the client can only download a single large file
> from the server, because once it is in the server's routing cache
> with the allfrag feature set, new TCP connections can no longer
> be established.
> 
> </endquote>
> 
> It appears ip6_fragment() doesn't handle CHECKSUM_PARTIAL properly.
> 
> As network drivers are not prepared to fetch correct transport header, a
> safe fix is to call skb_checksum_help() before fragmenting packet.
> 
> Reported-by: Tore Anderson <tore@fud.no>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Tested-by: Tore Anderson <tore@fud.no>

Applied, thanks.

^ permalink raw reply

* Re: [PATCH net-next] drivers/net: delete old 8bit ISA 3c501 driver.
From: David Miller @ 2012-05-19  3:54 UTC (permalink / raw)
  To: paul.gortmaker; +Cc: netdev, alan
In-Reply-To: <1337362769-4676-1-git-send-email-paul.gortmaker@windriver.com>

From: Paul Gortmaker <paul.gortmaker@windriver.com>
Date: Fri, 18 May 2012 13:39:29 -0400

> It was amusing that linux was able to make use of this 1980's
> technology on machines long past its intended lifespan, but
> it probably should go now -- it is causing issues in some
> distros[1], and while that might be fixable, it is just not
> worth it.
> 
> To set the context, the 3c501 was designed in the 1980's to be
> used on 8088 PC-XT 8bit ISA machines.  It was built using
> discrete TTL components and truly looks like a relic of the past.
> 
> But from a functional point of view, the real issue, as stated
> in the (also obsolete) Ethernet-HowTo, is that "...the 3c501 can
> only do one thing at a time -- while you are removing one packet
> from the single-packet buffer it cannot receive another packet,
> nor can it receive a packet while loading a transmit packet."
> 
> You know things are not good when the Kconfig help text suggests
> you make a cron job doing a ping every minute.
> 
> Hardware that old and crippled is simply not going to be used by
> anyone in a time where 10 year old 100Mbit PCI cards (that are
> still functional) are largely give-away items.
> 
> [1] http://www.linuxquestions.org/questions/linux-networking-3/3com-3c501-card-not-detecting-934344/
> 
> Cc: Alan Cox <alan@linux.intel.com>
> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>

Alan, any objections?

^ permalink raw reply

* Re: [PATCH net-next 0/5] cirrus: cs89x0: Neatening
From: David Miller @ 2012-05-19  3:53 UTC (permalink / raw)
  To: joe; +Cc: netdev, jaccon.bastiaansen, linux-kernel
In-Reply-To: <cover.1337381533.git.joe@perches.com>

From: Joe Perches <joe@perches.com>
Date: Fri, 18 May 2012 15:56:26 -0700

> Yeah, some might consider it gratuitous.
> I think it's cleaner now though.
> 
> Joe Perches (5):
>   cirrus: cs89x0: Code style neatening
>   cirrus: cs89x0: Convert printks to pr_<level>
>   cirrus: cs89x0: Code neatening
>   cirrus: cs89x0: Neaten debugging and logging
>   cirrus: cs89x0: Remove function prototypes and reorder declarations

Series applied, thanks joe.

^ permalink raw reply

* [GIT] Networking
From: David Miller @ 2012-05-19  3:43 UTC (permalink / raw)
  To: torvalds; +Cc: akpm, netdev


One last straggler.

Eric Dumazet's pktgen unload oops fix was not entirely complete, but
all the cases should be handled properly now.... fingers crossed.

Please pull, thanks a lot!

The following changes since commit 42ea7d7f2a7356962022cdd124d9043c488ca5e2:

  Merge branch 'fixes' of git://git.linaro.org/people/rmk/linux-arm (2012-05-17 16:52:29 -0700)

are available in the git repository at:


  git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git master

for you to fetch changes up to d4b1133558e0d417342d5d2c49e4c35b428ff20d:

  pktgen: fix module unload for good (2012-05-18 13:54:33 -0400)

----------------------------------------------------------------
Eric Dumazet (1):
      pktgen: fix module unload for good

 net/core/pktgen.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

^ permalink raw reply

* Re: Strange latency spikes/TX network stalls on Sun Fire X4150(x86) and e1000e
From: Denys Fedoryshchenko @ 2012-05-19  2:40 UTC (permalink / raw)
  To: Tom Herbert; +Cc: e1000-devel, netdev, jesse.brandeburg, davem
In-Reply-To: <CA+mtBx9axFKCjLwDYMvXXP2nB_og896kAhG0UYWaK6PTAXhPcw@mail.gmail.com>

On 2012-05-19 05:07, Tom Herbert wrote:
> 3) Have you tried a different interrupt mode?

Now tested:
e1000e.TxIntDelay=0,0,0,0
[    4.930570] e1000e 0000:04:00.0: (unregistered net_device): Transmit 
Interrupt Delay set to 0
[    4.930573] e1000e 0000:04:00.0: (unregistered net_device): 
Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode
Problem still occur.

e1000e.TxIntDelay=0,0,0,0 e1000e.InterruptThrottleRate=0,0,0,0
[    4.971476] e1000e 0000:04:00.0: (unregistered net_device): Transmit 
Interrupt Delay set to 0
[    4.971478] e1000e 0000:04:00.0: (unregistered net_device): 
Interrupt Throttling Rate (ints/sec) turned off
Problem also occur.

Probably it is a case of this specific machine, this problem is 
happened on same hardware (Sun Fire X4150).
The only "exotic" thing here is set of cards:
04:00.0 Ethernet controller: Intel Corporation 80003ES2LAN Gigabit 
Ethernet Controller (Copper) (rev 01)
04:00.1 Ethernet controller: Intel Corporation 80003ES2LAN Gigabit 
Ethernet Controller (Copper) (rev 01)
0b:00.0 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet 
Controller (rev 06)
0b:00.1 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet 
Controller (rev 06)

I'm using first card.

>
> Per #3, I am wondering if dynamic conservative mode interrupt
> throttling is not producing interrupts deterministically for BQL.
> I'll try to reproduce the problem in this mode.
>
>> I can make a patch that will make minimum BQL value not less than 
>> MTU +
>> overhead, is it ok like this?
>> Probably it will solve issue, but it is more workaround and safety 
>> fuse,
>> than a solution.
>>
> That would just be a bandaid and could just make this a latent issue
> for the future.
>
> Tom
>
>>
>> On 2012-05-17 19:54, Denys Fedoryshchenko wrote:
>>>
>>> Also i notice, limit constantly changing over time (even i am not
>>> touching it).
>>>
>>> centaur ~ # grep "" 
>>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/*
>>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/hold_time:1000
>>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/inflight:0
>>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/limit:13018
>>>
>>> 
>>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/limit_max:1879048192
>>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/limit_min:0
>>> centaur ~ # grep "" 
>>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/*
>>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/hold_time:1000
>>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/inflight:4542
>>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/limit:13018
>>>
>>> 
>>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/limit_max:1879048192
>>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/limit_min:0
>>>
>>> Is it supposed to be like this?
>>>
>>> On 2012-05-17 16:42, Denys Fedoryshchenko wrote:
>>>>
>>>> Found commit that cause problem:
>>>>
>>>> author  Tom Herbert <therbert@google.com>
>>>> Mon, 28 Nov 2011 16:33:16 +0000 (16:33 +0000)
>>>> committer       David S. Miller <davem@davemloft.net>
>>>> Tue, 29 Nov 2011 17:46:19 +0000 (12:46 -0500)
>>>> commit  3f0cfa3bc11e7f00c9994e0f469cbc0e7da7b00c
>>>> tree    d6670a4f94b2b9dedacc38edb6f0e1306b889f6b        tree | 
>>>> snapshot
>>>> parent  114cf5802165ee93e3ab461c9c505cd94a08b800        commit | 
>>>> diff
>>>> e1000e: Support for byte queue limits
>>>>
>>>> Changes to e1000e to use byte queue limits.
>>>>
>>>> Signed-off-by: Tom Herbert <therbert@google.com>
>>>> Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
>>>> Signed-off-by: David S. Miller <davem@davemloft.net>
>>>>
>>>> If i reverse it, problem disappearing.
>>>>
>>>> How i reproduce it:
>>>> In two consoles do "fast" ping to nearby host
>>>> ping 194.146.XXX.XXX -s1472 -i0.0001
>>>> ping 194.146.XXX.XXX -s1472 -i0.1
>>>>
>>>> For third open ssh to host with "problem", open mcedit, and just
>>>> scroll down large text file.
>>>> After few seconds some "stalls" will occur, and in ping history i 
>>>> can
>>>> see:
>>>> 1480 bytes from 194.146.153.7: icmp_req=1797 ttl=64 time=0.161 ms
>>>> 1480 bytes from 194.146.153.7: icmp_req=1798 ttl=64 time=0.198 ms
>>>> 1480 bytes from 194.146.153.7: icmp_req=1799 ttl=64 time=0.340 ms
>>>> 1480 bytes from 194.146.153.7: icmp_req=1800 ttl=64 time=0.381 ms
>>>> 1480 bytes from 194.146.153.7: icmp_req=1801 ttl=64 time=914 ms
>>>> 1480 bytes from 194.146.153.7: icmp_req=1802 ttl=64 time=804 ms
>>>> 1480 bytes from 194.146.153.7: icmp_req=1803 ttl=64 time=704 ms
>>>> 1480 bytes from 194.146.153.7: icmp_req=1804 ttl=64 time=594 ms
>>>> 1480 bytes from 194.146.153.7: icmp_req=1805 ttl=64 time=0.287 ms
>>>> 1480 bytes from 194.146.153.7: icmp_req=1806 ttl=64 time=0.226 ms
>>>>
>>>>
>>>> If i apply small patch - problem will disappear. Sure it is not a
>>>> solution, but
>>>> let me know how i can help to debug problem more.
>>>>
>>>> --- netdev.c    2012-05-12 20:08:37.000000000 +0300
>>>> +++ netdev.c.patched    2012-05-17 16:32:28.895760472 +0300
>>>> @@ -1135,7 +1135,7 @@
>>>>
>>>>        tx_ring->next_to_clean = i;
>>>>
>>>> -       netdev_completed_queue(netdev, pkts_compl, bytes_compl);
>>>> +//     netdev_completed_queue(netdev, pkts_compl, bytes_compl);
>>>>
>>>>  #define TX_WAKE_THRESHOLD 32
>>>>        if (count && netif_carrier_ok(netdev) &&
>>>> @@ -2263,7 +2263,7 @@
>>>>                e1000_put_txbuf(adapter, buffer_info);
>>>>        }
>>>>
>>>> -       netdev_reset_queue(adapter->netdev);
>>>> +//     netdev_reset_queue(adapter->netdev);
>>>>        size = sizeof(struct e1000_buffer) * tx_ring->count;
>>>>        memset(tx_ring->buffer_info, 0, size);
>>>>
>>>> @@ -5056,7 +5056,7 @@
>>>>        /* if count is 0 then mapping error has occurred */
>>>>        count = e1000_tx_map(adapter, skb, first, max_per_txd,
>>>> nr_frags, mss);
>>>>        if (count) {
>>>> -               netdev_sent_queue(netdev, skb->len);
>>>> +//             netdev_sent_queue(netdev, skb->len);
>>>>                e1000_tx_queue(adapter, tx_flags, count);
>>>>                /* Make sure there is space in the ring for the 
>>>> next send.
>>>> */
>>>>                e1000_maybe_stop_tx(netdev, MAX_SKB_FRAGS + 2);
>>>>
>>>>
>>>>
>>>> On 2012-05-15 17:15, Denys Fedoryshchenko wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>> I have two identical servers, Sun Fire X4150, both has different
>>>>> flavors of Linux, x86_64 and i386.
>>>>> 04:00.0 Ethernet controller: Intel Corporation 80003ES2LAN 
>>>>> Gigabit
>>>>> Ethernet Controller (Copper) (rev 01)
>>>>> 04:00.1 Ethernet controller: Intel Corporation 80003ES2LAN 
>>>>> Gigabit
>>>>> Ethernet Controller (Copper) (rev 01)
>>>>> 0b:00.0 Ethernet controller: Intel Corporation 82571EB Gigabit
>>>>> Ethernet Controller (rev 06)
>>>>> 0b:00.1 Ethernet controller: Intel Corporation 82571EB Gigabit
>>>>> Ethernet Controller (rev 06)
>>>>> I am using now interface:
>>>>> #ethtool -i eth0
>>>>> driver: e1000e
>>>>> version: 1.9.5-k
>>>>> firmware-version: 2.1-11
>>>>> bus-info: 0000:04:00.0
>>>>> There is 2 CPU , Intel(R) Xeon(R) CPU           E5440  @ 2.83GHz 
>>>>> .
>>>>>
>>>>> i386 was acting as NAT and shaper, and as soon as i removed 
>>>>> shaper
>>>>> from it, i started to experience strange lockups, e.g. traffic is
>>>>> normal for 5-30 seconds, then short lockup for 500-3000ms 
>>>>> (usually
>>>>> around 1000ms) with dropped packets counter increasing. I was
>>>>> suspecting it is due load, but it seems was wrong.
>>>>> Recently, on another server, x86_64 i am using as development, i
>>>>> upgrade kernel (it was old, from 2.6 series) and on completely 
>>>>> idle
>>>>> machine started to experience same latency spikes, while i am 
>>>>> just
>>>>> running mc and for example typing in text editor - i notice 
>>>>> "stalls".
>>>>> After i investigate it a little more, i notice also small amount 
>>>>> of
>>>>> drops on interface. No tcpdump running. Also this machine is 
>>>>> idle, and
>>>>> the only traffic there - some small broadcasts from network, my 
>>>>> ssh,
>>>>> and ping.
>>>>>
>>>>> Dropped packets in ifconfig
>>>>>          RX packets:3752868 errors:0 dropped:5350 overruns:0 
>>>>> frame:0
>>>>> Counter is increasing sometimes, when this stall happening.
>>>>>
>>>>> ethtool -S is clean, there is no dropped packets.
>>>>>
>>>>> I did tried to check load (mpstat and perf), there is nothing
>>>>> suspicious, latencytop also doesn't show anything suspicious.
>>>>> dropwatch report a lot of drops, but mostly because there is some
>>>>> broadcasts and etc. tcpdump at the moment of such drops doesn't 
>>>>> show
>>>>> anything suspicious.
>>>>> Changed qdisc from default fifo_fast to bfifo, without any 
>>>>> result.
>>>>> Tried:  ethtool -K eth0 tso off gso off gro off sg off , no 
>>>>> result
>>>>> Problem occured at 3.3.6 - 3.4.0-rc7, most probably 3.3.0 also, 
>>>>> but i
>>>>> don't remember for sure. I thik on some kernels like 3.1 probably 
>>>>> it
>>>>> doesn't occur, i will check it soon, because it is not always 
>>>>> reliable
>>>>> to reproduce it. All tests i did on 3.4.0-rc7.
>>>>>
>>>>> I did run also in background tcpdump, additionally iptables with
>>>>> timestamps, and at time when stall occured, seems i am still 
>>>>> receiving
>>>>> packets properly, also on iperf udp  (from some host to this 
>>>>> SunFire)
>>>>> at this moments no packets missing. But i am sure RX interface 
>>>>> errors
>>>>> are increasing.
>>>>> If i do iperf from SunFire to test host - there is packetloss at
>>>>> moments when stall occured.
>>>>>
>>>>> I suspect that by some reason network card stop to transmit, but
>>>>> unable to pinpoint issue. All other hosts in this network are 
>>>>> fine and
>>>>> don't have such problems.
>>>>> Can you help me with that please? Maybe i can provide more debug
>>>>> information, compile with patches and etc. Also i will try to 
>>>>> fallback
>>>>> to 3.1 and 3.0 kernels.
>>>>>
>>>>> Here it is how it occurs and i am reproducing it:
>>>>> I'm just opening file, and start to scroll it in mc, then in 
>>>>> another
>>>>> console i run ping
>>>>> [1337089061.844167] 1480 bytes from 194.146.153.20: icmp_req=162
>>>>> ttl=64 time=0.485 ms
>>>>> [1337089061.944138] 1480 bytes from 194.146.153.20: icmp_req=163
>>>>> ttl=64 time=0.470 ms
>>>>> [1337089062.467759] 1480 bytes from 194.146.153.20: icmp_req=164
>>>>> ttl=64 time=424 ms
>>>>> [1337089062.467899] 1480 bytes from 194.146.153.20: icmp_req=165
>>>>> ttl=64 time=324 ms
>>>>> [1337089062.468058] 1480 bytes from 194.146.153.20: icmp_req=166
>>>>> ttl=64 time=214 ms
>>>>> [1337089062.468161] 1480 bytes from 194.146.153.20: icmp_req=167
>>>>> ttl=64 time=104 ms
>>>>> [1337089062.468958] 1480 bytes from 194.146.153.20: icmp_req=168
>>>>> ttl=64 time=1.15 ms
>>>>> [1337089062.568604] 1480 bytes from 194.146.153.20: icmp_req=169
>>>>> ttl=64 time=0.477 ms
>>>>> [1337089062.668909] 1480 bytes from 194.146.153.20: icmp_req=170
>>>>> ttl=64 time=0.667 ms
>>>>>
>>>>> Remote host tcpdump:
>>>>> 1337089061.934737 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>>> reply, id 3486, seq 163, length 1480
>>>>> 1337089062.458360 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>>> request, id 3486, seq 164, length 1480
>>>>> 1337089062.458380 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>>> reply, id 3486, seq 164, length 1480
>>>>> 1337089062.458481 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>>> request, id 3486, seq 165, length 1480
>>>>> 1337089062.458502 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>>> reply, id 3486, seq 165, length 1480
>>>>> 1337089062.458606 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>>> request, id 3486, seq 166, length 1480
>>>>> 1337089062.458623 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>>> reply, id 3486, seq 166, length 1480
>>>>> 1337089062.458729 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>>> request, id 3486, seq 167, length 1480
>>>>> 1337089062.458745 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>>> reply, id 3486, seq 167, length 1480
>>>>> 1337089062.459537 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>>> request, id 3486, seq 168, length 1480
>>>>> 1337089062.459545 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>>> reply, id 3486, seq 168, length 1480
>>>>>
>>>>> Local host(SunFire) tcpdump:
>>>>> 1337089061.844140 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>>> reply, id 3486, seq 162, length 1480
>>>>> 1337089061.943661 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>>> request, id 3486, seq 163, length 1480
>>>>> 1337089061.944124 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>>> reply, id 3486, seq 163, length 1480
>>>>> 1337089062.465622 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>>> request, id 3486, seq 164, length 1480
>>>>> 1337089062.465630 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>>> request, id 3486, seq 165, length 1480
>>>>> 1337089062.465632 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>>> request, id 3486, seq 166, length 1480
>>>>> 1337089062.465634 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>>> request, id 3486, seq 167, length 1480
>>>>> 1337089062.467730 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>>> reply, id 3486, seq 164, length 1480
>>>>> 1337089062.467785 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>>> request, id 3486, seq 168, length 1480
>>>>> 1337089062.467884 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>>> reply, id 3486, seq 165, length 1480
>>>>> 1337089062.468035 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>>> reply, id 3486, seq 166, length 1480
>>>>> 1337089062.468129 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>>> reply, id 3486, seq 167, length 1480
>>>>> 1337089062.468928 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>>> reply, id 3486, seq 168, length 1480
>>>>> 1337089062.568112 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>>> request, id 3486, seq 169, length 1480
>>>>> 1337089062.568578 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>>> reply, id 3486, seq 169, length 1480
>>>>>
>>>>> lspci -t
>>>>> centaur src # lspci -t
>>>>> -[0000:00]-+-00.0
>>>>>           +-02.0-[01-05]--+-00.0-[02-04]--+-00.0-[03]--
>>>>>           |               |               \-02.0-[04]--+-00.0
>>>>>           |               |                            \-00.1
>>>>>           |               \-00.3-[05]--
>>>>>           +-03.0-[06]--
>>>>>           +-04.0-[07]----00.0
>>>>>           +-05.0-[08]--
>>>>>           +-06.0-[09]--
>>>>>           +-07.0-[0a]--
>>>>>           +-08.0
>>>>>           +-10.0
>>>>>           +-10.1
>>>>>           +-10.2
>>>>>           +-11.0
>>>>>           +-13.0
>>>>>           +-15.0
>>>>>           +-16.0
>>>>>           +-1c.0-[0b]--+-00.0
>>>>>           |            \-00.1
>>>>>           +-1d.0
>>>>>           +-1d.1
>>>>>           +-1d.2
>>>>>           +-1d.3
>>>>>           +-1d.7
>>>>>           +-1e.0-[0c]----05.0
>>>>>           +-1f.0
>>>>>           +-1f.1
>>>>>           +-1f.2
>>>>>           \-1f.3
>>>>> lspci
>>>>> 00:00.0 Host bridge: Intel Corporation 5000P Chipset Memory
>>>>> Controller Hub (rev b1)
>>>>> 00:02.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI 
>>>>> Express
>>>>> x4 Port 2 (rev b1)
>>>>> 00:03.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI 
>>>>> Express
>>>>> x4 Port 3 (rev b1)
>>>>> 00:04.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI 
>>>>> Express
>>>>> x8 Port 4-5 (rev b1)
>>>>> 00:05.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI 
>>>>> Express
>>>>> x4 Port 5 (rev b1)
>>>>> 00:06.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI 
>>>>> Express
>>>>> x8 Port 6-7 (rev b1)
>>>>> 00:07.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI 
>>>>> Express
>>>>> x4 Port 7 (rev b1)
>>>>> 00:08.0 System peripheral: Intel Corporation 5000 Series Chipset 
>>>>> DMA
>>>>> Engine (rev b1)
>>>>> 00:10.0 Host bridge: Intel Corporation 5000 Series Chipset FSB
>>>>> Registers (rev b1)
>>>>> 00:10.1 Host bridge: Intel Corporation 5000 Series Chipset FSB
>>>>> Registers (rev b1)
>>>>> 00:10.2 Host bridge: Intel Corporation 5000 Series Chipset FSB
>>>>> Registers (rev b1)
>>>>> 00:11.0 Host bridge: Intel Corporation 5000 Series Chipset 
>>>>> Reserved
>>>>> Registers (rev b1)
>>>>> 00:13.0 Host bridge: Intel Corporation 5000 Series Chipset 
>>>>> Reserved
>>>>> Registers (rev b1)
>>>>> 00:15.0 Host bridge: Intel Corporation 5000 Series Chipset FBD
>>>>> Registers (rev b1)
>>>>> 00:16.0 Host bridge: Intel Corporation 5000 Series Chipset FBD
>>>>> Registers (rev b1)
>>>>> 00:1c.0 PCI bridge: Intel Corporation 631xESB/632xESB/3100 
>>>>> Chipset
>>>>> PCI Express Root Port 1 (rev 09)
>>>>> 00:1d.0 USB controller: Intel Corporation 631xESB/632xESB/3100
>>>>> Chipset UHCI USB Controller #1 (rev 09)
>>>>> 00:1d.1 USB controller: Intel Corporation 631xESB/632xESB/3100
>>>>> Chipset UHCI USB Controller #2 (rev 09)
>>>>> 00:1d.2 USB controller: Intel Corporation 631xESB/632xESB/3100
>>>>> Chipset UHCI USB Controller #3 (rev 09)
>>>>> 00:1d.3 USB controller: Intel Corporation 631xESB/632xESB/3100
>>>>> Chipset UHCI USB Controller #4 (rev 09)
>>>>> 00:1d.7 USB controller: Intel Corporation 631xESB/632xESB/3100
>>>>> Chipset EHCI USB2 Controller (rev 09)
>>>>> 00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev d9)
>>>>> 00:1f.0 ISA bridge: Intel Corporation 631xESB/632xESB/3100 
>>>>> Chipset
>>>>> LPC Interface Controller (rev 09)
>>>>> 00:1f.1 IDE interface: Intel Corporation 631xESB/632xESB IDE
>>>>> Controller (rev 09)
>>>>> 00:1f.2 SATA controller: Intel Corporation 631xESB/632xESB SATA 
>>>>> AHCI
>>>>> Controller (rev 09)
>>>>> 00:1f.3 SMBus: Intel Corporation 631xESB/632xESB/3100 Chipset 
>>>>> SMBus
>>>>> Controller (rev 09)
>>>>> 01:00.0 PCI bridge: Intel Corporation 6311ESB/6321ESB PCI Express
>>>>> Upstream Port (rev 01)
>>>>> 01:00.3 PCI bridge: Intel Corporation 6311ESB/6321ESB PCI Express 
>>>>> to
>>>>> PCI-X Bridge (rev 01)
>>>>> 02:00.0 PCI bridge: Intel Corporation 6311ESB/6321ESB PCI Express
>>>>> Downstream Port E1 (rev 01)
>>>>> 02:02.0 PCI bridge: Intel Corporation 6311ESB/6321ESB PCI Express
>>>>> Downstream Port E3 (rev 01)
>>>>> 04:00.0 Ethernet controller: Intel Corporation 80003ES2LAN 
>>>>> Gigabit
>>>>> Ethernet Controller (Copper) (rev 01)
>>>>> 04:00.1 Ethernet controller: Intel Corporation 80003ES2LAN 
>>>>> Gigabit
>>>>> Ethernet Controller (Copper) (rev 01)
>>>>> 07:00.0 RAID bus controller: Adaptec AAC-RAID (rev 09)
>>>>> 0b:00.0 Ethernet controller: Intel Corporation 82571EB Gigabit
>>>>> Ethernet Controller (rev 06)
>>>>> 0b:00.1 Ethernet controller: Intel Corporation 82571EB Gigabit
>>>>> Ethernet Controller (rev 06)
>>>>> 0c:05.0 VGA compatible controller: ASPEED Technology, Inc. ASPEED
>>>>> Graphics Family
>>>>>
>>>>>
>>>>> dmesg:
>>>>> [    4.936885] e1000: Intel(R) PRO/1000 Network Driver - version
>>>>> 7.3.21-k8-NAPI
>>>>> [    4.936887] e1000: Copyright (c) 1999-2006 Intel Corporation.
>>>>> [    4.936966] e1000e: Intel(R) PRO/1000 Network Driver - 1.9.5-k
>>>>> [    4.936967] e1000e: Copyright(c) 1999 - 2012 Intel 
>>>>> Corporation.
>>>>> [    4.938529] e1000e 0000:04:00.0: (unregistered net_device):
>>>>> Interrupt Throttling Rate (ints/sec) set to dynamic conservative 
>>>>> mode
>>>>> [    4.939598] e1000e 0000:04:00.0: irq 65 for MSI/MSI-X
>>>>> [    4.992246] e1000e 0000:04:00.0: eth0: (PCI 
>>>>> Express:2.5GT/s:Width
>>>>> x4) 00:1e:68:04:99:f8
>>>>> [    4.992657] e1000e 0000:04:00.0: eth0: Intel(R) PRO/1000 
>>>>> Network
>>>>> Connection
>>>>> [    4.992964] e1000e 0000:04:00.0: eth0: MAC: 5, PHY: 5, PBA No:
>>>>> FFFFFF-0FF
>>>>> [    4.994745] e1000e 0000:04:00.1: (unregistered net_device):
>>>>> Interrupt Throttling Rate (ints/sec) set to dynamic conservative 
>>>>> mode
>>>>> [    4.996233] e1000e 0000:04:00.1: irq 66 for MSI/MSI-X
>>>>> [    5.050901] e1000e 0000:04:00.1: eth1: (PCI 
>>>>> Express:2.5GT/s:Width
>>>>> x4) 00:1e:68:04:99:f9
>>>>> [    5.051317] e1000e 0000:04:00.1: eth1: Intel(R) PRO/1000 
>>>>> Network
>>>>> Connection
>>>>> [    5.051623] e1000e 0000:04:00.1: eth1: MAC: 5, PHY: 5, PBA No:
>>>>> FFFFFF-0FF
>>>>> [    5.051857] e1000e 0000:0b:00.0: Disabling ASPM  L1
>>>>> [    5.052168] e1000e 0000:0b:00.0: (unregistered net_device):
>>>>> Interrupt Throttling Rate (ints/sec) set to dynamic conservative 
>>>>> mode
>>>>> [    5.052611] e1000e 0000:0b:00.0: irq 67 for MSI/MSI-X
>>>>> [    5.223454] e1000e 0000:0b:00.0: eth2: (PCI 
>>>>> Express:2.5GT/s:Width
>>>>> x4) 00:1e:68:04:99:fa
>>>>> [    5.223864] e1000e 0000:0b:00.0: eth2: Intel(R) PRO/1000 
>>>>> Network
>>>>> Connection
>>>>> [    5.224178] e1000e 0000:0b:00.0: eth2: MAC: 0, PHY: 4, PBA No:
>>>>> C83246-002
>>>>> [    5.224412] e1000e 0000:0b:00.1: Disabling ASPM  L1
>>>>> [    5.224709] e1000e 0000:0b:00.1: (unregistered net_device):
>>>>> Interrupt Throttling Rate (ints/sec) set to dynamic conservative 
>>>>> mode
>>>>> [    5.225168] e1000e 0000:0b:00.1: irq 68 for MSI/MSI-X
>>>>> [    5.397603] e1000e 0000:0b:00.1: eth3: (PCI 
>>>>> Express:2.5GT/s:Width
>>>>> x4) 00:1e:68:04:99:fb
>>>>> [    5.398021] e1000e 0000:0b:00.1: eth3: Intel(R) PRO/1000 
>>>>> Network
>>>>> Connection
>>>>> [    5.398336] e1000e 0000:0b:00.1: eth3: MAC: 0, PHY: 4, PBA No:
>>>>> C83246-002
>>>>> [   13.859817] e1000e 0000:04:00.0: irq 65 for MSI/MSI-X
>>>>> [   13.962309] e1000e 0000:04:00.0: irq 65 for MSI/MSI-X
>>>>> [   17.150392] e1000e: eth0 NIC Link is Up 1000 Mbps Full Duplex,
>>>>> Flow Control: None
>>>>>
>>>>> --
>>>>> To unsubscribe from this list: send the line "unsubscribe netdev" 
>>>>> in
>>>>> the body of a message to majordomo@vger.kernel.org
>>>>> More majordomo info at 
>>>>>  http://vger.kernel.org/majordomo-info.html
>>>>
>>>>
>>>> ---
>>>> Network engineer
>>>> Denys Fedoryshchenko
>>>>
>>>> Dora Highway - Center Cebaco - 2nd Floor
>>>> Beirut, Lebanon
>>>> Tel:    +961 1 247373
>>>> E-Mail: denys@visp.net.lb
>>>> --
>>>> To unsubscribe from this list: send the line "unsubscribe netdev" 
>>>> in
>>>> the body of a message to majordomo@vger.kernel.org
>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>>>
>>> ---
>>> Network engineer
>>> Denys Fedoryshchenko
>>>
>>> Dora Highway - Center Cebaco - 2nd Floor
>>> Beirut, Lebanon
>>> Tel:    +961 1 247373
>>> E-Mail: denys@visp.net.lb
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe netdev" 
>>> in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>>
>> ---
>> Network engineer
>> Denys Fedoryshchenko
>>
>> Dora Highway - Center Cebaco - 2nd Floor
>> Beirut, Lebanon
>> Tel:    +961 1 247373
>> E-Mail: denys@visp.net.lb
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

---
Denys Fedoryshchenko, Network Engineer, Virtual ISP S.A.L.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel&#174; Ethernet, visit http://communities.intel.com/community/wired

^ permalink raw reply

* Re: Strange latency spikes/TX network stalls on Sun Fire X4150(x86) and e1000e
From: Denys Fedoryshchenko @ 2012-05-19  2:29 UTC (permalink / raw)
  To: Tom Herbert; +Cc: e1000-devel, netdev, jesse.brandeburg, davem
In-Reply-To: <CA+mtBx9axFKCjLwDYMvXXP2nB_og896kAhG0UYWaK6PTAXhPcw@mail.gmail.com>

>
> Not expected, we've be running e1000e with BQL for a while.  A few 
> questions:
>
> 1) What kernel are you running?
> 2) What sort of traffic load are you using?
> 3) Have you tried a different interrupt mode?
>
1)Tested 3.3, 3.3.6, 3.4-rc7.
2)Easy to reproduce:

)Open 3 ssh consoles to server with problems
)First console "ping -s1472 -i0.0001 nearby.ip" (It will help to 
trigger problem quickier)
)Second console "ping -s1472 -i0.1 nearby.ip" (Easy to see when network 
stalls - ping rise to 1000-2000ms)
)Open some large text file and scroll it down. After while you will 
feel it "stalls" and just switch to second
console to check if ping risen recently.

It was occured also on loaded NAT server, after i remove shaper from 
it, that was limiting traffic to 350Mbps,
but there traffic pattern much more complicated.

3)Not yet, i run it with default parameters. I will try now.

---
Denys Fedoryshchenko, Network Engineer, Virtual ISP S.A.L.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel&#174; Ethernet, visit http://communities.intel.com/community/wired

^ permalink raw reply

* Re: Strange latency spikes/TX network stalls on Sun Fire X4150(x86) and e1000e
From: Tom Herbert @ 2012-05-19  2:07 UTC (permalink / raw)
  To: Denys Fedoryshchenko; +Cc: e1000-devel, netdev, jesse.brandeburg, davem
In-Reply-To: <d3a88d6c741394a48aee6179d58e4edf@visp.net.lb>

On Fri, May 18, 2012 at 7:04 AM, Denys Fedoryshchenko <denys@visp.net.lb> wrote:
> It seems logic in BQL has serious issues. The most bad thing, if someone
> don't want limits (especially low as this),
> there is no way to disable BQL in Kernel configuration, only tuning each
> interface over sysfs values.
>
echo max > /sys/class/net/ethX/tx-Y/byte_queue_limits/limit_min
 should disable BQL for a queue

> I just did short debug:
> if (limit != dql->limit) {
> +                printk("New limit %d\n", dql->limit);
>                dql->limit = limit;
>                ovlimit = 0;
> }
>
> And got this numbers:
> [   18.696839] New limit 0
> [   19.622967] New limit 42
> [   20.037810] New limit 165
> [   35.473666] New limit 386
> [   37.418591] New limit 1374
> [   37.420064] New limit 6432
> [   39.209480] New limit 16548
> [   39.214773] New limit 1704
> [   40.696065] New limit 6762
> [   40.696390] New limit 15564
> [   41.921120] New limit 25788
> [   41.921165] New limit 388
> [   42.696286] New limit 534
> [   42.696539] New limit 1096
> [   42.696719] New limit 2304
> [   53.360394] New limit 24334
> [   54.696072] New limit 484
> [   54.696135] New limit 934
>
> This means sometimes limit goes below MTU, and till queue limit increased, i
> will see this traffic "stalled",
> if there is large packet in queue. Probably BQL miscalculate queue as full
> because of some specific handling
> of sent packets in e1000e on this specific hardware. Because it should not
> be full, it is 1Gbps wire,
> and it is empty. So in result, instead of eliminating latency, it is adding
> it.
>

Not expected, we've be running e1000e with BQL for a while.  A few questions:

1) What kernel are you running?
2) What sort of traffic load are you using?
3) Have you tried a different interrupt mode?

Per #3, I am wondering if dynamic conservative mode interrupt
throttling is not producing interrupts deterministically for BQL.
I'll try to reproduce the problem in this mode.

> I can make a patch that will make minimum BQL value not less than MTU +
> overhead, is it ok like this?
> Probably it will solve issue, but it is more workaround and safety fuse,
> than a solution.
>
That would just be a bandaid and could just make this a latent issue
for the future.

Tom

>
> On 2012-05-17 19:54, Denys Fedoryshchenko wrote:
>>
>> Also i notice, limit constantly changing over time (even i am not
>> touching it).
>>
>> centaur ~ # grep "" /sys/class/net/eth0/queues/tx-0/byte_queue_limits/*
>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/hold_time:1000
>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/inflight:0
>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/limit:13018
>>
>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/limit_max:1879048192
>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/limit_min:0
>> centaur ~ # grep "" /sys/class/net/eth0/queues/tx-0/byte_queue_limits/*
>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/hold_time:1000
>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/inflight:4542
>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/limit:13018
>>
>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/limit_max:1879048192
>> /sys/class/net/eth0/queues/tx-0/byte_queue_limits/limit_min:0
>>
>> Is it supposed to be like this?
>>
>> On 2012-05-17 16:42, Denys Fedoryshchenko wrote:
>>>
>>> Found commit that cause problem:
>>>
>>> author  Tom Herbert <therbert@google.com>
>>> Mon, 28 Nov 2011 16:33:16 +0000 (16:33 +0000)
>>> committer       David S. Miller <davem@davemloft.net>
>>> Tue, 29 Nov 2011 17:46:19 +0000 (12:46 -0500)
>>> commit  3f0cfa3bc11e7f00c9994e0f469cbc0e7da7b00c
>>> tree    d6670a4f94b2b9dedacc38edb6f0e1306b889f6b        tree | snapshot
>>> parent  114cf5802165ee93e3ab461c9c505cd94a08b800        commit | diff
>>> e1000e: Support for byte queue limits
>>>
>>> Changes to e1000e to use byte queue limits.
>>>
>>> Signed-off-by: Tom Herbert <therbert@google.com>
>>> Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
>>> Signed-off-by: David S. Miller <davem@davemloft.net>
>>>
>>> If i reverse it, problem disappearing.
>>>
>>> How i reproduce it:
>>> In two consoles do "fast" ping to nearby host
>>> ping 194.146.XXX.XXX -s1472 -i0.0001
>>> ping 194.146.XXX.XXX -s1472 -i0.1
>>>
>>> For third open ssh to host with "problem", open mcedit, and just
>>> scroll down large text file.
>>> After few seconds some "stalls" will occur, and in ping history i can
>>> see:
>>> 1480 bytes from 194.146.153.7: icmp_req=1797 ttl=64 time=0.161 ms
>>> 1480 bytes from 194.146.153.7: icmp_req=1798 ttl=64 time=0.198 ms
>>> 1480 bytes from 194.146.153.7: icmp_req=1799 ttl=64 time=0.340 ms
>>> 1480 bytes from 194.146.153.7: icmp_req=1800 ttl=64 time=0.381 ms
>>> 1480 bytes from 194.146.153.7: icmp_req=1801 ttl=64 time=914 ms
>>> 1480 bytes from 194.146.153.7: icmp_req=1802 ttl=64 time=804 ms
>>> 1480 bytes from 194.146.153.7: icmp_req=1803 ttl=64 time=704 ms
>>> 1480 bytes from 194.146.153.7: icmp_req=1804 ttl=64 time=594 ms
>>> 1480 bytes from 194.146.153.7: icmp_req=1805 ttl=64 time=0.287 ms
>>> 1480 bytes from 194.146.153.7: icmp_req=1806 ttl=64 time=0.226 ms
>>>
>>>
>>> If i apply small patch - problem will disappear. Sure it is not a
>>> solution, but
>>> let me know how i can help to debug problem more.
>>>
>>> --- netdev.c    2012-05-12 20:08:37.000000000 +0300
>>> +++ netdev.c.patched    2012-05-17 16:32:28.895760472 +0300
>>> @@ -1135,7 +1135,7 @@
>>>
>>>        tx_ring->next_to_clean = i;
>>>
>>> -       netdev_completed_queue(netdev, pkts_compl, bytes_compl);
>>> +//     netdev_completed_queue(netdev, pkts_compl, bytes_compl);
>>>
>>>  #define TX_WAKE_THRESHOLD 32
>>>        if (count && netif_carrier_ok(netdev) &&
>>> @@ -2263,7 +2263,7 @@
>>>                e1000_put_txbuf(adapter, buffer_info);
>>>        }
>>>
>>> -       netdev_reset_queue(adapter->netdev);
>>> +//     netdev_reset_queue(adapter->netdev);
>>>        size = sizeof(struct e1000_buffer) * tx_ring->count;
>>>        memset(tx_ring->buffer_info, 0, size);
>>>
>>> @@ -5056,7 +5056,7 @@
>>>        /* if count is 0 then mapping error has occurred */
>>>        count = e1000_tx_map(adapter, skb, first, max_per_txd,
>>> nr_frags, mss);
>>>        if (count) {
>>> -               netdev_sent_queue(netdev, skb->len);
>>> +//             netdev_sent_queue(netdev, skb->len);
>>>                e1000_tx_queue(adapter, tx_flags, count);
>>>                /* Make sure there is space in the ring for the next send.
>>> */
>>>                e1000_maybe_stop_tx(netdev, MAX_SKB_FRAGS + 2);
>>>
>>>
>>>
>>> On 2012-05-15 17:15, Denys Fedoryshchenko wrote:
>>>>
>>>> Hi
>>>>
>>>> I have two identical servers, Sun Fire X4150, both has different
>>>> flavors of Linux, x86_64 and i386.
>>>> 04:00.0 Ethernet controller: Intel Corporation 80003ES2LAN Gigabit
>>>> Ethernet Controller (Copper) (rev 01)
>>>> 04:00.1 Ethernet controller: Intel Corporation 80003ES2LAN Gigabit
>>>> Ethernet Controller (Copper) (rev 01)
>>>> 0b:00.0 Ethernet controller: Intel Corporation 82571EB Gigabit
>>>> Ethernet Controller (rev 06)
>>>> 0b:00.1 Ethernet controller: Intel Corporation 82571EB Gigabit
>>>> Ethernet Controller (rev 06)
>>>> I am using now interface:
>>>> #ethtool -i eth0
>>>> driver: e1000e
>>>> version: 1.9.5-k
>>>> firmware-version: 2.1-11
>>>> bus-info: 0000:04:00.0
>>>> There is 2 CPU , Intel(R) Xeon(R) CPU           E5440  @ 2.83GHz .
>>>>
>>>> i386 was acting as NAT and shaper, and as soon as i removed shaper
>>>> from it, i started to experience strange lockups, e.g. traffic is
>>>> normal for 5-30 seconds, then short lockup for 500-3000ms (usually
>>>> around 1000ms) with dropped packets counter increasing. I was
>>>> suspecting it is due load, but it seems was wrong.
>>>> Recently, on another server, x86_64 i am using as development, i
>>>> upgrade kernel (it was old, from 2.6 series) and on completely idle
>>>> machine started to experience same latency spikes, while i am just
>>>> running mc and for example typing in text editor - i notice "stalls".
>>>> After i investigate it a little more, i notice also small amount of
>>>> drops on interface. No tcpdump running. Also this machine is idle, and
>>>> the only traffic there - some small broadcasts from network, my ssh,
>>>> and ping.
>>>>
>>>> Dropped packets in ifconfig
>>>>          RX packets:3752868 errors:0 dropped:5350 overruns:0 frame:0
>>>> Counter is increasing sometimes, when this stall happening.
>>>>
>>>> ethtool -S is clean, there is no dropped packets.
>>>>
>>>> I did tried to check load (mpstat and perf), there is nothing
>>>> suspicious, latencytop also doesn't show anything suspicious.
>>>> dropwatch report a lot of drops, but mostly because there is some
>>>> broadcasts and etc. tcpdump at the moment of such drops doesn't show
>>>> anything suspicious.
>>>> Changed qdisc from default fifo_fast to bfifo, without any result.
>>>> Tried:  ethtool -K eth0 tso off gso off gro off sg off , no result
>>>> Problem occured at 3.3.6 - 3.4.0-rc7, most probably 3.3.0 also, but i
>>>> don't remember for sure. I thik on some kernels like 3.1 probably it
>>>> doesn't occur, i will check it soon, because it is not always reliable
>>>> to reproduce it. All tests i did on 3.4.0-rc7.
>>>>
>>>> I did run also in background tcpdump, additionally iptables with
>>>> timestamps, and at time when stall occured, seems i am still receiving
>>>> packets properly, also on iperf udp  (from some host to this SunFire)
>>>> at this moments no packets missing. But i am sure RX interface errors
>>>> are increasing.
>>>> If i do iperf from SunFire to test host - there is packetloss at
>>>> moments when stall occured.
>>>>
>>>> I suspect that by some reason network card stop to transmit, but
>>>> unable to pinpoint issue. All other hosts in this network are fine and
>>>> don't have such problems.
>>>> Can you help me with that please? Maybe i can provide more debug
>>>> information, compile with patches and etc. Also i will try to fallback
>>>> to 3.1 and 3.0 kernels.
>>>>
>>>> Here it is how it occurs and i am reproducing it:
>>>> I'm just opening file, and start to scroll it in mc, then in another
>>>> console i run ping
>>>> [1337089061.844167] 1480 bytes from 194.146.153.20: icmp_req=162
>>>> ttl=64 time=0.485 ms
>>>> [1337089061.944138] 1480 bytes from 194.146.153.20: icmp_req=163
>>>> ttl=64 time=0.470 ms
>>>> [1337089062.467759] 1480 bytes from 194.146.153.20: icmp_req=164
>>>> ttl=64 time=424 ms
>>>> [1337089062.467899] 1480 bytes from 194.146.153.20: icmp_req=165
>>>> ttl=64 time=324 ms
>>>> [1337089062.468058] 1480 bytes from 194.146.153.20: icmp_req=166
>>>> ttl=64 time=214 ms
>>>> [1337089062.468161] 1480 bytes from 194.146.153.20: icmp_req=167
>>>> ttl=64 time=104 ms
>>>> [1337089062.468958] 1480 bytes from 194.146.153.20: icmp_req=168
>>>> ttl=64 time=1.15 ms
>>>> [1337089062.568604] 1480 bytes from 194.146.153.20: icmp_req=169
>>>> ttl=64 time=0.477 ms
>>>> [1337089062.668909] 1480 bytes from 194.146.153.20: icmp_req=170
>>>> ttl=64 time=0.667 ms
>>>>
>>>> Remote host tcpdump:
>>>> 1337089061.934737 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>> reply, id 3486, seq 163, length 1480
>>>> 1337089062.458360 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>> request, id 3486, seq 164, length 1480
>>>> 1337089062.458380 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>> reply, id 3486, seq 164, length 1480
>>>> 1337089062.458481 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>> request, id 3486, seq 165, length 1480
>>>> 1337089062.458502 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>> reply, id 3486, seq 165, length 1480
>>>> 1337089062.458606 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>> request, id 3486, seq 166, length 1480
>>>> 1337089062.458623 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>> reply, id 3486, seq 166, length 1480
>>>> 1337089062.458729 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>> request, id 3486, seq 167, length 1480
>>>> 1337089062.458745 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>> reply, id 3486, seq 167, length 1480
>>>> 1337089062.459537 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>> request, id 3486, seq 168, length 1480
>>>> 1337089062.459545 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>> reply, id 3486, seq 168, length 1480
>>>>
>>>> Local host(SunFire) tcpdump:
>>>> 1337089061.844140 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>> reply, id 3486, seq 162, length 1480
>>>> 1337089061.943661 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>> request, id 3486, seq 163, length 1480
>>>> 1337089061.944124 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>> reply, id 3486, seq 163, length 1480
>>>> 1337089062.465622 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>> request, id 3486, seq 164, length 1480
>>>> 1337089062.465630 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>> request, id 3486, seq 165, length 1480
>>>> 1337089062.465632 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>> request, id 3486, seq 166, length 1480
>>>> 1337089062.465634 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>> request, id 3486, seq 167, length 1480
>>>> 1337089062.467730 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>> reply, id 3486, seq 164, length 1480
>>>> 1337089062.467785 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>> request, id 3486, seq 168, length 1480
>>>> 1337089062.467884 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>> reply, id 3486, seq 165, length 1480
>>>> 1337089062.468035 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>> reply, id 3486, seq 166, length 1480
>>>> 1337089062.468129 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>> reply, id 3486, seq 167, length 1480
>>>> 1337089062.468928 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>> reply, id 3486, seq 168, length 1480
>>>> 1337089062.568112 IP 194.146.153.22 > 194.146.153.20: ICMP echo
>>>> request, id 3486, seq 169, length 1480
>>>> 1337089062.568578 IP 194.146.153.20 > 194.146.153.22: ICMP echo
>>>> reply, id 3486, seq 169, length 1480
>>>>
>>>> lspci -t
>>>> centaur src # lspci -t
>>>> -[0000:00]-+-00.0
>>>>           +-02.0-[01-05]--+-00.0-[02-04]--+-00.0-[03]--
>>>>           |               |               \-02.0-[04]--+-00.0
>>>>           |               |                            \-00.1
>>>>           |               \-00.3-[05]--
>>>>           +-03.0-[06]--
>>>>           +-04.0-[07]----00.0
>>>>           +-05.0-[08]--
>>>>           +-06.0-[09]--
>>>>           +-07.0-[0a]--
>>>>           +-08.0
>>>>           +-10.0
>>>>           +-10.1
>>>>           +-10.2
>>>>           +-11.0
>>>>           +-13.0
>>>>           +-15.0
>>>>           +-16.0
>>>>           +-1c.0-[0b]--+-00.0
>>>>           |            \-00.1
>>>>           +-1d.0
>>>>           +-1d.1
>>>>           +-1d.2
>>>>           +-1d.3
>>>>           +-1d.7
>>>>           +-1e.0-[0c]----05.0
>>>>           +-1f.0
>>>>           +-1f.1
>>>>           +-1f.2
>>>>           \-1f.3
>>>> lspci
>>>> 00:00.0 Host bridge: Intel Corporation 5000P Chipset Memory
>>>> Controller Hub (rev b1)
>>>> 00:02.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express
>>>> x4 Port 2 (rev b1)
>>>> 00:03.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express
>>>> x4 Port 3 (rev b1)
>>>> 00:04.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express
>>>> x8 Port 4-5 (rev b1)
>>>> 00:05.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express
>>>> x4 Port 5 (rev b1)
>>>> 00:06.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express
>>>> x8 Port 6-7 (rev b1)
>>>> 00:07.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express
>>>> x4 Port 7 (rev b1)
>>>> 00:08.0 System peripheral: Intel Corporation 5000 Series Chipset DMA
>>>> Engine (rev b1)
>>>> 00:10.0 Host bridge: Intel Corporation 5000 Series Chipset FSB
>>>> Registers (rev b1)
>>>> 00:10.1 Host bridge: Intel Corporation 5000 Series Chipset FSB
>>>> Registers (rev b1)
>>>> 00:10.2 Host bridge: Intel Corporation 5000 Series Chipset FSB
>>>> Registers (rev b1)
>>>> 00:11.0 Host bridge: Intel Corporation 5000 Series Chipset Reserved
>>>> Registers (rev b1)
>>>> 00:13.0 Host bridge: Intel Corporation 5000 Series Chipset Reserved
>>>> Registers (rev b1)
>>>> 00:15.0 Host bridge: Intel Corporation 5000 Series Chipset FBD
>>>> Registers (rev b1)
>>>> 00:16.0 Host bridge: Intel Corporation 5000 Series Chipset FBD
>>>> Registers (rev b1)
>>>> 00:1c.0 PCI bridge: Intel Corporation 631xESB/632xESB/3100 Chipset
>>>> PCI Express Root Port 1 (rev 09)
>>>> 00:1d.0 USB controller: Intel Corporation 631xESB/632xESB/3100
>>>> Chipset UHCI USB Controller #1 (rev 09)
>>>> 00:1d.1 USB controller: Intel Corporation 631xESB/632xESB/3100
>>>> Chipset UHCI USB Controller #2 (rev 09)
>>>> 00:1d.2 USB controller: Intel Corporation 631xESB/632xESB/3100
>>>> Chipset UHCI USB Controller #3 (rev 09)
>>>> 00:1d.3 USB controller: Intel Corporation 631xESB/632xESB/3100
>>>> Chipset UHCI USB Controller #4 (rev 09)
>>>> 00:1d.7 USB controller: Intel Corporation 631xESB/632xESB/3100
>>>> Chipset EHCI USB2 Controller (rev 09)
>>>> 00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev d9)
>>>> 00:1f.0 ISA bridge: Intel Corporation 631xESB/632xESB/3100 Chipset
>>>> LPC Interface Controller (rev 09)
>>>> 00:1f.1 IDE interface: Intel Corporation 631xESB/632xESB IDE
>>>> Controller (rev 09)
>>>> 00:1f.2 SATA controller: Intel Corporation 631xESB/632xESB SATA AHCI
>>>> Controller (rev 09)
>>>> 00:1f.3 SMBus: Intel Corporation 631xESB/632xESB/3100 Chipset SMBus
>>>> Controller (rev 09)
>>>> 01:00.0 PCI bridge: Intel Corporation 6311ESB/6321ESB PCI Express
>>>> Upstream Port (rev 01)
>>>> 01:00.3 PCI bridge: Intel Corporation 6311ESB/6321ESB PCI Express to
>>>> PCI-X Bridge (rev 01)
>>>> 02:00.0 PCI bridge: Intel Corporation 6311ESB/6321ESB PCI Express
>>>> Downstream Port E1 (rev 01)
>>>> 02:02.0 PCI bridge: Intel Corporation 6311ESB/6321ESB PCI Express
>>>> Downstream Port E3 (rev 01)
>>>> 04:00.0 Ethernet controller: Intel Corporation 80003ES2LAN Gigabit
>>>> Ethernet Controller (Copper) (rev 01)
>>>> 04:00.1 Ethernet controller: Intel Corporation 80003ES2LAN Gigabit
>>>> Ethernet Controller (Copper) (rev 01)
>>>> 07:00.0 RAID bus controller: Adaptec AAC-RAID (rev 09)
>>>> 0b:00.0 Ethernet controller: Intel Corporation 82571EB Gigabit
>>>> Ethernet Controller (rev 06)
>>>> 0b:00.1 Ethernet controller: Intel Corporation 82571EB Gigabit
>>>> Ethernet Controller (rev 06)
>>>> 0c:05.0 VGA compatible controller: ASPEED Technology, Inc. ASPEED
>>>> Graphics Family
>>>>
>>>>
>>>> dmesg:
>>>> [    4.936885] e1000: Intel(R) PRO/1000 Network Driver - version
>>>> 7.3.21-k8-NAPI
>>>> [    4.936887] e1000: Copyright (c) 1999-2006 Intel Corporation.
>>>> [    4.936966] e1000e: Intel(R) PRO/1000 Network Driver - 1.9.5-k
>>>> [    4.936967] e1000e: Copyright(c) 1999 - 2012 Intel Corporation.
>>>> [    4.938529] e1000e 0000:04:00.0: (unregistered net_device):
>>>> Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode
>>>> [    4.939598] e1000e 0000:04:00.0: irq 65 for MSI/MSI-X
>>>> [    4.992246] e1000e 0000:04:00.0: eth0: (PCI Express:2.5GT/s:Width
>>>> x4) 00:1e:68:04:99:f8
>>>> [    4.992657] e1000e 0000:04:00.0: eth0: Intel(R) PRO/1000 Network
>>>> Connection
>>>> [    4.992964] e1000e 0000:04:00.0: eth0: MAC: 5, PHY: 5, PBA No:
>>>> FFFFFF-0FF
>>>> [    4.994745] e1000e 0000:04:00.1: (unregistered net_device):
>>>> Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode
>>>> [    4.996233] e1000e 0000:04:00.1: irq 66 for MSI/MSI-X
>>>> [    5.050901] e1000e 0000:04:00.1: eth1: (PCI Express:2.5GT/s:Width
>>>> x4) 00:1e:68:04:99:f9
>>>> [    5.051317] e1000e 0000:04:00.1: eth1: Intel(R) PRO/1000 Network
>>>> Connection
>>>> [    5.051623] e1000e 0000:04:00.1: eth1: MAC: 5, PHY: 5, PBA No:
>>>> FFFFFF-0FF
>>>> [    5.051857] e1000e 0000:0b:00.0: Disabling ASPM  L1
>>>> [    5.052168] e1000e 0000:0b:00.0: (unregistered net_device):
>>>> Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode
>>>> [    5.052611] e1000e 0000:0b:00.0: irq 67 for MSI/MSI-X
>>>> [    5.223454] e1000e 0000:0b:00.0: eth2: (PCI Express:2.5GT/s:Width
>>>> x4) 00:1e:68:04:99:fa
>>>> [    5.223864] e1000e 0000:0b:00.0: eth2: Intel(R) PRO/1000 Network
>>>> Connection
>>>> [    5.224178] e1000e 0000:0b:00.0: eth2: MAC: 0, PHY: 4, PBA No:
>>>> C83246-002
>>>> [    5.224412] e1000e 0000:0b:00.1: Disabling ASPM  L1
>>>> [    5.224709] e1000e 0000:0b:00.1: (unregistered net_device):
>>>> Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode
>>>> [    5.225168] e1000e 0000:0b:00.1: irq 68 for MSI/MSI-X
>>>> [    5.397603] e1000e 0000:0b:00.1: eth3: (PCI Express:2.5GT/s:Width
>>>> x4) 00:1e:68:04:99:fb
>>>> [    5.398021] e1000e 0000:0b:00.1: eth3: Intel(R) PRO/1000 Network
>>>> Connection
>>>> [    5.398336] e1000e 0000:0b:00.1: eth3: MAC: 0, PHY: 4, PBA No:
>>>> C83246-002
>>>> [   13.859817] e1000e 0000:04:00.0: irq 65 for MSI/MSI-X
>>>> [   13.962309] e1000e 0000:04:00.0: irq 65 for MSI/MSI-X
>>>> [   17.150392] e1000e: eth0 NIC Link is Up 1000 Mbps Full Duplex,
>>>> Flow Control: None
>>>>
>>>> --
>>>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>>>> the body of a message to majordomo@vger.kernel.org
>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>>>
>>> ---
>>> Network engineer
>>> Denys Fedoryshchenko
>>>
>>> Dora Highway - Center Cebaco - 2nd Floor
>>> Beirut, Lebanon
>>> Tel:    +961 1 247373
>>> E-Mail: denys@visp.net.lb
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>>
>> ---
>> Network engineer
>> Denys Fedoryshchenko
>>
>> Dora Highway - Center Cebaco - 2nd Floor
>> Beirut, Lebanon
>> Tel:    +961 1 247373
>> E-Mail: denys@visp.net.lb
>> --
>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
> ---
> Network engineer
> Denys Fedoryshchenko
>
> Dora Highway - Center Cebaco - 2nd Floor
> Beirut, Lebanon
> Tel:    +961 1 247373
> E-Mail: denys@visp.net.lb

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel&#174; Ethernet, visit http://communities.intel.com/community/wired

^ permalink raw reply

* Re: 3.3.0, 3.4-rc1 reproducible tun Oops
From: Simon Kirby @ 2012-05-19  1:07 UTC (permalink / raw)
  To: Stanislav Kinsbursky; +Cc: Eric Dumazet, netdev@vger.kernel.org
In-Reply-To: <4F8EA64B.2050208@parallels.com>

On Wed, Apr 18, 2012 at 03:32:27PM +0400, Stanislav Kinsbursky wrote:

> 17.04.2012 22:35, Simon Kirby ??????????:
> >On Tue, Apr 17, 2012 at 04:18:53PM +0400, Stanislav Kinsbursky wrote:
> >>
> >>Hi, Simon.
> >>Could you please try to apply the patch below on top of your the
> >>tree (with 1ab5ecb90cb6a3df1476e052f76a6e8f6511cb3d applied) and
> >>check does it fix the problem:
> >>
> >>diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> >>index bb8c72c..1fc4622 100644
> >>--- a/drivers/net/tun.c
> >>+++ b/drivers/net/tun.c
> >>@@ -1540,13 +1540,10 @@ static int tun_chr_close(struct inode
> >>*inode, struct file *file)
> >>  			if (dev->reg_state == NETREG_REGISTERED)
> >>  				unregister_netdevice(dev);
> >>  			rtnl_unlock();
> >>-		}
> >>+		} else
> >>+			sock_put(tun->socket.sk);
> >>  	}
> >>
> >>-	tun = tfile->tun;
> >>-	if (tun)
> >>-		sock_put(tun->socket.sk);
> >>-
> >>  	put_net(tfile->net);
> >>  	kfree(tfile);
> >
> >(Whitespace-damaged patch, applied manually)
> >
> >Yes, I no longer see crashes with this applied. I haven't tried with
> >kmemleak or similar, but it seems to work.
> >
> >Thanks,
> >
> 
> This bug looks like double free, but I can't understand how does this can happen...
> Simon, would be really great, if you'll describe in details some
> simple way, how to reproduce the bug.

Oh, sorry, I did not see this until now. I just noticed it was still
floating in my tree with no upstream changes yet, then found your email.
I still have not seen any issues since applying your patch.

I was definitely seeing the issue on 3.4-rc3. I can try and see if it
still occurs with your patch removed, if that would help.

Do you have a box on which you can set up an SSH tunnel? In my case, I
can reproduce it easily with three boxes. From home, I run ssh to my work
box to establish the layer 2 tunnel. This goes through a ProxyCommand to
jump through an entry box, but I don't think that should matter. I use a
cheap tunnel start script similar to this:

work_net=10.0.0.0/8
work_tun_ip=10.x.x.x
home_tun_ip=10.x.x.x
echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp
ssh -w any:any <work box> "ifconfig tun0 $work_tun_ip pointopoint
$home_tun_ip; echo 'ifconfig tun0 $home_tun_ip pointopoint $work_tun_ip
&& ip route add $work_net via $work_tun_ip'; sleep 1d" | sh -v

...there's probably a better way, but it works. To reproduce, I log in
to a third box over this tunnel, and start a "vmstat 1", so that packets
keep coming back to the tunnel host. ^C on the SSH session will then
produce an Oops within a second.

With CONFIG_SLUB_DEBUG=y and booting with slub_debug=FZPU, I got the
Redzone overwritten notice. Without it, the box usually Oopses and
hangs immediately. Sometimes, I might have to reconnect the tunnel and
^C it once more. If I don't have that vmstat session open, it usually
doesn't crash.

Does this work for you?

Simon-

^ permalink raw reply

* GNU Linux 2.6.23: NULL ptr dereference in drop_buffers
From: Sam Portolla @ 2012-05-19  0:09 UTC (permalink / raw)
  To: netdev



Have seen one instance of this issue on above kernel version. 
Have not been able to reproduce. There is a discussion on this 
same issue here:
http://fixunix.com/kernel/395849-bug-2-6-26-rc1-git8-null-reference-drop_buffers.html

but there is no solution given above. Can someone please provide 
a root cause and diffs to fix this?

Logs showing the issue followed by some analysis:

Unable to handle kernel NULL pointer dereference at 
0000000000000000 RIP: 
 [<ffffffff802b3e69>] drop_buffers+0x29/0x120

RIP: 0010:[<ffffffff802b3e69>]  
[<ffffffff802b3e69>] drop_buffers+0x29/0x120
RSP: 0000:ffff81026033bb00  EFLAGS: 00010207
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff81025c48c7d8
RDX: 0000000000000000 RSI: ffff81026033bb40 RDI: ffff81026fb7c238
RBP: ffff81026033bb30 R08: 00000000ffffffff R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000003 R12: ffff81024ecc4000
R13: ffff81025c48c7d8 R14: ffff81026fb7c238 R15: ffff81026033bb40
FS:  0000000000000000(0000) GS:ffff810267703400(0000) 
knlGS:0000000000000000
CS:  0010 DS: 0018 ES: 0018 CR0: 000000008005003b
CR2: 0000000000000000 CR3: 000000002b8a4000 CR4: 00000000000006e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process kswapd0 (pid: 322, threadinfo ffff810260338000, 
task ffff810262108000)
Stack:  ffff81026f9ac638 ffff81026fb7c238 ffff81025c48c7d8
 ffff81025c48c7d8
 ffff81026033bd90 0000000000000001 ffff81026033bb60 
ffffffff802b41c6
 0000000000000000 ffff81026fb7c238 ffff81026033be80 
ffff81025c48c7d8
Call Trace:
 [<ffffffff802b41c6>] try_to_free_buffers+0x46/0xb0
 [<ffffffff80264c8e>] try_to_release_page+0x2e/0x50
 [<ffffffff8026bf73>] shrink_page_list+0x533/0x6f0
 [<ffffffff8026aa09>] release_pages+0x189/0x1c0
 [<ffffffff8026c273>] isolate_lru_pages+0xd3/0x1e0
 [<ffffffff8026c523>] shrink_inactive_list+0x163/0x410
 [<ffffffff8026cde5>] shrink_zone+0xf5/0x140
 [<ffffffff8026d507>] kswapd+0x387/0x540
 [<ffffffff802475e0>] autoremove_wake_function+0x0/0x40
 [<ffffffff8026d180>] kswapd+0x0/0x540
 [<ffffffff80246ef8>] kthread+0x68/0xa0
 [<ffffffff80229e24>] schedule_tail+0x54/0xc0
 [<ffffffff8020d058>] child_rip+0xa/0x12
 [<ffffffff80246e90>] kthread+0x0/0xa0
 [<ffffffff8020d04e>] child_rip+0x0/0x12

#### from GDB, the bh pointer in the 1st do/while loop in the 
drop_buffers() is NULL.


struct buffer_head *head(%r12)
This the 1st do/while loop:

0xffffffff802b3e69 <drop_buffers+41>:   mov    (%rbx),%eax

0xffffffff802b3e8d <drop_buffers+77>:  
 mov    0x8(%rbx),%rbx
0xffffffff802b3e91 <drop_buffers+81>:   cmp    %r12,%rbx
0xffffffff802b3e94 <drop_buffers+84>:  
 jne    0xffffffff802b3e69 <drop_buffers+41>

RBX: 0000000000000000


2825                    bh = bh->b_this_page;
2826            } while (bh != head);

In above do/while loop, the bh is NULL as %rbx. 
Function listing below:

static int
drop_buffers(struct page *page, 
struct buffer_head **buffers_to_free)
{
	struct buffer_head *head = page_buffers(page);
	struct buffer_head *bh;

	bh = head;
	do {
		if (buffer_write_io_error(bh) && page->mapping)
			set_bit(AS_EIO, &page->mapping->flags);
		if (buffer_busy(bh))
			goto failed;
		bh = bh->b_this_page;
	} while (bh != head);

	do {
		struct buffer_head *next = bh->b_this_page;

		if (!list_empty(&bh->b_assoc_buffers))
			__remove_assoc_queue(bh);
		bh = next;
	} while (bh != head);
	*buffers_to_free = head;
	__clear_page_buffers(page);
	return 1;
failed:
	return 0;
}

^ permalink raw reply

* Re: [RFC 13/13] USB: Disable hub-initiated LPM for comms devices.
From: Sarah Sharp @ 2012-05-18 23:09 UTC (permalink / raw)
  To: Tilman Schmidt
  Cc: gigaset307x-common-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	libertas-dev-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Greg Kroah-Hartman,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	users-poMEt7QlJxcwIE2E9O76wjtx2kNaKg5H,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA,
	ath9k-devel-xDcbHBWguxHbcTqmT+pZeQ, Alan Stern, Hansjoerg Lipp,
	netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <4FB6CF71.7080307-ZTO5kqT2PaM@public.gmane.org>

On Sat, May 19, 2012 at 12:38:41AM +0200, Tilman Schmidt wrote:
> Am 17.05.2012 19:31, schrieb Sarah Sharp:
> > On Thu, May 17, 2012 at 07:07:32PM +0200, Tilman Schmidt wrote:
> >>
> >> I follow the argument for class drivers. But this patch also
> >> modifies drivers for specific existing USB 2.0 only devices
> >> which are unlikely to ever grow USB 3.0 support, such as the
> >> Gigaset ISDN driver:
> >>
> >>>  drivers/isdn/gigaset/bas-gigaset.c            |    1 +
> >>>  drivers/isdn/gigaset/usb-gigaset.c            |    1 +
> > 
> > Is there a particular reason why you think that driver is unlikely to
> > ever get USB 3.0 support?
> 
> Actually, there is. :-)
> - The USB devices driven by this driver aren't built anymore.
> - Their USB interface design is quite, um, idiosyncratic, and it's
>   pretty unlikely that anyone will reuse it. (At least I truly hope
>   no one will.)
> - Their successor models have completely different and incompatible
>   USB interfaces which this driver is unable to handle.

I see!

> >> What is the interest of setting the disable_hub_initiated_lpm
> >> flag for these?
> > 
> > It's partially to lay the foundation for anyone who wants to make a USB
> > 3.0 communications driver in the future.  They're likely to start from
> > some USB 2.0 class driver, and copy a lot of code.  If they notice that
> > flag is set in all the USB communications class drivers, they're likely
> > to set it as well.
> 
> You've got a point there.
> 
> > I'm not quite sure where the best place to provide documentation on the
> > flag is.  I've added the kernel doc comments to the structure, but maybe
> > it needs to be documented somewhere in Documentation/usb/?
> 
> Documentation/usb/power-management.txt would seem like a natural
> place. Although it appears to limit itself to "suspending" in its
> first paragraph, it does have a section "xHCI hardware link PM"
> at the end already, added by Andiry Xu on 2011-09-23.

Ok, I'll send a separate patch to add documentation here, after the 3.5
merge window.  (I just sent the pull request for the USB 3.0 LPM patches
off to Greg.)

> Hmmm, that section seems to suggest that LPM exists for USB2, too.
> Perhaps I should reconsider my attitude towards your patch.

The patchset doesn't change the USB 2.0 LPM behavior at all.  USB 2.0
doesn't have hub initiated LPM, because that would mean changing
existing USB 2.0 hub IP.  Only devices attached directly to the roothub
will be able to do USB 2.0 LPM.  Also, devices have to specifically say
they implement the USB 2.1 LPM extensions, so it's unlikely devices
supported by your driver implement USB 2.0 LPM.

Sarah Sharp

^ permalink raw reply

* [PATCH net-next 5/5] cirrus: cs89x0: Remove function prototypes and reorder declarations
From: Joe Perches @ 2012-05-18 22:56 UTC (permalink / raw)
  To: netdev, linux-kernel; +Cc: Jaccon Bastiaansen
In-Reply-To: <cover.1337381533.git.joe@perches.com>

Move blocks of code around to avoid function prototypes.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/ethernet/cirrus/cs89x0.c | 1919 +++++++++++++++++-----------------
 1 files changed, 947 insertions(+), 972 deletions(-)

diff --git a/drivers/net/ethernet/cirrus/cs89x0.c b/drivers/net/ethernet/cirrus/cs89x0.c
index 859f8be..845b202 100644
--- a/drivers/net/ethernet/cirrus/cs89x0.c
+++ b/drivers/net/ethernet/cirrus/cs89x0.c
@@ -174,28 +174,6 @@ struct net_local {
 #endif
 };
 
-/* Index to functions, as function prototypes. */
-static int net_open(struct net_device *dev);
-static netdev_tx_t net_send_packet(struct sk_buff *skb, struct net_device *dev);
-static irqreturn_t net_interrupt(int irq, void *dev_id);
-static void set_multicast_list(struct net_device *dev);
-static void net_timeout(struct net_device *dev);
-static void net_rx(struct net_device *dev);
-static int net_close(struct net_device *dev);
-static struct net_device_stats *net_get_stats(struct net_device *dev);
-static void reset_chip(struct net_device *dev);
-static int get_eeprom_data(struct net_device *dev, int off, int len, int *buffer);
-static int get_eeprom_cksum(int off, int len, int *buffer);
-static int set_mac_address(struct net_device *dev, void *addr);
-static void count_rx_errors(int status, struct net_device *dev);
-#ifdef CONFIG_NET_POLL_CONTROLLER
-static void net_poll_controller(struct net_device *dev);
-#endif
-#if ALLOW_DMA
-static void get_dma_channel(struct net_device *dev);
-static void release_dma_buff(struct net_local *lp);
-#endif
-
 /* Example routines you must write ;->. */
 #define tx_done(dev) 1
 
@@ -321,7 +299,7 @@ get_eeprom_data(struct net_device *dev, int off, int len, int *buffer)
 {
 	int i;
 
-	cs89_dbg(3, info, "EEPROM data from %x for %x:\n", off, len);
+	cs89_dbg(3, info, "EEPROM data from %x for %x:", off, len);
 	for (i = 0; i < len; i++) {
 		if (wait_eeprom_ready(dev) < 0)
 			return -1;
@@ -330,7 +308,7 @@ get_eeprom_data(struct net_device *dev, int off, int len, int *buffer)
 		if (wait_eeprom_ready(dev) < 0)
 			return -1;
 		buffer[i] = readreg(dev, PP_EEData);
-		cs89_dbg(3, cont, "%04x ", buffer[i]);
+		cs89_dbg(3, cont, " %04x", buffer[i]);
 	}
 	cs89_dbg(3, cont, "\n");
 	return 0;
@@ -350,564 +328,425 @@ get_eeprom_cksum(int off, int len, int *buffer)
 	return -1;
 }
 
-#ifdef CONFIG_NET_POLL_CONTROLLER
-/*
- * Polling receive - used by netconsole and other diagnostic tools
- * to allow network i/o with interrupts disabled.
- */
-static void net_poll_controller(struct net_device *dev)
+static void
+write_irq(struct net_device *dev, int chip_type, int irq)
 {
-	disable_irq(dev->irq);
-	net_interrupt(dev->irq, dev);
-	enable_irq(dev->irq);
-}
-#endif
+	int i;
 
-static const struct net_device_ops net_ops = {
-	.ndo_open		= net_open,
-	.ndo_stop		= net_close,
-	.ndo_tx_timeout		= net_timeout,
-	.ndo_start_xmit		= net_send_packet,
-	.ndo_get_stats		= net_get_stats,
-	.ndo_set_rx_mode	= set_multicast_list,
-	.ndo_set_mac_address	= set_mac_address,
-#ifdef CONFIG_NET_POLL_CONTROLLER
-	.ndo_poll_controller	= net_poll_controller,
+	if (chip_type == CS8900) {
+#ifndef CONFIG_CS89x0_PLATFORM
+		/* Search the mapping table for the corresponding IRQ pin. */
+		for (i = 0; i != ARRAY_SIZE(cs8900_irq_map); i++)
+			if (cs8900_irq_map[i] == irq)
+				break;
+		/* Not found */
+		if (i == ARRAY_SIZE(cs8900_irq_map))
+			i = 3;
+#else
+		/* INTRQ0 pin is used for interrupt generation. */
+		i = 0;
 #endif
-	.ndo_change_mtu		= eth_change_mtu,
-	.ndo_validate_addr	= eth_validate_addr,
-};
+		writereg(dev, PP_CS8900_ISAINT, i);
+	} else {
+		writereg(dev, PP_CS8920_ISAINT, irq);
+	}
+}
 
-/* This is the real probe routine.
- * Linux has a history of friendly device probes on the ISA bus.
- * A good device probes avoids doing writes, and
- * verifies that the correct device exists and functions.
- * Return 0 on success.
- */
-static int __init
-cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular)
+static void
+count_rx_errors(int status, struct net_device *dev)
 {
-	struct net_local *lp = netdev_priv(dev);
-	int i;
-	int tmp;
-	unsigned rev_type = 0;
-	int eeprom_buff[CHKSUM_LEN];
-	int retval;
+	dev->stats.rx_errors++;
+	if (status & RX_RUNT)
+		dev->stats.rx_length_errors++;
+	if (status & RX_EXTRA_DATA)
+		dev->stats.rx_length_errors++;
+	if ((status & RX_CRC_ERROR) && !(status & (RX_EXTRA_DATA | RX_RUNT)))
+		/* per str 172 */
+		dev->stats.rx_crc_errors++;
+	if (status & RX_DRIBBLE)
+		dev->stats.rx_frame_errors++;
+}
+
+/*********************************
+ * This page contains DMA routines
+ *********************************/
 
-	/* Initialize the device structure. */
-	if (!modular) {
-		memset(lp, 0, sizeof(*lp));
-		spin_lock_init(&lp->lock);
-#ifndef MODULE
 #if ALLOW_DMA
-		if (g_cs89x0_dma) {
-			lp->use_dma = 1;
-			lp->dma = g_cs89x0_dma;
-			lp->dmasize = 16;	/* Could make this an option... */
+
+#define dma_page_eq(ptr1, ptr2) ((long)(ptr1) >> 17 == (long)(ptr2) >> 17)
+
+static void
+get_dma_channel(struct net_device *dev)
+{
+	struct net_local *lp = netdev_priv(dev);
+
+	if (lp->dma) {
+		dev->dma = lp->dma;
+		lp->isa_config |= ISA_RxDMA;
+	} else {
+		if ((lp->isa_config & ANY_ISA_DMA) == 0)
+			return;
+		dev->dma = lp->isa_config & DMA_NO_MASK;
+		if (lp->chip_type == CS8900)
+			dev->dma += 5;
+		if (dev->dma < 5 || dev->dma > 7) {
+			lp->isa_config &= ~ANY_ISA_DMA;
+			return;
 		}
-#endif
-		lp->force = g_cs89x0_media__force;
-#endif
 	}
+}
 
-	pr_debug("PP_addr at %p[%x]: 0x%x\n",
-		 ioaddr, ADD_PORT, ioread16(ioaddr + ADD_PORT));
-	iowrite16(PP_ChipID, ioaddr + ADD_PORT);
+static void
+write_dma(struct net_device *dev, int chip_type, int dma)
+{
+	struct net_local *lp = netdev_priv(dev);
+	if ((lp->isa_config & ANY_ISA_DMA) == 0)
+		return;
+	if (chip_type == CS8900)
+		writereg(dev, PP_CS8900_ISADMA, dma - 5);
+	else
+		writereg(dev, PP_CS8920_ISADMA, dma);
+}
 
-	tmp = ioread16(ioaddr + DATA_PORT);
-	if (tmp != CHIP_EISA_ID_SIG) {
-		pr_debug("%s: incorrect signature at %p[%x]: 0x%x!="
-			 CHIP_EISA_ID_SIG_STR "\n",
-			 dev->name, ioaddr, DATA_PORT, tmp);
-		retval = -ENODEV;
-		goto out1;
-	}
+static void
+set_dma_cfg(struct net_device *dev)
+{
+	struct net_local *lp = netdev_priv(dev);
 
-	lp->virt_addr = ioaddr;
+	if (lp->use_dma) {
+		if ((lp->isa_config & ANY_ISA_DMA) == 0) {
+			cs89_dbg(3, err, "set_dma_cfg(): no DMA\n");
+			return;
+		}
+		if (lp->isa_config & ISA_RxDMA) {
+			lp->curr_rx_cfg |= RX_DMA_ONLY;
+			cs89_dbg(3, info, "set_dma_cfg(): RX_DMA_ONLY\n");
+		} else {
+			lp->curr_rx_cfg |= AUTO_RX_DMA;	/* not that we support it... */
+			cs89_dbg(3, info, "set_dma_cfg(): AUTO_RX_DMA\n");
+		}
+	}
+}
 
-	/* get the chip type */
-	rev_type = readreg(dev, PRODUCT_ID_ADD);
-	lp->chip_type = rev_type & ~REVISON_BITS;
-	lp->chip_revision = ((rev_type & REVISON_BITS) >> 8) + 'A';
+static int
+dma_bufcfg(struct net_device *dev)
+{
+	struct net_local *lp = netdev_priv(dev);
+	if (lp->use_dma)
+		return (lp->isa_config & ANY_ISA_DMA) ? RX_DMA_ENBL : 0;
+	else
+		return 0;
+}
 
-	/* Check the chip type and revision in order to set the correct send command
-	   CS8920 revision C and CS8900 revision F can use the faster send. */
-	lp->send_cmd = TX_AFTER_381;
-	if (lp->chip_type == CS8900 && lp->chip_revision >= 'F')
-		lp->send_cmd = TX_NOW;
-	if (lp->chip_type != CS8900 && lp->chip_revision >= 'C')
-		lp->send_cmd = TX_NOW;
+static int
+dma_busctl(struct net_device *dev)
+{
+	int retval = 0;
+	struct net_local *lp = netdev_priv(dev);
+	if (lp->use_dma) {
+		if (lp->isa_config & ANY_ISA_DMA)
+			retval |= RESET_RX_DMA; /* Reset the DMA pointer */
+		if (lp->isa_config & DMA_BURST)
+			retval |= DMA_BURST_MODE; /* Does ISA config specify DMA burst ? */
+		if (lp->dmasize == 64)
+			retval |= RX_DMA_SIZE_64K; /* did they ask for 64K? */
+		retval |= MEMORY_ON;	/* we need memory enabled to use DMA. */
+	}
+	return retval;
+}
 
-	pr_info_once("%s\n", version);
+static void
+dma_rx(struct net_device *dev)
+{
+	struct net_local *lp = netdev_priv(dev);
+	struct sk_buff *skb;
+	int status, length;
+	unsigned char *bp = lp->rx_dma_ptr;
 
-	pr_info("%s: cs89%c0%s rev %c found at %p ",
-		dev->name,
-		lp->chip_type == CS8900  ? '0' : '2',
-		lp->chip_type == CS8920M ? "M" : "",
-		lp->chip_revision,
-		lp->virt_addr);
+	status = bp[0] + (bp[1] << 8);
+	length = bp[2] + (bp[3] << 8);
+	bp += 4;
 
-	reset_chip(dev);
+	cs89_dbg(5, debug, "%s: receiving DMA packet at %lx, status %x, length %x\n",
+		 dev->name, (unsigned long)bp, status, length);
 
-	/* Here we read the current configuration of the chip.
-	 * If there is no Extended EEPROM then the idea is to not disturb
-	 * the chip configuration, it should have been correctly setup by
-	 * automatic EEPROM read on reset. So, if the chip says it read
-	 * the EEPROM the driver will always do *something* instead of
-	 * complain that adapter_cnf is 0.
-	 */
+	if ((status & RX_OK) == 0) {
+		count_rx_errors(status, dev);
+		goto skip_this_frame;
+	}
 
-	if ((readreg(dev, PP_SelfST) & (EEPROM_OK | EEPROM_PRESENT)) ==
-	    (EEPROM_OK | EEPROM_PRESENT)) {
-		/* Load the MAC. */
-		for (i = 0; i < ETH_ALEN / 2; i++) {
-			unsigned int Addr;
-			Addr = readreg(dev, PP_IA + i * 2);
-			dev->dev_addr[i * 2] = Addr & 0xFF;
-			dev->dev_addr[i * 2 + 1] = Addr >> 8;
-		}
+	/* Malloc up new buffer. */
+	skb = netdev_alloc_skb(dev, length + 2);
+	if (skb == NULL) {
+		/* I don't think we want to do this to a stressed system */
+		cs89_dbg(0, err, "%s: Memory squeeze, dropping packet\n",
+			 dev->name);
+		dev->stats.rx_dropped++;
 
-		/* Load the Adapter Configuration.
-		 * Note:  Barring any more specific information from some
-		 * other source (ie EEPROM+Schematics), we would not know
-		 * how to operate a 10Base2 interface on the AUI port.
-		 * However, since we  do read the status of HCB1 and use
-		 * settings that always result in calls to control_dc_dc(dev,0)
-		 * a BNC interface should work if the enable pin
-		 * (dc/dc converter) is on HCB1.
-		 * It will be called AUI however.
-		 */
-
-		lp->adapter_cnf = 0;
-		i = readreg(dev, PP_LineCTL);
-		/* Preserve the setting of the HCB1 pin. */
-		if ((i & (HCB1 | HCB1_ENBL)) == (HCB1 | HCB1_ENBL))
-			lp->adapter_cnf |= A_CNF_DC_DC_POLARITY;
-		/* Save the sqelch bit */
-		if ((i & LOW_RX_SQUELCH) == LOW_RX_SQUELCH)
-			lp->adapter_cnf |= A_CNF_EXTND_10B_2 | A_CNF_LOW_RX_SQUELCH;
-		/* Check if the card is in 10Base-t only mode */
-		if ((i & (AUI_ONLY | AUTO_AUI_10BASET)) == 0)
-			lp->adapter_cnf |=  A_CNF_10B_T | A_CNF_MEDIA_10B_T;
-		/* Check if the card is in AUI only mode */
-		if ((i & (AUI_ONLY | AUTO_AUI_10BASET)) == AUI_ONLY)
-			lp->adapter_cnf |=  A_CNF_AUI | A_CNF_MEDIA_AUI;
-		/* Check if the card is in Auto mode. */
-		if ((i & (AUI_ONLY | AUTO_AUI_10BASET)) == AUTO_AUI_10BASET)
-			lp->adapter_cnf |=  A_CNF_AUI | A_CNF_10B_T |
-				A_CNF_MEDIA_AUI | A_CNF_MEDIA_10B_T | A_CNF_MEDIA_AUTO;
-
-		cs89_dbg(1, info, "%s: PP_LineCTL=0x%x, adapter_cnf=0x%x\n",
-			 dev->name, i, lp->adapter_cnf);
-
-		/* IRQ. Other chips already probe, see below. */
-		if (lp->chip_type == CS8900)
-			lp->isa_config = readreg(dev, PP_CS8900_ISAINT) & INT_NO_MASK;
-
-		pr_cont("[Cirrus EEPROM] ");
-	}
-
-	pr_cont("\n");
-
-	/* First check to see if an EEPROM is attached. */
-
-	if ((readreg(dev, PP_SelfST) & EEPROM_PRESENT) == 0)
-		pr_warn("No EEPROM, relying on command line....\n");
-	else if (get_eeprom_data(dev, START_EEPROM_DATA, CHKSUM_LEN, eeprom_buff) < 0) {
-		pr_warn("EEPROM read failed, relying on command line\n");
-	} else if (get_eeprom_cksum(START_EEPROM_DATA, CHKSUM_LEN, eeprom_buff) < 0) {
-		/* Check if the chip was able to read its own configuration starting
-		   at 0 in the EEPROM*/
-		if ((readreg(dev, PP_SelfST) & (EEPROM_OK | EEPROM_PRESENT)) !=
-		    (EEPROM_OK | EEPROM_PRESENT))
-			pr_warn("Extended EEPROM checksum bad and no Cirrus EEPROM, relying on command line\n");
+		/* AKPM: advance bp to the next frame */
+skip_this_frame:
+		bp += (length + 3) & ~3;
+		if (bp >= lp->end_dma_buff)
+			bp -= lp->dmasize * 1024;
+		lp->rx_dma_ptr = bp;
+		return;
+	}
+	skb_reserve(skb, 2);	/* longword align L3 header */
 
+	if (bp + length > lp->end_dma_buff) {
+		int semi_cnt = lp->end_dma_buff - bp;
+		memcpy(skb_put(skb, semi_cnt), bp, semi_cnt);
+		memcpy(skb_put(skb, length - semi_cnt), lp->dma_buff,
+		       length - semi_cnt);
 	} else {
-		/* This reads an extended EEPROM that is not documented
-		 * in the CS8900 datasheet.
-		 */
-
-		/* get transmission control word  but keep the autonegotiation bits */
-		if (!lp->auto_neg_cnf)
-			lp->auto_neg_cnf = eeprom_buff[AUTO_NEG_CNF_OFFSET / 2];
-		/* Store adapter configuration */
-		if (!lp->adapter_cnf)
-			lp->adapter_cnf = eeprom_buff[ADAPTER_CNF_OFFSET / 2];
-		/* Store ISA configuration */
-		lp->isa_config = eeprom_buff[ISA_CNF_OFFSET / 2];
-		dev->mem_start = eeprom_buff[PACKET_PAGE_OFFSET / 2] << 8;
-
-		/* eeprom_buff has 32-bit ints, so we can't just memcpy it */
-		/* store the initial memory base address */
-		for (i = 0; i < ETH_ALEN / 2; i++) {
-			dev->dev_addr[i * 2] = eeprom_buff[i];
-			dev->dev_addr[i * 2 + 1] = eeprom_buff[i] >> 8;
-		}
-		cs89_dbg(1, debug, "%s: new adapter_cnf: 0x%x\n",
-			 dev->name, lp->adapter_cnf);
+		memcpy(skb_put(skb, length), bp, length);
 	}
+	bp += (length + 3) & ~3;
+	if (bp >= lp->end_dma_buff)
+		bp -= lp->dmasize*1024;
+	lp->rx_dma_ptr = bp;
 
-	/* allow them to force multiple transceivers.  If they force multiple, autosense */
-	{
-		int count = 0;
-		if (lp->force & FORCE_RJ45) {
-			lp->adapter_cnf |= A_CNF_10B_T;
-			count++;
-		}
-		if (lp->force & FORCE_AUI) {
-			lp->adapter_cnf |= A_CNF_AUI;
-			count++;
-		}
-		if (lp->force & FORCE_BNC) {
-			lp->adapter_cnf |= A_CNF_10B_2;
-			count++;
-		}
-		if (count > 1)
-			lp->adapter_cnf |= A_CNF_MEDIA_AUTO;
-		else if (lp->force & FORCE_RJ45)
-			lp->adapter_cnf |= A_CNF_MEDIA_10B_T;
-		else if (lp->force & FORCE_AUI)
-			lp->adapter_cnf |= A_CNF_MEDIA_AUI;
-		else if (lp->force & FORCE_BNC)
-			lp->adapter_cnf |= A_CNF_MEDIA_10B_2;
-	}
+	cs89_dbg(3, info, "%s: received %d byte DMA packet of type %x\n",
+		 dev->name, length,
+		 ((skb->data[ETH_ALEN + ETH_ALEN] << 8) |
+		  skb->data[ETH_ALEN + ETH_ALEN + 1]));
 
-	cs89_dbg(1, debug, "%s: after force 0x%x, adapter_cnf=0x%x\n",
-		 dev->name, lp->force, lp->adapter_cnf);
+	skb->protocol = eth_type_trans(skb, dev);
+	netif_rx(skb);
+	dev->stats.rx_packets++;
+	dev->stats.rx_bytes += length;
+}
 
-	/* FIXME: We don't let you set dc-dc polarity or low RX squelch from the command line: add it here */
+static void release_dma_buff(struct net_local *lp)
+{
+	if (lp->dma_buff) {
+		free_pages((unsigned long)(lp->dma_buff),
+			   get_order(lp->dmasize * 1024));
+		lp->dma_buff = NULL;
+	}
+}
 
-	/* FIXME: We don't let you set the IMM bit from the command line: add it to lp->auto_neg_cnf here */
+#endif	/* ALLOW_DMA */
 
-	/* FIXME: we don't set the Ethernet address on the command line.  Use
-	 * ifconfig IFACE hw ether AABBCCDDEEFF
+static void
+control_dc_dc(struct net_device *dev, int on_not_off)
+{
+	struct net_local *lp = netdev_priv(dev);
+	unsigned int selfcontrol;
+	int timenow = jiffies;
+	/* control the DC to DC convertor in the SelfControl register.
+	 * Note: This is hooked up to a general purpose pin, might not
+	 * always be a DC to DC convertor.
 	 */
 
-	pr_info("media %s%s%s",
-		(lp->adapter_cnf & A_CNF_10B_T) ? "RJ-45," : "",
-		(lp->adapter_cnf & A_CNF_AUI) ? "AUI," : "",
-		(lp->adapter_cnf & A_CNF_10B_2) ? "BNC," : "");
-
-	lp->irq_map = 0xffff;
-
-	/* If this is a CS8900 then no pnp soft */
-	if (lp->chip_type != CS8900 &&
-	    /* Check if the ISA IRQ has been set  */
-	    (i = readreg(dev, PP_CS8920_ISAINT) & 0xff,
-	     (i != 0 && i < CS8920_NO_INTS))) {
-		if (!dev->irq)
-			dev->irq = i;
-	} else {
-		i = lp->isa_config & INT_NO_MASK;
-#ifndef CONFIG_CS89x0_PLATFORM
-		if (lp->chip_type == CS8900) {
-#ifdef CS89x0_NONISA_IRQ
-			i = cs8900_irq_map[0];
-#else
-			/* Translate the IRQ using the IRQ mapping table. */
-			if (i >= ARRAY_SIZE(cs8900_irq_map))
-				pr_err("invalid ISA interrupt number %d\n", i);
-			else
-				i = cs8900_irq_map[i];
+	selfcontrol = HCB1_ENBL; /* Enable the HCB1 bit as an output */
+	if (((lp->adapter_cnf & A_CNF_DC_DC_POLARITY) != 0) ^ on_not_off)
+		selfcontrol |= HCB1;
+	else
+		selfcontrol &= ~HCB1;
+	writereg(dev, PP_SelfCTL, selfcontrol);
 
-			lp->irq_map = CS8900_IRQ_MAP; /* fixed IRQ map for CS8900 */
-		} else {
-			int irq_map_buff[IRQ_MAP_LEN/2];
+	/* Wait for the DC/DC converter to power up - 500ms */
+	while (jiffies - timenow < HZ)
+		;
+}
 
-			if (get_eeprom_data(dev, IRQ_MAP_EEPROM_DATA,
-					    IRQ_MAP_LEN / 2,
-					    irq_map_buff) >= 0) {
-				if ((irq_map_buff[0] & 0xff) == PNP_IRQ_FRMT)
-					lp->irq_map = ((irq_map_buff[0] >> 8) |
-						       (irq_map_buff[1] << 8));
-			}
-#endif
-		}
-#endif
-		if (!dev->irq)
-			dev->irq = i;
-	}
+/* send a test packet - return true if carrier bits are ok */
+static int
+send_test_pkt(struct net_device *dev)
+{
+	struct net_local *lp = netdev_priv(dev);
+	char test_packet[] = {
+		0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0,
+		0, 46,		/* A 46 in network order */
+		0, 0,		/* DSAP=0 & SSAP=0 fields */
+		0xf3, 0		/* Control (Test Req + P bit set) */
+	};
+	long timenow = jiffies;
 
-	pr_cont(" IRQ %d", dev->irq);
+	writereg(dev, PP_LineCTL, readreg(dev, PP_LineCTL) | SERIAL_TX_ON);
 
-#if ALLOW_DMA
-	if (lp->use_dma) {
-		get_dma_channel(dev);
-		pr_cont(", DMA %d", dev->dma);
-	} else
-#endif
-		pr_cont(", programmed I/O");
+	memcpy(test_packet,            dev->dev_addr, ETH_ALEN);
+	memcpy(test_packet + ETH_ALEN, dev->dev_addr, ETH_ALEN);
 
-	/* print the ethernet address. */
-	pr_cont(", MAC %pM\n", dev->dev_addr);
+	iowrite16(TX_AFTER_ALL, lp->virt_addr + TX_CMD_PORT);
+	iowrite16(ETH_ZLEN, lp->virt_addr + TX_LEN_PORT);
 
-	dev->netdev_ops	= &net_ops;
-	dev->watchdog_timeo = HZ;
+	/* Test to see if the chip has allocated memory for the packet */
+	while (jiffies - timenow < 5)
+		if (readreg(dev, PP_BusST) & READY_FOR_TX_NOW)
+			break;
+	if (jiffies - timenow >= 5)
+		return 0;	/* this shouldn't happen */
 
-	cs89_dbg(0, info, "cs89x0_probe1() successful\n");
+	/* Write the contents of the packet */
+	writewords(lp, TX_FRAME_PORT, test_packet, (ETH_ZLEN + 1) >> 1);
 
-	retval = register_netdev(dev);
-	if (retval)
-		goto out2;
+	cs89_dbg(1, debug, "Sending test packet ");
+	/* wait a couple of jiffies for packet to be received */
+	for (timenow = jiffies; jiffies - timenow < 3;)
+		;
+	if ((readreg(dev, PP_TxEvent) & TX_SEND_OK_BITS) == TX_OK) {
+		cs89_dbg(1, cont, "succeeded\n");
+		return 1;
+	}
+	cs89_dbg(1, cont, "failed\n");
 	return 0;
-out2:
-	iowrite16(PP_ChipID, lp->virt_addr + ADD_PORT);
-out1:
-	return retval;
 }
 
-#ifndef CONFIG_CS89x0_PLATFORM
-/*
- * This function converts the I/O port addres used by the cs89x0_probe() and
- * init_module() functions to the I/O memory address used by the
- * cs89x0_probe1() function.
- */
-static int __init
-cs89x0_ioport_probe(struct net_device *dev, unsigned long ioport, int modular)
+#define DETECTED_NONE  0
+#define DETECTED_RJ45H 1
+#define DETECTED_RJ45F 2
+#define DETECTED_AUI   3
+#define DETECTED_BNC   4
+
+static int
+detect_tp(struct net_device *dev)
 {
 	struct net_local *lp = netdev_priv(dev);
-	int ret;
-	void __iomem *io_mem;
-
-	if (!lp)
-		return -ENOMEM;
-
-	dev->base_addr = ioport;
-
-	if (!request_region(ioport, NETCARD_IO_EXTENT, DRV_NAME)) {
-		ret = -EBUSY;
-		goto out;
-	}
+	int timenow = jiffies;
+	int fdx;
 
-	io_mem = ioport_map(ioport & ~3, NETCARD_IO_EXTENT);
-	if (!io_mem) {
-		ret = -ENOMEM;
-		goto release;
-	}
+	cs89_dbg(1, debug, "%s: Attempting TP\n", dev->name);
 
-	/* if they give us an odd I/O address, then do ONE write to
-	 * the address port, to get it back to address zero, where we
-	 * expect to find the EISA signature word. An IO with a base of 0x3
-	 * will skip the test for the ADD_PORT.
+	/* If connected to another full duplex capable 10-Base-T card
+	 * the link pulses seem to be lost when the auto detect bit in
+	 * the LineCTL is set.  To overcome this the auto detect bit will
+	 * be cleared whilst testing the 10-Base-T interface.  This would
+	 * not be necessary for the sparrow chip but is simpler to do it
+	 * anyway.
 	 */
-	if (ioport & 1) {
-		cs89_dbg(1, info, "%s: odd ioaddr 0x%lx\n", dev->name, ioport);
-		if ((ioport & 2) != 2) {
-			if ((ioread16(io_mem + ADD_PORT) & ADD_MASK) !=
-			    ADD_SIG) {
-				pr_err("%s: bad signature 0x%x\n",
-				       dev->name, ioread16(io_mem + ADD_PORT));
-				ret = -ENODEV;
-				goto unmap;
-			}
-		}
-	}
-
-	ret = cs89x0_probe1(dev, io_mem, modular);
-	if (!ret)
-		goto out;
-unmap:
-	ioport_unmap(io_mem);
-release:
-	release_region(ioport, NETCARD_IO_EXTENT);
-out:
-	return ret;
-}
-
-#ifndef MODULE
-/* Check for a network adaptor of this type, and return '0' iff one exists.
- * If dev->base_addr == 0, probe all likely locations.
- * If dev->base_addr == 1, always return failure.
- * If dev->base_addr == 2, allocate space for the device and return success
- * (detachable devices only).
- * Return 0 on success.
- */
-
-struct net_device * __init cs89x0_probe(int unit)
-{
-	struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
-	unsigned *port;
-	int err = 0;
-	int irq;
-	int io;
-
-	if (!dev)
-		return ERR_PTR(-ENODEV);
-
-	sprintf(dev->name, "eth%d", unit);
-	netdev_boot_setup_check(dev);
-	io = dev->base_addr;
-	irq = dev->irq;
+	writereg(dev, PP_LineCTL, lp->linectl & ~AUI_ONLY);
+	control_dc_dc(dev, 0);
 
-	cs89_dbg(0, info, "cs89x0_probe(0x%x)\n", io);
+	/* Delay for the hardware to work out if the TP cable is present
+	 * - 150ms
+	 */
+	for (timenow = jiffies; jiffies - timenow < 15;)
+		;
+	if ((readreg(dev, PP_LineST) & LINK_OK) == 0)
+		return DETECTED_NONE;
 
-	if (io > 0x1ff)	{	/* Check a single specified location. */
-		err = cs89x0_ioport_probe(dev, io, 0);
-	} else if (io != 0) {	/* Don't probe at all. */
-		err = -ENXIO;
+	if (lp->chip_type == CS8900) {
+		switch (lp->force & 0xf0) {
+#if 0
+		case FORCE_AUTO:
+			pr_info("%s: cs8900 doesn't autonegotiate\n",
+				dev->name);
+			return DETECTED_NONE;
+#endif
+			/* CS8900 doesn't support AUTO, change to HALF*/
+		case FORCE_AUTO:
+			lp->force &= ~FORCE_AUTO;
+			lp->force |= FORCE_HALF;
+			break;
+		case FORCE_HALF:
+			break;
+		case FORCE_FULL:
+			writereg(dev, PP_TestCTL,
+				 readreg(dev, PP_TestCTL) | FDX_8900);
+			break;
+		}
+		fdx = readreg(dev, PP_TestCTL) & FDX_8900;
 	} else {
-		for (port = netcard_portlist; *port; port++) {
-			if (cs89x0_ioport_probe(dev, *port, 0) == 0)
-				break;
-			dev->irq = irq;
+		switch (lp->force & 0xf0) {
+		case FORCE_AUTO:
+			lp->auto_neg_cnf = AUTO_NEG_ENABLE;
+			break;
+		case FORCE_HALF:
+			lp->auto_neg_cnf = 0;
+			break;
+		case FORCE_FULL:
+			lp->auto_neg_cnf = RE_NEG_NOW | ALLOW_FDX;
+			break;
 		}
-		if (!*port)
-			err = -ENODEV;
-	}
-	if (err)
-		goto out;
-	return dev;
-out:
-	free_netdev(dev);
-	pr_warn("no cs8900 or cs8920 detected.  Be sure to disable PnP with SETUP\n");
-	return ERR_PTR(err);
-}
-#endif
-#endif
-
-/*********************************
- * This page contains DMA routines
- *********************************/
-
-#if ALLOW_DMA
-
-#define dma_page_eq(ptr1, ptr2) ((long)(ptr1) >> 17 == (long)(ptr2) >> 17)
 
-static void
-get_dma_channel(struct net_device *dev)
-{
-	struct net_local *lp = netdev_priv(dev);
+		writereg(dev, PP_AutoNegCTL, lp->auto_neg_cnf & AUTO_NEG_MASK);
 
-	if (lp->dma) {
-		dev->dma = lp->dma;
-		lp->isa_config |= ISA_RxDMA;
-	} else {
-		if ((lp->isa_config & ANY_ISA_DMA) == 0)
-			return;
-		dev->dma = lp->isa_config & DMA_NO_MASK;
-		if (lp->chip_type == CS8900)
-			dev->dma += 5;
-		if (dev->dma < 5 || dev->dma > 7) {
-			lp->isa_config &= ~ANY_ISA_DMA;
-			return;
+		if ((lp->auto_neg_cnf & AUTO_NEG_BITS) == AUTO_NEG_ENABLE) {
+			pr_info("%s: negotiating duplex...\n", dev->name);
+			while (readreg(dev, PP_AutoNegST) & AUTO_NEG_BUSY) {
+				if (jiffies - timenow > 4000) {
+					pr_err("**** Full / half duplex auto-negotiation timed out ****\n");
+					break;
+				}
+			}
 		}
+		fdx = readreg(dev, PP_AutoNegST) & FDX_ACTIVE;
 	}
-}
-
-static void
-write_dma(struct net_device *dev, int chip_type, int dma)
-{
-	struct net_local *lp = netdev_priv(dev);
-	if ((lp->isa_config & ANY_ISA_DMA) == 0)
-		return;
-	if (chip_type == CS8900)
-		writereg(dev, PP_CS8900_ISADMA, dma - 5);
+	if (fdx)
+		return DETECTED_RJ45F;
 	else
-		writereg(dev, PP_CS8920_ISADMA, dma);
+		return DETECTED_RJ45H;
 }
 
-static void
-set_dma_cfg(struct net_device *dev)
+static int
+detect_bnc(struct net_device *dev)
 {
 	struct net_local *lp = netdev_priv(dev);
 
-	if (lp->use_dma) {
-		if ((lp->isa_config & ANY_ISA_DMA) == 0) {
-			cs89_dbg(3, err, "set_dma_cfg(): no DMA\n");
-			return;
-		}
-		if (lp->isa_config & ISA_RxDMA) {
-			lp->curr_rx_cfg |= RX_DMA_ONLY;
-			cs89_dbg(3, info, "set_dma_cfg(): RX_DMA_ONLY\n");
-		} else {
-			lp->curr_rx_cfg |= AUTO_RX_DMA;	/* not that we support it... */
-			cs89_dbg(3, info, "set_dma_cfg(): AUTO_RX_DMA\n");
-		}
-	}
-}
+	cs89_dbg(1, debug, "%s: Attempting BNC\n", dev->name);
+	control_dc_dc(dev, 1);
 
-static int
-dma_bufcfg(struct net_device *dev)
-{
-	struct net_local *lp = netdev_priv(dev);
-	if (lp->use_dma)
-		return (lp->isa_config & ANY_ISA_DMA) ? RX_DMA_ENBL : 0;
+	writereg(dev, PP_LineCTL, (lp->linectl & ~AUTO_AUI_10BASET) | AUI_ONLY);
+
+	if (send_test_pkt(dev))
+		return DETECTED_BNC;
 	else
-		return 0;
+		return DETECTED_NONE;
 }
 
 static int
-dma_busctl(struct net_device *dev)
+detect_aui(struct net_device *dev)
 {
-	int retval = 0;
 	struct net_local *lp = netdev_priv(dev);
-	if (lp->use_dma) {
-		if (lp->isa_config & ANY_ISA_DMA)
-			retval |= RESET_RX_DMA; /* Reset the DMA pointer */
-		if (lp->isa_config & DMA_BURST)
-			retval |= DMA_BURST_MODE; /* Does ISA config specify DMA burst ? */
-		if (lp->dmasize == 64)
-			retval |= RX_DMA_SIZE_64K; /* did they ask for 64K? */
-		retval |= MEMORY_ON;	/* we need memory enabled to use DMA. */
-	}
-	return retval;
+
+	cs89_dbg(1, debug, "%s: Attempting AUI\n", dev->name);
+	control_dc_dc(dev, 0);
+
+	writereg(dev, PP_LineCTL, (lp->linectl & ~AUTO_AUI_10BASET) | AUI_ONLY);
+
+	if (send_test_pkt(dev))
+		return DETECTED_AUI;
+	else
+		return DETECTED_NONE;
 }
 
+/* We have a good packet(s), get it/them out of the buffers. */
 static void
-dma_rx(struct net_device *dev)
+net_rx(struct net_device *dev)
 {
 	struct net_local *lp = netdev_priv(dev);
 	struct sk_buff *skb;
 	int status, length;
-	unsigned char *bp = lp->rx_dma_ptr;
-
-	status = bp[0] + (bp[1] << 8);
-	length = bp[2] + (bp[3] << 8);
-	bp += 4;
 
-	cs89_dbg(5, debug, "%s: receiving DMA packet at %lx, status %x, length %x\n",
-		 dev->name, (unsigned long)bp, status, length);
+	status = ioread16(lp->virt_addr + RX_FRAME_PORT);
+	length = ioread16(lp->virt_addr + RX_FRAME_PORT);
 
 	if ((status & RX_OK) == 0) {
 		count_rx_errors(status, dev);
-		goto skip_this_frame;
+		return;
 	}
 
 	/* Malloc up new buffer. */
 	skb = netdev_alloc_skb(dev, length + 2);
 	if (skb == NULL) {
-		/* I don't think we want to do this to a stressed system */
-		cs89_dbg(0, err, "%s: Memory squeeze, dropping packet\n",
-			 dev->name);
+#if 0		/* Again, this seems a cruel thing to do */
+		pr_warn("%s: Memory squeeze, dropping packet\n", dev->name);
+#endif
 		dev->stats.rx_dropped++;
-
-		/* AKPM: advance bp to the next frame */
-skip_this_frame:
-		bp += (length + 3) & ~3;
-		if (bp >= lp->end_dma_buff)
-			bp -= lp->dmasize * 1024;
-		lp->rx_dma_ptr = bp;
 		return;
 	}
 	skb_reserve(skb, 2);	/* longword align L3 header */
 
-	if (bp + length > lp->end_dma_buff) {
-		int semi_cnt = lp->end_dma_buff - bp;
-		memcpy(skb_put(skb, semi_cnt), bp, semi_cnt);
-		memcpy(skb_put(skb, length - semi_cnt), lp->dma_buff,
-		       length - semi_cnt);
-	} else {
-		memcpy(skb_put(skb, length), bp, length);
-	}
-	bp += (length + 3) & ~3;
-	if (bp >= lp->end_dma_buff)
-		bp -= lp->dmasize*1024;
-	lp->rx_dma_ptr = bp;
+	readwords(lp, RX_FRAME_PORT, skb_put(skb, length), length >> 1);
+	if (length & 1)
+		skb->data[length-1] = ioread16(lp->virt_addr + RX_FRAME_PORT);
 
-	cs89_dbg(3, info, "%s: received %d byte DMA packet of type %x\n",
+	cs89_dbg(3, debug, "%s: received %d byte packet of type %x\n",
 		 dev->name, length,
-		 ((skb->data[ETH_ALEN + ETH_ALEN] << 8) |
-		  skb->data[ETH_ALEN + ETH_ALEN + 1]));
+		 (skb->data[ETH_ALEN + ETH_ALEN] << 8) |
+		 skb->data[ETH_ALEN + ETH_ALEN + 1]);
 
 	skb->protocol = eth_type_trans(skb, dev);
 	netif_rx(skb);
@@ -915,278 +754,137 @@ skip_this_frame:
 	dev->stats.rx_bytes += length;
 }
 
-#endif	/* ALLOW_DMA */
+/* The typical workload of the driver:
+ * Handle the network interface interrupts.
+ */
 
-static void __init reset_chip(struct net_device *dev)
+static irqreturn_t net_interrupt(int irq, void *dev_id)
 {
-#if !defined(CONFIG_MACH_MX31ADS)
-#if !defined(CS89x0_NONISA_IRQ)
-	struct net_local *lp = netdev_priv(dev);
-#endif /* CS89x0_NONISA_IRQ */
-	int reset_start_time;
-
-	writereg(dev, PP_SelfCTL, readreg(dev, PP_SelfCTL) | POWER_ON_RESET);
-
-	/* wait 30 ms */
-	msleep(30);
+	struct net_device *dev = dev_id;
+	struct net_local *lp;
+	int status;
+	int handled = 0;
 
-#if !defined(CS89x0_NONISA_IRQ)
-	if (lp->chip_type != CS8900) {
-		/* Hardware problem requires PNP registers to be reconfigured after a reset */
-		iowrite16(PP_CS8920_ISAINT, lp->virt_addr + ADD_PORT);
-		iowrite8(dev->irq, lp->virt_addr + DATA_PORT);
-		iowrite8(0, lp->virt_addr + DATA_PORT + 1);
+	lp = netdev_priv(dev);
 
-		iowrite16(PP_CS8920_ISAMemB, lp->virt_addr + ADD_PORT);
-		iowrite8((dev->mem_start >> 16) & 0xff,
-			 lp->virt_addr + DATA_PORT);
-		iowrite8((dev->mem_start >> 8) & 0xff,
-			 lp->virt_addr + DATA_PORT + 1);
+	/* we MUST read all the events out of the ISQ, otherwise we'll never
+	 * get interrupted again.  As a consequence, we can't have any limit
+	 * on the number of times we loop in the interrupt handler.  The
+	 * hardware guarantees that eventually we'll run out of events.  Of
+	 * course, if you're on a slow machine, and packets are arriving
+	 * faster than you can read them off, you're screwed.  Hasta la
+	 * vista, baby!
+	 */
+	while ((status = ioread16(lp->virt_addr + ISQ_PORT))) {
+		cs89_dbg(4, debug, "%s: event=%04x\n", dev->name, status);
+		handled = 1;
+		switch (status & ISQ_EVENT_MASK) {
+		case ISQ_RECEIVER_EVENT:
+			/* Got a packet(s). */
+			net_rx(dev);
+			break;
+		case ISQ_TRANSMITTER_EVENT:
+			dev->stats.tx_packets++;
+			netif_wake_queue(dev);	/* Inform upper layers. */
+			if ((status & (TX_OK |
+				       TX_LOST_CRS |
+				       TX_SQE_ERROR |
+				       TX_LATE_COL |
+				       TX_16_COL)) != TX_OK) {
+				if ((status & TX_OK) == 0)
+					dev->stats.tx_errors++;
+				if (status & TX_LOST_CRS)
+					dev->stats.tx_carrier_errors++;
+				if (status & TX_SQE_ERROR)
+					dev->stats.tx_heartbeat_errors++;
+				if (status & TX_LATE_COL)
+					dev->stats.tx_window_errors++;
+				if (status & TX_16_COL)
+					dev->stats.tx_aborted_errors++;
+			}
+			break;
+		case ISQ_BUFFER_EVENT:
+			if (status & READY_FOR_TX) {
+				/* we tried to transmit a packet earlier,
+				 * but inexplicably ran out of buffers.
+				 * That shouldn't happen since we only ever
+				 * load one packet.  Shrug.  Do the right
+				 * thing anyway.
+				 */
+				netif_wake_queue(dev);	/* Inform upper layers. */
+			}
+			if (status & TX_UNDERRUN) {
+				cs89_dbg(0, err, "%s: transmit underrun\n",
+					 dev->name);
+				lp->send_underrun++;
+				if (lp->send_underrun == 3)
+					lp->send_cmd = TX_AFTER_381;
+				else if (lp->send_underrun == 6)
+					lp->send_cmd = TX_AFTER_ALL;
+				/* transmit cycle is done, although
+				 * frame wasn't transmitted - this
+				 * avoids having to wait for the upper
+				 * layers to timeout on us, in the
+				 * event of a tx underrun
+				 */
+				netif_wake_queue(dev);	/* Inform upper layers. */
+			}
+#if ALLOW_DMA
+			if (lp->use_dma && (status & RX_DMA)) {
+				int count = readreg(dev, PP_DmaFrameCnt);
+				while (count) {
+					cs89_dbg(5, debug,
+						 "%s: receiving %d DMA frames\n",
+						 dev->name, count);
+					if (count > 1)
+						cs89_dbg(2, debug,
+							 "%s: receiving %d DMA frames\n",
+							 dev->name, count);
+					dma_rx(dev);
+					if (--count == 0)
+						count = readreg(dev, PP_DmaFrameCnt);
+					if (count > 0)
+						cs89_dbg(2, debug,
+							 "%s: continuing with %d DMA frames\n",
+							 dev->name, count);
+				}
+			}
+#endif
+			break;
+		case ISQ_RX_MISS_EVENT:
+			dev->stats.rx_missed_errors += (status >> 6);
+			break;
+		case ISQ_TX_COL_EVENT:
+			dev->stats.collisions += (status >> 6);
+			break;
+		}
 	}
-#endif /* CS89x0_NONISA_IRQ */
-
-	/* Wait until the chip is reset */
-	reset_start_time = jiffies;
-	while ((readreg(dev, PP_SelfST) & INIT_DONE) == 0 &&
-	       jiffies - reset_start_time < 2)
-		;
-#endif /* !CONFIG_MACH_MX31ADS */
+	return IRQ_RETVAL(handled);
 }
 
+/* Open/initialize the board.  This is called (in the current kernel)
+   sometime after booting when the 'ifconfig' program is run.
 
-static void
-control_dc_dc(struct net_device *dev, int on_not_off)
-{
-	struct net_local *lp = netdev_priv(dev);
-	unsigned int selfcontrol;
-	int timenow = jiffies;
-	/* control the DC to DC convertor in the SelfControl register.
-	 * Note: This is hooked up to a general purpose pin, might not
-	 * always be a DC to DC convertor.
-	 */
-
-	selfcontrol = HCB1_ENBL; /* Enable the HCB1 bit as an output */
-	if (((lp->adapter_cnf & A_CNF_DC_DC_POLARITY) != 0) ^ on_not_off)
-		selfcontrol |= HCB1;
-	else
-		selfcontrol &= ~HCB1;
-	writereg(dev, PP_SelfCTL, selfcontrol);
-
-	/* Wait for the DC/DC converter to power up - 500ms */
-	while (jiffies - timenow < HZ)
-		;
-}
+   This routine should set everything up anew at each open, even
+   registers that "should" only need to be set once at boot, so that
+   there is non-reboot way to recover if something goes wrong.
+*/
 
-#define DETECTED_NONE  0
-#define DETECTED_RJ45H 1
-#define DETECTED_RJ45F 2
-#define DETECTED_AUI   3
-#define DETECTED_BNC   4
+/* AKPM: do we need to do any locking here? */
 
 static int
-detect_tp(struct net_device *dev)
+net_open(struct net_device *dev)
 {
 	struct net_local *lp = netdev_priv(dev);
-	int timenow = jiffies;
-	int fdx;
-
-	cs89_dbg(1, debug, "%s: Attempting TP\n", dev->name);
-
-	/* If connected to another full duplex capable 10-Base-T card
-	 * the link pulses seem to be lost when the auto detect bit in
-	 * the LineCTL is set.  To overcome this the auto detect bit will
-	 * be cleared whilst testing the 10-Base-T interface.  This would
-	 * not be necessary for the sparrow chip but is simpler to do it
-	 * anyway.
-	 */
-	writereg(dev, PP_LineCTL, lp->linectl & ~AUI_ONLY);
-	control_dc_dc(dev, 0);
-
-	/* Delay for the hardware to work out if the TP cable is present
-	 * - 150ms
-	 */
-	for (timenow = jiffies; jiffies - timenow < 15;)
-		;
-	if ((readreg(dev, PP_LineST) & LINK_OK) == 0)
-		return DETECTED_NONE;
+	int result = 0;
+	int i;
+	int ret;
 
-	if (lp->chip_type == CS8900) {
-		switch (lp->force & 0xf0) {
+	if (dev->irq < 2) {
+		/* Allow interrupts to be generated by the chip */
+/* Cirrus' release had this: */
 #if 0
-		case FORCE_AUTO:
-			pr_info("%s: cs8900 doesn't autonegotiate\n",
-				dev->name);
-			return DETECTED_NONE;
-#endif
-			/* CS8900 doesn't support AUTO, change to HALF*/
-		case FORCE_AUTO:
-			lp->force &= ~FORCE_AUTO;
-			lp->force |= FORCE_HALF;
-			break;
-		case FORCE_HALF:
-			break;
-		case FORCE_FULL:
-			writereg(dev, PP_TestCTL,
-				 readreg(dev, PP_TestCTL) | FDX_8900);
-			break;
-		}
-		fdx = readreg(dev, PP_TestCTL) & FDX_8900;
-	} else {
-		switch (lp->force & 0xf0) {
-		case FORCE_AUTO:
-			lp->auto_neg_cnf = AUTO_NEG_ENABLE;
-			break;
-		case FORCE_HALF:
-			lp->auto_neg_cnf = 0;
-			break;
-		case FORCE_FULL:
-			lp->auto_neg_cnf = RE_NEG_NOW | ALLOW_FDX;
-			break;
-		}
-
-		writereg(dev, PP_AutoNegCTL, lp->auto_neg_cnf & AUTO_NEG_MASK);
-
-		if ((lp->auto_neg_cnf & AUTO_NEG_BITS) == AUTO_NEG_ENABLE) {
-			pr_info("%s: negotiating duplex...\n", dev->name);
-			while (readreg(dev, PP_AutoNegST) & AUTO_NEG_BUSY) {
-				if (jiffies - timenow > 4000) {
-					pr_err("**** Full / half duplex auto-negotiation timed out ****\n");
-					break;
-				}
-			}
-		}
-		fdx = readreg(dev, PP_AutoNegST) & FDX_ACTIVE;
-	}
-	if (fdx)
-		return DETECTED_RJ45F;
-	else
-		return DETECTED_RJ45H;
-}
-
-/* send a test packet - return true if carrier bits are ok */
-static int
-send_test_pkt(struct net_device *dev)
-{
-	struct net_local *lp = netdev_priv(dev);
-	char test_packet[] = {
-		0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0,
-		0, 46,		/* A 46 in network order */
-		0, 0,		/* DSAP=0 & SSAP=0 fields */
-		0xf3, 0		/* Control (Test Req + P bit set) */
-	};
-	long timenow = jiffies;
-
-	writereg(dev, PP_LineCTL, readreg(dev, PP_LineCTL) | SERIAL_TX_ON);
-
-	memcpy(test_packet,            dev->dev_addr, ETH_ALEN);
-	memcpy(test_packet + ETH_ALEN, dev->dev_addr, ETH_ALEN);
-
-	iowrite16(TX_AFTER_ALL, lp->virt_addr + TX_CMD_PORT);
-	iowrite16(ETH_ZLEN, lp->virt_addr + TX_LEN_PORT);
-
-	/* Test to see if the chip has allocated memory for the packet */
-	while (jiffies - timenow < 5)
-		if (readreg(dev, PP_BusST) & READY_FOR_TX_NOW)
-			break;
-	if (jiffies - timenow >= 5)
-		return 0;	/* this shouldn't happen */
-
-	/* Write the contents of the packet */
-	writewords(lp, TX_FRAME_PORT, test_packet, (ETH_ZLEN + 1) >> 1);
-
-	cs89_dbg(1, debug, "Sending test packet ");
-	/* wait a couple of jiffies for packet to be received */
-	for (timenow = jiffies; jiffies - timenow < 3;)
-		;
-	if ((readreg(dev, PP_TxEvent) & TX_SEND_OK_BITS) == TX_OK) {
-		cs89_dbg(1, cont, "succeeded\n");
-		return 1;
-	}
-	cs89_dbg(1, cont, "failed\n");
-	return 0;
-}
-
-
-static int
-detect_aui(struct net_device *dev)
-{
-	struct net_local *lp = netdev_priv(dev);
-
-	cs89_dbg(1, debug, "%s: Attempting AUI\n", dev->name);
-	control_dc_dc(dev, 0);
-
-	writereg(dev, PP_LineCTL, (lp->linectl & ~AUTO_AUI_10BASET) | AUI_ONLY);
-
-	if (send_test_pkt(dev))
-		return DETECTED_AUI;
-	else
-		return DETECTED_NONE;
-}
-
-static int
-detect_bnc(struct net_device *dev)
-{
-	struct net_local *lp = netdev_priv(dev);
-
-	cs89_dbg(1, debug, "%s: Attempting BNC\n", dev->name);
-	control_dc_dc(dev, 1);
-
-	writereg(dev, PP_LineCTL, (lp->linectl & ~AUTO_AUI_10BASET) | AUI_ONLY);
-
-	if (send_test_pkt(dev))
-		return DETECTED_BNC;
-	else
-		return DETECTED_NONE;
-}
-
-
-static void
-write_irq(struct net_device *dev, int chip_type, int irq)
-{
-	int i;
-
-	if (chip_type == CS8900) {
-#ifndef CONFIG_CS89x0_PLATFORM
-		/* Search the mapping table for the corresponding IRQ pin. */
-		for (i = 0; i != ARRAY_SIZE(cs8900_irq_map); i++)
-			if (cs8900_irq_map[i] == irq)
-				break;
-		/* Not found */
-		if (i == ARRAY_SIZE(cs8900_irq_map))
-			i = 3;
-#else
-		/* INTRQ0 pin is used for interrupt generation. */
-		i = 0;
-#endif
-		writereg(dev, PP_CS8900_ISAINT, i);
-	} else {
-		writereg(dev, PP_CS8920_ISAINT, irq);
-	}
-}
-
-/* Open/initialize the board.  This is called (in the current kernel)
-   sometime after booting when the 'ifconfig' program is run.
-
-   This routine should set everything up anew at each open, even
-   registers that "should" only need to be set once at boot, so that
-   there is non-reboot way to recover if something goes wrong.
-*/
-
-/* AKPM: do we need to do any locking here? */
-
-static int
-net_open(struct net_device *dev)
-{
-	struct net_local *lp = netdev_priv(dev);
-	int result = 0;
-	int i;
-	int ret;
-
-	if (dev->irq < 2) {
-		/* Allow interrupts to be generated by the chip */
-/* Cirrus' release had this: */
-#if 0
-		writereg(dev, PP_BusCTL, readreg(dev, PP_BusCTL) | ENABLE_IRQ);
+		writereg(dev, PP_BusCTL, readreg(dev, PP_BusCTL) | ENABLE_IRQ);
 #endif
 /* And 2.3.47 had this: */
 		writereg(dev, PP_BusCTL, ENABLE_IRQ | MEMORY_ON);
@@ -1433,6 +1131,52 @@ bad_out:
 	return ret;
 }
 
+/* The inverse routine to net_open(). */
+static int
+net_close(struct net_device *dev)
+{
+#if ALLOW_DMA
+	struct net_local *lp = netdev_priv(dev);
+#endif
+
+	netif_stop_queue(dev);
+
+	writereg(dev, PP_RxCFG, 0);
+	writereg(dev, PP_TxCFG, 0);
+	writereg(dev, PP_BufCFG, 0);
+	writereg(dev, PP_BusCTL, 0);
+
+	free_irq(dev->irq, dev);
+
+#if ALLOW_DMA
+	if (lp->use_dma && lp->dma) {
+		free_dma(dev->dma);
+		release_dma_buff(lp);
+	}
+#endif
+
+	/* Update the statistics here. */
+	return 0;
+}
+
+/* Get the current statistics.
+ * This may be called with the card open or closed.
+ */
+static struct net_device_stats *
+net_get_stats(struct net_device *dev)
+{
+	struct net_local *lp = netdev_priv(dev);
+	unsigned long flags;
+
+	spin_lock_irqsave(&lp->lock, flags);
+	/* Update the statistics from the device registers. */
+	dev->stats.rx_missed_errors += (readreg(dev, PP_RxMiss) >> 6);
+	dev->stats.collisions += (readreg(dev, PP_TxCol) >> 6);
+	spin_unlock_irqrestore(&lp->lock, flags);
+
+	return &dev->stats;
+}
+
 static void net_timeout(struct net_device *dev)
 {
 	/* If we get here, some higher level has decided we are broken.
@@ -1495,278 +1239,509 @@ static netdev_tx_t net_send_packet(struct sk_buff *skb, struct net_device *dev)
 	return NETDEV_TX_OK;
 }
 
-/* The typical workload of the driver:
- * Handle the network interface interrupts.
- */
-
-static irqreturn_t net_interrupt(int irq, void *dev_id)
+static void set_multicast_list(struct net_device *dev)
 {
-	struct net_device *dev = dev_id;
-	struct net_local *lp;
-	int status;
-	int handled = 0;
+	struct net_local *lp = netdev_priv(dev);
+	unsigned long flags;
 
-	lp = netdev_priv(dev);
+	spin_lock_irqsave(&lp->lock, flags);
+	if (dev->flags & IFF_PROMISC)
+		lp->rx_mode = RX_ALL_ACCEPT;
+	else if ((dev->flags & IFF_ALLMULTI) || !netdev_mc_empty(dev))
+		/* The multicast-accept list is initialized to accept-all,
+		 * and we rely on higher-level filtering for now.
+		 */
+		lp->rx_mode = RX_MULTCAST_ACCEPT;
+	else
+		lp->rx_mode = 0;
 
-	/* we MUST read all the events out of the ISQ, otherwise we'll never
-	 * get interrupted again.  As a consequence, we can't have any limit
-	 * on the number of times we loop in the interrupt handler.  The
-	 * hardware guarantees that eventually we'll run out of events.  Of
-	 * course, if you're on a slow machine, and packets are arriving
-	 * faster than you can read them off, you're screwed.  Hasta la
-	 * vista, baby!
+	writereg(dev, PP_RxCTL, DEF_RX_ACCEPT | lp->rx_mode);
+
+	/* in promiscuous mode, we accept errored packets,
+	 * so we have to enable interrupts on them also
 	 */
-	while ((status = ioread16(lp->virt_addr + ISQ_PORT))) {
-		cs89_dbg(4, debug, "%s: event=%04x\n", dev->name, status);
-		handled = 1;
-		switch (status & ISQ_EVENT_MASK) {
-		case ISQ_RECEIVER_EVENT:
-			/* Got a packet(s). */
-			net_rx(dev);
-			break;
-		case ISQ_TRANSMITTER_EVENT:
-			dev->stats.tx_packets++;
-			netif_wake_queue(dev);	/* Inform upper layers. */
-			if ((status & (TX_OK |
-				       TX_LOST_CRS |
-				       TX_SQE_ERROR |
-				       TX_LATE_COL |
-				       TX_16_COL)) != TX_OK) {
-				if ((status & TX_OK) == 0)
-					dev->stats.tx_errors++;
-				if (status & TX_LOST_CRS)
-					dev->stats.tx_carrier_errors++;
-				if (status & TX_SQE_ERROR)
-					dev->stats.tx_heartbeat_errors++;
-				if (status & TX_LATE_COL)
-					dev->stats.tx_window_errors++;
-				if (status & TX_16_COL)
-					dev->stats.tx_aborted_errors++;
-			}
-			break;
-		case ISQ_BUFFER_EVENT:
-			if (status & READY_FOR_TX) {
-				/* we tried to transmit a packet earlier,
-				 * but inexplicably ran out of buffers.
-				 * That shouldn't happen since we only ever
-				 * load one packet.  Shrug.  Do the right
-				 * thing anyway.
-				 */
-				netif_wake_queue(dev);	/* Inform upper layers. */
-			}
-			if (status & TX_UNDERRUN) {
-				cs89_dbg(0, err, "%s: transmit underrun\n",
-					 dev->name);
-				lp->send_underrun++;
-				if (lp->send_underrun == 3)
-					lp->send_cmd = TX_AFTER_381;
-				else if (lp->send_underrun == 6)
-					lp->send_cmd = TX_AFTER_ALL;
-				/* transmit cycle is done, although
-				 * frame wasn't transmitted - this
-				 * avoids having to wait for the upper
-				 * layers to timeout on us, in the
-				 * event of a tx underrun
-				 */
-				netif_wake_queue(dev);	/* Inform upper layers. */
-			}
-#if ALLOW_DMA
-			if (lp->use_dma && (status & RX_DMA)) {
-				int count = readreg(dev, PP_DmaFrameCnt);
-				while (count) {
-					cs89_dbg(5, debug,
-						 "%s: receiving %d DMA frames\n",
-						 dev->name, count);
-					if (count > 1)
-						cs89_dbg(2, debug,
-							 "%s: receiving %d DMA frames\n",
-							 dev->name, count);
-					dma_rx(dev);
-					if (--count == 0)
-						count = readreg(dev, PP_DmaFrameCnt);
-					if (count > 0)
-						cs89_dbg(2, debug,
-							 "%s: continuing with %d DMA frames\n",
-							 dev->name, count);
-				}
-			}
-#endif
-			break;
-		case ISQ_RX_MISS_EVENT:
-			dev->stats.rx_missed_errors += (status >> 6);
-			break;
-		case ISQ_TX_COL_EVENT:
-			dev->stats.collisions += (status >> 6);
-			break;
-		}
-	}
-	return IRQ_RETVAL(handled);
+	writereg(dev, PP_RxCFG,
+		 (lp->curr_rx_cfg |
+		  (lp->rx_mode == RX_ALL_ACCEPT)
+		  ? (RX_CRC_ERROR_ENBL | RX_RUNT_ENBL | RX_EXTRA_DATA_ENBL)
+		  : 0));
+	spin_unlock_irqrestore(&lp->lock, flags);
 }
 
-static void
-count_rx_errors(int status, struct net_device *dev)
+static int set_mac_address(struct net_device *dev, void *p)
 {
-	dev->stats.rx_errors++;
-	if (status & RX_RUNT)
-		dev->stats.rx_length_errors++;
-	if (status & RX_EXTRA_DATA)
-		dev->stats.rx_length_errors++;
-	if ((status & RX_CRC_ERROR) && !(status & (RX_EXTRA_DATA | RX_RUNT)))
-		/* per str 172 */
-		dev->stats.rx_crc_errors++;
-	if (status & RX_DRIBBLE)
-		dev->stats.rx_frame_errors++;
+	int i;
+	struct sockaddr *addr = p;
+
+	if (netif_running(dev))
+		return -EBUSY;
+
+	memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+
+	cs89_dbg(0, debug, "%s: Setting MAC address to %pM\n",
+		 dev->name, dev->dev_addr);
+
+	/* set the Ethernet address */
+	for (i = 0; i < ETH_ALEN / 2; i++)
+		writereg(dev, PP_IA + i * 2,
+			 (dev->dev_addr[i * 2] |
+			  (dev->dev_addr[i * 2 + 1] << 8)));
+
+	return 0;
 }
 
-/* We have a good packet(s), get it/them out of the buffers. */
-static void
-net_rx(struct net_device *dev)
+#ifdef CONFIG_NET_POLL_CONTROLLER
+/*
+ * Polling receive - used by netconsole and other diagnostic tools
+ * to allow network i/o with interrupts disabled.
+ */
+static void net_poll_controller(struct net_device *dev)
 {
+	disable_irq(dev->irq);
+	net_interrupt(dev->irq, dev);
+	enable_irq(dev->irq);
+}
+#endif
+
+static const struct net_device_ops net_ops = {
+	.ndo_open		= net_open,
+	.ndo_stop		= net_close,
+	.ndo_tx_timeout		= net_timeout,
+	.ndo_start_xmit		= net_send_packet,
+	.ndo_get_stats		= net_get_stats,
+	.ndo_set_rx_mode	= set_multicast_list,
+	.ndo_set_mac_address	= set_mac_address,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	.ndo_poll_controller	= net_poll_controller,
+#endif
+	.ndo_change_mtu		= eth_change_mtu,
+	.ndo_validate_addr	= eth_validate_addr,
+};
+
+static void __init reset_chip(struct net_device *dev)
+{
+#if !defined(CONFIG_MACH_MX31ADS)
+#if !defined(CS89x0_NONISA_IRQ)
 	struct net_local *lp = netdev_priv(dev);
-	struct sk_buff *skb;
-	int status, length;
+#endif /* CS89x0_NONISA_IRQ */
+	int reset_start_time;
 
-	status = ioread16(lp->virt_addr + RX_FRAME_PORT);
-	length = ioread16(lp->virt_addr + RX_FRAME_PORT);
+	writereg(dev, PP_SelfCTL, readreg(dev, PP_SelfCTL) | POWER_ON_RESET);
 
-	if ((status & RX_OK) == 0) {
-		count_rx_errors(status, dev);
-		return;
+	/* wait 30 ms */
+	msleep(30);
+
+#if !defined(CS89x0_NONISA_IRQ)
+	if (lp->chip_type != CS8900) {
+		/* Hardware problem requires PNP registers to be reconfigured after a reset */
+		iowrite16(PP_CS8920_ISAINT, lp->virt_addr + ADD_PORT);
+		iowrite8(dev->irq, lp->virt_addr + DATA_PORT);
+		iowrite8(0, lp->virt_addr + DATA_PORT + 1);
+
+		iowrite16(PP_CS8920_ISAMemB, lp->virt_addr + ADD_PORT);
+		iowrite8((dev->mem_start >> 16) & 0xff,
+			 lp->virt_addr + DATA_PORT);
+		iowrite8((dev->mem_start >> 8) & 0xff,
+			 lp->virt_addr + DATA_PORT + 1);
 	}
+#endif /* CS89x0_NONISA_IRQ */
 
-	/* Malloc up new buffer. */
-	skb = netdev_alloc_skb(dev, length + 2);
-	if (skb == NULL) {
-#if 0		/* Again, this seems a cruel thing to do */
-		pr_warn("%s: Memory squeeze, dropping packet\n", dev->name);
+	/* Wait until the chip is reset */
+	reset_start_time = jiffies;
+	while ((readreg(dev, PP_SelfST) & INIT_DONE) == 0 &&
+	       jiffies - reset_start_time < 2)
+		;
+#endif /* !CONFIG_MACH_MX31ADS */
+}
+
+/* This is the real probe routine.
+ * Linux has a history of friendly device probes on the ISA bus.
+ * A good device probes avoids doing writes, and
+ * verifies that the correct device exists and functions.
+ * Return 0 on success.
+ */
+static int __init
+cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular)
+{
+	struct net_local *lp = netdev_priv(dev);
+	int i;
+	int tmp;
+	unsigned rev_type = 0;
+	int eeprom_buff[CHKSUM_LEN];
+	int retval;
+
+	/* Initialize the device structure. */
+	if (!modular) {
+		memset(lp, 0, sizeof(*lp));
+		spin_lock_init(&lp->lock);
+#ifndef MODULE
+#if ALLOW_DMA
+		if (g_cs89x0_dma) {
+			lp->use_dma = 1;
+			lp->dma = g_cs89x0_dma;
+			lp->dmasize = 16;	/* Could make this an option... */
+		}
 #endif
-		dev->stats.rx_dropped++;
-		return;
+		lp->force = g_cs89x0_media__force;
+#endif
+	}
+
+	pr_debug("PP_addr at %p[%x]: 0x%x\n",
+		 ioaddr, ADD_PORT, ioread16(ioaddr + ADD_PORT));
+	iowrite16(PP_ChipID, ioaddr + ADD_PORT);
+
+	tmp = ioread16(ioaddr + DATA_PORT);
+	if (tmp != CHIP_EISA_ID_SIG) {
+		pr_debug("%s: incorrect signature at %p[%x]: 0x%x!="
+			 CHIP_EISA_ID_SIG_STR "\n",
+			 dev->name, ioaddr, DATA_PORT, tmp);
+		retval = -ENODEV;
+		goto out1;
+	}
+
+	lp->virt_addr = ioaddr;
+
+	/* get the chip type */
+	rev_type = readreg(dev, PRODUCT_ID_ADD);
+	lp->chip_type = rev_type & ~REVISON_BITS;
+	lp->chip_revision = ((rev_type & REVISON_BITS) >> 8) + 'A';
+
+	/* Check the chip type and revision in order to set the correct
+	 * send command.  CS8920 revision C and CS8900 revision F can use
+	 * the faster send.
+	 */
+	lp->send_cmd = TX_AFTER_381;
+	if (lp->chip_type == CS8900 && lp->chip_revision >= 'F')
+		lp->send_cmd = TX_NOW;
+	if (lp->chip_type != CS8900 && lp->chip_revision >= 'C')
+		lp->send_cmd = TX_NOW;
+
+	pr_info_once("%s\n", version);
+
+	pr_info("%s: cs89%c0%s rev %c found at %p ",
+		dev->name,
+		lp->chip_type == CS8900  ? '0' : '2',
+		lp->chip_type == CS8920M ? "M" : "",
+		lp->chip_revision,
+		lp->virt_addr);
+
+	reset_chip(dev);
+
+	/* Here we read the current configuration of the chip.
+	 * If there is no Extended EEPROM then the idea is to not disturb
+	 * the chip configuration, it should have been correctly setup by
+	 * automatic EEPROM read on reset. So, if the chip says it read
+	 * the EEPROM the driver will always do *something* instead of
+	 * complain that adapter_cnf is 0.
+	 */
+
+	if ((readreg(dev, PP_SelfST) & (EEPROM_OK | EEPROM_PRESENT)) ==
+	    (EEPROM_OK | EEPROM_PRESENT)) {
+		/* Load the MAC. */
+		for (i = 0; i < ETH_ALEN / 2; i++) {
+			unsigned int Addr;
+			Addr = readreg(dev, PP_IA + i * 2);
+			dev->dev_addr[i * 2] = Addr & 0xFF;
+			dev->dev_addr[i * 2 + 1] = Addr >> 8;
+		}
+
+		/* Load the Adapter Configuration.
+		 * Note:  Barring any more specific information from some
+		 * other source (ie EEPROM+Schematics), we would not know
+		 * how to operate a 10Base2 interface on the AUI port.
+		 * However, since we  do read the status of HCB1 and use
+		 * settings that always result in calls to control_dc_dc(dev,0)
+		 * a BNC interface should work if the enable pin
+		 * (dc/dc converter) is on HCB1.
+		 * It will be called AUI however.
+		 */
+
+		lp->adapter_cnf = 0;
+		i = readreg(dev, PP_LineCTL);
+		/* Preserve the setting of the HCB1 pin. */
+		if ((i & (HCB1 | HCB1_ENBL)) == (HCB1 | HCB1_ENBL))
+			lp->adapter_cnf |= A_CNF_DC_DC_POLARITY;
+		/* Save the sqelch bit */
+		if ((i & LOW_RX_SQUELCH) == LOW_RX_SQUELCH)
+			lp->adapter_cnf |= A_CNF_EXTND_10B_2 | A_CNF_LOW_RX_SQUELCH;
+		/* Check if the card is in 10Base-t only mode */
+		if ((i & (AUI_ONLY | AUTO_AUI_10BASET)) == 0)
+			lp->adapter_cnf |=  A_CNF_10B_T | A_CNF_MEDIA_10B_T;
+		/* Check if the card is in AUI only mode */
+		if ((i & (AUI_ONLY | AUTO_AUI_10BASET)) == AUI_ONLY)
+			lp->adapter_cnf |=  A_CNF_AUI | A_CNF_MEDIA_AUI;
+		/* Check if the card is in Auto mode. */
+		if ((i & (AUI_ONLY | AUTO_AUI_10BASET)) == AUTO_AUI_10BASET)
+			lp->adapter_cnf |=  A_CNF_AUI | A_CNF_10B_T |
+				A_CNF_MEDIA_AUI | A_CNF_MEDIA_10B_T | A_CNF_MEDIA_AUTO;
+
+		cs89_dbg(1, info, "%s: PP_LineCTL=0x%x, adapter_cnf=0x%x\n",
+			 dev->name, i, lp->adapter_cnf);
+
+		/* IRQ. Other chips already probe, see below. */
+		if (lp->chip_type == CS8900)
+			lp->isa_config = readreg(dev, PP_CS8900_ISAINT) & INT_NO_MASK;
+
+		pr_cont("[Cirrus EEPROM] ");
+	}
+
+	pr_cont("\n");
+
+	/* First check to see if an EEPROM is attached. */
+
+	if ((readreg(dev, PP_SelfST) & EEPROM_PRESENT) == 0)
+		pr_warn("No EEPROM, relying on command line....\n");
+	else if (get_eeprom_data(dev, START_EEPROM_DATA, CHKSUM_LEN, eeprom_buff) < 0) {
+		pr_warn("EEPROM read failed, relying on command line\n");
+	} else if (get_eeprom_cksum(START_EEPROM_DATA, CHKSUM_LEN, eeprom_buff) < 0) {
+		/* Check if the chip was able to read its own configuration starting
+		   at 0 in the EEPROM*/
+		if ((readreg(dev, PP_SelfST) & (EEPROM_OK | EEPROM_PRESENT)) !=
+		    (EEPROM_OK | EEPROM_PRESENT))
+			pr_warn("Extended EEPROM checksum bad and no Cirrus EEPROM, relying on command line\n");
+
+	} else {
+		/* This reads an extended EEPROM that is not documented
+		 * in the CS8900 datasheet.
+		 */
+
+		/* get transmission control word  but keep the autonegotiation bits */
+		if (!lp->auto_neg_cnf)
+			lp->auto_neg_cnf = eeprom_buff[AUTO_NEG_CNF_OFFSET / 2];
+		/* Store adapter configuration */
+		if (!lp->adapter_cnf)
+			lp->adapter_cnf = eeprom_buff[ADAPTER_CNF_OFFSET / 2];
+		/* Store ISA configuration */
+		lp->isa_config = eeprom_buff[ISA_CNF_OFFSET / 2];
+		dev->mem_start = eeprom_buff[PACKET_PAGE_OFFSET / 2] << 8;
+
+		/* eeprom_buff has 32-bit ints, so we can't just memcpy it */
+		/* store the initial memory base address */
+		for (i = 0; i < ETH_ALEN / 2; i++) {
+			dev->dev_addr[i * 2] = eeprom_buff[i];
+			dev->dev_addr[i * 2 + 1] = eeprom_buff[i] >> 8;
+		}
+		cs89_dbg(1, debug, "%s: new adapter_cnf: 0x%x\n",
+			 dev->name, lp->adapter_cnf);
+	}
+
+	/* allow them to force multiple transceivers.  If they force multiple, autosense */
+	{
+		int count = 0;
+		if (lp->force & FORCE_RJ45) {
+			lp->adapter_cnf |= A_CNF_10B_T;
+			count++;
+		}
+		if (lp->force & FORCE_AUI) {
+			lp->adapter_cnf |= A_CNF_AUI;
+			count++;
+		}
+		if (lp->force & FORCE_BNC) {
+			lp->adapter_cnf |= A_CNF_10B_2;
+			count++;
+		}
+		if (count > 1)
+			lp->adapter_cnf |= A_CNF_MEDIA_AUTO;
+		else if (lp->force & FORCE_RJ45)
+			lp->adapter_cnf |= A_CNF_MEDIA_10B_T;
+		else if (lp->force & FORCE_AUI)
+			lp->adapter_cnf |= A_CNF_MEDIA_AUI;
+		else if (lp->force & FORCE_BNC)
+			lp->adapter_cnf |= A_CNF_MEDIA_10B_2;
 	}
-	skb_reserve(skb, 2);	/* longword align L3 header */
 
-	readwords(lp, RX_FRAME_PORT, skb_put(skb, length), length >> 1);
-	if (length & 1)
-		skb->data[length-1] = ioread16(lp->virt_addr + RX_FRAME_PORT);
+	cs89_dbg(1, debug, "%s: after force 0x%x, adapter_cnf=0x%x\n",
+		 dev->name, lp->force, lp->adapter_cnf);
 
-	cs89_dbg(3, debug, "%s: received %d byte packet of type %x\n",
-		 dev->name, length,
-		 (skb->data[ETH_ALEN + ETH_ALEN] << 8) |
-		 skb->data[ETH_ALEN + ETH_ALEN + 1]);
+	/* FIXME: We don't let you set dc-dc polarity or low RX squelch from the command line: add it here */
 
-	skb->protocol = eth_type_trans(skb, dev);
-	netif_rx(skb);
-	dev->stats.rx_packets++;
-	dev->stats.rx_bytes += length;
-}
+	/* FIXME: We don't let you set the IMM bit from the command line: add it to lp->auto_neg_cnf here */
 
-#if ALLOW_DMA
-static void release_dma_buff(struct net_local *lp)
-{
-	if (lp->dma_buff) {
-		free_pages((unsigned long)(lp->dma_buff),
-			   get_order(lp->dmasize * 1024));
-		lp->dma_buff = NULL;
-	}
-}
-#endif
+	/* FIXME: we don't set the Ethernet address on the command line.  Use
+	 * ifconfig IFACE hw ether AABBCCDDEEFF
+	 */
 
-/* The inverse routine to net_open(). */
-static int
-net_close(struct net_device *dev)
-{
-#if ALLOW_DMA
-	struct net_local *lp = netdev_priv(dev);
-#endif
+	pr_info("media %s%s%s",
+		(lp->adapter_cnf & A_CNF_10B_T) ? "RJ-45," : "",
+		(lp->adapter_cnf & A_CNF_AUI) ? "AUI," : "",
+		(lp->adapter_cnf & A_CNF_10B_2) ? "BNC," : "");
 
-	netif_stop_queue(dev);
+	lp->irq_map = 0xffff;
 
-	writereg(dev, PP_RxCFG, 0);
-	writereg(dev, PP_TxCFG, 0);
-	writereg(dev, PP_BufCFG, 0);
-	writereg(dev, PP_BusCTL, 0);
+	/* If this is a CS8900 then no pnp soft */
+	if (lp->chip_type != CS8900 &&
+	    /* Check if the ISA IRQ has been set  */
+	    (i = readreg(dev, PP_CS8920_ISAINT) & 0xff,
+	     (i != 0 && i < CS8920_NO_INTS))) {
+		if (!dev->irq)
+			dev->irq = i;
+	} else {
+		i = lp->isa_config & INT_NO_MASK;
+#ifndef CONFIG_CS89x0_PLATFORM
+		if (lp->chip_type == CS8900) {
+#ifdef CS89x0_NONISA_IRQ
+			i = cs8900_irq_map[0];
+#else
+			/* Translate the IRQ using the IRQ mapping table. */
+			if (i >= ARRAY_SIZE(cs8900_irq_map))
+				pr_err("invalid ISA interrupt number %d\n", i);
+			else
+				i = cs8900_irq_map[i];
 
-	free_irq(dev->irq, dev);
+			lp->irq_map = CS8900_IRQ_MAP; /* fixed IRQ map for CS8900 */
+		} else {
+			int irq_map_buff[IRQ_MAP_LEN/2];
 
-#if ALLOW_DMA
-	if (lp->use_dma && lp->dma) {
-		free_dma(dev->dma);
-		release_dma_buff(lp);
+			if (get_eeprom_data(dev, IRQ_MAP_EEPROM_DATA,
+					    IRQ_MAP_LEN / 2,
+					    irq_map_buff) >= 0) {
+				if ((irq_map_buff[0] & 0xff) == PNP_IRQ_FRMT)
+					lp->irq_map = ((irq_map_buff[0] >> 8) |
+						       (irq_map_buff[1] << 8));
+			}
+#endif
+		}
+#endif
+		if (!dev->irq)
+			dev->irq = i;
 	}
+
+	pr_cont(" IRQ %d", dev->irq);
+
+#if ALLOW_DMA
+	if (lp->use_dma) {
+		get_dma_channel(dev);
+		pr_cont(", DMA %d", dev->dma);
+	} else
 #endif
+		pr_cont(", programmed I/O");
 
-	/* Update the statistics here. */
+	/* print the ethernet address. */
+	pr_cont(", MAC %pM\n", dev->dev_addr);
+
+	dev->netdev_ops	= &net_ops;
+	dev->watchdog_timeo = HZ;
+
+	cs89_dbg(0, info, "cs89x0_probe1() successful\n");
+
+	retval = register_netdev(dev);
+	if (retval)
+		goto out2;
 	return 0;
+out2:
+	iowrite16(PP_ChipID, lp->virt_addr + ADD_PORT);
+out1:
+	return retval;
 }
 
-/* Get the current statistics.
- * This may be called with the card open or closed.
+#ifndef CONFIG_CS89x0_PLATFORM
+/*
+ * This function converts the I/O port addres used by the cs89x0_probe() and
+ * init_module() functions to the I/O memory address used by the
+ * cs89x0_probe1() function.
  */
-static struct net_device_stats *
-net_get_stats(struct net_device *dev)
+static int __init
+cs89x0_ioport_probe(struct net_device *dev, unsigned long ioport, int modular)
 {
 	struct net_local *lp = netdev_priv(dev);
-	unsigned long flags;
-
-	spin_lock_irqsave(&lp->lock, flags);
-	/* Update the statistics from the device registers. */
-	dev->stats.rx_missed_errors += (readreg(dev, PP_RxMiss) >> 6);
-	dev->stats.collisions += (readreg(dev, PP_TxCol) >> 6);
-	spin_unlock_irqrestore(&lp->lock, flags);
+	int ret;
+	void __iomem *io_mem;
 
-	return &dev->stats;
-}
+	if (!lp)
+		return -ENOMEM;
 
-static void set_multicast_list(struct net_device *dev)
-{
-	struct net_local *lp = netdev_priv(dev);
-	unsigned long flags;
+	dev->base_addr = ioport;
 
-	spin_lock_irqsave(&lp->lock, flags);
-	if (dev->flags & IFF_PROMISC)
-		lp->rx_mode = RX_ALL_ACCEPT;
-	else if ((dev->flags & IFF_ALLMULTI) || !netdev_mc_empty(dev))
-		/* The multicast-accept list is initialized to accept-all,
-		 * and we rely on higher-level filtering for now.
-		 */
-		lp->rx_mode = RX_MULTCAST_ACCEPT;
-	else
-		lp->rx_mode = 0;
+	if (!request_region(ioport, NETCARD_IO_EXTENT, DRV_NAME)) {
+		ret = -EBUSY;
+		goto out;
+	}
 
-	writereg(dev, PP_RxCTL, DEF_RX_ACCEPT | lp->rx_mode);
+	io_mem = ioport_map(ioport & ~3, NETCARD_IO_EXTENT);
+	if (!io_mem) {
+		ret = -ENOMEM;
+		goto release;
+	}
 
-	/* in promiscuous mode, we accept errored packets,
-	 * so we have to enable interrupts on them also
+	/* if they give us an odd I/O address, then do ONE write to
+	 * the address port, to get it back to address zero, where we
+	 * expect to find the EISA signature word. An IO with a base of 0x3
+	 * will skip the test for the ADD_PORT.
 	 */
-	writereg(dev, PP_RxCFG,
-		 (lp->curr_rx_cfg |
-		  (lp->rx_mode == RX_ALL_ACCEPT)
-		  ? (RX_CRC_ERROR_ENBL | RX_RUNT_ENBL | RX_EXTRA_DATA_ENBL)
-		  : 0));
-	spin_unlock_irqrestore(&lp->lock, flags);
+	if (ioport & 1) {
+		cs89_dbg(1, info, "%s: odd ioaddr 0x%lx\n", dev->name, ioport);
+		if ((ioport & 2) != 2) {
+			if ((ioread16(io_mem + ADD_PORT) & ADD_MASK) !=
+			    ADD_SIG) {
+				pr_err("%s: bad signature 0x%x\n",
+				       dev->name, ioread16(io_mem + ADD_PORT));
+				ret = -ENODEV;
+				goto unmap;
+			}
+		}
+	}
+
+	ret = cs89x0_probe1(dev, io_mem, modular);
+	if (!ret)
+		goto out;
+unmap:
+	ioport_unmap(io_mem);
+release:
+	release_region(ioport, NETCARD_IO_EXTENT);
+out:
+	return ret;
 }
 
-static int set_mac_address(struct net_device *dev, void *p)
-{
-	int i;
-	struct sockaddr *addr = p;
+#ifndef MODULE
+/* Check for a network adaptor of this type, and return '0' iff one exists.
+ * If dev->base_addr == 0, probe all likely locations.
+ * If dev->base_addr == 1, always return failure.
+ * If dev->base_addr == 2, allocate space for the device and return success
+ * (detachable devices only).
+ * Return 0 on success.
+ */
 
-	if (netif_running(dev))
-		return -EBUSY;
+struct net_device * __init cs89x0_probe(int unit)
+{
+	struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
+	unsigned *port;
+	int err = 0;
+	int irq;
+	int io;
 
-	memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+	if (!dev)
+		return ERR_PTR(-ENODEV);
 
-	cs89_dbg(0, debug, "%s: Setting MAC address to %pM\n",
-		 dev->name, dev->dev_addr);
+	sprintf(dev->name, "eth%d", unit);
+	netdev_boot_setup_check(dev);
+	io = dev->base_addr;
+	irq = dev->irq;
 
-	/* set the Ethernet address */
-	for (i = 0; i < ETH_ALEN / 2; i++)
-		writereg(dev, PP_IA + i * 2,
-			 (dev->dev_addr[i * 2] |
-			  (dev->dev_addr[i * 2 + 1] << 8)));
+	cs89_dbg(0, info, "cs89x0_probe(0x%x)\n", io);
 
-	return 0;
+	if (io > 0x1ff)	{	/* Check a single specified location. */
+		err = cs89x0_ioport_probe(dev, io, 0);
+	} else if (io != 0) {	/* Don't probe at all. */
+		err = -ENXIO;
+	} else {
+		for (port = netcard_portlist; *port; port++) {
+			if (cs89x0_ioport_probe(dev, *port, 0) == 0)
+				break;
+			dev->irq = irq;
+		}
+		if (!*port)
+			err = -ENODEV;
+	}
+	if (err)
+		goto out;
+	return dev;
+out:
+	free_netdev(dev);
+	pr_warn("no cs8900 or cs8920 detected.  Be sure to disable PnP with SETUP\n");
+	return ERR_PTR(err);
 }
+#endif
+#endif
 
 #if defined(MODULE) && !defined(CONFIG_CS89x0_PLATFORM)
 
-- 
1.7.8.111.gad25c.dirty

^ permalink raw reply related

* [PATCH net-next 4/5] cirrus: cs89x0: Neaten debugging and logging
From: Joe Perches @ 2012-05-18 22:56 UTC (permalink / raw)
  To: netdev, linux-kernel; +Cc: Jaccon Bastiaansen
In-Reply-To: <cover.1337381533.git.joe@perches.com>

Introduce and use a debug macro to test and print.
Convert printks to pr_<level>.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/ethernet/cirrus/cs89x0.c |  187 +++++++++++++++-------------------
 1 files changed, 82 insertions(+), 105 deletions(-)

diff --git a/drivers/net/ethernet/cirrus/cs89x0.c b/drivers/net/ethernet/cirrus/cs89x0.c
index 6e5b2c7..859f8be 100644
--- a/drivers/net/ethernet/cirrus/cs89x0.c
+++ b/drivers/net/ethernet/cirrus/cs89x0.c
@@ -77,8 +77,14 @@
 
 #include "cs89x0.h"
 
+#define cs89_dbg(val, level, fmt, ...)				\
+do {								\
+	if (val <= net_debug)					\
+		pr_##level(fmt, ##__VA_ARGS__);			\
+} while (0)
+
 static char version[] __initdata =
-	"v2.4.3-pre1 Russell Nelson <nelson@crynwr.com>, Andrew Morton\n";
+	"v2.4.3-pre1 Russell Nelson <nelson@crynwr.com>, Andrew Morton";
 
 #define DRV_NAME "cs89x0"
 
@@ -315,8 +321,7 @@ get_eeprom_data(struct net_device *dev, int off, int len, int *buffer)
 {
 	int i;
 
-	if (net_debug > 3)
-		printk("EEPROM data from %x for %x:\n", off, len);
+	cs89_dbg(3, info, "EEPROM data from %x for %x:\n", off, len);
 	for (i = 0; i < len; i++) {
 		if (wait_eeprom_ready(dev) < 0)
 			return -1;
@@ -325,11 +330,9 @@ get_eeprom_data(struct net_device *dev, int off, int len, int *buffer)
 		if (wait_eeprom_ready(dev) < 0)
 			return -1;
 		buffer[i] = readreg(dev, PP_EEData);
-		if (net_debug > 3)
-			printk("%04x ", buffer[i]);
+		cs89_dbg(3, cont, "%04x ", buffer[i]);
 	}
-	if (net_debug > 3)
-		printk("\n");
+	cs89_dbg(3, cont, "\n");
 	return 0;
 }
 
@@ -435,8 +438,7 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular)
 	if (lp->chip_type != CS8900 && lp->chip_revision >= 'C')
 		lp->send_cmd = TX_NOW;
 
-	if (net_debug)
-		printk_once(version);
+	pr_info_once("%s\n", version);
 
 	pr_info("%s: cs89%c0%s rev %c found at %p ",
 		dev->name,
@@ -495,18 +497,17 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular)
 			lp->adapter_cnf |=  A_CNF_AUI | A_CNF_10B_T |
 				A_CNF_MEDIA_AUI | A_CNF_MEDIA_10B_T | A_CNF_MEDIA_AUTO;
 
-		if (net_debug > 1)
-			pr_info("%s: PP_LineCTL=0x%x, adapter_cnf=0x%x\n",
-				dev->name, i, lp->adapter_cnf);
+		cs89_dbg(1, info, "%s: PP_LineCTL=0x%x, adapter_cnf=0x%x\n",
+			 dev->name, i, lp->adapter_cnf);
 
 		/* IRQ. Other chips already probe, see below. */
 		if (lp->chip_type == CS8900)
 			lp->isa_config = readreg(dev, PP_CS8900_ISAINT) & INT_NO_MASK;
 
-		printk("[Cirrus EEPROM] ");
+		pr_cont("[Cirrus EEPROM] ");
 	}
 
-	printk("\n");
+	pr_cont("\n");
 
 	/* First check to see if an EEPROM is attached. */
 
@@ -542,9 +543,8 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular)
 			dev->dev_addr[i * 2] = eeprom_buff[i];
 			dev->dev_addr[i * 2 + 1] = eeprom_buff[i] >> 8;
 		}
-		if (net_debug > 1)
-			pr_debug("%s: new adapter_cnf: 0x%x\n",
-				 dev->name, lp->adapter_cnf);
+		cs89_dbg(1, debug, "%s: new adapter_cnf: 0x%x\n",
+			 dev->name, lp->adapter_cnf);
 	}
 
 	/* allow them to force multiple transceivers.  If they force multiple, autosense */
@@ -572,9 +572,8 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular)
 			lp->adapter_cnf |= A_CNF_MEDIA_10B_2;
 	}
 
-	if (net_debug > 1)
-		pr_debug("%s: after force 0x%x, adapter_cnf=0x%x\n",
-			 dev->name, lp->force, lp->adapter_cnf);
+	cs89_dbg(1, debug, "%s: after force 0x%x, adapter_cnf=0x%x\n",
+		 dev->name, lp->force, lp->adapter_cnf);
 
 	/* FIXME: We don't let you set dc-dc polarity or low RX squelch from the command line: add it here */
 
@@ -629,24 +628,23 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular)
 			dev->irq = i;
 	}
 
-	printk(" IRQ %d", dev->irq);
+	pr_cont(" IRQ %d", dev->irq);
 
 #if ALLOW_DMA
 	if (lp->use_dma) {
 		get_dma_channel(dev);
-		printk(", DMA %d", dev->dma);
+		pr_cont(", DMA %d", dev->dma);
 	} else
 #endif
-		printk(", programmed I/O");
+		pr_cont(", programmed I/O");
 
 	/* print the ethernet address. */
-	printk(", MAC %pM\n", dev->dev_addr);
+	pr_cont(", MAC %pM\n", dev->dev_addr);
 
 	dev->netdev_ops	= &net_ops;
 	dev->watchdog_timeo = HZ;
 
-	if (net_debug)
-		printk("cs89x0_probe1() successful\n");
+	cs89_dbg(0, info, "cs89x0_probe1() successful\n");
 
 	retval = register_netdev(dev);
 	if (retval)
@@ -693,8 +691,7 @@ cs89x0_ioport_probe(struct net_device *dev, unsigned long ioport, int modular)
 	 * will skip the test for the ADD_PORT.
 	 */
 	if (ioport & 1) {
-		if (net_debug > 1)
-			pr_info("%s: odd ioaddr 0x%lx\n", dev->name, ioport);
+		cs89_dbg(1, info, "%s: odd ioaddr 0x%lx\n", dev->name, ioport);
 		if ((ioport & 2) != 2) {
 			if ((ioread16(io_mem + ADD_PORT) & ADD_MASK) !=
 			    ADD_SIG) {
@@ -742,8 +739,7 @@ struct net_device * __init cs89x0_probe(int unit)
 	io = dev->base_addr;
 	irq = dev->irq;
 
-	if (net_debug)
-		pr_info("cs89x0_probe(0x%x)\n", io);
+	cs89_dbg(0, info, "cs89x0_probe(0x%x)\n", io);
 
 	if (io > 0x1ff)	{	/* Check a single specified location. */
 		err = cs89x0_ioport_probe(dev, io, 0);
@@ -817,18 +813,15 @@ set_dma_cfg(struct net_device *dev)
 
 	if (lp->use_dma) {
 		if ((lp->isa_config & ANY_ISA_DMA) == 0) {
-			if (net_debug > 3)
-				printk("set_dma_cfg(): no DMA\n");
+			cs89_dbg(3, err, "set_dma_cfg(): no DMA\n");
 			return;
 		}
 		if (lp->isa_config & ISA_RxDMA) {
 			lp->curr_rx_cfg |= RX_DMA_ONLY;
-			if (net_debug > 3)
-				printk("set_dma_cfg(): RX_DMA_ONLY\n");
+			cs89_dbg(3, info, "set_dma_cfg(): RX_DMA_ONLY\n");
 		} else {
 			lp->curr_rx_cfg |= AUTO_RX_DMA;	/* not that we support it... */
-			if (net_debug > 3)
-				printk("set_dma_cfg(): AUTO_RX_DMA\n");
+			cs89_dbg(3, info, "set_dma_cfg(): AUTO_RX_DMA\n");
 		}
 	}
 }
@@ -871,10 +864,10 @@ dma_rx(struct net_device *dev)
 	status = bp[0] + (bp[1] << 8);
 	length = bp[2] + (bp[3] << 8);
 	bp += 4;
-	if (net_debug > 5) {
-		printk("%s: receiving DMA packet at %lx, status %x, length %x\n",
-		       dev->name, (unsigned long)bp, status, length);
-	}
+
+	cs89_dbg(5, debug, "%s: receiving DMA packet at %lx, status %x, length %x\n",
+		 dev->name, (unsigned long)bp, status, length);
+
 	if ((status & RX_OK) == 0) {
 		count_rx_errors(status, dev);
 		goto skip_this_frame;
@@ -883,9 +876,9 @@ dma_rx(struct net_device *dev)
 	/* Malloc up new buffer. */
 	skb = netdev_alloc_skb(dev, length + 2);
 	if (skb == NULL) {
-		if (net_debug)	/* I don't think we want to do this to a stressed system */
-			printk("%s: Memory squeeze, dropping packet\n",
-			       dev->name);
+		/* I don't think we want to do this to a stressed system */
+		cs89_dbg(0, err, "%s: Memory squeeze, dropping packet\n",
+			 dev->name);
 		dev->stats.rx_dropped++;
 
 		/* AKPM: advance bp to the next frame */
@@ -911,12 +904,11 @@ skip_this_frame:
 		bp -= lp->dmasize*1024;
 	lp->rx_dma_ptr = bp;
 
-	if (net_debug > 3) {
-		printk("%s: received %d byte DMA packet of type %x\n",
-		       dev->name, length,
-		       ((skb->data[ETH_ALEN + ETH_ALEN] << 8) |
-			skb->data[ETH_ALEN + ETH_ALEN + 1]));
-	}
+	cs89_dbg(3, info, "%s: received %d byte DMA packet of type %x\n",
+		 dev->name, length,
+		 ((skb->data[ETH_ALEN + ETH_ALEN] << 8) |
+		  skb->data[ETH_ALEN + ETH_ALEN + 1]));
+
 	skb->protocol = eth_type_trans(skb, dev);
 	netif_rx(skb);
 	dev->stats.rx_packets++;
@@ -998,8 +990,7 @@ detect_tp(struct net_device *dev)
 	int timenow = jiffies;
 	int fdx;
 
-	if (net_debug > 1)
-		printk("%s: Attempting TP\n", dev->name);
+	cs89_dbg(1, debug, "%s: Attempting TP\n", dev->name);
 
 	/* If connected to another full duplex capable 10-Base-T card
 	 * the link pulses seem to be lost when the auto detect bit in
@@ -1023,7 +1014,8 @@ detect_tp(struct net_device *dev)
 		switch (lp->force & 0xf0) {
 #if 0
 		case FORCE_AUTO:
-			printk("%s: cs8900 doesn't autonegotiate\n", dev->name);
+			pr_info("%s: cs8900 doesn't autonegotiate\n",
+				dev->name);
 			return DETECTED_NONE;
 #endif
 			/* CS8900 doesn't support AUTO, change to HALF*/
@@ -1102,18 +1094,15 @@ send_test_pkt(struct net_device *dev)
 	/* Write the contents of the packet */
 	writewords(lp, TX_FRAME_PORT, test_packet, (ETH_ZLEN + 1) >> 1);
 
-	if (net_debug > 1)
-		printk("Sending test packet ");
+	cs89_dbg(1, debug, "Sending test packet ");
 	/* wait a couple of jiffies for packet to be received */
 	for (timenow = jiffies; jiffies - timenow < 3;)
 		;
 	if ((readreg(dev, PP_TxEvent) & TX_SEND_OK_BITS) == TX_OK) {
-		if (net_debug > 1)
-			printk("succeeded\n");
+		cs89_dbg(1, cont, "succeeded\n");
 		return 1;
 	}
-	if (net_debug > 1)
-		printk("failed\n");
+	cs89_dbg(1, cont, "failed\n");
 	return 0;
 }
 
@@ -1123,8 +1112,7 @@ detect_aui(struct net_device *dev)
 {
 	struct net_local *lp = netdev_priv(dev);
 
-	if (net_debug > 1)
-		printk("%s: Attempting AUI\n", dev->name);
+	cs89_dbg(1, debug, "%s: Attempting AUI\n", dev->name);
 	control_dc_dc(dev, 0);
 
 	writereg(dev, PP_LineCTL, (lp->linectl & ~AUTO_AUI_10BASET) | AUI_ONLY);
@@ -1140,8 +1128,7 @@ detect_bnc(struct net_device *dev)
 {
 	struct net_local *lp = netdev_priv(dev);
 
-	if (net_debug > 1)
-		printk("%s: Attempting BNC\n", dev->name);
+	cs89_dbg(1, debug, "%s: Attempting BNC\n", dev->name);
 	control_dc_dc(dev, 1);
 
 	writereg(dev, PP_LineCTL, (lp->linectl & ~AUTO_AUI_10BASET) | AUI_ONLY);
@@ -1255,12 +1242,10 @@ net_open(struct net_device *dev)
 			       dev->name, lp->dmasize);
 			goto release_irq;
 		}
-		if (net_debug > 1) {
-			printk("%s: dma %lx %lx\n",
-			       dev->name,
-			       (unsigned long)lp->dma_buff,
-			       (unsigned long)isa_virt_to_bus(lp->dma_buff));
-		}
+		cs89_dbg(1, debug, "%s: dma %lx %lx\n",
+			 dev->name,
+			 (unsigned long)lp->dma_buff,
+			 (unsigned long)isa_virt_to_bus(lp->dma_buff));
 		if ((unsigned long)lp->dma_buff >= MAX_DMA_ADDRESS ||
 		    !dma_page_eq(lp->dma_buff,
 				 lp->dma_buff + lp->dmasize * 1024 - 1)) {
@@ -1442,8 +1427,7 @@ release_irq:
 #endif
 			 ));
 	netif_start_queue(dev);
-	if (net_debug > 1)
-		printk("cs89x0: net_open() succeeded\n");
+	cs89_dbg(1, debug, "net_open() succeeded\n");
 	return 0;
 bad_out:
 	return ret;
@@ -1453,10 +1437,9 @@ static void net_timeout(struct net_device *dev)
 {
 	/* If we get here, some higher level has decided we are broken.
 	   There should really be a "kick me" function call instead. */
-	if (net_debug > 0)
-		printk("%s: transmit timed out, %s?\n",
-		       dev->name,
-		       tx_done(dev) ? "IRQ conflict" : "network cable problem");
+	cs89_dbg(0, err, "%s: transmit timed out, %s?\n",
+		 dev->name,
+		 tx_done(dev) ? "IRQ conflict" : "network cable problem");
 	/* Try to restart the adaptor. */
 	netif_wake_queue(dev);
 }
@@ -1466,12 +1449,10 @@ static netdev_tx_t net_send_packet(struct sk_buff *skb, struct net_device *dev)
 	struct net_local *lp = netdev_priv(dev);
 	unsigned long flags;
 
-	if (net_debug > 3) {
-		printk("%s: sent %d byte packet of type %x\n",
-		       dev->name, skb->len,
-		       ((skb->data[ETH_ALEN + ETH_ALEN] << 8) |
-			skb->data[ETH_ALEN + ETH_ALEN + 1]));
-	}
+	cs89_dbg(3, debug, "%s: sent %d byte packet of type %x\n",
+		 dev->name, skb->len,
+		 ((skb->data[ETH_ALEN + ETH_ALEN] << 8) |
+		  skb->data[ETH_ALEN + ETH_ALEN + 1]));
 
 	/* keep the upload from being interrupted, since we
 	 * ask the chip to start transmitting before the
@@ -1492,8 +1473,7 @@ static netdev_tx_t net_send_packet(struct sk_buff *skb, struct net_device *dev)
 		 */
 
 		spin_unlock_irqrestore(&lp->lock, flags);
-		if (net_debug)
-			printk("cs89x0: Tx buffer not free!\n");
+		cs89_dbg(0, err, "Tx buffer not free!\n");
 		return NETDEV_TX_BUSY;
 	}
 	/* Write the contents of the packet */
@@ -1537,8 +1517,7 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)
 	 * vista, baby!
 	 */
 	while ((status = ioread16(lp->virt_addr + ISQ_PORT))) {
-		if (net_debug > 4)
-			printk("%s: event=%04x\n", dev->name, status);
+		cs89_dbg(4, debug, "%s: event=%04x\n", dev->name, status);
 		handled = 1;
 		switch (status & ISQ_EVENT_MASK) {
 		case ISQ_RECEIVER_EVENT:
@@ -1576,9 +1555,8 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)
 				netif_wake_queue(dev);	/* Inform upper layers. */
 			}
 			if (status & TX_UNDERRUN) {
-				if (net_debug > 0)
-					printk("%s: transmit underrun\n",
-					       dev->name);
+				cs89_dbg(0, err, "%s: transmit underrun\n",
+					 dev->name);
 				lp->send_underrun++;
 				if (lp->send_underrun == 3)
 					lp->send_cmd = TX_AFTER_381;
@@ -1596,18 +1574,20 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)
 			if (lp->use_dma && (status & RX_DMA)) {
 				int count = readreg(dev, PP_DmaFrameCnt);
 				while (count) {
-					if (net_debug > 5)
-						printk("%s: receiving %d DMA frames\n",
-						       dev->name, count);
-					if (net_debug > 2 && count > 1)
-						printk("%s: receiving %d DMA frames\n",
-						       dev->name, count);
+					cs89_dbg(5, debug,
+						 "%s: receiving %d DMA frames\n",
+						 dev->name, count);
+					if (count > 1)
+						cs89_dbg(2, debug,
+							 "%s: receiving %d DMA frames\n",
+							 dev->name, count);
 					dma_rx(dev);
 					if (--count == 0)
 						count = readreg(dev, PP_DmaFrameCnt);
-					if (net_debug > 2 && count > 0)
-						printk("%s: continuing with %d DMA frames\n",
-						       dev->name, count);
+					if (count > 0)
+						cs89_dbg(2, debug,
+							 "%s: continuing with %d DMA frames\n",
+							 dev->name, count);
 				}
 			}
 #endif
@@ -1669,12 +1649,10 @@ net_rx(struct net_device *dev)
 	if (length & 1)
 		skb->data[length-1] = ioread16(lp->virt_addr + RX_FRAME_PORT);
 
-	if (net_debug > 3) {
-		printk("%s: received %d byte packet of type %x\n",
-		       dev->name, length,
-		       (skb->data[ETH_ALEN + ETH_ALEN] << 8) |
-		       skb->data[ETH_ALEN + ETH_ALEN + 1]);
-	}
+	cs89_dbg(3, debug, "%s: received %d byte packet of type %x\n",
+		 dev->name, length,
+		 (skb->data[ETH_ALEN + ETH_ALEN] << 8) |
+		 skb->data[ETH_ALEN + ETH_ALEN + 1]);
 
 	skb->protocol = eth_type_trans(skb, dev);
 	netif_rx(skb);
@@ -1778,9 +1756,8 @@ static int set_mac_address(struct net_device *dev, void *p)
 
 	memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
 
-	if (net_debug)
-		printk("%s: Setting MAC address to %pM\n",
-		       dev->name, dev->dev_addr);
+	cs89_dbg(0, debug, "%s: Setting MAC address to %pM\n",
+		 dev->name, dev->dev_addr);
 
 	/* set the Ethernet address */
 	for (i = 0; i < ETH_ALEN / 2; i++)
-- 
1.7.8.111.gad25c.dirty

^ permalink raw reply related


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