sync with OpenBSD -current

This commit is contained in:
purplerain 2024-02-13 19:37:16 +00:00
parent c151d49b7a
commit be76e7e421
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
96 changed files with 2153 additions and 617 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ehci_fdt.c,v 1.11 2024/01/26 17:11:50 kettenis Exp $ */
/* $OpenBSD: ehci_fdt.c,v 1.12 2024/02/12 21:37:25 uaa Exp $ */
/*
* Copyright (c) 2005 David Gwynne <dlg@openbsd.org>
@ -207,6 +207,7 @@ struct ehci_phy ehci_phys[] = {
{ "allwinner,sun8i-v3s-usb-phy", sun4i_phy_init },
{ "allwinner,sun20i-d1-usb-phy", sun4i_phy_init },
{ "allwinner,sun50i-h6-usb-phy", sun4i_phy_init },
{ "allwinner,sun50i-h616-usb-phy", sun4i_phy_init },
{ "allwinner,sun50i-a64-usb-phy", sun4i_phy_init },
{ "allwinner,sun9i-a80-usb-phy", sun9i_phy_init },
};
@ -286,6 +287,62 @@ ehci_init_phys(struct ehci_fdt_softc *sc)
#define SUNXI_AHB_INCR8 (1 << 10)
#define SUNXI_AHB_INCR16 (1 << 11)
void
sun50i_h616_phy2_init(struct ehci_fdt_softc *sc, int node)
{
int len, idx;
uint32_t *reg, val;
bus_size_t size;
bus_space_handle_t ioh;
/*
* to access USB2-PHY register, get address from "reg" property of
* current "allwinner,...-usb-phy" node
*/
len = OF_getproplen(node, "reg");
if (len <= 0)
goto out;
reg = malloc(len, M_TEMP, M_WAITOK);
OF_getpropintarray(node, "reg", reg, len);
idx = OF_getindex(node, "pmu2", "reg-names");
if (idx < 0 || (idx + 1) > (len / (sizeof(uint32_t) * 2))) {
printf(": no phy2 register\n");
goto free;
}
/* convert "reg-names" index to "reg" (address-size pair) index */
idx *= 2;
size = reg[idx + 1];
if (bus_space_map(sc->sc.iot, reg[idx], size, 0, &ioh)) {
printf(": can't map phy2 registers\n");
goto free;
}
clock_enable(node, "usb2_phy");
reset_deassert(node, "usb2_reset");
clock_enable(node, "pmu2_clk");
/*
* address is offset from "pmu2", not EHCI2 base address
* (normally it points EHCI2 base address + 0x810)
*/
val = bus_space_read_4(sc->sc.iot, ioh, 0x10);
val &= ~(1 << 3); /* clear SIDDQ */
bus_space_write_4(sc->sc.iot, ioh, 0x10, val);
clock_disable(node, "pmu2_clk");
/* "usb2_reset" and "usb2_phy" unchanged */
bus_space_unmap(sc->sc.iot, ioh, size);
free:
free(reg, M_TEMP, len);
out:
return;
}
void
sun4i_phy_init(struct ehci_fdt_softc *sc, uint32_t *cells)
{
@ -298,6 +355,11 @@ sun4i_phy_init(struct ehci_fdt_softc *sc, uint32_t *cells)
if (node == -1)
return;
/* Allwinner H616 needs to clear PHY2's SIDDQ flag */
if (OF_is_compatible(node, "allwinner,sun50i-h616-usb-phy") &&
cells[1] != 2)
sun50i_h616_phy2_init(sc, node);
val = bus_space_read_4(sc->sc.iot, sc->sc.ioh, SUNXI_HCI_ICR);
val |= SUNXI_AHB_INCR8 | SUNXI_AHB_INCR4;
val |= SUNXI_AHB_INCRX_ALIGN;
@ -315,11 +377,19 @@ sun4i_phy_init(struct ehci_fdt_softc *sc, uint32_t *cells)
val = bus_space_read_4(sc->sc.iot, sc->sc.ioh, 0x810);
val &= ~(1 << 1);
bus_space_write_4(sc->sc.iot, sc->sc.ioh, 0x810, val);
} else if (OF_is_compatible(node, "allwinner,sun20i-d1-usb-phy")) {
} else if (OF_is_compatible(node, "allwinner,sun8i-a83t-usb-phy") ||
OF_is_compatible(node, "allwinner,sun20i-d1-usb-phy") ||
OF_is_compatible(node, "allwinner,sun50i-h616-usb-phy")) {
val = bus_space_read_4(sc->sc.iot, sc->sc.ioh, 0x810);
val &= ~(1 << 3);
bus_space_write_4(sc->sc.iot, sc->sc.ioh, 0x810, val);
}
if (OF_is_compatible(node, "allwinner,sun8i-a83t-usb-phy") ||
OF_is_compatible(node, "allwinner,sun50i-h616-usb-phy")) {
val = bus_space_read_4(sc->sc.iot, sc->sc.ioh, 0x810);
val |= 1 << 5;
bus_space_write_4(sc->sc.iot, sc->sc.ioh, 0x810, val);
}
pinctrl_byname(node, "default");

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_bnxt.c,v 1.45 2024/01/19 03:25:13 jmatthew Exp $ */
/* $OpenBSD: if_bnxt.c,v 1.46 2024/02/13 13:58:19 bluhm Exp $ */
/*-
* Broadcom NetXtreme-C/E network driver.
*
@ -1433,13 +1433,13 @@ bnxt_start(struct ifqueue *ifq)
lflags |= TX_BD_LONG_LFLAGS_LSO;
hdrsize = sizeof(*ext.eh);
if (ext.ip4)
hdrsize += ext.ip4->ip_hl << 2;
hdrsize += ext.ip4hlen;
else if (ext.ip6)
hdrsize += sizeof(*ext.ip6);
else
tcpstat_inc(tcps_outbadtso);
hdrsize += ext.tcp->th_off << 2;
hdrsize += ext.tcphlen;
txhi->hdr_size = htole16(hdrsize / 2);
outlen = m->m_pkthdr.ph_mss;

View file

@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
/* $OpenBSD: if_em.c,v 1.371 2024/01/28 18:42:58 mglocker Exp $ */
/* $OpenBSD: if_em.c,v 1.372 2024/02/13 13:58:19 bluhm Exp $ */
/* $FreeBSD: if_em.c,v 1.46 2004/09/29 18:28:28 mlaier Exp $ */
#include <dev/pci/if_em.h>
@ -2433,7 +2433,7 @@ em_tx_ctx_setup(struct em_queue *que, struct mbuf *mp, u_int head,
vlan_macip_lens |= (sizeof(*ext.eh) << E1000_ADVTXD_MACLEN_SHIFT);
if (ext.ip4) {
iphlen = ext.ip4->ip_hl << 2;
iphlen = ext.ip4hlen;
type_tucmd_mlhl |= E1000_ADVTXD_TUCMD_IPV4;
if (ISSET(mp->m_pkthdr.csum_flags, M_IPV4_CSUM_OUT)) {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_igc.c,v 1.15 2024/01/23 08:48:12 kevlo Exp $ */
/* $OpenBSD: if_igc.c,v 1.16 2024/02/13 13:58:19 bluhm Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
@ -2028,7 +2028,7 @@ igc_tx_ctx_setup(struct tx_ring *txr, struct mbuf *mp, int prod,
ether_extract_headers(mp, &ext);
if (ext.ip4) {
iphlen = ext.ip4->ip_hl << 2;
iphlen = ext.ip4hlen;
type_tucmd_mlhl |= IGC_ADVTXD_TUCMD_IPV4;
if (ISSET(mp->m_pkthdr.csum_flags, M_IPV4_CSUM_OUT)) {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_ix.c,v 1.206 2023/11/10 15:51:20 bluhm Exp $ */
/* $OpenBSD: if_ix.c,v 1.207 2024/02/13 13:58:19 bluhm Exp $ */
/******************************************************************************
@ -2502,7 +2502,7 @@ ixgbe_tx_offload(struct mbuf *mp, uint32_t *vlan_macip_lens,
*vlan_macip_lens |= (ethlen << IXGBE_ADVTXD_MACLEN_SHIFT);
if (ext.ip4) {
iphlen = ext.ip4->ip_hl << 2;
iphlen = ext.ip4hlen;
if (ISSET(mp->m_pkthdr.csum_flags, M_IPV4_CSUM_OUT)) {
*olinfo_status |= IXGBE_TXD_POPTS_IXSM << 8;
@ -2542,7 +2542,7 @@ ixgbe_tx_offload(struct mbuf *mp, uint32_t *vlan_macip_lens,
if (ext.tcp) {
uint32_t hdrlen, thlen, paylen, outlen;
thlen = ext.tcp->th_off << 2;
thlen = ext.tcphlen;
outlen = mp->m_pkthdr.ph_mss;
*mss_l4len_idx |= outlen << IXGBE_ADVTXD_MSS_SHIFT;
@ -3277,11 +3277,11 @@ ixgbe_rxeof(struct rx_ring *rxr)
hdrlen += ETHER_VLAN_ENCAP_LEN;
#endif
if (ext.ip4)
hdrlen += ext.ip4->ip_hl << 2;
hdrlen += ext.ip4hlen;
if (ext.ip6)
hdrlen += sizeof(*ext.ip6);
if (ext.tcp) {
hdrlen += ext.tcp->th_off << 2;
hdrlen += ext.tcphlen;
tcpstat_inc(tcps_inhwlro);
tcpstat_add(tcps_inpktlro, pkts);
} else {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_vio.c,v 1.29 2023/12/20 09:51:06 jan Exp $ */
/* $OpenBSD: if_vio.c,v 1.30 2024/02/13 13:58:19 bluhm Exp $ */
/*
* Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg.
@ -765,7 +765,7 @@ again:
hdr->csum_offset = offsetof(struct udphdr, uh_sum);
if (ext.ip4)
hdr->csum_start += ext.ip4->ip_hl << 2;
hdr->csum_start += ext.ip4hlen;
#ifdef INET6
else if (ext.ip6)
hdr->csum_start += sizeof(*ext.ip6);