MFC
This commit is contained in:
commit
c02f1527a9
@ -108,7 +108,7 @@ linux emul emulation Please discuss changes here.
|
||||
bs{diff,patch} cperciva Pre-commit review requested.
|
||||
portsnap cperciva Pre-commit review requested.
|
||||
freebsd-update cperciva Pre-commit review requested.
|
||||
openssl - No non-upstream commits should be done.
|
||||
openssl benl Pre-commit review requested.
|
||||
sys/netgraph/bluetooth emax Pre-commit review preferred.
|
||||
lib/libbluetooth emax Pre-commit review preferred.
|
||||
lib/libsdp emax Pre-commit review preferred.
|
||||
|
@ -1333,38 +1333,14 @@ get_default_if()
|
||||
# Echo decimal number $arg (single digit) in hexadecimal format.
|
||||
hexdigit()
|
||||
{
|
||||
if [ $1 -lt 10 ]; then
|
||||
echo $1
|
||||
else
|
||||
case $1 in
|
||||
10) echo a ;;
|
||||
11) echo b ;;
|
||||
12) echo c ;;
|
||||
13) echo d ;;
|
||||
14) echo e ;;
|
||||
15) echo f ;;
|
||||
esac
|
||||
fi
|
||||
printf '%x\n' "$1"
|
||||
}
|
||||
|
||||
# hexprint arg
|
||||
# Echo decimal number $arg (multiple digits) in hexadecimal format.
|
||||
hexprint()
|
||||
{
|
||||
local val str dig
|
||||
val=$1
|
||||
str=''
|
||||
dig=`hexdigit $((${val} & 15))`
|
||||
str=${dig}${str}
|
||||
val=$((${val} >> 4))
|
||||
|
||||
while [ ${val} -gt 0 ]; do
|
||||
dig=`hexdigit $((${val} & 15))`
|
||||
str=${dig}${str}
|
||||
val=$((${val} >> 4))
|
||||
done
|
||||
|
||||
echo ${str}
|
||||
printf '%x\n' "$1"
|
||||
}
|
||||
|
||||
is_wired_interface()
|
||||
|
@ -480,7 +480,7 @@ main(int argc, char *argv[])
|
||||
cfg->hc_controladdr);
|
||||
}
|
||||
|
||||
if (drop_privs(true) != 0)
|
||||
if (drop_privs(NULL) != 0)
|
||||
exit(EX_CONFIG);
|
||||
|
||||
/* Send the command to the server... */
|
||||
|
@ -904,7 +904,7 @@ hastd_primary(struct hast_resource *res)
|
||||
init_ggate(res);
|
||||
init_environment(res);
|
||||
|
||||
if (drop_privs(true) != 0) {
|
||||
if (drop_privs(res) != 0) {
|
||||
cleanup(res);
|
||||
exit(EX_CONFIG);
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ hastd_secondary(struct hast_resource *res, struct nv *nvin)
|
||||
init_local(res);
|
||||
init_environment();
|
||||
|
||||
if (drop_privs(true) != 0)
|
||||
if (drop_privs(res) != 0)
|
||||
exit(EX_CONFIG);
|
||||
pjdlog_info("Privileges successfully dropped.");
|
||||
|
||||
|
@ -32,9 +32,10 @@
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/capability.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/disk.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/jail.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <errno.h>
|
||||
@ -147,21 +148,15 @@ role2str(int role)
|
||||
}
|
||||
|
||||
int
|
||||
drop_privs(bool usecapsicum)
|
||||
drop_privs(struct hast_resource *res)
|
||||
{
|
||||
char jailhost[sizeof(res->hr_name) * 2];
|
||||
struct jail jailst;
|
||||
struct passwd *pw;
|
||||
uid_t ruid, euid, suid;
|
||||
gid_t rgid, egid, sgid;
|
||||
gid_t gidset[1];
|
||||
|
||||
if (usecapsicum) {
|
||||
if (cap_enter() == 0) {
|
||||
pjdlog_debug(1,
|
||||
"Privileges successfully dropped using capsicum.");
|
||||
return (0);
|
||||
}
|
||||
pjdlog_errno(LOG_WARNING, "Unable to sandbox using capsicum");
|
||||
}
|
||||
bool capsicum, jailed;
|
||||
|
||||
/*
|
||||
* According to getpwnam(3) we have to clear errno before calling the
|
||||
@ -181,10 +176,34 @@ drop_privs(bool usecapsicum)
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
if (chroot(pw->pw_dir) == -1) {
|
||||
KEEP_ERRNO(pjdlog_errno(LOG_ERR,
|
||||
"Unable to change root directory to %s", pw->pw_dir));
|
||||
return (-1);
|
||||
|
||||
bzero(&jailst, sizeof(jailst));
|
||||
jailst.version = JAIL_API_VERSION;
|
||||
jailst.path = pw->pw_dir;
|
||||
if (res == NULL) {
|
||||
(void)snprintf(jailhost, sizeof(jailhost), "hastctl");
|
||||
} else {
|
||||
(void)snprintf(jailhost, sizeof(jailhost), "hastd: %s (%s)",
|
||||
res->hr_name, role2str(res->hr_role));
|
||||
}
|
||||
jailst.hostname = jailhost;
|
||||
jailst.jailname = NULL;
|
||||
jailst.ip4s = 0;
|
||||
jailst.ip4 = NULL;
|
||||
jailst.ip6s = 0;
|
||||
jailst.ip6 = NULL;
|
||||
if (jail(&jailst) >= 0) {
|
||||
jailed = true;
|
||||
} else {
|
||||
jailed = false;
|
||||
pjdlog_errno(LOG_WARNING,
|
||||
"Unable to jail to directory to %s", pw->pw_dir);
|
||||
if (chroot(pw->pw_dir) == -1) {
|
||||
KEEP_ERRNO(pjdlog_errno(LOG_ERR,
|
||||
"Unable to change root directory to %s",
|
||||
pw->pw_dir));
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
PJDLOG_VERIFY(chdir("/") == 0);
|
||||
gidset[0] = pw->pw_gid;
|
||||
@ -205,6 +224,11 @@ drop_privs(bool usecapsicum)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (res == NULL || res->hr_role != HAST_ROLE_PRIMARY)
|
||||
capsicum = (cap_enter() == 0);
|
||||
else
|
||||
capsicum = false;
|
||||
|
||||
/*
|
||||
* Better be sure that everything succeeded.
|
||||
*/
|
||||
@ -221,7 +245,8 @@ drop_privs(bool usecapsicum)
|
||||
PJDLOG_VERIFY(gidset[0] == pw->pw_gid);
|
||||
|
||||
pjdlog_debug(1,
|
||||
"Privileges successfully dropped using chroot+setgid+setuid.");
|
||||
"Privileges successfully dropped using %s%s+setgid+setuid.",
|
||||
capsicum ? "capsicum+" : "", jailed ? "jail" : "chroot");
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -51,6 +51,6 @@ int snprlcat(char *str, size_t size, const char *fmt, ...);
|
||||
|
||||
int provinfo(struct hast_resource *res, bool dowrite);
|
||||
const char *role2str(int role);
|
||||
int drop_privs(bool usecapsicum);
|
||||
int drop_privs(struct hast_resource *res);
|
||||
|
||||
#endif /* !_SUBR_H_ */
|
||||
|
@ -25,11 +25,21 @@ CWARNFLAGS?= -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
|
||||
# operations inside the kernel itself. These operations are exclusively
|
||||
# reserved for user applications.
|
||||
#
|
||||
# gcc:
|
||||
# Setting -mno-mmx implies -mno-3dnow
|
||||
# Setting -mno-sse implies -mno-sse2, -mno-sse3 and -mno-ssse3
|
||||
#
|
||||
# clang:
|
||||
# Setting -mno-mmx implies -mno-3dnow, -mno-3dnowa, -mno-sse, -mno-sse2,
|
||||
# -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
|
||||
#
|
||||
.if ${MACHINE_CPUARCH} == "i386"
|
||||
.if ${CC:T:Mclang} != "clang"
|
||||
CFLAGS+= -mno-align-long-strings -mpreferred-stack-boundary=2
|
||||
CFLAGS+= -mno-align-long-strings -mpreferred-stack-boundary=2 -mno-sse
|
||||
.else
|
||||
CFLAGS+= -mno-aes -mno-avx
|
||||
.endif
|
||||
CFLAGS+= -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
|
||||
CFLAGS+= -mno-mmx -msoft-float
|
||||
INLINE_LIMIT?= 8000
|
||||
.endif
|
||||
|
||||
@ -61,10 +71,23 @@ INLINE_LIMIT?= 15000
|
||||
# operations inside the kernel itself. These operations are exclusively
|
||||
# reserved for user applications.
|
||||
#
|
||||
# gcc:
|
||||
# Setting -mno-mmx implies -mno-3dnow
|
||||
# Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3 and -mfpmath=387
|
||||
#
|
||||
# clang:
|
||||
# Setting -mno-mmx implies -mno-3dnow, -mno-3dnowa, -mno-sse, -mno-sse2,
|
||||
# -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
|
||||
# (-mfpmath= is not supported)
|
||||
#
|
||||
.if ${MACHINE_CPUARCH} == "amd64"
|
||||
CFLAGS+= -mcmodel=kernel -mno-red-zone \
|
||||
-mfpmath=387 -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 \
|
||||
-msoft-float -fno-asynchronous-unwind-tables
|
||||
.if ${CC:T:Mclang} != "clang"
|
||||
CFLAGS+= -mno-sse
|
||||
.else
|
||||
CFLAGS+= -mno-aes -mno-avx
|
||||
.endif
|
||||
CFLAGS+= -mcmodel=kernel -mno-red-zone -mno-mmx -msoft-float \
|
||||
-fno-asynchronous-unwind-tables
|
||||
INLINE_LIMIT?= 8000
|
||||
.endif
|
||||
|
||||
|
@ -133,4 +133,5 @@ HAL_STATUS ath_hal_v1EepromAttach(struct ath_hal *ah);
|
||||
HAL_STATUS ath_hal_legacyEepromAttach(struct ath_hal *ah);
|
||||
HAL_STATUS ath_hal_v14EepromAttach(struct ath_hal *ah);
|
||||
HAL_STATUS ath_hal_v4kEepromAttach(struct ath_hal *ah);
|
||||
HAL_STATUS ath_hal_9287EepromAttach(struct ath_hal *ah);
|
||||
#endif /* _ATH_AH_EEPROM_H_ */
|
||||
|
405
sys/dev/ath/ath_hal/ah_eeprom_9287.c
Normal file
405
sys/dev/ath/ath_hal/ah_eeprom_9287.c
Normal file
@ -0,0 +1,405 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Sam Leffler, Errno Consulting
|
||||
* Copyright (c) 2010 Atheros Communications, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
#include "opt_ah.h"
|
||||
|
||||
#include "ah.h"
|
||||
#include "ah_internal.h"
|
||||
#include "ah_eeprom_v14.h"
|
||||
#include "ah_eeprom_9287.h"
|
||||
|
||||
static HAL_STATUS
|
||||
v9287EepromGet(struct ath_hal *ah, int param, void *val)
|
||||
{
|
||||
#define CHAN_A_IDX 0
|
||||
#define CHAN_B_IDX 1
|
||||
#define IS_VERS(op, v) ((pBase->version & AR5416_EEP_VER_MINOR_MASK) op (v))
|
||||
HAL_EEPROM_9287 *ee = AH_PRIVATE(ah)->ah_eeprom;
|
||||
const MODAL_EEP_9287_HEADER *pModal = &ee->ee_base.modalHeader;
|
||||
const BASE_EEP_9287_HEADER *pBase = &ee->ee_base.baseEepHeader;
|
||||
uint32_t sum;
|
||||
uint8_t *macaddr;
|
||||
int i;
|
||||
|
||||
switch (param) {
|
||||
case AR_EEP_NFTHRESH_2:
|
||||
*(int16_t *)val = pModal->noiseFloorThreshCh[0];
|
||||
return HAL_OK;
|
||||
case AR_EEP_MACADDR: /* Get MAC Address */
|
||||
sum = 0;
|
||||
macaddr = val;
|
||||
for (i = 0; i < 6; i++) {
|
||||
macaddr[i] = pBase->macAddr[i];
|
||||
sum += pBase->macAddr[i];
|
||||
}
|
||||
if (sum == 0 || sum == 0xffff*3) {
|
||||
HALDEBUG(ah, HAL_DEBUG_ANY, "%s: bad mac address %s\n",
|
||||
__func__, ath_hal_ether_sprintf(macaddr));
|
||||
return HAL_EEBADMAC;
|
||||
}
|
||||
return HAL_OK;
|
||||
case AR_EEP_REGDMN_0:
|
||||
return pBase->regDmn[0];
|
||||
case AR_EEP_REGDMN_1:
|
||||
return pBase->regDmn[1];
|
||||
case AR_EEP_OPCAP:
|
||||
return pBase->deviceCap;
|
||||
case AR_EEP_OPMODE:
|
||||
return pBase->opCapFlags;
|
||||
case AR_EEP_RFSILENT:
|
||||
return pBase->rfSilent;
|
||||
#if 0
|
||||
case AR_EEP_OB_5:
|
||||
return pModal[CHAN_A_IDX].ob;
|
||||
case AR_EEP_DB_5:
|
||||
return pModal[CHAN_A_IDX].db;
|
||||
case AR_EEP_OB_2:
|
||||
return pModal[CHAN_B_IDX].ob;
|
||||
case AR_EEP_DB_2:
|
||||
return pModal[CHAN_B_IDX].db;
|
||||
#endif
|
||||
case AR_EEP_TXMASK:
|
||||
return pBase->txMask;
|
||||
case AR_EEP_RXMASK:
|
||||
return pBase->rxMask;
|
||||
#if 0
|
||||
case AR_EEP_RXGAIN_TYPE:
|
||||
return IS_VERS(>=, AR5416_EEP_MINOR_VER_17) ?
|
||||
pBase->rxGainType : AR5416_EEP_RXGAIN_ORIG;
|
||||
case AR_EEP_TXGAIN_TYPE:
|
||||
return IS_VERS(>=, AR5416_EEP_MINOR_VER_19) ?
|
||||
pBase->txGainType : AR5416_EEP_TXGAIN_ORIG;
|
||||
#endif
|
||||
case AR_EEP_OL_PWRCTRL:
|
||||
HALASSERT(val == AH_NULL);
|
||||
return pBase->openLoopPwrCntl ? HAL_OK : HAL_EIO;
|
||||
case AR_EEP_AMODE:
|
||||
return HAL_EIO; /* no 5GHz for Kiwi */
|
||||
case AR_EEP_BMODE:
|
||||
case AR_EEP_GMODE:
|
||||
HALASSERT(val == AH_NULL);
|
||||
return pBase->opCapFlags & AR5416_OPFLAGS_11G ?
|
||||
HAL_OK : HAL_EIO;
|
||||
case AR_EEP_32KHZCRYSTAL:
|
||||
case AR_EEP_COMPRESS:
|
||||
case AR_EEP_FASTFRAME: /* XXX policy decision, h/w can do it */
|
||||
case AR_EEP_WRITEPROTECT: /* NB: no write protect bit */
|
||||
HALASSERT(val == AH_NULL);
|
||||
/* fall thru... */
|
||||
case AR_EEP_MAXQCU: /* NB: not in opCapFlags */
|
||||
case AR_EEP_KCENTRIES: /* NB: not in opCapFlags */
|
||||
return HAL_EIO;
|
||||
case AR_EEP_AES:
|
||||
case AR_EEP_BURST:
|
||||
case AR_EEP_RFKILL:
|
||||
case AR_EEP_TURBO5DISABLE:
|
||||
case AR_EEP_TURBO2DISABLE:
|
||||
HALASSERT(val == AH_NULL);
|
||||
return HAL_OK;
|
||||
case AR_EEP_ANTGAINMAX_2:
|
||||
*(int8_t *) val = ee->ee_antennaGainMax[1];
|
||||
return HAL_OK;
|
||||
case AR_EEP_PWR_TABLE_OFFSET:
|
||||
*(int8_t *) val = pBase->pwrTableOffset;
|
||||
return HAL_OK;
|
||||
default:
|
||||
HALASSERT(0);
|
||||
return HAL_EINVAL;
|
||||
}
|
||||
#undef IS_VERS
|
||||
#undef CHAN_A_IDX
|
||||
#undef CHAN_B_IDX
|
||||
}
|
||||
|
||||
static HAL_STATUS
|
||||
v9287EepromSet(struct ath_hal *ah, int param, int v)
|
||||
{
|
||||
HAL_EEPROM_9287 *ee = AH_PRIVATE(ah)->ah_eeprom;
|
||||
|
||||
switch (param) {
|
||||
case AR_EEP_ANTGAINMAX_2:
|
||||
ee->ee_antennaGainMax[1] = (int8_t) v;
|
||||
return HAL_OK;
|
||||
case AR_EEP_ANTGAINMAX_5:
|
||||
ee->ee_antennaGainMax[0] = (int8_t) v;
|
||||
return HAL_OK;
|
||||
}
|
||||
return HAL_EINVAL;
|
||||
}
|
||||
|
||||
static HAL_BOOL
|
||||
v9287EepromDiag(struct ath_hal *ah, int request,
|
||||
const void *args, uint32_t argsize, void **result, uint32_t *resultsize)
|
||||
{
|
||||
HAL_EEPROM_9287 *ee = AH_PRIVATE(ah)->ah_eeprom;
|
||||
|
||||
switch (request) {
|
||||
case HAL_DIAG_EEPROM:
|
||||
*result = ee;
|
||||
*resultsize = sizeof(HAL_EEPROM_9287);
|
||||
return AH_TRUE;
|
||||
}
|
||||
return AH_FALSE;
|
||||
}
|
||||
|
||||
/* Do structure specific swaps if Eeprom format is non native to host */
|
||||
static void
|
||||
eepromSwap(HAL_EEPROM_9287 *ee)
|
||||
{
|
||||
uint32_t integer, i;
|
||||
uint16_t word;
|
||||
MODAL_EEP_9287_HEADER *pModal;
|
||||
|
||||
/* convert Base Eep header */
|
||||
word = __bswap16(ee->ee_base.baseEepHeader.length);
|
||||
ee->ee_base.baseEepHeader.length = word;
|
||||
|
||||
word = __bswap16(ee->ee_base.baseEepHeader.checksum);
|
||||
ee->ee_base.baseEepHeader.checksum = word;
|
||||
|
||||
word = __bswap16(ee->ee_base.baseEepHeader.version);
|
||||
ee->ee_base.baseEepHeader.version = word;
|
||||
|
||||
word = __bswap16(ee->ee_base.baseEepHeader.regDmn[0]);
|
||||
ee->ee_base.baseEepHeader.regDmn[0] = word;
|
||||
|
||||
word = __bswap16(ee->ee_base.baseEepHeader.regDmn[1]);
|
||||
ee->ee_base.baseEepHeader.regDmn[1] = word;
|
||||
|
||||
word = __bswap16(ee->ee_base.baseEepHeader.rfSilent);
|
||||
ee->ee_base.baseEepHeader.rfSilent = word;
|
||||
|
||||
word = __bswap16(ee->ee_base.baseEepHeader.blueToothOptions);
|
||||
ee->ee_base.baseEepHeader.blueToothOptions = word;
|
||||
|
||||
word = __bswap16(ee->ee_base.baseEepHeader.deviceCap);
|
||||
ee->ee_base.baseEepHeader.deviceCap = word;
|
||||
|
||||
/* convert Modal Eep header */
|
||||
|
||||
/* only 2.4ghz here; so only one modal header entry */
|
||||
pModal = &ee->ee_base.modalHeader;
|
||||
|
||||
/* XXX linux/ah_osdep.h only defines __bswap32 for BE */
|
||||
integer = __bswap32(pModal->antCtrlCommon);
|
||||
pModal->antCtrlCommon = integer;
|
||||
|
||||
for (i = 0; i < AR9287_MAX_CHAINS; i++) {
|
||||
integer = __bswap32(pModal->antCtrlChain[i]);
|
||||
pModal->antCtrlChain[i] = integer;
|
||||
}
|
||||
for (i = 0; i < AR5416_EEPROM_MODAL_SPURS; i++) {
|
||||
word = __bswap16(pModal->spurChans[i].spurChan);
|
||||
pModal->spurChans[i].spurChan = word;
|
||||
}
|
||||
}
|
||||
|
||||
static uint16_t
|
||||
v9287EepromGetSpurChan(struct ath_hal *ah, int ix, HAL_BOOL is2GHz)
|
||||
{
|
||||
HAL_EEPROM_9287 *ee = AH_PRIVATE(ah)->ah_eeprom;
|
||||
|
||||
HALASSERT(is2GHz == AH_TRUE);
|
||||
if (is2GHz != AH_TRUE)
|
||||
return 0; /* XXX ? */
|
||||
|
||||
HALASSERT(0 <= ix && ix < AR5416_EEPROM_MODAL_SPURS);
|
||||
return ee->ee_base.modalHeader.spurChans[ix].spurChan;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* fbin2freq
|
||||
*
|
||||
* Get channel value from binary representation held in eeprom
|
||||
* RETURNS: the frequency in MHz
|
||||
*/
|
||||
static uint16_t
|
||||
fbin2freq(uint8_t fbin, HAL_BOOL is2GHz)
|
||||
{
|
||||
/*
|
||||
* Reserved value 0xFF provides an empty definition both as
|
||||
* an fbin and as a frequency - do not convert
|
||||
*/
|
||||
if (fbin == AR5416_BCHAN_UNUSED)
|
||||
return fbin;
|
||||
return (uint16_t)((is2GHz) ? (2300 + fbin) : (4800 + 5 * fbin));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Copy EEPROM Conformance Testing Limits contents
|
||||
* into the allocated space
|
||||
*/
|
||||
/* USE CTLS from chain zero */
|
||||
#define CTL_CHAIN 0
|
||||
|
||||
static void
|
||||
v9287EepromReadCTLInfo(struct ath_hal *ah, HAL_EEPROM_9287 *ee)
|
||||
{
|
||||
RD_EDGES_POWER *rep = ee->ee_rdEdgesPower;
|
||||
int i, j;
|
||||
|
||||
HALASSERT(AR9287_NUM_CTLS <= sizeof(ee->ee_rdEdgesPower)/NUM_EDGES);
|
||||
|
||||
for (i = 0; ee->ee_base.ctlIndex[i] != 0 && i < AR9287_NUM_CTLS; i++) {
|
||||
for (j = 0; j < NUM_EDGES; j ++) {
|
||||
/* XXX Confirm this is the right thing to do when an invalid channel is stored */
|
||||
if (ee->ee_base.ctlData[i].ctlEdges[CTL_CHAIN][j].bChannel == AR5416_BCHAN_UNUSED) {
|
||||
rep[j].rdEdge = 0;
|
||||
rep[j].twice_rdEdgePower = 0;
|
||||
rep[j].flag = 0;
|
||||
} else {
|
||||
rep[j].rdEdge = fbin2freq(
|
||||
ee->ee_base.ctlData[i].ctlEdges[CTL_CHAIN][j].bChannel,
|
||||
(ee->ee_base.ctlIndex[i] & CTL_MODE_M) != CTL_11A);
|
||||
rep[j].twice_rdEdgePower = MS(ee->ee_base.ctlData[i].ctlEdges[CTL_CHAIN][j].tPowerFlag, CAL_CTL_EDGES_POWER);
|
||||
rep[j].flag = MS(ee->ee_base.ctlData[i].ctlEdges[CTL_CHAIN][j].tPowerFlag, CAL_CTL_EDGES_FLAG) != 0;
|
||||
}
|
||||
}
|
||||
rep += NUM_EDGES;
|
||||
}
|
||||
ee->ee_numCtls = i;
|
||||
HALDEBUG(ah, HAL_DEBUG_ATTACH | HAL_DEBUG_EEPROM,
|
||||
"%s Numctls = %u\n",__func__,i);
|
||||
}
|
||||
|
||||
/*
|
||||
* Reclaim any EEPROM-related storage.
|
||||
*/
|
||||
static void
|
||||
v9287EepromDetach(struct ath_hal *ah)
|
||||
{
|
||||
HAL_EEPROM_9287 *ee = AH_PRIVATE(ah)->ah_eeprom;
|
||||
|
||||
ath_hal_free(ee);
|
||||
AH_PRIVATE(ah)->ah_eeprom = AH_NULL;
|
||||
}
|
||||
|
||||
#define owl_get_eep_ver(_ee) \
|
||||
(((_ee)->ee_base.baseEepHeader.version >> 12) & 0xF)
|
||||
#define owl_get_eep_rev(_ee) \
|
||||
(((_ee)->ee_base.baseEepHeader.version) & 0xFFF)
|
||||
|
||||
HAL_STATUS
|
||||
ath_hal_9287EepromAttach(struct ath_hal *ah)
|
||||
{
|
||||
#define NW(a) (sizeof(a) / sizeof(uint16_t))
|
||||
HAL_EEPROM_9287 *ee = AH_PRIVATE(ah)->ah_eeprom;
|
||||
uint16_t *eep_data, magic;
|
||||
HAL_BOOL need_swap;
|
||||
u_int w, off, len;
|
||||
uint32_t sum;
|
||||
|
||||
HALASSERT(ee == AH_NULL);
|
||||
|
||||
if (!ath_hal_eepromRead(ah, AR5416_EEPROM_MAGIC_OFFSET, &magic)) {
|
||||
HALDEBUG(ah, HAL_DEBUG_ANY,
|
||||
"%s Error reading Eeprom MAGIC\n", __func__);
|
||||
return HAL_EEREAD;
|
||||
}
|
||||
HALDEBUG(ah, HAL_DEBUG_ATTACH, "%s Eeprom Magic = 0x%x\n",
|
||||
__func__, magic);
|
||||
if (magic != AR5416_EEPROM_MAGIC) {
|
||||
HALDEBUG(ah, HAL_DEBUG_ANY, "Bad magic number\n");
|
||||
return HAL_EEMAGIC;
|
||||
}
|
||||
|
||||
ee = ath_hal_malloc(sizeof(HAL_EEPROM_9287));
|
||||
if (ee == AH_NULL) {
|
||||
/* XXX message */
|
||||
return HAL_ENOMEM;
|
||||
}
|
||||
|
||||
eep_data = (uint16_t *) ee;
|
||||
for (w = 0; w < NW(struct ar9287_eeprom); w++) {
|
||||
off = AR9287_EEP_START_LOC + w;
|
||||
if (!ath_hal_eepromRead(ah, off, &eep_data[w])) {
|
||||
HALDEBUG(ah, HAL_DEBUG_ANY,
|
||||
"%s eeprom read error at offset 0x%x\n",
|
||||
__func__, off);
|
||||
return HAL_EEREAD;
|
||||
}
|
||||
}
|
||||
/* Convert to eeprom native eeprom endian format */
|
||||
if (isBigEndian()) {
|
||||
for (w = 0; w < NW(HAL_EEPROM_9287); w++)
|
||||
eep_data[w] = __bswap16(eep_data[w]);
|
||||
}
|
||||
|
||||
/*
|
||||
* At this point, we're in the native eeprom endian format
|
||||
* Now, determine the eeprom endian by looking at byte 26??
|
||||
*/
|
||||
need_swap = ((ee->ee_base.baseEepHeader.eepMisc & AR5416_EEPMISC_BIG_ENDIAN) != 0) ^ isBigEndian();
|
||||
if (need_swap) {
|
||||
HALDEBUG(ah, HAL_DEBUG_ATTACH | HAL_DEBUG_EEPROM,
|
||||
"Byte swap EEPROM contents.\n");
|
||||
len = __bswap16(ee->ee_base.baseEepHeader.length);
|
||||
} else {
|
||||
len = ee->ee_base.baseEepHeader.length;
|
||||
}
|
||||
len = AH_MIN(len, sizeof(HAL_EEPROM_9287)) / sizeof(uint16_t);
|
||||
|
||||
/* Apply the checksum, done in native eeprom format */
|
||||
/* XXX - Need to check to make sure checksum calculation is done
|
||||
* in the correct endian format. Right now, it seems it would
|
||||
* cast the raw data to host format and do the calculation, which may
|
||||
* not be correct as the calculation may need to be done in the native
|
||||
* eeprom format
|
||||
*/
|
||||
sum = 0;
|
||||
for (w = 0; w < len; w++)
|
||||
sum ^= eep_data[w];
|
||||
/* Check CRC - Attach should fail on a bad checksum */
|
||||
if (sum != 0xffff) {
|
||||
HALDEBUG(ah, HAL_DEBUG_ANY,
|
||||
"Bad EEPROM checksum 0x%x (Len=%u)\n", sum, len);
|
||||
return HAL_EEBADSUM;
|
||||
}
|
||||
|
||||
if (need_swap)
|
||||
eepromSwap(ee); /* byte swap multi-byte data */
|
||||
|
||||
/* swap words 0+2 so version is at the front */
|
||||
magic = eep_data[0];
|
||||
eep_data[0] = eep_data[2];
|
||||
eep_data[2] = magic;
|
||||
|
||||
HALDEBUG(ah, HAL_DEBUG_ATTACH | HAL_DEBUG_EEPROM,
|
||||
"%s Eeprom Version %u.%u\n", __func__,
|
||||
owl_get_eep_ver(ee), owl_get_eep_rev(ee));
|
||||
|
||||
/* NB: must be after all byte swapping */
|
||||
if (owl_get_eep_ver(ee) != AR5416_EEP_VER) {
|
||||
HALDEBUG(ah, HAL_DEBUG_ANY,
|
||||
"Bad EEPROM version 0x%x\n", owl_get_eep_ver(ee));
|
||||
return HAL_EEBADSUM;
|
||||
}
|
||||
|
||||
v9287EepromReadCTLInfo(ah, ee); /* Get CTLs */
|
||||
|
||||
AH_PRIVATE(ah)->ah_eeprom = ee;
|
||||
AH_PRIVATE(ah)->ah_eeversion = ee->ee_base.baseEepHeader.version;
|
||||
AH_PRIVATE(ah)->ah_eepromDetach = v9287EepromDetach;
|
||||
AH_PRIVATE(ah)->ah_eepromGet = v9287EepromGet;
|
||||
AH_PRIVATE(ah)->ah_eepromSet = v9287EepromSet;
|
||||
AH_PRIVATE(ah)->ah_getSpurChan = v9287EepromGetSpurChan;
|
||||
AH_PRIVATE(ah)->ah_eepromDiag = v9287EepromDiag;
|
||||
return HAL_OK;
|
||||
#undef NW
|
||||
}
|
166
sys/dev/ath/ath_hal/ah_eeprom_9287.h
Normal file
166
sys/dev/ath/ath_hal/ah_eeprom_9287.h
Normal file
@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2009 Atheros Communications Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef __AH_EEPROM_9287_H__
|
||||
#define __AH_EEPROM_9287_H__
|
||||
|
||||
#define OLC_FOR_AR9287_10_LATER (AR_SREV_9287_11_OR_LATER(ah) && \
|
||||
ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL))
|
||||
|
||||
#define AR9287_EEP_VER 0xE
|
||||
#define AR9287_EEP_VER_MINOR_MASK 0xFFF
|
||||
#define AR9287_EEP_MINOR_VER_1 0x1
|
||||
#define AR9287_EEP_MINOR_VER_2 0x2
|
||||
#define AR9287_EEP_MINOR_VER_3 0x3
|
||||
#define AR9287_EEP_MINOR_VER AR9287_EEP_MINOR_VER_3
|
||||
#define AR9287_EEP_MINOR_VER_b AR9287_EEP_MINOR_VER
|
||||
#define AR9287_EEP_NO_BACK_VER AR9287_EEP_MINOR_VER_1
|
||||
|
||||
#define AR9287_EEP_START_LOC 128
|
||||
#define AR9287_HTC_EEP_START_LOC 256
|
||||
#define AR9287_NUM_2G_CAL_PIERS 3
|
||||
#define AR9287_NUM_2G_CCK_TARGET_POWERS 3
|
||||
#define AR9287_NUM_2G_20_TARGET_POWERS 3
|
||||
#define AR9287_NUM_2G_40_TARGET_POWERS 3
|
||||
#define AR9287_NUM_CTLS 12
|
||||
#define AR9287_NUM_BAND_EDGES 4
|
||||
#define AR9287_PD_GAIN_ICEPTS 1
|
||||
#define AR9287_EEPMISC_BIG_ENDIAN 0x01
|
||||
#define AR9287_EEPMISC_WOW 0x02
|
||||
#define AR9287_MAX_CHAINS 2
|
||||
#define AR9287_ANT_16S 32
|
||||
|
||||
#define AR9287_DATA_SZ 32
|
||||
|
||||
#define AR9287_PWR_TABLE_OFFSET_DB -5
|
||||
|
||||
#define AR9287_CHECKSUM_LOCATION (AR9287_EEP_START_LOC + 1)
|
||||
|
||||
struct base_eep_ar9287_header {
|
||||
uint16_t version; /* Swapped w/ length; check ah_eeprom_v14.h */
|
||||
uint16_t checksum;
|
||||
uint16_t length;
|
||||
uint8_t opCapFlags;
|
||||
uint8_t eepMisc;
|
||||
uint16_t regDmn[2];
|
||||
uint8_t macAddr[6];
|
||||
uint8_t rxMask;
|
||||
uint8_t txMask;
|
||||
uint16_t rfSilent;
|
||||
uint16_t blueToothOptions;
|
||||
uint16_t deviceCap;
|
||||
uint32_t binBuildNumber;
|
||||
uint8_t deviceType;
|
||||
uint8_t openLoopPwrCntl;
|
||||
int8_t pwrTableOffset;
|
||||
int8_t tempSensSlope;
|
||||
int8_t tempSensSlopePalOn;
|
||||
uint8_t futureBase[29];
|
||||
} __packed;
|
||||
|
||||
struct modal_eep_ar9287_header {
|
||||
uint32_t antCtrlChain[AR9287_MAX_CHAINS];
|
||||
uint32_t antCtrlCommon;
|
||||
int8_t antennaGainCh[AR9287_MAX_CHAINS];
|
||||
uint8_t switchSettling;
|
||||
uint8_t txRxAttenCh[AR9287_MAX_CHAINS];
|
||||
uint8_t rxTxMarginCh[AR9287_MAX_CHAINS];
|
||||
int8_t adcDesiredSize;
|
||||
uint8_t txEndToXpaOff;
|
||||
uint8_t txEndToRxOn;
|
||||
uint8_t txFrameToXpaOn;
|
||||
uint8_t thresh62;
|
||||
int8_t noiseFloorThreshCh[AR9287_MAX_CHAINS];
|
||||
uint8_t xpdGain;
|
||||
uint8_t xpd;
|
||||
int8_t iqCalICh[AR9287_MAX_CHAINS];
|
||||
int8_t iqCalQCh[AR9287_MAX_CHAINS];
|
||||
uint8_t pdGainOverlap;
|
||||
uint8_t xpaBiasLvl;
|
||||
uint8_t txFrameToDataStart;
|
||||
uint8_t txFrameToPaOn;
|
||||
uint8_t ht40PowerIncForPdadc;
|
||||
uint8_t bswAtten[AR9287_MAX_CHAINS];
|
||||
uint8_t bswMargin[AR9287_MAX_CHAINS];
|
||||
uint8_t swSettleHt40;
|
||||
uint8_t version;
|
||||
uint8_t db1;
|
||||
uint8_t db2;
|
||||
uint8_t ob_cck;
|
||||
uint8_t ob_psk;
|
||||
uint8_t ob_qam;
|
||||
uint8_t ob_pal_off;
|
||||
uint8_t futureModal[30];
|
||||
SPUR_CHAN spurChans[AR5416_EEPROM_MODAL_SPURS];
|
||||
} __packed;
|
||||
|
||||
struct cal_data_op_loop_ar9287 {
|
||||
uint8_t pwrPdg[2][5];
|
||||
uint8_t vpdPdg[2][5];
|
||||
uint8_t pcdac[2][5];
|
||||
uint8_t empty[2][5];
|
||||
} __packed;
|
||||
|
||||
struct cal_data_per_freq_ar9287 {
|
||||
uint8_t pwrPdg[AR5416_NUM_PD_GAINS][AR9287_PD_GAIN_ICEPTS];
|
||||
uint8_t vpdPdg[AR5416_NUM_PD_GAINS][AR9287_PD_GAIN_ICEPTS];
|
||||
} __packed;
|
||||
|
||||
union cal_data_per_freq_ar9287_u {
|
||||
struct cal_data_op_loop_ar9287 calDataOpen;
|
||||
struct cal_data_per_freq_ar9287 calDataClose;
|
||||
} __packed;
|
||||
|
||||
struct cal_ctl_data_ar9287 {
|
||||
CAL_CTL_EDGES ctlEdges[AR9287_MAX_CHAINS][AR9287_NUM_BAND_EDGES];
|
||||
} __packed;
|
||||
|
||||
struct ar9287_eeprom {
|
||||
struct base_eep_ar9287_header baseEepHeader;
|
||||
uint8_t custData[AR9287_DATA_SZ];
|
||||
struct modal_eep_ar9287_header modalHeader;
|
||||
uint8_t calFreqPier2G[AR9287_NUM_2G_CAL_PIERS];
|
||||
union cal_data_per_freq_ar9287_u
|
||||
calPierData2G[AR9287_MAX_CHAINS][AR9287_NUM_2G_CAL_PIERS];
|
||||
CAL_TARGET_POWER_LEG
|
||||
calTargetPowerCck[AR9287_NUM_2G_CCK_TARGET_POWERS];
|
||||
CAL_TARGET_POWER_LEG
|
||||
calTargetPower2G[AR9287_NUM_2G_20_TARGET_POWERS];
|
||||
CAL_TARGET_POWER_HT
|
||||
calTargetPower2GHT20[AR9287_NUM_2G_20_TARGET_POWERS];
|
||||
CAL_TARGET_POWER_HT
|
||||
calTargetPower2GHT40[AR9287_NUM_2G_40_TARGET_POWERS];
|
||||
uint8_t ctlIndex[AR9287_NUM_CTLS];
|
||||
struct cal_ctl_data_ar9287 ctlData[AR9287_NUM_CTLS];
|
||||
uint8_t padding;
|
||||
} __packed;
|
||||
|
||||
typedef struct {
|
||||
struct ar9287_eeprom ee_base;
|
||||
#define NUM_EDGES 8
|
||||
uint16_t ee_numCtls;
|
||||
RD_EDGES_POWER ee_rdEdgesPower[NUM_EDGES*AR9287_NUM_CTLS];
|
||||
/* XXX these are dynamically calculated for use by shared code */
|
||||
int8_t ee_antennaGainMax[2];
|
||||
} HAL_EEPROM_9287;
|
||||
|
||||
typedef struct modal_eep_ar9287_header MODAL_EEP_9287_HEADER;
|
||||
typedef struct base_eep_ar9287_header BASE_EEP_9287_HEADER;
|
||||
|
||||
|
||||
#endif /* __AH_EEPROM_9287_H__ */
|
@ -68,7 +68,7 @@ v1EepromGet(struct ath_hal *ah, int param, void *val)
|
||||
}
|
||||
}
|
||||
|
||||
static HAL_BOOL
|
||||
static HAL_STATUS
|
||||
v1EepromSet(struct ath_hal *ah, int param, int v)
|
||||
{
|
||||
return HAL_EINVAL;
|
||||
|
@ -84,8 +84,10 @@ v14EepromGet(struct ath_hal *ah, int param, void *val)
|
||||
return IS_VERS(>=, AR5416_EEP_MINOR_VER_19) ?
|
||||
pBase->txGainType : AR5416_EEP_TXGAIN_ORIG;
|
||||
case AR_EEP_FSTCLK_5G:
|
||||
return IS_VERS(>, AR5416_EEP_MINOR_VER_16) ?
|
||||
pBase->fastClk5g : AH_TRUE;
|
||||
/* 5ghz fastclock is always enabled for Merlin minor <= 16 */
|
||||
if (IS_VERS(<=, AR5416_EEP_MINOR_VER_16))
|
||||
return HAL_OK;
|
||||
return pBase->fastClk5g ? HAL_OK : HAL_EIO;
|
||||
case AR_EEP_OL_PWRCTRL:
|
||||
HALASSERT(val == AH_NULL);
|
||||
return pBase->openLoopPwrCntl ? HAL_OK : HAL_EIO;
|
||||
@ -148,7 +150,7 @@ v14EepromGet(struct ath_hal *ah, int param, void *val)
|
||||
#undef CHAN_B_IDX
|
||||
}
|
||||
|
||||
static HAL_BOOL
|
||||
static HAL_STATUS
|
||||
v14EepromSet(struct ath_hal *ah, int param, int v)
|
||||
{
|
||||
HAL_EEPROM_v14 *ee = AH_PRIVATE(ah)->ah_eeprom;
|
||||
|
@ -1665,7 +1665,7 @@ legacyEepromGet(struct ath_hal *ah, int param, void *val)
|
||||
return HAL_EINVAL;
|
||||
}
|
||||
|
||||
static HAL_BOOL
|
||||
static HAL_STATUS
|
||||
legacyEepromSet(struct ath_hal *ah, int param, int v)
|
||||
{
|
||||
HAL_EEPROM *ee = AH_PRIVATE(ah)->ah_eeprom;
|
||||
|
@ -116,7 +116,7 @@ v4kEepromGet(struct ath_hal *ah, int param, void *val)
|
||||
#undef CHAN_B_IDX
|
||||
}
|
||||
|
||||
static HAL_BOOL
|
||||
static HAL_STATUS
|
||||
v4kEepromSet(struct ath_hal *ah, int param, int v)
|
||||
{
|
||||
HAL_EEPROM_v4k *ee = AH_PRIVATE(ah)->ah_eeprom;
|
||||
|
@ -269,7 +269,7 @@ struct ath_hal_private {
|
||||
uint16_t ah_eeversion; /* EEPROM version */
|
||||
void (*ah_eepromDetach)(struct ath_hal *);
|
||||
HAL_STATUS (*ah_eepromGet)(struct ath_hal *, int, void *);
|
||||
HAL_BOOL (*ah_eepromSet)(struct ath_hal *, int, int);
|
||||
HAL_STATUS (*ah_eepromSet)(struct ath_hal *, int, int);
|
||||
uint16_t (*ah_getSpurChan)(struct ath_hal *, int, HAL_BOOL);
|
||||
HAL_BOOL (*ah_eepromDiag)(struct ath_hal *, int request,
|
||||
const void *args, uint32_t argsize,
|
||||
|
@ -199,7 +199,8 @@ extern HAL_STATUS ar5416GetCapability(struct ath_hal *ah,
|
||||
extern HAL_BOOL ar5416GetDiagState(struct ath_hal *ah, int request,
|
||||
const void *args, uint32_t argsize,
|
||||
void **result, uint32_t *resultsize);
|
||||
extern HAL_BOOL ar5416SetRifsDelay(struct ath_hal *ah, HAL_BOOL enable);
|
||||
extern HAL_BOOL ar5416SetRifsDelay(struct ath_hal *ah,
|
||||
const struct ieee80211_channel *chan, HAL_BOOL enable);
|
||||
|
||||
extern HAL_BOOL ar5416SetPowerMode(struct ath_hal *ah, HAL_POWER_MODE mode,
|
||||
int setChip);
|
||||
|
@ -367,9 +367,18 @@ typedef struct {
|
||||
} hal_mac_hang_check_t;
|
||||
|
||||
HAL_BOOL
|
||||
ar5416SetRifsDelay(struct ath_hal *ah, HAL_BOOL enable)
|
||||
ar5416SetRifsDelay(struct ath_hal *ah, const struct ieee80211_channel *chan,
|
||||
HAL_BOOL enable)
|
||||
{
|
||||
uint32_t val;
|
||||
HAL_BOOL is_chan_2g = AH_FALSE;
|
||||
HAL_BOOL is_ht40 = AH_FALSE;
|
||||
|
||||
if (chan)
|
||||
is_chan_2g = IEEE80211_IS_CHAN_2GHZ(chan);
|
||||
|
||||
if (chan)
|
||||
is_ht40 = IEEE80211_IS_CHAN_HT40(chan);
|
||||
|
||||
/* Only support disabling RIFS delay for now */
|
||||
HALASSERT(enable == AH_FALSE);
|
||||
@ -382,6 +391,31 @@ ar5416SetRifsDelay(struct ath_hal *ah, HAL_BOOL enable)
|
||||
val &= ~AR_PHY_RIFS_INIT_DELAY;
|
||||
OS_REG_WRITE(ah, AR_PHY_HEAVY_CLIP_FACTOR_RIFS, val);
|
||||
|
||||
/*
|
||||
* For Owl, RIFS RX parameters are controlled differently;
|
||||
* it isn't enabled in the inivals by default.
|
||||
*
|
||||
* For Sowl/Howl, RIFS RX is enabled in the inivals by default;
|
||||
* the following code sets them back to non-RIFS values.
|
||||
*
|
||||
* For > Sowl/Howl, RIFS RX can be left on by default and so
|
||||
* this function shouldn't be called.
|
||||
*/
|
||||
if ((! AR_SREV_SOWL(ah)) && (! AR_SREV_HOWL(ah)))
|
||||
return AH_TRUE;
|
||||
|
||||
/* Reset search delay to default values */
|
||||
if (is_chan_2g)
|
||||
if (is_ht40)
|
||||
OS_REG_WRITE(ah, AR_PHY_SEARCH_START_DELAY, 0x268);
|
||||
else
|
||||
OS_REG_WRITE(ah, AR_PHY_SEARCH_START_DELAY, 0x134);
|
||||
else
|
||||
if (is_ht40)
|
||||
OS_REG_WRITE(ah, AR_PHY_SEARCH_START_DELAY, 0x370);
|
||||
else
|
||||
OS_REG_WRITE(ah, AR_PHY_SEARCH_START_DELAY, 0x1b8);
|
||||
|
||||
return AH_TRUE;
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ ar5416Reset(struct ath_hal *ah, HAL_OPMODE opmode,
|
||||
|
||||
/* For chips on which the RTC reset is done, save TSF before it gets cleared */
|
||||
if (AR_SREV_HOWL(ah) ||
|
||||
(AR_SREV_MERLIN_20_OR_LATER(ah) && ath_hal_eepromGetFlag(ah, AR_EEP_OL_PWRCTRL)))
|
||||
(AR_SREV_MERLIN(ah) && ath_hal_eepromGetFlag(ah, AR_EEP_OL_PWRCTRL)))
|
||||
tsf = ar5212GetTsf64(ah);
|
||||
|
||||
/* Mark PHY as inactive; marked active in ar5416InitBB() */
|
||||
@ -663,7 +663,7 @@ ar5416ChipReset(struct ath_hal *ah, const struct ieee80211_channel *chan)
|
||||
/*
|
||||
* Warm reset is optimistic.
|
||||
*/
|
||||
if (AR_SREV_MERLIN_20_OR_LATER(ah) &&
|
||||
if (AR_SREV_MERLIN(ah) &&
|
||||
ath_hal_eepromGetFlag(ah, AR_EEP_OL_PWRCTRL)) {
|
||||
if (!ar5416SetResetReg(ah, HAL_RESET_POWER_ON))
|
||||
return AH_FALSE;
|
||||
@ -1053,9 +1053,9 @@ ar5416SetTransmitPower(struct ath_hal *ah,
|
||||
int cck_ofdm_delta = 2;
|
||||
int i;
|
||||
for (i = 0; i < N(adj); i++) {
|
||||
ratesArray[i] -= cck_ofdm_delta;
|
||||
if (ratesArray[i] < 0)
|
||||
ratesArray[i] = 0;
|
||||
ratesArray[adj[i]] -= cck_ofdm_delta;
|
||||
if (ratesArray[adj[i]] < 0)
|
||||
ratesArray[adj[i]] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1449,7 +1449,7 @@ ar5416SetDefGainValues(struct ath_hal *ah,
|
||||
if (IS_EEP_MINOR_V3(ah)) {
|
||||
txRxAttenLocal = pModal->txRxAttenCh[i];
|
||||
|
||||
if (AR_SREV_MERLIN_20_OR_LATER(ah)) {
|
||||
if (AR_SREV_MERLIN_10_OR_LATER(ah)) {
|
||||
OS_REG_RMW_FIELD(ah, AR_PHY_GAIN_2GHZ + regChainOffset,
|
||||
AR_PHY_GAIN_2GHZ_XATTEN1_MARGIN,
|
||||
pModal->bswMargin[i]);
|
||||
@ -1472,7 +1472,7 @@ ar5416SetDefGainValues(struct ath_hal *ah,
|
||||
}
|
||||
}
|
||||
|
||||
if (AR_SREV_MERLIN_20_OR_LATER(ah)) {
|
||||
if (AR_SREV_MERLIN_10_OR_LATER(ah)) {
|
||||
OS_REG_RMW_FIELD(ah,
|
||||
AR_PHY_RXGAIN + regChainOffset,
|
||||
AR9280_PHY_RXGAIN_TXRX_ATTEN, txRxAttenLocal);
|
||||
@ -1551,8 +1551,10 @@ ar5416SetBoardValues(struct ath_hal *ah, const struct ieee80211_channel *chan)
|
||||
SM(pModal->iqCalQCh[i], AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF));
|
||||
|
||||
/*
|
||||
* Large signal upgrade.
|
||||
* XXX update
|
||||
* Large signal upgrade,
|
||||
* If 14.3 or later EEPROM, use
|
||||
* txRxAttenLocal = pModal->txRxAttenCh[i]
|
||||
* else txRxAttenLocal is fixed value above.
|
||||
*/
|
||||
|
||||
if ((i == 0) || AR_SREV_5416_V20_OR_LATER(ah))
|
||||
@ -1560,7 +1562,7 @@ ar5416SetBoardValues(struct ath_hal *ah, const struct ieee80211_channel *chan)
|
||||
|
||||
}
|
||||
|
||||
if (AR_SREV_MERLIN_20_OR_LATER(ah)) {
|
||||
if (AR_SREV_MERLIN_10_OR_LATER(ah)) {
|
||||
if (IEEE80211_IS_CHAN_2GHZ(chan)) {
|
||||
OS_A_REG_RMW_FIELD(ah, AR_AN_RF2G1_CH0, AR_AN_RF2G1_CH0_OB, pModal->ob);
|
||||
OS_A_REG_RMW_FIELD(ah, AR_AN_RF2G1_CH0, AR_AN_RF2G1_CH0_DB, pModal->db);
|
||||
@ -1582,7 +1584,7 @@ ar5416SetBoardValues(struct ath_hal *ah, const struct ieee80211_channel *chan)
|
||||
OS_REG_RMW_FIELD(ah, AR_PHY_SETTLING, AR_PHY_SETTLING_SWITCH, pModal->switchSettling);
|
||||
OS_REG_RMW_FIELD(ah, AR_PHY_DESIRED_SZ, AR_PHY_DESIRED_SZ_ADC, pModal->adcDesiredSize);
|
||||
|
||||
if (! AR_SREV_MERLIN_20_OR_LATER(ah))
|
||||
if (! AR_SREV_MERLIN_10_OR_LATER(ah))
|
||||
OS_REG_RMW_FIELD(ah, AR_PHY_DESIRED_SZ, AR_PHY_DESIRED_SZ_PGA, pModal->pgaDesiredSize);
|
||||
|
||||
OS_REG_WRITE(ah, AR_PHY_RF_CTL4,
|
||||
@ -1591,7 +1593,8 @@ ar5416SetBoardValues(struct ath_hal *ah, const struct ieee80211_channel *chan)
|
||||
| SM(pModal->txFrameToXpaOn, AR_PHY_RF_CTL4_FRAME_XPAA_ON)
|
||||
| SM(pModal->txFrameToXpaOn, AR_PHY_RF_CTL4_FRAME_XPAB_ON));
|
||||
|
||||
OS_REG_RMW_FIELD(ah, AR_PHY_RF_CTL3, AR_PHY_TX_END_TO_A2_RX_ON, pModal->txEndToRxOn);
|
||||
OS_REG_RMW_FIELD(ah, AR_PHY_RF_CTL3, AR_PHY_TX_END_TO_A2_RX_ON,
|
||||
pModal->txEndToRxOn);
|
||||
|
||||
if (AR_SREV_MERLIN_10_OR_LATER(ah)) {
|
||||
OS_REG_RMW_FIELD(ah, AR_PHY_CCA, AR9280_PHY_CCA_THRESH62,
|
||||
@ -1607,27 +1610,36 @@ ar5416SetBoardValues(struct ath_hal *ah, const struct ieee80211_channel *chan)
|
||||
|
||||
/* Minor Version Specific application */
|
||||
if (IS_EEP_MINOR_V2(ah)) {
|
||||
OS_REG_RMW_FIELD(ah, AR_PHY_RF_CTL2, AR_PHY_TX_FRAME_TO_DATA_START, pModal->txFrameToDataStart);
|
||||
OS_REG_RMW_FIELD(ah, AR_PHY_RF_CTL2, AR_PHY_TX_FRAME_TO_PA_ON, pModal->txFrameToPaOn);
|
||||
OS_REG_RMW_FIELD(ah, AR_PHY_RF_CTL2, AR_PHY_TX_FRAME_TO_DATA_START,
|
||||
pModal->txFrameToDataStart);
|
||||
OS_REG_RMW_FIELD(ah, AR_PHY_RF_CTL2, AR_PHY_TX_FRAME_TO_PA_ON,
|
||||
pModal->txFrameToPaOn);
|
||||
}
|
||||
|
||||
if (IS_EEP_MINOR_V3(ah) && IEEE80211_IS_CHAN_HT40(chan))
|
||||
/* Overwrite switch settling with HT40 value */
|
||||
OS_REG_RMW_FIELD(ah, AR_PHY_SETTLING, AR_PHY_SETTLING_SWITCH, pModal->swSettleHt40);
|
||||
OS_REG_RMW_FIELD(ah, AR_PHY_SETTLING, AR_PHY_SETTLING_SWITCH,
|
||||
pModal->swSettleHt40);
|
||||
|
||||
if (AR_SREV_MERLIN_20_OR_LATER(ah) && EEP_MINOR(ah) >= AR5416_EEP_MINOR_VER_19)
|
||||
OS_REG_RMW_FIELD(ah, AR_PHY_CCK_TX_CTRL, AR_PHY_CCK_TX_CTRL_TX_DAC_SCALE_CCK, pModal->miscBits);
|
||||
|
||||
if (AR_SREV_MERLIN_20(ah) && EEP_MINOR(ah) >= AR5416_EEP_MINOR_VER_20) {
|
||||
if (IEEE80211_IS_CHAN_2GHZ(chan))
|
||||
OS_A_REG_RMW_FIELD(ah, AR_AN_TOP1, AR_AN_TOP1_DACIPMODE, eep->baseEepHeader.dacLpMode);
|
||||
OS_A_REG_RMW_FIELD(ah, AR_AN_TOP1, AR_AN_TOP1_DACIPMODE,
|
||||
eep->baseEepHeader.dacLpMode);
|
||||
else if (eep->baseEepHeader.dacHiPwrMode_5G)
|
||||
OS_A_REG_RMW_FIELD(ah, AR_AN_TOP1, AR_AN_TOP1_DACIPMODE, 0);
|
||||
else
|
||||
OS_A_REG_RMW_FIELD(ah, AR_AN_TOP1, AR_AN_TOP1_DACIPMODE, eep->baseEepHeader.dacLpMode);
|
||||
OS_A_REG_RMW_FIELD(ah, AR_AN_TOP1, AR_AN_TOP1_DACIPMODE,
|
||||
eep->baseEepHeader.dacLpMode);
|
||||
|
||||
OS_REG_RMW_FIELD(ah, AR_PHY_FRAME_CTL, AR_PHY_FRAME_CTL_TX_CLIP, pModal->miscBits >> 2);
|
||||
OS_REG_RMW_FIELD(ah, AR_PHY_TX_PWRCTRL9, AR_PHY_TX_DESIRED_SCALE_CCK, eep->baseEepHeader.desiredScaleCCK);
|
||||
OS_DELAY(100);
|
||||
|
||||
OS_REG_RMW_FIELD(ah, AR_PHY_FRAME_CTL, AR_PHY_FRAME_CTL_TX_CLIP,
|
||||
pModal->miscBits >> 2);
|
||||
OS_REG_RMW_FIELD(ah, AR_PHY_TX_PWRCTRL9, AR_PHY_TX_DESIRED_SCALE_CCK,
|
||||
eep->baseEepHeader.desiredScaleCCK);
|
||||
}
|
||||
|
||||
return AH_TRUE;
|
||||
@ -2418,7 +2430,7 @@ ar5416GetGainBoundariesAndPdadcs(struct ath_hal *ah,
|
||||
|
||||
/* Find starting index for this pdGain */
|
||||
if (i == 0) {
|
||||
if (AR_SREV_MERLIN_20_OR_LATER(ah))
|
||||
if (AR_SREV_MERLIN_10_OR_LATER(ah))
|
||||
ss = (int16_t)(0 - (minPwrT4[i] / 2));
|
||||
else
|
||||
ss = 0; /* for the first pdGain, start from index 0 */
|
||||
@ -2579,7 +2591,7 @@ ar5416OverrideIni(struct ath_hal *ah, const struct ieee80211_channel *chan)
|
||||
* hang issues.
|
||||
*/
|
||||
if (AR_SREV_HOWL(ah) || AR_SREV_SOWL(ah))
|
||||
(void) ar5416SetRifsDelay(ah, AH_FALSE);
|
||||
(void) ar5416SetRifsDelay(ah, chan, AH_FALSE);
|
||||
|
||||
if (!AR_SREV_5416_V20_OR_LATER(ah) || AR_SREV_MERLIN(ah))
|
||||
return;
|
||||
|
@ -93,6 +93,8 @@
|
||||
#define AR9280_PHY_RXGAIN_TXRX_MARGIN 0x001FC000
|
||||
#define AR9280_PHY_RXGAIN_TXRX_MARGIN_S 14
|
||||
|
||||
#define AR_PHY_SEARCH_START_DELAY 0x9918 /* search start delay */
|
||||
|
||||
#define AR_PHY_EXT_CCA 0x99bc
|
||||
#define AR_PHY_EXT_CCA_CYCPWR_THR1 0x0000FE00
|
||||
#define AR_PHY_EXT_CCA_CYCPWR_THR1_S 9
|
||||
|
@ -99,6 +99,10 @@ ar9280AniSetup(struct ath_hal *ah)
|
||||
ar5416AniAttach(ah, &aniparams, &aniparams, AH_TRUE);
|
||||
}
|
||||
|
||||
/* XXX shouldn't be here! */
|
||||
#define EEP_MINOR(_ah) \
|
||||
(AH_PRIVATE(_ah)->ah_eeversion & AR5416_EEP_VER_MINOR_MASK)
|
||||
|
||||
/*
|
||||
* Attach for an AR9280 part.
|
||||
*/
|
||||
@ -270,7 +274,8 @@ ar9280Attach(uint16_t devid, HAL_SOFTC sc,
|
||||
ath_hal_printf(ah, "[ath]: default pwr offset: %d dBm != EEPROM pwr offset: %d dBm; curves will be adjusted.\n",
|
||||
AR5416_PWR_TABLE_OFFSET_DB, (int) pwr_table_offset);
|
||||
|
||||
if (AR_SREV_MERLIN_20_OR_LATER(ah)) {
|
||||
/* XXX check for >= minor ver 17 */
|
||||
if (AR_SREV_MERLIN_20(ah)) {
|
||||
/* setup rxgain table */
|
||||
switch (ath_hal_eepromGet(ah, AR_EEP_RXGAIN_TYPE, AH_NULL)) {
|
||||
case AR5416_EEP_RXGAIN_13dB_BACKOFF:
|
||||
@ -290,7 +295,9 @@ ar9280Attach(uint16_t devid, HAL_SOFTC sc,
|
||||
goto bad; /* XXX ? try to continue */
|
||||
}
|
||||
}
|
||||
if (AR_SREV_MERLIN_20_OR_LATER(ah)) {
|
||||
|
||||
/* XXX check for >= minor ver 19 */
|
||||
if (AR_SREV_MERLIN_20(ah)) {
|
||||
/* setp txgain table */
|
||||
switch (ath_hal_eepromGet(ah, AR_EEP_TXGAIN_TYPE, AH_NULL)) {
|
||||
case AR5416_EEP_TXGAIN_HIGH_POWER:
|
||||
|
@ -628,6 +628,7 @@ vendor OQO 0x1557 OQO
|
||||
vendor UMEDIA 0x157e U-MEDIA Communications
|
||||
vendor FIBERLINE 0x1582 Fiberline
|
||||
vendor SPARKLAN 0x15a9 SparkLAN
|
||||
vendor SOUNDGRAPH 0x15c2 Soundgraph, Inc.
|
||||
vendor AMIT2 0x15c5 AMIT
|
||||
vendor SOHOWARE 0x15e8 SOHOware
|
||||
vendor UMAX 0x1606 UMAX Data Systems
|
||||
@ -3141,6 +3142,10 @@ product SPARKLAN RT2573 0x0004 RT2573
|
||||
product SPARKLAN RT2870_1 0x0006 RT2870
|
||||
product SPARKLAN RT3070 0x0010 RT3070
|
||||
|
||||
/* Soundgraph products */
|
||||
product SOUNDGRAPH IMON_VFD 0x0044 Antec Veris Elite VFD Panel, Knob, and Remote
|
||||
product SOUNDGRAPH SSTONE_LC16 0xffdc Silverstone LC16 VFD Panel, Knob, and Remote
|
||||
|
||||
/* Speed Dragon Multimedia products */
|
||||
product SPEEDDRAGON MS3303H 0x110b MS3303H Serial
|
||||
|
||||
|
@ -202,13 +202,13 @@ exception_save_restart:
|
||||
{ .mmi
|
||||
st8 [r30]=r19,16 // length
|
||||
st8 [r31]=r0,16 // flags
|
||||
add r19=16,r19
|
||||
add r29=16,r19 // Clobber restart token
|
||||
;;
|
||||
}
|
||||
{ .mmi
|
||||
st8.spill [r30]=sp,16 // sp
|
||||
st8 [r31]=r20,16 // unat
|
||||
sub sp=r23,r19
|
||||
sub sp=r23,r29
|
||||
;;
|
||||
}
|
||||
{ .mmi
|
||||
@ -641,7 +641,7 @@ exception_restore_restart:
|
||||
mov r30=ar.bspstore
|
||||
;;
|
||||
loadrs // load user regs
|
||||
nop 0
|
||||
mov r29=0 // Clobber restart token
|
||||
;;
|
||||
}
|
||||
{ .mmi
|
||||
@ -1094,22 +1094,26 @@ IVT_ENTRY(Data_Nested_TLB, 0x1400)
|
||||
}
|
||||
{ .mlx
|
||||
mov r26=ar.bsp
|
||||
movl r27=kstack
|
||||
movl r29=kstack
|
||||
;;
|
||||
}
|
||||
{ .mmi
|
||||
{ .mlx
|
||||
mov r28=sp
|
||||
nop 0
|
||||
addl r27=KSTACK_PAGES*PAGE_SIZE-16,r0
|
||||
movl r27=kstack_top
|
||||
;;
|
||||
}
|
||||
{ .mmi
|
||||
mov sp=r27
|
||||
add sp=-16,r27
|
||||
;;
|
||||
mov r27=ar.bspstore
|
||||
nop 0
|
||||
;;
|
||||
}
|
||||
mov ar.rsc=0
|
||||
dep r29=r27,r29,0,9
|
||||
;;
|
||||
mov ar.bspstore=r29
|
||||
;;
|
||||
CALL(trap, 5, r30)
|
||||
IVT_END(Data_Nested_TLB)
|
||||
|
||||
|
@ -239,21 +239,22 @@ ENTRY_NOPROFILE(epc_syscall, 8)
|
||||
;;
|
||||
}
|
||||
{ .mmi
|
||||
mov ar.bspstore=r15
|
||||
mov r13=ar.k4
|
||||
add r30=-SIZEOF_TRAPFRAME,r14
|
||||
mov r20=sp
|
||||
;;
|
||||
}
|
||||
{ .mii
|
||||
mov r13=ar.k4
|
||||
mov r21=ar.unat
|
||||
dep r30=0,r30,0,10
|
||||
;;
|
||||
add sp=-16,r30
|
||||
;;
|
||||
}
|
||||
{ .mmi
|
||||
mov ar.bspstore=r15
|
||||
;;
|
||||
mov ar.rnat=r19
|
||||
mov r21=ar.unat
|
||||
add r31=8,r30
|
||||
;;
|
||||
}
|
||||
|
@ -508,17 +508,14 @@ ia64_enable_highfp(void)
|
||||
__asm __volatile("rsm psr.dfh;; srlz.d");
|
||||
}
|
||||
|
||||
static __inline void
|
||||
ia64_srlz_d(void)
|
||||
{
|
||||
__asm __volatile("srlz.d");
|
||||
}
|
||||
|
||||
static __inline void
|
||||
ia64_srlz_i(void)
|
||||
{
|
||||
__asm __volatile("srlz.i;;");
|
||||
}
|
||||
/*
|
||||
* Avoid inline functions for the following so that they still work
|
||||
* correctly when inlining is not enabled (e.g. -O0). Function calls
|
||||
* need data serialization after setting psr, which results in a
|
||||
* hazard.
|
||||
*/
|
||||
#define ia64_srlz_d() __asm __volatile("srlz.d")
|
||||
#define ia64_srlz_i() __asm __volatile("srlz.i;;")
|
||||
|
||||
#endif /* !LOCORE */
|
||||
|
||||
|
@ -68,7 +68,7 @@ struct pcpu_md {
|
||||
|
||||
struct pcpu;
|
||||
|
||||
register struct pcpu *pcpup __asm__("r13");
|
||||
register struct pcpu * volatile pcpup __asm__("r13");
|
||||
|
||||
static __inline __pure2 struct thread *
|
||||
__curthread(void)
|
||||
|
@ -2022,7 +2022,8 @@ sctp_add_addr_to_mbuf(struct mbuf *m, struct sctp_ifa *ifa)
|
||||
|
||||
|
||||
struct mbuf *
|
||||
sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp, struct sctp_scoping *scope,
|
||||
sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
||||
struct sctp_scoping *scope,
|
||||
struct mbuf *m_at, int cnt_inits_to)
|
||||
{
|
||||
struct sctp_vrf *vrf = NULL;
|
||||
@ -2056,6 +2057,9 @@ sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp, struct sctp_scoping *scope,
|
||||
continue;
|
||||
}
|
||||
LIST_FOREACH(sctp_ifap, &sctp_ifnp->ifalist, next_ifa) {
|
||||
if (sctp_is_addr_restricted(stcb, sctp_ifap)) {
|
||||
continue;
|
||||
}
|
||||
if (sctp_is_address_in_scope(sctp_ifap,
|
||||
scope->ipv4_addr_legal,
|
||||
scope->ipv6_addr_legal,
|
||||
@ -2088,6 +2092,9 @@ skip_count:
|
||||
continue;
|
||||
}
|
||||
LIST_FOREACH(sctp_ifap, &sctp_ifnp->ifalist, next_ifa) {
|
||||
if (sctp_is_addr_restricted(stcb, sctp_ifap)) {
|
||||
continue;
|
||||
}
|
||||
if (sctp_is_address_in_scope(sctp_ifap,
|
||||
scope->ipv4_addr_legal,
|
||||
scope->ipv6_addr_legal,
|
||||
@ -2295,32 +2302,46 @@ sctp_is_ifa_addr_acceptable(struct sctp_ifa *ifa,
|
||||
{
|
||||
uint8_t dest_is_global = 0;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Here we determine if its a acceptable address. A acceptable
|
||||
* address means it is the same scope or higher scope but we can
|
||||
* allow for NAT which means its ok to have a global dest and a
|
||||
* private src.
|
||||
*
|
||||
*
|
||||
* L = loopback, P = private, G = global
|
||||
* ----------------------------------------- src | dest | result
|
||||
* ----------------------------------------- L | L | yes
|
||||
* ----------------------------------------- P | L |
|
||||
* yes-v4 no-v6 ----------------------------------------- G |
|
||||
* L | yes ----------------------------------------- L |
|
||||
* P | no ----------------------------------------- P | P
|
||||
* | yes ----------------------------------------- G | P
|
||||
* | yes - May not work -----------------------------------------
|
||||
* L | G | no ----------------------------------------- P
|
||||
* | G | yes - May not work
|
||||
* ----------------------------------------- G | G | yes
|
||||
* -----------------------------------------
|
||||
* src | dest | result
|
||||
* -----------------------------------------
|
||||
* L | L | yes
|
||||
* -----------------------------------------
|
||||
* P | L | yes-v4 no-v6
|
||||
* -----------------------------------------
|
||||
* G | L | yes
|
||||
* -----------------------------------------
|
||||
* L | P | no
|
||||
* -----------------------------------------
|
||||
* P | P | yes
|
||||
* -----------------------------------------
|
||||
* G | P | yes - May not work
|
||||
* -----------------------------------------
|
||||
* L | G | no
|
||||
* -----------------------------------------
|
||||
* P | G | yes - May not work
|
||||
* -----------------------------------------
|
||||
* G | G | yes
|
||||
* -----------------------------------------
|
||||
*/
|
||||
|
||||
if (ifa->address.sa.sa_family != fam) {
|
||||
/* forget non matching family */
|
||||
SCTPDBG(SCTP_DEBUG_OUTPUT3, "ifa_fam:%d fam:%d\n",
|
||||
ifa->address.sa.sa_family, fam);
|
||||
return (NULL);
|
||||
}
|
||||
/* Ok the address may be ok */
|
||||
SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT3, &ifa->address.sa);
|
||||
SCTPDBG(SCTP_DEBUG_OUTPUT3, "dst_is_loop:%d dest_is_priv:%d\n",
|
||||
dest_is_loop, dest_is_priv);
|
||||
if ((dest_is_loop == 0) && (dest_is_priv == 0)) {
|
||||
dest_is_global = 1;
|
||||
}
|
||||
@ -2342,12 +2363,19 @@ sctp_is_ifa_addr_acceptable(struct sctp_ifa *ifa,
|
||||
* theory be done slicker (it used to be), but this is
|
||||
* straightforward and easier to validate :-)
|
||||
*/
|
||||
SCTPDBG(SCTP_DEBUG_OUTPUT3, "ifa->src_is_loop:%d dest_is_priv:%d\n",
|
||||
ifa->src_is_loop,
|
||||
dest_is_priv);
|
||||
if ((ifa->src_is_loop == 1) && (dest_is_priv)) {
|
||||
return (NULL);
|
||||
}
|
||||
SCTPDBG(SCTP_DEBUG_OUTPUT3, "ifa->src_is_loop:%d dest_is_glob:%d\n",
|
||||
ifa->src_is_loop,
|
||||
dest_is_global);
|
||||
if ((ifa->src_is_loop == 1) && (dest_is_global)) {
|
||||
return (NULL);
|
||||
}
|
||||
SCTPDBG(SCTP_DEBUG_OUTPUT3, "address is acceptable\n");
|
||||
/* its an acceptable address */
|
||||
return (ifa);
|
||||
}
|
||||
@ -2854,6 +2882,10 @@ sctp_choose_boundall(struct sctp_inpcb *inp,
|
||||
uint32_t ifn_index;
|
||||
struct sctp_vrf *vrf;
|
||||
|
||||
#ifdef INET
|
||||
int retried = 0;
|
||||
|
||||
#endif
|
||||
/*-
|
||||
* For boundall we can use any address in the association.
|
||||
* If non_asoc_addr_ok is set we can use any address (at least in
|
||||
@ -2874,6 +2906,7 @@ sctp_choose_boundall(struct sctp_inpcb *inp,
|
||||
|
||||
ifn = SCTP_GET_IFN_VOID_FROM_ROUTE(ro);
|
||||
ifn_index = SCTP_GET_IF_INDEX_FROM_ROUTE(ro);
|
||||
SCTPDBG(SCTP_DEBUG_OUTPUT2, "ifn from route:%p ifn_index:%d\n", ifn, ifn_index);
|
||||
emit_ifn = looked_at = sctp_ifn = sctp_find_ifn(ifn, ifn_index);
|
||||
if (sctp_ifn == NULL) {
|
||||
/* ?? We don't have this guy ?? */
|
||||
@ -2982,22 +3015,30 @@ bound_all_plan_b:
|
||||
}
|
||||
atomic_add_int(&sifa->refcount, 1);
|
||||
return (sifa);
|
||||
|
||||
}
|
||||
|
||||
#ifdef INET
|
||||
again_with_private_addresses_allowed:
|
||||
#endif
|
||||
/* plan_c: do we have an acceptable address on the emit interface */
|
||||
sifa = NULL;
|
||||
SCTPDBG(SCTP_DEBUG_OUTPUT2, "Trying Plan C: find acceptable on interface\n");
|
||||
if (emit_ifn == NULL) {
|
||||
SCTPDBG(SCTP_DEBUG_OUTPUT2, "Jump to Plan D - no emit_ifn\n");
|
||||
goto plan_d;
|
||||
}
|
||||
LIST_FOREACH(sctp_ifa, &emit_ifn->ifalist, next_ifa) {
|
||||
SCTPDBG(SCTP_DEBUG_OUTPUT2, "ifa:%p\n", sctp_ifa);
|
||||
if ((sctp_ifa->localifa_flags & SCTP_ADDR_DEFER_USE) &&
|
||||
(non_asoc_addr_ok == 0))
|
||||
(non_asoc_addr_ok == 0)) {
|
||||
SCTPDBG(SCTP_DEBUG_OUTPUT2, "Defer\n");
|
||||
continue;
|
||||
}
|
||||
sifa = sctp_is_ifa_addr_acceptable(sctp_ifa, dest_is_loop,
|
||||
dest_is_priv, fam);
|
||||
if (sifa == NULL)
|
||||
if (sifa == NULL) {
|
||||
SCTPDBG(SCTP_DEBUG_OUTPUT2, "IFA not acceptable\n");
|
||||
continue;
|
||||
}
|
||||
if (stcb) {
|
||||
if (sctp_is_address_in_scope(sifa,
|
||||
stcb->asoc.ipv4_addr_legal,
|
||||
@ -3006,6 +3047,8 @@ bound_all_plan_b:
|
||||
stcb->asoc.ipv4_local_scope,
|
||||
stcb->asoc.local_scope,
|
||||
stcb->asoc.site_scope, 0) == 0) {
|
||||
SCTPDBG(SCTP_DEBUG_OUTPUT2, "NOT in scope\n");
|
||||
sifa = NULL;
|
||||
continue;
|
||||
}
|
||||
if (((non_asoc_addr_ok == 0) &&
|
||||
@ -3017,11 +3060,15 @@ bound_all_plan_b:
|
||||
* It is restricted for some reason..
|
||||
* probably not yet added.
|
||||
*/
|
||||
SCTPDBG(SCTP_DEBUG_OUTPUT2, "Its resticted\n");
|
||||
sifa = NULL;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
printf("Stcb is null - no print\n");
|
||||
}
|
||||
atomic_add_int(&sifa->refcount, 1);
|
||||
return (sifa);
|
||||
goto out;
|
||||
}
|
||||
plan_d:
|
||||
/*
|
||||
@ -3030,16 +3077,12 @@ plan_d:
|
||||
* out and see if we can find an acceptable address somewhere
|
||||
* amongst all interfaces.
|
||||
*/
|
||||
SCTPDBG(SCTP_DEBUG_OUTPUT2, "Trying Plan D\n");
|
||||
SCTPDBG(SCTP_DEBUG_OUTPUT2, "Trying Plan D looked_at is %p\n", looked_at);
|
||||
LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
|
||||
if (dest_is_loop == 0 && SCTP_IFN_IS_IFT_LOOP(sctp_ifn)) {
|
||||
/* wrong base scope */
|
||||
continue;
|
||||
}
|
||||
if ((sctp_ifn == looked_at) && looked_at)
|
||||
/* already looked at this guy */
|
||||
continue;
|
||||
|
||||
LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
|
||||
if ((sctp_ifa->localifa_flags & SCTP_ADDR_DEFER_USE) &&
|
||||
(non_asoc_addr_ok == 0))
|
||||
@ -3057,6 +3100,7 @@ plan_d:
|
||||
stcb->asoc.ipv4_local_scope,
|
||||
stcb->asoc.local_scope,
|
||||
stcb->asoc.site_scope, 0) == 0) {
|
||||
sifa = NULL;
|
||||
continue;
|
||||
}
|
||||
if (((non_asoc_addr_ok == 0) &&
|
||||
@ -3068,19 +3112,81 @@ plan_d:
|
||||
* It is restricted for some
|
||||
* reason.. probably not yet added.
|
||||
*/
|
||||
sifa = NULL;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
atomic_add_int(&sifa->refcount, 1);
|
||||
return (sifa);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Ok we can find NO address to source from that is not on our
|
||||
* restricted list and non_asoc_address is NOT ok, or it is on our
|
||||
* restricted list. We can't source to it :-(
|
||||
*/
|
||||
return (NULL);
|
||||
#ifdef INET
|
||||
if ((retried == 0) && (stcb->asoc.ipv4_local_scope == 0)) {
|
||||
stcb->asoc.ipv4_local_scope = 1;
|
||||
retried = 1;
|
||||
goto again_with_private_addresses_allowed;
|
||||
} else if (retried == 1) {
|
||||
stcb->asoc.ipv4_local_scope = 0;
|
||||
}
|
||||
#endif
|
||||
out:
|
||||
if (sifa) {
|
||||
#ifdef INET
|
||||
if (retried == 1) {
|
||||
LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
|
||||
if (dest_is_loop == 0 && SCTP_IFN_IS_IFT_LOOP(sctp_ifn)) {
|
||||
/* wrong base scope */
|
||||
continue;
|
||||
}
|
||||
LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
|
||||
struct sctp_ifa *tmp_sifa;
|
||||
|
||||
if ((sctp_ifa->localifa_flags & SCTP_ADDR_DEFER_USE) &&
|
||||
(non_asoc_addr_ok == 0))
|
||||
continue;
|
||||
tmp_sifa = sctp_is_ifa_addr_acceptable(sctp_ifa,
|
||||
dest_is_loop,
|
||||
dest_is_priv, fam);
|
||||
if (tmp_sifa == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (tmp_sifa == sifa) {
|
||||
continue;
|
||||
}
|
||||
if (stcb) {
|
||||
if (sctp_is_address_in_scope(tmp_sifa,
|
||||
stcb->asoc.ipv4_addr_legal,
|
||||
stcb->asoc.ipv6_addr_legal,
|
||||
stcb->asoc.loopback_scope,
|
||||
stcb->asoc.ipv4_local_scope,
|
||||
stcb->asoc.local_scope,
|
||||
stcb->asoc.site_scope, 0) == 0) {
|
||||
continue;
|
||||
}
|
||||
if (((non_asoc_addr_ok == 0) &&
|
||||
(sctp_is_addr_restricted(stcb, tmp_sifa))) ||
|
||||
(non_asoc_addr_ok &&
|
||||
(sctp_is_addr_restricted(stcb, tmp_sifa)) &&
|
||||
(!sctp_is_addr_pending(stcb, tmp_sifa)))) {
|
||||
/*
|
||||
* It is restricted
|
||||
* for some reason..
|
||||
* probably not yet
|
||||
* added.
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((tmp_sifa->address.sin.sin_family == AF_INET) &&
|
||||
(IN4_ISPRIVATE_ADDRESS(&(tmp_sifa->address.sin.sin_addr)))) {
|
||||
sctp_add_local_addr_restricted(stcb, tmp_sifa);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
atomic_add_int(&sifa->refcount, 1);
|
||||
}
|
||||
#endif
|
||||
return (sifa);
|
||||
}
|
||||
|
||||
|
||||
@ -3106,7 +3212,7 @@ sctp_source_address_selection(struct sctp_inpcb *inp,
|
||||
|
||||
#endif
|
||||
|
||||
/*-
|
||||
/**
|
||||
* Rules: - Find the route if needed, cache if I can. - Look at
|
||||
* interface address in route, Is it in the bound list. If so we
|
||||
* have the best source. - If not we must rotate amongst the
|
||||
@ -3509,15 +3615,17 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
|
||||
)
|
||||
/* nofragment_flag to tell if IP_DF should be set (IPv4 only) */
|
||||
{
|
||||
/*
|
||||
* Given a mbuf chain (via SCTP_BUF_NEXT()) that holds a packet
|
||||
* header WITH an SCTPHDR but no IP header, endpoint inp and sa
|
||||
* structure: - fill in the HMAC digest of any AUTH chunk in the
|
||||
* packet. - calculate and fill in the SCTP checksum. - prepend an
|
||||
* IP address header. - if boundall use INADDR_ANY. - if
|
||||
* boundspecific do source address selection. - set fragmentation
|
||||
* option for ipV4. - On return from IP output, check/adjust mtu
|
||||
* size of output interface and smallest_mtu size as well.
|
||||
/**
|
||||
* Given a mbuf chain (via SCTP_BUF_NEXT()) that holds a packet header
|
||||
* WITH an SCTPHDR but no IP header, endpoint inp and sa structure:
|
||||
* - fill in the HMAC digest of any AUTH chunk in the packet.
|
||||
* - calculate and fill in the SCTP checksum.
|
||||
* - prepend an IP address header.
|
||||
* - if boundall use INADDR_ANY.
|
||||
* - if boundspecific do source address selection.
|
||||
* - set fragmentation option for ipV4.
|
||||
* - On return from IP output, check/adjust mtu size of output
|
||||
* interface and smallest_mtu size as well.
|
||||
*/
|
||||
/* Will need ifdefs around this */
|
||||
struct mbuf *o_pak;
|
||||
@ -4409,7 +4517,7 @@ sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked
|
||||
scp.local_scope = stcb->asoc.local_scope;
|
||||
scp.site_scope = stcb->asoc.site_scope;
|
||||
|
||||
m_at = sctp_add_addresses_to_i_ia(inp, &scp, m_at, cnt_inits_to);
|
||||
m_at = sctp_add_addresses_to_i_ia(inp, stcb, &scp, m_at, cnt_inits_to);
|
||||
}
|
||||
|
||||
/* calulate the size and update pkt header and chunk header */
|
||||
@ -5538,7 +5646,7 @@ do_a_abort:
|
||||
scp.ipv4_local_scope = stc.ipv4_scope;
|
||||
scp.local_scope = stc.local_scope;
|
||||
scp.site_scope = stc.site_scope;
|
||||
m_at = sctp_add_addresses_to_i_ia(inp, &scp, m_at, cnt_inits_to);
|
||||
m_at = sctp_add_addresses_to_i_ia(inp, stcb, &scp, m_at, cnt_inits_to);
|
||||
}
|
||||
|
||||
/* tack on the operational error if present */
|
||||
|
@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
struct mbuf *
|
||||
sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp,
|
||||
struct sctp_tcb *stcb,
|
||||
struct sctp_scoping *scope,
|
||||
struct mbuf *m_at,
|
||||
int cnt_inits_to);
|
||||
|
@ -1833,7 +1833,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
|
||||
win = 0;
|
||||
KASSERT(SEQ_GEQ(tp->rcv_adv, tp->rcv_nxt),
|
||||
("tcp_input negative window: tp %p rcv_nxt %u rcv_adv %u", tp,
|
||||
tp->rcv_adv, tp->rcv_nxt));
|
||||
tp->rcv_nxt, tp->rcv_adv));
|
||||
tp->rcv_wnd = imax(win, (int)(tp->rcv_adv - tp->rcv_nxt));
|
||||
|
||||
/* Reset receive buffer auto scaling when not in bulk receive mode. */
|
||||
|
@ -244,7 +244,7 @@ tcp_twstart(struct tcpcb *tp)
|
||||
*/
|
||||
KASSERT(SEQ_GEQ(tp->rcv_adv, tp->rcv_nxt),
|
||||
("tcp_twstart negative window: tp %p rcv_nxt %u rcv_adv %u", tp,
|
||||
tp->rcv_adv, tp->rcv_nxt));
|
||||
tp->rcv_nxt, tp->rcv_adv));
|
||||
tw->last_win = (tp->rcv_adv - tp->rcv_nxt) >> tp->rcv_scale;
|
||||
|
||||
/*
|
||||
|
49
tools/regression/bin/sh/parser/heredoc10.0
Normal file
49
tools/regression/bin/sh/parser/heredoc10.0
Normal file
@ -0,0 +1,49 @@
|
||||
# $FreeBSD$
|
||||
|
||||
# It may be argued that
|
||||
# x=$(cat <<EOF
|
||||
# foo
|
||||
# EOF)
|
||||
# is a valid complete command that sets x to foo, because
|
||||
# cat <<EOF
|
||||
# foo
|
||||
# EOF
|
||||
# is a valid script even without the final newline.
|
||||
# However, if the here-document is not within a new-style command substitution
|
||||
# or there are other constructs nested inside the command substitution that
|
||||
# need terminators, the delimiter at the start of a line followed by a close
|
||||
# parenthesis is clearly a literal part of the here-document.
|
||||
|
||||
# This file contains tests that may not work with simplistic $(...) parsers.
|
||||
# The open parentheses in comments help mksh, but not zsh.
|
||||
|
||||
failures=0
|
||||
|
||||
check() {
|
||||
if ! eval "[ $* ]"; then
|
||||
echo "Failed: $*"
|
||||
: $((failures += 1))
|
||||
fi
|
||||
}
|
||||
|
||||
check '"$(cat <<EOF # (
|
||||
EOF )
|
||||
EOF
|
||||
)" = "EOF )"'
|
||||
|
||||
check '"$({ cat <<EOF # (
|
||||
EOF)
|
||||
EOF
|
||||
})" = "EOF)"'
|
||||
|
||||
check '"$(if :; then cat <<EOF # (
|
||||
EOF)
|
||||
EOF
|
||||
fi)" = "EOF)"'
|
||||
|
||||
check '"$( (cat <<EOF # (
|
||||
EOF)
|
||||
EOF
|
||||
))" = "EOF)"'
|
||||
|
||||
exit $((failures != 0))
|
58
tools/regression/bin/sh/parser/heredoc9.0
Normal file
58
tools/regression/bin/sh/parser/heredoc9.0
Normal file
@ -0,0 +1,58 @@
|
||||
# $FreeBSD$
|
||||
|
||||
# It may be argued that
|
||||
# x=$(cat <<EOF
|
||||
# foo
|
||||
# EOF)
|
||||
# is a valid complete command that sets x to foo, because
|
||||
# cat <<EOF
|
||||
# foo
|
||||
# EOF
|
||||
# is a valid script even without the final newline.
|
||||
# However, if the here-document is not within a new-style command substitution
|
||||
# or there are other constructs nested inside the command substitution that
|
||||
# need terminators, the delimiter at the start of a line followed by a close
|
||||
# parenthesis is clearly a literal part of the here-document.
|
||||
|
||||
# This file contains tests that also work with simplistic $(...) parsers.
|
||||
|
||||
failures=0
|
||||
|
||||
check() {
|
||||
if ! eval "[ $* ]"; then
|
||||
echo "Failed: $*"
|
||||
: $((failures += 1))
|
||||
fi
|
||||
}
|
||||
|
||||
check '`${SH} -c "cat <<EOF
|
||||
EOF)
|
||||
EOF
|
||||
"` = "EOF)"'
|
||||
|
||||
check '`${SH} -c "(cat <<EOF
|
||||
EOF)
|
||||
EOF
|
||||
)"` = "EOF)"'
|
||||
|
||||
check '"`cat <<EOF
|
||||
EOF x
|
||||
EOF
|
||||
`" = "EOF x"'
|
||||
|
||||
check '"`cat <<EOF
|
||||
EOF )
|
||||
EOF
|
||||
`" = "EOF )"'
|
||||
|
||||
check '"`cat <<EOF
|
||||
EOF)
|
||||
EOF
|
||||
`" = "EOF)"'
|
||||
|
||||
check '"$(cat <<EOF
|
||||
EOF x
|
||||
EOF
|
||||
)" = "EOF x"'
|
||||
|
||||
exit $((failures != 0))
|
@ -660,7 +660,7 @@ cust_comconsole () (
|
||||
sed -i "" -e '/^ttyv[0-8]/s/ on/ off/' ${NANO_WORLDDIR}/etc/ttys
|
||||
|
||||
# Tell loader to use serial console early.
|
||||
echo " -h" > ${NANO_WORLDDIR}/boot.config
|
||||
echo "${NANO_BOOT2CFG}" > ${NANO_WORLDDIR}/boot.config
|
||||
)
|
||||
|
||||
#######################################################################
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" Copyright (c) 2005-2009 Stanislav Sedov <stas@FreeBSD.org>
|
||||
.\" Copyright (c) 2005-2011 Stanislav Sedov <stas@FreeBSD.org>
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
@ -24,7 +24,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd July 31, 2009
|
||||
.Dd May 13, 2011
|
||||
.Dt FUSER 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -66,7 +66,7 @@ Send signal to reported processes
|
||||
.It Fl m
|
||||
Search through mmapped files too.
|
||||
.It Fl u
|
||||
Write the user name associated with each process to stdout.
|
||||
Write the user name associated with each process to stderr.
|
||||
.It Fl M
|
||||
Extract values associated with the name list from the specified core
|
||||
instead of the default
|
||||
@ -114,9 +114,9 @@ utility returns 0 on successful completion and >0 otherwise.
|
||||
.Sh EXAMPLES
|
||||
The command:
|
||||
.Dq Li "fuser -fu ."
|
||||
writes to standart output the process IDs of processes that are using the
|
||||
writes to standard output the process IDs of processes that are using the
|
||||
current directory and writes to stderr an indication of how those processes are
|
||||
using the direcory and user names associated with the processes that are using
|
||||
using the directory and user names associated with the processes that are using
|
||||
this directory.
|
||||
.Sh SEE ALSO
|
||||
.Xr fstat 1 ,
|
||||
@ -125,7 +125,7 @@ this directory.
|
||||
.Xr iostat 8 ,
|
||||
.Xr pstat 8 ,
|
||||
.Xr vmstat 8
|
||||
.Sh STANDARTS
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Nm
|
||||
utility is expected to conform to
|
||||
@ -141,6 +141,11 @@ interface the report will be limited to filesystems the
|
||||
.Nm
|
||||
utility knows about (currently only cd9660, devfs, nfs, ntfs, nwfs, udf,
|
||||
ufs and zfs).
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
utility appeared in
|
||||
.Fx 9.0 .
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
|
@ -125,6 +125,7 @@ __FBSDID("$FreeBSD$");
|
||||
/* process when trimming this file. */
|
||||
#define CE_CREATE 0x0100 /* Create the log file if it does not exist. */
|
||||
#define CE_NODUMP 0x0200 /* Set 'nodump' on newly created log file. */
|
||||
#define CE_PID2CMD 0x0400 /* Replace PID file with a shell command.*/
|
||||
|
||||
#define MIN_PID 5 /* Don't touch pids lower than this */
|
||||
#define MAX_PID 99999 /* was lower, see /usr/include/sys/proc.h */
|
||||
@ -154,7 +155,7 @@ const struct compress_types compress_type[COMPRESS_TYPES] = {
|
||||
struct conf_entry {
|
||||
STAILQ_ENTRY(conf_entry) cf_nextp;
|
||||
char *log; /* Name of the log */
|
||||
char *pid_file; /* PID file */
|
||||
char *pid_cmd_file; /* PID or command file */
|
||||
char *r_reason; /* The reason this file is being rotated */
|
||||
int firstcreate; /* Creating log for the first time (-C). */
|
||||
int rotate; /* Non-zero if this file should be rotated */
|
||||
@ -178,7 +179,8 @@ struct sigwork_entry {
|
||||
int sw_pidok; /* true if pid value is valid */
|
||||
pid_t sw_pid; /* the process id from the PID file */
|
||||
const char *sw_pidtype; /* "daemon" or "process group" */
|
||||
char sw_fname[1]; /* file the PID was read from */
|
||||
int run_cmd; /* run command or send PID to signal */
|
||||
char sw_fname[1]; /* file the PID was read from or shell cmd */
|
||||
};
|
||||
|
||||
struct zipwork_entry {
|
||||
@ -384,9 +386,9 @@ init_entry(const char *fname, struct conf_entry *src_entry)
|
||||
err(1, "strdup for %s", fname);
|
||||
|
||||
if (src_entry != NULL) {
|
||||
tempwork->pid_file = NULL;
|
||||
if (src_entry->pid_file)
|
||||
tempwork->pid_file = strdup(src_entry->pid_file);
|
||||
tempwork->pid_cmd_file = NULL;
|
||||
if (src_entry->pid_cmd_file)
|
||||
tempwork->pid_cmd_file = strdup(src_entry->pid_cmd_file);
|
||||
tempwork->r_reason = NULL;
|
||||
tempwork->firstcreate = 0;
|
||||
tempwork->rotate = 0;
|
||||
@ -406,7 +408,7 @@ init_entry(const char *fname, struct conf_entry *src_entry)
|
||||
tempwork->def_cfg = src_entry->def_cfg;
|
||||
} else {
|
||||
/* Initialize as a "do-nothing" entry */
|
||||
tempwork->pid_file = NULL;
|
||||
tempwork->pid_cmd_file = NULL;
|
||||
tempwork->r_reason = NULL;
|
||||
tempwork->firstcreate = 0;
|
||||
tempwork->rotate = 0;
|
||||
@ -441,9 +443,9 @@ free_entry(struct conf_entry *ent)
|
||||
ent->log = NULL;
|
||||
}
|
||||
|
||||
if (ent->pid_file != NULL) {
|
||||
free(ent->pid_file);
|
||||
ent->pid_file = NULL;
|
||||
if (ent->pid_cmd_file != NULL) {
|
||||
free(ent->pid_cmd_file);
|
||||
ent->pid_cmd_file = NULL;
|
||||
}
|
||||
|
||||
if (ent->r_reason != NULL) {
|
||||
@ -1291,6 +1293,9 @@ no_trimat:
|
||||
case 'n':
|
||||
working->flags |= CE_NOSIGNAL;
|
||||
break;
|
||||
case 'r':
|
||||
working->flags |= CE_PID2CMD;
|
||||
break;
|
||||
case 'u':
|
||||
working->flags |= CE_SIGNALGROUP;
|
||||
break;
|
||||
@ -1324,10 +1329,10 @@ no_trimat:
|
||||
*parse = '\0';
|
||||
}
|
||||
|
||||
working->pid_file = NULL;
|
||||
working->pid_cmd_file = NULL;
|
||||
if (q && *q) {
|
||||
if (*q == '/')
|
||||
working->pid_file = strdup(q);
|
||||
working->pid_cmd_file = strdup(q);
|
||||
else if (isdigit(*q))
|
||||
goto got_sig;
|
||||
else
|
||||
@ -1364,16 +1369,16 @@ no_trimat:
|
||||
if ((working->flags & CE_NOSIGNAL) == CE_NOSIGNAL) {
|
||||
/*
|
||||
* This config-entry specified 'n' for nosignal,
|
||||
* see if it also specified an explicit pid_file.
|
||||
* see if it also specified an explicit pid_cmd_file.
|
||||
* This would be a pretty pointless combination.
|
||||
*/
|
||||
if (working->pid_file != NULL) {
|
||||
if (working->pid_cmd_file != NULL) {
|
||||
warnx("Ignoring '%s' because flag 'n' was specified in line:\n%s",
|
||||
working->pid_file, errline);
|
||||
free(working->pid_file);
|
||||
working->pid_file = NULL;
|
||||
working->pid_cmd_file, errline);
|
||||
free(working->pid_cmd_file);
|
||||
working->pid_cmd_file = NULL;
|
||||
}
|
||||
} else if (working->pid_file == NULL) {
|
||||
} else if (working->pid_cmd_file == NULL) {
|
||||
/*
|
||||
* This entry did not specify the 'n' flag, which
|
||||
* means it should signal syslogd unless it had
|
||||
@ -1388,7 +1393,7 @@ no_trimat:
|
||||
working->flags &= ~CE_SIGNALGROUP;
|
||||
}
|
||||
if (needroot)
|
||||
working->pid_file = strdup(path_syslogpid);
|
||||
working->pid_cmd_file = strdup(path_syslogpid);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1826,7 +1831,7 @@ do_rotate(const struct conf_entry *ent)
|
||||
* multiple log files had to be rotated.
|
||||
*/
|
||||
swork = NULL;
|
||||
if (ent->pid_file != NULL)
|
||||
if (ent->pid_cmd_file != NULL)
|
||||
swork = save_sigwork(ent);
|
||||
if (ent->numlogs > 0 && ent->compress > COMPRESS_NONE) {
|
||||
/*
|
||||
@ -1845,6 +1850,7 @@ do_sigwork(struct sigwork_entry *swork)
|
||||
{
|
||||
struct sigwork_entry *nextsig;
|
||||
int kres, secs;
|
||||
char *tmp;
|
||||
|
||||
if (!(swork->sw_pidok) || swork->sw_pid == 0)
|
||||
return; /* no work to do... */
|
||||
@ -1887,6 +1893,24 @@ do_sigwork(struct sigwork_entry *swork)
|
||||
return;
|
||||
}
|
||||
|
||||
if (swork->run_cmd) {
|
||||
asprintf(&tmp, "%s %d", swork->sw_fname, swork->sw_signum);
|
||||
if (tmp == NULL) {
|
||||
warn("can't allocate memory to run %s",
|
||||
swork->sw_fname);
|
||||
return;
|
||||
}
|
||||
if (verbose)
|
||||
printf("Run command: %s\n", tmp);
|
||||
kres = system(tmp);
|
||||
if (kres) {
|
||||
warnx("%s: returned non-zero exit code: %d",
|
||||
tmp, kres);
|
||||
}
|
||||
free(tmp);
|
||||
return;
|
||||
}
|
||||
|
||||
kres = kill(swork->sw_pid, swork->sw_signum);
|
||||
if (kres != 0) {
|
||||
/*
|
||||
@ -2016,7 +2040,7 @@ save_sigwork(const struct conf_entry *ent)
|
||||
sprev = NULL;
|
||||
ndiff = 1;
|
||||
SLIST_FOREACH(stmp, &swhead, sw_nextp) {
|
||||
ndiff = strcmp(ent->pid_file, stmp->sw_fname);
|
||||
ndiff = strcmp(ent->pid_cmd_file, stmp->sw_fname);
|
||||
if (ndiff > 0)
|
||||
break;
|
||||
if (ndiff == 0) {
|
||||
@ -2032,11 +2056,18 @@ save_sigwork(const struct conf_entry *ent)
|
||||
if (stmp != NULL && ndiff == 0)
|
||||
return (stmp);
|
||||
|
||||
tmpsiz = sizeof(struct sigwork_entry) + strlen(ent->pid_file) + 1;
|
||||
tmpsiz = sizeof(struct sigwork_entry) + strlen(ent->pid_cmd_file) + 1;
|
||||
stmp = malloc(tmpsiz);
|
||||
set_swpid(stmp, ent);
|
||||
|
||||
stmp->run_cmd = 0;
|
||||
/* If this is a command to run we just set the flag and run command */
|
||||
if (ent->flags & CE_PID2CMD) {
|
||||
stmp->run_cmd = 1;
|
||||
} else {
|
||||
set_swpid(stmp, ent);
|
||||
}
|
||||
stmp->sw_signum = ent->sig;
|
||||
strcpy(stmp->sw_fname, ent->pid_file);
|
||||
strcpy(stmp->sw_fname, ent->pid_cmd_file);
|
||||
if (sprev == NULL)
|
||||
SLIST_INSERT_HEAD(&swhead, stmp, sw_nextp);
|
||||
else
|
||||
@ -2113,7 +2144,7 @@ set_swpid(struct sigwork_entry *swork, const struct conf_entry *ent)
|
||||
swork->sw_pidtype = "process-group";
|
||||
}
|
||||
|
||||
f = fopen(ent->pid_file, "r");
|
||||
f = fopen(ent->pid_cmd_file, "r");
|
||||
if (f == NULL) {
|
||||
if (errno == ENOENT && enforcepid == 0) {
|
||||
/*
|
||||
@ -2124,9 +2155,9 @@ set_swpid(struct sigwork_entry *swork, const struct conf_entry *ent)
|
||||
* files that the process would have been using.
|
||||
*/
|
||||
swork->sw_pidok = 1;
|
||||
warnx("pid file doesn't exist: %s", ent->pid_file);
|
||||
warnx("pid file doesn't exist: %s", ent->pid_cmd_file);
|
||||
} else
|
||||
warn("can't open pid file: %s", ent->pid_file);
|
||||
warn("can't open pid file: %s", ent->pid_cmd_file);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2139,9 +2170,9 @@ set_swpid(struct sigwork_entry *swork, const struct conf_entry *ent)
|
||||
*/
|
||||
if (feof(f) && enforcepid == 0) {
|
||||
swork->sw_pidok = 1;
|
||||
warnx("pid file is empty: %s", ent->pid_file);
|
||||
warnx("pid/cmd file is empty: %s", ent->pid_cmd_file);
|
||||
} else
|
||||
warn("can't read from pid file: %s", ent->pid_file);
|
||||
warn("can't read from pid file: %s", ent->pid_cmd_file);
|
||||
(void)fclose(f);
|
||||
return;
|
||||
}
|
||||
@ -2154,10 +2185,10 @@ set_swpid(struct sigwork_entry *swork, const struct conf_entry *ent)
|
||||
rval = strtol(linep, &endp, 10);
|
||||
if (*endp != '\0' && !isspacech(*endp)) {
|
||||
warnx("pid file does not start with a valid number: %s",
|
||||
ent->pid_file);
|
||||
ent->pid_cmd_file);
|
||||
} else if (rval < minok || rval > maxok) {
|
||||
warnx("bad value '%ld' for process number in %s",
|
||||
rval, ent->pid_file);
|
||||
rval, ent->pid_cmd_file);
|
||||
if (verbose)
|
||||
warnx("\t(expecting value between %ld and %ld)",
|
||||
minok, maxok);
|
||||
|
@ -301,9 +301,16 @@ log file using
|
||||
.It Cm N
|
||||
indicates that there is no process which needs to be signaled
|
||||
when this log file is rotated.
|
||||
.It Cm R
|
||||
if this flag is set the
|
||||
.Xr newsyslog 8
|
||||
will run shell command defined in
|
||||
.Ar path_to_pid_cmd_file
|
||||
after rotation instead of trying to send signal to a process id
|
||||
stored in the file.
|
||||
.It Cm U
|
||||
indicates that the file specified by
|
||||
.Ar path_to_pid_file
|
||||
.Ar path_to_pid_cmd_file
|
||||
will contain the ID for a process group instead of a process.
|
||||
This option also requires that the first line in that file
|
||||
be a negative value to distinguish it from a process ID.
|
||||
@ -319,7 +326,7 @@ can be used as a placeholder to create a
|
||||
.Ar flags
|
||||
field when you need to specify any of the following fields.
|
||||
.El
|
||||
.It Ar path_to_pid_file
|
||||
.It Ar path_to_pid_cmd_file
|
||||
This optional field specifies the file name containing a daemon's
|
||||
process ID or to find a group process ID if the
|
||||
.Cm U
|
||||
@ -340,6 +347,12 @@ switch.
|
||||
This field must start with
|
||||
.Ql /
|
||||
in order to be recognized properly.
|
||||
When used with the
|
||||
.Cm R
|
||||
flag, the file is treated as a path to a binary to be executed
|
||||
by the
|
||||
.Xr newsyslog 8
|
||||
after rotation instead of sending the signal out.
|
||||
.It Ar signal_number
|
||||
This optional field specifies the signal number that will be sent
|
||||
to the daemon process (or to all processes in a process group, if the
|
||||
|
Loading…
x
Reference in New Issue
Block a user