sync with OpenBSD -current
This commit is contained in:
parent
72a51d0b15
commit
f437ff84be
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: login.conf,v 1.19 2023/12/11 19:52:40 kettenis Exp $
|
||||
# $OpenBSD: login.conf,v 1.20 2023/12/31 16:05:50 bluhm Exp $
|
||||
|
||||
#
|
||||
# Sample login.conf file. See login.conf(5) for details.
|
||||
@ -41,8 +41,8 @@ auth-ftp-defaults:auth-ftp=passwd:
|
||||
default:\
|
||||
:path=/usr/bin /bin /usr/sbin /sbin /usr/X11R6/bin /usr/local/bin /usr/local/sbin:\
|
||||
:umask=022:\
|
||||
:datasize-max=768M:\
|
||||
:datasize-cur=768M:\
|
||||
:datasize-max=1536M:\
|
||||
:datasize-cur=1536M:\
|
||||
:maxproc-max=256:\
|
||||
:maxproc-cur=128:\
|
||||
:openfiles-max=1024:\
|
||||
@ -70,7 +70,7 @@ daemon:\
|
||||
# Staff have fewer restrictions and can login even when nologins are set.
|
||||
#
|
||||
staff:\
|
||||
:datasize-cur=768M:\
|
||||
:datasize-cur=1536M:\
|
||||
:datasize-max=infinity:\
|
||||
:maxproc-max=512:\
|
||||
:maxproc-cur=128:\
|
||||
|
@ -1 +1 @@
|
||||
# SecBSD 1.4-babd3ac: Tue Dec 19 00:03:02 UTC 2023 (Mictlantecuhtli)
|
||||
# SecBSD 1.4-4dba83b: Sun Dec 31 05:08:46 UTC 2023 (Mictlantecuhtli)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: e_chacha20poly1305.c,v 1.33 2023/12/15 13:48:59 tb Exp $ */
|
||||
/* $OpenBSD: e_chacha20poly1305.c,v 1.34 2023/12/30 18:24:09 tb Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2022 Joel Sing <jsing@openbsd.org>
|
||||
@ -345,7 +345,7 @@ static const EVP_AEAD aead_chacha20_poly1305 = {
|
||||
};
|
||||
|
||||
const EVP_AEAD *
|
||||
EVP_aead_chacha20_poly1305()
|
||||
EVP_aead_chacha20_poly1305(void)
|
||||
{
|
||||
return &aead_chacha20_poly1305;
|
||||
}
|
||||
@ -363,7 +363,7 @@ static const EVP_AEAD aead_xchacha20_poly1305 = {
|
||||
};
|
||||
|
||||
const EVP_AEAD *
|
||||
EVP_aead_xchacha20_poly1305()
|
||||
EVP_aead_xchacha20_poly1305(void)
|
||||
{
|
||||
return &aead_xchacha20_poly1305;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: x509_issuer_cache.c,v 1.4 2022/12/26 07:18:53 jmc Exp $ */
|
||||
/* $OpenBSD: x509_issuer_cache.c,v 1.7 2023/12/30 18:26:13 tb Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2020 Bob Beck <beck@openbsd.org>
|
||||
*
|
||||
@ -78,8 +78,8 @@ x509_issuer_cache_set_max(size_t max)
|
||||
* if an entry was successfully freed, 0 otherwise. Must
|
||||
* be called with x509_issuer_tree_mutex held.
|
||||
*/
|
||||
void
|
||||
x509_issuer_cache_free_oldest()
|
||||
static void
|
||||
x509_issuer_cache_free_oldest(void)
|
||||
{
|
||||
struct x509_issuer *old;
|
||||
|
||||
@ -98,7 +98,7 @@ x509_issuer_cache_free_oldest()
|
||||
* Free the entire issuer cache, discarding all entries.
|
||||
*/
|
||||
void
|
||||
x509_issuer_cache_free()
|
||||
x509_issuer_cache_free(void)
|
||||
{
|
||||
if (pthread_mutex_lock(&x509_issuer_tree_mutex) != 0)
|
||||
return;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: x509_issuer_cache.h,v 1.2 2022/09/03 17:47:47 jsing Exp $ */
|
||||
/* $OpenBSD: x509_issuer_cache.h,v 1.3 2023/12/30 18:06:59 tb Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2020 Bob Beck <beck@openbsd.org>
|
||||
*
|
||||
@ -41,7 +41,7 @@ int x509_issuer_cache_set_max(size_t max);
|
||||
int x509_issuer_cache_find(unsigned char *parent_md, unsigned char *child_md);
|
||||
void x509_issuer_cache_add(unsigned char *parent_md, unsigned char *child_md,
|
||||
int valid);
|
||||
void x509_issuer_cache_free();
|
||||
void x509_issuer_cache_free(void);
|
||||
|
||||
__END_HIDDEN_DECLS
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: x509_purp.c,v 1.30 2023/11/13 10:33:00 tb Exp $ */
|
||||
/* $OpenBSD: x509_purp.c,v 1.33 2023/12/31 07:19:13 tb Exp $ */
|
||||
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
|
||||
* project 2001.
|
||||
*/
|
||||
@ -386,68 +386,33 @@ X509_PURPOSE_get_trust(const X509_PURPOSE *xp)
|
||||
}
|
||||
LCRYPTO_ALIAS(X509_PURPOSE_get_trust);
|
||||
|
||||
static int
|
||||
nid_cmp(const int *a, const int *b)
|
||||
{
|
||||
return *a - *b;
|
||||
}
|
||||
|
||||
static int nid_cmp_BSEARCH_CMP_FN(const void *, const void *);
|
||||
static int nid_cmp(int const *, int const *);
|
||||
static int *OBJ_bsearch_nid(int *key, int const *base, int num);
|
||||
|
||||
static int
|
||||
nid_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)
|
||||
{
|
||||
int const *a = a_;
|
||||
int const *b = b_;
|
||||
return nid_cmp(a, b);
|
||||
}
|
||||
|
||||
static int *
|
||||
OBJ_bsearch_nid(int *key, int const *base, int num)
|
||||
{
|
||||
return (int *)OBJ_bsearch_(key, base, num, sizeof(int),
|
||||
nid_cmp_BSEARCH_CMP_FN);
|
||||
}
|
||||
|
||||
/*
|
||||
* List of NIDs of extensions supported by the verifier. If an extension
|
||||
* is critical and doesn't appear in this list, then the certificate will
|
||||
* normally be rejected.
|
||||
*/
|
||||
int
|
||||
X509_supported_extension(X509_EXTENSION *ex)
|
||||
X509_supported_extension(X509_EXTENSION *ext)
|
||||
{
|
||||
/* This table is a list of the NIDs of supported extensions:
|
||||
* that is those which are used by the verify process. If
|
||||
* an extension is critical and doesn't appear in this list
|
||||
* then the verify process will normally reject the certificate.
|
||||
* The list must be kept in numerical order because it will be
|
||||
* searched using bsearch.
|
||||
*/
|
||||
|
||||
static const int supported_nids[] = {
|
||||
NID_netscape_cert_type, /* 71 */
|
||||
NID_key_usage, /* 83 */
|
||||
NID_subject_alt_name, /* 85 */
|
||||
NID_basic_constraints, /* 87 */
|
||||
NID_certificate_policies, /* 89 */
|
||||
NID_ext_key_usage, /* 126 */
|
||||
switch (OBJ_obj2nid(X509_EXTENSION_get_object(ext))) {
|
||||
case NID_basic_constraints:
|
||||
case NID_certificate_policies:
|
||||
case NID_ext_key_usage:
|
||||
case NID_inhibit_any_policy:
|
||||
case NID_key_usage:
|
||||
case NID_name_constraints:
|
||||
case NID_netscape_cert_type:
|
||||
case NID_policy_constraints:
|
||||
case NID_policy_mappings:
|
||||
#ifndef OPENSSL_NO_RFC3779
|
||||
NID_sbgp_ipAddrBlock, /* 290 */
|
||||
NID_sbgp_autonomousSysNum, /* 291 */
|
||||
case NID_sbgp_ipAddrBlock:
|
||||
case NID_sbgp_autonomousSysNum:
|
||||
#endif
|
||||
NID_policy_constraints, /* 401 */
|
||||
NID_name_constraints, /* 666 */
|
||||
NID_policy_mappings, /* 747 */
|
||||
NID_inhibit_any_policy /* 748 */
|
||||
};
|
||||
|
||||
int ex_nid = OBJ_obj2nid(X509_EXTENSION_get_object(ex));
|
||||
|
||||
if (ex_nid == NID_undef)
|
||||
return 0;
|
||||
|
||||
if (OBJ_bsearch_nid(&ex_nid, supported_nids,
|
||||
sizeof(supported_nids) / sizeof(int)))
|
||||
case NID_subject_alt_name:
|
||||
return 1;
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
LCRYPTO_ALIAS(X509_supported_extension);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ssl_rsa.c,v 1.50 2023/07/08 16:40:13 beck Exp $ */
|
||||
/* $OpenBSD: ssl_rsa.c,v 1.51 2023/12/30 06:25:56 tb Exp $ */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -150,24 +150,28 @@ LSSL_ALIAS(SSL_use_certificate_ASN1);
|
||||
int
|
||||
SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa)
|
||||
{
|
||||
EVP_PKEY *pkey;
|
||||
int ret;
|
||||
EVP_PKEY *pkey = NULL;
|
||||
int ret = 0;
|
||||
|
||||
if (rsa == NULL) {
|
||||
SSLerror(ssl, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return (0);
|
||||
goto err;
|
||||
}
|
||||
if ((pkey = EVP_PKEY_new()) == NULL) {
|
||||
SSLerror(ssl, ERR_R_EVP_LIB);
|
||||
return (0);
|
||||
goto err;
|
||||
}
|
||||
if (!EVP_PKEY_set1_RSA(pkey, rsa))
|
||||
goto err;
|
||||
if (!ssl_set_pkey(NULL, ssl, pkey))
|
||||
goto err;
|
||||
|
||||
RSA_up_ref(rsa);
|
||||
EVP_PKEY_assign_RSA(pkey, rsa);
|
||||
ret = 1;
|
||||
|
||||
ret = ssl_set_pkey(NULL, ssl, pkey);
|
||||
err:
|
||||
EVP_PKEY_free(pkey);
|
||||
return (ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
LSSL_ALIAS(SSL_use_RSAPrivateKey);
|
||||
|
||||
@ -508,24 +512,28 @@ LSSL_ALIAS(SSL_CTX_use_certificate_ASN1);
|
||||
int
|
||||
SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa)
|
||||
{
|
||||
int ret;
|
||||
EVP_PKEY *pkey;
|
||||
EVP_PKEY *pkey = NULL;
|
||||
int ret = 0;
|
||||
|
||||
if (rsa == NULL) {
|
||||
SSLerrorx(ERR_R_PASSED_NULL_PARAMETER);
|
||||
return (0);
|
||||
goto err;
|
||||
}
|
||||
if ((pkey = EVP_PKEY_new()) == NULL) {
|
||||
SSLerrorx(ERR_R_EVP_LIB);
|
||||
return (0);
|
||||
goto err;
|
||||
}
|
||||
if (!EVP_PKEY_set1_RSA(pkey, rsa))
|
||||
goto err;
|
||||
if (!ssl_set_pkey(ctx, NULL, pkey))
|
||||
goto err;
|
||||
|
||||
RSA_up_ref(rsa);
|
||||
EVP_PKEY_assign_RSA(pkey, rsa);
|
||||
ret = 1;
|
||||
|
||||
ret = ssl_set_pkey(ctx, NULL, pkey);
|
||||
err:
|
||||
EVP_PKEY_free(pkey);
|
||||
return (ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
LSSL_ALIAS(SSL_CTX_use_RSAPrivateKey);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: evp_test.c,v 1.11 2023/12/10 19:20:06 tb Exp $ */
|
||||
/* $OpenBSD: evp_test.c,v 1.13 2023/12/31 01:31:07 tb Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2022 Joel Sing <jsing@openbsd.org>
|
||||
* Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
|
||||
@ -106,6 +106,160 @@ evp_asn1_method_test(void)
|
||||
return failed;
|
||||
}
|
||||
|
||||
/* EVP_PKEY_asn1_find() by hand. Allows cross-checking and finding duplicates. */
|
||||
static const EVP_PKEY_ASN1_METHOD *
|
||||
evp_pkey_asn1_find(int nid, int skip_id)
|
||||
{
|
||||
const EVP_PKEY_ASN1_METHOD *ameth;
|
||||
int count, i, pkey_id;
|
||||
|
||||
count = EVP_PKEY_asn1_get_count();
|
||||
for (i = 0; i < count; i++) {
|
||||
if (i == skip_id)
|
||||
continue;
|
||||
if ((ameth = EVP_PKEY_asn1_get0(i)) == NULL)
|
||||
return NULL;
|
||||
if (!EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL,
|
||||
NULL, NULL, ameth))
|
||||
return NULL;
|
||||
if (pkey_id == nid)
|
||||
return ameth;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
evp_asn1_method_aliases_test(void)
|
||||
{
|
||||
const EVP_PKEY_ASN1_METHOD *ameth;
|
||||
int id, base_id, flags;
|
||||
const char *info, *pem_str;
|
||||
int count, i;
|
||||
int failed = 0;
|
||||
|
||||
if ((count = EVP_PKEY_asn1_get_count()) <= 0) {
|
||||
fprintf(stderr, "FAIL: EVP_PKEY_asn1_get_count(): %d\n", count);
|
||||
failed |= 1;
|
||||
}
|
||||
for (i = 0; i < count; i++) {
|
||||
if ((ameth = EVP_PKEY_asn1_get0(i)) == NULL) {
|
||||
fprintf(stderr, "FAIL: no ameth for index %d < %d\n",
|
||||
i, count);
|
||||
failed |= 1;
|
||||
continue;
|
||||
}
|
||||
if (!EVP_PKEY_asn1_get0_info(&id, &base_id, &flags,
|
||||
&info, &pem_str, ameth)) {
|
||||
fprintf(stderr, "FAIL: no info for ameth %d\n", i);
|
||||
failed |= 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* The following are all true or all false for any ameth:
|
||||
* 1. ASN1_PKEY_ALIAS is set 2. id != base_id
|
||||
* 3. info == NULL 4. pem_str == NULL
|
||||
*/
|
||||
|
||||
if ((flags & ASN1_PKEY_ALIAS) == 0) {
|
||||
size_t pem_str_len;
|
||||
|
||||
if (id != base_id) {
|
||||
fprintf(stderr, "FAIL: non-alias with "
|
||||
"id %d != base_id %d\n", id, base_id);
|
||||
failed |= 1;
|
||||
continue;
|
||||
}
|
||||
if (info == NULL || strlen(info) == 0) {
|
||||
fprintf(stderr, "FAIL: missing or empty info %d\n", id);
|
||||
failed |= 1;
|
||||
continue;
|
||||
}
|
||||
if (pem_str == NULL) {
|
||||
fprintf(stderr, "FAIL: missing pem_str %d\n", id);
|
||||
failed |= 1;
|
||||
continue;
|
||||
}
|
||||
if ((pem_str_len = strlen(pem_str)) == 0) {
|
||||
fprintf(stderr, "FAIL: empty pem_str %d\n", id);
|
||||
failed |= 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (evp_pkey_asn1_find(id, i) != NULL) {
|
||||
fprintf(stderr, "FAIL: duplicate ameth %d\n", id);
|
||||
failed |= 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ameth != EVP_PKEY_asn1_find(NULL, id)) {
|
||||
fprintf(stderr, "FAIL: EVP_PKEY_asn1_find(%d) "
|
||||
"returned different ameth\n", id);
|
||||
failed |= 1;
|
||||
continue;
|
||||
}
|
||||
if (ameth != EVP_PKEY_asn1_find_str(NULL, pem_str, -1)) {
|
||||
fprintf(stderr, "FAIL: EVP_PKEY_asn1_find_str(%s) "
|
||||
"returned different ameth\n", pem_str);
|
||||
failed |= 1;
|
||||
continue;
|
||||
}
|
||||
if (ameth != EVP_PKEY_asn1_find_str(NULL,
|
||||
pem_str, pem_str_len)) {
|
||||
fprintf(stderr, "FAIL: EVP_PKEY_asn1_find_str(%s, %zu) "
|
||||
"returned different ameth\n", pem_str, pem_str_len);
|
||||
failed |= 1;
|
||||
continue;
|
||||
}
|
||||
if (EVP_PKEY_asn1_find_str(NULL, pem_str,
|
||||
pem_str_len - 1) != NULL) {
|
||||
fprintf(stderr, "FAIL: EVP_PKEY_asn1_find_str(%s, %zu) "
|
||||
"returned an ameth\n", pem_str, pem_str_len - 1);
|
||||
failed |= 1;
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (id == base_id) {
|
||||
fprintf(stderr, "FAIL: alias with id %d == base_id %d\n",
|
||||
id, base_id);
|
||||
failed |= 1;
|
||||
}
|
||||
if (info != NULL) {
|
||||
fprintf(stderr, "FAIL: alias %d with info %s\n", id, info);
|
||||
failed |= 1;
|
||||
}
|
||||
if (pem_str != NULL) {
|
||||
fprintf(stderr, "FAIL: alias %d with pem_str %s\n",
|
||||
id, pem_str);
|
||||
failed |= 1;
|
||||
}
|
||||
|
||||
/* Check that ameth resolves to a non-alias. */
|
||||
if ((ameth = evp_pkey_asn1_find(base_id, -1)) == NULL) {
|
||||
fprintf(stderr, "FAIL: no ameth with pkey_id %d\n",
|
||||
base_id);
|
||||
failed |= 1;
|
||||
continue;
|
||||
}
|
||||
if (!EVP_PKEY_asn1_get0_info(NULL, NULL, &flags, NULL, NULL, ameth)) {
|
||||
fprintf(stderr, "FAIL: no info for ameth with pkey_id %d\n",
|
||||
base_id);
|
||||
failed |= 1;
|
||||
continue;
|
||||
}
|
||||
if ((flags & ASN1_PKEY_ALIAS) != 0) {
|
||||
fprintf(stderr, "FAIL: ameth with pkey_id %d "
|
||||
"resolves to another alias\n", base_id);
|
||||
failed |= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return failed;
|
||||
}
|
||||
|
||||
static int
|
||||
evp_pkey_method_test(void)
|
||||
{
|
||||
@ -634,6 +788,7 @@ main(int argc, char **argv)
|
||||
int failed = 0;
|
||||
|
||||
failed |= evp_asn1_method_test();
|
||||
failed |= evp_asn1_method_aliases_test();
|
||||
failed |= evp_pkey_method_test();
|
||||
failed |= evp_pkey_iv_len_test();
|
||||
failed |= evp_do_all_test();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: rtkit.c,v 1.13 2023/11/25 18:12:20 kettenis Exp $ */
|
||||
/* $OpenBSD: rtkit.c,v 1.14 2023/12/30 13:13:11 kettenis Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
|
||||
*
|
||||
@ -23,6 +23,8 @@
|
||||
#include <machine/bus.h>
|
||||
#include <machine/fdt.h>
|
||||
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
#include <dev/ofw/openfirm.h>
|
||||
#include <dev/ofw/ofw_misc.h>
|
||||
#include <dev/ofw/fdt.h>
|
||||
@ -71,7 +73,10 @@
|
||||
#define RTKIT_BUFFER_SIZE_SHIFT 44
|
||||
|
||||
#define RTKIT_SYSLOG_LOG 5
|
||||
#define RTKIT_SYSLOG_LOG_IDX(x) (((x) >> 0) & 0xff)
|
||||
#define RTKIT_SYSLOG_INIT 8
|
||||
#define RTKIT_SYSLOG_INIT_N_ENTRIES(x) (((x) >> 0) & 0xff)
|
||||
#define RTKIT_SYSLOG_INIT_MSG_SIZE(x) (((x) >> 24) & 0xff)
|
||||
|
||||
#define RTKIT_IOREPORT_UNKNOWN1 8
|
||||
#define RTKIT_IOREPORT_UNKNOWN2 12
|
||||
@ -94,11 +99,20 @@ struct rtkit_dmamem {
|
||||
bus_dmamap_t rdm_map;
|
||||
bus_dma_segment_t rdm_seg;
|
||||
size_t rdm_size;
|
||||
caddr_t rdm_kva;
|
||||
};
|
||||
|
||||
struct rtkit_state {
|
||||
struct mbox_channel *mc;
|
||||
struct rtkit *rk;
|
||||
int flags;
|
||||
char *crashlog;
|
||||
char *ioreport;
|
||||
char *oslog;
|
||||
char *syslog;
|
||||
uint8_t syslog_n_entries;
|
||||
uint8_t syslog_msg_size;
|
||||
char *syslog_msg;
|
||||
uint16_t iop_pwrstate;
|
||||
uint16_t ap_pwrstate;
|
||||
uint64_t epmap;
|
||||
@ -126,22 +140,30 @@ rtkit_send(struct mbox_channel *mc, uint32_t endpoint,
|
||||
}
|
||||
|
||||
bus_addr_t
|
||||
rtkit_alloc(struct rtkit_state *state, bus_size_t size)
|
||||
rtkit_alloc(struct rtkit_state *state, bus_size_t size, caddr_t *kvap)
|
||||
{
|
||||
struct rtkit *rk = state->rk;
|
||||
bus_dma_segment_t seg;
|
||||
bus_dmamap_t map;
|
||||
caddr_t kva;
|
||||
int nsegs;
|
||||
|
||||
if (state->ndmamem >= nitems(state->dmamem))
|
||||
return ENOMEM;
|
||||
return (bus_addr_t)-1;
|
||||
|
||||
if (bus_dmamem_alloc(rk->rk_dmat, size, 16384, 0,
|
||||
&seg, 1, &nsegs, BUS_DMA_WAITOK | BUS_DMA_ZERO))
|
||||
return (bus_addr_t)-1;
|
||||
|
||||
if (bus_dmamem_map(rk->rk_dmat, &seg, 1, size,
|
||||
&kva, BUS_DMA_WAITOK | BUS_DMA_COHERENT)) {
|
||||
bus_dmamem_free(rk->rk_dmat, &seg, 1);
|
||||
return (bus_addr_t)-1;
|
||||
}
|
||||
|
||||
if (bus_dmamap_create(rk->rk_dmat, size, 1, size, 0,
|
||||
BUS_DMA_WAITOK, &map)) {
|
||||
bus_dmamem_unmap(rk->rk_dmat, kva, size);
|
||||
bus_dmamem_free(rk->rk_dmat, &seg, 1);
|
||||
return (bus_addr_t)-1;
|
||||
}
|
||||
@ -149,6 +171,7 @@ rtkit_alloc(struct rtkit_state *state, bus_size_t size)
|
||||
if (bus_dmamap_load_raw(rk->rk_dmat, map, &seg, 1, size,
|
||||
BUS_DMA_WAITOK)) {
|
||||
bus_dmamap_destroy(rk->rk_dmat, map);
|
||||
bus_dmamem_unmap(rk->rk_dmat, kva, size);
|
||||
bus_dmamem_free(rk->rk_dmat, &seg, 1);
|
||||
return (bus_addr_t)-1;
|
||||
}
|
||||
@ -157,6 +180,7 @@ rtkit_alloc(struct rtkit_state *state, bus_size_t size)
|
||||
if (rk->rk_map(rk->rk_cookie, seg.ds_addr, seg.ds_len)) {
|
||||
bus_dmamap_unload(rk->rk_dmat, map);
|
||||
bus_dmamap_destroy(rk->rk_dmat, map);
|
||||
bus_dmamem_unmap(rk->rk_dmat, kva, size);
|
||||
bus_dmamem_free(rk->rk_dmat, &seg, 1);
|
||||
return (bus_addr_t)-1;
|
||||
}
|
||||
@ -165,9 +189,11 @@ rtkit_alloc(struct rtkit_state *state, bus_size_t size)
|
||||
state->dmamem[state->ndmamem].rdm_map = map;
|
||||
state->dmamem[state->ndmamem].rdm_seg = seg;
|
||||
state->dmamem[state->ndmamem].rdm_size = size;
|
||||
state->dmamem[state->ndmamem].rdm_kva = kva;
|
||||
state->ndmamem++;
|
||||
|
||||
return seg.ds_addr;
|
||||
*kvap = kva;
|
||||
return map->dm_segs[0].ds_addr;
|
||||
}
|
||||
|
||||
int
|
||||
@ -264,6 +290,156 @@ rtkit_handle_mgmt(struct rtkit_state *state, struct aplmbox_msg *msg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct rtkit_crashlog_header {
|
||||
uint32_t fourcc;
|
||||
uint32_t version;
|
||||
uint32_t size;
|
||||
uint32_t flags;
|
||||
uint8_t unknown[16];
|
||||
};
|
||||
|
||||
struct rtkit_crashlog_mbx {
|
||||
uint64_t msg1;
|
||||
uint64_t msg0;
|
||||
uint32_t timestamp;
|
||||
uint8_t unknown[4];
|
||||
};
|
||||
|
||||
struct rtkit_crashlog_rg8 {
|
||||
uint64_t unknown0;
|
||||
uint64_t reg[31];
|
||||
uint64_t sp;
|
||||
uint64_t pc;
|
||||
uint64_t psr;
|
||||
uint64_t cpacr;
|
||||
uint64_t fpsr;
|
||||
uint64_t fpcr;
|
||||
uint64_t fpreg[64];
|
||||
uint64_t far;
|
||||
uint64_t unknown1;
|
||||
uint64_t esr;
|
||||
uint64_t unknown2;
|
||||
};
|
||||
|
||||
#define RTKIT_FOURCC(s) ((s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3])
|
||||
|
||||
void
|
||||
rtkit_crashlog_dump_str(char *buf, size_t size)
|
||||
{
|
||||
char *end = buf + size - 1;
|
||||
char *newl;
|
||||
uint32_t idx;
|
||||
|
||||
if (size < 5)
|
||||
return;
|
||||
|
||||
idx = lemtoh32((uint32_t *)buf);
|
||||
buf += sizeof(uint32_t);
|
||||
|
||||
*end = 0;
|
||||
while (buf < end) {
|
||||
if (*buf == 0)
|
||||
return;
|
||||
newl = memchr(buf, '\n', buf - end);
|
||||
if (newl)
|
||||
*newl = 0;
|
||||
printf("RTKit Cstr %x: %s\n", idx, buf);
|
||||
if (!newl)
|
||||
return;
|
||||
buf = newl + 1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rtkit_crashlog_dump_ver(char *buf, size_t size)
|
||||
{
|
||||
char *end = buf + size - 1;
|
||||
|
||||
if (size < 17)
|
||||
return;
|
||||
|
||||
buf += 16;
|
||||
|
||||
*end = 0;
|
||||
printf("RTKit Cver %s\n", buf);
|
||||
}
|
||||
|
||||
void
|
||||
rtkit_crashlog_dump_mbx(char *buf, size_t size)
|
||||
{
|
||||
struct rtkit_crashlog_mbx mbx;
|
||||
char *end = buf + size;
|
||||
|
||||
buf += 28;
|
||||
size -= 28;
|
||||
|
||||
while (buf + sizeof(mbx) <= end) {
|
||||
memcpy(&mbx, buf, sizeof(mbx));
|
||||
printf("RTKit Cmbx: 0x%016llx 0x%016llx @0x%08x\n",
|
||||
mbx.msg0, mbx.msg1, mbx.timestamp);
|
||||
buf += sizeof(mbx);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rtkit_crashlog_dump_rg8(char *buf, size_t size)
|
||||
{
|
||||
struct rtkit_crashlog_rg8 rg8;
|
||||
int i;
|
||||
|
||||
if (size < sizeof(rg8))
|
||||
return;
|
||||
|
||||
memcpy(&rg8, buf, sizeof(rg8));
|
||||
printf("RTKit Crg8: psr %016llx\n", rg8.psr);
|
||||
printf("RTKit Crg8: pc %016llx\n", rg8.pc);
|
||||
printf("RTKit Crg8: esr %016llx\n", rg8.esr);
|
||||
printf("RTKit Crg8: far %016llx\n", rg8.far);
|
||||
printf("RTKit Crg8: sp %016llx\n", rg8.sp);
|
||||
for (i = 0; i < nitems(rg8.reg); i++)
|
||||
printf("RTKit Crg8: reg[%d] %016llx\n", i, rg8.reg[i]);
|
||||
}
|
||||
|
||||
void
|
||||
rtkit_crashlog_dump(char *buf, size_t size)
|
||||
{
|
||||
struct rtkit_crashlog_header hdr;
|
||||
size_t off;
|
||||
|
||||
if (size < sizeof(hdr))
|
||||
return;
|
||||
|
||||
memcpy(&hdr, buf, sizeof(hdr));
|
||||
if (letoh32(hdr.fourcc) != RTKIT_FOURCC("CLHE")) {
|
||||
printf("RTKit: Invalid header\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (letoh32(hdr.size) > size) {
|
||||
printf("RTKit: Invalid header size\n");
|
||||
return;
|
||||
}
|
||||
|
||||
off = sizeof(hdr);
|
||||
while (off < letoh32(hdr.size)) {
|
||||
uint32_t fourcc, size;
|
||||
|
||||
fourcc = lemtoh32((uint32_t *)(buf + off));
|
||||
size = lemtoh32((uint32_t *)(buf + off + 12));
|
||||
if (fourcc == RTKIT_FOURCC("CLHE"))
|
||||
break;
|
||||
if (fourcc == RTKIT_FOURCC("Cstr"))
|
||||
rtkit_crashlog_dump_str(buf + off + 16, size - 16);
|
||||
if (fourcc == RTKIT_FOURCC("Cver"))
|
||||
rtkit_crashlog_dump_ver(buf + off + 16, size - 16);
|
||||
if (fourcc == RTKIT_FOURCC("Cmbx"))
|
||||
rtkit_crashlog_dump_mbx(buf + off + 16, size - 16);
|
||||
if (fourcc == RTKIT_FOURCC("Crg8"))
|
||||
rtkit_crashlog_dump_rg8(buf + off + 16, size - 16);
|
||||
off += size;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
rtkit_handle_crashlog(struct rtkit_state *state, struct aplmbox_msg *msg)
|
||||
{
|
||||
@ -277,11 +453,46 @@ rtkit_handle_crashlog(struct rtkit_state *state, struct aplmbox_msg *msg)
|
||||
case RTKIT_BUFFER_REQUEST:
|
||||
addr = RTKIT_BUFFER_ADDR(msg->data0);
|
||||
size = RTKIT_BUFFER_SIZE(msg->data0);
|
||||
if (addr)
|
||||
|
||||
if (state->crashlog) {
|
||||
char *buf;
|
||||
|
||||
printf("\nRTKit crashed:\n");
|
||||
|
||||
buf = malloc(size * PAGE_SIZE, M_TEMP, M_NOWAIT);
|
||||
if (buf) {
|
||||
memcpy(buf, state->crashlog, size * PAGE_SIZE);
|
||||
rtkit_crashlog_dump(buf, size * PAGE_SIZE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (addr) {
|
||||
paddr_t pa = addr;
|
||||
vaddr_t va;
|
||||
|
||||
if (rk && rk->rk_logmap) {
|
||||
pa = rk->rk_logmap(rk->rk_cookie, addr);
|
||||
if (pa == (paddr_t)-1)
|
||||
break;
|
||||
}
|
||||
|
||||
state->crashlog = km_alloc(size * PAGE_SIZE,
|
||||
&kv_any, &kp_none, &kd_waitok);
|
||||
va = (vaddr_t)state->crashlog;
|
||||
|
||||
while (size-- > 0) {
|
||||
pmap_kenter_cache(va, pa, PROT_READ,
|
||||
PMAP_CACHE_CI);
|
||||
va += PAGE_SIZE;
|
||||
pa += PAGE_SIZE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (rk) {
|
||||
addr = rtkit_alloc(state, size << PAGE_SHIFT);
|
||||
addr = rtkit_alloc(state, size << PAGE_SHIFT,
|
||||
&state->crashlog);
|
||||
if (addr == (bus_addr_t)-1)
|
||||
return ENOMEM;
|
||||
}
|
||||
@ -300,6 +511,42 @@ rtkit_handle_crashlog(struct rtkit_state *state, struct aplmbox_msg *msg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
rtkit_handle_syslog_log(struct rtkit_state *state, struct aplmbox_msg *msg)
|
||||
{
|
||||
char context[24];
|
||||
size_t syslog_msg_size;
|
||||
char *syslog_msg;
|
||||
int idx, pos;
|
||||
|
||||
if ((state->flags & RK_SYSLOG) == 0)
|
||||
return;
|
||||
|
||||
idx = RTKIT_SYSLOG_LOG_IDX(msg->data0);
|
||||
if (idx > state->syslog_n_entries)
|
||||
return;
|
||||
|
||||
syslog_msg_size = state->syslog_msg_size + 32;
|
||||
syslog_msg = state->syslog + (idx * syslog_msg_size + 8);
|
||||
memcpy(context, syslog_msg, sizeof(context));
|
||||
context[sizeof(context) - 1] = 0;
|
||||
|
||||
syslog_msg += sizeof(context);
|
||||
memcpy(state->syslog_msg, syslog_msg, state->syslog_msg_size);
|
||||
state->syslog_msg[state->syslog_msg_size - 1] = 0;
|
||||
|
||||
pos = strlen(state->syslog_msg) - 1;
|
||||
while (pos >= 0) {
|
||||
if (state->syslog_msg[pos] != ' ' &&
|
||||
state->syslog_msg[pos] != '\n' &&
|
||||
state->syslog_msg[pos] != '\r')
|
||||
break;
|
||||
state->syslog_msg[pos--] = 0;
|
||||
}
|
||||
|
||||
printf("RTKit syslog %d: %s:%s\n", idx, context, state->syslog_msg);
|
||||
}
|
||||
|
||||
int
|
||||
rtkit_handle_syslog(struct rtkit_state *state, struct aplmbox_msg *msg)
|
||||
{
|
||||
@ -317,7 +564,8 @@ rtkit_handle_syslog(struct rtkit_state *state, struct aplmbox_msg *msg)
|
||||
break;
|
||||
|
||||
if (rk) {
|
||||
addr = rtkit_alloc(state, size << PAGE_SHIFT);
|
||||
addr = rtkit_alloc(state, size << PAGE_SHIFT,
|
||||
&state->syslog);
|
||||
if (addr == (bus_addr_t)-1)
|
||||
return ENOMEM;
|
||||
}
|
||||
@ -328,8 +576,15 @@ rtkit_handle_syslog(struct rtkit_state *state, struct aplmbox_msg *msg)
|
||||
return error;
|
||||
break;
|
||||
case RTKIT_SYSLOG_INIT:
|
||||
state->syslog_n_entries =
|
||||
RTKIT_SYSLOG_INIT_N_ENTRIES(msg->data0);
|
||||
state->syslog_msg_size =
|
||||
RTKIT_SYSLOG_INIT_MSG_SIZE(msg->data0);
|
||||
state->syslog_msg = malloc(state->syslog_msg_size,
|
||||
M_DEVBUF, M_WAITOK);
|
||||
break;
|
||||
case RTKIT_SYSLOG_LOG:
|
||||
rtkit_handle_syslog_log(state, msg);
|
||||
error = rtkit_send(mc, RTKIT_EP_SYSLOG,
|
||||
RTKIT_MGMT_TYPE(msg->data0), msg->data0);
|
||||
if (error)
|
||||
@ -361,7 +616,8 @@ rtkit_handle_ioreport(struct rtkit_state *state, struct aplmbox_msg *msg)
|
||||
break;
|
||||
|
||||
if (rk) {
|
||||
addr = rtkit_alloc(state, size << PAGE_SHIFT);
|
||||
addr = rtkit_alloc(state, size << PAGE_SHIFT,
|
||||
&state->ioreport);
|
||||
if (addr == (bus_addr_t)-1)
|
||||
return ENOMEM;
|
||||
}
|
||||
@ -405,7 +661,7 @@ rtkit_handle_oslog(struct rtkit_state *state, struct aplmbox_msg *msg)
|
||||
break;
|
||||
|
||||
if (rk) {
|
||||
addr = rtkit_alloc(state, size);
|
||||
addr = rtkit_alloc(state, size, &state->oslog);
|
||||
if (addr == (bus_addr_t)-1)
|
||||
return ENOMEM;
|
||||
}
|
||||
@ -444,6 +700,8 @@ rtkit_poll(struct rtkit_state *state)
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
if (state->flags & RK_DEBUG)
|
||||
printf("%s: 0x%016llx 0x%02x\n", __func__, msg.data0, msg.data1);
|
||||
endpoint = msg.data1;
|
||||
switch (endpoint) {
|
||||
case RTKIT_EP_MGMT:
|
||||
@ -513,6 +771,7 @@ rtkit_init(int node, const char *name, int flags, struct rtkit *rk)
|
||||
return NULL;
|
||||
}
|
||||
state->rk = rk;
|
||||
state->flags = flags;
|
||||
|
||||
state->iop_pwrstate = RTKIT_MGMT_PWR_STATE_SLEEP;
|
||||
state->ap_pwrstate = RTKIT_MGMT_PWR_STATE_QUIESCED;
|
||||
@ -540,6 +799,11 @@ rtkit_shutdown(struct rtkit_state *state)
|
||||
KASSERT(state->ap_pwrstate == RTKIT_MGMT_PWR_STATE_QUIESCED);
|
||||
state->epmap = 0;
|
||||
|
||||
state->crashlog = NULL;
|
||||
state->ioreport = NULL;
|
||||
state->oslog = NULL;
|
||||
state->syslog = NULL;
|
||||
|
||||
/* Clean up our memory allocations. */
|
||||
for (i = 0; i < state->ndmamem; i++) {
|
||||
if (rk->rk_unmap) {
|
||||
@ -549,6 +813,8 @@ rtkit_shutdown(struct rtkit_state *state)
|
||||
}
|
||||
bus_dmamap_unload(rk->rk_dmat, state->dmamem[i].rdm_map);
|
||||
bus_dmamap_destroy(rk->rk_dmat, state->dmamem[i].rdm_map);
|
||||
bus_dmamem_unmap(rk->rk_dmat, state->dmamem[i].rdm_kva,
|
||||
state->dmamem[i].rdm_size);
|
||||
bus_dmamem_free(rk->rk_dmat, &state->dmamem[i].rdm_seg, 1);
|
||||
}
|
||||
state->ndmamem = 0;
|
||||
@ -607,7 +873,7 @@ rtkit_set_iop_pwrstate(struct rtkit_state *state, uint16_t pwrstate)
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
if (state->iop_pwrstate == pwrstate)
|
||||
if (state->iop_pwrstate == (pwrstate & 0xff))
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#define RTKIT_MGMT_PWR_STATE_SLEEP 0x0001
|
||||
#define RTKIT_MGMT_PWR_STATE_QUIESCED 0x0010
|
||||
#define RTKIT_MGMT_PWR_STATE_ON 0x0020
|
||||
#define RTKIT_MGMT_PWR_STATE_INIT 0x0220
|
||||
|
||||
struct rtkit_state;
|
||||
|
||||
@ -11,9 +12,12 @@ struct rtkit {
|
||||
bus_dma_tag_t rk_dmat;
|
||||
int (*rk_map)(void *, bus_addr_t, bus_size_t);
|
||||
int (*rk_unmap)(void *, bus_addr_t, bus_size_t);
|
||||
paddr_t (*rk_logmap)(void *, bus_addr_t);
|
||||
};
|
||||
|
||||
#define RK_WAKEUP 0x00000001
|
||||
#define RK_DEBUG 0x00000002
|
||||
#define RK_SYSLOG 0x00000004
|
||||
|
||||
struct rtkit_state *rtkit_init(int, const char *, int, struct rtkit *);
|
||||
int rtkit_boot(struct rtkit_state *);
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user