From: james palmer <james@biobuf.link>
To: 9front@9front.org
Subject: [9front] [PATCH] etherbcm: support for newer BCM5717 series cards.
Date: Wed, 22 Feb 2023 21:01:01 +0000 [thread overview]
Message-ID: <B7301F23CDB495B46ECD5327D94D8CB3@tachibana-labs.org> (raw)
In-Reply-To: <5E52249F-37F9-4741-A035-8FE894A0A7BB@biobuf.link>
talk to the right phy for cards with many ports.
fix pci ids.
---
diff 9f6096b4319bbeb81b74ffd83ffa6edc22b7890e e24d29cc1a9c0a6483e0faaa1009ff194245a708
--- a/sys/src/9/pc/etherbcm.c
+++ b/sys/src/9/pc/etherbcm.c
@@ -32,6 +32,7 @@
ulong recvreti, recvprodi, sendri, sendcleani;
Block **sends, **recvs;
int active, duplex;
+ int phy;
};
enum {
@@ -218,7 +219,7 @@
BCM5705_2 = 0x1654,
BCM5717 = 0x1655,
BCM5718 = 0x1656,
- BCM5720 = 0x1658,
+ BCM5719 = 0x1657,
BCM5721 = 0x1659,
BCM5722 = 0x165a,
BCM5723 = 0x165b,
@@ -225,6 +226,7 @@
BCM5724 = 0x165c,
BCM5705M = 0x165d,
BCM5705M_2 = 0x165e,
+ BCM5720 = 0x165f,
BCM5714 = 0x1668,
BCM5780 = 0x166a,
BCM5780S = 0x166b,
@@ -290,10 +292,24 @@
}
static int
+phyno(Ctlr *ctlr)
+{
+ switch(ctlr->pdev->did) {
+ case BCM5717:
+ case BCM5718:
+ case BCM5719:
+ case BCM5720:
+ return BUSFNO(ctlr->pdev->tbdf) + 1;
+ }
+
+ return 1;
+}
+
+static int
miir(Ctlr *ctlr, int ra)
{
while(csr32(ctlr, MIComm) & (1<<29));
- csr32(ctlr, MIComm) = (ra << 16) | (1 << 21) | (1 << 27) | (1 << 29);
+ csr32(ctlr, MIComm) = (ra << 16) | (ctlr->phy << 21) | (1 << 27) | (1 << 29);
while(csr32(ctlr, MIComm) & (1<<29));
if(csr32(ctlr, MIComm) & (1<<28)) return -1;
return csr32(ctlr, MIComm) & 0xFFFF;
@@ -303,7 +319,7 @@
miiw(Ctlr *ctlr, int ra, int value)
{
while(csr32(ctlr, MIComm) & (1<<29));
- csr32(ctlr, MIComm) = (value & 0xFFFF) | (ra << 16) | (1 << 21) | (1 << 27) | (1 << 29);
+ csr32(ctlr, MIComm) = (value & 0xFFFF) | (ra << 16) | (ctlr->phy << 21) | (1 << 27) | (1 << 29);
while(csr32(ctlr, MIComm) & (1<<29));
return 0;
}
@@ -599,8 +615,22 @@
pa = PCIWADDR(ctlr->recvprod);
csr32(ctlr, ReceiveBDHostAddr + 0) = pa >> 32;
csr32(ctlr, ReceiveBDHostAddr + 4) = pa;
- csr32(ctlr, ReceiveBDFlags) = RecvProdRingLen << 16;
- csr32(ctlr, ReceiveBDNIC) = 0x6000;
+ switch(ctlr->pdev->did) {
+ case BCM5717:
+ case BCM5718:
+ case BCM5719:
+ case BCM5720:
+ /* 5717 series have a different receive bd nic addr,
+ * and a max frame length field in bits 2 to 15. */
+ csr32(ctlr, ReceiveBDFlags) = RecvProdRingLen << 16 | 1536 << 2;
+ csr32(ctlr, ReceiveBDNIC) = 0x40000;
+ break;
+
+ default:
+ csr32(ctlr, ReceiveBDFlags) = RecvProdRingLen << 16;
+ csr32(ctlr, ReceiveBDNIC) = 0x6000;
+ }
+
csr32(ctlr, ReceiveBDRepl) = 25;
csr32(ctlr, SendBDRingHostIndex) = 0;
csr32(ctlr, SendBDRingHostIndex+4) = 0;
@@ -743,7 +773,7 @@
case BCM5705_2:
case BCM5717:
case BCM5718:
- case BCM5720:
+ case BCM5719:
case BCM5721:
case BCM5722:
case BCM5723:
@@ -750,6 +780,7 @@
case BCM5724:
case BCM5705M:
case BCM5705M_2:
+ case BCM5720:
case BCM5714:
case BCM5780:
case BCM5780S:
@@ -833,6 +864,7 @@
ctlr->recvprod = xspanalloc(32 * RecvProdRingLen, 16, 0);
ctlr->recvret = xspanalloc(32 * RecvRetRingLen, 16, 0);
ctlr->sendr = xspanalloc(16 * SendRingLen, 16, 0);
+ ctlr->phy = phyno(ctlr);
if(bcmhead != nil)
bcmtail->link = ctlr;
else
next prev parent reply other threads:[~2023-02-22 21:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-22 18:03 james palmer
2023-02-22 18:54 ` cinap_lenrek
2023-02-22 19:36 ` [9front] " james palmer
2023-02-22 21:01 ` james palmer [this message]
2023-02-23 0:12 ` cinap_lenrek
2023-02-23 0:08 ` [9front] " cinap_lenrek
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=B7301F23CDB495B46ECD5327D94D8CB3@tachibana-labs.org \
--to=james@biobuf.link \
--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).