Date: Sat, 14 May 2011 19:20:14 +0000 (UTC) From: Attilio Rao <attilio@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r221910 - in projects/largeSMP: . contrib/top etc sbin/hastctl sbin/hastd share/mk sys/conf sys/dev/ath/ath_hal sys/dev/ath/ath_hal/ar5416 sys/dev/ath/ath_hal/ar9002 sys/dev/usb sys/ia6... Message-ID: <201105141920.p4EJKEvT012818@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: attilio Date: Sat May 14 19:20:13 2011 New Revision: 221910 URL: http://svn.freebsd.org/changeset/base/221910 Log: MFC Added: projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_9287.c - copied unchanged from r221906, head/sys/dev/ath/ath_hal/ah_eeprom_9287.c projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_9287.h - copied unchanged from r221906, head/sys/dev/ath/ath_hal/ah_eeprom_9287.h projects/largeSMP/tools/regression/bin/sh/parser/heredoc10.0 - copied unchanged from r221906, head/tools/regression/bin/sh/parser/heredoc10.0 projects/largeSMP/tools/regression/bin/sh/parser/heredoc9.0 - copied unchanged from r221906, head/tools/regression/bin/sh/parser/heredoc9.0 Modified: projects/largeSMP/MAINTAINERS projects/largeSMP/etc/network.subr projects/largeSMP/sbin/hastctl/hastctl.c projects/largeSMP/sbin/hastd/primary.c projects/largeSMP/sbin/hastd/secondary.c projects/largeSMP/sbin/hastd/subr.c projects/largeSMP/sbin/hastd/subr.h projects/largeSMP/sys/conf/kern.mk projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom.h projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_v1.c projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_v14.c projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_v3.c projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_v4k.c projects/largeSMP/sys/dev/ath/ath_hal/ah_internal.h projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416.h projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416phy.h projects/largeSMP/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c projects/largeSMP/sys/dev/usb/usbdevs projects/largeSMP/sys/ia64/ia64/exception.S projects/largeSMP/sys/ia64/ia64/syscall.S projects/largeSMP/sys/ia64/include/ia64_cpu.h projects/largeSMP/sys/ia64/include/pcpu.h projects/largeSMP/sys/netinet/sctp_output.c projects/largeSMP/sys/netinet/sctp_output.h projects/largeSMP/sys/netinet/tcp_input.c projects/largeSMP/sys/netinet/tcp_timewait.c projects/largeSMP/tools/tools/nanobsd/nanobsd.sh projects/largeSMP/usr.bin/fstat/fuser.1 projects/largeSMP/usr.sbin/newsyslog/newsyslog.c projects/largeSMP/usr.sbin/newsyslog/newsyslog.conf.5 Directory Properties: projects/largeSMP/ (props changed) projects/largeSMP/cddl/contrib/opensolaris/ (props changed) projects/largeSMP/contrib/bind9/ (props changed) projects/largeSMP/contrib/binutils/ (props changed) projects/largeSMP/contrib/bzip2/ (props changed) projects/largeSMP/contrib/dialog/ (props changed) projects/largeSMP/contrib/ee/ (props changed) projects/largeSMP/contrib/expat/ (props changed) projects/largeSMP/contrib/file/ (props changed) projects/largeSMP/contrib/gcc/ (props changed) projects/largeSMP/contrib/gdb/ (props changed) projects/largeSMP/contrib/gdtoa/ (props changed) projects/largeSMP/contrib/gnu-sort/ (props changed) projects/largeSMP/contrib/groff/ (props changed) projects/largeSMP/contrib/less/ (props changed) projects/largeSMP/contrib/libpcap/ (props changed) projects/largeSMP/contrib/libstdc++/ (props changed) projects/largeSMP/contrib/llvm/ (props changed) projects/largeSMP/contrib/llvm/tools/clang/ (props changed) projects/largeSMP/contrib/ncurses/ (props changed) projects/largeSMP/contrib/netcat/ (props changed) projects/largeSMP/contrib/ntp/ (props changed) projects/largeSMP/contrib/one-true-awk/ (props changed) projects/largeSMP/contrib/openbsm/ (props changed) projects/largeSMP/contrib/openpam/ (props changed) projects/largeSMP/contrib/pf/ (props changed) projects/largeSMP/contrib/sendmail/ (props changed) projects/largeSMP/contrib/tcpdump/ (props changed) projects/largeSMP/contrib/tcsh/ (props changed) projects/largeSMP/contrib/top/ (props changed) projects/largeSMP/contrib/top/install-sh (props changed) projects/largeSMP/contrib/tzcode/stdtime/ (props changed) projects/largeSMP/contrib/tzcode/zic/ (props changed) projects/largeSMP/contrib/tzdata/ (props changed) projects/largeSMP/contrib/wpa/ (props changed) projects/largeSMP/contrib/xz/ (props changed) projects/largeSMP/crypto/openssh/ (props changed) projects/largeSMP/crypto/openssl/ (props changed) projects/largeSMP/gnu/lib/ (props changed) projects/largeSMP/gnu/usr.bin/binutils/ (props changed) projects/largeSMP/gnu/usr.bin/cc/cc_tools/ (props changed) projects/largeSMP/gnu/usr.bin/gdb/ (props changed) projects/largeSMP/lib/libc/ (props changed) projects/largeSMP/lib/libc/stdtime/ (props changed) projects/largeSMP/lib/libutil/ (props changed) projects/largeSMP/lib/libz/ (props changed) projects/largeSMP/sbin/ (props changed) projects/largeSMP/sbin/ipfw/ (props changed) projects/largeSMP/share/mk/bsd.arch.inc.mk (props changed) projects/largeSMP/share/zoneinfo/ (props changed) projects/largeSMP/sys/ (props changed) projects/largeSMP/sys/amd64/include/xen/ (props changed) projects/largeSMP/sys/boot/ (props changed) projects/largeSMP/sys/boot/i386/efi/ (props changed) projects/largeSMP/sys/boot/ia64/efi/ (props changed) projects/largeSMP/sys/boot/ia64/ski/ (props changed) projects/largeSMP/sys/boot/powerpc/boot1.chrp/ (props changed) projects/largeSMP/sys/boot/powerpc/ofw/ (props changed) projects/largeSMP/sys/cddl/contrib/opensolaris/ (props changed) projects/largeSMP/sys/conf/ (props changed) projects/largeSMP/sys/contrib/dev/acpica/ (props changed) projects/largeSMP/sys/contrib/octeon-sdk/ (props changed) projects/largeSMP/sys/contrib/pf/ (props changed) projects/largeSMP/sys/contrib/x86emu/ (props changed) projects/largeSMP/usr.bin/calendar/ (props changed) projects/largeSMP/usr.bin/csup/ (props changed) projects/largeSMP/usr.bin/procstat/ (props changed) projects/largeSMP/usr.sbin/ndiscvt/ (props changed) projects/largeSMP/usr.sbin/zic/ (props changed) Modified: projects/largeSMP/MAINTAINERS ============================================================================== --- projects/largeSMP/MAINTAINERS Sat May 14 19:03:54 2011 (r221909) +++ projects/largeSMP/MAINTAINERS Sat May 14 19:20:13 2011 (r221910) @@ -108,7 +108,7 @@ linux emul emulation Please discuss chan 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. Modified: projects/largeSMP/etc/network.subr ============================================================================== --- projects/largeSMP/etc/network.subr Sat May 14 19:03:54 2011 (r221909) +++ projects/largeSMP/etc/network.subr Sat May 14 19:20:13 2011 (r221910) @@ -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() Modified: projects/largeSMP/sbin/hastctl/hastctl.c ============================================================================== --- projects/largeSMP/sbin/hastctl/hastctl.c Sat May 14 19:03:54 2011 (r221909) +++ projects/largeSMP/sbin/hastctl/hastctl.c Sat May 14 19:20:13 2011 (r221910) @@ -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... */ Modified: projects/largeSMP/sbin/hastd/primary.c ============================================================================== --- projects/largeSMP/sbin/hastd/primary.c Sat May 14 19:03:54 2011 (r221909) +++ projects/largeSMP/sbin/hastd/primary.c Sat May 14 19:20:13 2011 (r221910) @@ -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); } Modified: projects/largeSMP/sbin/hastd/secondary.c ============================================================================== --- projects/largeSMP/sbin/hastd/secondary.c Sat May 14 19:03:54 2011 (r221909) +++ projects/largeSMP/sbin/hastd/secondary.c Sat May 14 19:20:13 2011 (r221910) @@ -436,7 +436,7 @@ hastd_secondary(struct hast_resource *re init_local(res); init_environment(); - if (drop_privs(true) != 0) + if (drop_privs(res) != 0) exit(EX_CONFIG); pjdlog_info("Privileges successfully dropped."); Modified: projects/largeSMP/sbin/hastd/subr.c ============================================================================== --- projects/largeSMP/sbin/hastd/subr.c Sat May 14 19:03:54 2011 (r221909) +++ projects/largeSMP/sbin/hastd/subr.c Sat May 14 19:20:13 2011 (r221910) @@ -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); } Modified: projects/largeSMP/sbin/hastd/subr.h ============================================================================== --- projects/largeSMP/sbin/hastd/subr.h Sat May 14 19:03:54 2011 (r221909) +++ projects/largeSMP/sbin/hastd/subr.h Sat May 14 19:20:13 2011 (r221910) @@ -51,6 +51,6 @@ int snprlcat(char *str, size_t size, con 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_ */ Modified: projects/largeSMP/sys/conf/kern.mk ============================================================================== --- projects/largeSMP/sys/conf/kern.mk Sat May 14 19:03:54 2011 (r221909) +++ projects/largeSMP/sys/conf/kern.mk Sat May 14 19:20:13 2011 (r221910) @@ -25,11 +25,21 @@ CWARNFLAGS?= -Wall -Wredundant-decls -Wn # 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 Modified: projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom.h ============================================================================== --- projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom.h Sat May 14 19:03:54 2011 (r221909) +++ projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom.h Sat May 14 19:20:13 2011 (r221910) @@ -133,4 +133,5 @@ HAL_STATUS ath_hal_v1EepromAttach(struct 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_ */ Copied: projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_9287.c (from r221906, head/sys/dev/ath/ath_hal/ah_eeprom_9287.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_9287.c Sat May 14 19:20:13 2011 (r221910, copy of r221906, head/sys/dev/ath/ath_hal/ah_eeprom_9287.c) @@ -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 +} Copied: projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_9287.h (from r221906, head/sys/dev/ath/ath_hal/ah_eeprom_9287.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_9287.h Sat May 14 19:20:13 2011 (r221910, copy of r221906, head/sys/dev/ath/ath_hal/ah_eeprom_9287.h) @@ -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__ */ Modified: projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_v1.c ============================================================================== --- projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_v1.c Sat May 14 19:03:54 2011 (r221909) +++ projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_v1.c Sat May 14 19:20:13 2011 (r221910) @@ -68,7 +68,7 @@ v1EepromGet(struct ath_hal *ah, int para } } -static HAL_BOOL +static HAL_STATUS v1EepromSet(struct ath_hal *ah, int param, int v) { return HAL_EINVAL; Modified: projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_v14.c ============================================================================== --- projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_v14.c Sat May 14 19:03:54 2011 (r221909) +++ projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_v14.c Sat May 14 19:20:13 2011 (r221910) @@ -84,8 +84,10 @@ v14EepromGet(struct ath_hal *ah, int par 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 par #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; Modified: projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_v3.c ============================================================================== --- projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_v3.c Sat May 14 19:03:54 2011 (r221909) +++ projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_v3.c Sat May 14 19:20:13 2011 (r221910) @@ -1665,7 +1665,7 @@ legacyEepromGet(struct ath_hal *ah, int 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; Modified: projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_v4k.c ============================================================================== --- projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_v4k.c Sat May 14 19:03:54 2011 (r221909) +++ projects/largeSMP/sys/dev/ath/ath_hal/ah_eeprom_v4k.c Sat May 14 19:20:13 2011 (r221910) @@ -116,7 +116,7 @@ v4kEepromGet(struct ath_hal *ah, int par #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; Modified: projects/largeSMP/sys/dev/ath/ath_hal/ah_internal.h ============================================================================== --- projects/largeSMP/sys/dev/ath/ath_hal/ah_internal.h Sat May 14 19:03:54 2011 (r221909) +++ projects/largeSMP/sys/dev/ath/ath_hal/ah_internal.h Sat May 14 19:20:13 2011 (r221910) @@ -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, Modified: projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416.h ============================================================================== --- projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416.h Sat May 14 19:03:54 2011 (r221909) +++ projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416.h Sat May 14 19:20:13 2011 (r221910) @@ -199,7 +199,8 @@ extern HAL_STATUS ar5416GetCapability(st 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); Modified: projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c ============================================================================== --- projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c Sat May 14 19:03:54 2011 (r221909) +++ projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c Sat May 14 19:20:13 2011 (r221910) @@ -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, H 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; } Modified: projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c ============================================================================== --- projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c Sat May 14 19:03:54 2011 (r221909) +++ projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c Sat May 14 19:20:13 2011 (r221910) @@ -146,7 +146,7 @@ ar5416Reset(struct ath_hal *ah, HAL_OPMO /* 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, cons /* * 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 *a 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; *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105141920.p4EJKEvT012818>