9front - general discussion about 9front
 help / color / mirror / Atom feed
* ether8169: fix wrong mbps setting
@ 2016-06-30 18:06 qwx
  0 siblings, 0 replies; only message in thread
From: qwx @ 2016-06-30 18:06 UTC (permalink / raw)
  To: 9front

ether8169: fix wrong mbps setting

the first time rtl8169link is called (from rtl8169pnp), the link isn't up, so
setting edev->mbps based on Phystatus register is skipped. edev->mbps is then
still set at the default 100, and that ends up being what devether uses.
this is why some rtl8169 cards are misprinted as 100Mbps in kmesg.
later, after rtl8169link is called again from rtl8169interrupt, the link is up
and edev->mbps is set to the correct value (as shown by e.g. /net/ether0/stats).

so instead, set speed regardless of link status.

diff -r 0a3cf47fce65 sys/src/9/pc/ether8169.c
--- a/sys/src/9/pc/ether8169.c	Mon Jun 27 00:36:54 2016 +0200
+++ b/sys/src/9/pc/ether8169.c	Thu Jun 30 14:29:58 2016 +0300
@@ -830,15 +830,12 @@
 
 	ctlr = edev->ctlr;
 
+	r = csr8r(ctlr, Phystatus);
 	/*
 	 * Maybe the link changed - do we care very much?
 	 * Could stall transmits if no link, maybe?
 	 */
-	if(!((r = csr8r(ctlr, Phystatus)) & Linksts)){
-		edev->link = 0;
-		return;
-	}
-	edev->link = 1;
+	edev->link = (r & Linksts) != 0;
 
 	limit = 256*1024;
 	if(r & Speed10){


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-06-30 15:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-30 18:06 ether8169: fix wrong mbps setting qwx

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).