9front - general discussion about 9front
 help / color / mirror / Atom feed
From: qwx <qu7uux@gmail.com>
To: 9front@9front.org
Subject: ether8169: fix wrong mbps setting
Date: Thu, 30 Jun 2016 20:06:03 +0200	[thread overview]
Message-ID: <20160630180603.GA28996@u14> (raw)

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){


                 reply	other threads:[~2016-06-30 15:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20160630180603.GA28996@u14 \
    --to=qu7uux@gmail.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

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

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