From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm0-f42.google.com ([74.125.82.42]) by ur; Thu Jun 30 11:08:42 EDT 2016 Received: by mail-wm0-f42.google.com with SMTP id a66so123143633wme.0 for <9front@9front.org>; Thu, 30 Jun 2016 08:08:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mime-version:content-disposition; bh=7zMrVQeix4cVvsdBOZK9ARatEykXxKz9Es0uCNpzDSY=; b=mXrNEwxGVXSdJv2W3kNXvxLkR0OxCqOdmR3/FIdxDlnpLSm5+x0wHfL+e1YcQfSWMP 52gIScIvlmRBQw39GUwc+UBc6P+Dz53qp1+sI15FOQ8rk7aW6XbqGqdtQNr8dXVz6SkC m8boL6olQTzlbIAwlOitCt8u7jpS3q5Pyv7z+S/mJPCUNG5kL+qtLys8j8tra54mGNZV LpKoNmOlba+1E9GWSXp4d7gjOw5q/QoeojnZl3Y0IzZkomEwZ3gr4WbHspogZQAvK/Nt 7hZ0IPTQSh+BiqWwfzClNS8EwNa6yNeSeqrviw62qPiRXTkDhLH/0nUDQOmrfSgBhZyG YJHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=7zMrVQeix4cVvsdBOZK9ARatEykXxKz9Es0uCNpzDSY=; b=fgDyt3n3feiSGM1ppDAlLTzCSxJ1i/CPCvOVCYQEAlcar6OSOVh9zbP8OfysNxdRxd FfnR+5juBtGm0QIw5KI05bPN+Bv/X+v8QSgff9Y+hmMP6am0LogeOBBEzJUUqFOddogc 8izFsIcP9+uSxQfcTssNEjf4M1W98tjJisncuQ4+7C83rsKyyNnMkWo8qCm65xhnix4C wmDbZ64P+jJqkSIJ+ZOdDoEq8R4XX74YO4NDRX7FDys+J3D7Xy3/f17Walf0pyfkWmw2 mVmi3adNJVLmCaz7pKfDVk+Z2hGXclEy0MHza1CH9kahUxZG0PugnLyRvNdd6eJ5THPu uwjA== X-Gm-Message-State: ALyK8tIWKkp0QpN5uxGZstgjAZ1KvxJBj5iAs65x9RFbz9mW2NQTsDQ315l7jxMuALisMA== X-Received: by 10.28.181.80 with SMTP id e77mr28567714wmf.24.1467299319314; Thu, 30 Jun 2016 08:08:39 -0700 (PDT) Return-Path: Received: from u14 ([130.204.142.12]) by smtp.gmail.com with ESMTPSA id z14sm1763451wjw.6.2016.06.30.08.08.38 for <9front@9front.org> (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Jun 2016 08:08:38 -0700 (PDT) Date: Thu, 30 Jun 2016 20:06:03 +0200 From: qwx To: 9front@9front.org Subject: ether8169: fix wrong mbps setting Message-ID: <20160630180603.GA28996@u14> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: mobile webscale table 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){