sync with OpenBSD -current

This commit is contained in:
purplerain 2023-12-29 01:31:20 +00:00
parent 11b1e48835
commit 505632e9be
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
25 changed files with 37303 additions and 192 deletions

View file

@ -1,4 +1,4 @@
# $OpenBSD: GENERIC,v 1.520 2023/10/11 12:52:00 stsp Exp $
# $OpenBSD: GENERIC,v 1.521 2023/12/28 17:36:28 stsp Exp $
#
# For further information on compiling SecBSD kernels, see the config(8)
# man page.
@ -586,6 +586,7 @@ wpi* at pci? # Intel PRO/Wireless 3945ABG
iwn* at pci? # Intel WiFi Link 4965/5000/1000/6000
iwm* at pci? # Intel WiFi Link 7xxx
iwx* at pci? # Intel WiFi Link 22xxx
#qwx* at pci? # Qualcomm 802.11ax
ral* at pci? # Ralink RT2500/RT2501/RT2600
ral* at cardbus? # Ralink RT2500/RT2501/RT2600
rtw* at pci? # Realtek 8180

View file

@ -1,4 +1,4 @@
# $OpenBSD: RAMDISK_CD,v 1.203 2023/10/13 13:52:08 stsp Exp $
# $OpenBSD: RAMDISK_CD,v 1.204 2023/12/28 17:36:28 stsp Exp $
machine amd64
maxusers 4
@ -287,6 +287,7 @@ wpi* at pci? # Intel PRO/Wireless 3945ABG
iwn* at pci? # Intel Wireless WiFi Link 4965AGN
iwm* at pci? # Intel WiFi Link 7xxx
iwx* at pci? # Intel WiFi Link 22xxx
#qwx* at pci? # Qualcomm 802.11ax
ral* at pci? # Ralink RT2500/RT2501/RT2600
ral* at cardbus? # Ralink RT2500/RT2501/RT2600
rtw* at pci? # Realtek 8180

View file

@ -1,4 +1,4 @@
# $OpenBSD: GENERIC,v 1.278 2023/12/11 11:15:44 claudio Exp $
# $OpenBSD: GENERIC,v 1.279 2023/12/28 17:36:29 stsp Exp $
#
# GENERIC machine description file
#
@ -394,6 +394,7 @@ vmx* at pci? # VMware VMXNET3 virtual interface
athn* at pci? # Atheros AR9k (802.11a/g/n)
bwfm* at pci? # Broadcom FullMAC
iwx* at pci? # Intel WiFi Link 22xxx
#qwx* at pci? # Qualcomm 802.11ax
# PCI SCSI
ahci* at pci? flags 0x0000 # AHCI SATA controllers

View file

@ -1,4 +1,4 @@
# $OpenBSD: RAMDISK,v 1.211 2023/11/13 12:49:41 jsg Exp $
# $OpenBSD: RAMDISK,v 1.212 2023/12/28 17:36:29 stsp Exp $
machine arm64
maxusers 4
@ -315,6 +315,7 @@ vmx* at pci? # VMware VMXNET3 virtual interface
athn* at pci? # Atheros AR9k (802.11a/g/n)
bwfm* at pci? # Broadcom FullMAC
iwx* at pci? # Intel WiFi Link 22xxx
#qwx* at pci? # Qualcomm 802.11ax
# PCI SCSI
ahci* at pci? flags 0x0000 # AHCI SATA controllers

View file

@ -1,4 +1,4 @@
/* $OpenBSD: aplpcie.c,v 1.17 2023/09/21 20:26:17 kettenis Exp $ */
/* $OpenBSD: aplpcie.c,v 1.18 2023/12/28 13:32:56 kettenis Exp $ */
/*
* Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
*
@ -74,10 +74,13 @@
#define PCIE_PORT_RID2SID_VALID (1U << 31)
#define PCIE_PORT_RID2SID_SID_SHIFT 16
#define PCIE_PORT_RID2SID_RID_MASK 0x0000ffff
#define PCIE_PORT_MAX_RID2SID 64
#define PCIE_T6020_PORT_MSI_DOORBELL_LO 0x016c
#define PCIE_T6020_PORT_MSI_DOORBELL_HI 0x0170
#define PCIE_T6020_PORT_PERST 0x082c
#define PCIE_T6020_PORT_RID2SID(idx) (0x3000 + (idx) * 4)
#define PCIE_T6020_PORT_MAX_RID2SID 512
#define PCIE_T6020_PORT_MSI_MAP(idx) (0x3800 + (idx) * 4)
#define PCIE_T6020_PORT_MSI_MAP_ENABLE (1U << 31)
@ -472,7 +475,7 @@ aplpcie_init_port(struct aplpcie_softc *sc, int node)
/*
* Clear stream ID mappings.
*/
for (idx = 0; idx < 16; idx++)
for (idx = 0; idx < PCIE_PORT_MAX_RID2SID; idx++)
PWRITE4(sc, port, PCIE_PORT_RID2SID(idx), 0);
/* Check if the link is already up. */
@ -565,7 +568,7 @@ aplpcie_t6020_init_port(struct aplpcie_softc *sc, int node)
uint32_t *reset_gpio;
int pwren_gpiolen, reset_gpiolen;
uint32_t stat;
int msi, port, timo;
int idx, msi, port, timo;
if (OF_getprop(node, "status", status, sizeof(status)) > 0 &&
strcmp(status, "disabled") == 0)
@ -596,6 +599,12 @@ aplpcie_t6020_init_port(struct aplpcie_softc *sc, int node)
PWRITE4(sc, port, PCIE_T6020_PORT_MSI_DOORBELL_HI,
sc->sc_msi_doorbell >> 32);
/*
* Clear stream ID mappings.
*/
for (idx = 0; idx < PCIE_T6020_PORT_MAX_RID2SID; idx++)
PWRITE4(sc, port, PCIE_T6020_PORT_RID2SID(idx), 0);
/* Check if the link is already up. */
stat = PREAD4(sc, port, PCIE_PORT_LINK_STAT);
if (stat & PCIE_PORT_LINK_STAT_UP)
@ -782,13 +791,76 @@ aplpcie_find_port(struct aplpcie_softc *sc, int bus)
return -1;
}
int
aplpcie_map_rid(struct aplpcie_softc *sc, int port, uint16_t rid, uint32_t sid)
{
uint32_t reg;
int idx;
for (idx = 0; idx < PCIE_PORT_MAX_RID2SID; idx++) {
reg = PREAD4(sc, port, PCIE_PORT_RID2SID(idx));
/* If already mapped, we're done. */
if ((reg & PCIE_PORT_RID2SID_RID_MASK) == rid)
return 0;
/* Is this an empty slot? */
if (reg & PCIE_PORT_RID2SID_VALID)
continue;
/* Map using this slot. */
reg = (sid << PCIE_PORT_RID2SID_SID_SHIFT) | rid |
PCIE_PORT_RID2SID_VALID;
PWRITE4(sc, port, PCIE_PORT_RID2SID(idx), reg);
/* Read back to check the slot is implemented. */
if (PREAD4(sc, port, PCIE_PORT_RID2SID(idx)) != reg)
return ENODEV;
return 0;
}
return ENODEV;
}
int
aplpcie_t6020_map_rid(struct aplpcie_softc *sc, int port, uint16_t rid,
uint32_t sid)
{
uint32_t reg;
int idx;
for (idx = 0; idx < PCIE_T6020_PORT_MAX_RID2SID; idx++) {
reg = PREAD4(sc, port, PCIE_T6020_PORT_RID2SID(idx));
/* If already mapped, we're done. */
if ((reg & PCIE_PORT_RID2SID_RID_MASK) == rid)
return 0;
/* Is this an empty slot? */
if (reg & PCIE_PORT_RID2SID_VALID)
continue;
/* Map using this slot. */
reg = (sid << PCIE_PORT_RID2SID_SID_SHIFT) | rid |
PCIE_PORT_RID2SID_VALID;
PWRITE4(sc, port, PCIE_T6020_PORT_RID2SID(idx), reg);
/* Read back to check the slot is implemented. */
if (PREAD4(sc, port, PCIE_T6020_PORT_RID2SID(idx)) != reg)
return ENODEV;
return 0;
}
return ENODEV;
}
int
aplpcie_probe_device_hook(void *v, struct pci_attach_args *pa)
{
struct aplpcie_softc *sc = v;
uint32_t phandle, reg, sid;
uint32_t phandle, sid;
uint16_t rid;
int idx, port;
int error, port;
rid = pci_requester_id(pa->pa_pc, pa->pa_tag);
pa->pa_dmat = iommu_device_map_pci(sc->sc_node, rid, pa->pa_dmat);
@ -807,26 +879,19 @@ aplpcie_probe_device_hook(void *v, struct pci_attach_args *pa)
if (port == -1)
return EINVAL;
for (idx = 0; idx < 16; idx++) {
reg = PREAD4(sc, port, PCIE_PORT_RID2SID(idx));
/* If already mapped, we're done. */
if ((reg & PCIE_PORT_RID2SID_RID_MASK) == rid)
return 0;
/* Is this an empty slot? */
if (reg & PCIE_PORT_RID2SID_VALID)
continue;
/* Map using this slot. */
reg = (sid << PCIE_PORT_RID2SID_SID_SHIFT) | rid |
PCIE_PORT_RID2SID_VALID;
PWRITE4(sc, port, PCIE_PORT_RID2SID(idx), reg);
return 0;
if (OF_is_compatible(sc->sc_node, "apple,t6020-pcie"))
error = aplpcie_t6020_map_rid(sc, port, rid, sid);
else
error = aplpcie_map_rid(sc, port, rid, sid);
if (error) {
printf("%s: out of stream ID mapping slots\n",
sc->sc_dev.dv_xname);
}
printf("%s: out of stream ID mapping slots\n",
sc->sc_dev.dv_xname);
/*
* Not all PCI devices do DMA, so don't return an error if we
* ran out of stream ID mapping slots.
*/
return 0;
}

View file

@ -1,4 +1,4 @@
# $OpenBSD: files,v 1.727 2023/12/21 02:57:14 jsg Exp $
# $OpenBSD: files,v 1.728 2023/12/28 17:36:29 stsp Exp $
# $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@ -424,6 +424,10 @@ file dev/ic/malo.c malo
device bwi: ether, ifnet, ifmedia, firmload, wlan
file dev/ic/bwi.c bwi
# Qualcomm 802.11ax
device qwx: ether, ifnet, ifmedia, firmload, wlan
file dev/ic/qwx.c qwx
# Intel OnChip System Fabric
device iosf
file dev/ic/iosf.c iosf needs-flag

View file

@ -1,4 +1,4 @@
/* $OpenBSD: dwqe.c,v 1.15 2023/11/10 15:51:20 bluhm Exp $ */
/* $OpenBSD: dwqe.c,v 1.16 2023/12/28 14:30:28 uwe Exp $ */
/*
* Copyright (c) 2008, 2019 Mark Kettenis <kettenis@openbsd.org>
* Copyright (c) 2017, 2022 Patrick Wildt <patrick@blueri.se>
@ -338,11 +338,18 @@ dwqe_start(struct ifqueue *ifq)
#endif
}
if (sc->sc_tx_prod != idx) {
if (used > 0) {
sc->sc_tx_prod = idx;
/* Set a timeout in case the chip goes out to lunch. */
ifp->if_timer = 5;
/*
* Start the transmit process after the last in-use Tx
* descriptor's OWN bit has been updated.
*/
dwqe_write(sc, GMAC_CHAN_TX_END_ADDR(0), DWQE_DMA_DVA(sc->sc_txring) +
idx * sizeof(struct dwqe_desc));
}
}
@ -1055,9 +1062,6 @@ dwqe_encap(struct dwqe_softc *sc, struct mbuf *m, int *idx, int *used)
bus_dmamap_sync(sc->sc_dmat, DWQE_DMA_MAP(sc->sc_txring),
*idx * sizeof(*txd), sizeof(*txd), BUS_DMASYNC_PREWRITE);
dwqe_write(sc, GMAC_CHAN_TX_END_ADDR(0), DWQE_DMA_DVA(sc->sc_txring) +
frag * sizeof(*txd));
KASSERT(sc->sc_txbuf[cur].tb_m == NULL);
sc->sc_txbuf[*idx].tb_map = sc->sc_txbuf[cur].tb_map;
sc->sc_txbuf[cur].tb_map = map;

18404
sys/dev/ic/qwx.c Normal file

File diff suppressed because it is too large Load diff

13140
sys/dev/ic/qwxreg.h Normal file

File diff suppressed because it is too large Load diff

1523
sys/dev/ic/qwxvar.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* $OpenBSD: eephy.c,v 1.62 2023/12/07 09:46:58 uwe Exp $ */
/* $OpenBSD: eephy.c,v 1.63 2023/12/28 14:03:21 uwe Exp $ */
/*
* Principal Author: Parag Patel
* Copyright (c) 2001
@ -188,16 +188,28 @@ eephy_attach(struct device *parent, struct device *self, void *aux)
PHY_WRITE(sc, E1000_EADR, page);
}
/* Switch to SGMII-to-copper mode if necessary. */
if (sc->mii_model == MII_MODEL_MARVELL_E1512 &&
sc->mii_flags & MIIF_SGMII) {
/*
* GCR1 MII mode defaults to an invalid value on E1512/E1514
* and must be programmed with the desired mode of operation.
*/
if (sc->mii_model == MII_MODEL_MARVELL_E1512) {
uint32_t mode;
page = PHY_READ(sc, E1000_EADR);
PHY_WRITE(sc, E1000_EADR, 18);
reg = PHY_READ(sc, E1000_GCR1);
mode = reg & E1000_GCR1_MODE_MASK;
if (mode == E1000_GCR1_MODE_UNSET)
mode = E1000_GCR1_MODE_RGMII;
if (sc->mii_flags & MIIF_SGMII)
mode = E1000_GCR1_MODE_SGMII;
reg &= ~E1000_GCR1_MODE_MASK;
reg |= E1000_GCR1_MODE_SGMII;
reg |= E1000_GCR1_RESET;
reg |= E1000_GCR1_RESET | mode;
PHY_WRITE(sc, E1000_GCR1, reg);
PHY_WRITE(sc, E1000_EADR, page);
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: eephyreg.h,v 1.10 2023/12/07 09:46:58 uwe Exp $ */
/* $OpenBSD: eephyreg.h,v 1.11 2023/12/28 14:03:21 uwe Exp $ */
/*
* Principal Author: Parag Patel
* Copyright (c) 2001
@ -331,4 +331,9 @@
#define E1000_GCR1 0x14 /* General Control Register 1 */
#define E1000_GCR1_RESET 0x8000
#define E1000_GCR1_MODE_MASK 0x0007
#define E1000_GCR1_MODE_RGMII 0x0000
#define E1000_GCR1_MODE_SGMII 0x0001
#define E1000_GCR1_MODE_RGMII_1000X 0x0002
#define E1000_GCR1_MODE_RGMII_100FX 0x0003
#define E1000_GCR1_MODE_RGMII_TO_SGMII 0x0004
#define E1000_GCR1_MODE_UNSET 0x0007

View file

@ -1,4 +1,4 @@
# $OpenBSD: files.pci,v 1.362 2023/10/11 12:52:00 stsp Exp $
# $OpenBSD: files.pci,v 1.363 2023/12/28 17:36:29 stsp Exp $
# $NetBSD: files.pci,v 1.20 1996/09/24 17:47:15 christos Exp $
#
# Config file and device description for machine-independent PCI code.
@ -555,6 +555,10 @@ device iwx: ifnet, wlan, firmload
attach iwx at pci
file dev/pci/if_iwx.c iwx
# Qualcomm 802.11ax
attach qwx at pci with qwx_pci
file dev/pci/if_qwx_pci.c qwx_pci
# C-Media CMI8x38 Audio Chip
device cmpci {}: audio
attach cmpci at pci

3857
sys/dev/pci/if_qwx_pci.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* $OpenBSD: pf.c,v 1.1189 2023/12/01 10:28:32 sashan Exp $ */
/* $OpenBSD: pf.c,v 1.1190 2023/12/28 16:21:08 aisha Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@ -1731,11 +1731,8 @@ pf_purge_expired_src_nodes(void)
PF_ASSERT_LOCKED();
for (cur = RB_MIN(pf_src_tree, &tree_src_tracking); cur; cur = next) {
next = RB_NEXT(pf_src_tree, &tree_src_tracking, cur);
RB_FOREACH_SAFE(cur, pf_src_tree, &tree_src_tracking, next) {
if (cur->states == 0 && cur->expire <= getuptime()) {
next = RB_NEXT(pf_src_tree, &tree_src_tracking, cur);
pf_remove_src_node(cur);
}
}