1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-19 02:29:40 +00:00

Merge ^/head r343320 through r343570.

This commit is contained in:
Dimitry Andric 2019-01-30 07:10:33 +00:00
commit 7e565c552a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/clang800-import/; revision=343571
374 changed files with 9927 additions and 3650 deletions

View File

@ -190,6 +190,9 @@ OLD_FILES+=usr/lib/clang/7.0.1/lib/freebsd/libclang_rt.ubsan_standalone_cxx-x86_
OLD_DIRS+=usr/lib/clang/7.0.1/lib/freebsd
OLD_DIRS+=usr/lib/clang/7.0.1/lib
OLD_DIRS+=usr/lib/clang/7.0.1
# 20190126: adv(4) / adw(4) removal
OLD_FILES+=usr/share/man/man4/adv.4.gz
OLD_FILES+=usr/share/man/man4/adw.4.gz
# 20190114: old pbuf allocator removed
OLD_FILES+=usr/share/man/man9/pbuf.9.gz
# 20181219: ibcs removal

View File

@ -3,9 +3,12 @@
.include <src.opts.mk>
CONFS= dot.profile profile
CONFSDIR_dot.profile= /root
CONFSNAME_dot.profile= .profile
CONFGROUPS= ETC ROOT
ETC= profile
ROOT= dot.shrc dot.profile
ROOTDIR= /root
ROOTNAME_dot.shrc= .shrc
ROOTNAME_dot.profile= .profile
PACKAGE=runtime
PROG= sh
INSTALLFLAGS= -S

View File

@ -9,6 +9,9 @@ export TERM
PAGER=less
export PAGER
# set ENV to a file invoked each time sh is started for interactive use.
ENV=$HOME/.shrc; export ENV
# Query terminal size; useful for serial lines.
if [ -x /usr/bin/resizewin ] ; then /usr/bin/resizewin -z ; fi

39
bin/sh/dot.shrc Normal file
View File

@ -0,0 +1,39 @@
# $FreeBSD$
#
# .shrc - bourne shell startup file
#
# This file will be used if the shell is invoked for interactive use and
# the environment variable ENV is set to this file.
#
# see also sh(1), environ(7).
#
# file permissions: rwxr-xr-x
#
# umask 022
# Uncomment this to enable the builtin vi(1) command line editor in sh(1),
# e.g. ESC to go into visual mode.
# set -o vi
# # some useful aliases
# alias h='fc -l'
# alias j=jobs
# alias m="$PAGER"
# alias ll='ls -laFo'
# alias l='ls -l'
# alias g='egrep -i'
# # be paranoid
# alias cp='cp -ip'
# alias mv='mv -i'
# alias rm='rm -i'
# set prompt: ``username@hostname:directory $ ''
PS1="\u@\h:\w \\$ "
# search path for cd(1)
# CDPATH=:$HOME

View File

@ -40,6 +40,8 @@ static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <pwd.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
@ -130,6 +132,7 @@ static void synexpect(int) __dead2;
static void synerror(const char *) __dead2;
static void setprompt(int);
static int pgetc_linecont(void);
static void getusername(char *, size_t);
static void *
@ -1969,6 +1972,53 @@ pgetc_linecont(void)
return (c);
}
static struct passwd *
getpwlogin(void)
{
const char *login;
login = getlogin();
if (login == NULL)
return (NULL);
return (getpwnam(login));
}
static void
getusername(char *name, size_t namelen)
{
static char cached_name[MAXLOGNAME];
struct passwd *pw;
uid_t euid;
if (cached_name[0] == '\0') {
euid = geteuid();
/*
* Handle the case when there is more than one
* login with the same UID, or when the login
* returned by getlogin(2) does no longer match
* the current UID.
*/
pw = getpwlogin();
if (pw == NULL || pw->pw_uid != euid)
pw = getpwuid(euid);
if (pw != NULL) {
strlcpy(cached_name, pw->pw_name,
sizeof(cached_name));
} else {
snprintf(cached_name, sizeof(cached_name),
"%u", euid);
}
}
strlcpy(name, cached_name, namelen);
}
/*
* called by editline -- any expansions to the prompt
* should be added here.
@ -2026,6 +2076,17 @@ getprompt(void *unused __unused)
--i;
break;
/*
* User name.
*/
case 'u':
ps[i] = '\0';
getusername(&ps[i], PROMPTLEN - i);
/* Skip to end of username. */
while (ps[i + 1] != '\0')
i++;
break;
/*
* Working directory.
*

View File

@ -32,7 +32,7 @@
.\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95
.\" $FreeBSD$
.\"
.Dd December 8, 2018
.Dd January 24, 2019
.Dt SH 1
.Os
.Sh NAME
@ -1402,6 +1402,8 @@ which are replaced by the given information:
This system's fully-qualified hostname (FQDN).
.It Li \eh
This system's hostname.
.It Li \eu
User name.
.It Li \eW
The final component of the current working directory.
.It Li \ew

View File

@ -104,7 +104,7 @@ map le0 10.0.0.0/8 -> 192.168.55.0/24 portmap tcp/udp auto
In this instance, the word "auto" tells IPFilter to calculate a private
range of port numbers for each address on the LHS to use without fear
of them being trampled by others. This can lead to problems if there are
connections being generated mire quickly than IPFilter can expire them.
connections being generated more quickly than IPFilter can expire them.
In this instance, and if we want to get away from a private range of
port numbers, we can say:
.nf

View File

@ -357,6 +357,13 @@ ToolChain::CXXStdlibType FreeBSD::GetDefaultCXXStdlibType() const {
return ToolChain::CST_Libstdcxx;
}
unsigned FreeBSD::GetDefaultDwarfVersion() const {
// Default to use DWARF 2 before FreeBSD 13.
if (getTriple().getOSMajorVersion() < 13)
return 2;
return 4;
}
void FreeBSD::addLibStdCxxIncludePaths(
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const {

View File

@ -70,7 +70,7 @@ class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF {
const llvm::opt::ArgList &Args) const override;
bool isPIEDefault() const override;
SanitizerMask getSupportedSanitizers() const override;
unsigned GetDefaultDwarfVersion() const override { return 2; }
unsigned GetDefaultDwarfVersion() const override;
// Until dtrace (via CTF) and LLDB can deal with distributed debug info,
// FreeBSD defaults to standalone/full debug info.
bool GetDefaultStandaloneDebug() const override { return true; }

View File

@ -268,6 +268,10 @@ ATF_TC_BODY(cbrtl_powl, tc)
long double y, z;
size_t i;
#if defined(__amd64__) && defined(__clang__) && __clang_major__ >= 7
atf_tc_expect_fail("test fails with clang 7+ - bug 234040");
#endif
for (i = 0; i < __arraycount(x); i++) {
y = cbrtl(x[i]);

View File

@ -649,32 +649,14 @@ int
be_import(libbe_handle_t *lbh, const char *bootenv, int fd)
{
char buf[BE_MAXPATHLEN];
time_t rawtime;
nvlist_t *props;
zfs_handle_t *zfs;
int err, len;
char nbuf[24];
recvflags_t flags = { .nomount = 1 };
int err;
/*
* We don't need this to be incredibly random, just unique enough that
* it won't conflict with an existing dataset name. Chopping time
* down to 32 bits is probably good enough for this.
*/
snprintf(nbuf, 24, "tmp%u",
(uint32_t)(time(NULL) & 0xFFFFFFFF));
if ((err = be_root_concat(lbh, nbuf, buf)) != 0)
/*
* Technically this is our problem, but we try to use short
* enough names that we won't run into problems except in
* worst-case BE root approaching MAXPATHLEN.
*/
return (set_error(lbh, BE_ERR_PATHLEN));
be_root_concat(lbh, bootenv, buf);
time(&rawtime);
len = strlen(buf);
strftime(buf + len, sizeof(buf) - len, "@%F-%T", localtime(&rawtime));
if ((err = lzc_receive(buf, NULL, NULL, false, fd)) != 0) {
if ((err = zfs_receive(lbh->lzh, buf, NULL, &flags, fd, NULL)) != 0) {
switch (err) {
case EINVAL:
return (set_error(lbh, BE_ERR_NOORIGIN));
@ -687,39 +669,22 @@ be_import(libbe_handle_t *lbh, const char *bootenv, int fd)
}
}
if ((zfs = zfs_open(lbh->lzh, buf, ZFS_TYPE_SNAPSHOT)) == NULL)
if ((zfs = zfs_open(lbh->lzh, buf, ZFS_TYPE_FILESYSTEM)) == NULL)
return (set_error(lbh, BE_ERR_ZFSOPEN));
nvlist_alloc(&props, NV_UNIQUE_NAME, KM_SLEEP);
nvlist_add_string(props, "canmount", "noauto");
nvlist_add_string(props, "mountpoint", "/");
be_root_concat(lbh, bootenv, buf);
err = zfs_clone(zfs, buf, props);
zfs_close(zfs);
err = zfs_prop_set_list(zfs, props);
nvlist_free(props);
if (err != 0)
return (set_error(lbh, BE_ERR_UNKNOWN));
/*
* Finally, we open up the dataset we just cloned the snapshot so that
* we may promote it. This is necessary in order to clean up the ghost
* snapshot that doesn't need to be seen after the operation is
* complete.
*/
if ((zfs = zfs_open(lbh->lzh, buf, ZFS_TYPE_DATASET)) == NULL)
return (set_error(lbh, BE_ERR_ZFSOPEN));
err = zfs_promote(zfs);
zfs_close(zfs);
if (err != 0)
return (set_error(lbh, BE_ERR_UNKNOWN));
/* Clean up the temporary snapshot */
return (be_destroy(lbh, nbuf, 0));
return (0);
}
#if SOON

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd October 12, 2018
.Dd January 25, 2019
.Dt SENDFILE 2
.Os
.Sh NAME
@ -104,7 +104,7 @@ variable pointed to by
The least significant 16 bits of
.Fa flags
argument is a bitmap of these values:
.Bl -tag -offset indent
.Bl -tag -offset indent -width "SF_USER_READAHEAD"
.It Dv SF_NODISKIO
This flag causes
.Nm
@ -403,3 +403,14 @@ The
.Fx 11
implementation was written by
.An Gleb Smirnoff Aq Mt glebius@FreeBSD.org .
.Sh BUGS
The
.Fn sendfile
system call will not fail, i.e., return
.Dv -1
and set
.Va errno
to
.Er EFAULT ,
if provided an invalid address for
.Fa sbytes .

View File

@ -8,6 +8,7 @@ PACKAGE= tests
ATF_TESTS_C+= brk_test
.endif
ATF_TESTS_C+= queue_test
ATF_TESTS_C+= sendfile_test
# TODO: clone, lwp_create, lwp_ctl, posix_fadvise, recvmmsg,
# swapcontext

File diff suppressed because it is too large Load Diff

View File

@ -148,20 +148,20 @@ service_execute(int chanfd)
nvl = nvlist_recv(chanfd, 0);
if (nvl == NULL)
exit(1);
_exit(1);
if (!nvlist_exists_string(nvl, "service"))
exit(1);
_exit(1);
servname = nvlist_get_string(nvl, "service");
casserv = service_find(servname);
if (casserv == NULL)
exit(1);
_exit(1);
service = casserv->cs_service;
procfd = nvlist_take_descriptor(nvl, "procfd");
nvlist_destroy(nvl);
service_start(service, chanfd, procfd);
/* Not reached. */
exit(1);
_exit(1);
}
static int
@ -231,7 +231,7 @@ casper_main_loop(int fd)
int sock, maxfd, ret;
if (zygote_init() < 0)
exit(1);
_exit(1);
/*
* Register core services.
@ -256,7 +256,7 @@ casper_main_loop(int fd)
}
if (maxfd == -1) {
/* Nothing to do. */
exit(0);
_exit(0);
}
maxfd++;
@ -267,7 +267,7 @@ casper_main_loop(int fd)
if (ret == -1) {
if (errno == EINTR)
continue;
exit(1);
_exit(1);
}
TAILQ_FOREACH(casserv, &casper_services, cs_next) {

View File

@ -427,7 +427,7 @@ service_start(struct service *service, int sock, int procfd)
service_clean(sock, procfd, service->s_flags);
if (service_connection_add(service, sock, NULL) == NULL)
exit(1);
_exit(1);
for (;;) {
FD_ZERO(&fds);
@ -443,7 +443,7 @@ service_start(struct service *service, int sock, int procfd)
nfds = select(maxfd + 1, &fds, NULL, NULL, NULL);
if (nfds < 0) {
if (errno != EINTR)
exit(1);
_exit(1);
continue;
} else if (nfds == 0) {
/* Timeout. */
@ -468,5 +468,5 @@ service_start(struct service *service, int sock, int procfd)
}
}
exit(0);
_exit(0);
}

View File

@ -122,7 +122,7 @@ zygote_main(int sock)
if (nvlin == NULL) {
if (errno == ENOTCONN) {
/* Casper exited. */
exit(0);
_exit(0);
}
continue;
}
@ -134,7 +134,7 @@ zygote_main(int sock)
func = service_execute;
break;
default:
exit(0);
_exit(0);
}
/*
@ -161,7 +161,7 @@ zygote_main(int sock)
close(chanfd[0]);
func(chanfd[1]);
/* NOTREACHED */
exit(1);
_exit(1);
default:
/* Parent. */
close(chanfd[1]);

View File

@ -120,9 +120,9 @@ replaceall(char *source, const char *find, const char *replace)
/* If replace is longer than find, we'll need to create a temp copy */
if (rlen > flen) {
temp = malloc(slen + 1);
if (errno != 0) /* could not allocate memory */
if (temp == NULL) /* could not allocate memory */
return (-1);
strcpy(temp, source);
memcpy(temp, source, slen + 1);
} else
temp = source;

View File

@ -67,14 +67,16 @@ typedef uint64_t i386_pde_pae_t;
_Static_assert(PAGE_SHIFT == I386_PAGE_SHIFT, "PAGE_SHIFT mismatch");
_Static_assert(PAGE_SIZE == I386_PAGE_SIZE, "PAGE_SIZE mismatch");
_Static_assert(PAGE_MASK == I386_PAGE_MASK, "PAGE_MASK mismatch");
#if 0
_Static_assert(NPTEPG == I386_NPTEPG, "NPTEPG mismatch");
_Static_assert(PDRSHIFT == I386_PDRSHIFT, "PDRSHIFT mismatch");
_Static_assert(NBPDR == I386_NBPDR, "NBPDR mismatch");
#endif
_Static_assert(PDRSHIFT_NOPAE == I386_PDRSHIFT, "PDRSHIFT mismatch");
_Static_assert(PG_V == I386_PG_V, "PG_V mismatch");
_Static_assert(PG_PS == I386_PG_PS, "PG_PS mismatch");
_Static_assert((u_int)PG_FRAME == I386_PG_FRAME, "PG_FRAME mismatch");
_Static_assert(PG_PS_FRAME == I386_PG_PS_FRAME, "PG_PS_FRAME mismatch");
_Static_assert((u_int)PG_FRAME_NOPAE == I386_PG_FRAME, "PG_FRAME mismatch");
_Static_assert(PG_PS_FRAME_NOPAE == I386_PG_PS_FRAME, "PG_PS_FRAME mismatch");
#endif
int _i386_native(kvm_t *);

View File

@ -35,9 +35,12 @@ FBSD_1.3 {
FBSD_1.5 {
procstat_freeptlwpinfo;
procstat_getptlwpinfo;
procstat_get_pts_info;
procstat_get_sem_info;
procstat_get_shm_info;
procstat_get_socket_info;
};
FBSD_1.6 {
procstat_get_pts_info;
procstat_get_vnode_info;
};

View File

@ -36,9 +36,11 @@ __FBSDID("$FreeBSD$");
#include "libprocstat.h"
#define SPECNAMELEN_COMPAT12 63
struct freebsd11_ptsstat {
uint32_t dev;
char devname[SPECNAMELEN + 1];
char devname[SPECNAMELEN_COMPAT12 + 1];
};
struct freebsd11_vnstat {
@ -49,7 +51,7 @@ struct freebsd11_vnstat {
uint32_t vn_fsid;
int vn_type;
uint16_t vn_mode;
char vn_devname[SPECNAMELEN + 1];
char vn_devname[SPECNAMELEN_COMPAT12 + 1];
};
struct freebsd11_semstat {
uint32_t value;
@ -75,8 +77,25 @@ struct freebsd11_sockstat {
char dname[32];
};
struct freebsd12_vnstat {
uint64_t vn_fileid;
uint64_t vn_size;
uint64_t vn_dev;
uint64_t vn_fsid;
char *vn_mntdir;
int vn_type;
uint16_t vn_mode;
char vn_devname[SPECNAMELEN_COMPAT12 + 1];
};
struct freebsd12_ptsstat {
uint64_t dev;
char devname[SPECNAMELEN_COMPAT12 + 1];
};
int freebsd11_procstat_get_pts_info(struct procstat *procstat,
struct filestat *fst, struct freebsd11_ptsstat *pts, char *errbuf);
int freebsd12_procstat_get_pts_info(struct procstat *procstat,
struct filestat *fst, struct freebsd12_ptsstat *pts_compat, char *errbuf);
int freebsd11_procstat_get_sem_info(struct procstat *procstat,
struct filestat *fst, struct freebsd11_semstat *sem, char *errbuf);
int freebsd11_procstat_get_shm_info(struct procstat *procstat,
@ -85,6 +104,10 @@ int freebsd11_procstat_get_socket_info(struct procstat *procstat,
struct filestat *fst, struct freebsd11_sockstat *sock, char *errbuf);
int freebsd11_procstat_get_vnode_info(struct procstat *procstat,
struct filestat *fst, struct freebsd11_vnstat *vn, char *errbuf);
int freebsd12_procstat_get_vnode_info(struct procstat *procstat,
struct filestat *fst, struct freebsd12_vnstat *vn_compat, char *errbuf);
static const char trunc_name[] = "<TRUNCATED>";
int
freebsd11_procstat_get_pts_info(struct procstat *procstat,
@ -97,8 +120,30 @@ freebsd11_procstat_get_pts_info(struct procstat *procstat,
if (r != 0)
return (r);
pts_compat->dev = pts.dev;
memcpy(pts_compat->devname, pts.devname,
sizeof(pts_compat->devname));
if (strlen(pts.devname) >= sizeof(pts_compat->devname))
strcpy(pts_compat->devname, trunc_name);
else
memcpy(pts_compat->devname, pts.devname,
sizeof(pts_compat->devname));
return (0);
}
int
freebsd12_procstat_get_pts_info(struct procstat *procstat,
struct filestat *fst, struct freebsd12_ptsstat *pts_compat, char *errbuf)
{
struct ptsstat pts;
int r;
r = procstat_get_pts_info(procstat, fst, &pts, errbuf);
if (r != 0)
return (r);
pts_compat->dev = pts.dev;
if (strlen(pts.devname) >= sizeof(pts_compat->devname))
strcpy(pts_compat->devname, trunc_name);
else
memcpy(pts_compat->devname, pts.devname,
sizeof(pts_compat->devname));
return (0);
}
@ -174,8 +219,36 @@ freebsd11_procstat_get_vnode_info(struct procstat *procstat,
vn_compat->vn_fsid = vn.vn_fsid;
vn_compat->vn_type = vn.vn_type;
vn_compat->vn_mode = vn.vn_mode;
memcpy(vn_compat->vn_devname, vn.vn_devname,
sizeof(vn_compat->vn_devname));
if (strlen(vn.vn_devname) >= sizeof(vn_compat->vn_devname))
strcpy(vn_compat->vn_devname, trunc_name);
else
memcpy(vn_compat->vn_devname, vn.vn_devname,
sizeof(vn_compat->vn_devname));
return (0);
}
int
freebsd12_procstat_get_vnode_info(struct procstat *procstat,
struct filestat *fst, struct freebsd12_vnstat *vn_compat, char *errbuf)
{
struct vnstat vn;
int r;
r = procstat_get_vnode_info(procstat, fst, &vn, errbuf);
if (r != 0)
return (r);
vn_compat->vn_fileid = vn.vn_fileid;
vn_compat->vn_size = vn.vn_size;
vn_compat->vn_mntdir = vn.vn_mntdir;
vn_compat->vn_dev = vn.vn_dev;
vn_compat->vn_fsid = vn.vn_fsid;
vn_compat->vn_type = vn.vn_type;
vn_compat->vn_mode = vn.vn_mode;
if (strlen(vn.vn_devname) >= sizeof(vn_compat->vn_devname))
strcpy(vn_compat->vn_devname, trunc_name);
else
memcpy(vn_compat->vn_devname, vn.vn_devname,
sizeof(vn_compat->vn_devname));
return (0);
}
@ -186,3 +259,6 @@ __sym_compat(procstat_get_vnode_info, freebsd11_procstat_get_vnode_info,
FBSD_1.2);
__sym_compat(procstat_get_sem_info, freebsd11_procstat_get_sem_info, FBSD_1.3);
__sym_compat(procstat_get_shm_info, freebsd11_procstat_get_shm_info, FBSD_1.3);
__sym_compat(procstat_get_pts_info, freebsd12_procstat_get_pts_info, FBSD_1.5);
__sym_compat(procstat_get_vnode_info, freebsd12_procstat_get_vnode_info,
FBSD_1.5);

View File

@ -27,6 +27,7 @@ CFLAGS+=-I${SRCTOP}/lib/libthread_db
CFLAGS+=-Winline
CFLAGS.thr_stack.c+= -Wno-cast-align
CFLAGS.malloc.c+= -Wno-cast-align
.include <bsd.compiler.mk>
.if !(${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} < 40300)
CFLAGS.thr_symbols.c+= -Wno-missing-variable-declarations
@ -50,12 +51,14 @@ CFLAGS+=-D_PTHREADS_INVARIANTS
PRECIOUSLIB=
.PATH: ${.CURDIR}/arch/${MACHINE_CPUARCH}/${MACHINE_CPUARCH}
.PATH: ${SRCTOP}/libexec/rtld-elf
.if exists(${.CURDIR}/arch/${MACHINE_CPUARCH}/Makefile.inc)
.include "${.CURDIR}/arch/${MACHINE_CPUARCH}/Makefile.inc"
.endif
.include "${.CURDIR}/sys/Makefile.inc"
.include "${.CURDIR}/thread/Makefile.inc"
SRCS+= malloc.c
.if ${MK_INSTALLLIB} != "no"
SYMLINKS+=lib${LIB}.a ${LIBDIR}/libpthread.a

View File

@ -31,6 +31,7 @@ SRCS+= \
thr_kern.c \
thr_kill.c \
thr_main_np.c \
thr_malloc.c \
thr_multi_np.c \
thr_mutex.c \
thr_mutexattr.c \

View File

@ -170,6 +170,7 @@ __thr_fork(void)
*/
if (_thr_isthreaded() != 0) {
was_threaded = 1;
__thr_malloc_prefork(curthread);
_malloc_prefork();
__thr_pshared_atfork_pre();
_rtld_atfork_pre(rtld_locks);
@ -197,6 +198,10 @@ __thr_fork(void)
*/
curthread->tlflags &= ~TLFLAGS_IN_TDLIST;
/* before thr_self() */
if (was_threaded)
__thr_malloc_postfork(curthread);
/* child is a new kernel thread. */
thr_self(&curthread->tid);
@ -241,6 +246,7 @@ __thr_fork(void)
_thr_signal_postfork();
if (was_threaded) {
__thr_malloc_postfork(curthread);
_rtld_atfork_post(rtld_locks);
__thr_pshared_atfork_post();
_malloc_postfork();

View File

@ -461,6 +461,7 @@ init_private(void)
*/
if (init_once == 0) {
__thr_pshared_init();
__thr_malloc_init();
/* Find the stack top */
mib[0] = CTL_KERN;
mib[1] = KERN_USRSTACK;

View File

@ -0,0 +1,137 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2019 The FreeBSD Foundation
* All rights reserved.
*
* This software was developed by Konstantin Belousov <kib@FreeBSD.org>
* under sponsorship from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/mman.h>
#include <rtld_malloc.h>
#include "thr_private.h"
int npagesizes;
size_t *pagesizes;
static size_t pagesizes_d[2];
static struct umutex thr_malloc_umtx;
void
__thr_malloc_init(void)
{
npagesizes = getpagesizes(pagesizes_d, nitems(pagesizes_d));
if (npagesizes == -1) {
npagesizes = 1;
pagesizes_d[0] = PAGE_SIZE;
}
pagesizes = pagesizes_d;
_thr_umutex_init(&thr_malloc_umtx);
}
static void
thr_malloc_lock(struct pthread *curthread)
{
curthread->locklevel++;
_thr_umutex_lock(&thr_malloc_umtx, TID(curthread));
}
static void
thr_malloc_unlock(struct pthread *curthread)
{
_thr_umutex_unlock(&thr_malloc_umtx, TID(curthread));
curthread->locklevel--;
_thr_ast(curthread);
}
void *
__thr_calloc(size_t num, size_t size)
{
struct pthread *curthread;
void *res;
curthread = _get_curthread();
thr_malloc_lock(curthread);
res = __crt_calloc(num, size);
thr_malloc_unlock(curthread);
return (res);
}
void
__thr_free(void *cp)
{
struct pthread *curthread;
curthread = _get_curthread();
thr_malloc_lock(curthread);
__crt_free(cp);
thr_malloc_unlock(curthread);
}
void *
__thr_malloc(size_t nbytes)
{
struct pthread *curthread;
void *res;
curthread = _get_curthread();
thr_malloc_lock(curthread);
res = __crt_malloc(nbytes);
thr_malloc_unlock(curthread);
return (res);
}
void *
__thr_realloc(void *cp, size_t nbytes)
{
struct pthread *curthread;
void *res;
curthread = _get_curthread();
thr_malloc_lock(curthread);
res = __crt_realloc(cp, nbytes);
thr_malloc_unlock(curthread);
return (res);
}
void
__thr_malloc_prefork(struct pthread *curthread)
{
_thr_umutex_lock(&thr_malloc_umtx, TID(curthread));
}
void
__thr_malloc_postfork(struct pthread *curthread)
{
_thr_umutex_unlock(&thr_malloc_umtx, TID(curthread));
}

View File

@ -306,10 +306,11 @@ init_static(struct pthread *thread, pthread_mutex_t *mutex)
THR_LOCK_ACQUIRE(thread, &_mutex_static_lock);
if (*mutex == THR_MUTEX_INITIALIZER)
ret = mutex_init(mutex, &_pthread_mutexattr_default, calloc);
ret = mutex_init(mutex, &_pthread_mutexattr_default,
__thr_calloc);
else if (*mutex == THR_ADAPTIVE_MUTEX_INITIALIZER)
ret = mutex_init(mutex, &_pthread_mutexattr_adaptive_default,
calloc);
__thr_calloc);
else
ret = 0;
THR_LOCK_RELEASE(thread, &_mutex_static_lock);
@ -390,7 +391,7 @@ __pthread_mutex_init(pthread_mutex_t * __restrict mutex,
if (mutex_attr == NULL ||
(*mutex_attr)->m_pshared == PTHREAD_PROCESS_PRIVATE) {
return (mutex_init(mutex, mutex_attr ? *mutex_attr : NULL,
calloc));
__thr_calloc));
}
pmtx = __thr_pshared_offpage(__DECONST(void *, mutex), 1);
if (pmtx == NULL)
@ -483,7 +484,7 @@ _pthread_mutex_destroy(pthread_mutex_t *mutex)
} else {
*mutex = THR_MUTEX_DESTROYED;
mutex_assert_not_owned(_get_curthread(), m);
free(m);
__thr_free(m);
ret = 0;
}
}

View File

@ -1003,6 +1003,14 @@ void __thr_pshared_destroy(void *key) __hidden;
void __thr_pshared_atfork_pre(void) __hidden;
void __thr_pshared_atfork_post(void) __hidden;
void *__thr_calloc(size_t num, size_t size);
void __thr_free(void *cp);
void *__thr_malloc(size_t nbytes);
void *__thr_realloc(void *cp, size_t nbytes);
void __thr_malloc_init(void);
void __thr_malloc_prefork(struct pthread *curthread);
void __thr_malloc_postfork(struct pthread *curthread);
__END_DECLS
__NULLABILITY_PRAGMA_POP

View File

@ -155,8 +155,7 @@ _thread_cleanupspecific(void)
}
}
THR_LOCK_RELEASE(curthread, &_keytable_lock);
munmap(curthread->specific, PTHREAD_KEYS_MAX * sizeof(struct
pthread_specific_elem));
__thr_free(curthread->specific);
curthread->specific = NULL;
if (curthread->specific_data_count > 0) {
stderr_debug("Thread %p has exited with leftover "
@ -179,10 +178,9 @@ _pthread_setspecific(pthread_key_t userkey, const void *value)
pthread = _get_curthread();
if (pthread->specific == NULL) {
tmp = mmap(NULL, PTHREAD_KEYS_MAX *
sizeof(struct pthread_specific_elem),
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
if (tmp == MAP_FAILED)
tmp = __thr_calloc(PTHREAD_KEYS_MAX,
sizeof(struct pthread_specific_elem));
if (tmp == NULL)
return (ENOMEM);
pthread->specific = tmp;
}

View File

@ -160,6 +160,10 @@ ATF_TC_BODY(reduction, tc)
unsigned i;
#if defined(__amd64__) && defined(__clang__) && __clang_major__ >= 7
atf_tc_expect_fail("test fails with clang 7+ - bug 234040");
#endif
for (i = 0; i < nitems(f_pi_odd); i++) {
ATF_CHECK(fabs(sinf(f_pi_odd[i])) < FLT_EPSILON);
ATF_CHECK(cosf(f_pi_odd[i]) == -1.0);

View File

@ -141,7 +141,7 @@ read_chat(char **chatstr)
int l;
if ((l=strlen(str)) > 0 && (tmp=malloc(l + 1)) != NULL &&
(res=malloc((l / 2 + 1) * sizeof(char *))) != NULL) {
(res=malloc(((l + 1) / 2 + 1) * sizeof(char *))) != NULL) {
static char ws[] = " \t";
char * p;
@ -216,7 +216,7 @@ read_chat(char **chatstr)
q = strrchr(p+1, *p);
if (q != NULL && *q == *p && q[1] == '\0') {
*q = '\0';
strcpy(p, p+1);
p++;
}
}

View File

@ -257,9 +257,7 @@ ifconfig_down()
elif hostapif $1; then
/etc/rc.d/hostapd stop $1
_cfg=0
fi
if dhcpif $1; then
elif dhcpif $1; then
/etc/rc.d/dhclient stop $1
_cfg=0
fi

View File

@ -153,7 +153,7 @@ botch(s)
*/
void *
malloc(size_t nbytes)
__crt_malloc(size_t nbytes)
{
union overhead *op;
int bucket;
@ -236,7 +236,7 @@ malloc(size_t nbytes)
}
void *
calloc(size_t num, size_t size)
__crt_calloc(size_t num, size_t size)
{
void *ret;
@ -245,7 +245,7 @@ calloc(size_t num, size_t size)
return (NULL);
}
if ((ret = malloc(num * size)) != NULL)
if ((ret = __crt_malloc(num * size)) != NULL)
memset(ret, 0, num * size);
return (ret);
@ -298,7 +298,7 @@ morecore(int bucket)
}
void
free(void * cp)
__crt_free(void *cp)
{
int size;
union overhead *op;
@ -339,7 +339,7 @@ free(void * cp)
static int realloc_srchlen = 4; /* 4 should be plenty, -1 =>'s whole list */
void *
realloc(void *cp, size_t nbytes)
__crt_realloc(void *cp, size_t nbytes)
{
u_int onb;
int i;
@ -348,7 +348,7 @@ realloc(void *cp, size_t nbytes)
int was_alloced = 0;
if (cp == NULL)
return (malloc(nbytes));
return (__crt_malloc(nbytes));
op = (union overhead *)((caddr_t)cp - sizeof (union overhead));
if (op->ov_magic == MAGIC) {
was_alloced++;
@ -393,10 +393,10 @@ realloc(void *cp, size_t nbytes)
#endif
return(cp);
} else
free(cp);
__crt_free(cp);
}
if ((res = malloc(nbytes)) == NULL)
return (NULL);
if ((res = __crt_malloc(nbytes)) == NULL)
return (NULL);
if (cp != res) /* common optimization if "compacting" */
bcopy(cp, res, (nbytes < onb) ? nbytes : onb);
return (res);
@ -467,9 +467,11 @@ morepages(int n)
caddr_t addr = (caddr_t)
(((long)pagepool_start + pagesz - 1) & ~(pagesz - 1));
if (munmap(addr, pagepool_end - addr) != 0) {
#ifdef IN_RTLD
rtld_fdprintf(STDERR_FILENO, _BASENAME_RTLD ": "
"morepages: cannot munmap %p: %s\n",
addr, rtld_strerror(errno));
#endif
}
}
@ -478,9 +480,11 @@ morepages(int n)
if ((pagepool_start = mmap(0, n * pagesz,
PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, fd, 0)) == (caddr_t)-1) {
#ifdef IN_RTLD
rtld_fdprintf(STDERR_FILENO, _BASENAME_RTLD ": morepages: "
"cannot mmap anonymous memory: %s\n",
rtld_strerror(errno));
#endif
return 0;
}
pagepool_end = pagepool_start + n * pagesz;

View File

@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$");
#include "paths.h"
#include "rtld_tls.h"
#include "rtld_printf.h"
#include "rtld_malloc.h"
#include "rtld_utrace.h"
#include "notes.h"
@ -2897,16 +2898,6 @@ relocate_object(Obj_Entry *obj, bool bind_now, Obj_Entry *rtldobj,
lockstate) == -1)
return (-1);
/*
* Process the non-PLT IFUNC relocations. The relocations are
* processed in two phases, because IFUNC resolvers may
* reference other symbols, which must be readily processed
* before resolvers are called.
*/
if (obj->non_plt_gnu_ifunc &&
reloc_non_plt(obj, rtldobj, flags | SYMLOOK_IFUNC, lockstate))
return (-1);
if (!obj->mainprog && obj_enforce_relro(obj) == -1)
return (-1);
@ -5647,3 +5638,32 @@ bzero(void *dest, size_t len)
for (i = 0; i < len; i++)
((char *)dest)[i] = 0;
}
/* malloc */
void *
malloc(size_t nbytes)
{
return (__crt_malloc(nbytes));
}
void *
calloc(size_t num, size_t size)
{
return (__crt_calloc(num, size));
}
void
free(void *cp)
{
__crt_free(cp);
}
void *
realloc(void *cp, size_t nbytes)
{
return (__crt_realloc(cp, nbytes));
}

View File

@ -409,4 +409,9 @@ void pre_init(void);
void init_pltgot(Obj_Entry *);
void allocate_initial_tls(Obj_Entry *);
void *__crt_calloc(size_t num, size_t size);
void __crt_free(void *cp);
void *__crt_malloc(size_t nbytes);
void *__crt_realloc(void *cp, size_t nbytes);
#endif /* } */

View File

@ -0,0 +1,45 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2019 The FreeBSD Foundation
* All rights reserved.
*
* This software was developed by Konstantin Belousov <kib@FreeBSD.org>
* under sponsorship from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef RTLD_MALLOC_H
#define RTLD_MALLOC_H
void *__crt_calloc(size_t num, size_t size);
void __crt_free(void *cp);
void *__crt_malloc(size_t nbytes);
void *__crt_realloc(void *cp, size_t nbytes);
extern int npagesizes;
extern size_t *pagesizes;
#endif

View File

@ -33,13 +33,14 @@
#include <unistd.h>
#include "rtld.h"
#include "rtld_printf.h"
#include "rtld_malloc.h"
void *
xcalloc(size_t number, size_t size)
{
void *p;
p = calloc(number, size);
p = __crt_calloc(number, size);
if (p == NULL) {
rtld_fdputstr(STDERR_FILENO, "Out of memory\n");
_exit(1);
@ -50,12 +51,15 @@ xcalloc(size_t number, size_t size)
void *
xmalloc(size_t size)
{
void *p = malloc(size);
if (p == NULL) {
rtld_fdputstr(STDERR_FILENO, "Out of memory\n");
_exit(1);
}
return p;
void *p;
p = __crt_malloc(size);
if (p == NULL) {
rtld_fdputstr(STDERR_FILENO, "Out of memory\n");
_exit(1);
}
return (p);
}
char *

View File

@ -62,7 +62,7 @@ bectl_cleanup()
zpool=$1
if zpool get health ${zpool} >/dev/null 2>&1; then
zpool destroy ${zpool}
zpool destroy -f ${zpool}
fi
}

View File

@ -43,7 +43,7 @@ options {
#
notify 0 {
match "system" "IFNET";
match "subsystem" "(?!usbus[0-9]+|?!wlan[0-9]+)";
match "subsystem" "!(usbus|wlan)[0-9]+";
match "type" "ATTACH";
action "/etc/pccard_ether $subsystem start";
};

View File

@ -111,6 +111,8 @@ static void status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
static void tunnel_status(int s);
static _Noreturn void usage(void);
static int getifflags(const char *ifname, int us);
static struct afswtch *af_getbyname(const char *name);
static struct afswtch *af_getbyfamily(int af);
static void af_other_status(int);
@ -369,6 +371,7 @@ main(int argc, char *argv[])
const char *ifname;
struct option *p;
size_t iflen;
int flags;
all = downonly = uponly = namesonly = noload = verbose = 0;
f_inet = f_inet6 = f_ether = f_addr = NULL;
@ -526,6 +529,25 @@ main(int argc, char *argv[])
argc--, argv++;
}
/*
* Check for a requested configuration action on a single interface,
* which doesn't require building, sorting, and searching the entire
* system address list
*/
if ((argc > 0) && (ifname != NULL)) {
iflen = strlcpy(name, ifname, sizeof(name));
if (iflen >= sizeof(name)) {
warnx("%s: interface name too long, skipping", ifname);
} else {
flags = getifflags(name, -1);
if (!(((flags & IFF_CANTCONFIG) != 0) ||
(downonly && (flags & IFF_UP) != 0) ||
(uponly && (flags & IFF_UP) == 0)))
ifconfig(argc, argv, 0, afp);
}
goto done;
}
if (getifaddrs(&ifap) != 0)
err(EXIT_FAILURE, "getifaddrs");
@ -609,6 +631,7 @@ main(int argc, char *argv[])
printf("\n");
freeifaddrs(ifap);
done:
freeformat();
exit(exit_code);
}
@ -1020,6 +1043,28 @@ setifdstaddr(const char *addr, int param __unused, int s,
afp->af_getaddr(addr, DSTADDR);
}
static int
getifflags(const char *ifname, int us)
{
struct ifreq my_ifr;
int s;
memset(&my_ifr, 0, sizeof(my_ifr));
(void) strlcpy(my_ifr.ifr_name, ifname, sizeof(my_ifr.ifr_name));
if (us < 0) {
if ((s = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0)
err(1, "socket(family AF_LOCAL,SOCK_DGRAM");
} else
s = us;
if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&my_ifr) < 0) {
Perror("ioctl (SIOCGIFFLAGS)");
exit(1);
}
if (us < 0)
close(s);
return ((my_ifr.ifr_flags & 0xffff) | (my_ifr.ifr_flagshigh << 16));
}
/*
* Note: doing an SIOCIGIFFLAGS scribbles on the union portion
* of the ifreq structure, which may confuse other parts of ifconfig.
@ -1031,20 +1076,14 @@ setifflags(const char *vname, int value, int s, const struct afswtch *afp)
struct ifreq my_ifr;
int flags;
memset(&my_ifr, 0, sizeof(my_ifr));
(void) strlcpy(my_ifr.ifr_name, name, sizeof(my_ifr.ifr_name));
if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&my_ifr) < 0) {
Perror("ioctl (SIOCGIFFLAGS)");
exit(1);
}
flags = (my_ifr.ifr_flags & 0xffff) | (my_ifr.ifr_flagshigh << 16);
flags = getifflags(name, s);
if (value < 0) {
value = -value;
flags &= ~value;
} else
flags |= value;
memset(&my_ifr, 0, sizeof(my_ifr));
(void) strlcpy(my_ifr.ifr_name, name, sizeof(my_ifr.ifr_name));
my_ifr.ifr_flags = flags & 0xffff;
my_ifr.ifr_flagshigh = flags >> 16;
if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&my_ifr) < 0)

View File

@ -1528,9 +1528,6 @@ getmodeflags(const char *val)
return flags;
}
#define IEEE80211_CHAN_HTA (IEEE80211_CHAN_HT|IEEE80211_CHAN_5GHZ)
#define IEEE80211_CHAN_HTG (IEEE80211_CHAN_HT|IEEE80211_CHAN_2GHZ)
#define _APPLY(_flags, _base, _param, _v) do { \
if (_flags & IEEE80211_CHAN_HT) { \
if ((_flags & (IEEE80211_CHAN_5GHZ|IEEE80211_CHAN_2GHZ)) == 0) {\
@ -1720,8 +1717,6 @@ DECL_CMD_FUNC(set80211maxretry, val, d)
}
#undef _APPLY_RATE
#undef _APPLY
#undef IEEE80211_CHAN_HTA
#undef IEEE80211_CHAN_HTG
static
DECL_CMD_FUNC(set80211fragthreshold, val, d)

View File

@ -195,16 +195,16 @@ pfsync_status(int s)
return;
if (preq.pfsyncr_syncdev[0] != '\0' ||
preq.pfsyncr_syncpeer.s_addr != INADDR_PFSYNC_GROUP)
preq.pfsyncr_syncpeer.s_addr != htonl(INADDR_PFSYNC_GROUP))
printf("\t");
if (preq.pfsyncr_syncdev[0] != '\0')
printf("pfsync: syncdev: %s ", preq.pfsyncr_syncdev);
if (preq.pfsyncr_syncpeer.s_addr != INADDR_PFSYNC_GROUP)
if (preq.pfsyncr_syncpeer.s_addr != htonl(INADDR_PFSYNC_GROUP))
printf("syncpeer: %s ", inet_ntoa(preq.pfsyncr_syncpeer));
if (preq.pfsyncr_syncdev[0] != '\0' ||
preq.pfsyncr_syncpeer.s_addr != INADDR_PFSYNC_GROUP) {
preq.pfsyncr_syncpeer.s_addr != htonl(INADDR_PFSYNC_GROUP)) {
printf("maxupd: %d ", preq.pfsyncr_maxupdates);
printf("defer: %s\n", preq.pfsyncr_defer ? "on" : "off");
}

View File

@ -28,7 +28,7 @@
.\" @(#)newfs.8 8.6 (Berkeley) 5/3/95
.\" $FreeBSD$
.\"
.Dd July 7, 2017
.Dd January 29, 2019
.Dt NEWFS 8
.Os
.Sh NAME
@ -89,6 +89,7 @@ See
for details.
.It Fl L Ar volname
Add a volume label to the new file system.
Legal characters are alphanumerics, dashes, and underscores.
.It Fl N
Cause the file system parameters to be printed out
without really creating the file system.

View File

@ -153,9 +153,10 @@ main(int argc, char *argv[])
volumelabel = optarg;
i = -1;
while (isalnum(volumelabel[++i]) ||
volumelabel[i] == '_');
volumelabel[i] == '_' || volumelabel[i] == '-');
if (volumelabel[i] != '\0') {
errx(1, "bad volume label. Valid characters are alphanumerics.");
errx(1, "bad volume label. Valid characters "
"are alphanumerics, dashes, and underscores.");
}
if (strlen(volumelabel) >= MAXVOLLEN) {
errx(1, "bad volume label. Length is longer than %d.",

View File

@ -4743,6 +4743,8 @@ process_tabledef(char *name, struct table_opts *opts)
{
struct pfr_buffer ab;
struct node_tinit *ti;
unsigned long maxcount;
size_t s = sizeof(maxcount);
bzero(&ab, sizeof(ab));
ab.pfrb_type = PFRB_ADDRS;
@ -4770,8 +4772,19 @@ process_tabledef(char *name, struct table_opts *opts)
if (!(pf->opts & PF_OPT_NOACTION) &&
pfctl_define_table(name, opts->flags, opts->init_addr,
pf->anchor->name, &ab, pf->anchor->ruleset.tticket)) {
yyerror("cannot define table %s: %s", name,
pfr_strerror(errno));
if (sysctlbyname("net.pf.request_maxcount", &maxcount, &s,
NULL, 0) == -1)
maxcount = 65535;
if (ab.pfrb_size > maxcount)
yyerror("cannot define table %s: too many elements.\n"
"Consider increasing net.pf.request_maxcount.",
name);
else
yyerror("cannot define table %s: %s", name,
pfr_strerror(errno));
goto _error;
}
pf->tdirty = 1;

View File

@ -28,7 +28,7 @@
.\" @(#)tunefs.8 8.2 (Berkeley) 12/11/93
.\" $FreeBSD$
.\"
.Dd April 19, 2016
.Dd January 29, 2019
.Dt TUNEFS 8
.Os
.Sh NAME
@ -112,6 +112,7 @@ By default
sets it to half of the space reserved to minfree.
.It Fl L Ar volname
Add/modify an optional file system volume label.
Legal characters are alphanumerics, dashes, and underscores.
.It Fl l Cm enable | disable
Turn on/off MAC multilabel flag.
.It Fl m Ar minfree

View File

@ -189,10 +189,12 @@ main(int argc, char *argv[])
name = "volume label";
Lvalue = optarg;
i = -1;
while (isalnum(Lvalue[++i]));
while (isalnum(Lvalue[++i]) || Lvalue[i] == '_' ||
Lvalue[i] == '-')
;
if (Lvalue[i] != '\0') {
errx(10,
"bad %s. Valid characters are alphanumerics.",
errx(10, "bad %s. Valid characters are "
"alphanumerics, dashes, and underscores.",
name);
}
if (strlen(Lvalue) >= MAXVOLLEN) {

View File

@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"/
.Dd April 14, 2014
.Dd January 25, 2019
.Dt ATH 4
.Os
.Sh NAME
@ -42,7 +42,6 @@ kernel configuration file:
.Cd "device ath"
.Cd "device ath_pci"
.Cd "device ath_hal"
.Cd "options AH_SUPPORT_AR5416"
.Cd "device ath_rate_sample"
.Cd "device wlan"
.Ed

View File

@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"/
.Dd July 22, 2013
.Dd January 25, 2019
.Dt ATH_HAL 4
.Os
.Sh NAME
@ -36,7 +36,6 @@
.Nd "Atheros Hardware Access Layer (HAL)"
.Sh SYNOPSIS
.Cd "device ath_hal"
.Cd "options AH_SUPPORT_AR5416"
or
.Cd "device ath_ar5210"
.Cd "device ath_ar5211"
@ -57,12 +56,11 @@ or
.Cd "device ath_ar9285"
.Cd "device ath_ar9287"
.Cd "device ath_ar9300"
.Cd "options AH_SUPPORT_AR5416"
.Sh DESCRIPTION
The hal provides hardware support for wireless network adapters based on
the Atheros AR5210, AR5211, AR5212, AR5213, AR2413, AR2417, AR2425,
AR5413, AR5416, AR5418, AR5424, AR9160, AR9220, AR9280, AR9285, AR9287,
AR9380, AR9390, AR9580, AR9590, AR9562 and QCA9565
AR5413, AR5416, AR5418, AR5424, AR9130, AR9160, AR9220, AR9280, AR9285,
AR9287, AR9380, AR9390, AR9580, AR9590, AR9562 and QCA9565
chips (and companion RF/baseband parts).
This code is part of the
.Xr ath 4
@ -71,11 +69,6 @@ over the set of chips supported.
Selecting
.Nm
enables support for all PCI and Cardbus devices.
Note this includes AR5416, AR5418, AR9130, AR9160, AR9220, AR9280, AR9285
and AR9287 devices and must be accompanied by the
AH_SUPPORT_AR5416
option to enable the extended hardware descriptor format used by
AR5416 and later devices.
.Pp
Some devices come in Cardbus/MiniPCI/PCI format.
Others (for example AR2413, AR2427, AR5418, AR9280, AR9285, AR9287) come in

View File

@ -166,4 +166,4 @@ and ported by
The
.Nm
driver only supports 802.11a/b/g operations.
802.11 operation is not supported at this time.
802.11n operation is not supported at this time.

View File

@ -29,7 +29,7 @@
.\"
.\" $FreeBSD$
.\"/
.Dd January 2, 2019
.Dd January 28, 2019
.Dt RTWN_USB 4
.Os
.Sh NAME
@ -80,6 +80,7 @@ based USB wireless network adapters, including:
.It "Edimax EW-7811Un" Ta RTL8188CUS Ta USB 2.0
.It "Edimax EW-7811UTC" Ta RTL8821AU Ta USB 2.0
.It "Edimax EW-7822UAC" Ta RTL8812AU Ta USB 3.0
.It "EDUP EP-AC1620" Ta RTL8821AU Ta USB 2.0
.It "Elecom WDC-150SU2M" Ta RTL8188EU Ta USB 2.0
.It "EnGenius EUB1200AC" Ta RTL8812AU Ta USB 3.0
.It "Hawking HD65U" Ta RTL8821AU Ta USB 2.0

View File

@ -167,9 +167,8 @@ was used to be compatible with
.Pp
Mesh stations follow the 802.11s Draft 3.0 specification which is
not ratified and subject to change.
Beware that this specification is incompatible with earlier drafts;
and stations implementing earlier drafts (e.g. Linux)
may not interoperate.
Be aware that this specification is incompatible with earlier drafts.
Stations implementing earlier drafts (e.g., Linux) may be incompatible.
.Sh SEE ALSO
.Xr an 4 ,
.Xr ath 4 ,

View File

@ -2095,8 +2095,7 @@ MLINKS+=timeout.9 callout.9 \
timeout.9 callout_stop.9 \
timeout.9 callout_when.9 \
timeout.9 untimeout.9
MLINKS+=ucred.9 cred_update_thread.9 \
ucred.9 crcopy.9 \
MLINKS+=ucred.9 crcopy.9 \
ucred.9 crcopysafe.9 \
ucred.9 crdup.9 \
ucred.9 crfree.9 \

View File

@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd September 27, 2017
.Dd January 23, 2019
.Dt UCRED 9
.Os
.Sh NAME
@ -36,8 +36,7 @@
.Nm crfree ,
.Nm crcopy ,
.Nm crdup ,
.Nm cru2x ,
.Nm cred_update_thread
.Nm cru2x
.Nd "functions related to user credentials"
.Sh SYNOPSIS
.In sys/param.h
@ -58,8 +57,6 @@
.Fn crsetgroups "struct ucred *cr" "int ngrp" "gid_t *groups"
.Ft void
.Fn cru2x "struct ucred *cr" "struct xucred *xcr"
.Ft void
.Fn cred_update_thread "struct thread *td"
.Sh DESCRIPTION
The
.Nm
@ -147,11 +144,6 @@ the former
(e.g.,
.Va cr_version ) .
.Pp
The
.Fn cred_update_thread
function sets the credentials of
.Fa td
to that of its process, freeing its old credential if required.
.Sh RETURN VALUES
.Fn crget ,
.Fn crhold ,

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,7 @@ alias g='egrep -i'
# set prompt: ``username@hostname:directory $ ''
PS1="`whoami`@\h:\w \\$ "
PS1="\u@\h:\w \\$ "
# search path for cd(1)
# CDPATH=:$HOME

View File

@ -100,9 +100,12 @@ options WITNESS # Enable checks to detect deadlocks and cycles
options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
options VERBOSE_SYSINIT=0 # Support debug.verbose_sysinit, off by default
# Kernel Sanitizers
#options COVERAGE # Generic kernel coverage. Used by KCOV
#options KCOV # Kernel Coverage Sanitizer
# Warning: KUBSAN can result in a kernel too large for loader to load
#options KUBSAN # Kernel Undefined Behavior Sanitizer
#options KCOV # Kernel Coverage Sanitizer
# Kernel dump features.
options EKCD # Support for encrypted kernel dumps
@ -293,7 +296,6 @@ device an # Aironet 4500/4800 802.11 wireless NICs.
device ath # Atheros NICs
device ath_pci # Atheros pci/cardbus glue
device ath_hal # pci/cardbus chip support
options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors
options AH_AR5416_INTERRUPT_MITIGATION # AR5416 interrupt mitigation
options ATH_ENABLE_11N # Enable 802.11n support for AR5416 and later
device ath_rate_sample # SampleRate tx rate control for ath

View File

@ -37,4 +37,5 @@ nooptions WITNESS_SKIPSPIN
nooptions BUF_TRACKING
nooptions DEADLKRES
nooptions FULL_BUF_TRACKING
nooptions COVERAGE
nooptions KCOV

View File

@ -92,9 +92,12 @@ options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
options ALT_BREAK_TO_DEBUGGER # Enter debugger on keyboard escape sequence
options USB_DEBUG # enable debug msgs
options VERBOSE_SYSINIT=0 # Support debug.verbose_sysinit, off by default
# Kernel Sanitizers
#options COVERAGE # Generic kernel coverage. Used by KCOV
#options KCOV # Kernel Coverage Sanitizer
# Warning: KUBSAN can result in a kernel too large for loader to load
#options KUBSAN # Kernel Undefined Behavior Sanitizer
#options KCOV # Kernel Coverage Sanitizer
# Kernel dump features.
options EKCD # Support for encrypted kernel dumps

View File

@ -36,3 +36,5 @@ nooptions WITNESS
nooptions WITNESS_SKIPSPIN
nooptions DEADLKRES
nooptions USB_DEBUG
nooptions COVERAGE
nooptions KCOV

View File

@ -0,0 +1,2 @@
/* $FreeBSD$ */
#include <machine/frame.h>

View File

@ -1090,6 +1090,30 @@ static struct da_quirk_entry da_quirk_table[] =
{ T_DIRECT, SIP_MEDIA_FIXED, "WDC WD??", "???PVT*", "*" },
/*quirks*/DA_Q_4K
},
{
/*
* Olympus digital cameras (C-3040ZOOM, C-2040ZOOM, C-1)
* PR: usb/97472
*/
{ T_DIRECT, SIP_MEDIA_REMOVABLE, "OLYMPUS", "C*", "*"},
/*quirks*/ DA_Q_NO_6_BYTE | DA_Q_NO_SYNC_CACHE
},
{
/*
* Olympus digital cameras (D-370)
* PR: usb/97472
*/
{ T_DIRECT, SIP_MEDIA_REMOVABLE, "OLYMPUS", "D*", "*"},
/*quirks*/ DA_Q_NO_6_BYTE
},
{
/*
* Olympus digital cameras (E-100RS, E-10).
* PR: usb/97472
*/
{ T_DIRECT, SIP_MEDIA_REMOVABLE, "OLYMPUS", "E*", "*"},
/*quirks*/ DA_Q_NO_6_BYTE | DA_Q_NO_SYNC_CACHE
},
{
/*
* Olympus FE-210 camera

View File

@ -103,7 +103,7 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, zil_replay_disable, CTLFLAG_RWTUN,
* out-of-order write cache is enabled.
*/
boolean_t zfs_nocacheflush = B_FALSE;
SYSCTL_INT(_vfs_zfs, OID_AUTO, cache_flush_disable, CTLFLAG_RDTUN,
SYSCTL_INT(_vfs_zfs, OID_AUTO, cache_flush_disable, CTLFLAG_RWTUN,
&zfs_nocacheflush, 0, "Disable cache flush");
boolean_t zfs_trim_enabled = B_TRUE;
SYSCTL_DECL(_vfs_zfs_trim);

View File

@ -71,7 +71,7 @@ struct pci_device_id {
#define PCI_BASE_CLASS_BRIDGE 0x06
#define PCI_CLASS_BRIDGE_ISA 0x0601
#define PCI_ANY_ID (-1)
#define PCI_ANY_ID -1U
#define PCI_VENDOR_ID_APPLE 0x106b
#define PCI_VENDOR_ID_ASUSTEK 0x1043
#define PCI_VENDOR_ID_ATI 0x1002

View File

@ -82,14 +82,21 @@ linux_pci_find(device_t dev, const struct pci_device_id **idp)
struct pci_driver *pdrv;
uint16_t vendor;
uint16_t device;
uint16_t subvendor;
uint16_t subdevice;
vendor = pci_get_vendor(dev);
device = pci_get_device(dev);
subvendor = pci_get_subvendor(dev);
subdevice = pci_get_subdevice(dev);
spin_lock(&pci_lock);
list_for_each_entry(pdrv, &pci_drivers, links) {
for (id = pdrv->id_table; id->vendor != 0; id++) {
if (vendor == id->vendor && device == id->device) {
if (vendor == id->vendor &&
(PCI_ANY_ID == id->device || device == id->device) &&
(PCI_ANY_ID == id->subvendor || subvendor == id->subvendor) &&
(PCI_ANY_ID == id->subdevice || subdevice == id->subdevice)) {
*idp = id;
spin_unlock(&pci_lock);
return (pdrv);
@ -145,8 +152,8 @@ linux_pci_attach(device_t dev)
pdev->dev.bsddev = dev;
INIT_LIST_HEAD(&pdev->dev.irqents);
pdev->devfn = PCI_DEVFN(pci_get_slot(dev), pci_get_function(dev));
pdev->device = id->device;
pdev->vendor = id->vendor;
pdev->device = dinfo->cfg.device;
pdev->vendor = dinfo->cfg.vendor;
pdev->subsystem_vendor = dinfo->cfg.subvendor;
pdev->subsystem_device = dinfo->cfg.subdevice;
pdev->class = pci_get_class(dev);

View File

@ -2121,7 +2121,6 @@ device ath_hal # pci/cardbus chip support
#device ath_rf5112
#device ath_rf5413
#device ath_ar5416 # AR5416 chips
options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors
# All of the AR5212 parts have a problem when paired with the AR71xx
# CPUS. These parts have a bug that triggers a fatal bus error on the AR71xx
# only. Details of the exact nature of the bug are sketchy, but some can be

View File

@ -3883,6 +3883,8 @@ kern/subr_capability.c standard
kern/subr_clock.c standard
kern/subr_compressor.c standard \
compile-with "${NORMAL_C} -I$S/contrib/zstd/lib/freebsd"
kern/subr_coverage.c optional coverage \
compile-with "${NORMAL_C} -fno-sanitize=all"
kern/subr_counter.c standard
kern/subr_devstat.c standard
kern/subr_disk.c standard

View File

@ -492,12 +492,16 @@ i386/i386/longrun.c optional cpu_enable_longrun
i386/i386/machdep.c standard
i386/i386/mem.c optional mem
i386/i386/minidump_machdep.c standard
i386/i386/minidump_machdep_pae.c standard
i386/i386/minidump_machdep_nopae.c standard
i386/i386/mp_clock.c optional smp
i386/i386/mp_machdep.c optional smp
i386/i386/mpboot.s optional smp
i386/i386/npx.c standard
i386/i386/perfmon.c optional perfmon
i386/i386/pmap.c standard
i386/i386/pmap_base.c standard
i386/i386/pmap_nopae.c standard
i386/i386/pmap_pae.c standard
i386/i386/prof_machdep.c optional profiling-routine
i386/i386/ptrace_machdep.c standard
i386/i386/sigtramp.s standard

View File

@ -118,8 +118,8 @@ KUBSAN_ENABLED!= grep KUBSAN opt_global.h || true ; echo
SAN_CFLAGS+= -fsanitize=undefined
.endif
KCOV_ENABLED!= grep KCOV opt_kcov.h || true ; echo
.if !empty(KCOV_ENABLED)
COVERAGE_ENABLED!= grep COVERAGE opt_global.h || true ; echo
.if !empty(COVERAGE_ENABLED)
SAN_CFLAGS+= -fsanitize-coverage=trace-pc,trace-cmp
.endif

View File

@ -57,7 +57,6 @@ DDB_CTF opt_ddb.h
DDB_NUMSYM opt_ddb.h
FULL_BUF_TRACKING opt_global.h
GDB
KCOV opt_kcov.h
KDB opt_global.h
KDB_TRACE opt_kdb.h
KDB_UNATTENDED opt_kdb.h
@ -234,6 +233,8 @@ VERBOSE_SYSINIT
ZSTDIO opt_zstdio.h
# Sanitizers
COVERAGE opt_global.h
KCOV
KUBSAN opt_global.h
# POSIX kernel options
@ -828,7 +829,6 @@ ATH_DEBUG_ALQ opt_ath.h
ATH_KTR_INTR_DEBUG opt_ath.h
# options for the Atheros hal
AH_SUPPORT_AR5416 opt_ah.h
# XXX For now, this breaks non-AR9130 chipsets, so only use it
# XXX when actually targeting AR9130.
AH_SUPPORT_AR9130 opt_ah.h

View File

@ -33,11 +33,6 @@ KVA_PAGES opt_global.h
# Physical address extensions and support for >4G ram. As above.
PAE opt_global.h
# Use PAE page tables, but limit memory support to 4GB.
# This keeps the i386 non-PAE KBI, in particular, drivers see
# 32bit vm_paddr_t.
PAE_TABLES opt_global.h
TIMER_FREQ opt_clock.h
CPU_ATHLON_SSE_HACK opt_cpu.h

View File

@ -1036,7 +1036,7 @@ bhnd_pmu_res_init(struct bhnd_pmu_softc *sc)
return (error);
}
PMU_DEBUG(sc, "Applying %s=%s to rsrc %d res_updn_timer\n",
PMU_DEBUG(sc, "Applying %s=%d to rsrc %d res_updn_timer\n",
name, val, i);
BHND_PMU_WRITE_4(sc, BHND_PMU_RES_TABLE_SEL, i);
@ -1111,7 +1111,7 @@ bhnd_pmu_res_init(struct bhnd_pmu_softc *sc)
return (error);
}
PMU_DEBUG(sc, "Applying %s=%s to rsrc %d res_dep_mask\n", name,
PMU_DEBUG(sc, "Applying %s=%d to rsrc %d res_dep_mask\n", name,
val, i);
BHND_PMU_WRITE_4(sc, BHND_PMU_RES_TABLE_SEL, i);

View File

@ -307,9 +307,6 @@ static const struct {
[108] = { 7, 3 }
};
static const uint8_t bwi_chan_2ghz[] =
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
#ifdef BWI_DEBUG
#ifdef BWI_DEBUG_VERBOSE
static uint32_t bwi_debug = BWI_DBG_ATTACH | BWI_DBG_INIT | BWI_DBG_TXPOWER;
@ -1715,8 +1712,7 @@ bwi_getradiocaps(struct ieee80211com *ic,
panic("unknown phymode %d\n", phy->phy_mode);
}
ieee80211_add_channel_list_2ghz(chans, maxchans, nchans,
bwi_chan_2ghz, nitems(bwi_chan_2ghz), bands, 0);
ieee80211_add_channels_default_2ghz(chans, maxchans, nchans, bands, 0);
}
static void

View File

@ -207,7 +207,7 @@ _c4iw_write_mem_dma(struct c4iw_rdev *rdev, u32 addr, u32 len, void *data)
if (ret)
goto out;
addr += dmalen >> 5;
data = (u64 *)data + dmalen;
data = (u8 *)data + dmalen;
daddr = daddr + dmalen;
}
if (remain)

View File

@ -42,10 +42,14 @@
#include <sys/syslog.h>
#include <dev/pci/pcireg.h>
#define CH_ERR(adap, fmt, ...) log(LOG_ERR, fmt, ##__VA_ARGS__)
#define CH_WARN(adap, fmt, ...) log(LOG_WARNING, fmt, ##__VA_ARGS__)
#define CH_ALERT(adap, fmt, ...) log(LOG_ALERT, fmt, ##__VA_ARGS__)
#define CH_WARN_RATELIMIT(adap, fmt, ...) log(LOG_WARNING, fmt, ##__VA_ARGS__)
#define CH_ERR(adap, fmt, ...) log(LOG_ERR, "%s: " fmt, \
device_get_nameunit(adap->dev), ##__VA_ARGS__)
#define CH_WARN(adap, fmt, ...) log(LOG_WARNING, "%s: " fmt, \
device_get_nameunit(adap->dev), ##__VA_ARGS__)
#define CH_ALERT(adap, fmt, ...) log(LOG_ALERT, "%s: " fmt, \
device_get_nameunit(adap->dev), ##__VA_ARGS__)
#define CH_WARN_RATELIMIT(adap, fmt, ...) log(LOG_WARNING, "%s: " fmt, \
device_get_nameunit(adap->dev), ##__VA_ARGS__)
#ifndef LINUX_TYPES_DEFINED
typedef int8_t s8;

View File

@ -5524,6 +5524,8 @@ vi_full_uninit(struct vi_info *vi)
struct sge_txq *txq;
#ifdef TCP_OFFLOAD
struct sge_ofld_rxq *ofld_rxq;
#endif
#if defined(TCP_OFFLOAD) || defined(RATELIMIT)
struct sge_wrq *ofld_txq;
#endif
@ -5539,7 +5541,7 @@ vi_full_uninit(struct vi_info *vi)
quiesce_txq(sc, txq);
}
#ifdef TCP_OFFLOAD
#if defined(TCP_OFFLOAD) || defined(RATELIMIT)
for_each_ofld_txq(vi, i, ofld_txq) {
quiesce_wrq(sc, ofld_txq);
}
@ -6327,15 +6329,9 @@ vi_sysctls(struct vi_info *vi)
SYSCTL_ADD_INT(ctx, children, OID_AUTO, "nofldrxq", CTLFLAG_RD,
&vi->nofldrxq, 0,
"# of rx queues for offloaded TCP connections");
SYSCTL_ADD_INT(ctx, children, OID_AUTO, "nofldtxq", CTLFLAG_RD,
&vi->nofldtxq, 0,
"# of tx queues for offloaded TCP connections");
SYSCTL_ADD_INT(ctx, children, OID_AUTO, "first_ofld_rxq",
CTLFLAG_RD, &vi->first_ofld_rxq, 0,
"index of first TOE rx queue");
SYSCTL_ADD_INT(ctx, children, OID_AUTO, "first_ofld_txq",
CTLFLAG_RD, &vi->first_ofld_txq, 0,
"index of first TOE tx queue");
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "holdoff_tmr_idx_ofld",
CTLTYPE_INT | CTLFLAG_RW, vi, 0,
sysctl_holdoff_tmr_idx_ofld, "I",
@ -6346,6 +6342,16 @@ vi_sysctls(struct vi_info *vi)
"holdoff packet counter index for TOE queues");
}
#endif
#if defined(TCP_OFFLOAD) || defined(RATELIMIT)
if (vi->nofldtxq != 0) {
SYSCTL_ADD_INT(ctx, children, OID_AUTO, "nofldtxq", CTLFLAG_RD,
&vi->nofldtxq, 0,
"# of tx queues for TOE/ETHOFLD");
SYSCTL_ADD_INT(ctx, children, OID_AUTO, "first_ofld_txq",
CTLFLAG_RD, &vi->first_ofld_txq, 0,
"index of first TOE/ETHOFLD tx queue");
}
#endif
#ifdef DEV_NETMAP
if (vi->nnmrxq != 0) {
SYSCTL_ADD_INT(ctx, children, OID_AUTO, "nnmrxq", CTLFLAG_RD,
@ -10011,7 +10017,7 @@ t4_ioctl(struct cdev *dev, unsigned long cmd, caddr_t data, int fflag,
mp_ring_reset_stats(txq->r);
}
#ifdef TCP_OFFLOAD
#if defined(TCP_OFFLOAD) || defined(RATELIMIT)
/* nothing to clear for each ofld_rxq */
for_each_ofld_txq(vi, i, wrq) {

View File

@ -309,7 +309,7 @@ dcons_drv_init(int stage)
* Allow read/write access to dcons buffer.
*/
for (pa = trunc_page(addr); pa < addr + size; pa += PAGE_SIZE)
*vtopte(PMAP_MAP_LOW + pa) |= PG_RW;
pmap_ksetrw(PMAP_MAP_LOW + pa);
invltlb();
#endif
/* XXX P to V */

View File

@ -457,16 +457,11 @@ em_isc_txd_credits_update(void *arg, uint16_t txqid, bool clear)
prev = txr->tx_cidx_processed;
ntxd = scctx->isc_ntxd[0];
do {
MPASS(prev != cur);
delta = (int32_t)cur - (int32_t)prev;
/*
* XXX This appears to be a hack for first-packet.
* A correct fix would prevent prev == cur in the first place.
*/
MPASS(prev == 0 || delta != 0);
if (prev == 0 && cur == 0)
delta += 1;
if (delta < 0)
delta += ntxd;
MPASS(delta > 0);
DPRINTF(iflib_get_dev(adapter->ctx),
"%s: cidx_processed=%u cur=%u clear=%d delta=%d\n",
__FUNCTION__, prev, cur, clear, delta);

View File

@ -1208,6 +1208,7 @@ static void
em_if_init(if_ctx_t ctx)
{
struct adapter *adapter = iflib_get_softc(ctx);
if_softc_ctx_t scctx = adapter->shared;
struct ifnet *ifp = iflib_get_ifp(ctx);
struct em_tx_queue *tx_que;
int i;
@ -1240,7 +1241,14 @@ em_if_init(if_ctx_t ctx)
for (i = 0, tx_que = adapter->tx_queues; i < adapter->tx_num_queues; i++, tx_que++) {
struct tx_ring *txr = &tx_que->txr;
txr->tx_rs_cidx = txr->tx_rs_pidx = txr->tx_cidx_processed = 0;
txr->tx_rs_cidx = txr->tx_rs_pidx;
/* Initialize the last processed descriptor to be the end of
* the ring, rather than the start, so that we avoid an
* off-by-one error when calculating how many descriptors are
* done in the credits_update function.
*/
txr->tx_cidx_processed = scctx->isc_ntxd[0] - 1;
}
/* Setup VLAN support, basic and offload if available */

View File

@ -332,16 +332,11 @@ igb_isc_txd_credits_update(void *arg, uint16_t txqid, bool clear)
prev = txr->tx_cidx_processed;
ntxd = scctx->isc_ntxd[0];
do {
MPASS(prev != cur);
delta = (int32_t)cur - (int32_t)prev;
/*
* XXX This appears to be a hack for first-packet.
* A correct fix would prevent prev == cur in the first place.
*/
MPASS(prev == 0 || delta != 0);
if (prev == 0 && cur == 0)
delta += 1;
if (delta < 0)
delta += ntxd;
MPASS(delta > 0);
processed += delta;
prev = cur;

View File

@ -68,7 +68,7 @@ static phynode_method_t phynode_methods[] = {
DEFINE_CLASS_0(phynode, phynode_class, phynode_methods, 0);
static phynode_list_t phynode_list = TAILQ_HEAD_INITIALIZER(phynode_list);
struct sx phynode_topo_lock;
SX_SYSINIT(phy_topology, &phynode_topo_lock, "Phy topology lock");
/* ----------------------------------------------------------------------------

View File

@ -78,6 +78,6 @@ struct phy {
#define PHYNODE_XLOCK(_sc) sx_xlock(&((_sc)->lock))
#define PHYNODE_UNLOCK(_sc) sx_unlock(&((_sc)->lock))
struct sx phynode_topo_lock;
extern struct sx phynode_topo_lock;
#endif /* DEV_EXTRES_PHY_INTERNAL_H */

View File

@ -513,7 +513,7 @@ int genfbioctl(genfb_softc_t *sc, video_adapter_t *adp, u_long cmd,
}
int genfbmmap(genfb_softc_t *sc, video_adapter_t *adp, vm_ooffset_t offset,
vm_offset_t *paddr, int prot, vm_memattr_t *memattr)
vm_paddr_t *paddr, int prot, vm_memattr_t *memattr)
{
return vidd_mmap(adp, offset, paddr, prot, memattr);
}

View File

@ -327,7 +327,7 @@ int genfbwrite(genfb_softc_t *sc, video_adapter_t *adp,
int genfbioctl(genfb_softc_t *sc, video_adapter_t *adp,
u_long cmd, caddr_t arg, int flag, struct thread *td);
int genfbmmap(genfb_softc_t *sc, video_adapter_t *adp,
vm_ooffset_t offset, vm_offset_t *paddr,
vm_ooffset_t offset, vm_paddr_t *paddr,
int prot, vm_memattr_t *memattr);
#endif /* FB_INSTALL_CDEV */

View File

@ -147,7 +147,7 @@ vga_ioctl(struct cdev *dev, vga_softc_t *sc, u_long cmd, caddr_t arg, int flag,
int
vga_mmap(struct cdev *dev, vga_softc_t *sc, vm_ooffset_t offset,
vm_offset_t *paddr, int prot, vm_memattr_t *memattr)
vm_paddr_t *paddr, int prot, vm_memattr_t *memattr)
{
return genfbmmap(&sc->gensc, sc->adp, offset, paddr, prot, memattr);
}

View File

@ -91,7 +91,7 @@ int vga_write(struct cdev *dev, vga_softc_t *sc, struct uio *uio, int flag);
int vga_ioctl(struct cdev *dev, vga_softc_t *sc, u_long cmd, caddr_t arg,
int flag, struct thread *td);
int vga_mmap(struct cdev *dev, vga_softc_t *sc, vm_ooffset_t offset,
vm_offset_t *paddr, int prot, vm_memattr_t *memattr);
vm_paddr_t *paddr, int prot, vm_memattr_t *memattr);
#endif
extern int (*vga_sub_configure)(int flags);

View File

@ -132,8 +132,6 @@ static const struct iwi_ident iwi_ident_table[] = {
{ 0, 0, NULL }
};
static const uint8_t def_chan_2ghz[] =
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
static const uint8_t def_chan_5ghz_band1[] =
{ 36, 40, 44, 48, 52, 56, 60, 64 };
static const uint8_t def_chan_5ghz_band2[] =
@ -3604,8 +3602,8 @@ iwi_getradiocaps(struct ieee80211com *ic,
iwi_collect_bands(ic, bands, sizeof(bands));
*nchans = 0;
if (isset(bands, IEEE80211_MODE_11B) || isset(bands, IEEE80211_MODE_11G))
ieee80211_add_channel_list_2ghz(chans, maxchans, nchans,
def_chan_2ghz, nitems(def_chan_2ghz), bands, 0);
ieee80211_add_channels_default_2ghz(chans, maxchans, nchans,
bands, 0);
if (isset(bands, IEEE80211_MODE_11A)) {
ieee80211_add_channel_list_5ghz(chans, maxchans, nchans,
def_chan_5ghz_band1, nitems(def_chan_5ghz_band1),

File diff suppressed because it is too large Load Diff

View File

@ -80,6 +80,8 @@ enum iwm_device_family {
IWM_DEVICE_FAMILY_8000,
};
#define IWM_DEFAULT_MAX_TX_POWER 22
/* Antenna presence definitions */
#define IWM_ANT_NONE 0x0
#define IWM_ANT_A (1 << 0)

View File

@ -44,6 +44,7 @@ enum {
IWM_DEBUG_TEMP = 0x00100000, /* Thermal Sensor handling */
IWM_DEBUG_FW = 0x00200000, /* Firmware management */
IWM_DEBUG_LAR = 0x00400000, /* Location Aware Regulatory */
IWM_DEBUG_TE = 0x00800000, /* Time Event handling */
IWM_DEBUG_REGISTER = 0x20000000, /* print chipset register */
IWM_DEBUG_TRACE = 0x40000000, /* Print begin and start driver function */
IWM_DEBUG_FATAL = 0x80000000, /* fatal errors */

View File

@ -141,7 +141,7 @@ iwm_free_fw_paging(struct iwm_softc *sc)
}
static int
iwm_fill_paging_mem(struct iwm_softc *sc, const struct iwm_fw_sects *image)
iwm_fill_paging_mem(struct iwm_softc *sc, const struct iwm_fw_img *image)
{
int sec_idx, idx;
uint32_t offset = 0;
@ -158,7 +158,7 @@ iwm_fill_paging_mem(struct iwm_softc *sc, const struct iwm_fw_sects *image)
* CPU2 paging image (including instruction and data)
*/
for (sec_idx = 0; sec_idx < IWM_UCODE_SECTION_MAX; sec_idx++) {
if (image->fw_sect[sec_idx].offset == IWM_PAGING_SEPARATOR_SECTION) {
if (image->sec[sec_idx].offset == IWM_PAGING_SEPARATOR_SECTION) {
sec_idx++;
break;
}
@ -168,7 +168,7 @@ iwm_fill_paging_mem(struct iwm_softc *sc, const struct iwm_fw_sects *image)
* If paging is enabled there should be at least 2 more sections left
* (one for CSS and one for Paging data)
*/
if (sec_idx >= nitems(image->fw_sect) - 1) {
if (sec_idx >= nitems(image->sec) - 1) {
device_printf(sc->sc_dev,
"Paging: Missing CSS and/or paging sections\n");
iwm_free_fw_paging(sc);
@ -181,7 +181,7 @@ iwm_fill_paging_mem(struct iwm_softc *sc, const struct iwm_fw_sects *image)
sec_idx);
memcpy(sc->fw_paging_db[0].fw_paging_block.vaddr,
image->fw_sect[sec_idx].data,
image->sec[sec_idx].data,
sc->fw_paging_db[0].fw_paging_size);
IWM_DPRINTF(sc, IWM_DEBUG_FW,
@ -198,7 +198,7 @@ iwm_fill_paging_mem(struct iwm_softc *sc, const struct iwm_fw_sects *image)
*/
for (idx = 1; idx < sc->num_of_paging_blk; idx++) {
memcpy(sc->fw_paging_db[idx].fw_paging_block.vaddr,
(const char *)image->fw_sect[sec_idx].data + offset,
(const char *)image->sec[sec_idx].data + offset,
sc->fw_paging_db[idx].fw_paging_size);
IWM_DPRINTF(sc, IWM_DEBUG_FW,
@ -212,7 +212,7 @@ iwm_fill_paging_mem(struct iwm_softc *sc, const struct iwm_fw_sects *image)
/* copy the last paging block */
if (sc->num_of_pages_in_last_blk > 0) {
memcpy(sc->fw_paging_db[idx].fw_paging_block.vaddr,
(const char *)image->fw_sect[sec_idx].data + offset,
(const char *)image->sec[sec_idx].data + offset,
IWM_FW_PAGING_SIZE * sc->num_of_pages_in_last_blk);
IWM_DPRINTF(sc, IWM_DEBUG_FW,
@ -224,7 +224,7 @@ iwm_fill_paging_mem(struct iwm_softc *sc, const struct iwm_fw_sects *image)
}
static int
iwm_alloc_fw_paging_mem(struct iwm_softc *sc, const struct iwm_fw_sects *image)
iwm_alloc_fw_paging_mem(struct iwm_softc *sc, const struct iwm_fw_img *image)
{
int blk_idx = 0;
int error, num_of_pages;
@ -298,7 +298,7 @@ iwm_alloc_fw_paging_mem(struct iwm_softc *sc, const struct iwm_fw_sects *image)
}
int
iwm_save_fw_paging(struct iwm_softc *sc, const struct iwm_fw_sects *fw)
iwm_save_fw_paging(struct iwm_softc *sc, const struct iwm_fw_img *fw)
{
int ret;
@ -311,7 +311,7 @@ iwm_save_fw_paging(struct iwm_softc *sc, const struct iwm_fw_sects *fw)
/* send paging cmd to FW in case CPU2 has paging image */
int
iwm_send_paging_cmd(struct iwm_softc *sc, const struct iwm_fw_sects *fw)
iwm_send_paging_cmd(struct iwm_softc *sc, const struct iwm_fw_img *fw)
{
int blk_idx;
uint32_t dev_phy_addr;

View File

@ -107,7 +107,7 @@
#define IWM_PAGING_TLV_SECURE_MASK 1
extern void iwm_free_fw_paging(struct iwm_softc *);
extern int iwm_save_fw_paging(struct iwm_softc *, const struct iwm_fw_sects *);
extern int iwm_send_paging_cmd(struct iwm_softc *, const struct iwm_fw_sects *);
extern int iwm_save_fw_paging(struct iwm_softc *, const struct iwm_fw_img *);
extern int iwm_send_paging_cmd(struct iwm_softc *, const struct iwm_fw_img *);
#endif /* __IF_IWM_FW_H__ */

View File

@ -162,6 +162,9 @@ iwm_led_blink_timeout(void *arg)
{
struct iwm_softc *sc = arg;
if (sc->sc_attached == 0)
return;
if (iwm_mvm_led_is_enabled(sc))
iwm_mvm_led_disable(sc);
else

View File

@ -309,7 +309,12 @@ iwm_mvm_mac_ctxt_cmd_common(struct iwm_softc *sc, struct iwm_node *in,
* iwm_mvm_mac_ctxt_changed() when already authenticating or
* associating, ni->ni_bssid should always make sense here.
*/
IEEE80211_ADDR_COPY(cmd->bssid_addr, ni->ni_bssid);
if (ivp->iv_auth) {
IEEE80211_ADDR_COPY(cmd->bssid_addr, ni->ni_bssid);
} else {
/* XXX Or maybe all zeroes address? */
IEEE80211_ADDR_COPY(cmd->bssid_addr, ieee80211broadcastaddr);
}
#endif
/*

View File

@ -406,18 +406,39 @@ iwm_prepare_card_hw(struct iwm_softc *sc)
void
iwm_apm_config(struct iwm_softc *sc)
{
uint16_t reg;
uint16_t lctl, cap;
int pcie_ptr;
reg = pci_read_config(sc->sc_dev, PCIER_LINK_CTL, sizeof(reg));
if (reg & PCIEM_LINK_CTL_ASPMC_L1) {
/* Um the Linux driver prints "Disabling L0S for this one ... */
/*
* HW bug W/A for instability in PCIe bus L0S->L1 transition.
* Check if BIOS (or OS) enabled L1-ASPM on this device.
* If so (likely), disable L0S, so device moves directly L0->L1;
* costs negligible amount of power savings.
* If not (unlikely), enable L0S, so there is at least some
* power savings, even without L1.
*/
int error;
error = pci_find_cap(sc->sc_dev, PCIY_EXPRESS, &pcie_ptr);
if (error != 0)
return;
lctl = pci_read_config(sc->sc_dev, pcie_ptr + PCIER_LINK_CTL,
sizeof(lctl));
if (lctl & PCIEM_LINK_CTL_ASPMC_L1) {
IWM_SETBITS(sc, IWM_CSR_GIO_REG,
IWM_CSR_GIO_REG_VAL_L0S_ENABLED);
} else {
/* ... and "Enabling" here */
IWM_CLRBITS(sc, IWM_CSR_GIO_REG,
IWM_CSR_GIO_REG_VAL_L0S_ENABLED);
}
cap = pci_read_config(sc->sc_dev, pcie_ptr + PCIER_DEVICE_CTL2,
sizeof(cap));
sc->sc_ltr_enabled = (cap & PCIEM_CTL2_LTR_ENABLE) ? 1 : 0;
IWM_DPRINTF(sc, IWM_DEBUG_RESET | IWM_DEBUG_PWRSAVE,
"L1 %sabled - LTR %sabled\n",
(lctl & PCIEM_LINK_CTL_ASPMC_L1) ? "En" : "Dis",
sc->sc_ltr_enabled ? "En" : "Dis");
}
/*

View File

@ -390,7 +390,7 @@ static uint8_t
ch_id_to_ch_index(uint16_t ch_id)
{
if (!is_valid_channel(ch_id))
return 0xff;
return 0xff;
if (ch_id <= 14)
return ch_id - 1;
@ -509,7 +509,7 @@ iwm_phy_db_send_all_channel_groups(struct iwm_phy_db *phy_db,
int err;
struct iwm_phy_db_entry *entry;
/* Send all the channel specific groups to operational fw */
/* Send all the channel specific groups to operational fw */
for (i = 0; i < max_ch_groups; i++) {
entry = iwm_phy_db_get_section(phy_db,
type,

View File

@ -215,7 +215,7 @@ static inline boolean_t
iwm_mvm_rrm_scan_needed(struct iwm_softc *sc)
{
/* require rrm scan whenever the fw supports it */
return fw_has_capa(&sc->ucode_capa,
return fw_has_capa(&sc->sc_fw.ucode_capa,
IWM_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT);
}
@ -251,7 +251,7 @@ iwm_mvm_rx_lmac_scan_complete_notif(struct iwm_softc *sc,
/* If this happens, the firmware has mistakenly sent an LMAC
* notification during UMAC scans -- warn and ignore it.
*/
if (fw_has_capa(&sc->ucode_capa, IWM_UCODE_TLV_CAPA_UMAC_SCAN)) {
if (fw_has_capa(&sc->sc_fw.ucode_capa, IWM_UCODE_TLV_CAPA_UMAC_SCAN)) {
device_printf(sc->sc_dev,
"%s: Mistakenly got LMAC notification during UMAC scan\n",
__func__);
@ -307,7 +307,8 @@ iwm_mvm_lmac_scan_fill_channels(struct iwm_softc *sc,
int j;
for (nchan = j = 0;
j < ss->ss_last && nchan < sc->ucode_capa.n_scan_channels; j++) {
j < ss->ss_last && nchan < sc->sc_fw.ucode_capa.n_scan_channels;
j++) {
c = ss->ss_chans[j];
/*
* Catch other channels, in case we have 900MHz channels or
@ -350,7 +351,8 @@ iwm_mvm_umac_scan_fill_channels(struct iwm_softc *sc,
int j;
for (nchan = j = 0;
j < ss->ss_last && nchan < sc->ucode_capa.n_scan_channels; j++) {
j < ss->ss_last && nchan < sc->sc_fw.ucode_capa.n_scan_channels;
j++) {
c = ss->ss_chans[j];
/*
* Catch other channels, in case we have 900MHz channels or
@ -495,7 +497,7 @@ iwm_mvm_config_umac_scan(struct iwm_softc *sc)
IWM_SCAN_CONFIG_RATE_36M | IWM_SCAN_CONFIG_RATE_48M |
IWM_SCAN_CONFIG_RATE_54M);
cmd_size = sizeof(*scan_config) + sc->ucode_capa.n_scan_channels;
cmd_size = sizeof(*scan_config) + sc->sc_fw.ucode_capa.n_scan_channels;
scan_config = malloc(cmd_size, M_DEVBUF, M_NOWAIT | M_ZERO);
if (scan_config == NULL)
@ -523,7 +525,8 @@ iwm_mvm_config_umac_scan(struct iwm_softc *sc)
IWM_CHANNEL_FLAG_PRE_SCAN_PASSIVE2ACTIVE;
for (nchan = j = 0;
j < ic->ic_nchans && nchan < sc->ucode_capa.n_scan_channels; j++) {
j < ic->ic_nchans && nchan < sc->sc_fw.ucode_capa.n_scan_channels;
j++) {
c = &ic->ic_channels[j];
/* For 2GHz, only populate 11b channels */
/* For 5GHz, only populate 11a channels */
@ -566,7 +569,7 @@ iwm_mvm_config_umac_scan(struct iwm_softc *sc)
static boolean_t
iwm_mvm_scan_use_ebs(struct iwm_softc *sc)
{
const struct iwm_ucode_capabilities *capa = &sc->ucode_capa;
const struct iwm_ucode_capabilities *capa = &sc->sc_fw.ucode_capa;
/* We can only use EBS if:
* 1. the feature is supported;
@ -596,7 +599,7 @@ iwm_mvm_umac_scan(struct iwm_softc *sc)
req_len = sizeof(struct iwm_scan_req_umac) +
(sizeof(struct iwm_scan_channel_cfg_umac) *
sc->ucode_capa.n_scan_channels) +
sc->sc_fw.ucode_capa.n_scan_channels) +
sizeof(struct iwm_scan_req_umac_tail);
if (req_len > IWM_MAX_CMD_PAYLOAD_SIZE)
return ENOMEM;
@ -630,7 +633,7 @@ iwm_mvm_umac_scan(struct iwm_softc *sc)
tail = (void *)((char *)&req->data +
sizeof(struct iwm_scan_channel_cfg_umac) *
sc->ucode_capa.n_scan_channels);
sc->sc_fw.ucode_capa.n_scan_channels);
/* Check if we're doing an active directed scan. */
for (i = 0; i < nssid; i++) {
@ -694,7 +697,7 @@ iwm_mvm_lmac_scan(struct iwm_softc *sc)
req_len = sizeof(struct iwm_scan_req_lmac) +
(sizeof(struct iwm_scan_channel_cfg_lmac) *
sc->ucode_capa.n_scan_channels) + sizeof(struct iwm_scan_probe_req);
sc->sc_fw.ucode_capa.n_scan_channels) + sizeof(struct iwm_scan_probe_req);
if (req_len > IWM_MAX_CMD_PAYLOAD_SIZE)
return ENOMEM;
req = malloc(req_len, M_DEVBUF, M_NOWAIT | M_ZERO);
@ -764,7 +767,7 @@ iwm_mvm_lmac_scan(struct iwm_softc *sc)
ret = iwm_mvm_fill_probe_req(sc,
(struct iwm_scan_probe_req *)(req->data +
(sizeof(struct iwm_scan_channel_cfg_lmac) *
sc->ucode_capa.n_scan_channels)));
sc->sc_fw.ucode_capa.n_scan_channels)));
if (ret) {
free(req, M_DEVBUF);
return ret;
@ -863,7 +866,7 @@ iwm_mvm_scan_stop_wait(struct iwm_softc *sc)
IWM_DPRINTF(sc, IWM_DEBUG_SCAN, "Preparing to stop scan\n");
if (fw_has_capa(&sc->ucode_capa, IWM_UCODE_TLV_CAPA_UMAC_SCAN))
if (fw_has_capa(&sc->sc_fw.ucode_capa, IWM_UCODE_TLV_CAPA_UMAC_SCAN))
ret = iwm_mvm_umac_scan_abort(sc);
else
ret = iwm_mvm_lmac_scan_abort(sc);

View File

@ -286,7 +286,7 @@ iwm_mvm_rm_sta(struct iwm_softc *sc, struct ieee80211vap *vap,
for (ac = 0; ac < WME_NUM_AC; ac++) {
tfd_queue_msk |= htole32(1 << iwm_mvm_ac_to_tx_fifo[ac]);
}
ret = iwm_mvm_flush_tx_path(sc, tfd_queue_msk, 0);
ret = iwm_mvm_flush_tx_path(sc, tfd_queue_msk, IWM_CMD_SYNC);
if (ret)
return ret;
#ifdef notyet /* function not yet implemented */

View File

@ -155,31 +155,188 @@ __FBSDID("$FreeBSD$");
#include <dev/iwm/if_iwmvar.h>
#include <dev/iwm/if_iwm_debug.h>
#include <dev/iwm/if_iwm_util.h>
#include <dev/iwm/if_iwm_notif_wait.h>
#include <dev/iwm/if_iwm_pcie_trans.h>
#include <dev/iwm/if_iwm_time_event.h>
#define TU_TO_HZ(tu) (((uint64_t)(tu) * 1024 * hz) / 1000000)
static void
iwm_mvm_te_clear_data(struct iwm_softc *sc)
{
sc->sc_time_event_uid = 0;
sc->sc_time_event_duration = 0;
sc->sc_time_event_end_ticks = 0;
sc->sc_flags &= ~IWM_FLAG_TE_ACTIVE;
}
/*
* For the high priority TE use a time event type that has similar priority to
* the FW's action scan priority.
* Handles a FW notification for an event that is known to the driver.
*
* @mvm: the mvm component
* @te_data: the time event data
* @notif: the notification data corresponding the time event data.
*/
#define IWM_MVM_ROC_TE_TYPE_NORMAL IWM_TE_P2P_DEVICE_DISCOVERABLE
#define IWM_MVM_ROC_TE_TYPE_MGMT_TX IWM_TE_P2P_CLIENT_ASSOC
static void
iwm_mvm_te_handle_notif(struct iwm_softc *sc,
struct iwm_time_event_notif *notif)
{
IWM_DPRINTF(sc, IWM_DEBUG_TE,
"Handle time event notif - UID = 0x%x action %d\n",
le32toh(notif->unique_id),
le32toh(notif->action));
if (!le32toh(notif->status)) {
const char *msg;
if (notif->action & htole32(IWM_TE_V2_NOTIF_HOST_EVENT_START))
msg = "Time Event start notification failure";
else
msg = "Time Event end notification failure";
IWM_DPRINTF(sc, IWM_DEBUG_TE, "%s\n", msg);
}
if (le32toh(notif->action) & IWM_TE_V2_NOTIF_HOST_EVENT_END) {
IWM_DPRINTF(sc, IWM_DEBUG_TE,
"TE ended - current time %d, estimated end %d\n",
ticks, sc->sc_time_event_end_ticks);
iwm_mvm_te_clear_data(sc);
} else if (le32toh(notif->action) & IWM_TE_V2_NOTIF_HOST_EVENT_START) {
sc->sc_time_event_end_ticks =
ticks + TU_TO_HZ(sc->sc_time_event_duration);
} else {
device_printf(sc->sc_dev, "Got TE with unknown action\n");
}
}
/*
* The Rx handler for time event notifications
*/
void
iwm_mvm_rx_time_event_notif(struct iwm_softc *sc, struct iwm_rx_packet *pkt)
{
struct iwm_time_event_notif *notif = (void *)pkt->data;
IWM_DPRINTF(sc, IWM_DEBUG_TE,
"Time event notification - UID = 0x%x action %d\n",
le32toh(notif->unique_id),
le32toh(notif->action));
iwm_mvm_te_handle_notif(sc, notif);
}
static int
iwm_mvm_te_notif(struct iwm_softc *sc, struct iwm_rx_packet *pkt,
void *data)
{
struct iwm_time_event_notif *resp;
int resp_len = iwm_rx_packet_payload_len(pkt);
if (pkt->hdr.code != IWM_TIME_EVENT_NOTIFICATION ||
resp_len != sizeof(*resp)) {
IWM_DPRINTF(sc, IWM_DEBUG_TE,
"Invalid TIME_EVENT_NOTIFICATION response\n");
return 1;
}
resp = (void *)pkt->data;
/* te_data->uid is already set in the TIME_EVENT_CMD response */
if (le32toh(resp->unique_id) != sc->sc_time_event_uid)
return false;
IWM_DPRINTF(sc, IWM_DEBUG_TE,
"TIME_EVENT_NOTIFICATION response - UID = 0x%x\n",
sc->sc_time_event_uid);
if (!resp->status) {
IWM_DPRINTF(sc, IWM_DEBUG_TE,
"TIME_EVENT_NOTIFICATION received but not executed\n");
}
return 1;
}
static int
iwm_mvm_time_event_response(struct iwm_softc *sc, struct iwm_rx_packet *pkt,
void *data)
{
struct iwm_time_event_resp *resp;
int resp_len = iwm_rx_packet_payload_len(pkt);
if (pkt->hdr.code != IWM_TIME_EVENT_CMD ||
resp_len != sizeof(*resp)) {
IWM_DPRINTF(sc, IWM_DEBUG_TE,
"Invalid TIME_EVENT_CMD response\n");
return 1;
}
resp = (void *)pkt->data;
/* we should never get a response to another TIME_EVENT_CMD here */
if (le32toh(resp->id) != IWM_TE_BSS_STA_AGGRESSIVE_ASSOC) {
IWM_DPRINTF(sc, IWM_DEBUG_TE,
"Got TIME_EVENT_CMD response with wrong id: %d\n",
le32toh(resp->id));
return 0;
}
sc->sc_time_event_uid = le32toh(resp->unique_id);
IWM_DPRINTF(sc, IWM_DEBUG_TE,
"TIME_EVENT_CMD response - UID = 0x%x\n", sc->sc_time_event_uid);
return 1;
}
/* XXX Use the te_data function argument properly, like in iwlwifi's code. */
static int
iwm_mvm_time_event_send_add(struct iwm_softc *sc, struct iwm_vap *ivp,
void *te_data, struct iwm_time_event_cmd *te_cmd)
{
static const uint16_t time_event_response[] = { IWM_TIME_EVENT_CMD };
struct iwm_notification_wait wait_time_event;
int ret;
IWM_DPRINTF(sc, IWM_DEBUG_CMD | IWM_DEBUG_RESET,
IWM_DPRINTF(sc, IWM_DEBUG_TE,
"Add new TE, duration %d TU\n", le32toh(te_cmd->duration));
ret = iwm_mvm_send_cmd_pdu(sc, IWM_TIME_EVENT_CMD, IWM_CMD_SYNC,
sizeof(*te_cmd), te_cmd);
sc->sc_time_event_duration = le32toh(te_cmd->duration);
/*
* Use a notification wait, which really just processes the
* command response and doesn't wait for anything, in order
* to be able to process the response and get the UID inside
* the RX path. Using CMD_WANT_SKB doesn't work because it
* stores the buffer and then wakes up this thread, by which
* time another notification (that the time event started)
* might already be processed unsuccessfully.
*/
iwm_init_notification_wait(sc->sc_notif_wait, &wait_time_event,
time_event_response,
nitems(time_event_response),
iwm_mvm_time_event_response, /*te_data*/NULL);
ret = iwm_mvm_send_cmd_pdu(sc, IWM_TIME_EVENT_CMD, 0, sizeof(*te_cmd),
te_cmd);
if (ret) {
IWM_DPRINTF(sc, IWM_DEBUG_CMD | IWM_DEBUG_RESET,
IWM_DPRINTF(sc, IWM_DEBUG_TE,
"%s: Couldn't send IWM_TIME_EVENT_CMD: %d\n",
__func__, ret);
iwm_remove_notification(sc->sc_notif_wait, &wait_time_event);
return ret;
}
/* No need to wait for anything, so just pass 1 (0 isn't valid) */
IWM_UNLOCK(sc);
ret = iwm_wait_notification(sc->sc_notif_wait, &wait_time_event, 1);
IWM_LOCK(sc);
/* should never fail */
if (ret) {
IWM_DPRINTF(sc, IWM_DEBUG_TE,
"%s: Failed to get response for IWM_TIME_EVENT_CMD: %d\n",
__func__, ret);
}
return ret;
@ -187,10 +344,16 @@ iwm_mvm_time_event_send_add(struct iwm_softc *sc, struct iwm_vap *ivp,
void
iwm_mvm_protect_session(struct iwm_softc *sc, struct iwm_vap *ivp,
uint32_t duration, uint32_t max_delay)
uint32_t duration, uint32_t max_delay, boolean_t wait_for_notif)
{
const uint16_t te_notif_response[] = { IWM_TIME_EVENT_NOTIFICATION };
struct iwm_notification_wait wait_te_notif;
struct iwm_time_event_cmd time_cmd = {};
/* Do nothing if a time event is already scheduled. */
if (sc->sc_flags & IWM_FLAG_TE_ACTIVE)
return;
time_cmd.action = htole32(IWM_FW_CTXT_ACTION_ADD);
time_cmd.id_and_color =
htole32(IWM_FW_CMD_ID_AND_COLOR(ivp->id, ivp->color));
@ -209,5 +372,58 @@ iwm_mvm_protect_session(struct iwm_softc *sc, struct iwm_vap *ivp,
IWM_TE_V2_NOTIF_HOST_EVENT_END |
IWM_T2_V2_START_IMMEDIATELY);
iwm_mvm_time_event_send_add(sc, ivp, /*te_data*/NULL, &time_cmd);
if (!wait_for_notif) {
iwm_mvm_time_event_send_add(sc, ivp, /*te_data*/NULL, &time_cmd);
DELAY(100);
sc->sc_flags |= IWM_FLAG_TE_ACTIVE;
return;
}
/*
* Create notification_wait for the TIME_EVENT_NOTIFICATION to use
* right after we send the time event
*/
iwm_init_notification_wait(sc->sc_notif_wait, &wait_te_notif,
te_notif_response, nitems(te_notif_response),
iwm_mvm_te_notif, /*te_data*/NULL);
/* If TE was sent OK - wait for the notification that started */
if (iwm_mvm_time_event_send_add(sc, ivp, /*te_data*/NULL, &time_cmd)) {
IWM_DPRINTF(sc, IWM_DEBUG_TE,
"%s: Failed to add TE to protect session\n", __func__);
iwm_remove_notification(sc->sc_notif_wait, &wait_te_notif);
} else {
sc->sc_flags |= IWM_FLAG_TE_ACTIVE;
IWM_UNLOCK(sc);
if (iwm_wait_notification(sc->sc_notif_wait, &wait_te_notif,
TU_TO_HZ(max_delay))) {
IWM_DPRINTF(sc, IWM_DEBUG_TE,
"%s: Failed to protect session until TE\n",
__func__);
}
IWM_LOCK(sc);
}
}
void
iwm_mvm_stop_session_protection(struct iwm_softc *sc, struct iwm_vap *ivp)
{
struct iwm_time_event_cmd time_cmd = {};
/* Do nothing if the time event has already ended. */
if ((sc->sc_flags & IWM_FLAG_TE_ACTIVE) == 0)
return;
time_cmd.id = htole32(sc->sc_time_event_uid);
time_cmd.action = htole32(IWM_FW_CTXT_ACTION_REMOVE);
time_cmd.id_and_color =
htole32(IWM_FW_CMD_ID_AND_COLOR(ivp->id, ivp->color));
IWM_DPRINTF(sc, IWM_DEBUG_TE,
"%s: Removing TE 0x%x\n", __func__, le32toh(time_cmd.id));
if (iwm_mvm_send_cmd_pdu(sc, IWM_TIME_EVENT_CMD, 0, sizeof(time_cmd),
&time_cmd) == 0)
iwm_mvm_te_clear_data(sc);
DELAY(100);
}

View File

@ -107,7 +107,11 @@
#ifndef __IF_IWM_TIME_EVENT_H__
#define __IF_IWM_TIME_EVENT_H__
extern void iwm_mvm_rx_time_event_notif(struct iwm_softc *sc,
struct iwm_rx_packet *pkt);
extern void iwm_mvm_protect_session(struct iwm_softc *sc, struct iwm_vap *ivp,
uint32_t duration, uint32_t max_delay);
uint32_t duration, uint32_t max_delay, boolean_t wait_for_notif);
extern void iwm_mvm_stop_session_protection(struct iwm_softc *sc,
struct iwm_vap *ivp);
#endif /* __IF_IWM_TIME_EVENT_H__ */

Some files were not shown because too many files have changed in this diff Show More