sync with OpenBSD -current

This commit is contained in:
purplerain 2023-12-31 21:02:40 +00:00
parent 72a51d0b15
commit f437ff84be
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
15 changed files with 633 additions and 114 deletions

View file

@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
/* $OpenBSD: if_em.c,v 1.368 2023/12/03 00:19:25 jsg Exp $ */
/* $OpenBSD: if_em.c,v 1.370 2023/12/31 08:42:33 mglocker Exp $ */
/* $FreeBSD: if_em.c,v 1.46 2004/09/29 18:28:28 mlaier Exp $ */
#include <dev/pci/if_em.h>
@ -285,11 +285,14 @@ int em_allocate_transmit_structures(struct em_softc *);
int em_allocate_desc_rings(struct em_softc *);
int em_rxfill(struct em_queue *);
void em_rxrefill(void *);
void em_rxrefill_locked(struct em_queue *);
int em_rxeof(struct em_queue *);
void em_receive_checksum(struct em_softc *, struct em_rx_desc *,
struct mbuf *);
u_int em_transmit_checksum_setup(struct em_queue *, struct mbuf *, u_int,
u_int32_t *, u_int32_t *);
u_int em_tso_setup(struct em_queue *, struct mbuf *, u_int, u_int32_t *,
u_int32_t *);
u_int em_tx_ctx_setup(struct em_queue *, struct mbuf *, u_int, u_int32_t *,
u_int32_t *);
void em_iff(struct em_softc *);
@ -1022,7 +1025,7 @@ em_intr(void *arg)
if (ifp->if_flags & IFF_RUNNING) {
em_txeof(que);
if (em_rxeof(que))
em_rxrefill(que);
em_rxrefill_locked(que);
}
/* Link status change */
@ -1187,7 +1190,7 @@ em_flowstatus(struct em_softc *sc)
*
* This routine maps the mbufs to tx descriptors.
*
* return 0 on success, positive on failure
* return 0 on failure, positive on success
**********************************************************************/
u_int
em_encap(struct em_queue *que, struct mbuf *m)
@ -1235,7 +1238,15 @@ em_encap(struct em_queue *que, struct mbuf *m)
}
if (sc->hw.mac_type >= em_82575 && sc->hw.mac_type <= em_i210) {
used += em_tx_ctx_setup(que, m, head, &txd_upper, &txd_lower);
if (ISSET(m->m_pkthdr.csum_flags, M_TCP_TSO)) {
used += em_tso_setup(que, m, head, &txd_upper,
&txd_lower);
if (!used)
return (used);
} else {
used += em_tx_ctx_setup(que, m, head, &txd_upper,
&txd_lower);
}
} else if (sc->hw.mac_type >= em_82543) {
used += em_transmit_checksum_setup(que, m, head,
&txd_upper, &txd_lower);
@ -1568,6 +1579,21 @@ em_update_link_status(struct em_softc *sc)
ifp->if_link_state = link_state;
if_link_state_change(ifp);
}
/* Disable TSO for 10/100 speeds to avoid some hardware issues */
switch (sc->link_speed) {
case SPEED_10:
case SPEED_100:
if (sc->hw.mac_type >= em_82575 && sc->hw.mac_type <= em_i210) {
ifp->if_capabilities &= ~IFCAP_TSOv4;
ifp->if_capabilities &= ~IFCAP_TSOv6;
}
break;
case SPEED_1000:
if (sc->hw.mac_type >= em_82575 && sc->hw.mac_type <= em_i210)
ifp->if_capabilities |= IFCAP_TSOv4 | IFCAP_TSOv6;
break;
}
}
/*********************************************************************
@ -1987,6 +2013,7 @@ em_setup_interface(struct em_softc *sc)
if (sc->hw.mac_type >= em_82575 && sc->hw.mac_type <= em_i210) {
ifp->if_capabilities |= IFCAP_CSUM_IPv4;
ifp->if_capabilities |= IFCAP_CSUM_TCPv6 | IFCAP_CSUM_UDPv6;
ifp->if_capabilities |= IFCAP_TSOv4 | IFCAP_TSOv6;
}
/*
@ -2230,9 +2257,9 @@ em_setup_transmit_structures(struct em_softc *sc)
for (i = 0; i < sc->sc_tx_slots; i++) {
pkt = &que->tx.sc_tx_pkts_ring[i];
error = bus_dmamap_create(sc->sc_dmat, MAX_JUMBO_FRAME_SIZE,
error = bus_dmamap_create(sc->sc_dmat, EM_TSO_SIZE,
EM_MAX_SCATTER / (sc->pcix_82544 ? 2 : 1),
MAX_JUMBO_FRAME_SIZE, 0, BUS_DMA_NOWAIT, &pkt->pkt_map);
EM_TSO_SEG_SIZE, 0, BUS_DMA_NOWAIT, &pkt->pkt_map);
if (error != 0) {
printf("%s: Unable to create TX DMA map\n",
DEVNAME(sc));
@ -2404,6 +2431,81 @@ em_free_transmit_structures(struct em_softc *sc)
}
}
u_int
em_tso_setup(struct em_queue *que, struct mbuf *mp, u_int head,
u_int32_t *olinfo_status, u_int32_t *cmd_type_len)
{
struct ether_extracted ext;
struct e1000_adv_tx_context_desc *TD;
uint32_t vlan_macip_lens = 0, type_tucmd_mlhl = 0, mss_l4len_idx = 0;
uint32_t paylen = 0;
uint8_t iphlen = 0;
*olinfo_status = 0;
*cmd_type_len = 0;
TD = (struct e1000_adv_tx_context_desc *)&que->tx.sc_tx_desc_ring[head];
#if NVLAN > 0
if (ISSET(mp->m_flags, M_VLANTAG)) {
uint32_t vtag = mp->m_pkthdr.ether_vtag;
vlan_macip_lens |= vtag << E1000_ADVTXD_VLAN_SHIFT;
*cmd_type_len |= E1000_ADVTXD_DCMD_VLE;
}
#endif
ether_extract_headers(mp, &ext);
if (ext.tcp == NULL)
goto out;
vlan_macip_lens |= (sizeof(*ext.eh) << E1000_ADVTXD_MACLEN_SHIFT);
if (ext.ip4) {
iphlen = ext.ip4->ip_hl << 2;
type_tucmd_mlhl |= E1000_ADVTXD_TUCMD_IPV4;
*olinfo_status |= E1000_TXD_POPTS_IXSM << 8;
#ifdef INET6
} else if (ext.ip6) {
iphlen = sizeof(*ext.ip6);
type_tucmd_mlhl |= E1000_ADVTXD_TUCMD_IPV6;
#endif
} else {
goto out;
}
*cmd_type_len |= E1000_ADVTXD_DTYP_DATA | E1000_ADVTXD_DCMD_IFCS;
*cmd_type_len |= E1000_ADVTXD_DCMD_DEXT | E1000_ADVTXD_DCMD_TSE;
paylen = mp->m_pkthdr.len - sizeof(*ext.eh) - iphlen -
(ext.tcp->th_off << 2);
*olinfo_status |= paylen << E1000_ADVTXD_PAYLEN_SHIFT;
vlan_macip_lens |= iphlen;
type_tucmd_mlhl |= E1000_ADVTXD_DCMD_DEXT | E1000_ADVTXD_DTYP_CTXT;
type_tucmd_mlhl |= E1000_ADVTXD_TUCMD_L4T_TCP;
*olinfo_status |= E1000_TXD_POPTS_TXSM << 8;
mss_l4len_idx |= mp->m_pkthdr.ph_mss << E1000_ADVTXD_MSS_SHIFT;
mss_l4len_idx |= (ext.tcp->th_off << 2) << E1000_ADVTXD_L4LEN_SHIFT;
/* 82575 needs the queue index added */
if (que->sc->hw.mac_type == em_82575)
mss_l4len_idx |= (que->me & 0xff) << 4;
htolem32(&TD->vlan_macip_lens, vlan_macip_lens);
htolem32(&TD->type_tucmd_mlhl, type_tucmd_mlhl);
htolem32(&TD->u.seqnum_seed, 0);
htolem32(&TD->mss_l4len_idx, mss_l4len_idx);
tcpstat_add(tcps_outpkttso, (paylen + mp->m_pkthdr.ph_mss - 1) /
mp->m_pkthdr.ph_mss);
return 1;
out:
tcpstat_inc(tcps_outbadtso);
return 0;
}
u_int
em_tx_ctx_setup(struct em_queue *que, struct mbuf *mp, u_int head,
u_int32_t *olinfo_status, u_int32_t *cmd_type_len)
@ -2958,6 +3060,16 @@ void
em_rxrefill(void *arg)
{
struct em_queue *que = arg;
int s;
s = splnet();
em_rxrefill_locked(que);
splx(s);
}
void
em_rxrefill_locked(struct em_queue *que)
{
struct em_softc *sc = que->sc;
if (em_rxfill(que))
@ -3954,7 +4066,7 @@ em_queue_intr_msix(void *vque)
if (ifp->if_flags & IFF_RUNNING) {
em_txeof(que);
if (em_rxeof(que))
em_rxrefill(que);
em_rxrefill_locked(que);
}
em_enable_queue_intr_msix(que);

View file

@ -32,7 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
/* $FreeBSD: if_em.h,v 1.26 2004/09/01 23:22:41 pdeuskar Exp $ */
/* $OpenBSD: if_em.h,v 1.80 2022/01/09 05:42:50 jsg Exp $ */
/* $OpenBSD: if_em.h,v 1.81 2023/12/31 08:42:33 mglocker Exp $ */
#ifndef _EM_H_DEFINED_
#define _EM_H_DEFINED_
@ -55,11 +55,14 @@ POSSIBILITY OF SUCH DAMAGE.
#include <net/if.h>
#include <net/if_media.h>
#include <net/route.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/if_ether.h>
#include <netinet/tcp.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
#include <netinet/udp.h>
#if NBPFILTER > 0
@ -269,6 +272,7 @@ typedef int boolean_t;
#define EM_MAX_SCATTER 64
#define EM_TSO_SIZE 65535
#define EM_TSO_SEG_SIZE 4096 /* Max dma segment size */
struct em_packet {
int pkt_eop; /* Index of the desc to watch */

View file

@ -31,7 +31,7 @@
*******************************************************************************/
/* $OpenBSD: if_em_hw.h,v 1.90 2023/12/03 00:19:25 jsg Exp $ */
/* $OpenBSD: if_em_hw.h,v 1.91 2023/12/31 08:42:33 mglocker Exp $ */
/* $FreeBSD: if_em_hw.h,v 1.15 2005/05/26 23:32:02 tackerman Exp $ */
/* if_em_hw.h
@ -2150,6 +2150,7 @@ struct e1000_adv_tx_context_desc {
#define E1000_ADVTXD_DCMD_IFCS 0x02000000 /* Insert FCS (Ethernet CRC) */
#define E1000_ADVTXD_DCMD_DEXT 0x20000000 /* Descriptor extension (1=Adv) */
#define E1000_ADVTXD_DCMD_VLE 0x40000000 /* VLAN pkt enable */
#define E1000_ADVTXD_DCMD_TSE 0x80000000 /* TCP Seg enable */
#define E1000_ADVTXD_PAYLEN_SHIFT 14 /* Adv desc PAYLEN shift */
/* Adv Transmit Descriptor Config Masks */
@ -2160,6 +2161,10 @@ struct e1000_adv_tx_context_desc {
#define E1000_ADVTXD_TUCMD_L4T_UDP 0x00000000 /* L4 Packet TYPE of UDP */
#define E1000_ADVTXD_TUCMD_L4T_TCP 0x00000800 /* L4 Packet TYPE of TCP */
/* Req requires Markers and CRC */
#define E1000_ADVTXD_L4LEN_SHIFT 8 /* Adv ctxt L4LEN shift */
#define E1000_ADVTXD_MSS_SHIFT 16 /* Adv ctxt MSS shift */
/* Multiple Receive Queue Control */
#define E1000_MRQC_ENABLE_MASK 0x00000003
#define E1000_MRQC_ENABLE_RSS_2Q 0x00000001

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_iwx.c,v 1.179 2023/12/20 07:33:32 stsp Exp $ */
/* $OpenBSD: if_iwx.c,v 1.180 2023/12/30 16:55:44 stsp Exp $ */
/*
* Copyright (c) 2014, 2016 genua gmbh <info@genua.de>
@ -10696,7 +10696,7 @@ static const struct iwx_dev_info iwx_dev_info_table[] = {
_IWX_DEV_INFO(IWX_CFG_ANY, IWX_CFG_ANY,
IWX_CFG_MAC_TYPE_SO, IWX_CFG_ANY,
IWX_CFG_RF_TYPE_HR1, IWX_CFG_ANY,
IWX_CFG_160, IWX_CFG_ANY, IWX_CFG_NO_CDB, IWX_CFG_ANY,
IWX_CFG_NO_160, IWX_CFG_ANY, IWX_CFG_NO_CDB, IWX_CFG_ANY,
iwx_cfg_so_a0_hr_b0), /* ax101 */
_IWX_DEV_INFO(IWX_CFG_ANY, IWX_CFG_ANY,
IWX_CFG_MAC_TYPE_SO, IWX_CFG_ANY,
@ -10713,7 +10713,7 @@ static const struct iwx_dev_info iwx_dev_info_table[] = {
_IWX_DEV_INFO(IWX_CFG_ANY, IWX_CFG_ANY,
IWX_CFG_MAC_TYPE_SOF, IWX_CFG_ANY,
IWX_CFG_RF_TYPE_HR1, IWX_CFG_ANY,
IWX_CFG_160, IWX_CFG_ANY, IWX_CFG_NO_CDB, IWX_CFG_ANY,
IWX_CFG_NO_160, IWX_CFG_ANY, IWX_CFG_NO_CDB, IWX_CFG_ANY,
iwx_cfg_so_a0_hr_b0), /* AX101 */
_IWX_DEV_INFO(IWX_CFG_ANY, IWX_CFG_ANY,
IWX_CFG_MAC_TYPE_SOF, IWX_CFG_ANY,

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_ixl.c,v 1.93 2023/11/10 15:51:20 bluhm Exp $ */
/* $OpenBSD: if_ixl.c,v 1.94 2023/12/30 17:52:27 bluhm Exp $ */
/*
* Copyright (c) 2013-2015, Intel Corporation
@ -900,7 +900,7 @@ struct ixl_rx_wb_desc_32 {
uint64_t qword3;
} __packed __aligned(16);
#define IXL_TX_PKT_DESCS 32
#define IXL_TX_PKT_DESCS 8
#define IXL_TX_QUEUE_ALIGN 128
#define IXL_RX_QUEUE_ALIGN 128