sync with OpenBSD -current

This commit is contained in:
purplerain 2024-05-04 16:43:11 +00:00
parent c9341f2e4a
commit 22b3fbc138
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
14 changed files with 148 additions and 125 deletions

View file

@ -16,12 +16,18 @@ static inline bool
static_cpu_has(uint16_t f)
{
switch (f) {
case X86_FEATURE_CLFLUSH:
return curcpu()->ci_cflushsz != 0;
case X86_FEATURE_XMM4_1:
return (cpu_ecxfeature & CPUIDECX_SSE41) != 0;
#ifdef __amd64__
case X86_FEATURE_CLFLUSH:
case X86_FEATURE_PAT:
return true;
#else
case X86_FEATURE_CLFLUSH:
return curcpu()->ci_cflushsz != 0;
case X86_FEATURE_PAT:
return (curcpu()->ci_feature_flags & CPUID_PAT) != 0;
#endif
case X86_FEATURE_HYPERVISOR:
return (cpu_ecxfeature & CPUIDECX_HV) != 0;
default:
@ -32,7 +38,7 @@ static_cpu_has(uint16_t f)
static inline bool
pat_enabled(void)
{
return ((curcpu()->ci_feature_flags & CPUID_PAT) != 0);
return static_cpu_has(X86_FEATURE_PAT);
}
#define boot_cpu_has(x) static_cpu_has(x)

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_igc.c,v 1.20 2024/04/12 19:27:43 jan Exp $ */
/* $OpenBSD: if_igc.c,v 1.21 2024/05/04 13:35:26 mbuhl Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
@ -44,10 +44,14 @@
#include <net/if.h>
#include <net/if_media.h>
#include <net/route.h>
#include <net/toeplitz.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <netinet/tcp.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
#if NBPFILTER > 0
#include <net/bpf.h>
@ -796,6 +800,7 @@ igc_setup_interface(struct igc_softc *sc)
ifp->if_capabilities |= IFCAP_CSUM_IPv4;
ifp->if_capabilities |= IFCAP_CSUM_TCPv4 | IFCAP_CSUM_UDPv4;
ifp->if_capabilities |= IFCAP_CSUM_TCPv6 | IFCAP_CSUM_UDPv6;
ifp->if_capabilities |= IFCAP_TSOv4 | IFCAP_TSOv6;
/* Initialize ifmedia structures. */
ifmedia_init(&sc->media, IFM_IMASK, igc_media_change, igc_media_status);
@ -2025,13 +2030,11 @@ igc_tx_ctx_setup(struct tx_ring *txr, struct mbuf *mp, int prod,
{
struct ether_extracted ext;
struct igc_adv_tx_context_desc *txdesc;
uint32_t mss_l4len_idx = 0;
uint32_t type_tucmd_mlhl = 0;
uint32_t vlan_macip_lens = 0;
int off = 0;
ether_extract_headers(mp, &ext);
vlan_macip_lens |= (sizeof(*ext.eh) << IGC_ADVTXD_MACLEN_SHIFT);
/*
* In advanced descriptors the vlan tag must
* be placed into the context descriptor. Hence
@ -2046,6 +2049,10 @@ igc_tx_ctx_setup(struct tx_ring *txr, struct mbuf *mp, int prod,
}
#endif
ether_extract_headers(mp, &ext);
vlan_macip_lens |= (sizeof(*ext.eh) << IGC_ADVTXD_MACLEN_SHIFT);
if (ext.ip4) {
type_tucmd_mlhl |= IGC_ADVTXD_TUCMD_IPV4;
if (ISSET(mp->m_pkthdr.csum_flags, M_IPV4_CSUM_OUT)) {
@ -2075,6 +2082,30 @@ igc_tx_ctx_setup(struct tx_ring *txr, struct mbuf *mp, int prod,
}
}
if (ISSET(mp->m_pkthdr.csum_flags, M_TCP_TSO)) {
if (ext.tcp) {
uint32_t hdrlen, thlen, paylen, outlen;
thlen = ext.tcphlen;
outlen = mp->m_pkthdr.ph_mss;
mss_l4len_idx |= outlen << IGC_ADVTXD_MSS_SHIFT;
mss_l4len_idx |= thlen << IGC_ADVTXD_L4LEN_SHIFT;
hdrlen = sizeof(*ext.eh) + ext.iphlen + thlen;
paylen = mp->m_pkthdr.len - hdrlen;
CLR(*olinfo_status, IGC_ADVTXD_PAYLEN_MASK);
*olinfo_status |= paylen << IGC_ADVTXD_PAYLEN_SHIFT;
*cmd_type_len |= IGC_ADVTXD_DCMD_TSE;
off = 1;
tcpstat_add(tcps_outpkttso,
(paylen + outlen - 1) / outlen);
} else
tcpstat_inc(tcps_outbadtso);
}
if (off == 0)
return 0;
@ -2085,7 +2116,7 @@ igc_tx_ctx_setup(struct tx_ring *txr, struct mbuf *mp, int prod,
htolem32(&txdesc->vlan_macip_lens, vlan_macip_lens);
htolem32(&txdesc->type_tucmd_mlhl, type_tucmd_mlhl);
htolem32(&txdesc->seqnum_seed, 0);
htolem32(&txdesc->mss_l4len_idx, 0);
htolem32(&txdesc->mss_l4len_idx, mss_l4len_idx);
return 1;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: igc_base.h,v 1.2 2024/03/25 20:25:13 mbuhl Exp $ */
/* $OpenBSD: igc_base.h,v 1.3 2024/05/04 13:35:26 mbuhl Exp $ */
/*-
* Copyright 2021 Intel Corp
* Copyright 2021 Rubicon Communications, LLC (Netgate)
@ -66,6 +66,7 @@ struct igc_adv_tx_context_desc {
#define IGC_ADVTXD_POPTS_ISCO_FULL 0x00001800
#define IGC_ADVTXD_POPTS_IPSEC 0x00000400 /* IPSec offload request */
#define IGC_ADVTXD_PAYLEN_SHIFT 14 /* Adv desc PAYLEN shift */
#define IGC_ADVTXD_PAYLEN_MASK 0xFFFFD000 /* Adv desc PAYLEN shift */
/* Advanced Transmit Context Descriptor Config */
#define IGC_ADVTXD_MACLEN_SHIFT 9 /* Adv ctxt desc mac len shift */