* [9front] [PATCH] etherbcm: support for newer BCM5717 series cards. @ 2023-02-22 18:03 james palmer 2023-02-22 18:54 ` cinap_lenrek 0 siblings, 1 reply; 6+ messages in thread From: james palmer @ 2023-02-22 18:03 UTC (permalink / raw) To: 9front talk to the right phy for cards with many ports. fix pci ids. --- diff 9f6096b4319bbeb81b74ffd83ffa6edc22b7890e b67c008fa3829c6a1cb1f0c4ee20560d48b7c1a6 --- a/sys/src/9/pc/etherbcm.c +++ b/sys/src/9/pc/etherbcm.c @@ -218,7 +218,7 @@ BCM5705_2 = 0x1654, BCM5717 = 0x1655, BCM5718 = 0x1656, - BCM5720 = 0x1658, + BCM5719 = 0x1657, BCM5721 = 0x1659, BCM5722 = 0x165a, BCM5723 = 0x165b, @@ -225,6 +225,7 @@ BCM5724 = 0x165c, BCM5705M = 0x165d, BCM5705M_2 = 0x165e, + BCM5720 = 0x165f, BCM5714 = 0x1668, BCM5780 = 0x166a, BCM5780S = 0x166b, @@ -289,11 +290,26 @@ return x; } +static uint +phyno(Ctlr *ctlr) +{ + uint pa; + switch(ctlr->pdev->did) { + case BCM5717: + case BCM5718: + case BCM5719: + case BCM5720: + pa = BUSFNO(ctlr->pdev->tbdf) + 1; + } + + return pa; +} + 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) | (phyno(ctlr) << 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) | (phyno(ctlr) << 21) | (1 << 27) | (1 << 29); while(csr32(ctlr, MIComm) & (1<<29)); return 0; } @@ -599,8 +615,21 @@ 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 +772,7 @@ case BCM5705_2: case BCM5717: case BCM5718: - case BCM5720: + case BCM5719: case BCM5721: case BCM5722: case BCM5723: @@ -750,6 +779,7 @@ case BCM5724: case BCM5705M: case BCM5705M_2: + case BCM5720: case BCM5714: case BCM5780: case BCM5780S: ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9front] [PATCH] etherbcm: support for newer BCM5717 series cards. 2023-02-22 18:03 [9front] [PATCH] etherbcm: support for newer BCM5717 series cards james palmer @ 2023-02-22 18:54 ` cinap_lenrek 2023-02-22 19:36 ` [9front] " james palmer 0 siblings, 1 reply; 6+ messages in thread From: cinap_lenrek @ 2023-02-22 18:54 UTC (permalink / raw) To: 9front phyno() is wrong as it wont set pa to 1 when the switch case doesnt match. Maybe make the phy address a argument to miir()/miiw()? -- cinap ^ permalink raw reply [flat|nested] 6+ messages in thread
* [9front] Re: [9front] [PATCH] etherbcm: support for newer BCM5717 series cards. 2023-02-22 18:54 ` cinap_lenrek @ 2023-02-22 19:36 ` james palmer 2023-02-22 21:01 ` james palmer 2023-02-23 0:08 ` [9front] " cinap_lenrek 0 siblings, 2 replies; 6+ messages in thread From: james palmer @ 2023-02-22 19:36 UTC (permalink / raw) To: 9front >phyno() is wrong as it wont set pa to 1 when the switch case doesnt match. thanks, i will fix that. >Maybe make the phy address a argument to miir()/miiw()? i don't know if there is a use for making the phy address an argument, talking to the wrong phy just doesn't work. maybe it should be stored on the ctlr struct to avoid the function call each time. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [9front] [PATCH] etherbcm: support for newer BCM5717 series cards. 2023-02-22 19:36 ` [9front] " james palmer @ 2023-02-22 21:01 ` james palmer 2023-02-23 0:12 ` cinap_lenrek 2023-02-23 0:08 ` [9front] " cinap_lenrek 1 sibling, 1 reply; 6+ messages in thread From: james palmer @ 2023-02-22 21:01 UTC (permalink / raw) To: 9front 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9front] [PATCH] etherbcm: support for newer BCM5717 series cards. 2023-02-22 21:01 ` james palmer @ 2023-02-23 0:12 ` cinap_lenrek 0 siblings, 0 replies; 6+ messages in thread From: cinap_lenrek @ 2023-02-23 0:12 UTC (permalink / raw) To: 9front applied. -- cinap ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9front] Re: [9front] [PATCH] etherbcm: support for newer BCM5717 series cards. 2023-02-22 19:36 ` [9front] " james palmer 2023-02-22 21:01 ` james palmer @ 2023-02-23 0:08 ` cinap_lenrek 1 sibling, 0 replies; 6+ messages in thread From: cinap_lenrek @ 2023-02-23 0:08 UTC (permalink / raw) To: 9front yeah, latest patch looks good to me. -- cinap ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-02-23 0:13 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-02-22 18:03 [9front] [PATCH] etherbcm: support for newer BCM5717 series cards james palmer 2023-02-22 18:54 ` cinap_lenrek 2023-02-22 19:36 ` [9front] " james palmer 2023-02-22 21:01 ` james palmer 2023-02-23 0:12 ` cinap_lenrek 2023-02-23 0:08 ` [9front] " cinap_lenrek
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).