summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorKevin Lo <kevlo@cvs.openbsd.org>2022-12-21 02:31:10 +0000
committerKevin Lo <kevlo@cvs.openbsd.org>2022-12-21 02:31:10 +0000
commitaa6ddb2ca4f08356dd428a5bf50d2152b64ccf69 (patch)
tree6b88748a5b9fde9973a039c4dd442f9d8ab48b47 /sys
parentd0fc18edb9b2e0e018150ef2de9afc71d5c1d70c (diff)
Update the Rx descriptor based on the vendor driver for Linux.
This fixes a panic seen by Geoff Steckel on RTL8125 with MCLGETL. Tested by Geoff Steckel and Nick Owens. ok dlg@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/if_rge.c42
-rw-r--r--sys/dev/pci/if_rgereg.h76
2 files changed, 76 insertions, 42 deletions
diff --git a/sys/dev/pci/if_rge.c b/sys/dev/pci/if_rge.c
index c16ad523167..51f316de3d5 100644
--- a/sys/dev/pci/if_rge.c
+++ b/sys/dev/pci/if_rge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_rge.c,v 1.20 2022/11/20 23:47:51 dlg Exp $ */
+/* $OpenBSD: if_rge.c,v 1.21 2022/12/21 02:31:09 kevlo Exp $ */
/*
* Copyright (c) 2019, 2020 Kevin Lo <kevlo@openbsd.org>
@@ -1104,24 +1104,16 @@ rge_newbuf(struct rge_queues *q)
/* Map the segments into RX descriptors. */
r = &q->q_rx.rge_rx_list[idx];
- if (RGE_OWN(r)) {
- printf("%s: tried to map busy RX descriptor\n",
- sc->sc_dev.dv_xname);
- m_freem(m);
- return (ENOBUFS);
- }
-
rxq->rxq_mbuf = m;
- r->rge_extsts = 0;
- r->rge_addrlo = htole32(RGE_ADDR_LO(rxmap->dm_segs[0].ds_addr));
- r->rge_addrhi = htole32(RGE_ADDR_HI(rxmap->dm_segs[0].ds_addr));
+ r->hi_qword1.rx_qword4.rge_extsts = 0;
+ r->hi_qword0.rge_addr = htole64(rxmap->dm_segs[0].ds_addr);
- r->rge_cmdsts = htole32(rxmap->dm_segs[0].ds_len);
+ r->hi_qword1.rx_qword4.rge_cmdsts = htole32(rxmap->dm_segs[0].ds_len);
if (idx == RGE_RX_LIST_CNT - 1)
- r->rge_cmdsts |= htole32(RGE_RDCMDSTS_EOR);
+ r->hi_qword1.rx_qword4.rge_cmdsts |= htole32(RGE_RDCMDSTS_EOR);
- r->rge_cmdsts |= htole32(RGE_RDCMDSTS_OWN);
+ r->hi_qword1.rx_qword4.rge_cmdsts |= htole32(RGE_RDCMDSTS_OWN);
bus_dmamap_sync(sc->sc_dmat, q->q_rx.rge_rx_list_map,
idx * sizeof(struct rge_rx_desc), sizeof(struct rge_rx_desc),
@@ -1140,11 +1132,11 @@ rge_discard_rxbuf(struct rge_queues *q, int idx)
r = &q->q_rx.rge_rx_list[idx];
- r->rge_cmdsts = htole32(RGE_JUMBO_FRAMELEN);
- r->rge_extsts = 0;
+ r->hi_qword1.rx_qword4.rge_cmdsts = htole32(RGE_JUMBO_FRAMELEN);
+ r->hi_qword1.rx_qword4.rge_extsts = 0;
if (idx == RGE_RX_LIST_CNT - 1)
- r->rge_cmdsts |= htole32(RGE_RDCMDSTS_EOR);
- r->rge_cmdsts |= htole32(RGE_RDCMDSTS_OWN);
+ r->hi_qword1.rx_qword4.rge_cmdsts |= htole32(RGE_RDCMDSTS_EOR);
+ r->hi_qword1.rx_qword4.rge_cmdsts |= htole32(RGE_RDCMDSTS_OWN);
bus_dmamap_sync(sc->sc_dmat, q->q_rx.rge_rx_list_map,
idx * sizeof(struct rge_rx_desc), sizeof(struct rge_rx_desc),
@@ -1219,8 +1211,8 @@ rge_rxeof(struct rge_queues *q)
if (RGE_OWN(cur_rx))
break;
- rxstat = letoh32(cur_rx->rge_cmdsts);
- extsts = letoh32(cur_rx->rge_extsts);
+ rxstat = letoh32(cur_rx->hi_qword1.rx_qword4.rge_cmdsts);
+ extsts = letoh32(cur_rx->hi_qword1.rx_qword4.rge_extsts);
total_len = RGE_RXBYTES(cur_rx);
rxq = &q->q_rx.rge_rxq[i];
@@ -1282,16 +1274,16 @@ rge_rxeof(struct rge_queues *q)
(total_len - ETHER_CRC_LEN);
/* Check IP header checksum. */
- if (!(rxstat & RGE_RDCMDSTS_IPCSUMERR) &&
+ if (!(extsts & RGE_RDEXTSTS_IPCSUMERR) &&
(extsts & RGE_RDEXTSTS_IPV4))
m->m_pkthdr.csum_flags |= M_IPV4_CSUM_IN_OK;
/* Check TCP/UDP checksum. */
if ((extsts & (RGE_RDEXTSTS_IPV4 | RGE_RDEXTSTS_IPV6)) &&
- (((rxstat & RGE_RDCMDSTS_TCPPKT) &&
- !(rxstat & RGE_RDCMDSTS_TCPCSUMERR)) ||
- ((rxstat & RGE_RDCMDSTS_UDPPKT) &&
- !(rxstat & RGE_RDCMDSTS_UDPCSUMERR))))
+ (((extsts & RGE_RDEXTSTS_TCPPKT) &&
+ !(extsts & RGE_RDEXTSTS_TCPCSUMERR)) ||
+ ((extsts & RGE_RDEXTSTS_UDPPKT) &&
+ !(extsts & RGE_RDEXTSTS_UDPCSUMERR))))
m->m_pkthdr.csum_flags |= M_TCP_CSUM_IN_OK |
M_UDP_CSUM_IN_OK;
diff --git a/sys/dev/pci/if_rgereg.h b/sys/dev/pci/if_rgereg.h
index 42709ebd110..6cedaf8e412 100644
--- a/sys/dev/pci/if_rgereg.h
+++ b/sys/dev/pci/if_rgereg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_rgereg.h,v 1.8 2022/11/20 23:47:51 dlg Exp $ */
+/* $OpenBSD: if_rgereg.h,v 1.9 2022/12/21 02:31:09 kevlo Exp $ */
/*
* Copyright (c) 2019, 2020 Kevin Lo <kevlo@openbsd.org>
@@ -189,9 +189,10 @@
#define RGE_NEXT_RX_DESC(x) (((x) + 1) % RGE_RX_LIST_CNT)
#define RGE_ADDR_LO(y) ((uint64_t) (y) & 0xffffffff)
#define RGE_ADDR_HI(y) ((uint64_t) (y) >> 32)
-#define RGE_OWN(x) (letoh32((x)->rge_cmdsts) & RGE_RDCMDSTS_OWN)
-#define RGE_RXBYTES(x) (letoh32((x)->rge_cmdsts) & \
- RGE_RDCMDSTS_FRAGLEN)
+#define RGE_OWN(x) \
+ (letoh32((x)->hi_qword1.rx_qword4.rge_cmdsts) & RGE_RDCMDSTS_OWN)
+#define RGE_RXBYTES(x) \
+ (letoh32((x)->hi_qword1.rx_qword4.rge_cmdsts) & RGE_RDCMDSTS_FRAGLEN)
#define RGE_ADV_2500TFDX 0x0080
@@ -219,26 +220,67 @@ struct rge_tx_desc {
/* Rx descriptor */
struct rge_rx_desc {
- uint32_t rge_cmdsts;
- uint32_t rge_extsts;
- uint32_t rge_addrlo;
- uint32_t rge_addrhi;
+ union {
+ struct {
+ uint32_t rsvd0;
+ uint32_t rsvd1;
+ } rx_qword0;
+ } lo_qword0;
+
+ union {
+ struct {
+ uint32_t rss;
+ uint16_t length;
+ uint16_t hdr_info;
+ } rx_qword1;
+
+ struct {
+ uint32_t rsvd2;
+ uint32_t rsvd3;
+ } rx_qword2;
+ } lo_qword1;
+
+ union {
+ uint64_t rge_addr;
+
+ struct {
+ uint64_t timestamp;
+ } rx_timestamp;
+
+ struct {
+ uint32_t rsvd4;
+ uint32_t rsvd5;
+ } rx_qword3;
+ } hi_qword0;
+
+ union {
+ struct {
+ uint32_t rge_extsts;
+ uint32_t rge_cmdsts;
+ } rx_qword4;
+
+ struct {
+ uint16_t rsvd6;
+ uint16_t rsvd7;
+ uint32_t rsvd8;
+ } rx_ptp;
+ } hi_qword1;
};
-#define RGE_RDCMDSTS_TCPCSUMERR 0x00004000
-#define RGE_RDCMDSTS_UDPCSUMERR 0x00008000
-#define RGE_RDCMDSTS_IPCSUMERR 0x00010000
-#define RGE_RDCMDSTS_TCPPKT 0x00020000
-#define RGE_RDCMDSTS_UDPPKT 0x00040000
-#define RGE_RDCMDSTS_RXERRSUM 0x00200000
-#define RGE_RDCMDSTS_EOF 0x10000000
-#define RGE_RDCMDSTS_SOF 0x20000000
+#define RGE_RDCMDSTS_RXERRSUM 0x00100000
+#define RGE_RDCMDSTS_EOF 0x01000000
+#define RGE_RDCMDSTS_SOF 0x02000000
#define RGE_RDCMDSTS_EOR 0x40000000
#define RGE_RDCMDSTS_OWN 0x80000000
#define RGE_RDCMDSTS_FRAGLEN 0x00003fff
#define RGE_RDEXTSTS_VTAG 0x00010000
#define RGE_RDEXTSTS_VLAN_MASK 0x0000ffff
+#define RGE_RDEXTSTS_TCPCSUMERR 0x01000000
+#define RGE_RDEXTSTS_UDPCSUMERR 0x02000000
+#define RGE_RDEXTSTS_IPCSUMERR 0x04000000
+#define RGE_RDEXTSTS_TCPPKT 0x10000000
+#define RGE_RDEXTSTS_UDPPKT 0x20000000
#define RGE_RDEXTSTS_IPV4 0x40000000
#define RGE_RDEXTSTS_IPV6 0x80000000
@@ -332,7 +374,7 @@ enum rge_mac_type {
ETHER_VLAN_ENCAP_LEN)
#define RGE_TXCFG_CONFIG 0x03000700
-#define RGE_RXCFG_CONFIG 0x40c00700
+#define RGE_RXCFG_CONFIG 0x41c00700
struct kstat;