diff options
863 files changed, 25903 insertions, 9351 deletions
@@ -205,7 +205,7 @@ _TARGET_ARCH?= ${MACHINE_ARCH} # The user can define ALWAYS_CHECK_MAKE to have this check performed # for all targets. # -.if defined(ALWAYS_CHECK_MAKE) +.if defined(ALWAYS_CHECK_MAKE) || !defined(.PARSEDIR) ${TGTS}: upgrade_checks .else buildworld: upgrade_checks diff --git a/Makefile.inc1 b/Makefile.inc1 index a26df46..6ee07b1 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -569,10 +569,9 @@ _worldtmp: .PHONY .endif .else rm -rf ${WORLDTMP}/legacy/usr/include -# XXX - These three can depend on any header file. - rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c +# XXX - These can depend on any header file. + rm -f ${OBJTREE}${.CURDIR}/lib/libsysdecode/ioctl.c rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c - rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c .endif .for _dir in \ lib usr legacy/bin legacy/usr @@ -1230,7 +1229,7 @@ reinstallkernel reinstallkernel.debug: _installcheck_kernel ${CROSSENV} PATH=${TMPPATH} \ ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//} .endif -.if ${BUILDKERNELS:[#]} > 1 +.if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS) .for _kernel in ${BUILDKERNELS:[2..-1]} @echo "--------------------------------------------------------------" @echo ">>> Installing kernel ${_kernel}" @@ -1261,7 +1260,7 @@ distributekernel distributekernel.debug: ${DESTDIR}/${DISTDIR}/kernel.meta .endif .endif -.if ${BUILDKERNELS:[#]} > 1 +.if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS) .for _kernel in ${BUILDKERNELS:[2..-1]} .if defined(NO_ROOT) echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta @@ -1284,27 +1283,43 @@ packagekernel: .if defined(NO_ROOT) .if !defined(NO_INSTALLKERNEL) cd ${DESTDIR}/${DISTDIR}/kernel; \ - tar cvf - @${DESTDIR}/${DISTDIR}/kernel.meta | \ + tar cvf - --exclude '*.debug' \ + @${DESTDIR}/${DISTDIR}/kernel.meta | \ ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz .endif -.if ${BUILDKERNELS:[#]} > 1 + cd ${DESTDIR}/${DISTDIR}/kernel; \ + tar cvf - --include '*/*/*.debug' \ + @${DESTDIR}/${DISTDIR}/kernel.meta | \ + ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz +.if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS) .for _kernel in ${BUILDKERNELS:[2..-1]} cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ - tar cvf - @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \ + tar cvf - --exclude '*.debug' \ + @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \ ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz + cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ + tar cvf - --include '*/*/*.debug' \ + @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \ + ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz .endfor .endif .else .if !defined(NO_INSTALLKERNEL) cd ${DESTDIR}/${DISTDIR}/kernel; \ - tar cvf - . | \ + tar cvf - --exclude '*.debug' . | \ ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz .endif -.if ${BUILDKERNELS:[#]} > 1 + cd ${DESTDIR}/${DISTDIR}/kernel; \ + tar cvf - --include '*/*/*.debug' $$(eval find .) | \ + ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz +.if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS) .for _kernel in ${BUILDKERNELS:[2..-1]} cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ - tar cvf - . | \ + tar cvf - --exclude '*.debug' . | \ ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz + cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ + tar cvf - --include '*/*/*.debug' $$(eval find .) | \ + ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz .endfor .endif .endif @@ -1409,11 +1424,13 @@ _vtfontcvt= usr.bin/vtfontcvt _sed= usr.bin/sed .endif -.if ${BOOTSTRAPPING} < 1000002 +.if ${BOOTSTRAPPING} < 1000033 _libopenbsd= lib/libopenbsd _m4= usr.bin/m4 +_lex= usr.bin/lex ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd +${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4 .endif .if ${BOOTSTRAPPING} < 1000026 @@ -1427,12 +1444,6 @@ ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd _cat= bin/cat .endif -.if ${BOOTSTRAPPING} < 1000033 -_lex= usr.bin/lex - -${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4 -.endif - # r277259 crunchide: Correct 64-bit section header offset # r281674 crunchide: always include both 32- and 64-bit ELF support # r285986 crunchen: use STRIPBIN rather than STRIP @@ -31,6 +31,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11.x IS SLOW: disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20160113: + With the addition of ypldap(8), a new _ypldap user is now required + during installworld. "mergemaster -p" can be used to add the user + prior to installworld, as documented in the handbook. + 20151216: The tftp loader (pxeboot) now uses the option root-path directive. As a consequence it no longer looks for a pxeboot.4th file on the tftp diff --git a/bin/sh/eval.c b/bin/sh/eval.c index 46c00de..949157d 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -496,10 +496,12 @@ exphere(union node *redir, struct arglist *fn) struct jmploc *savehandler; struct localvar *savelocalvars; int need_longjmp = 0; + unsigned char saveoptreset; redir->nhere.expdoc = ""; savelocalvars = localvars; localvars = NULL; + saveoptreset = shellparam.reset; forcelocal++; savehandler = handler; if (setjmp(jmploc.loc)) @@ -514,6 +516,7 @@ exphere(union node *redir, struct arglist *fn) forcelocal--; poplocalvars(); localvars = savelocalvars; + shellparam.reset = saveoptreset; if (need_longjmp) longjmp(handler->loc, 1); INTON; @@ -647,6 +650,7 @@ evalbackcmd(union node *n, struct backcmd *result) struct jmploc jmploc; struct jmploc *savehandler; struct localvar *savelocalvars; + unsigned char saveoptreset; result->fd = -1; result->buf = NULL; @@ -661,6 +665,7 @@ evalbackcmd(union node *n, struct backcmd *result) if (is_valid_fast_cmdsubst(n)) { savelocalvars = localvars; localvars = NULL; + saveoptreset = shellparam.reset; forcelocal++; savehandler = handler; if (setjmp(jmploc.loc)) { @@ -671,6 +676,7 @@ evalbackcmd(union node *n, struct backcmd *result) forcelocal--; poplocalvars(); localvars = savelocalvars; + shellparam.reset = saveoptreset; longjmp(handler->loc, 1); } } else { @@ -681,6 +687,7 @@ evalbackcmd(union node *n, struct backcmd *result) forcelocal--; poplocalvars(); localvars = savelocalvars; + shellparam.reset = saveoptreset; } else { if (pipe(pip) < 0) error("Pipe call failed: %s", strerror(errno)); @@ -1032,12 +1039,12 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd) reffunc(cmdentry.u.func); savehandler = handler; if (setjmp(jmploc.loc)) { - freeparam(&shellparam); - shellparam = saveparam; popredir(); unreffunc(cmdentry.u.func); poplocalvars(); localvars = savelocalvars; + freeparam(&shellparam); + shellparam = saveparam; funcnest--; handler = savehandler; longjmp(handler->loc, 1); diff --git a/bin/sh/exec.c b/bin/sh/exec.c index 7d18c3c..ab86b76 100644 --- a/bin/sh/exec.c +++ b/bin/sh/exec.c @@ -439,12 +439,14 @@ success: int find_builtin(const char *name, int *special) { - const struct builtincmd *bp; + const unsigned char *bp; + size_t len; - for (bp = builtincmd ; bp->name ; bp++) { - if (*bp->name == *name && equal(bp->name, name)) { - *special = bp->special; - return bp->code; + len = strlen(name); + for (bp = builtincmd ; *bp ; bp += 2 + bp[0]) { + if (bp[0] == len && memcmp(bp + 2, name, len) == 0) { + *special = (bp[1] & BUILTIN_SPECIAL) != 0; + return bp[1] & ~BUILTIN_SPECIAL; } } return -1; diff --git a/bin/sh/expand.c b/bin/sh/expand.c index 59ba549..c661541 100644 --- a/bin/sh/expand.c +++ b/bin/sh/expand.c @@ -951,8 +951,8 @@ varvalue(const char *name, int quoted, int subtype, int flag, case '-': p = buf; for (i = 0 ; i < NSHORTOPTS ; i++) { - if (optlist[i].val) - *p++ = optlist[i].letter; + if (optval[i]) + *p++ = optletter[i]; } *p = '\0'; strtodest(buf, flag, subtype, quoted, dst); diff --git a/bin/sh/mkbuiltins b/bin/sh/mkbuiltins index 1be7ff1..02be8ab 100755 --- a/bin/sh/mkbuiltins +++ b/bin/sh/mkbuiltins @@ -62,17 +62,16 @@ echo 'int (*const builtinfunc[])(int, char **) = {' awk '/^[^#]/ { printf "\t%s,\n", $1}' $temp echo '}; -const struct builtincmd builtincmd[] = {' +const unsigned char builtincmd[] = {' awk '{ for (i = 2 ; i <= NF ; i++) { if ($i == "-s") { spc = 1; } else { - printf "\t{ \"%s\", %d, %d },\n", $i, NR-1, spc + printf "\t\"\\%03o\\%03o%s\"\n", length($i), (spc ? 128 : 0) + NR-1, $i spc = 0; } }}' $temp -echo ' { NULL, 0, 0 } -};' +echo '};' exec > builtins.h cat <<\! @@ -85,14 +84,10 @@ cat <<\! tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ < $temp | awk '{ printf "#define %s %d\n", $1, NR-1}' echo ' -struct builtincmd { - const char *name; - int code; - int special; -}; +#define BUILTIN_SPECIAL 0x80 extern int (*const builtinfunc[])(int, char **); -extern const struct builtincmd builtincmd[]; +extern const unsigned char builtincmd[]; ' awk '{ printf "int %s(int, char **);\n", $1}' $temp rm -f $temp diff --git a/bin/sh/options.c b/bin/sh/options.c index d131200..606ccfb 100644 --- a/bin/sh/options.c +++ b/bin/sh/options.c @@ -91,7 +91,7 @@ procargs(int argc, char **argv) if (argc > 0) argptr++; for (i = 0; i < NOPTS; i++) - optlist[i].val = 2; + optval[i] = 2; privileged = (getuid() != geteuid() || getgid() != getegid()); options(1); if (*argptr == NULL && minusc == NULL) @@ -104,8 +104,8 @@ procargs(int argc, char **argv) if (mflag == 2) mflag = iflag; for (i = 0; i < NOPTS; i++) - if (optlist[i].val == 2) - optlist[i].val = 0; + if (optval[i] == 2) + optval[i] = 0; arg0 = argv[0]; if (sflag == 0 && minusc == NULL) { scriptname = *argptr++; @@ -250,26 +250,29 @@ static void minus_o(char *name, int val) { int i; + const unsigned char *on; + size_t len; if (name == NULL) { if (val) { /* "Pretty" output. */ out1str("Current option settings\n"); - for (i = 0; i < NOPTS; i++) - out1fmt("%-16s%s\n", optlist[i].name, - optlist[i].val ? "on" : "off"); + for (i = 0, on = optname; i < NOPTS; i++, on += *on + 1) + out1fmt("%-16.*s%s\n", *on, on + 1, + optval[i] ? "on" : "off"); } else { /* Output suitable for re-input to shell. */ - for (i = 0; i < NOPTS; i++) - out1fmt("%s %co %s%s", + for (i = 0, on = optname; i < NOPTS; i++, on += *on + 1) + out1fmt("%s %co %.*s%s", i % 6 == 0 ? "set" : "", - optlist[i].val ? '-' : '+', - optlist[i].name, + optval[i] ? '-' : '+', + *on, on + 1, i % 6 == 5 || i == NOPTS - 1 ? "\n" : ""); } } else { - for (i = 0; i < NOPTS; i++) - if (equal(name, optlist[i].name)) { + len = strlen(name); + for (i = 0, on = optname; i < NOPTS; i++, on += *on + 1) + if (*on == len && memcmp(on + 1, name, len) == 0) { setoptionbyindex(i, val); return; } @@ -281,18 +284,18 @@ minus_o(char *name, int val) static void setoptionbyindex(int idx, int val) { - if (optlist[idx].letter == 'p' && !val && privileged) { + if (optletter[idx] == 'p' && !val && privileged) { if (setgid(getgid()) == -1) error("setgid"); if (setuid(getuid()) == -1) error("setuid"); } - optlist[idx].val = val; + optval[idx] = val; if (val) { /* #%$ hack for ksh semantics */ - if (optlist[idx].letter == 'V') + if (optletter[idx] == 'V') Eflag = 0; - else if (optlist[idx].letter == 'E') + else if (optletter[idx] == 'E') Vflag = 0; } } @@ -303,7 +306,7 @@ setoption(int flag, int val) int i; for (i = 0; i < NSHORTOPTS; i++) - if (optlist[i].letter == flag) { + if (optletter[i] == flag) { setoptionbyindex(i, val); return; } diff --git a/bin/sh/options.h b/bin/sh/options.h index b5cd67f..d997e6f 100644 --- a/bin/sh/options.h +++ b/bin/sh/options.h @@ -45,60 +45,57 @@ struct shparam { -#define eflag optlist[0].val -#define fflag optlist[1].val -#define Iflag optlist[2].val -#define iflag optlist[3].val -#define mflag optlist[4].val -#define nflag optlist[5].val -#define sflag optlist[6].val -#define xflag optlist[7].val -#define vflag optlist[8].val -#define Vflag optlist[9].val -#define Eflag optlist[10].val -#define Cflag optlist[11].val -#define aflag optlist[12].val -#define bflag optlist[13].val -#define uflag optlist[14].val -#define privileged optlist[15].val -#define Tflag optlist[16].val -#define Pflag optlist[17].val -#define hflag optlist[18].val -#define nologflag optlist[19].val +#define eflag optval[0] +#define fflag optval[1] +#define Iflag optval[2] +#define iflag optval[3] +#define mflag optval[4] +#define nflag optval[5] +#define sflag optval[6] +#define xflag optval[7] +#define vflag optval[8] +#define Vflag optval[9] +#define Eflag optval[10] +#define Cflag optval[11] +#define aflag optval[12] +#define bflag optval[13] +#define uflag optval[14] +#define privileged optval[15] +#define Tflag optval[16] +#define Pflag optval[17] +#define hflag optval[18] +#define nologflag optval[19] #define NSHORTOPTS 19 #define NOPTS 20 -struct optent { - const char *name; - const char letter; - char val; -}; - -extern struct optent optlist[NOPTS]; +extern char optval[NOPTS]; +extern const char optletter[NSHORTOPTS]; #ifdef DEFINE_OPTIONS -struct optent optlist[NOPTS] = { - { "errexit", 'e', 0 }, - { "noglob", 'f', 0 }, - { "ignoreeof", 'I', 0 }, - { "interactive",'i', 0 }, - { "monitor", 'm', 0 }, - { "noexec", 'n', 0 }, - { "stdin", 's', 0 }, - { "xtrace", 'x', 0 }, - { "verbose", 'v', 0 }, - { "vi", 'V', 0 }, - { "emacs", 'E', 0 }, - { "noclobber", 'C', 0 }, - { "allexport", 'a', 0 }, - { "notify", 'b', 0 }, - { "nounset", 'u', 0 }, - { "privileged", 'p', 0 }, - { "trapsasync", 'T', 0 }, - { "physical", 'P', 0 }, - { "trackall", 'h', 0 }, - { "nolog", '\0', 0 }, -}; +char optval[NOPTS]; +const char optletter[NSHORTOPTS] = "efIimnsxvVECabupTPh"; +static const unsigned char optname[] = + "\007errexit" + "\006noglob" + "\011ignoreeof" + "\013interactive" + "\007monitor" + "\006noexec" + "\005stdin" + "\006xtrace" + "\007verbose" + "\002vi" + "\005emacs" + "\011noclobber" + "\011allexport" + "\006notify" + "\007nounset" + "\012privileged" + "\012trapsasync" + "\010physical" + "\010trackall" + "\005nolog" +; #endif diff --git a/bin/sh/tests/builtins/Makefile b/bin/sh/tests/builtins/Makefile index 46a0b41..1511f70 100644 --- a/bin/sh/tests/builtins/Makefile +++ b/bin/sh/tests/builtins/Makefile @@ -48,6 +48,7 @@ FILES+= cd5.0 FILES+= cd6.0 FILES+= cd7.0 FILES+= cd8.0 +FILES+= cd9.0 cd9.0.stdout FILES+= command1.0 FILES+= command2.0 FILES+= command3.0 @@ -94,6 +95,8 @@ FILES+= getopts5.0 FILES+= getopts6.0 FILES+= getopts7.0 FILES+= getopts8.0 getopts8.0.stdout +FILES+= getopts9.0 getopts9.0.stdout +FILES+= getopts10.0 FILES+= hash1.0 hash1.0.stdout FILES+= hash2.0 hash2.0.stdout FILES+= hash3.0 hash3.0.stdout @@ -108,6 +111,7 @@ FILES+= local1.0 FILES+= local2.0 FILES+= local3.0 FILES+= local4.0 +FILES+= local5.0 .if ${MK_NLS} != "no" FILES+= locale1.0 .endif diff --git a/bin/sh/tests/builtins/cd9.0 b/bin/sh/tests/builtins/cd9.0 new file mode 100644 index 0000000..78bcdff --- /dev/null +++ b/bin/sh/tests/builtins/cd9.0 @@ -0,0 +1,8 @@ +# $FreeBSD$ + +cd /dev +cd /bin +cd - >/dev/null +pwd +cd - >/dev/null +pwd diff --git a/bin/sh/tests/builtins/cd9.0.stdout b/bin/sh/tests/builtins/cd9.0.stdout new file mode 100644 index 0000000..dac16a7 --- /dev/null +++ b/bin/sh/tests/builtins/cd9.0.stdout @@ -0,0 +1,2 @@ +/dev +/bin diff --git a/bin/sh/tests/builtins/getopts10.0 b/bin/sh/tests/builtins/getopts10.0 new file mode 100644 index 0000000..a88e6ca --- /dev/null +++ b/bin/sh/tests/builtins/getopts10.0 @@ -0,0 +1,11 @@ +# $FreeBSD$ + +set -- -x arg +opt=not +getopts x opt +r1=$? OPTIND1=$OPTIND opt1=$opt +: $(: $((OPTIND = 1))) +getopts x opt +r2=$? OPTIND2=$OPTIND +[ "$r1" = 0 ] && [ "$OPTIND1" = 2 ] && [ "$opt1" = x ] && [ "$r2" != 0 ] && + [ "$OPTIND2" = 2 ] diff --git a/bin/sh/tests/builtins/local5.0 b/bin/sh/tests/builtins/local5.0 new file mode 100644 index 0000000..2f2a14e --- /dev/null +++ b/bin/sh/tests/builtins/local5.0 @@ -0,0 +1,15 @@ +# $FreeBSD$ + +f() { + local PATH IFS elem + IFS=: + for elem in ''$PATH''; do + PATH=/var/empty/$elem:$PATH + done + ls -d / >/dev/null +} + +p1=$(command -v ls) +f +p2=$(command -v ls) +[ "$p1" = "$p2" ] diff --git a/bin/sh/var.c b/bin/sh/var.c index c124a5d..3af7dbe 100644 --- a/bin/sh/var.c +++ b/bin/sh/var.c @@ -754,8 +754,8 @@ mklocal(char *name) INTOFF; lvp = ckmalloc(sizeof (struct localvar)); if (name[0] == '-' && name[1] == '\0') { - lvp->text = ckmalloc(sizeof optlist); - memcpy(lvp->text, optlist, sizeof optlist); + lvp->text = ckmalloc(sizeof optval); + memcpy(lvp->text, optval, sizeof optval); vp = NULL; } else { vp = find_var(name, &vpp, NULL); @@ -791,22 +791,33 @@ poplocalvars(void) { struct localvar *lvp; struct var *vp; + int islocalevar; INTOFF; while ((lvp = localvars) != NULL) { localvars = lvp->next; vp = lvp->vp; if (vp == NULL) { /* $- saved */ - memcpy(optlist, lvp->text, sizeof optlist); + memcpy(optval, lvp->text, sizeof optval); ckfree(lvp->text); optschanged(); } else if ((lvp->flags & (VUNSET|VSTRFIXED)) == VUNSET) { (void)unsetvar(vp->text); } else { + islocalevar = (vp->flags | lvp->flags) & VEXPORT && + localevar(lvp->text); if ((vp->flags & VTEXTFIXED) == 0) ckfree(vp->text); vp->flags = lvp->flags; vp->text = lvp->text; + if (vp->func) + (*vp->func)(vp->text + vp->name_len + 1); + if (islocalevar) { + change_env(vp->text, vp->flags & VEXPORT && + (vp->flags & VUNSET) == 0); + setlocale(LC_ALL, ""); + updatecharset(); + } } ckfree(lvp); } diff --git a/contrib/hyperv/tools/hv_kvp_daemon.c b/contrib/hyperv/tools/hv_kvp_daemon.c index 50ae3ed..9b9e3a6 100644 --- a/contrib/hyperv/tools/hv_kvp_daemon.c +++ b/contrib/hyperv/tools/hv_kvp_daemon.c @@ -1437,7 +1437,7 @@ main(int argc, char *argv[]) for (;;) { - r = poll (hv_kvp_poll_fd, 1, 100); + r = poll (hv_kvp_poll_fd, 1, INFTIM); KVP_LOG(LOG_DEBUG, "poll returned r = %d, revent = 0x%x\n", r, hv_kvp_poll_fd[0].revents); diff --git a/contrib/less/LICENSE b/contrib/less/LICENSE index 3fe715f..376b8c8 100644 --- a/contrib/less/LICENSE +++ b/contrib/less/LICENSE @@ -2,7 +2,7 @@ ------------ Less -Copyright (C) 1984-2012 Mark Nudelman +Copyright (C) 1984-2015 Mark Nudelman Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/contrib/less/NEWS b/contrib/less/NEWS index e03f35a..43f1247 100644 --- a/contrib/less/NEWS +++ b/contrib/less/NEWS @@ -7,7 +7,44 @@ http://www.greenwoodsoftware.com/less You can also download the latest version of less from there. - To report bugs, suggestions or comments, send email to bug-less@gnu.org. + To report bugs, suggestions or comments, send email to bug-less@gnu.org + +====================================================================== + + Major changes between "less" versions 458 and 481 + +* Don't overwrite history file; just append to it. + +* New command ESC-G goes to end of currently buffered data in a pipe. + +* Disable history feature when compiled with LESSHISTFILE set to "-". + +* In more-compatible mode, make the -p option apply to every file opened, + not just the first one. + +* In more-compatible mode, change the -e option to work like -E, not -EF. + +* Treat multiple CRs before LF are like one CR (all the CRs are hidden). + +* Allow "extra" string in lesskey file to append to a multi-char command + (like a search pattern), without executing the command. + +* Ignore -u/-U setting while viewing help file, so that + underline and bold chars are displayed correctly. + +* Improve detection of "binary" files in UTF-8 mode. + +* Fix bug with ++ commands. + +* Fix bug where prompt was sometimes not displayed with +G. + +* Fix possible memory corruption + +* Fix bugs and improve performance in ampersand filtering. + +* Automate construction of Unicode tables from Unicode database. + +* Allow %% escape sequence in LESSOPEN variable. ====================================================================== diff --git a/contrib/less/README b/contrib/less/README index 807749a..1088431 100644 --- a/contrib/less/README +++ b/contrib/less/README @@ -7,9 +7,9 @@ ************************************************************************** ************************************************************************** - Less, version 458 + Less, version 481 - This is the distribution of less, version 458, released 04 Apr 2013. + This is the distribution of less, version 481, released 31 Aug 2015. This program is part of the GNU project (http://www.gnu.org). This program is free software. You may redistribute it and/or @@ -53,8 +53,9 @@ INSTALLATION (Unix systems only): Specifies the regular expression library used by less for pattern matching. The default is "auto", which means the configure program finds a regular expression library automatically. Other values are: - posix Use the POSIX-compatible regcomp. + gnu Use the GNU regex library. pcre Use the PCRE library. + posix Use the POSIX-compatible regcomp. regcmp Use the regcmp library. re_comp Use the re_comp library. regcomp Use the V8-compatible regcomp. diff --git a/contrib/less/brac.c b/contrib/less/brac.c index 70a7771..10a0843 100644 --- a/contrib/less/brac.c +++ b/contrib/less/brac.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/ch.c b/contrib/less/ch.c index 2e2ded7..da729c5 100644 --- a/contrib/less/ch.c +++ b/contrib/less/ch.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -54,7 +54,7 @@ struct buf { * The file state is maintained in a filestate structure. * A pointer to the filestate is kept in the ifile structure. */ -#define BUFHASH_SIZE 64 +#define BUFHASH_SIZE 1024 struct filestate { struct bufnode buflist; struct bufnode hashtbl[BUFHASH_SIZE]; @@ -323,13 +323,16 @@ ch_get() #if HAVE_STAT_INO if (follow_mode == FOLLOW_NAME) { - /* See whether the file's i-number has changed. + /* See whether the file's i-number has changed, + * or the file has shrunk. * If so, force the file to be closed and * reopened. */ struct stat st; + POSITION curr_pos = ch_tell(); int r = stat(get_filename(curr_ifile), &st); if (r == 0 && (st.st_ino != curr_ino || - st.st_dev != curr_dev)) + st.st_dev != curr_dev || + (curr_pos != NULL_POSITION && st.st_size < curr_pos))) { /* screen_trashed=2 causes * make_display to reopen the file. */ @@ -536,6 +539,32 @@ ch_end_seek() } /* + * Seek to the last position in the file that is currently buffered. + */ + public int +ch_end_buffer_seek() +{ + register struct buf *bp; + register struct bufnode *bn; + POSITION buf_pos; + POSITION end_pos; + + if (thisfile == NULL || (ch_flags & CH_CANSEEK)) + return (ch_end_seek()); + + end_pos = 0; + FOR_BUFS(bn) + { + bp = bufnode_buf(bn); + buf_pos = (bp->block * LBUFSIZE) + bp->datasize; + if (buf_pos > end_pos) + end_pos = buf_pos; + } + + return (ch_seek(end_pos)); +} + +/* * Seek to the beginning of the file, or as close to it as we can get. * We may not be able to seek there if input is a pipe and the * beginning of the pipe is no longer buffered. diff --git a/contrib/less/charset.c b/contrib/less/charset.c index 03b38e0..4c62664 100644 --- a/contrib/less/charset.c +++ b/contrib/less/charset.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -466,36 +466,15 @@ prutfchar(ch) else SNPRINTF1(buf, sizeof(buf), binfmt, (char) ch); } else if (is_ubin_char(ch)) + { SNPRINTF1(buf, sizeof(buf), utfbinfmt, ch); - else + } else { - int len; + char *p = buf; if (ch >= 0x80000000) - { - len = 3; - ch = 0xFFFD; - } else - { - len = (ch < 0x80) ? 1 - : (ch < 0x800) ? 2 - : (ch < 0x10000) ? 3 - : (ch < 0x200000) ? 4 - : (ch < 0x4000000) ? 5 - : 6; - } - buf[len] = '\0'; - if (len == 1) - *buf = (char) ch; - else - { - *buf = ((1 << len) - 1) << (8 - len); - while (--len > 0) - { - buf[len] = (char) (0x80 | (ch & 0x3F)); - ch >>= 6; - } - *buf |= ch; - } + ch = 0xFFFD; /* REPLACEMENT CHARACTER */ + put_wchar(&p, ch); + *p = '\0'; } return (buf); } @@ -524,11 +503,12 @@ utf_len(ch) } /* - * Is a UTF-8 character well-formed? + * Does the parameter point to the lead byte of a well-formed UTF-8 character? */ public int -is_utf8_well_formed(s) +is_utf8_well_formed(s, slen) unsigned char *s; + int slen; { int i; int len; @@ -537,6 +517,8 @@ is_utf8_well_formed(s) return (0); len = utf_len((char) s[0]); + if (len > slen) + return (0); if (len == 1) return (1); if (len == 2) @@ -558,6 +540,35 @@ is_utf8_well_formed(s) } /* + * Return number of invalid UTF-8 sequences found in a buffer. + */ + public int +utf_bin_count(data, len) + unsigned char *data; + int len; +{ + int bin_count = 0; + while (len > 0) + { + if (is_utf8_well_formed(data, len)) + { + int clen = utf_len(*data); + data += clen; + len -= clen; + } else + { + /* Skip to next lead byte. */ + bin_count++; + do { + ++data; + --len; + } while (len > 0 && !IS_UTF8_LEAD(*data)); + } + } + return (bin_count); +} + +/* * Get the value of a UTF-8 character. */ public LWCHAR @@ -706,411 +717,51 @@ step_char(pp, dir, limit) /* * Unicode characters data + * Actual data is in the generated *.uni files. */ -struct wchar_range { LWCHAR first, last; }; -/* - * Characters with general category values - * Mn: Mark, Nonspacing - * Me: Mark, Enclosing - * Last synched with - * <http://www.unicode.org/Public/5.0.0/ucd/UnicodeData-5.0.0d7.txt> - * dated 2005-11-30T00:58:48Z - */ -static struct wchar_range comp_table[] = { - { 0x0300, 0x036F} /* Mn */, { 0x0483, 0x0486} /* Mn */, - { 0x0488, 0x0489} /* Me */, - { 0x0591, 0x05BD} /* Mn */, { 0x05BF, 0x05BF} /* Mn */, - { 0x05C1, 0x05C2} /* Mn */, { 0x05C4, 0x05C5} /* Mn */, - { 0x05C7, 0x05C7} /* Mn */, { 0x0610, 0x0615} /* Mn */, - { 0x064B, 0x065E} /* Mn */, { 0x0670, 0x0670} /* Mn */, - { 0x06D6, 0x06DC} /* Mn */, - { 0x06DE, 0x06DE} /* Me */, - { 0x06DF, 0x06E4} /* Mn */, { 0x06E7, 0x06E8} /* Mn */, - { 0x06EA, 0x06ED} /* Mn */, { 0x0711, 0x0711} /* Mn */, - { 0x0730, 0x074A} /* Mn */, { 0x07A6, 0x07B0} /* Mn */, - { 0x07EB, 0x07F3} /* Mn */, { 0x0901, 0x0902} /* Mn */, - { 0x093C, 0x093C} /* Mn */, { 0x0941, 0x0948} /* Mn */, - { 0x094D, 0x094D} /* Mn */, { 0x0951, 0x0954} /* Mn */, - { 0x0962, 0x0963} /* Mn */, { 0x0981, 0x0981} /* Mn */, - { 0x09BC, 0x09BC} /* Mn */, { 0x09C1, 0x09C4} /* Mn */, - { 0x09CD, 0x09CD} /* Mn */, { 0x09E2, 0x09E3} /* Mn */, - { 0x0A01, 0x0A02} /* Mn */, { 0x0A3C, 0x0A3C} /* Mn */, - { 0x0A41, 0x0A42} /* Mn */, { 0x0A47, 0x0A48} /* Mn */, - { 0x0A4B, 0x0A4D} /* Mn */, { 0x0A70, 0x0A71} /* Mn */, - { 0x0A81, 0x0A82} /* Mn */, { 0x0ABC, 0x0ABC} /* Mn */, - { 0x0AC1, 0x0AC5} /* Mn */, { 0x0AC7, 0x0AC8} /* Mn */, - { 0x0ACD, 0x0ACD} /* Mn */, { 0x0AE2, 0x0AE3} /* Mn */, - { 0x0B01, 0x0B01} /* Mn */, { 0x0B3C, 0x0B3C} /* Mn */, - { 0x0B3F, 0x0B3F} /* Mn */, { 0x0B41, 0x0B43} /* Mn */, - { 0x0B4D, 0x0B4D} /* Mn */, { 0x0B56, 0x0B56} /* Mn */, - { 0x0B82, 0x0B82} /* Mn */, { 0x0BC0, 0x0BC0} /* Mn */, - { 0x0BCD, 0x0BCD} /* Mn */, { 0x0C3E, 0x0C40} /* Mn */, - { 0x0C46, 0x0C48} /* Mn */, { 0x0C4A, 0x0C4D} /* Mn */, - { 0x0C55, 0x0C56} /* Mn */, { 0x0CBC, 0x0CBC} /* Mn */, - { 0x0CBF, 0x0CBF} /* Mn */, { 0x0CC6, 0x0CC6} /* Mn */, - { 0x0CCC, 0x0CCD} /* Mn */, { 0x0CE2, 0x0CE3} /* Mn */, - { 0x0D41, 0x0D43} /* Mn */, { 0x0D4D, 0x0D4D} /* Mn */, - { 0x0DCA, 0x0DCA} /* Mn */, { 0x0DD2, 0x0DD4} /* Mn */, - { 0x0DD6, 0x0DD6} /* Mn */, { 0x0E31, 0x0E31} /* Mn */, - { 0x0E34, 0x0E3A} /* Mn */, { 0x0E47, 0x0E4E} /* Mn */, - { 0x0EB1, 0x0EB1} /* Mn */, { 0x0EB4, 0x0EB9} /* Mn */, - { 0x0EBB, 0x0EBC} /* Mn */, { 0x0EC8, 0x0ECD} /* Mn */, - { 0x0F18, 0x0F19} /* Mn */, { 0x0F35, 0x0F35} /* Mn */, - { 0x0F37, 0x0F37} /* Mn */, { 0x0F39, 0x0F39} /* Mn */, - { 0x0F71, 0x0F7E} /* Mn */, { 0x0F80, 0x0F84} /* Mn */, - { 0x0F86, 0x0F87} /* Mn */, { 0x0F90, 0x0F97} /* Mn */, - { 0x0F99, 0x0FBC} /* Mn */, { 0x0FC6, 0x0FC6} /* Mn */, - { 0x102D, 0x1030} /* Mn */, { 0x1032, 0x1032} /* Mn */, - { 0x1036, 0x1037} /* Mn */, { 0x1039, 0x1039} /* Mn */, - { 0x1058, 0x1059} /* Mn */, { 0x135F, 0x135F} /* Mn */, - { 0x1712, 0x1714} /* Mn */, { 0x1732, 0x1734} /* Mn */, - { 0x1752, 0x1753} /* Mn */, { 0x1772, 0x1773} /* Mn */, - { 0x17B7, 0x17BD} /* Mn */, { 0x17C6, 0x17C6} /* Mn */, - { 0x17C9, 0x17D3} /* Mn */, { 0x17DD, 0x17DD} /* Mn */, - { 0x180B, 0x180D} /* Mn */, { 0x18A9, 0x18A9} /* Mn */, - { 0x1920, 0x1922} /* Mn */, { 0x1927, 0x1928} /* Mn */, - { 0x1932, 0x1932} /* Mn */, { 0x1939, 0x193B} /* Mn */, - { 0x1A17, 0x1A18} /* Mn */, { 0x1B00, 0x1B03} /* Mn */, - { 0x1B34, 0x1B34} /* Mn */, { 0x1B36, 0x1B3A} /* Mn */, - { 0x1B3C, 0x1B3C} /* Mn */, { 0x1B42, 0x1B42} /* Mn */, - { 0x1B6B, 0x1B73} /* Mn */, { 0x1DC0, 0x1DCA} /* Mn */, - { 0x1DFE, 0x1DFF} /* Mn */, { 0x20D0, 0x20DC} /* Mn */, - { 0x20DD, 0x20E0} /* Me */, - { 0x20E1, 0x20E1} /* Mn */, - { 0x20E2, 0x20E4} /* Me */, - { 0x20E5, 0x20EF} /* Mn */, { 0x302A, 0x302F} /* Mn */, - { 0x3099, 0x309A} /* Mn */, { 0xA806, 0xA806} /* Mn */, - { 0xA80B, 0xA80B} /* Mn */, { 0xA825, 0xA826} /* Mn */, - { 0xFB1E, 0xFB1E} /* Mn */, { 0xFE00, 0xFE0F} /* Mn */, - { 0xFE20, 0xFE23} /* Mn */, { 0x10A01, 0x10A03} /* Mn */, - { 0x10A05, 0x10A06} /* Mn */, { 0x10A0C, 0x10A0F} /* Mn */, - { 0x10A38, 0x10A3A} /* Mn */, { 0x10A3F, 0x10A3F} /* Mn */, - { 0x1D167, 0x1D169} /* Mn */, { 0x1D17B, 0x1D182} /* Mn */, - { 0x1D185, 0x1D18B} /* Mn */, { 0x1D1AA, 0x1D1AD} /* Mn */, - { 0x1D242, 0x1D244} /* Mn */, { 0xE0100, 0xE01EF} /* Mn */, -}; +#define DECLARE_RANGE_TABLE_START(name) \ + static struct wchar_range name##_array[] = { +#define DECLARE_RANGE_TABLE_END(name) \ + }; struct wchar_range_table name##_table = { name##_array, sizeof(name##_array)/sizeof(*name##_array) }; -/* - * Special pairs, not ranges. - */ +DECLARE_RANGE_TABLE_START(compose) +#include "compose.uni" +DECLARE_RANGE_TABLE_END(compose) + +DECLARE_RANGE_TABLE_START(ubin) +#include "ubin.uni" +DECLARE_RANGE_TABLE_END(ubin) + +DECLARE_RANGE_TABLE_START(wide) +#include "wide.uni" +DECLARE_RANGE_TABLE_END(wide) + +/* comb_table is special pairs, not ranges. */ static struct wchar_range comb_table[] = { {0x0644,0x0622}, {0x0644,0x0623}, {0x0644,0x0625}, {0x0644,0x0627}, }; -/* - * Characters with general category values - * Cc: Other, Control - * Cf: Other, Format - * Cs: Other, Surrogate - * Co: Other, Private Use - * Cn: Other, Not Assigned - * Zl: Separator, Line - * Zp: Separator, Paragraph - * Last synched with - * <http://www.unicode.org/Public/5.0.0/ucd/UnicodeData-5.0.0d7.txt> - * dated 2005-11-30T00:58:48Z - */ -static struct wchar_range ubin_table[] = { - { 0x0000, 0x0007} /* Cc */, - { 0x000B, 0x000C} /* Cc */, - { 0x000E, 0x001A} /* Cc */, - { 0x001C, 0x001F} /* Cc */, - { 0x007F, 0x009F} /* Cc */, -#if 0 - { 0x00AD, 0x00AD} /* Cf */, -#endif - { 0x0370, 0x0373} /* Cn */, { 0x0376, 0x0379} /* Cn */, - { 0x037F, 0x0383} /* Cn */, { 0x038B, 0x038B} /* Cn */, - { 0x038D, 0x038D} /* Cn */, { 0x03A2, 0x03A2} /* Cn */, - { 0x03CF, 0x03CF} /* Cn */, { 0x0487, 0x0487} /* Cn */, - { 0x0514, 0x0530} /* Cn */, { 0x0557, 0x0558} /* Cn */, - { 0x0560, 0x0560} /* Cn */, { 0x0588, 0x0588} /* Cn */, - { 0x058B, 0x0590} /* Cn */, { 0x05C8, 0x05CF} /* Cn */, - { 0x05EB, 0x05EF} /* Cn */, { 0x05F5, 0x05FF} /* Cn */, -#if 0 - { 0x0600, 0x0603} /* Cf */, -#endif - { 0x0604, 0x060A} /* Cn */, { 0x0616, 0x061A} /* Cn */, - { 0x061C, 0x061D} /* Cn */, { 0x0620, 0x0620} /* Cn */, - { 0x063B, 0x063F} /* Cn */, { 0x065F, 0x065F} /* Cn */, -#if 0 - { 0x06DD, 0x06DD} /* Cf */, -#endif - { 0x070E, 0x070E} /* Cn */, -#if 0 - { 0x070F, 0x070F} /* Cf */, -#endif - { 0x074B, 0x074C} /* Cn */, { 0x076E, 0x077F} /* Cn */, - { 0x07B2, 0x07BF} /* Cn */, { 0x07FB, 0x0900} /* Cn */, - { 0x093A, 0x093B} /* Cn */, { 0x094E, 0x094F} /* Cn */, - { 0x0955, 0x0957} /* Cn */, { 0x0971, 0x097A} /* Cn */, - { 0x0980, 0x0980} /* Cn */, { 0x0984, 0x0984} /* Cn */, - { 0x098D, 0x098E} /* Cn */, { 0x0991, 0x0992} /* Cn */, - { 0x09A9, 0x09A9} /* Cn */, { 0x09B1, 0x09B1} /* Cn */, - { 0x09B3, 0x09B5} /* Cn */, { 0x09BA, 0x09BB} /* Cn */, - { 0x09C5, 0x09C6} /* Cn */, { 0x09C9, 0x09CA} /* Cn */, - { 0x09CF, 0x09D6} /* Cn */, { 0x09D8, 0x09DB} /* Cn */, - { 0x09DE, 0x09DE} /* Cn */, { 0x09E4, 0x09E5} /* Cn */, - { 0x09FB, 0x0A00} /* Cn */, { 0x0A04, 0x0A04} /* Cn */, - { 0x0A0B, 0x0A0E} /* Cn */, { 0x0A11, 0x0A12} /* Cn */, - { 0x0A29, 0x0A29} /* Cn */, { 0x0A31, 0x0A31} /* Cn */, - { 0x0A34, 0x0A34} /* Cn */, { 0x0A37, 0x0A37} /* Cn */, - { 0x0A3A, 0x0A3B} /* Cn */, { 0x0A3D, 0x0A3D} /* Cn */, - { 0x0A43, 0x0A46} /* Cn */, { 0x0A49, 0x0A4A} /* Cn */, - { 0x0A4E, 0x0A58} /* Cn */, { 0x0A5D, 0x0A5D} /* Cn */, - { 0x0A5F, 0x0A65} /* Cn */, { 0x0A75, 0x0A80} /* Cn */, - { 0x0A84, 0x0A84} /* Cn */, { 0x0A8E, 0x0A8E} /* Cn */, - { 0x0A92, 0x0A92} /* Cn */, { 0x0AA9, 0x0AA9} /* Cn */, - { 0x0AB1, 0x0AB1} /* Cn */, { 0x0AB4, 0x0AB4} /* Cn */, - { 0x0ABA, 0x0ABB} /* Cn */, { 0x0AC6, 0x0AC6} /* Cn */, - { 0x0ACA, 0x0ACA} /* Cn */, { 0x0ACE, 0x0ACF} /* Cn */, - { 0x0AD1, 0x0ADF} /* Cn */, { 0x0AE4, 0x0AE5} /* Cn */, - { 0x0AF0, 0x0AF0} /* Cn */, { 0x0AF2, 0x0B00} /* Cn */, - { 0x0B04, 0x0B04} /* Cn */, { 0x0B0D, 0x0B0E} /* Cn */, - { 0x0B11, 0x0B12} /* Cn */, { 0x0B29, 0x0B29} /* Cn */, - { 0x0B31, 0x0B31} /* Cn */, { 0x0B34, 0x0B34} /* Cn */, - { 0x0B3A, 0x0B3B} /* Cn */, { 0x0B44, 0x0B46} /* Cn */, - { 0x0B49, 0x0B4A} /* Cn */, { 0x0B4E, 0x0B55} /* Cn */, - { 0x0B58, 0x0B5B} /* Cn */, { 0x0B5E, 0x0B5E} /* Cn */, - { 0x0B62, 0x0B65} /* Cn */, { 0x0B72, 0x0B81} /* Cn */, - { 0x0B84, 0x0B84} /* Cn */, { 0x0B8B, 0x0B8D} /* Cn */, - { 0x0B91, 0x0B91} /* Cn */, { 0x0B96, 0x0B98} /* Cn */, - { 0x0B9B, 0x0B9B} /* Cn */, { 0x0B9D, 0x0B9D} /* Cn */, - { 0x0BA0, 0x0BA2} /* Cn */, { 0x0BA5, 0x0BA7} /* Cn */, - { 0x0BAB, 0x0BAD} /* Cn */, { 0x0BBA, 0x0BBD} /* Cn */, - { 0x0BC3, 0x0BC5} /* Cn */, { 0x0BC9, 0x0BC9} /* Cn */, - { 0x0BCE, 0x0BD6} /* Cn */, { 0x0BD8, 0x0BE5} /* Cn */, - { 0x0BFB, 0x0C00} /* Cn */, { 0x0C04, 0x0C04} /* Cn */, - { 0x0C0D, 0x0C0D} /* Cn */, { 0x0C11, 0x0C11} /* Cn */, - { 0x0C29, 0x0C29} /* Cn */, { 0x0C34, 0x0C34} /* Cn */, - { 0x0C3A, 0x0C3D} /* Cn */, { 0x0C45, 0x0C45} /* Cn */, - { 0x0C49, 0x0C49} /* Cn */, { 0x0C4E, 0x0C54} /* Cn */, - { 0x0C57, 0x0C5F} /* Cn */, { 0x0C62, 0x0C65} /* Cn */, - { 0x0C70, 0x0C81} /* Cn */, { 0x0C84, 0x0C84} /* Cn */, - { 0x0C8D, 0x0C8D} /* Cn */, { 0x0C91, 0x0C91} /* Cn */, - { 0x0CA9, 0x0CA9} /* Cn */, { 0x0CB4, 0x0CB4} /* Cn */, - { 0x0CBA, 0x0CBB} /* Cn */, { 0x0CC5, 0x0CC5} /* Cn */, - { 0x0CC9, 0x0CC9} /* Cn */, { 0x0CCE, 0x0CD4} /* Cn */, - { 0x0CD7, 0x0CDD} /* Cn */, { 0x0CDF, 0x0CDF} /* Cn */, - { 0x0CE4, 0x0CE5} /* Cn */, { 0x0CF0, 0x0CF0} /* Cn */, - { 0x0CF3, 0x0D01} /* Cn */, { 0x0D04, 0x0D04} /* Cn */, - { 0x0D0D, 0x0D0D} /* Cn */, { 0x0D11, 0x0D11} /* Cn */, - { 0x0D29, 0x0D29} /* Cn */, { 0x0D3A, 0x0D3D} /* Cn */, - { 0x0D44, 0x0D45} /* Cn */, { 0x0D49, 0x0D49} /* Cn */, - { 0x0D4E, 0x0D56} /* Cn */, { 0x0D58, 0x0D5F} /* Cn */, - { 0x0D62, 0x0D65} /* Cn */, { 0x0D70, 0x0D81} /* Cn */, - { 0x0D84, 0x0D84} /* Cn */, { 0x0D97, 0x0D99} /* Cn */, - { 0x0DB2, 0x0DB2} /* Cn */, { 0x0DBC, 0x0DBC} /* Cn */, - { 0x0DBE, 0x0DBF} /* Cn */, { 0x0DC7, 0x0DC9} /* Cn */, - { 0x0DCB, 0x0DCE} /* Cn */, { 0x0DD5, 0x0DD5} /* Cn */, - { 0x0DD7, 0x0DD7} /* Cn */, { 0x0DE0, 0x0DF1} /* Cn */, - { 0x0DF5, 0x0E00} /* Cn */, { 0x0E3B, 0x0E3E} /* Cn */, - { 0x0E5C, 0x0E80} /* Cn */, { 0x0E83, 0x0E83} /* Cn */, - { 0x0E85, 0x0E86} /* Cn */, { 0x0E89, 0x0E89} /* Cn */, - { 0x0E8B, 0x0E8C} /* Cn */, { 0x0E8E, 0x0E93} /* Cn */, - { 0x0E98, 0x0E98} /* Cn */, { 0x0EA0, 0x0EA0} /* Cn */, - { 0x0EA4, 0x0EA4} /* Cn */, { 0x0EA6, 0x0EA6} /* Cn */, - { 0x0EA8, 0x0EA9} /* Cn */, { 0x0EAC, 0x0EAC} /* Cn */, - { 0x0EBA, 0x0EBA} /* Cn */, { 0x0EBE, 0x0EBF} /* Cn */, - { 0x0EC5, 0x0EC5} /* Cn */, { 0x0EC7, 0x0EC7} /* Cn */, - { 0x0ECE, 0x0ECF} /* Cn */, { 0x0EDA, 0x0EDB} /* Cn */, - { 0x0EDE, 0x0EFF} /* Cn */, { 0x0F48, 0x0F48} /* Cn */, - { 0x0F6B, 0x0F70} /* Cn */, { 0x0F8C, 0x0F8F} /* Cn */, - { 0x0F98, 0x0F98} /* Cn */, { 0x0FBD, 0x0FBD} /* Cn */, - { 0x0FCD, 0x0FCE} /* Cn */, { 0x0FD2, 0x0FFF} /* Cn */, - { 0x1022, 0x1022} /* Cn */, { 0x1028, 0x1028} /* Cn */, - { 0x102B, 0x102B} /* Cn */, { 0x1033, 0x1035} /* Cn */, - { 0x103A, 0x103F} /* Cn */, { 0x105A, 0x109F} /* Cn */, - { 0x10C6, 0x10CF} /* Cn */, { 0x10FD, 0x10FF} /* Cn */, - { 0x115A, 0x115E} /* Cn */, { 0x11A3, 0x11A7} /* Cn */, - { 0x11FA, 0x11FF} /* Cn */, { 0x1249, 0x1249} /* Cn */, - { 0x124E, 0x124F} /* Cn */, { 0x1257, 0x1257} /* Cn */, - { 0x1259, 0x1259} /* Cn */, { 0x125E, 0x125F} /* Cn */, - { 0x1289, 0x1289} /* Cn */, { 0x128E, 0x128F} /* Cn */, - { 0x12B1, 0x12B1} /* Cn */, { 0x12B6, 0x12B7} /* Cn */, - { 0x12BF, 0x12BF} /* Cn */, { 0x12C1, 0x12C1} /* Cn */, - { 0x12C6, 0x12C7} /* Cn */, { 0x12D7, 0x12D7} /* Cn */, - { 0x1311, 0x1311} /* Cn */, { 0x1316, 0x1317} /* Cn */, - { 0x135B, 0x135E} /* Cn */, { 0x137D, 0x137F} /* Cn */, - { 0x139A, 0x139F} /* Cn */, { 0x13F5, 0x1400} /* Cn */, - { 0x1677, 0x167F} /* Cn */, { 0x169D, 0x169F} /* Cn */, - { 0x16F1, 0x16FF} /* Cn */, { 0x170D, 0x170D} /* Cn */, - { 0x1715, 0x171F} /* Cn */, { 0x1737, 0x173F} /* Cn */, - { 0x1754, 0x175F} /* Cn */, { 0x176D, 0x176D} /* Cn */, - { 0x1771, 0x1771} /* Cn */, { 0x1774, 0x177F} /* Cn */, -#if 0 - { 0x17B4, 0x17B5} /* Cf */, -#endif - { 0x17DE, 0x17DF} /* Cn */, { 0x17EA, 0x17EF} /* Cn */, - { 0x17FA, 0x17FF} /* Cn */, { 0x180F, 0x180F} /* Cn */, - { 0x181A, 0x181F} /* Cn */, { 0x1878, 0x187F} /* Cn */, - { 0x18AA, 0x18FF} /* Cn */, { 0x191D, 0x191F} /* Cn */, - { 0x192C, 0x192F} /* Cn */, { 0x193C, 0x193F} /* Cn */, - { 0x1941, 0x1943} /* Cn */, { 0x196E, 0x196F} /* Cn */, - { 0x1975, 0x197F} /* Cn */, { 0x19AA, 0x19AF} /* Cn */, - { 0x19CA, 0x19CF} /* Cn */, { 0x19DA, 0x19DD} /* Cn */, - { 0x1A1C, 0x1A1D} /* Cn */, { 0x1A20, 0x1AFF} /* Cn */, - { 0x1B4C, 0x1B4F} /* Cn */, { 0x1B7D, 0x1CFF} /* Cn */, - { 0x1DCB, 0x1DFD} /* Cn */, { 0x1E9C, 0x1E9F} /* Cn */, - { 0x1EFA, 0x1EFF} /* Cn */, { 0x1F16, 0x1F17} /* Cn */, - { 0x1F1E, 0x1F1F} /* Cn */, { 0x1F46, 0x1F47} /* Cn */, - { 0x1F4E, 0x1F4F} /* Cn */, { 0x1F58, 0x1F58} /* Cn */, - { 0x1F5A, 0x1F5A} /* Cn */, { 0x1F5C, 0x1F5C} /* Cn */, - { 0x1F5E, 0x1F5E} /* Cn */, { 0x1F7E, 0x1F7F} /* Cn */, - { 0x1FB5, 0x1FB5} /* Cn */, { 0x1FC5, 0x1FC5} /* Cn */, - { 0x1FD4, 0x1FD5} /* Cn */, { 0x1FDC, 0x1FDC} /* Cn */, - { 0x1FF0, 0x1FF1} /* Cn */, { 0x1FF5, 0x1FF5} /* Cn */, - { 0x1FFF, 0x1FFF} /* Cn */, - { 0x200B, 0x200F} /* Cf */, - { 0x2028, 0x2028} /* Zl */, - { 0x2029, 0x2029} /* Zp */, - { 0x202A, 0x202E} /* Cf */, - { 0x2060, 0x2063} /* Cf */, - { 0x2064, 0x2069} /* Cn */, - { 0x206A, 0x206F} /* Cf */, - { 0x2072, 0x2073} /* Cn */, { 0x208F, 0x208F} /* Cn */, - { 0x2095, 0x209F} /* Cn */, { 0x20B6, 0x20CF} /* Cn */, - { 0x20F0, 0x20FF} /* Cn */, { 0x214F, 0x2152} /* Cn */, - { 0x2185, 0x218F} /* Cn */, { 0x23E8, 0x23FF} /* Cn */, - { 0x2427, 0x243F} /* Cn */, { 0x244B, 0x245F} /* Cn */, - { 0x269D, 0x269F} /* Cn */, { 0x26B3, 0x2700} /* Cn */, - { 0x2705, 0x2705} /* Cn */, { 0x270A, 0x270B} /* Cn */, - { 0x2728, 0x2728} /* Cn */, { 0x274C, 0x274C} /* Cn */, - { 0x274E, 0x274E} /* Cn */, { 0x2753, 0x2755} /* Cn */, - { 0x2757, 0x2757} /* Cn */, { 0x275F, 0x2760} /* Cn */, - { 0x2795, 0x2797} /* Cn */, { 0x27B0, 0x27B0} /* Cn */, - { 0x27BF, 0x27BF} /* Cn */, { 0x27CB, 0x27CF} /* Cn */, - { 0x27EC, 0x27EF} /* Cn */, { 0x2B1B, 0x2B1F} /* Cn */, - { 0x2B24, 0x2BFF} /* Cn */, { 0x2C2F, 0x2C2F} /* Cn */, - { 0x2C5F, 0x2C5F} /* Cn */, { 0x2C6D, 0x2C73} /* Cn */, - { 0x2C78, 0x2C7F} /* Cn */, { 0x2CEB, 0x2CF8} /* Cn */, - { 0x2D26, 0x2D2F} /* Cn */, { 0x2D66, 0x2D6E} /* Cn */, - { 0x2D70, 0x2D7F} /* Cn */, { 0x2D97, 0x2D9F} /* Cn */, - { 0x2DA7, 0x2DA7} /* Cn */, { 0x2DAF, 0x2DAF} /* Cn */, - { 0x2DB7, 0x2DB7} /* Cn */, { 0x2DBF, 0x2DBF} /* Cn */, - { 0x2DC7, 0x2DC7} /* Cn */, { 0x2DCF, 0x2DCF} /* Cn */, - { 0x2DD7, 0x2DD7} /* Cn */, { 0x2DDF, 0x2DFF} /* Cn */, - { 0x2E18, 0x2E1B} /* Cn */, { 0x2E1E, 0x2E7F} /* Cn */, - { 0x2E9A, 0x2E9A} /* Cn */, { 0x2EF4, 0x2EFF} /* Cn */, - { 0x2FD6, 0x2FEF} /* Cn */, { 0x2FFC, 0x2FFF} /* Cn */, - { 0x3040, 0x3040} /* Cn */, { 0x3097, 0x3098} /* Cn */, - { 0x3100, 0x3104} /* Cn */, { 0x312D, 0x3130} /* Cn */, - { 0x318F, 0x318F} /* Cn */, { 0x31B8, 0x31BF} /* Cn */, - { 0x31D0, 0x31EF} /* Cn */, { 0x321F, 0x321F} /* Cn */, - { 0x3244, 0x324F} /* Cn */, { 0x32FF, 0x32FF} /* Cn */, - { 0x4DB6, 0x4DBF} /* Cn */, { 0x9FBC, 0x9FFF} /* Cn */, - { 0xA48D, 0xA48F} /* Cn */, { 0xA4C7, 0xA6FF} /* Cn */, - { 0xA71B, 0xA71F} /* Cn */, { 0xA722, 0xA7FF} /* Cn */, - { 0xA82C, 0xA83F} /* Cn */, { 0xA878, 0xABFF} /* Cn */, - { 0xD7A4, 0xD7FF} /* Cn */, - { 0xD800, 0xDFFF} /* Cs */, - { 0xE000, 0xF8FF} /* Co */, - { 0xFA2E, 0xFA2F} /* Cn */, { 0xFA6B, 0xFA6F} /* Cn */, - { 0xFADA, 0xFAFF} /* Cn */, { 0xFB07, 0xFB12} /* Cn */, - { 0xFB18, 0xFB1C} /* Cn */, { 0xFB37, 0xFB37} /* Cn */, - { 0xFB3D, 0xFB3D} /* Cn */, { 0xFB3F, 0xFB3F} /* Cn */, - { 0xFB42, 0xFB42} /* Cn */, { 0xFB45, 0xFB45} /* Cn */, - { 0xFBB2, 0xFBD2} /* Cn */, { 0xFD40, 0xFD4F} /* Cn */, - { 0xFD90, 0xFD91} /* Cn */, { 0xFDC8, 0xFDEF} /* Cn */, - { 0xFDFE, 0xFDFF} /* Cn */, { 0xFE1A, 0xFE1F} /* Cn */, - { 0xFE24, 0xFE2F} /* Cn */, { 0xFE53, 0xFE53} /* Cn */, - { 0xFE67, 0xFE67} /* Cn */, { 0xFE6C, 0xFE6F} /* Cn */, - { 0xFE75, 0xFE75} /* Cn */, { 0xFEFD, 0xFEFE} /* Cn */, - { 0xFEFF, 0xFEFF} /* Cf */, - { 0xFF00, 0xFF00} /* Cn */, { 0xFFBF, 0xFFC1} /* Cn */, - { 0xFFC8, 0xFFC9} /* Cn */, { 0xFFD0, 0xFFD1} /* Cn */, - { 0xFFD8, 0xFFD9} /* Cn */, { 0xFFDD, 0xFFDF} /* Cn */, - { 0xFFE7, 0xFFE7} /* Cn */, { 0xFFEF, 0xFFF8} /* Cn */, - { 0xFFF9, 0xFFFB} /* Cf */, - { 0xFFFE, 0xFFFF} /* Cn */, { 0x1000C, 0x1000C} /* Cn */, - { 0x10027, 0x10027} /* Cn */, { 0x1003B, 0x1003B} /* Cn */, - { 0x1003E, 0x1003E} /* Cn */, { 0x1004E, 0x1004F} /* Cn */, - { 0x1005E, 0x1007F} /* Cn */, { 0x100FB, 0x100FF} /* Cn */, - { 0x10103, 0x10106} /* Cn */, { 0x10134, 0x10136} /* Cn */, - { 0x1018B, 0x102FF} /* Cn */, { 0x1031F, 0x1031F} /* Cn */, - { 0x10324, 0x1032F} /* Cn */, { 0x1034B, 0x1037F} /* Cn */, - { 0x1039E, 0x1039E} /* Cn */, { 0x103C4, 0x103C7} /* Cn */, - { 0x103D6, 0x103FF} /* Cn */, - { 0x1049E, 0x1049F} /* Cn */, { 0x104AA, 0x107FF} /* Cn */, - { 0x10806, 0x10807} /* Cn */, { 0x10809, 0x10809} /* Cn */, - { 0x10836, 0x10836} /* Cn */, { 0x10839, 0x1083B} /* Cn */, - { 0x1083D, 0x1083E} /* Cn */, { 0x10840, 0x108FF} /* Cn */, - { 0x1091A, 0x1091E} /* Cn */, { 0x10920, 0x109FF} /* Cn */, - { 0x10A04, 0x10A04} /* Cn */, { 0x10A07, 0x10A0B} /* Cn */, - { 0x10A14, 0x10A14} /* Cn */, { 0x10A18, 0x10A18} /* Cn */, - { 0x10A34, 0x10A37} /* Cn */, { 0x10A3B, 0x10A3E} /* Cn */, - { 0x10A48, 0x10A4F} /* Cn */, { 0x10A59, 0x11FFF} /* Cn */, - { 0x1236F, 0x123FF} /* Cn */, { 0x12463, 0x1246F} /* Cn */, - { 0x12474, 0x1CFFF} /* Cn */, { 0x1D0F6, 0x1D0FF} /* Cn */, - { 0x1D127, 0x1D129} /* Cn */, - { 0x1D173, 0x1D17A} /* Cf */, - { 0x1D1DE, 0x1D1FF} /* Cn */, { 0x1D246, 0x1D2FF} /* Cn */, - { 0x1D357, 0x1D35F} /* Cn */, { 0x1D372, 0x1D3FF} /* Cn */, - { 0x1D455, 0x1D455} /* Cn */, { 0x1D49D, 0x1D49D} /* Cn */, - { 0x1D4A0, 0x1D4A1} /* Cn */, { 0x1D4A3, 0x1D4A4} /* Cn */, - { 0x1D4A7, 0x1D4A8} /* Cn */, { 0x1D4AD, 0x1D4AD} /* Cn */, - { 0x1D4BA, 0x1D4BA} /* Cn */, { 0x1D4BC, 0x1D4BC} /* Cn */, - { 0x1D4C4, 0x1D4C4} /* Cn */, { 0x1D506, 0x1D506} /* Cn */, - { 0x1D50B, 0x1D50C} /* Cn */, { 0x1D515, 0x1D515} /* Cn */, - { 0x1D51D, 0x1D51D} /* Cn */, { 0x1D53A, 0x1D53A} /* Cn */, - { 0x1D53F, 0x1D53F} /* Cn */, { 0x1D545, 0x1D545} /* Cn */, - { 0x1D547, 0x1D549} /* Cn */, { 0x1D551, 0x1D551} /* Cn */, - { 0x1D6A6, 0x1D6A7} /* Cn */, { 0x1D7CC, 0x1D7CD} /* Cn */, - { 0x1D800, 0x1FFFF} /* Cn */, { 0x2A6D7, 0x2F7FF} /* Cn */, - { 0x2FA1E, 0xE0000} /* Cn */, - { 0xE0001, 0xE0001} /* Cf */, - { 0xE0002, 0xE001F} /* Cn */, - { 0xE0020, 0xE007F} /* Cf */, - { 0xE0080, 0xE00FF} /* Cn */, { 0xE01F0, 0xEFFFF} /* Cn */, - { 0xF0000, 0xFFFFD} /* Co */, - { 0xFFFFE, 0xFFFFF} /* Cn */, - {0x100000,0x10FFFD} /* Co */, - {0x10FFFE,0x10FFFF} /* Cn */, - {0x110000,0x7FFFFFFF} /* ISO 10646?? */ -}; - -/* - * Double width characters - * W: East Asian Wide - * F: East Asian Full-width - * Unassigned code points may be included when they allow ranges to be merged. - * Last synched with - * <http://www.unicode.org/Public/5.0.0/ucd/EastAsianWidth-5.0.0d2.txt> - * dated 2005-11-08T01:32:56Z - */ -static struct wchar_range wide_table[] = { - { 0x1100, 0x115F} /* W */, { 0x2329, 0x232A} /* W */, - { 0x2E80, 0x2FFB} /* W */, - { 0x3000, 0x3000} /* F */, - { 0x3001, 0x303E} /* W */, { 0x3041, 0x4DB5} /* W */, - { 0x4E00, 0x9FBB} /* W */, { 0xA000, 0xA4C6} /* W */, - { 0xAC00, 0xD7A3} /* W */, { 0xF900, 0xFAD9} /* W */, - { 0xFE10, 0xFE19} /* W */, { 0xFE30, 0xFE6B} /* W */, - { 0xFF01, 0xFF60} /* F */, { 0xFFE0, 0xFFE6} /* F */, - { 0x20000, 0x2FFFD} /* W */, { 0x30000, 0x3FFFD} /* W */, -}; static int -is_in_table(ch, table, tsize) +is_in_table(ch, table) LWCHAR ch; - struct wchar_range table[]; - int tsize; + struct wchar_range_table *table; { int hi; int lo; /* Binary search in the table. */ - if (ch < table[0].first) + if (ch < table->table[0].first) return 0; lo = 0; - hi = tsize - 1; + hi = table->count - 1; while (lo <= hi) { int mid = (lo + hi) / 2; - if (ch > table[mid].last) + if (ch > table->table[mid].last) lo = mid + 1; - else if (ch < table[mid].first) + else if (ch < table->table[mid].first) hi = mid - 1; else return 1; @@ -1126,7 +777,7 @@ is_in_table(ch, table, tsize) is_composing_char(ch) LWCHAR ch; { - return is_in_table(ch, comp_table, (sizeof(comp_table) / sizeof(*comp_table))); + return is_in_table(ch, &compose_table); } /* @@ -1136,7 +787,7 @@ is_composing_char(ch) is_ubin_char(ch) LWCHAR ch; { - return is_in_table(ch, ubin_table, (sizeof(ubin_table) / sizeof(*ubin_table))); + return is_in_table(ch, &ubin_table); } /* @@ -1146,7 +797,7 @@ is_ubin_char(ch) is_wide_char(ch) LWCHAR ch; { - return is_in_table(ch, wide_table, (sizeof(wide_table) / sizeof(*wide_table))); + return is_in_table(ch, &wide_table); } /* diff --git a/contrib/less/charset.h b/contrib/less/charset.h index 7df4df6..bb1e437 100644 --- a/contrib/less/charset.h +++ b/contrib/less/charset.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/cmd.h b/contrib/less/cmd.h index 9a72160..8a943d1 100644 --- a/contrib/less/cmd.h +++ b/contrib/less/cmd.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -66,6 +66,7 @@ #define A_PREV_TAG 54 #define A_FILTER 55 #define A_F_UNTIL_HILITE 56 +#define A_GOEND_BUF 57 #define A_INVALID 100 #define A_NOACTION 101 diff --git a/contrib/less/cmdbuf.c b/contrib/less/cmdbuf.c index e387ccc..69d7414 100644 --- a/contrib/less/cmdbuf.c +++ b/contrib/less/cmdbuf.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -203,7 +203,7 @@ cmd_step_common(p, ch, len, pwidth, bswidth) pr = prchar((int) ch); if (pwidth != NULL || bswidth != NULL) { - int len = strlen(pr); + int len = (int) strlen(pr); if (pwidth != NULL) *pwidth = len; if (bswidth != NULL) @@ -222,7 +222,7 @@ cmd_step_common(p, ch, len, pwidth, bswidth) *bswidth = 0; } else if (is_ubin_char(ch)) { - int len = strlen(pr); + int len = (int) strlen(pr); if (pwidth != NULL) *pwidth = len; if (bswidth != NULL) @@ -375,7 +375,7 @@ cmd_lshift() s = ns; } - cmd_offset = s - cmdbuf; + cmd_offset = (int) (s - cmdbuf); save_cp = cp; cmd_home(); cmd_repaint(save_cp); @@ -405,7 +405,7 @@ cmd_rshift() cols += width; } - cmd_offset = s - cmdbuf; + cmd_offset = (int) (s - cmdbuf); save_cp = cp; cmd_home(); cmd_repaint(save_cp); @@ -535,7 +535,7 @@ cmd_erase() */ s = cp; cmd_left(); - clen = s - cp; + clen = (int) (s - cp); /* * Remove the char from the buffer (shift the buffer left). @@ -701,7 +701,7 @@ cmd_updown(action) if (updown_match < 0) { - updown_match = cp - cmdbuf; + updown_match = (int) (cp - cmdbuf); } /* @@ -744,12 +744,13 @@ cmd_updown(action) #endif /* - * Add a string to a history list. + * Add a string to an mlist. */ public void -cmd_addhist(mlist, cmd) +cmd_addhist(mlist, cmd, modified) struct mlist *mlist; char *cmd; + int modified; { #if CMD_HISTORY struct mlist *ml; @@ -773,6 +774,7 @@ cmd_addhist(mlist, cmd) */ ml = (struct mlist *) ecalloc(1, sizeof(struct mlist)); ml->string = save(cmd); + ml->modified = modified; ml->next = mlist; ml->prev = mlist->prev; mlist->prev->next = ml; @@ -799,7 +801,7 @@ cmd_accept() */ if (curr_mlist == NULL) return; - cmd_addhist(curr_mlist, cmdbuf); + cmd_addhist(curr_mlist, cmdbuf, 1); curr_mlist->modified = 1; #endif } @@ -965,7 +967,7 @@ delimit_word() int delim_quoted = 0; int meta_quoted = 0; char *esc = get_meta_escape(); - int esclen = strlen(esc); + int esclen = (int) strlen(esc); #endif /* @@ -1262,7 +1264,7 @@ cmd_char(c) cmd_mbc_buf[cmd_mbc_buf_index++] = c; if (cmd_mbc_buf_index < cmd_mbc_buf_len) return (CC_OK); - if (!is_utf8_well_formed(cmd_mbc_buf)) + if (!is_utf8_well_formed(cmd_mbc_buf, cmd_mbc_buf_index)) { /* complete, but not well formed (non-shortest form), sequence */ cmd_mbc_buf_len = 0; @@ -1359,6 +1361,18 @@ cmd_lastpattern() #if CMD_HISTORY /* + */ + static int +mlist_size(ml) + struct mlist *ml; +{ + int size = 0; + for (ml = ml->next; ml->string != NULL; ml = ml->next) + ++size; + return size; +} + +/* * Get the name of the history file. */ static char * @@ -1378,6 +1392,10 @@ histfile_name() return (save(name)); } + /* See if history file is disabled in the build. */ + if (strcmp(LESSHISTFILE, "") == 0 || strcmp(LESSHISTFILE, "-") == 0) + return (NULL); + /* Otherwise, file is in $HOME. */ home = lgetenv("HOME"); if (home == NULL || *home == '\0') @@ -1388,25 +1406,28 @@ histfile_name() #endif return (NULL); } - len = strlen(home) + strlen(LESSHISTFILE) + 2; + len = (int) (strlen(home) + strlen(LESSHISTFILE) + 2); name = (char *) ecalloc(len, sizeof(char)); SNPRINTF2(name, len, "%s/%s", home, LESSHISTFILE); return (name); } -#endif /* CMD_HISTORY */ /* - * Initialize history from a .lesshist file. + * Read a .lesshst file and call a callback for each line in the file. */ - public void -init_cmdhist() + static void +read_cmdhist2(action, uparam, skip_search, skip_shell) + void (*action)(void*,struct mlist*,char*); + void *uparam; + int skip_search; + int skip_shell; { -#if CMD_HISTORY struct mlist *ml = NULL; char line[CMDBUF_SIZE]; char *filename; FILE *f; char *p; + int *skip = NULL; filename = histfile_name(); if (filename == NULL) @@ -1432,84 +1453,170 @@ init_cmdhist() } } if (strcmp(line, HISTFILE_SEARCH_SECTION) == 0) + { ml = &mlist_search; - else if (strcmp(line, HISTFILE_SHELL_SECTION) == 0) + skip = &skip_search; + } else if (strcmp(line, HISTFILE_SHELL_SECTION) == 0) { #if SHELL_ESCAPE || PIPEC ml = &mlist_shell; + skip = &skip_shell; #else ml = NULL; + skip = NULL; #endif } else if (*line == '"') { if (ml != NULL) - cmd_addhist(ml, line+1); + { + if (skip != NULL && *skip > 0) + --(*skip); + else + (*action)(uparam, ml, line+1); + } } } fclose(f); +} + + static void +read_cmdhist(action, uparam, skip_search, skip_shell) + void (*action)(void*,struct mlist*,char*); + void *uparam; + int skip_search; + int skip_shell; +{ + read_cmdhist2(action, uparam, skip_search, skip_shell); + (*action)(uparam, NULL, NULL); /* signal end of file */ +} + + static void +addhist_init(void *uparam, struct mlist *ml, char *string) +{ + if (ml == NULL || string == NULL) + return; + cmd_addhist(ml, string, 0); +} +#endif /* CMD_HISTORY */ + +/* + * Initialize history from a .lesshist file. + */ + public void +init_cmdhist() +{ +#if CMD_HISTORY + read_cmdhist(&addhist_init, NULL, 0, 0); #endif /* CMD_HISTORY */ } /* - * + * Write the header for a section of the history file. */ #if CMD_HISTORY static void -save_mlist(ml, f) +write_mlist_header(ml, f) struct mlist *ml; FILE *f; { - int histsize = 0; - int n; - char *s; - - s = lgetenv("LESSHISTSIZE"); - if (s != NULL) - histsize = atoi(s); - if (histsize == 0) - histsize = 100; + if (ml == &mlist_search) + fprintf(f, "%s\n", HISTFILE_SEARCH_SECTION); +#if SHELL_ESCAPE || PIPEC + else if (ml == &mlist_shell) + fprintf(f, "%s\n", HISTFILE_SHELL_SECTION); +#endif +} - ml = ml->prev; - for (n = 0; n < histsize; n++) - { - if (ml->string == NULL) - break; - ml = ml->prev; - } +/* + * Write all modified entries in an mlist to the history file. + */ + static void +write_mlist(ml, f) + struct mlist *ml; + FILE *f; +{ for (ml = ml->next; ml->string != NULL; ml = ml->next) + { + if (!ml->modified) + continue; fprintf(f, "\"%s\n", ml->string); + ml->modified = 0; + } + ml->modified = 0; /* entire mlist is now unmodified */ } -#endif /* CMD_HISTORY */ /* - * + * Make a temp name in the same directory as filename. */ - public void -save_cmdhist() -{ -#if CMD_HISTORY + static char * +make_tempname(filename) char *filename; - FILE *f; - int modified = 0; +{ + char lastch; + char *tempname = ecalloc(1, strlen(filename)+1); + strcpy(tempname, filename); + lastch = tempname[strlen(tempname)-1]; + tempname[strlen(tempname)-1] = (lastch == 'Q') ? 'Z' : 'Q'; + return tempname; +} - if (mlist_search.modified) - modified = 1; +struct save_ctx +{ + struct mlist *mlist; + FILE *fout; +}; + +/* + * Copy entries from the saved history file to a new file. + * At the end of each mlist, append any new entries + * created during this session. + */ + static void +copy_hist(void *uparam, struct mlist *ml, char *string) +{ + struct save_ctx *ctx = (struct save_ctx *) uparam; + + if (ml != ctx->mlist) { + /* We're changing mlists. */ + if (ctx->mlist) + /* Append any new entries to the end of the current mlist. */ + write_mlist(ctx->mlist, ctx->fout); + /* Write the header for the new mlist. */ + ctx->mlist = ml; + write_mlist_header(ctx->mlist, ctx->fout); + } + if (string != NULL) + { + /* Copy the entry. */ + fprintf(ctx->fout, "\"%s\n", string); + } + if (ml == NULL) /* End of file */ + { + /* Write any sections that were not in the original file. */ + if (mlist_search.modified) + { + write_mlist_header(&mlist_search, ctx->fout); + write_mlist(&mlist_search, ctx->fout); + } #if SHELL_ESCAPE || PIPEC - if (mlist_shell.modified) - modified = 1; + if (mlist_shell.modified) + { + write_mlist_header(&mlist_shell, ctx->fout); + write_mlist(&mlist_shell, ctx->fout); + } #endif - if (!modified) - return; - filename = histfile_name(); - if (filename == NULL) - return; - f = fopen(filename, "w"); - free(filename); - if (f == NULL) - return; -#if HAVE_FCHMOD + } +} +#endif /* CMD_HISTORY */ + +/* + * Make a file readable only by its owner. + */ + static void +make_file_private(f) + FILE *f; { - /* Make history file readable only by owner. */ +#if HAVE_FCHMOD int do_chmod = 1; #if HAVE_STAT struct stat statbuf; @@ -1520,19 +1627,74 @@ save_cmdhist() #endif if (do_chmod) fchmod(fileno(f), 0600); -} #endif +} - fprintf(f, "%s\n", HISTFILE_FIRST_LINE); +/* + * Does the history file need to be updated? + */ + static int +histfile_modified() +{ + if (mlist_search.modified) + return 1; +#if SHELL_ESCAPE || PIPEC + if (mlist_shell.modified) + return 1; +#endif + return 0; +} - fprintf(f, "%s\n", HISTFILE_SEARCH_SECTION); - save_mlist(&mlist_search, f); +/* + * Update the .lesshst file. + */ + public void +save_cmdhist() +{ +#if CMD_HISTORY + char *histname; + char *tempname; + int skip_search; + int skip_shell; + struct save_ctx ctx; + char *s; + FILE *fout = NULL; + int histsize = 0; + if (!histfile_modified()) + return; + histname = histfile_name(); + if (histname == NULL) + return; + tempname = make_tempname(histname); + fout = fopen(tempname, "w"); + if (fout != NULL) + { + make_file_private(fout); + s = lgetenv("LESSHISTSIZE"); + if (s != NULL) + histsize = atoi(s); + if (histsize <= 0) + histsize = 100; + skip_search = mlist_size(&mlist_search) - histsize; #if SHELL_ESCAPE || PIPEC - fprintf(f, "%s\n", HISTFILE_SHELL_SECTION); - save_mlist(&mlist_shell, f); + skip_shell = mlist_size(&mlist_shell) - histsize; #endif - - fclose(f); + fprintf(fout, "%s\n", HISTFILE_FIRST_LINE); + ctx.fout = fout; + ctx.mlist = NULL; + read_cmdhist(copy_hist, &ctx, skip_search, skip_shell); + fclose(fout); +#if MSDOS_COMPILER==WIN32C + /* + * Windows rename doesn't remove an existing file, + * making it useless for atomic operations. Sigh. + */ + remove(histname); +#endif + rename(tempname, histname); + } + free(tempname); + free(histname); #endif /* CMD_HISTORY */ } diff --git a/contrib/less/command.c b/contrib/less/command.c index 5cbab00..ddcddd4 100644 --- a/contrib/less/command.c +++ b/contrib/less/command.c @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -35,6 +35,7 @@ extern int top_scroll; extern int ignore_eoi; extern int secure; extern int hshift; +extern int bs_mode; extern int show_attn; extern int less_is_more; extern POSITION highest_hilite; @@ -56,6 +57,7 @@ extern int screen_trashed; /* The screen has been overwritten */ extern int shift_count; extern int oldbot; extern int forw_prompt; +extern int same_pos_bell; #if SHELL_ESCAPE static char *shellcmd = NULL; /* For holding last shell command for "!!" */ @@ -70,6 +72,7 @@ static int optflag; static int optgetname; static POSITION bottompos; static int save_hshift; +static int save_bs_mode; #if PIPEC static char pipec; #endif @@ -77,9 +80,9 @@ static char pipec; struct ungot { struct ungot *ug_next; char ug_char; + char ug_end_command; }; static struct ungot* ungot = NULL; -static int unget_end = 0; static void multi_search(); @@ -160,6 +163,7 @@ mca_search() cmd_putstr("/"); else cmd_putstr("?"); + forw_prompt = 0; set_mlist(ml_search, 0); } @@ -194,6 +198,7 @@ mca_opt_toggle() cmd_putstr("!"); break; } + forw_prompt = 0; set_mlist(NULL, 0); } @@ -212,7 +217,7 @@ exec_mca() { case A_F_SEARCH: case A_B_SEARCH: - multi_search(cbuf, (int) number); + multi_search(cbuf, (int) number, 0); break; #if HILITE_SEARCH case A_FILTER: @@ -688,7 +693,7 @@ prompt() { register constant char *p; - if (ungot != NULL) + if (ungot != NULL && !ungot->ug_end_command) { /* * No prompt necessary if commands are from @@ -778,40 +783,6 @@ dispversion() public int getcc() { - if (unget_end) - { - /* - * We have just run out of ungotten chars. - */ - unget_end = 0; - if (len_cmdbuf() == 0 || !empty_screen()) - return (getchr()); - /* - * Command is incomplete, so try to complete it. - */ - switch (mca) - { - case A_DIGIT: - /* - * We have a number but no command. Treat as #g. - */ - return ('g'); - - case A_F_SEARCH: - case A_B_SEARCH: - /* - * We have "/string" but no newline. Add the \n. - */ - return ('\n'); - - default: - /* - * Some other incomplete command. Let user complete it. - */ - return (getchr()); - } - } - if (ungot == NULL) { /* @@ -826,9 +797,36 @@ getcc() { struct ungot *ug = ungot; char c = ug->ug_char; + int end_command = ug->ug_end_command; ungot = ug->ug_next; free(ug); - unget_end = (ungot == NULL); + if (end_command) + { + /* + * Command is incomplete, so try to complete it. + */ + switch (mca) + { + case A_DIGIT: + /* + * We have a number but no command. Treat as #g. + */ + return ('g'); + + case A_F_SEARCH: + case A_B_SEARCH: + /* + * We have "/string" but no newline. Add the \n. + */ + return ('\n'); + + default: + /* + * Some other incomplete command. Let user complete it. + */ + return (getchr()); + } + } return (c); } } @@ -843,10 +841,10 @@ ungetcc(c) { struct ungot *ug = (struct ungot *) ecalloc(1, sizeof(struct ungot)); - ug->ug_char = c; + ug->ug_char = (char) c; + ug->ug_end_command = (c == CHAR_END_COMMAND); ug->ug_next = ungot; ungot = ug; - unget_end = 0; } /* @@ -869,9 +867,10 @@ ungetsc(s) * If SRCH_PAST_EOF is set, continue the search thru multiple files. */ static void -multi_search(pattern, n) +multi_search(pattern, n, silent) char *pattern; int n; + int silent; { register int nomore; IFILE save_ifile; @@ -946,7 +945,7 @@ multi_search(pattern, n) * Didn't find it. * Print an error message if we haven't already. */ - if (n > 0) + if (n > 0 && !silent) error("Pattern not found", NULL_PARG); if (changed_file) @@ -974,7 +973,7 @@ forw_loop(until_hilite) return (A_NOACTION); cmd_exec(); - jump_forw(); + jump_forw_buffered(); curr_len = ch_length(); highest_hilite = until_hilite ? curr_len : NULL_POSITION; ignore_eoi = 1; @@ -1019,7 +1018,6 @@ commands() IFILE old_ifile; IFILE new_ifile; char *tagfile; - int until_hilite = 0; search_type = SRCH_FORW; wscroll = (sc_height + 1) / 2; @@ -1247,6 +1245,8 @@ commands() /* * Forward forever, ignoring EOF. */ + if (show_attn) + set_attnpos(bottompos); newaction = forw_loop(0); break; @@ -1332,6 +1332,17 @@ commands() jump_back(number); break; + case A_GOEND_BUF: + /* + * Go to line N, default last buffered byte. + */ + cmd_exec(); + if (number <= 0) + jump_forw_buffered(); + else + jump_back(number); + break; + case A_GOPOS: /* * Go to a specified byte position in the file. @@ -1374,6 +1385,7 @@ commands() * previous file. */ hshift = save_hshift; + bs_mode = save_bs_mode; if (edit_prev(1) == 0) break; } @@ -1389,7 +1401,7 @@ commands() if (number <= 0) number = 1; \ mca_search(); \ cmd_exec(); \ - multi_search((char *)NULL, (int) number); + multi_search((char *)NULL, (int) number, 0); case A_F_SEARCH: @@ -1477,6 +1489,8 @@ commands() cmd_exec(); save_hshift = hshift; hshift = 0; + save_bs_mode = bs_mode; + bs_mode = BS_SPECIAL; (void) edit(FAKE_HELPFILE); break; diff --git a/contrib/less/compose.uni b/contrib/less/compose.uni new file mode 100644 index 0000000..b814ce9 --- /dev/null +++ b/contrib/less/compose.uni @@ -0,0 +1,261 @@ +/* Generated by "./mkutable -f2 Mn Me -- unicode/UnicodeData.txt" on Mon Jul 14 16:21:21 PDT 2014 */ + { 0x0300, 0x036f }, /* Mn */ + { 0x0483, 0x0487 }, /* Mn */ + { 0x0488, 0x0489 }, /* Me */ + { 0x0591, 0x05bd }, /* Mn */ + { 0x05bf, 0x05bf }, /* Mn */ + { 0x05c1, 0x05c2 }, /* Mn */ + { 0x05c4, 0x05c5 }, /* Mn */ + { 0x05c7, 0x05c7 }, /* Mn */ + { 0x0610, 0x061a }, /* Mn */ + { 0x064b, 0x065f }, /* Mn */ + { 0x0670, 0x0670 }, /* Mn */ + { 0x06d6, 0x06dc }, /* Mn */ + { 0x06df, 0x06e4 }, /* Mn */ + { 0x06e7, 0x06e8 }, /* Mn */ + { 0x06ea, 0x06ed }, /* Mn */ + { 0x0711, 0x0711 }, /* Mn */ + { 0x0730, 0x074a }, /* Mn */ + { 0x07a6, 0x07b0 }, /* Mn */ + { 0x07eb, 0x07f3 }, /* Mn */ + { 0x0816, 0x0819 }, /* Mn */ + { 0x081b, 0x0823 }, /* Mn */ + { 0x0825, 0x0827 }, /* Mn */ + { 0x0829, 0x082d }, /* Mn */ + { 0x0859, 0x085b }, /* Mn */ + { 0x08e4, 0x0902 }, /* Mn */ + { 0x093a, 0x093a }, /* Mn */ + { 0x093c, 0x093c }, /* Mn */ + { 0x0941, 0x0948 }, /* Mn */ + { 0x094d, 0x094d }, /* Mn */ + { 0x0951, 0x0957 }, /* Mn */ + { 0x0962, 0x0963 }, /* Mn */ + { 0x0981, 0x0981 }, /* Mn */ + { 0x09bc, 0x09bc }, /* Mn */ + { 0x09c1, 0x09c4 }, /* Mn */ + { 0x09cd, 0x09cd }, /* Mn */ + { 0x09e2, 0x09e3 }, /* Mn */ + { 0x0a01, 0x0a02 }, /* Mn */ + { 0x0a3c, 0x0a3c }, /* Mn */ + { 0x0a41, 0x0a42 }, /* Mn */ + { 0x0a47, 0x0a48 }, /* Mn */ + { 0x0a4b, 0x0a4d }, /* Mn */ + { 0x0a51, 0x0a51 }, /* Mn */ + { 0x0a70, 0x0a71 }, /* Mn */ + { 0x0a75, 0x0a75 }, /* Mn */ + { 0x0a81, 0x0a82 }, /* Mn */ + { 0x0abc, 0x0abc }, /* Mn */ + { 0x0ac1, 0x0ac5 }, /* Mn */ + { 0x0ac7, 0x0ac8 }, /* Mn */ + { 0x0acd, 0x0acd }, /* Mn */ + { 0x0ae2, 0x0ae3 }, /* Mn */ + { 0x0b01, 0x0b01 }, /* Mn */ + { 0x0b3c, 0x0b3c }, /* Mn */ + { 0x0b3f, 0x0b3f }, /* Mn */ + { 0x0b41, 0x0b44 }, /* Mn */ + { 0x0b4d, 0x0b4d }, /* Mn */ + { 0x0b56, 0x0b56 }, /* Mn */ + { 0x0b62, 0x0b63 }, /* Mn */ + { 0x0b82, 0x0b82 }, /* Mn */ + { 0x0bc0, 0x0bc0 }, /* Mn */ + { 0x0bcd, 0x0bcd }, /* Mn */ + { 0x0c00, 0x0c00 }, /* Mn */ + { 0x0c3e, 0x0c40 }, /* Mn */ + { 0x0c46, 0x0c48 }, /* Mn */ + { 0x0c4a, 0x0c4d }, /* Mn */ + { 0x0c55, 0x0c56 }, /* Mn */ + { 0x0c62, 0x0c63 }, /* Mn */ + { 0x0c81, 0x0c81 }, /* Mn */ + { 0x0cbc, 0x0cbc }, /* Mn */ + { 0x0cbf, 0x0cbf }, /* Mn */ + { 0x0cc6, 0x0cc6 }, /* Mn */ + { 0x0ccc, 0x0ccd }, /* Mn */ + { 0x0ce2, 0x0ce3 }, /* Mn */ + { 0x0d01, 0x0d01 }, /* Mn */ + { 0x0d41, 0x0d44 }, /* Mn */ + { 0x0d4d, 0x0d4d }, /* Mn */ + { 0x0d62, 0x0d63 }, /* Mn */ + { 0x0dca, 0x0dca }, /* Mn */ + { 0x0dd2, 0x0dd4 }, /* Mn */ + { 0x0dd6, 0x0dd6 }, /* Mn */ + { 0x0e31, 0x0e31 }, /* Mn */ + { 0x0e34, 0x0e3a }, /* Mn */ + { 0x0e47, 0x0e4e }, /* Mn */ + { 0x0eb1, 0x0eb1 }, /* Mn */ + { 0x0eb4, 0x0eb9 }, /* Mn */ + { 0x0ebb, 0x0ebc }, /* Mn */ + { 0x0ec8, 0x0ecd }, /* Mn */ + { 0x0f18, 0x0f19 }, /* Mn */ + { 0x0f35, 0x0f35 }, /* Mn */ + { 0x0f37, 0x0f37 }, /* Mn */ + { 0x0f39, 0x0f39 }, /* Mn */ + { 0x0f71, 0x0f7e }, /* Mn */ + { 0x0f80, 0x0f84 }, /* Mn */ + { 0x0f86, 0x0f87 }, /* Mn */ + { 0x0f8d, 0x0f97 }, /* Mn */ + { 0x0f99, 0x0fbc }, /* Mn */ + { 0x0fc6, 0x0fc6 }, /* Mn */ + { 0x102d, 0x1030 }, /* Mn */ + { 0x1032, 0x1037 }, /* Mn */ + { 0x1039, 0x103a }, /* Mn */ + { 0x103d, 0x103e }, /* Mn */ + { 0x1058, 0x1059 }, /* Mn */ + { 0x105e, 0x1060 }, /* Mn */ + { 0x1071, 0x1074 }, /* Mn */ + { 0x1082, 0x1082 }, /* Mn */ + { 0x1085, 0x1086 }, /* Mn */ + { 0x108d, 0x108d }, /* Mn */ + { 0x109d, 0x109d }, /* Mn */ + { 0x135d, 0x135f }, /* Mn */ + { 0x1712, 0x1714 }, /* Mn */ + { 0x1732, 0x1734 }, /* Mn */ + { 0x1752, 0x1753 }, /* Mn */ + { 0x1772, 0x1773 }, /* Mn */ + { 0x17b4, 0x17b5 }, /* Mn */ + { 0x17b7, 0x17bd }, /* Mn */ + { 0x17c6, 0x17c6 }, /* Mn */ + { 0x17c9, 0x17d3 }, /* Mn */ + { 0x17dd, 0x17dd }, /* Mn */ + { 0x180b, 0x180d }, /* Mn */ + { 0x18a9, 0x18a9 }, /* Mn */ + { 0x1920, 0x1922 }, /* Mn */ + { 0x1927, 0x1928 }, /* Mn */ + { 0x1932, 0x1932 }, /* Mn */ + { 0x1939, 0x193b }, /* Mn */ + { 0x1a17, 0x1a18 }, /* Mn */ + { 0x1a1b, 0x1a1b }, /* Mn */ + { 0x1a56, 0x1a56 }, /* Mn */ + { 0x1a58, 0x1a5e }, /* Mn */ + { 0x1a60, 0x1a60 }, /* Mn */ + { 0x1a62, 0x1a62 }, /* Mn */ + { 0x1a65, 0x1a6c }, /* Mn */ + { 0x1a73, 0x1a7c }, /* Mn */ + { 0x1a7f, 0x1a7f }, /* Mn */ + { 0x1ab0, 0x1abd }, /* Mn */ + { 0x1abe, 0x1abe }, /* Me */ + { 0x1b00, 0x1b03 }, /* Mn */ + { 0x1b34, 0x1b34 }, /* Mn */ + { 0x1b36, 0x1b3a }, /* Mn */ + { 0x1b3c, 0x1b3c }, /* Mn */ + { 0x1b42, 0x1b42 }, /* Mn */ + { 0x1b6b, 0x1b73 }, /* Mn */ + { 0x1b80, 0x1b81 }, /* Mn */ + { 0x1ba2, 0x1ba5 }, /* Mn */ + { 0x1ba8, 0x1ba9 }, /* Mn */ + { 0x1bab, 0x1bad }, /* Mn */ + { 0x1be6, 0x1be6 }, /* Mn */ + { 0x1be8, 0x1be9 }, /* Mn */ + { 0x1bed, 0x1bed }, /* Mn */ + { 0x1bef, 0x1bf1 }, /* Mn */ + { 0x1c2c, 0x1c33 }, /* Mn */ + { 0x1c36, 0x1c37 }, /* Mn */ + { 0x1cd0, 0x1cd2 }, /* Mn */ + { 0x1cd4, 0x1ce0 }, /* Mn */ + { 0x1ce2, 0x1ce8 }, /* Mn */ + { 0x1ced, 0x1ced }, /* Mn */ + { 0x1cf4, 0x1cf4 }, /* Mn */ + { 0x1cf8, 0x1cf9 }, /* Mn */ + { 0x1dc0, 0x1df5 }, /* Mn */ + { 0x1dfc, 0x1dff }, /* Mn */ + { 0x20d0, 0x20dc }, /* Mn */ + { 0x20dd, 0x20e0 }, /* Me */ + { 0x20e1, 0x20e1 }, /* Mn */ + { 0x20e2, 0x20e4 }, /* Me */ + { 0x20e5, 0x20f0 }, /* Mn */ + { 0x2cef, 0x2cf1 }, /* Mn */ + { 0x2d7f, 0x2d7f }, /* Mn */ + { 0x2de0, 0x2dff }, /* Mn */ + { 0x302a, 0x302d }, /* Mn */ + { 0x3099, 0x309a }, /* Mn */ + { 0xa66f, 0xa66f }, /* Mn */ + { 0xa670, 0xa672 }, /* Me */ + { 0xa674, 0xa67d }, /* Mn */ + { 0xa69f, 0xa69f }, /* Mn */ + { 0xa6f0, 0xa6f1 }, /* Mn */ + { 0xa802, 0xa802 }, /* Mn */ + { 0xa806, 0xa806 }, /* Mn */ + { 0xa80b, 0xa80b }, /* Mn */ + { 0xa825, 0xa826 }, /* Mn */ + { 0xa8c4, 0xa8c4 }, /* Mn */ + { 0xa8e0, 0xa8f1 }, /* Mn */ + { 0xa926, 0xa92d }, /* Mn */ + { 0xa947, 0xa951 }, /* Mn */ + { 0xa980, 0xa982 }, /* Mn */ + { 0xa9b3, 0xa9b3 }, /* Mn */ + { 0xa9b6, 0xa9b9 }, /* Mn */ + { 0xa9bc, 0xa9bc }, /* Mn */ + { 0xa9e5, 0xa9e5 }, /* Mn */ + { 0xaa29, 0xaa2e }, /* Mn */ + { 0xaa31, 0xaa32 }, /* Mn */ + { 0xaa35, 0xaa36 }, /* Mn */ + { 0xaa43, 0xaa43 }, /* Mn */ + { 0xaa4c, 0xaa4c }, /* Mn */ + { 0xaa7c, 0xaa7c }, /* Mn */ + { 0xaab0, 0xaab0 }, /* Mn */ + { 0xaab2, 0xaab4 }, /* Mn */ + { 0xaab7, 0xaab8 }, /* Mn */ + { 0xaabe, 0xaabf }, /* Mn */ + { 0xaac1, 0xaac1 }, /* Mn */ + { 0xaaec, 0xaaed }, /* Mn */ + { 0xaaf6, 0xaaf6 }, /* Mn */ + { 0xabe5, 0xabe5 }, /* Mn */ + { 0xabe8, 0xabe8 }, /* Mn */ + { 0xabed, 0xabed }, /* Mn */ + { 0xfb1e, 0xfb1e }, /* Mn */ + { 0xfe00, 0xfe0f }, /* Mn */ + { 0xfe20, 0xfe2d }, /* Mn */ + { 0x101fd, 0x101fd }, /* Mn */ + { 0x102e0, 0x102e0 }, /* Mn */ + { 0x10376, 0x1037a }, /* Mn */ + { 0x10a01, 0x10a03 }, /* Mn */ + { 0x10a05, 0x10a06 }, /* Mn */ + { 0x10a0c, 0x10a0f }, /* Mn */ + { 0x10a38, 0x10a3a }, /* Mn */ + { 0x10a3f, 0x10a3f }, /* Mn */ + { 0x10ae5, 0x10ae6 }, /* Mn */ + { 0x11001, 0x11001 }, /* Mn */ + { 0x11038, 0x11046 }, /* Mn */ + { 0x1107f, 0x11081 }, /* Mn */ + { 0x110b3, 0x110b6 }, /* Mn */ + { 0x110b9, 0x110ba }, /* Mn */ + { 0x11100, 0x11102 }, /* Mn */ + { 0x11127, 0x1112b }, /* Mn */ + { 0x1112d, 0x11134 }, /* Mn */ + { 0x11173, 0x11173 }, /* Mn */ + { 0x11180, 0x11181 }, /* Mn */ + { 0x111b6, 0x111be }, /* Mn */ + { 0x1122f, 0x11231 }, /* Mn */ + { 0x11234, 0x11234 }, /* Mn */ + { 0x11236, 0x11237 }, /* Mn */ + { 0x112df, 0x112df }, /* Mn */ + { 0x112e3, 0x112ea }, /* Mn */ + { 0x11301, 0x11301 }, /* Mn */ + { 0x1133c, 0x1133c }, /* Mn */ + { 0x11340, 0x11340 }, /* Mn */ + { 0x11366, 0x1136c }, /* Mn */ + { 0x11370, 0x11374 }, /* Mn */ + { 0x114b3, 0x114b8 }, /* Mn */ + { 0x114ba, 0x114ba }, /* Mn */ + { 0x114bf, 0x114c0 }, /* Mn */ + { 0x114c2, 0x114c3 }, /* Mn */ + { 0x115b2, 0x115b5 }, /* Mn */ + { 0x115bc, 0x115bd }, /* Mn */ + { 0x115bf, 0x115c0 }, /* Mn */ + { 0x11633, 0x1163a }, /* Mn */ + { 0x1163d, 0x1163d }, /* Mn */ + { 0x1163f, 0x11640 }, /* Mn */ + { 0x116ab, 0x116ab }, /* Mn */ + { 0x116ad, 0x116ad }, /* Mn */ + { 0x116b0, 0x116b5 }, /* Mn */ + { 0x116b7, 0x116b7 }, /* Mn */ + { 0x16af0, 0x16af4 }, /* Mn */ + { 0x16b30, 0x16b36 }, /* Mn */ + { 0x16f8f, 0x16f92 }, /* Mn */ + { 0x1bc9d, 0x1bc9e }, /* Mn */ + { 0x1d167, 0x1d169 }, /* Mn */ + { 0x1d17b, 0x1d182 }, /* Mn */ + { 0x1d185, 0x1d18b }, /* Mn */ + { 0x1d1aa, 0x1d1ad }, /* Mn */ + { 0x1d242, 0x1d244 }, /* Mn */ + { 0x1e8d0, 0x1e8d6 }, /* Mn */ + { 0xe0100, 0xe01ef }, /* Mn */ diff --git a/contrib/less/cvt.c b/contrib/less/cvt.c index c3b3e6e..d983641 100644 --- a/contrib/less/cvt.c +++ b/contrib/less/cvt.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -75,8 +75,8 @@ cvt_text(odst, osrc, chpos, lenp, ops) for (src = osrc, dst = odst; src < src_end; ) { - int src_pos = src - osrc; - int dst_pos = dst - odst; + int src_pos = (int) (src - osrc); + int dst_pos = (int) (dst - odst); ch = step_char(&src, +1, src_end); if ((ops & CVT_BS) && ch == '\b' && dst > odst) { @@ -109,6 +109,6 @@ cvt_text(odst, osrc, chpos, lenp, ops) edst--; *edst = '\0'; if (lenp != NULL) - *lenp = edst - odst; + *lenp = (int) (edst - odst); /* FIXME: why was this here? if (chpos != NULL) chpos[dst - odst] = src - osrc; */ } diff --git a/contrib/less/decode.c b/contrib/less/decode.c index 6d0312d..1cd1599 100644 --- a/contrib/less/decode.c +++ b/contrib/less/decode.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -105,6 +105,7 @@ static unsigned char cmdtable[] = ESC,CONTROL('F'),0, A_F_BRACKET, ESC,CONTROL('B'),0, A_B_BRACKET, 'G',0, A_GOEND, + ESC,'G',0, A_GOEND_BUF, ESC,'>',0, A_GOEND, '>',0, A_GOEND, SK(SK_END),0, A_GOEND, diff --git a/contrib/less/edit.c b/contrib/less/edit.c index 5f4e679..2a35ade 100644 --- a/contrib/less/edit.c +++ b/contrib/less/edit.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -64,7 +64,7 @@ init_textlist(tlist, str) int meta_quoted = 0; int delim_quoted = 0; char *esc = get_meta_escape(); - int esclen = strlen(esc); + int esclen = (int) strlen(esc); #endif tlist->string = skipsp(str); @@ -411,7 +411,10 @@ edit_ifile(ifile) } #endif if (every_first_cmd != NULL) + { + ungetcc(CHAR_END_COMMAND); ungetsc(every_first_cmd); + } } free(qopen_filename); @@ -433,7 +436,8 @@ edit_ifile(ifile) #if HILITE_SEARCH clr_hilite(); #endif - cmd_addhist(ml_examine, filename); + if (strcmp(filename, FAKE_HELPFILE) && strcmp(filename, FAKE_EMPTYFILE)) + cmd_addhist(ml_examine, filename, 1); if (no_display && errmsgs > 0) { /* @@ -745,7 +749,8 @@ use_logfile(filename) */ filename = shell_unquote(filename); exists = open(filename, OPEN_READ); - close(exists); + if (exists >= 0) + close(exists); exists = (exists >= 0); /* diff --git a/contrib/less/filename.c b/contrib/less/filename.c index 14e85e3..9631f1c 100644 --- a/contrib/less/filename.c +++ b/contrib/less/filename.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -86,7 +86,7 @@ shell_unquote(str) } else { char *esc = get_meta_escape(); - int esclen = strlen(esc); + int esclen = (int) strlen(esc); while (*str != '\0') { if (esclen > 0 && strncmp(str, esc, esclen) == 0) @@ -150,7 +150,7 @@ shell_quote(s) char *newstr; int len; char *esc = get_meta_escape(); - int esclen = strlen(esc); + int esclen = (int) strlen(esc); int use_quotes = 0; int have_quotes = 0; @@ -188,7 +188,7 @@ shell_quote(s) * We can't quote a string that contains quotes. */ return (NULL); - len = strlen(s) + 3; + len = (int) strlen(s) + 3; } /* * Allocate and construct the new string. @@ -235,7 +235,7 @@ dirfile(dirname, filename) /* * Construct the full pathname. */ - len= strlen(dirname) + strlen(filename) + 2; + len = (int) (strlen(dirname) + strlen(filename) + 2); pathname = (char *) calloc(len, sizeof(char)); if (pathname == NULL) return (NULL); @@ -350,7 +350,7 @@ fexpand(s) if (ifile == NULL_IFILE) n++; else - n += strlen(get_filename(ifile)); + n += (int) strlen(get_filename(ifile)); } /* * Else it is the first char in a string of @@ -432,7 +432,7 @@ fcomplete(s) for (slash = s+strlen(s)-1; slash > s; slash--) if (*slash == *PATHNAME_SEP || *slash == '/') break; - len = strlen(s) + 4; + len = (int) strlen(s) + 4; fpat = (char *) ecalloc(len, sizeof(char)); if (strchr(slash, '.') == NULL) SNPRINTF1(fpat, len, "%s*.*", s); @@ -441,7 +441,7 @@ fcomplete(s) } #else { - int len = strlen(s) + 2; + int len = (int) strlen(s) + 2; fpat = (char *) ecalloc(len, sizeof(char)); SNPRINTF1(fpat, len, "%s*", s); } @@ -481,17 +481,25 @@ bin_file(f) if (lseek(f, (off_t)0, SEEK_SET) == BAD_LSEEK) return (0); n = read(f, data, sizeof(data)); - pend = &data[n]; - for (p = data; p < pend; ) + if (n <= 0) + return (0); + if (utf_mode) + { + bin_count = utf_bin_count(data, n); + } else { - LWCHAR c = step_char(&p, +1, pend); - if (ctldisp == OPT_ONPLUS && IS_CSI_START(c)) + pend = &data[n]; + for (p = data; p < pend; ) { - do { - c = step_char(&p, +1, pend); - } while (p < pend && is_ansi_middle(c)); - } else if (binary_char(c)) - bin_count++; + LWCHAR c = step_char(&p, +1, pend); + if (ctldisp == OPT_ONPLUS && IS_CSI_START(c)) + { + do { + c = step_char(&p, +1, pend); + } while (p < pend && is_ansi_middle(c)); + } else if (binary_char(c)) + bin_count++; + } } /* * Call it a binary file if there are more than 5 binary characters @@ -593,7 +601,7 @@ shellcmd(cmd) fd = popen(cmd, "r"); } else { - int len = strlen(shell) + strlen(esccmd) + 5; + int len = (int) (strlen(shell) + strlen(esccmd) + 5); scmd = (char *) ecalloc(len, sizeof(char)); SNPRINTF3(scmd, len, "%s %s %s", shell, shell_coption(), esccmd); free(esccmd); @@ -701,14 +709,14 @@ lglob(filename) gfilename = (char *) ecalloc(len, sizeof(char)); p = gfilename; do { - n = strlen(drive) + strlen(dir) + strlen(fnd.GLOB_NAME) + 1; + n = (int) (strlen(drive) + strlen(dir) + strlen(fnd.GLOB_NAME) + 1); pathname = (char *) ecalloc(n, sizeof(char)); SNPRINTF3(pathname, n, "%s%s%s", drive, dir, fnd.GLOB_NAME); qpathname = shell_quote(pathname); free(pathname); if (qpathname != NULL) { - n = strlen(qpathname); + n = (int) strlen(qpathname); while (p - gfilename + n + 2 >= len) { /* @@ -765,7 +773,7 @@ lglob(filename) /* * Invoke lessecho, and read its output (a globbed list of filenames). */ - len = strlen(lessecho) + strlen(ofilename) + (7*strlen(metachars())) + 24; + len = (int) (strlen(lessecho) + strlen(ofilename) + (7*strlen(metachars())) + 24); cmd = (char *) ecalloc(len, sizeof(char)); SNPRINTF4(cmd, len, "%s -p0x%x -d0x%x -e%s ", lessecho, openquote, closequote, esc); free(esc); @@ -813,15 +821,20 @@ lglob(filename) num_pct_s(lessopen) char *lessopen; { - int num; + int num = 0; - for (num = 0;; num++) + while (*lessopen != '\0') { - lessopen = strchr(lessopen, '%'); - if (lessopen == NULL) - break; - if (*++lessopen != 's') - return (999); + if (*lessopen == '%') + { + if (lessopen[1] == '%') + ++lessopen; + else if (lessopen[1] == 's') + ++num; + else + return (999); + } + ++lessopen; } return (num); } @@ -881,7 +894,7 @@ open_altfile(filename, pf, pfd) return (NULL); } - len = strlen(lessopen) + strlen(filename) + 2; + len = (int) (strlen(lessopen) + strlen(filename) + 2); cmd = (char *) ecalloc(len, sizeof(char)); SNPRINTF1(cmd, len, lessopen, filename); fd = shellcmd(cmd); @@ -971,10 +984,10 @@ close_altfile(altfilename, filename, pipefd) return; if (num_pct_s(lessclose) > 2) { - error("Invalid LESSCLOSE variable"); + error("Invalid LESSCLOSE variable", NULL_PARG); return; } - len = strlen(lessclose) + strlen(filename) + strlen(altfilename) + 2; + len = (int) (strlen(lessclose) + strlen(filename) + strlen(altfilename) + 2); cmd = (char *) ecalloc(len, sizeof(char)); SNPRINTF2(cmd, len, lessclose, filename, altfilename); fd = shellcmd(cmd); diff --git a/contrib/less/forwback.c b/contrib/less/forwback.c index 0166266..9626dc1 100644 --- a/contrib/less/forwback.c +++ b/contrib/less/forwback.c @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -21,6 +21,7 @@ public int screen_trashed; public int squished; public int no_back_scroll = 0; public int forw_prompt; +public int same_pos_bell = 1; extern int sigs; extern int top_scroll; @@ -34,6 +35,11 @@ extern int ignore_eoi; extern int clear_bg; extern int final_attr; extern int oldbot; +#if HILITE_SEARCH +extern int size_linebuf; +extern int hilite_search; +extern int status_col; +#endif #if TAGS extern char *tagoption; #endif @@ -126,7 +132,6 @@ forw(n, pos, force, only_last, nblank) int only_last; int nblank; { - int eof = 0; int nlines = 0; int do_repaint; static int first_time = 1; @@ -145,6 +150,13 @@ forw(n, pos, force, only_last, nblank) do_repaint = (only_last && n > sc_height-1) || (forw_scroll >= 0 && n > forw_scroll && n != sc_height-1); +#if HILITE_SEARCH + if (hilite_search == OPT_ONPLUS || is_filtering() || status_col) { + prep_hilite(pos, pos + 4*size_linebuf, ignore_eoi ? 1 : -1); + pos = next_unfiltered(pos); + } +#endif + if (!do_repaint) { if (top_scroll && n >= sc_height - 1 && pos != ch_length()) @@ -206,6 +218,9 @@ forw(n, pos, force, only_last, nblank) * Get the next line from the file. */ pos = forw_line(pos); +#if HILITE_SEARCH + pos = next_unfiltered(pos); +#endif if (pos == NULL_POSITION) { /* @@ -214,7 +229,6 @@ forw(n, pos, force, only_last, nblank) * Even if force is true, stop when the last * line in the file reaches the top of screen. */ - eof = 1; if (!force && position(TOP) != NULL_POSITION) break; if (!empty_lines(0, 0) && @@ -276,7 +290,7 @@ forw(n, pos, force, only_last, nblank) forw_prompt = 1; } - if (nlines == 0) + if (nlines == 0 && same_pos_bell) eof_bell(); else if (do_repaint) repaint(); @@ -299,11 +313,20 @@ back(n, pos, force, only_last) squish_check(); do_repaint = (n > get_back_scroll() || (only_last && n > sc_height-1)); +#if HILITE_SEARCH + if (hilite_search == OPT_ONPLUS || is_filtering() || status_col) { + prep_hilite((pos < 3*size_linebuf) ? 0 : pos - 3*size_linebuf, pos, -1); + } +#endif while (--n >= 0) { /* * Get the previous line of input. */ +#if HILITE_SEARCH + pos = prev_unfiltered(pos); +#endif + pos = back_line(pos); if (pos == NULL_POSITION) { @@ -327,7 +350,7 @@ back(n, pos, force, only_last) } } - if (nlines == 0) + if (nlines == 0 && same_pos_bell) eof_bell(); else if (do_repaint) repaint(); diff --git a/contrib/less/funcs.h b/contrib/less/funcs.h index 325ba0e..53550f0 100644 --- a/contrib/less/funcs.h +++ b/contrib/less/funcs.h @@ -38,6 +38,7 @@ public void sync_logfile (); public int ch_seek (); public int ch_end_seek (); + public int ch_end_buffer_seek (); public int ch_beg_seek (); public POSITION ch_length (); public POSITION ch_tell (); @@ -58,6 +59,7 @@ public char * prutfchar (); public int utf_len (); public int is_utf8_well_formed (); + public int utf_bin_count (); public LWCHAR get_wchar (); public void put_wchar (); public LWCHAR step_char (); @@ -158,6 +160,7 @@ public POSITION back_line (); public void set_attnpos (); public void jump_forw (); + public void jump_forw_buffered (); public void jump_back (); public void repaint (); public void jump_percent (); @@ -227,7 +230,7 @@ public struct loption * findopt_name (); public int iread (); public void intread (); - public long get_time (); + public time_type get_time (); public char * errno_message (); public int percentage (); public POSITION percent_pos (); @@ -242,6 +245,7 @@ public int query (); public int compile_pattern (); public void uncompile_pattern (); + public int valid_pattern (); public int is_null_pattern (); public int match_pattern (); public POSITION position (); @@ -267,6 +271,8 @@ public void clr_hilite (); public void clr_filter (); public int is_filtered (); + public POSITION next_unfiltered (); + public POSITION prev_unfiltered (); public int is_hilited (); public void chg_caseless (); public void chg_hilite (); diff --git a/contrib/less/help.c b/contrib/less/help.c index 46b8ff1..aba7116 100644 --- a/contrib/less/help.c +++ b/contrib/less/help.c @@ -26,6 +26,7 @@ constant char helpdata[] = { ' ',' ','E','S','C','-',')',' ',' ','R','i','g','h','t','A','r','r','o','w',' ','*',' ',' ','L','e','f','t',' ',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')','.','\n', ' ',' ','E','S','C','-','(',' ',' ','L','e','f','t','A','r','r','o','w',' ',' ','*',' ',' ','R','i','g','h','t',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')','.','\n', ' ',' ','F',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ','f','o','r','e','v','e','r',';',' ','l','i','k','e',' ','"','t','a','i','l',' ','-','f','"','.','\n', +' ',' ','E','S','C','-','F',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','L','i','k','e',' ','F',' ','b','u','t',' ','s','t','o','p',' ','w','h','e','n',' ','s','e','a','r','c','h',' ','p','a','t','t','e','r','n',' ','i','s',' ','f','o','u','n','d','.','\n', ' ',' ','r',' ',' ','^','R',' ',' ','^','L',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','s','c','r','e','e','n','.','\n', ' ',' ','R',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','s','c','r','e','e','n',',',' ','d','i','s','c','a','r','d','i','n','g',' ','b','u','f','f','e','r','e','d',' ','i','n','p','u','t','.','\n', ' ',' ',' ',' ',' ',' ',' ',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n', @@ -204,6 +205,8 @@ constant char helpdata[] = { ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','s','e','n','d',' ','t','e','r','m','c','a','p',' ','k','e','y','p','a','d',' ','i','n','i','t','/','d','e','i','n','i','t',' ','s','t','r','i','n','g','s','.','\n', ' ',' ',' ',' ',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','f','o','l','l','o','w','-','n','a','m','e','\n', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','T','h','e',' ','F',' ','c','o','m','m','a','n','d',' ','c','h','a','n','g','e','s',' ','f','i','l','e','s',' ','i','f',' ','t','h','e',' ','i','n','p','u','t',' ','f','i','l','e',' ','i','s',' ','r','e','n','a','m','e','d','.','\n', +' ',' ',' ',' ',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','u','s','e','-','b','a','c','k','s','l','a','s','h','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','u','b','s','e','q','u','e','n','t',' ','o','p','t','i','o','n','s',' ','u','s','e',' ','b','a','c','k','s','l','a','s','h',' ','a','s',' ','e','s','c','a','p','e',' ','c','h','a','r','.','\n', '\n', '\n', ' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n', @@ -213,22 +216,22 @@ constant char helpdata[] = { ' ',' ',' ',' ',' ',' ',' ',' ','T','h','e','s','e',' ','k','e','y','s',' ','c','a','n',' ','b','e',' ','u','s','e','d',' ','t','o',' ','e','d','i','t',' ','t','e','x','t',' ','b','e','i','n','g',' ','e','n','t','e','r','e','d',' ','\n', ' ',' ',' ',' ',' ',' ',' ',' ','o','n',' ','t','h','e',' ','"','c','o','m','m','a','n','d',' ','l','i','n','e','"',' ','a','t',' ','t','h','e',' ','b','o','t','t','o','m',' ','o','f',' ','t','h','e',' ','s','c','r','e','e','n','.','\n', '\n', -' ','R','i','g','h','t','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','l',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','r','i','g','h','t',' ','o','n','e',' ','c','h','a','r','a','c','t','e','r','.','\n', -' ','L','e','f','t','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','h',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','l','e','f','t',' ','o','n','e',' ','c','h','a','r','a','c','t','e','r','.','\n', -' ','c','t','r','l','-','R','i','g','h','t','A','r','r','o','w',' ',' ','E','S','C','-','R','i','g','h','t','A','r','r','o','w',' ',' ','E','S','C','-','w',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','r','i','g','h','t',' ','o','n','e',' ','w','o','r','d','.','\n', -' ','c','t','r','l','-','L','e','f','t','A','r','r','o','w',' ',' ',' ','E','S','C','-','L','e','f','t','A','r','r','o','w',' ',' ',' ','E','S','C','-','b',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','l','e','f','t',' ','o','n','e',' ','w','o','r','d','.','\n', -' ','H','O','M','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','0',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','t','o',' ','s','t','a','r','t',' ','o','f',' ','l','i','n','e','.','\n', -' ','E','N','D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','$',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','t','o',' ','e','n','d',' ','o','f',' ','l','i','n','e','.','\n', -' ','B','A','C','K','S','P','A','C','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','c','h','a','r',' ','t','o',' ','l','e','f','t',' ','o','f',' ','c','u','r','s','o','r','.','\n', -' ','D','E','L','E','T','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','x',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','c','h','a','r',' ','u','n','d','e','r',' ','c','u','r','s','o','r','.','\n', -' ','c','t','r','l','-','B','A','C','K','S','P','A','C','E',' ',' ',' ','E','S','C','-','B','A','C','K','S','P','A','C','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','w','o','r','d',' ','t','o',' ','l','e','f','t',' ','o','f',' ','c','u','r','s','o','r','.','\n', -' ','c','t','r','l','-','D','E','L','E','T','E',' ',' ',' ',' ',' ',' ','E','S','C','-','D','E','L','E','T','E',' ',' ',' ',' ',' ',' ','E','S','C','-','X',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','w','o','r','d',' ','u','n','d','e','r',' ','c','u','r','s','o','r','.','\n', -' ','c','t','r','l','-','U',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C',' ','(','M','S','-','D','O','S',' ','o','n','l','y',')',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','e','n','t','i','r','e',' ','l','i','n','e','.','\n', -' ','U','p','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','k',' ',' ',' ',' ',' ','R','e','t','r','i','e','v','e',' ','p','r','e','v','i','o','u','s',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n', -' ','D','o','w','n','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','j',' ',' ',' ',' ',' ','R','e','t','r','i','e','v','e',' ','n','e','x','t',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n', -' ','T','A','B',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',' ','&',' ','c','y','c','l','e','.','\n', -' ','S','H','I','F','T','-','T','A','B',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','T','A','B',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',' ','&',' ','r','e','v','e','r','s','e',' ','c','y','c','l','e','.','\n', -' ','c','t','r','l','-','L',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',',',' ','l','i','s','t',' ','a','l','l','.','\n', +' ','R','i','g','h','t','A','r','r','o','w',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','E','S','C','-','l',' ','.','.','.',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','r','i','g','h','t',' ','o','n','e',' ','c','h','a','r','a','c','t','e','r','.','\n', +' ','L','e','f','t','A','r','r','o','w',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','E','S','C','-','h',' ','.','.','.',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','l','e','f','t',' ','o','n','e',' ','c','h','a','r','a','c','t','e','r','.','\n', +' ','c','t','r','l','-','R','i','g','h','t','A','r','r','o','w',' ',' ','E','S','C','-','R','i','g','h','t','A','r','r','o','w',' ',' ','E','S','C','-','w',' ','.','.','.',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','r','i','g','h','t',' ','o','n','e',' ','w','o','r','d','.','\n', +' ','c','t','r','l','-','L','e','f','t','A','r','r','o','w',' ',' ',' ','E','S','C','-','L','e','f','t','A','r','r','o','w',' ',' ',' ','E','S','C','-','b',' ','.','.','.',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','l','e','f','t',' ','o','n','e',' ','w','o','r','d','.','\n', +' ','H','O','M','E',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','E','S','C','-','0',' ','.','.','.',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','t','o',' ','s','t','a','r','t',' ','o','f',' ','l','i','n','e','.','\n', +' ','E','N','D',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','E','S','C','-','$',' ','.','.','.',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','t','o',' ','e','n','d',' ','o','f',' ','l','i','n','e','.','\n', +' ','B','A','C','K','S','P','A','C','E',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','D','e','l','e','t','e',' ','c','h','a','r',' ','t','o',' ','l','e','f','t',' ','o','f',' ','c','u','r','s','o','r','.','\n', +' ','D','E','L','E','T','E',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','E','S','C','-','x',' ','.','.','.',' ','D','e','l','e','t','e',' ','c','h','a','r',' ','u','n','d','e','r',' ','c','u','r','s','o','r','.','\n', +' ','c','t','r','l','-','B','A','C','K','S','P','A','C','E',' ',' ',' ','E','S','C','-','B','A','C','K','S','P','A','C','E',' ','.','.','.','.','.','.','.','.','.','.','.',' ','D','e','l','e','t','e',' ','w','o','r','d',' ','t','o',' ','l','e','f','t',' ','o','f',' ','c','u','r','s','o','r','.','\n', +' ','c','t','r','l','-','D','E','L','E','T','E',' ','.','.','.','.',' ','E','S','C','-','D','E','L','E','T','E',' ','.','.','.','.',' ','E','S','C','-','X',' ','.','.','.',' ','D','e','l','e','t','e',' ','w','o','r','d',' ','u','n','d','e','r',' ','c','u','r','s','o','r','.','\n', +' ','c','t','r','l','-','U',' ','.','.','.','.','.','.','.','.','.',' ','E','S','C',' ','(','M','S','-','D','O','S',' ','o','n','l','y',')',' ','.','.','.','.','.','.','.',' ','D','e','l','e','t','e',' ','e','n','t','i','r','e',' ','l','i','n','e','.','\n', +' ','U','p','A','r','r','o','w',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','E','S','C','-','k',' ','.','.','.',' ','R','e','t','r','i','e','v','e',' ','p','r','e','v','i','o','u','s',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n', +' ','D','o','w','n','A','r','r','o','w',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','E','S','C','-','j',' ','.','.','.',' ','R','e','t','r','i','e','v','e',' ','n','e','x','t',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n', +' ','T','A','B',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',' ','&',' ','c','y','c','l','e','.','\n', +' ','S','H','I','F','T','-','T','A','B',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','E','S','C','-','T','A','B',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',' ','&',' ','r','e','v','e','r','s','e',' ','c','y','c','l','e','.','\n', +' ','c','t','r','l','-','L',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',',',' ','l','i','s','t',' ','a','l','l','.','\n', '\n', '\n', 0 }; diff --git a/contrib/less/ifile.c b/contrib/less/ifile.c index 3e5e855..fea2ea1 100644 --- a/contrib/less/ifile.c +++ b/contrib/less/ifile.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/input.c b/contrib/less/input.c index b211323..9419a02 100644 --- a/contrib/less/input.c +++ b/contrib/less/input.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -60,6 +60,7 @@ get_forw_line: } #if HILITE_SEARCH if (hilite_search == OPT_ONPLUS || is_filtering() || status_col) + { /* * If we are ignoring EOI (command F), only prepare * one line ahead, to avoid getting stuck waiting for @@ -69,6 +70,8 @@ get_forw_line: */ prep_hilite(curr_pos, curr_pos + 3*size_linebuf, ignore_eoi ? 1 : -1); + curr_pos = next_unfiltered(curr_pos); + } #endif if (ch_seek(curr_pos)) { @@ -439,19 +442,22 @@ set_attnpos(pos) { c = ch_forw_get(); if (c == EOI) - return; - if (c != '\n' && c != '\r') break; + if (c == '\n' || c == '\r') + { + (void) ch_back_get(); + break; + } pos++; } + end_attnpos = pos; + for (;;) + { + c = ch_back_get(); + if (c == EOI || c == '\n' || c == '\r') + break; + pos--; + } } start_attnpos = pos; - for (;;) - { - c = ch_forw_get(); - pos++; - if (c == EOI || c == '\n' || c == '\r') - break; - } - end_attnpos = pos; } diff --git a/contrib/less/jump.c b/contrib/less/jump.c index 075aa64..8373d8b 100644 --- a/contrib/less/jump.c +++ b/contrib/less/jump.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -61,6 +61,24 @@ jump_forw() } /* + * Jump to the last buffered line in the file. + */ + public void +jump_forw_buffered() +{ + POSITION end; + + if (ch_end_buffer_seek()) + { + error("Cannot seek to end of buffers", NULL_PARG); + return; + } + end = ch_tell(); + if (end != NULL_POSITION && end > 0) + jump_line_loc(end-1, sc_height-1); +} + +/* * Jump to line n in the file. */ public void @@ -281,6 +299,9 @@ jump_loc(pos, sline) */ break; } +#if HILITE_SEARCH + pos = next_unfiltered(pos); +#endif if (pos >= tpos) { /* diff --git a/contrib/less/less.h b/contrib/less/less.h index fada513..f57fb1e 100644 --- a/contrib/less/less.h +++ b/contrib/less/less.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -295,6 +295,15 @@ struct scrpos int ln; }; +/* + * A mark is an ifile (input file) plus a position within the file. + */ +struct mark +{ + IFILE m_ifile; + struct scrpos m_scrpos; +}; + typedef union parg { char *p_string; @@ -310,6 +319,17 @@ struct textlist char *endstring; }; +struct wchar_range +{ + LWCHAR first, last; +}; + +struct wchar_range_table +{ + struct wchar_range *table; + int count; +}; + #define EOI (-1) #define READ_INTR (-2) @@ -445,6 +465,7 @@ struct textlist #define ESC CONTROL('[') #define CSI ((unsigned char)'\233') +#define CHAR_END_COMMAND 0x40000000 #if _OSK_MWC32 #define LSIGNAL(sig,func) os9_signal(sig,func) @@ -498,6 +519,12 @@ struct textlist #define CVT_CRLF 04 /* Remove CR after LF */ #define CVT_ANSI 010 /* Remove ANSI escape sequences */ +#if HAVE_TIME_T +#define time_type time_t +#else +#define time_type long +#endif + #include "funcs.h" /* Functions not included in funcs.h */ diff --git a/contrib/less/less.hlp b/contrib/less/less.hlp index 45a7fe5..2a8e3e7 100644 --- a/contrib/less/less.hlp +++ b/contrib/less/less.hlp @@ -23,6 +23,7 @@ ESC-) RightArrow * Left one half screen width (or _N positions). ESC-( LeftArrow * Right one half screen width (or _N positions). F Forward forever; like "tail -f". + ESC-F Like F but stop when search pattern is found. r ^R ^L Repaint screen. R Repaint screen, discarding buffered input. --------------------------------------------------- @@ -201,6 +202,8 @@ Don't send termcap keypad init/deinit strings. ........ --follow-name The F command changes files if the input file is renamed. + ........ --use-backslash + Subsequent options use backslash as escape char. --------------------------------------------------------------------------- @@ -210,21 +213,21 @@ These keys can be used to edit text being entered on the "command line" at the bottom of the screen. - RightArrow ESC-l Move cursor right one character. - LeftArrow ESC-h Move cursor left one character. - ctrl-RightArrow ESC-RightArrow ESC-w Move cursor right one word. - ctrl-LeftArrow ESC-LeftArrow ESC-b Move cursor left one word. - HOME ESC-0 Move cursor to start of line. - END ESC-$ Move cursor to end of line. - BACKSPACE Delete char to left of cursor. - DELETE ESC-x Delete char under cursor. - ctrl-BACKSPACE ESC-BACKSPACE Delete word to left of cursor. - ctrl-DELETE ESC-DELETE ESC-X Delete word under cursor. - ctrl-U ESC (MS-DOS only) Delete entire line. - UpArrow ESC-k Retrieve previous command line. - DownArrow ESC-j Retrieve next command line. - TAB Complete filename & cycle. - SHIFT-TAB ESC-TAB Complete filename & reverse cycle. - ctrl-L Complete filename, list all. + RightArrow ..................... ESC-l ... Move cursor right one character. + LeftArrow ...................... ESC-h ... Move cursor left one character. + ctrl-RightArrow ESC-RightArrow ESC-w ... Move cursor right one word. + ctrl-LeftArrow ESC-LeftArrow ESC-b ... Move cursor left one word. + HOME ........................... ESC-0 ... Move cursor to start of line. + END ............................ ESC-$ ... Move cursor to end of line. + BACKSPACE ................................ Delete char to left of cursor. + DELETE ......................... ESC-x ... Delete char under cursor. + ctrl-BACKSPACE ESC-BACKSPACE ........... Delete word to left of cursor. + ctrl-DELETE .... ESC-DELETE .... ESC-X ... Delete word under cursor. + ctrl-U ......... ESC (MS-DOS only) ....... Delete entire line. + UpArrow ........................ ESC-k ... Retrieve previous command line. + DownArrow ...................... ESC-j ... Retrieve next command line. + TAB ...................................... Complete filename & cycle. + SHIFT-TAB ...................... ESC-TAB Complete filename & reverse cycle. + ctrl-L ................................... Complete filename, list all. diff --git a/contrib/less/less.nro b/contrib/less/less.nro index eba98ee..b3d9874 100644 --- a/contrib/less/less.nro +++ b/contrib/less/less.nro @@ -1,4 +1,4 @@ -.TH LESS 1 "Version 458: 04 Apr 2013" +.TH LESS 1 "Version 481: 31 Aug 2015" .SH NAME less \- opposite of more .SH SYNOPSIS @@ -12,19 +12,19 @@ less \- opposite of more .br .B "less [\-[+]aABcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]" .br -.B " [\-b \fIspace\fP] [\-h \fIlines\fP] [\-j \fIline\fP] [\-k \fIkeyfile\fP]" +.B " [\-b \fIspace\/\fP] [\-h \fIlines\/\fP] [\-j \fIline\/\fP] [\-k \fIkeyfile\/\fP]" .br -.B " [\-{oO} \fIlogfile\fP] [\-p \fIpattern\fP] [\-P \fIprompt\fP] [\-t \fItag\fP]" +.B " [\-{oO} \fIlogfile\/\fP] [\-p \fIpattern\/\fP] [\-P \fIprompt\/\fP] [\-t \fItag\/\fP]" .br -.B " [\-T \fItagsfile\fP] [\-x \fItab\fP,...] [\-y \fIlines\fP] [\-[z] \fIlines\fP]" +.B " [\-T \fItagsfile\/\fP] [\-x \fItab\/\fP,...] [\-y \fIlines\/\fP] [\-[z] \fIlines\/\fP]" .br -.B " [\-# \fIshift\fP] [+[+]\fIcmd\fP] [\-\-] [\fIfilename\fP]..." +.B " [\-# \fIshift\/\fP] [+[+]\fIcmd\/\fP] [\-\-] [\fIfilename\/\fP]..." .br (See the OPTIONS section for alternate option syntax with long option names.) .SH DESCRIPTION .I Less -is a program similar to +is a program similar to .I more (1), but which allows backward movement in the file as well as forward movement. @@ -45,7 +45,7 @@ Commands are based on both .I more and .I vi. -Commands may be preceded by a decimal number, +Commands may be preceded by a decimal number, called N in the descriptions below. The number is used by some commands, as indicated. @@ -70,7 +70,7 @@ Scroll forward N lines, default 1. The entire N lines are displayed, even if N is more than the screen size. .IP "d or ^D" Scroll forward N lines, default one half of the screen size. -If N is specified, it becomes the new default for +If N is specified, it becomes the new default for subsequent d and u commands. .IP "b or ^B or ESC-v" Scroll backward N lines, default one window (see option \-z below). @@ -83,8 +83,12 @@ The entire N lines are displayed, even if N is more than the screen size. Warning: some systems use ^Y as a special job control character. .IP "u or ^U" Scroll backward N lines, default one half of the screen size. -If N is specified, it becomes the new default for +If N is specified, it becomes the new default for subsequent d and u commands. +.IP "J" +Like j, but continues to scroll beyond the end of the file. +.IP "K or Y" +Like k, but continues to scroll beyond the beginning of the file. .IP "ESC-) or RIGHTARROW" Scroll horizontally right N characters, default half the screen width (see the \-# option). @@ -111,7 +115,7 @@ while it is being viewed. (The behavior is similar to the "tail \-f" command.) .IP "ESC-F" Like F, but as soon as a line is found which matches -the last search pattern, the terminal bell is rung +the last search pattern, the terminal bell is rung and forward scrolling stops. .IP "g or < or ESC-<" Go to line N in the file, default 1 (beginning of file). @@ -121,6 +125,9 @@ Go to line N in the file, default the end of the file. (Warning: this may be slow if N is large, or if N is not specified and standard input, rather than a file, is being read.) +.IP "ESC-G" +Same as G, except if no number N is specified and the input is standard input, +goes to the last line which is currently buffered. .IP "p or %" Go to a position N percent into the file. N should be between 0 and 100, and may contain a decimal point. @@ -154,16 +161,16 @@ Like }, but applies to square brackets rather than curly brackets. Followed by two characters, acts like {, but uses the two characters as open and close brackets, respectively. -For example, "ESC ^F < >" could be used to +For example, "ESC ^F < >" could be used to go forward to the > which matches the < in the top displayed line. .IP "ESC-^B" Followed by two characters, acts like }, but uses the two characters as open and close brackets, respectively. -For example, "ESC ^B < >" could be used to +For example, "ESC ^B < >" could be used to go backward to the < which matches the > in the bottom displayed line. .IP m -Followed by any lowercase letter, +Followed by any lowercase letter, marks the current position with that letter. .IP "'" (Single quote.) @@ -193,7 +200,7 @@ they modify the type of search rather than become part of the pattern: Search for lines which do NOT match the pattern. .IP "^E or *" Search multiple files. -That is, if the search reaches the END of the current file +That is, if the search reaches the END of the current file without finding a match, the search continues in the next file in the command line list. .IP "^F or @" @@ -202,7 +209,7 @@ in the command line list, regardless of what is currently displayed on the screen or the settings of the \-a or \-j options. .IP "^K" -Highlight any text which matches the pattern on the current screen, +Highlight any text which matches the pattern on the current screen, but don't move to the first match (KEEP current position). .IP "^R" Don't interpret regular expression metacharacters; @@ -210,7 +217,8 @@ that is, do a simple textual comparison. .RE .IP ?pattern Search backward in the file for the N-th line containing the pattern. -The search starts at the line immediately before the top line displayed. +The search starts at the last line displayed +(but see the \-a and \-j options, which change this). .sp Certain characters are special as in the / command: .RS @@ -218,7 +226,7 @@ Certain characters are special as in the / command: Search for lines which do NOT match the pattern. .IP "^E or *" Search multiple files. -That is, if the search reaches the beginning of the current file +That is, if the search reaches the beginning of the current file without finding a match, the search continues in the previous file in the command line list. .IP "^F or @" @@ -254,7 +262,7 @@ Repeat previous search, but in the reverse direction and crossing file boundaries. .IP "ESC-u" Undo search highlighting. -Turn off highlighting of strings matching the current search pattern. +Turn off highlighting of strings matching the current search pattern. If highlighting is already off because of a previous ESC-u command, turn highlighting back on. Any search command will also turn highlighting back on. @@ -282,10 +290,10 @@ Examine a new file. If the filename is missing, the "current" file (see the :n and :p commands below) from the list of files in the command line is re-examined. A percent sign (%) in the filename is replaced by the name of the -current file. +current file. A pound sign (#) is replaced by the name of the previously examined file. -However, two consecutive percent signs are simply -replaced with a single percent sign. +However, two consecutive percent signs are simply +replaced with a single percent sign. This allows you to enter a filename that contains a percent sign in the name. Similarly, two consecutive pound signs are replaced with a single pound sign. @@ -338,7 +346,7 @@ the current setting is printed and nothing is changed. Like the \- command, but takes a long option name (see OPTIONS below) rather than a single option letter. You must press ENTER or RETURN after typing the option name. -A ^P immediately after the second dash suppresses printing of a +A ^P immediately after the second dash suppresses printing of a message describing the new setting, as in the \- command. .IP \-+ Followed by one of the command line option letters @@ -370,19 +378,19 @@ rather than a single option letter. You must press ENTER or RETURN after typing the option name. .IP +cmd Causes the specified cmd to be executed each time a new file is examined. -For example, +G causes +For example, +G causes .I less -to initially display each file starting at the end +to initially display each file starting at the end rather than the beginning. .IP V -Prints the version number of -.I less +Prints the version number of +.I less being run. .IP "q or Q or :q or :Q or ZZ" Exits .I less. .PP -The following +The following four commands may or may not be valid, depending on your particular installation. .PP @@ -395,7 +403,7 @@ See also the discussion of LESSEDIT under the section on PROMPTS below. .IP "! shell-command" Invokes a shell to run the shell-command given. A percent sign (%) in the command is replaced by the name of the -current file. +current file. A pound sign (#) is replaced by the name of the previously examined file. "!!" repeats the last shell command. "!" with no shell command simply invokes a shell. @@ -408,7 +416,7 @@ Pipes a section of the input file to the given shell command. The section of the file to be piped is between the first line on the current screen and the position marked by the letter. <m> may also be ^ or $ to indicate beginning or end of file respectively. -If <m> is . or newline, the current screen is piped. +If <m> is \&.\& or newline, the current screen is piped. .IP "s filename" Save the input to a file. This only works if the input is a pipe, not an ordinary file. @@ -416,16 +424,16 @@ This only works if the input is a pipe, not an ordinary file. .SH OPTIONS Command line options are described below. Most options may be changed while -.I less +.I less is running, via the "\-" command. .PP -Most options may be given in one of two forms: +Most options may be given in one of two forms: either a dash followed by a single letter, or two dashes followed by a long option name. A long option name may be abbreviated as long as the abbreviation is unambiguous. For example, \-\-quit-at-eof may be abbreviated \-\-quit, but not ---qui, since both \-\-quit-at-eof and \-\-quiet begin with \-\-qui. +\-\-qui, since both \-\-quit-at-eof and \-\-quiet begin with \-\-qui. Some long option names are in uppercase, such as \-\-QUIT-AT-EOF, as distinct from \-\-quit-at-eof. Such option names need only have their first letter capitalized; @@ -433,20 +441,20 @@ the remainder of the name may be in either case. For example, \-\-Quit-at-eof is equivalent to \-\-QUIT-AT-EOF. .PP Options are also taken from the environment variable "LESS". -For example, -to avoid typing "less \-options ..." each time -.I less -is invoked, you might tell +For example, +to avoid typing "less \-options \&...\&" each time +.I less +is invoked, you might tell .I csh: .sp -setenv LESS "-options" +setenv LESS "\-options" .sp -or if you use +or if you use .I sh: .sp -LESS="-options"; export LESS +LESS="\-options"; export LESS .sp -On MS-DOS, you don't need the quotes, but you should replace any +On MS-DOS, you don't need the quotes, but you should replace any percent signs in the options string by double percent signs. .sp The environment variable is parsed before the command line, @@ -461,11 +469,11 @@ For example, you can set two \-D options on MS-DOS like this: .sp LESS="Dn9.1$Ds4.1" .sp -If the --use-backslash option appears earlier in the options, then +If the \-\-use-backslash option appears earlier in the options, then a dollar sign or backslash may be included literally in an option string by preceding it with a backslash. -If the --use-backslash option is not in effect, then backslashes are -not treated specially, and there is no way to include a dollar sign +If the \-\-use-backslash option is not in effect, then backslashes are +not treated specially, and there is no way to include a dollar sign in the option string. .IP "\-? or \-\-help" This option displays a summary of the commands accepted by @@ -484,8 +492,8 @@ the bottom of the screen and backward searches to start at the top of the screen, thus skipping all lines displayed on the screen. .IP "\-A or \-\-SEARCH-SKIP-SCREEN" -Causes all forward searches (not just non-repeated searches) -to start just after the target line, and all backward searches +Causes all forward searches (not just non-repeated searches) +to start just after the target line, and all backward searches to start just before the target line. Thus, forward searches will skip part of the displayed screen (from the first line up to and including the target line). @@ -496,9 +504,9 @@ This was the default behavior in less versions prior to 441. Specifies the amount of buffer space .I less will use for each file, in units of kilobytes (1024 bytes). -By default 64K of buffer space is used for each file +By default 64\ K of buffer space is used for each file (unless the file is a pipe; see the \-B option). -The \-b option specifies instead that \fIn\fP kilobytes of +The \-b option specifies instead that \fIn\fP kilobytes of buffer space should be used for each file. If \fIn\fP is \-1, buffer space is unlimited; that is, the entire file can be read into memory. @@ -508,18 +516,18 @@ buffers are allocated automatically as needed. If a large amount of data is read from the pipe, this can cause a large amount of memory to be allocated. The \-B option disables this automatic allocation of buffers for pipes, -so that only 64K +so that only 64\ K (or the amount of space specified by the \-b option) is used for the pipe. Warning: use of \-B can result in erroneous display, since only the -most recently viewed part of the piped data is kept in memory; +most recently viewed part of the piped data is kept in memory; any earlier data is lost. .IP "\-c or \-\-clear-screen" Causes full screen repaints to be painted from the top line down. By default, full screen repaints are done by scrolling from the bottom of the screen. .IP "\-C or \-\-CLEAR-SCREEN" -Same as \-c, for compatibility with older versions of +Same as \-c, for compatibility with older versions of .I less. .IP "\-d or \-\-dumb" The \-d option suppresses the error message @@ -532,24 +540,24 @@ on a dumb terminal. .IP "\-D\fBx\fP\fIcolor\fP or \-\-color=\fBx\fP\fIcolor\fP" [MS-DOS only] Sets the color of the text displayed. -\fBx\fP is a single character which selects the type of text whose color is +\fBx\fP is a single character which selects the type of text whose color is being set: n=normal, s=standout, d=bold, u=underlined, k=blink. -\fIcolor\fP is a pair of numbers separated by a period. -The first number selects the foreground color and the second selects +\fIcolor\fP is a pair of numbers separated by a period. +The first number selects the foreground color and the second selects the background color of the text. A single number \fIN\fP is the same as \fIN.M\fP, where \fIM\fP is the normal background color. .IP "\-e or \-\-quit-at-eof" -Causes -.I less +Causes +.I less to automatically exit the second time it reaches end-of-file. -By default, the only way to exit +By default, the only way to exit .I less is via the "q" command. .IP "\-E or \-\-QUIT-AT-EOF" -Causes +Causes .I less to automatically exit the first time it reaches end-of-file. .IP "\-f or \-\-force" @@ -567,13 +575,13 @@ Causes to automatically exit if the entire file can be displayed on the first screen. .IP "\-g or \-\-hilite-search" -Normally, -.I less +Normally, +.I less will highlight ALL strings which match the last search command. -The \-g option changes this behavior to highlight only the particular string +The \-g option changes this behavior to highlight only the particular string which was found by the last search command. -This can cause -.I less +This can cause +.I less to run somewhat faster than the default. .IP "\-G or \-\-HILITE-SEARCH" The \-G option suppresses all highlighting of strings found by search commands. @@ -587,11 +595,11 @@ backward, \-h0 is implied.) Causes searches to ignore case; that is, uppercase and lowercase are considered identical. This option is ignored if any uppercase letters -appear in the search pattern; +appear in the search pattern; in other words, if a pattern contains uppercase letters, then that search does not ignore case. .IP "\-I or \-\-IGNORE-CASE" -Like \-i, but searches ignore case even if +Like \-i, but searches ignore case even if the pattern contains uppercase letters. .IP "\-j\fIn\fP or \-\-jump-target=\fIn\fP" Specifies a line on the screen where the "target" line @@ -605,18 +613,21 @@ The number may be negative to specify a line relative to the bottom of the screen: the bottom line on the screen is \-1, the second to the bottom is \-2, and so on. Alternately, the screen line may be specified as a fraction of the height -of the screen, starting with a decimal point: .5 is in the middle of the -screen, .3 is three tenths down from the first line, and so on. +of the screen, starting with a decimal point: \&.5 is in the middle of the +screen, \&.3 is three tenths down from the first line, and so on. If the line is specified as a fraction, the actual line number is recalculated if the terminal window is resized, so that the target line remains at the specified fraction of the screen height. -If any form of the \-j option is used, -forward searches begin at the line immediately after the target line, -and backward searches begin at the target line, +If any form of the \-j option is used, +repeated forward searches (invoked with "n" or "N") +begin at the line immediately after the target line, +and repeated backward searches begin at the target line, unless changed by \-a or \-A. For example, if "\-j4" is used, the target line is the fourth line on the screen, so forward searches begin at the fifth line on the screen. +However nonrepeated searches (invoked with "/" or "?") +always begin at the start or end of the current screen respectively. .IP "\-J or \-\-status-column" Displays a status column at the left edge of the screen. The status column shows the lines that matched the current search. @@ -630,7 +641,7 @@ to open and interpret the named file as a Multiple \-k options may be specified. If the LESSKEY or LESSKEY_SYSTEM environment variable is set, or if a lesskey file is found in a standard place (see KEY BINDINGS), -it is also used as a +it is also used as a .I lesskey file. .IP "\-K or \-\-quit-on-intr" @@ -641,16 +652,16 @@ when an interrupt character (usually ^C) is typed. Normally, an interrupt character causes .I less to stop whatever it is doing and return to its command prompt. -Note that use of this option makes it impossible to return to the +Note that use of this option makes it impossible to return to the command prompt from the "F" command. .IP "\-L or \-\-no-lessopen" Ignore the LESSOPEN environment variable (see the INPUT PREPROCESSOR section below). -This option can be set from within \fIless\fP, -but it will apply only to files opened subsequently, not to the +This option can be set from within \fIless\fP, +but it will apply only to files opened subsequently, not to the file which is currently open. .IP "\-m or \-\-long-prompt" -Causes +Causes .I less to prompt verbosely (like \fImore\fP), with the percent into the file. @@ -658,9 +669,9 @@ By default, .I less prompts with a colon. .IP "\-M or \-\-LONG-PROMPT" -Causes +Causes .I less -to prompt even more verbosely than +to prompt even more verbosely than .I more. .IP "\-n or \-\-line-numbers" Suppresses line numbers. @@ -681,7 +692,7 @@ Causes to copy its input to the named file as it is being viewed. This applies only when the input file is a pipe, not an ordinary file. -If the file already exists, +If the file already exists, .I less will ask for confirmation before overwriting it. .IP "\-O\fIfilename\fP or \-\-LOG-FILE=\fIfilename\fP" @@ -689,14 +700,14 @@ The \-O option is like \-o, but it will overwrite an existing file without asking for confirmation. .sp If no log file has been specified, -the \-o and \-O options can be used from within +the \-o and \-O options can be used from within .I less to specify a log file. Without a file name, they will simply report the name of the log file. The "s" command is equivalent to specifying \-o from within .I less. .IP "\-p\fIpattern\fP or \-\-pattern=\fIpattern\fP" -The \-p option on the command line is equivalent to +The \-p option on the command line is equivalent to specifying +/\fIpattern\fP; that is, it tells .I less @@ -705,24 +716,24 @@ to start at the first occurrence of \fIpattern\fP in the file. Provides a way to tailor the three prompt styles to your own preference. This option would normally be put in the LESS environment -variable, rather than being typed in with each +variable, rather than being typed in with each .I less command. Such an option must either be the last option in the LESS variable, or be terminated by a dollar sign. --Ps followed by a string changes the default (short) prompt + \-Ps followed by a string changes the default (short) prompt to that string. --Pm changes the medium (\-m) prompt. --PM changes the long (\-M) prompt. --Ph changes the prompt for the help screen. --P= changes the message printed by the = command. --Pw changes the message printed while waiting for data (in the F command). -All prompt strings consist of a sequence of + \-Pm changes the medium (\-m) prompt. + \-PM changes the long (\-M) prompt. + \-Ph changes the prompt for the help screen. + \-P= changes the message printed by the = command. + \-Pw changes the message printed while waiting for data (in the F command). +All prompt strings consist of a sequence of letters and special escape sequences. See the section on PROMPTS for more details. .IP "\-q or \-\-quiet or \-\-silent" Causes moderately "quiet" operation: -the terminal bell is not rung +the terminal bell is not rung if an attempt is made to scroll past the end of the file or before the beginning of the file. If the terminal has a "visual bell", it is used instead. @@ -748,9 +759,9 @@ Like \-r, but only ANSI "color" escape sequences are output in "raw" form. Unlike \-r, the screen appearance is maintained correctly in most cases. ANSI "color" escape sequences are sequences of the form: .sp - ESC [ ... m + ESC [ \&...\& m .sp -where the "..." is zero or more color specification characters +where the "...\&" is zero or more color specification characters For the purpose of keeping track of screen appearance, ANSI color escape sequences are assumed to not move the cursor. You can make @@ -758,9 +769,9 @@ You can make think that characters other than "m" can end ANSI color escape sequences by setting the environment variable LESSANSIENDCHARS to the list of characters which can end a color escape sequence. -And you can make -.I less -think that characters other than the standard ones may appear between +And you can make +.I less +think that characters other than the standard ones may appear between the ESC and the m by setting the environment variable LESSANSIMIDCHARS to the list of characters which can appear. .IP "\-s or \-\-squeeze-blank-lines" @@ -780,16 +791,16 @@ The \-t option, followed immediately by a TAG, will edit the file containing that tag. For this to work, tag information must be available; for example, there may be a file in the current directory called "tags", -which was previously built by +which was previously built by .I ctags (1) or an equivalent command. If the environment variable LESSGLOBALTAGS is set, it is taken to be -the name of a command compatible with +the name of a command compatible with .I global (1), and that command is executed to find the tag. (See http://www.gnu.org/software/global/global.html). -The \-t option may also be specified from within -.I less +The \-t option may also be specified from within +.I less (using the \- command) as a way of examining a new file. The command ":t" is equivalent to specifying \-t from within .I less. @@ -799,18 +810,18 @@ Specifies a tags file to be used instead of "tags". Causes backspaces and carriage returns to be treated as printable characters; that is, they are sent to the terminal when they appear in the input. .IP "\-U or \-\-UNDERLINE-SPECIAL" -Causes backspaces, tabs and carriage returns to be +Causes backspaces, tabs and carriage returns to be treated as control characters; that is, they are handled as specified by the \-r option. .sp By default, if neither \-u nor \-U is given, backspaces which appear adjacent to an underscore character are treated specially: -the underlined text is displayed +the underlined text is displayed using the terminal's hardware underlining capability. Also, backspaces which appear between two identical characters -are treated specially: -the overstruck text is printed +are treated specially: +the overstruck text is printed using the terminal's hardware boldface capability. Other backspaces are deleted, along with the preceding character. Carriage returns immediately followed by a newline are deleted. @@ -818,7 +829,7 @@ Other carriage returns are handled as specified by the \-r option. Text which is overstruck or underlined can be searched for if neither \-u nor \-U is in effect. .IP "\-V or \-\-version" -Displays the version number of +Displays the version number of .I less. .IP "\-w or \-\-hilite-unread" Temporarily highlights the first "new" line after a forward movement @@ -830,9 +841,9 @@ The highlight is removed at the next command which causes movement. The entire line is highlighted, unless the \-J option is in effect, in which case only the status column is highlighted. .IP "\-W or \-\-HILITE-UNREAD" -Like \-w, but temporarily highlights the first new line after any +Like \-w, but temporarily highlights the first new line after any forward movement command larger than one line. -.IP "\-x\fIn\fP,... or \-\-tabs=\fIn\fP,..." +.IP "\-x\fIn\fP,...\& or \-\-tabs=\fIn\fP,..." Sets tab stops. If only one \fIn\fP is specified, tab stops are set at multiples of \fIn\fP. If multiple values separated by commas are specified, tab stops @@ -856,14 +867,14 @@ By default, any forward movement causes scrolling. Changes the default scrolling window size to \fIn\fP lines. The default is one screenful. The z and w commands can also be used to change the window size. -The "z" may be omitted for compatibility with some versions of +The "z" may be omitted for compatibility with some versions of .I more. If the number .I n -is negative, it indicates +is negative, it indicates .I n lines less than the current screen size. -For example, if the screen is 24 lines, \fI\-z-4\fP sets the +For example, if the screen is 24 lines, \fI\-z\-4\fP sets the scrolling window to 20 lines. If the screen is resized to 40 lines, the scrolling window automatically changes to 36 lines. .IP "\-\fI\(dqcc\fP\ or\ \-\-quotes=\fIcc\fP" @@ -889,14 +900,14 @@ in the RIGHTARROW and LEFTARROW commands. If the number specified is zero, it sets the default number of positions to one half of the screen width. Alternately, the number may be specified as a fraction of the width -of the screen, starting with a decimal point: .5 is half of the -screen width, .3 is three tenths of the screen width, and so on. -If the number is specified as a fraction, the actual number of -scroll positions is recalculated if the terminal window is resized, -so that the actual scroll remains at the specified fraction +of the screen, starting with a decimal point: \&.5 is half of the +screen width, \&.3 is three tenths of the screen width, and so on. +If the number is specified as a fraction, the actual number of +scroll positions is recalculated if the terminal window is resized, +so that the actual scroll remains at the specified fraction of the screen width. .IP "\-\-follow-name" -Normally, if the input file is renamed while an F command is executing, +Normally, if the input file is renamed while an F command is executing, .I less will continue to display the contents of the original file despite its name change. @@ -904,7 +915,7 @@ If \-\-follow-name is specified, during an F command .I less will periodically attempt to reopen the file by name. If the reopen succeeds and the file is a different file from the original -(which means that a new file has been created +(which means that a new file has been created with the same name as the original (now renamed) file), .I less will display the contents of that new file. @@ -930,7 +941,7 @@ For example, +G tells .I less to start at the end of the file rather than the beginning, and +/xyz tells it to start at the first occurrence of "xyz" in the file. -As a special case, +<number> acts like +<number>g; +As a special case, +<number> acts like +<number>g; that is, it starts the display at the specified line number (however, see the caveat under the "g" command above). If the option starts with ++, the initial command applies to @@ -944,8 +955,8 @@ When entering command line at the bottom of the screen or the pattern for a search command), certain keys can be used to manipulate the command line. Most commands have an alternate form in [ brackets ] which can be used if -a key does not exist on a particular keyboard. -(Note that the forms beginning with ESC do not work +a key does not exist on a particular keyboard. +(Note that the forms beginning with ESC do not work in some MS-DOS and Windows systems because ESC is the line erase character.) Any of these special keys may be entered literally by preceding it with the "literal" character, either ^V or ^A. @@ -990,7 +1001,7 @@ is entered into the command line. Repeated TABs will cycle thru the other matching filenames. If the completed filename is a directory, a "/" is appended to the filename. (On MS-DOS systems, a "\e" is appended.) -The environment variable LESSSEPARATOR can be used to specify a +The environment variable LESSSEPARATOR can be used to specify a different character to append to a directory name. .IP "BACKTAB [ ESC-TAB ]" Like, TAB, but cycles in the reverse direction thru the matching filenames. @@ -1007,9 +1018,9 @@ other than ^U, that character is used instead of ^U. Delete the entire command line and return to the main prompt. .SH "KEY BINDINGS" -You may define your own +You may define your own .I less -commands by using the program +commands by using the program .I lesskey (1) to create a lesskey file. @@ -1022,7 +1033,7 @@ and to set environment variables. If the environment variable LESSKEY is set, .I less uses that as the name of the lesskey file. -Otherwise, +Otherwise, .I less looks in a standard place for the lesskey file: On Unix systems, @@ -1046,24 +1057,24 @@ manual page for more details. .P A system-wide lesskey file may also be set up to provide key bindings. If a key is defined in both a local lesskey file and in the -system-wide file, key bindings in the local file take precedence over +system-wide file, key bindings in the local file take precedence over those in the system-wide file. If the environment variable LESSKEY_SYSTEM is set, .I less uses that as the name of the system-wide lesskey file. Otherwise, -.I less +.I less looks in a standard place for the system-wide lesskey file: On Unix systems, the system-wide lesskey file is /usr/local/etc/sysless. -(However, if -.I less +(However, if +.I less was built with a different sysconf directory than /usr/local/etc, that directory is where the sysless file is found.) On MS-DOS and Windows systems, the system-wide lesskey file is c:\e_sysless. On OS/2 systems, the system-wide lesskey file is c:\esysless.ini. .SH "INPUT PREPROCESSOR" -You may define an "input preprocessor" for +You may define an "input preprocessor" for .I less. Before .I less @@ -1072,10 +1083,10 @@ way the contents of the file are displayed. An input preprocessor is simply an executable program (or shell script), which writes the contents of the file to a different file, called the replacement file. -The contents of the replacement file are then displayed +The contents of the replacement file are then displayed in place of the contents of the original file. However, it will appear to the user as if the original file is opened; -that is, +that is, .I less will display the original filename as the name of the current file. .PP @@ -1083,17 +1094,17 @@ An input preprocessor receives one command line argument, the original filename, as entered by the user. It should create the replacement file, and when finished, print the name of the replacement file to its standard output. -If the input preprocessor does not output a replacement filename, +If the input preprocessor does not output a replacement filename, .I less uses the original file, as normal. The input preprocessor is not called when viewing standard input. To set up an input preprocessor, set the LESSOPEN environment variable to a command line which will invoke your input preprocessor. -This command line should include one occurrence of the string "%s", +This command line should include one occurrence of the string "%s", which will be replaced by the filename when the input preprocessor command is invoked. .PP -When +When .I less closes a file opened in such a way, it will call another program, called the input postprocessor, @@ -1101,11 +1112,11 @@ which may perform any desired clean-up action (such as deleting the replacement file created by LESSOPEN). This program receives two command line arguments, the original filename as entered by the user, and the name of the replacement file. -To set up an input postprocessor, set the LESSCLOSE environment variable +To set up an input postprocessor, set the LESSCLOSE environment variable to a command line which will invoke your input postprocessor. -It may include two occurrences of the string "%s"; -the first is replaced with the original name of the file and -the second with the name of the replacement file, +It may include two occurrences of the string "%s"; +the first is replaced with the original name of the file and +the second with the name of the replacement file, which was output by LESSOPEN. .PP For example, on many Unix systems, these two scripts will allow you @@ -1119,9 +1130,9 @@ lessopen.sh: .br case "$1" in .br - *.Z) uncompress -\c $1 >/tmp/less.$$ 2>/dev/null + *.Z) uncompress \-c $1 >/tmp/less.$$ 2>/dev/null .br - if [ \-s /tmp/less.$$ ]; then + if [ \-s /tmp/less.$$ ]; then .br echo /tmp/less.$$ .br @@ -1148,21 +1159,21 @@ More complex LESSOPEN and LESSCLOSE scripts may be written to accept other types of compressed files, and so on. .PP It is also possible to set up an input preprocessor to -pipe the file data directly to +pipe the file data directly to .I less, rather than putting the data into a replacement file. -This avoids the need to decompress the entire file before +This avoids the need to decompress the entire file before starting to view it. An input preprocessor that works this way is called an input pipe. An input pipe, instead of writing the name of a replacement file on its standard output, writes the entire contents of the replacement file on its standard output. If the input pipe does not write any characters on its standard output, -then there is no replacement file and +then there is no replacement file and .I less uses the original file, as normal. To use an input pipe, -make the first character in the LESSOPEN environment variable a +make the first character in the LESSOPEN environment variable a vertical bar (|) to signify that the input preprocessor is an input pipe. .PP For example, on many Unix systems, this script will work like the @@ -1189,11 +1200,11 @@ To use this script, put it where it can be executed and set LESSOPEN="|lesspipe.sh %s". .PP Note that a preprocessor cannot output an empty file, since that -is interpreted as meaning there is no replacement, and +is interpreted as meaning there is no replacement, and the original file is used. To avoid this, if LESSOPEN starts with two vertical bars, the exit status of the script becomes meaningful. -If the exit status is zero, the output is considered to be +If the exit status is zero, the output is considered to be replacement text, even if it empty. If the exit status is nonzero, any output is ignored and the original file is used. @@ -1212,17 +1223,17 @@ For compatibility with previous versions of .I less, the input preprocessor or pipe is not used if .I less -is viewing standard input. +is viewing standard input. However, if the first character of LESSOPEN is a dash (\-), the input preprocessor is used on standard input as well as other files. -In this case, the dash is not considered to be part of +In this case, the dash is not considered to be part of the preprocessor command. If standard input is being viewed, the input preprocessor is passed a file name consisting of a single dash. Similarly, if the first two characters of LESSOPEN are vertical bar and dash -(|\-) or two vertical bars and a dash (||\-), +(|\-) or two vertical bars and a dash (||\-), the input pipe is used on standard input as well as other files. -Again, in this case the dash is not considered to be part of +Again, in this case the dash is not considered to be part of the input pipe command. .SH "NATIONAL CHARACTER SETS" @@ -1282,11 +1293,11 @@ one character in the character set. The character "." is used for a normal character, "c" for control, and "b" for binary. A decimal number may be used for repetition. -For example, "bccc4b." would mean character 0 is binary, +For example, "bccc4b.\&" would mean character 0 is binary, 1, 2 and 3 are control, 4, 5, 6 and 7 are binary, and 8 is normal. All characters after the last are taken to be the same as the last, so characters 9 through 255 would be normal. -(This is an example, and does not necessarily +(This is an example, and does not necessarily represent any real character set.) .PP This table shows the value of LESSCHARDEF which is equivalent @@ -1313,7 +1324,7 @@ to each of the possible values for LESSCHARSET: next\ \ 8bcccbcc18b95.bb125.bb .PP If neither LESSCHARSET nor LESSCHARDEF is set, -but any of the strings "UTF-8", "UTF8", "utf-8" or "utf8" +but any of the strings "UTF-8", "UTF8", "utf-8" or "utf8" is found in the LC_ALL, LC_CTYPE or LANG environment variables, then the default character set is utf-8. .PP @@ -1331,12 +1342,12 @@ interface is also not available, the default character set is latin1. .PP Control and binary characters are displayed in standout (reverse video). Each such character is displayed in caret notation if possible -(e.g. ^A for control-A). Caret notation is used only if +(e.g.\& ^A for control-A). Caret notation is used only if inverting the 0100 bit results in a normal printable character. Otherwise, the character is displayed as a hex number in angle brackets. -This format can be changed by +This format can be changed by setting the LESSBINFMT environment variable. -LESSBINFMT may begin with a "*" and one character to select +LESSBINFMT may begin with a "*" and one character to select the display attribute: "*k" is blinking, "*d" is bold, "*u" is underlined, "*s" is standout, and "*n" is normal. @@ -1354,12 +1365,12 @@ acts similarly to LESSBINFMT but it applies to Unicode code points that were successfully decoded but are unsuitable for display (e.g., unassigned code points). Its default value is "<U+%04lX>". -Note that LESSUTFBINFMT and LESSBINFMT share their display attribute -setting ("*x") so specifying one will affect both; +Note that LESSUTFBINFMT and LESSBINFMT share their display attribute +setting ("*x") so specifying one will affect both; LESSUTFBINFMT is read after LESSBINFMT so its setting, if any, -will have priority. +will have priority. Problematic octets in a UTF-8 file (octets of a truncated sequence, -octets of a complete but non-shortest form sequence, illegal octets, +octets of a complete but non-shortest form sequence, illegal octets, and stray trailing octets) are displayed individually using LESSBINFMT so as to facilitate diagnostic of how the UTF-8 file is ill-formed. @@ -1424,6 +1435,9 @@ Same as %B. .IP "%t" Causes any trailing spaces to be removed. Usually used at the end of the string, but may appear anywhere. +.IP "%T" +Normally expands to the word "file". +However if viewing files via a tags list using the \-t option, it expands to the word "tag". .IP "%x" Replaced by the name of the next input file in the list. .PP @@ -1490,7 +1504,7 @@ Some examples: This prompt prints the filename, if known; otherwise the string "Standard input". .sp -?f%f .?ltLine %lt:?pt%pt\e%:?btByte %bt:-... +?f%f \&.?ltLine %lt:?pt%pt\e%:?btByte %bt:-... .sp This prompt would print the filename, if known. The filename is followed by the line number, if known, @@ -1500,7 +1514,7 @@ Notice how each question mark has a matching period, and how the % after the %pt is included literally by escaping it with a backslash. .sp -?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\e:\ %x..%t +?n?f%f\ .?m(%T %i of %m)\ ..?e(END)\ ?x-\ Next\e:\ %x..%t"; .sp This prints the filename if this is the first prompt in a file, followed by the "file N of N" message if there is more @@ -1514,17 +1528,17 @@ the other two prompts (\-m and \-M respectively). Each is broken into two lines here for readability only. .nf .sp -?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\e:\ %x.: +?n?f%f\ .?m(%T\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\e:\ %x.: ?pB%pB\e%:byte\ %bB?s/%s...%t .sp -?f%f\ .?n?m(file\ %i\ of\ %m)\ ..?ltlines\ %lt-%lb?L/%L.\ : +?f%f\ .?n?m(%T\ %i\ of\ %m)\ ..?ltlines\ %lt-%lb?L/%L.\ : byte\ %bB?s/%s.\ .?e(END)\ ?x-\ Next\e:\ %x.:?pB%pB\e%..%t .sp .fi And here is the default message produced by the = command: .nf .sp -?f%f\ .?m(file\ %i\ of\ %m)\ .?ltlines\ %lt-%lb?L/%L.\ . +?f%f\ .?m(%T\ %i\ of\ %m)\ .?ltlines\ %lt-%lb?L/%L.\ . byte\ %bB?s/%s.\ ?e(END)\ :?pB%pB\e%..%t .fi .PP @@ -1541,7 +1555,7 @@ The default value for LESSEDIT is: Note that this expands to the editor name, followed by a + and the line number, followed by the file name. If your editor does not accept the "+linenumber" syntax, or has other -differences in invocation syntax, the LESSEDIT variable can be +differences in invocation syntax, the LESSEDIT variable can be changed to modify this default. .SH SECURITY @@ -1580,12 +1594,12 @@ behaves (mostly) in conformance with the POSIX "more" command specification. In this mode, less behaves differently in these ways: .PP The \-e option works differently. -If the \-e option is not set, +If the \-e option is not set, .I less -behaves as if the \-E option were set. -If the \-e option is set, +behaves as if the \-e option were set. +If the \-e option is set, .I less -behaves as if the \-e and \-F options were set. +behaves as if the \-E option were set. .PP The \-m option works differently. If the \-m option is not set, the medium prompt is used, @@ -1595,7 +1609,7 @@ If the \-m option is set, the short prompt is used. The \-n option acts like the \-z option. The normal behavior of the \-n option is unavailable in this mode. .PP -The parameter to the \-p option is taken to be a +The parameter to the \-p option is taken to be a .I less command rather than a search pattern. .PP @@ -1604,10 +1618,10 @@ and the MORE environment variable is used in its place. .SH "ENVIRONMENT VARIABLES" Environment variables may be specified either in the system environment -as usual, or in a +as usual, or in a .I lesskey (1) file. -If environment variables are defined in more than one place, +If environment variables are defined in more than one place, variables defined in a local lesskey file take precedence over variables defined in the system environment, which take precedence over variables defined in the system-wide lesskey file. @@ -1633,7 +1647,7 @@ Language for determining the character set. .IP LC_CTYPE Language for determining the character set. .IP LESS -Options which are passed to +Options which are passed to .I less automatically. .IP LESSANSIENDCHARS @@ -1642,7 +1656,7 @@ Characters which may end an ANSI color escape sequence .IP LESSANSIMIDCHARS Characters which may appear between the ESC character and the end character in an ANSI color escape sequence -(default "0123456789;[?!"'#%()*+\ ". +(default "0123456789:;[?!"'#%()*+\ ". .IP LESSBINFMT Format for displaying non-printable, non-control characters. .IP LESSCHARDEF @@ -1665,11 +1679,11 @@ Normally should be set to "global" if your system has the (1) command. If not set, global tags are not used. .IP LESSHISTFILE Name of the history file used to remember search commands and -shell commands between invocations of +shell commands between invocations of .I less. If set to "\-" or "/dev/null", a history file is not used. The default is "$HOME/.lesshst" on Unix systems, "$HOME/_lesshst" on -DOS and Windows systems, or "$HOME/lesshst.ini" or "$INIT/lesshst.ini" +DOS and Windows systems, or "$HOME/lesshst.ini" or "$INIT/lesshst.ini" on OS/2 systems. .IP LESSHISTSIZE The maximum number of commands to save in the history file. @@ -1695,7 +1709,7 @@ String to be appended to a directory name in filename completion. .IP LESSUTFBINFMT Format for displaying non-printable Unicode code points. .IP LESS_IS_MORE -Emulate the +Emulate the .I more (1) command. .IP LINES @@ -1707,11 +1721,11 @@ LINES and COLUMNS environment variables.) .IP MORE Options which are passed to .I less -automatically when running in +automatically when running in .I more compatible mode. .IP PATH -User's search path (used to find a lesskey file +User's search path (used to find a lesskey file on MS-DOS and OS/2 systems). .IP SHELL The shell used to execute the ! command, as well as to expand filenames. @@ -1726,7 +1740,7 @@ The name of the editor (used for the v command). lesskey(1) .SH COPYRIGHT -Copyright (C) 1984-2012 Mark Nudelman +Copyright (C) 1984-2015 Mark Nudelman .PP less is part of the GNU project and is free software. You can redistribute it and/or modify it @@ -1735,7 +1749,7 @@ under the terms of either the Free Software Foundation; or (2) the Less License. See the file README in the less distribution for more details regarding redistribution. -You should have received a copy of the GNU General Public License +You should have received a copy of the GNU General Public License along with the source for less; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. @@ -1749,12 +1763,12 @@ See the GNU General Public License for more details. .SH AUTHOR .PP -Mark Nudelman +Mark Nudelman .br Send bug reports or comments to <bug-less@gnu.org> .br See http://www.greenwoodsoftware.com/less/bugs.html for the latest list of known bugs in less. .br -For more information, see the less homepage at +For more information, see the less homepage at .br http://www.greenwoodsoftware.com/less. diff --git a/contrib/less/lessecho.c b/contrib/less/lessecho.c index 7098f2d..fb0b22d 100644 --- a/contrib/less/lessecho.c +++ b/contrib/less/lessecho.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/lessecho.nro b/contrib/less/lessecho.nro index d7fb390..78b893f 100644 --- a/contrib/less/lessecho.nro +++ b/contrib/less/lessecho.nro @@ -1,4 +1,4 @@ -.TH LESSECHO 1 "Version 458: 04 Apr 2013" +.TH LESSECHO 1 "Version 481: 31 Aug 2015" .SH NAME lessecho \- expand metacharacters .SH SYNOPSIS diff --git a/contrib/less/lesskey.c b/contrib/less/lesskey.c index 3d7571e..298748b 100644 --- a/contrib/less/lesskey.c +++ b/contrib/less/lesskey.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -120,6 +120,7 @@ struct cmdname cmdnames[] = { "forw-search", A_F_SEARCH }, { "forw-window", A_F_WINDOW }, { "goto-end", A_GOEND }, + { "goto-end-buffered", A_GOEND_BUF }, { "goto-line", A_GOLINE }, { "goto-mark", A_GOMARK }, { "help", A_HELP }, @@ -647,7 +648,7 @@ parse_cmdline(p) do { s = tstr(&p, 1); - cmdlen += strlen(s); + cmdlen += (int) strlen(s); if (cmdlen > MAX_CMDLEN) error("command too long"); else diff --git a/contrib/less/lesskey.h b/contrib/less/lesskey.h index 91098a5..34b8c17 100644 --- a/contrib/less/lesskey.h +++ b/contrib/less/lesskey.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/lesskey.nro b/contrib/less/lesskey.nro index 2bbd887..826332d 100644 --- a/contrib/less/lesskey.nro +++ b/contrib/less/lesskey.nro @@ -1,4 +1,4 @@ -.TH LESSKEY 1 "Version 458: 04 Apr 2013" +.TH LESSKEY 1 "Version 481: 31 Aug 2015" .SH NAME lesskey \- specify key bindings for less .SH SYNOPSIS @@ -178,6 +178,8 @@ default command keys used by less: \ee] right-scroll \ee( left-scroll \ee) right-scroll + \ekl left-scroll + \ekr right-scroll { forw-bracket {} } back-bracket {} ( forw-bracket () @@ -190,6 +192,7 @@ default command keys used by less: \ee> goto-end > goto-end \eke goto-end + \eeG goto-end-buffered = status ^G status :f status @@ -356,26 +359,29 @@ which start with a NUL character (0). This NUL character should be represented as \e340 in a lesskey file. .SH COPYRIGHT -Copyright (C) 2000-2012 Mark Nudelman +Copyright (C) 1984-2015 Mark Nudelman .PP -lesskey is part of the GNU project and is free software; -you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by -the Free Software Foundation; -either version 2, or (at your option) any later version. +less is part of the GNU project and is free software. +You can redistribute it and/or modify it +under the terms of either +(1) the GNU General Public License as published by +the Free Software Foundation; or (2) the Less License. +See the file README in the less distribution for more details +regarding redistribution. +You should have received a copy of the GNU General Public License +along with the source for less; see the file COPYING. +If not, write to the Free Software Foundation, 59 Temple Place, +Suite 330, Boston, MA 02111-1307, USA. +You should also have received a copy of the Less License; +see the file LICENSE. .PP -lesskey is distributed in the hope that it will be useful, but +less is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -.PP -You should have received a copy of the GNU General Public License -along with lesskey; see the file COPYING. -If not, write to the Free Software Foundation, 59 Temple Place, -Suite 330, Boston, MA 02111-1307, USA. .SH AUTHOR .PP -Mark Nudelman <bug-less@gnu.org> +Mark Nudelman .br -Send bug reports or comments to bug-less@gnu.org. +Send bug reports or comments to <bug-less@gnu.org>. diff --git a/contrib/less/lglob.h b/contrib/less/lglob.h index b08d24c..87b5fb4 100644 --- a/contrib/less/lglob.h +++ b/contrib/less/lglob.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/line.c b/contrib/less/line.c index 1eb3914..e54835d 100644 --- a/contrib/less/line.c +++ b/contrib/less/line.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -35,7 +35,7 @@ static int overstrike; /* Next char should overstrike previous char */ static int last_overstrike = AT_NORMAL; static int is_null_line; /* There is no current line */ static int lmargin; /* Left margin */ -static char pendc; +static LWCHAR pendc; static POSITION pendpos; static char *end_ansi_chars; static char *mid_ansi_chars; @@ -78,7 +78,7 @@ init_line() mid_ansi_chars = lgetenv("LESSANSIMIDCHARS"); if (mid_ansi_chars == NULL || *mid_ansi_chars == '\0') - mid_ansi_chars = "0123456789;[?!\"'#%()*+ "; + mid_ansi_chars = "0123456789:;[?!\"'#%()*+ "; linebuf = (char *) ecalloc(LINEBUF_SIZE, sizeof(char)); attr = (char *) ecalloc(LINEBUF_SIZE, sizeof(char)); @@ -209,7 +209,7 @@ plinenum(pos) int n; linenumtoa(linenum, buf); - n = strlen(buf); + n = (int) strlen(buf); if (n < MIN_LINENUM_WIDTH) n = MIN_LINENUM_WIDTH; sprintf(linebuf+curr, "%*s ", n, buf); @@ -491,7 +491,7 @@ backc() && column > lmargin && (!(attr[curr - 1] & (AT_ANSI|AT_BINARY)))) { - curr = p - linebuf; + curr = (int) (p - linebuf); prev_ch = step_char(&p, -1, linebuf + lmargin); width = pwidth(ch, attr[curr], prev_ch); column -= width; @@ -604,7 +604,7 @@ store_char(ch, a, rep, pos) do { bch = step_char(&p, -1, linebuf); } while (p > linebuf && !IS_CSI_START(bch)); - curr = p - linebuf; + curr = (int) (p - linebuf); return 0; } a = AT_ANSI; /* Will force re-AT_'ing around it. */ @@ -697,7 +697,7 @@ store_tab(attr, pos) static int store_prchar(c, pos) - char c; + LWCHAR c; POSITION pos; { char *s; @@ -741,13 +741,15 @@ flush_mbc_buf(pos) */ public int pappend(c, pos) - char c; + unsigned char c; POSITION pos; { int r; if (pendc) { + if (c == '\r' && pendc == '\r') + return (0); if (do_append(pendc, NULL, pendpos)) /* * Oops. We've probably lost the char which @@ -781,7 +783,7 @@ pappend(c, pos) if (!utf_mode) { - r = do_append((LWCHAR) c, NULL, pos); + r = do_append(c, NULL, pos); } else { /* Perform strict validation in all possible cases. */ @@ -791,7 +793,7 @@ pappend(c, pos) mbc_buf_index = 1; *mbc_buf = c; if (IS_ASCII_OCTET(c)) - r = do_append((LWCHAR) c, NULL, pos); + r = do_append(c, NULL, pos); else if (IS_UTF8_LEAD(c)) { mbc_buf_len = utf_len(c); @@ -805,7 +807,7 @@ pappend(c, pos) mbc_buf[mbc_buf_index++] = c; if (mbc_buf_index < mbc_buf_len) return (0); - if (is_utf8_well_formed(mbc_buf)) + if (is_utf8_well_formed(mbc_buf, mbc_buf_index)) r = do_append(get_wchar(mbc_buf), mbc_buf, mbc_pos); else /* Complete, but not shortest form, sequence. */ @@ -885,8 +887,14 @@ do_append(ch, rep, pos) * or just deletion of the character in the buffer. */ overstrike = utf_mode ? -1 : 0; - /* To be correct, this must be a base character. */ - prev_ch = get_wchar(linebuf + curr); + if (utf_mode) + { + /* To be correct, this must be a base character. */ + prev_ch = get_wchar(linebuf + curr); + } else + { + prev_ch = (unsigned char) linebuf[curr]; + } a = attr[curr]; if (ch == prev_ch) { diff --git a/contrib/less/linenum.c b/contrib/less/linenum.c index 4f45be8..6d078ec 100644 --- a/contrib/less/linenum.c +++ b/contrib/less/linenum.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -216,7 +216,7 @@ longloopmessage() static int loopcount; #if HAVE_TIME -static long startime; +static time_type startime; #endif static void diff --git a/contrib/less/lsystem.c b/contrib/less/lsystem.c index 674e5a2..8a7cb8f 100644 --- a/contrib/less/lsystem.c +++ b/contrib/less/lsystem.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -137,7 +137,7 @@ lsystem(cmd, donemsg) char *esccmd = shell_quote(cmd); if (esccmd != NULL) { - int len = strlen(shell) + strlen(esccmd) + 5; + int len = (int) (strlen(shell) + strlen(esccmd) + 5); p = (char *) ecalloc(len, sizeof(char)); SNPRINTF3(p, len, "%s %s %s", shell, shell_coption(), esccmd); free(esccmd); diff --git a/contrib/less/main.c b/contrib/less/main.c index 4a66147..6cfd34d 100644 --- a/contrib/less/main.c +++ b/contrib/less/main.c @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -57,7 +57,6 @@ static char consoleTitle[256]; extern int less_is_more; extern int missing_cap; extern int know_dumb; -extern int quit_if_one_screen; extern int no_init; extern int pr_type; @@ -167,8 +166,6 @@ main(argc, argv) if (less_is_more) no_init = TRUE; - if (less_is_more && get_quit_at_eof()) - quit_if_one_screen = TRUE; #if EDITOR editor = lgetenv("VISUAL"); diff --git a/contrib/less/mark.c b/contrib/less/mark.c index c61ce03..44d606f 100644 --- a/contrib/less/mark.c +++ b/contrib/less/mark.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -15,14 +15,6 @@ extern int sc_height; extern int jump_sline; /* - * A mark is an ifile (input file) plus a position within the file. - */ -struct mark { - IFILE m_ifile; - struct scrpos m_scrpos; -}; - -/* * The table of marks. * Each mark is identified by a lowercase or uppercase letter. * The final one is lmark, for the "last mark"; addressed by the apostrophe. diff --git a/contrib/less/mkhelp.c b/contrib/less/mkhelp.c index 45530fd..d4e4063 100644 --- a/contrib/less/mkhelp.c +++ b/contrib/less/mkhelp.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/mkutable b/contrib/less/mkutable new file mode 100755 index 0000000..803335b --- /dev/null +++ b/contrib/less/mkutable @@ -0,0 +1,75 @@ +#! /usr/bin/perl +use strict; + +my $USAGE = <<__EOF__; + usage: mkutable [-n] [-f#] type... [--] [<] UnicodeData.txt + -n = take non-matching types + -f = zero-based type field (default 2) +__EOF__ + +use vars qw( $opt_f $opt_n ); +use Getopt::Std; +my $type_field = 2; + +exit (main() ? 1 : 0); + +sub main { + my $date = `date`; + chomp $date; + my $args = join ' ', @ARGV; + my $header = "/* Generated by \"$0 $args\" on $date */\n"; + + die $USAGE if not getopts('f:n'); + $type_field = $opt_f if $opt_f; + my %types; + my $arg; + while ($arg = shift @ARGV) { + last if $arg eq '--'; + $types{$arg} = 1; + } + my %out = ( 'types' => \%types ); + my $last_code = 0; + + print $header; + while (<>) { + chomp; + s/#.*//; + my @fields = split /;/; + next if not @fields; + my $code = hex $fields[0]; + my $type = $fields[$type_field]; + $type =~ s/\s//g; + while (++$last_code < $code) { + output(\%out, $last_code, '?'); + } + output(\%out, $code, $type); + } + output(\%out, $last_code+1, '?'); +} + +sub output { + my ($out, $code, $type) = @_; + my $match = ${${$out}{types}}{$type}; + my $type_change = (not $$out{start_type} or $type ne $$out{start_type}); + $match = not $match if $opt_n; + if ($match and (not $$out{in_run} or $type_change)) { + end_run($out, $code-1); + start_run($out, $code, $type); + } elsif (not $match and $$out{in_run}) { + end_run($out, $code-1); + } +} + +sub start_run { + my ($out, $code, $type) = @_; + $$out{start_code} = $code; + $$out{start_type} = $type; + $$out{in_run} = 1; +} + +sub end_run { + my ($out, $code) = @_; + return if not $$out{in_run}; + printf "\t{ 0x%04x, 0x%04x }, /* %s */\n", $$out{start_code}, $code, $$out{start_type}; + $$out{in_run} = 0; +} diff --git a/contrib/less/optfunc.c b/contrib/less/optfunc.c index e3cd57f..c3bb6b2 100644 --- a/contrib/less/optfunc.c +++ b/contrib/less/optfunc.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -43,6 +43,7 @@ extern char *prproto[]; extern char *eqproto; extern char *hproto; extern char *wproto; +extern char *every_first_cmd; extern IFILE curr_ifile; extern char version[]; extern int jump_sline; @@ -58,6 +59,7 @@ extern int logfile; #if TAGS public char *tagoption = NULL; extern char *tags; +extern char ztags[]; #endif #if MSDOS_COMPILER extern int nm_fg_color, nm_bg_color; @@ -87,7 +89,7 @@ opt_o(type, s) switch (type) { case INIT: - namelogfile = s; + namelogfile = save(s); break; case TOGGLE: if (ch_getflags() & CH_CANSEEK) @@ -101,6 +103,8 @@ opt_o(type, s) return; } s = skipsp(s); + if (namelogfile != NULL) + free(namelogfile); namelogfile = lglob(s); use_logfile(namelogfile); sync_logfile(); @@ -176,7 +180,7 @@ opt_j(type, s) { sprintf(buf, ".%06d", jump_sline_fraction); - len = strlen(buf); + len = (int) strlen(buf); while (len > 2 && buf[len-1] == '0') len--; buf[len] = '\0'; @@ -241,7 +245,7 @@ opt_shift(type, s) { sprintf(buf, ".%06d", shift_count_fraction); - len = strlen(buf); + len = (int) strlen(buf); while (len > 2 && buf[len-1] == '0') len--; buf[len] = '\0'; @@ -295,7 +299,7 @@ opt_t(type, s) switch (type) { case INIT: - tagoption = s; + tagoption = save(s); /* Do the rest in main() */ break; case TOGGLE: @@ -335,10 +339,12 @@ opt__T(type, s) switch (type) { case INIT: - tags = s; + tags = save(s); break; case TOGGLE: s = skipsp(s); + if (tags != NULL && tags != ztags) + free(tags); tags = lglob(s); break; case QUERY: @@ -361,18 +367,26 @@ opt_p(type, s) { case INIT: /* - * Unget a search command for the specified string. - * {{ This won't work if the "/" command is - * changed or invalidated by a .lesskey file. }} + * Unget a command for the specified string. */ - plusoption = TRUE; - ungetsc(s); - /* - * In "more" mode, the -p argument is a command, - * not a search string, so we don't need a slash. - */ - if (!less_is_more) + if (less_is_more) + { + /* + * In "more" mode, the -p argument is a command, + * not a search string, so we don't need a slash. + */ + every_first_cmd = save(s); + } else + { + plusoption = TRUE; + ungetcc(CHAR_END_COMMAND); + ungetsc(s); + /* + * {{ This won't work if the "/" command is + * changed or invalidated by a .lesskey file. }} + */ ungetsc("/"); + } break; } } @@ -503,7 +517,7 @@ opt__V(type, s) putstr("no "); #endif putstr("regular expressions)\n"); - putstr("Copyright (C) 1984-2012 Mark Nudelman\n\n"); + putstr("Copyright (C) 1984-2015 Mark Nudelman\n\n"); putstr("less comes with NO WARRANTY, to the extent permitted by law.\n"); putstr("For information about the terms of redistribution,\n"); putstr("see the file named README in the less distribution.\n"); diff --git a/contrib/less/option.c b/contrib/less/option.c index 2c26dc6..256f569 100644 --- a/contrib/less/option.c +++ b/contrib/less/option.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -152,7 +152,10 @@ scan_option(s) if (*str == '+') every_first_cmd = save(str+1); else + { + ungetcc(CHAR_END_COMMAND); ungetsc(str); + } free(str); continue; case '0': case '1': case '2': case '3': case '4': @@ -701,5 +704,5 @@ get_quit_at_eof() if (!less_is_more) return quit_at_eof; /* When less_is_more is set, the -e flag semantics are different. */ - return quit_at_eof ? OPT_ON : OPT_ONPLUS; + return quit_at_eof ? OPT_ONPLUS : OPT_ON; } diff --git a/contrib/less/option.h b/contrib/less/option.h index c11ad3b..dc97d75f 100644 --- a/contrib/less/option.h +++ b/contrib/less/option.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/opttbl.c b/contrib/less/opttbl.c index 6f582bf..b896391 100644 --- a/contrib/less/opttbl.c +++ b/contrib/less/opttbl.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/os.c b/contrib/less/os.c index eb75bba..530abe1 100644 --- a/contrib/less/os.c +++ b/contrib/less/os.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -33,12 +33,6 @@ #include <values.h> #endif -#if HAVE_TIME_T -#define time_type time_t -#else -#define time_type long -#endif - /* * BSD setjmp() saves (and longjmp() restores) the signal mask. * This costs a system call or two per setjmp(), so if possible we clear the @@ -191,7 +185,7 @@ intread() * Return the current time. */ #if HAVE_TIME - public long + public time_type get_time() { time_type t; @@ -243,7 +237,7 @@ errno_message(filename) #else p = "cannot open"; #endif - len = strlen(filename) + strlen(p) + 3; + len = (int) (strlen(filename) + strlen(p) + 3); m = (char *) ecalloc(len, sizeof(char)); SNPRINTF2(m, len, "%s: %s", filename, p); return (m); diff --git a/contrib/less/output.c b/contrib/less/output.c index e1f2cff..d6cfc38 100644 --- a/contrib/less/output.c +++ b/contrib/less/output.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -98,7 +98,7 @@ flush() register int n; register int fd; - n = ob - obuf; + n = (int) (ob - obuf); if (n == 0) return; @@ -197,7 +197,7 @@ flush() * Leave it unprocessed * in the buffer. */ - int slop = q - anchor; + int slop = (int) (q - anchor); /* {{ strcpy args overlap! }} */ strcpy(obuf, anchor); ob = &obuf[slop]; @@ -423,7 +423,7 @@ iprint_int(num) inttoa(num, buf); putstr(buf); - return (strlen(buf)); + return ((int) strlen(buf)); } /* @@ -437,7 +437,7 @@ iprint_linenum(num) linenumtoa(num, buf); putstr(buf); - return (strlen(buf)); + return ((int) strlen(buf)); } /* diff --git a/contrib/less/pattern.c b/contrib/less/pattern.c index fa26b99..71141c7 100644 --- a/contrib/less/pattern.c +++ b/contrib/less/pattern.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -20,10 +20,11 @@ extern int caseless; * Compile a search pattern, for future use by match_pattern. */ static int -compile_pattern2(pattern, search_type, comp_pattern) +compile_pattern2(pattern, search_type, comp_pattern, show_error) char *pattern; int search_type; void **comp_pattern; + int show_error; { if (search_type & SRCH_NO_REGEX) return (0); @@ -37,7 +38,8 @@ compile_pattern2(pattern, search_type, comp_pattern) if (re_compile_pattern(pattern, strlen(pattern), comp)) { free(comp); - error("Invalid pattern", NULL_PARG); + if (show_error) + error("Invalid pattern", NULL_PARG); return (-1); } if (*pcomp != NULL) @@ -50,7 +52,8 @@ compile_pattern2(pattern, search_type, comp_pattern) if (regcomp(comp, pattern, REGCOMP_FLAG)) { free(comp); - error("Invalid pattern", NULL_PARG); + if (show_error) + error("Invalid pattern", NULL_PARG); return (-1); } if (*pcomp != NULL) @@ -68,7 +71,8 @@ compile_pattern2(pattern, search_type, comp_pattern) if (comp == NULL) { parg.p_string = (char *) errstring; - error("%s", &parg); + if (show_error) + error("%s", &parg); return (-1); } *pcomp = comp; @@ -78,7 +82,8 @@ compile_pattern2(pattern, search_type, comp_pattern) int *pcomp = (int *) comp_pattern; if ((parg.p_string = re_comp(pattern)) != NULL) { - error("%s", &parg); + if (show_error) + error("%s", &parg); return (-1); } *pcomp = 1; @@ -88,7 +93,8 @@ compile_pattern2(pattern, search_type, comp_pattern) char **pcomp = (char **) comp_pattern; if ((comp = regcmp(pattern, 0)) == NULL) { - error("Invalid pattern", NULL_PARG); + if (show_error) + error("Invalid pattern", NULL_PARG); return (-1); } if (pcomp != NULL) @@ -98,7 +104,10 @@ compile_pattern2(pattern, search_type, comp_pattern) #if HAVE_V8_REGCOMP struct regexp *comp; struct regexp **pcomp = (struct regexp **) comp_pattern; - if ((comp = regcomp(pattern)) == NULL) + reg_show_error = show_error; + comp = regcomp(pattern); + reg_show_error = 1; + if (comp == NULL) { /* * regcomp has already printed an error message @@ -133,7 +142,7 @@ compile_pattern(pattern, search_type, comp_pattern) cvt_pattern = (char*) ecalloc(1, cvt_length(strlen(pattern), CVT_TO_LC)); cvt_text(cvt_pattern, pattern, (int *)NULL, (int *)NULL, CVT_TO_LC); } - result = compile_pattern2(cvt_pattern, search_type, comp_pattern); + result = compile_pattern2(cvt_pattern, search_type, comp_pattern, 1); if (cvt_pattern != pattern) free(cvt_pattern); return (result); @@ -183,6 +192,24 @@ uncompile_pattern(pattern) } /* + * Can a pattern be successfully compiled? + */ + public int +valid_pattern(pattern) + char *pattern; +{ + void *comp_pattern; + int result; + + CLEAR_PATTERN(comp_pattern); + result = compile_pattern2(pattern, 0, &comp_pattern, 0); + if (result != 0) + return (0); + uncompile_pattern(&comp_pattern); + return (1); +} + +/* * Is a compiled pattern null? */ public int @@ -207,6 +234,9 @@ is_null_pattern(pattern) #if HAVE_V8_REGCOMP return (pattern == NULL); #endif +#if NO_REGEX + return (pattern == NULL); +#endif } /* @@ -227,9 +257,17 @@ match(pattern, pattern_len, buf, buf_len, pfound, pend) for ( ; buf < buf_end; buf++) { - for (pp = pattern, lp = buf; *pp == *lp; pp++, lp++) + for (pp = pattern, lp = buf; ; pp++, lp++) + { + char cp = *pp; + char cl = *lp; + if (caseless == OPT_ONPLUS && ASCII_IS_UPPER(cp)) + cp = ASCII_TO_LOWER(cp); + if (cp != cl) + break; if (pp == pattern_end || lp == buf_end) break; + } if (pp == pattern_end) { if (pfound != NULL) @@ -277,6 +315,7 @@ match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type) struct regexp *spattern = (struct regexp *) pattern; #endif + *sp = *ep = NULL; #if NO_REGEX search_type |= SRCH_NO_REGEX; #endif @@ -287,24 +326,25 @@ match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type) #if HAVE_GNU_REGEX { struct re_registers search_regs; - regoff_t *starts = (regoff_t *) ecalloc(1, sizeof (regoff_t)); - regoff_t *ends = (regoff_t *) ecalloc(1, sizeof (regoff_t)); spattern->not_bol = notbol; - re_set_registers(spattern, &search_regs, 1, starts, ends); + spattern->regs_allocated = REGS_UNALLOCATED; matched = re_search(spattern, line, line_len, 0, line_len, &search_regs) >= 0; if (matched) { *sp = line + search_regs.start[0]; *ep = line + search_regs.end[0]; } - free(starts); - free(ends); } #endif #if HAVE_POSIX_REGCOMP { regmatch_t rm; int flags = (notbol) ? REG_NOTBOL : 0; +#ifdef REG_STARTEND + flags |= REG_STARTEND; + rm.rm_so = 0; + rm.rm_eo = line_len; +#endif matched = !regexec(spattern, line, 1, &rm, flags); if (matched) { diff --git a/contrib/less/pattern.h b/contrib/less/pattern.h index 0a90d5d..712fdcf 100644 --- a/contrib/less/pattern.h +++ b/contrib/less/pattern.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -49,6 +49,7 @@ extern char *__loc1; #if HAVE_V8_REGCOMP #include "regexp.h" +extern int reg_show_error; #define DEFINE_PATTERN(name) struct regexp *name #define CLEAR_PATTERN(name) name = NULL #endif diff --git a/contrib/less/pckeys.h b/contrib/less/pckeys.h index b673756..8fb6800 100644 --- a/contrib/less/pckeys.h +++ b/contrib/less/pckeys.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/position.c b/contrib/less/position.c index b655f07..dc80fd6 100644 --- a/contrib/less/position.c +++ b/contrib/less/position.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/position.h b/contrib/less/position.h index 3b96637..e0e2bff 100644 --- a/contrib/less/position.h +++ b/contrib/less/position.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/prompt.c b/contrib/less/prompt.c index f374101..50ced97 100644 --- a/contrib/less/prompt.c +++ b/contrib/less/prompt.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -85,9 +85,9 @@ ap_str(s) { int len; - len = strlen(s); + len = (int) strlen(s); if (mp + len >= message + PROMPT_SIZE) - len = message + PROMPT_SIZE - mp - 1; + len = (int) (message + PROMPT_SIZE - mp - 1); strncpy(mp, s, len); mp += len; *mp = '\0'; diff --git a/contrib/less/regexp.c b/contrib/less/regexp.c index 77ab611..fcf7c9a 100644 --- a/contrib/less/regexp.c +++ b/contrib/less/regexp.c @@ -243,7 +243,10 @@ char *exp; regcode = r->program; regc(MAGIC); if (reg(0, &flags) == NULL) + { + free(r); return(NULL); + } /* Dig out information for optimizations. */ r->regstart = '\0'; /* Worst-case defaults. */ @@ -274,7 +277,7 @@ char *exp; for (; scan != NULL; scan = regnext(scan)) if (OP(scan) == EXACTLY && ((int) strlen(OPERAND(scan))) >= len) { longest = OPERAND(scan); - len = strlen(OPERAND(scan)); + len = (int) strlen(OPERAND(scan)); } r->regmust = longest; r->regmlen = len; @@ -554,7 +557,7 @@ int *flagp; register char ender; regparse--; - len = strcspn(regparse, META); + len = (int) strcspn(regparse, META); if (len <= 0) FAIL("internal disaster"); ender = *(regparse+len); @@ -670,9 +673,9 @@ char *val; } if (OP(scan) == BACK) - offset = scan - val; + offset = (int) (scan - val); else - offset = val - scan; + offset = (int) (val - scan); *(scan+1) = (offset>>8)&0377; *(scan+2) = offset&0377; } @@ -870,7 +873,7 @@ char *prog; /* Inline the first character, for speed. */ if (*opnd != *reginput) return(0); - len = strlen(opnd); + len = (int) strlen(opnd); if (len > 1 && strncmp(opnd, reginput, len) != 0) return(0); reginput += len; @@ -1034,7 +1037,7 @@ char *p; opnd = OPERAND(p); switch (OP(p)) { case ANY: - count = strlen(scan); + count = (int) strlen(scan); scan += count; break; case EXACTLY: diff --git a/contrib/less/screen.c b/contrib/less/screen.c index a79eba2..8f8a433 100644 --- a/contrib/less/screen.c +++ b/contrib/less/screen.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/scrsize.c b/contrib/less/scrsize.c index 9f786fe..91fc03f 100644 --- a/contrib/less/scrsize.c +++ b/contrib/less/scrsize.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/search.c b/contrib/less/search.c index 24d4210..e824acb 100644 --- a/contrib/less/search.c +++ b/contrib/less/search.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -45,15 +45,57 @@ static POSITION prep_endpos; static int is_caseless; static int is_ucase_pattern; +/* + * Structures for maintaining a set of ranges for hilites and filtered-out + * lines. Each range is stored as a node within a red-black tree, and we + * try to extend existing ranges (without creating overlaps) rather than + * create new nodes if possible. We remember the last node found by a + * search for constant-time lookup if the next search is near enough to + * the previous. To aid that, we overlay a secondary doubly-linked list + * on top of the red-black tree so we can find the preceding/succeeding + * nodes also in constant time. + * + * Each node is allocated from a series of pools, each pool double the size + * of the previous (for amortised constant time allocation). Since our only + * tree operations are clear and node insertion, not node removal, we don't + * need to maintain a usage bitmap or freelist and can just return nodes + * from the pool in-order until capacity is reached. + */ struct hilite { - struct hilite *hl_next; POSITION hl_startpos; POSITION hl_endpos; }; -static struct hilite hilite_anchor = { NULL, NULL_POSITION, NULL_POSITION }; -static struct hilite filter_anchor = { NULL, NULL_POSITION, NULL_POSITION }; -#define hl_first hl_next +struct hilite_node +{ + struct hilite_node *parent; + struct hilite_node *left; + struct hilite_node *right; + struct hilite_node *prev; + struct hilite_node *next; + int red; + struct hilite r; +}; +struct hilite_storage +{ + int capacity; + int used; + struct hilite_storage *next; + struct hilite_node *nodes; +}; +struct hilite_tree +{ + struct hilite_storage *first; + struct hilite_storage *current; + struct hilite_node *root; + struct hilite_node *lookaside; +}; +#define HILITE_INITIALIZER() { NULL, NULL, NULL, NULL } +#define HILITE_LOOKASIDE_STEPS 2 + +static struct hilite_tree hilite_anchor = HILITE_INITIALIZER(); +static struct hilite_tree filter_anchor = HILITE_INITIALIZER(); + #endif /* @@ -219,7 +261,6 @@ repaint_hilite(on) { int slinenum; POSITION pos; - POSITION epos; int save_hide_hilite; if (squished) @@ -245,7 +286,6 @@ repaint_hilite(on) pos = position(slinenum); if (pos == NULL_POSITION) continue; - epos = position(slinenum+1); (void) forw_line(pos); goto_line(slinenum); put_line(); @@ -324,17 +364,23 @@ undo_search() */ public void clr_hlist(anchor) - struct hilite *anchor; + struct hilite_tree *anchor; { - struct hilite *hl; - struct hilite *nexthl; + struct hilite_storage *hls; + struct hilite_storage *nexthls; - for (hl = anchor->hl_first; hl != NULL; hl = nexthl) + for (hls = anchor->first; hls != NULL; hls = nexthls) { - nexthl = hl->hl_next; - free((void*)hl); + nexthls = hls->next; + free((void*)hls->nodes); + free((void*)hls); } - anchor->hl_first = NULL; + anchor->first = NULL; + anchor->current = NULL; + anchor->root = NULL; + + anchor->lookaside = NULL; + prep_startpos = prep_endpos = NULL_POSITION; } @@ -350,6 +396,126 @@ clr_filter() clr_hlist(&filter_anchor); } + struct hilite_node* +hlist_last(anchor) + struct hilite_tree *anchor; +{ + struct hilite_node *n = anchor->root; + while (n != NULL && n->right != NULL) + n = n->right; + return n; +} + + struct hilite_node* +hlist_next(n) + struct hilite_node *n; +{ + return n->next; +} + + struct hilite_node* +hlist_prev(n) + struct hilite_node *n; +{ + return n->prev; +} + +/* + * Find the node covering pos, or the node after it if no node covers it, + * or return NULL if pos is after the last range. Remember the found node, + * to speed up subsequent searches for the same or similar positions (if + * we return NULL, remember the last node.) + */ + struct hilite_node* +hlist_find(anchor, pos) + struct hilite_tree *anchor; + POSITION pos; +{ + struct hilite_node *n, *m; + + if (anchor->lookaside) + { + int steps = 0; + int hit = 0; + + n = anchor->lookaside; + + for (;;) + { + if (pos < n->r.hl_endpos) + { + if (n->prev == NULL || pos >= n->prev->r.hl_endpos) + { + hit = 1; + break; + } + } else if (n->next == NULL) + { + n = NULL; + hit = 1; + break; + } + + /* + * If we don't find the right node within a small + * distance, don't keep doing a linear search! + */ + if (steps >= HILITE_LOOKASIDE_STEPS) + break; + steps++; + + if (pos < n->r.hl_endpos) + anchor->lookaside = n = n->prev; + else + anchor->lookaside = n = n->next; + } + + if (hit) + return n; + } + + n = anchor->root; + m = NULL; + + while (n != NULL) + { + if (pos < n->r.hl_startpos) + { + if (n->left != NULL) + { + m = n; + n = n->left; + continue; + } + break; + } + if (pos >= n->r.hl_endpos) + { + if (n->right != NULL) + { + n = n->right; + continue; + } + if (m != NULL) + { + n = m; + } else + { + m = n; + n = NULL; + } + } + break; + } + + if (n != NULL) + anchor->lookaside = n; + else if (m != NULL) + anchor->lookaside = m; + + return n; +} + /* * Should any characters in a specified range be highlighted? */ @@ -358,18 +524,8 @@ is_hilited_range(pos, epos) POSITION pos; POSITION epos; { - struct hilite *hl; - - /* - * Look at each highlight and see if any part of it falls in the range. - */ - for (hl = hilite_anchor.hl_first; hl != NULL; hl = hl->hl_next) - { - if (hl->hl_endpos > pos && - (epos == NULL_POSITION || epos > hl->hl_startpos)) - return (1); - } - return (0); + struct hilite_node *n = hlist_find(&hilite_anchor, pos); + return (n != NULL && (epos == NULL_POSITION || epos > n->r.hl_startpos)); } /* @@ -379,24 +535,64 @@ is_hilited_range(pos, epos) is_filtered(pos) POSITION pos; { - struct hilite *hl; + struct hilite_node *n; if (ch_getflags() & CH_HELPFILE) return (0); - /* - * Look at each filter and see if the start position - * equals the start position of the line. - */ - for (hl = filter_anchor.hl_first; hl != NULL; hl = hl->hl_next) + n = hlist_find(&filter_anchor, pos); + return (n != NULL && pos >= n->r.hl_startpos); +} + +/* + * If pos is hidden, return the next position which isn't, otherwise + * just return pos. + */ + public POSITION +next_unfiltered(pos) + POSITION pos; +{ + struct hilite_node *n; + + if (ch_getflags() & CH_HELPFILE) + return (pos); + + n = hlist_find(&filter_anchor, pos); + while (n != NULL && pos >= n->r.hl_startpos) { - if (hl->hl_startpos == pos) - return (1); + pos = n->r.hl_endpos; + n = n->next; } - return (0); + return (pos); } /* + * If pos is hidden, return the previous position which isn't or 0 if + * we're filtered right to the beginning, otherwise just return pos. + */ + public POSITION +prev_unfiltered(pos) + POSITION pos; +{ + struct hilite_node *n; + + if (ch_getflags() & CH_HELPFILE) + return (pos); + + n = hlist_find(&filter_anchor, pos); + while (n != NULL && pos >= n->r.hl_startpos) + { + pos = n->r.hl_startpos; + if (pos == 0) + break; + pos--; + n = n->prev; + } + return (pos); +} + + +/* * Should any characters in a specified range be highlighted? * If nohide is nonzero, don't consider hide_hilite. */ @@ -447,43 +643,288 @@ is_hilited(pos, epos, nohide, p_matches) } /* + * Tree node storage: get the current block of nodes if it has spare + * capacity, or create a new one if not. + */ + static struct hilite_storage* +hlist_getstorage(anchor) + struct hilite_tree *anchor; +{ + int capacity = 1; + struct hilite_storage *s; + + if (anchor->current) + { + if (anchor->current->used < anchor->current->capacity) + return anchor->current; + capacity = anchor->current->capacity * 2; + } + + s = (struct hilite_storage *) ecalloc(1, sizeof(struct hilite_storage)); + s->nodes = (struct hilite_node *) ecalloc(capacity, sizeof(struct hilite_node)); + s->capacity = capacity; + s->used = 0; + s->next = NULL; + if (anchor->current) + anchor->current->next = s; + else + anchor->first = s; + anchor->current = s; + return s; +} + +/* + * Tree node storage: retrieve a new empty node to be inserted into the + * tree. + */ + static struct hilite_node* +hlist_getnode(anchor) + struct hilite_tree *anchor; +{ + struct hilite_storage *s = hlist_getstorage(anchor); + return &s->nodes[s->used++]; +} + +/* + * Rotate the tree left around a pivot node. + */ + static void +hlist_rotate_left(anchor, n) + struct hilite_tree *anchor; + struct hilite_node *n; +{ + struct hilite_node *np = n->parent; + struct hilite_node *nr = n->right; + struct hilite_node *nrl = n->right->left; + + if (np != NULL) + { + if (n == np->left) + np->left = nr; + else + np->right = nr; + } else + { + anchor->root = nr; + } + nr->left = n; + n->right = nrl; + + nr->parent = np; + n->parent = nr; + if (nrl != NULL) + nrl->parent = n; +} + +/* + * Rotate the tree right around a pivot node. + */ + static void +hlist_rotate_right(anchor, n) + struct hilite_tree *anchor; + struct hilite_node *n; +{ + struct hilite_node *np = n->parent; + struct hilite_node *nl = n->left; + struct hilite_node *nlr = n->left->right; + + if (np != NULL) + { + if (n == np->right) + np->right = nl; + else + np->left = nl; + } else + { + anchor->root = nl; + } + nl->right = n; + n->left = nlr; + + nl->parent = np; + n->parent = nl; + if (nlr != NULL) + nlr->parent = n; +} + + +/* * Add a new hilite to a hilite list. */ static void add_hilite(anchor, hl) - struct hilite *anchor; + struct hilite_tree *anchor; struct hilite *hl; { - struct hilite *ihl; + struct hilite_node *p, *n, *u; + + /* Ignore empty ranges. */ + if (hl->hl_startpos >= hl->hl_endpos) + return; + + p = anchor->root; + + /* Inserting the very first node is trivial. */ + if (p == NULL) + { + n = hlist_getnode(anchor); + n->r = *hl; + anchor->root = n; + anchor->lookaside = n; + return; + } /* - * Hilites are sorted in the list; find where new one belongs. - * Insert new one after ihl. + * Find our insertion point. If we come across any overlapping + * or adjoining existing ranges, shrink our range and discard + * if it become empty. */ - for (ihl = anchor; ihl->hl_next != NULL; ihl = ihl->hl_next) + for (;;) { - if (ihl->hl_next->hl_startpos > hl->hl_startpos) + if (hl->hl_startpos < p->r.hl_startpos) + { + if (hl->hl_endpos > p->r.hl_startpos) + hl->hl_endpos = p->r.hl_startpos; + if (p->left != NULL) + { + p = p->left; + continue; + } break; + } + if (hl->hl_startpos < p->r.hl_endpos) { + hl->hl_startpos = p->r.hl_endpos; + if (hl->hl_startpos >= hl->hl_endpos) + return; + } + if (p->right != NULL) + { + p = p->right; + continue; + } + break; } /* - * Truncate hilite so it doesn't overlap any existing ones - * above and below it. + * Now we're at the right leaf, again check for contiguous ranges + * and extend the existing node if possible to avoid the + * insertion. Otherwise insert a new node at the leaf. */ - if (ihl != anchor) - hl->hl_startpos = MAXPOS(hl->hl_startpos, ihl->hl_endpos); - if (ihl->hl_next != NULL) - hl->hl_endpos = MINPOS(hl->hl_endpos, ihl->hl_next->hl_startpos); - if (hl->hl_startpos >= hl->hl_endpos) + if (hl->hl_startpos < p->r.hl_startpos) { + if (hl->hl_endpos == p->r.hl_startpos) + { + p->r.hl_startpos = hl->hl_startpos; + return; + } + if (p->prev != NULL && p->prev->r.hl_endpos == hl->hl_startpos) + { + p->prev->r.hl_endpos = hl->hl_endpos; + return; + } + + p->left = n = hlist_getnode(anchor); + n->next = p; + if (p->prev != NULL) + { + n->prev = p->prev; + p->prev->next = n; + } + p->prev = n; + } else { + if (p->r.hl_endpos == hl->hl_startpos) + { + p->r.hl_endpos = hl->hl_endpos; + return; + } + if (p->next != NULL && hl->hl_endpos == p->next->r.hl_startpos) { + p->next->r.hl_startpos = hl->hl_startpos; + return; + } + + p->right = n = hlist_getnode(anchor); + n->prev = p; + if (p->next != NULL) + { + n->next = p->next; + p->next->prev = n; + } + p->next = n; + } + n->parent = p; + n->red = 1; + n->r = *hl; + + /* + * The tree is in the correct order and covers the right ranges + * now, but may have become unbalanced. Rebalance it using the + * standard red-black tree constraints and operations. + */ + for (;;) { + /* case 1 - current is root, root is always black */ + if (n->parent == NULL) + { + n->red = 0; + break; + } + + /* case 2 - parent is black, we can always be red */ + if (!n->parent->red) + break; + /* - * Hilite was truncated out of existence. + * constraint: because the root must be black, if our + * parent is red it cannot be the root therefore we must + * have a grandparent */ - free(hl); - return; + + /* + * case 3 - parent and uncle are red, repaint them black, + * the grandparent red, and start again at the grandparent. + */ + u = n->parent->parent->left; + if (n->parent == u) + u = n->parent->parent->right; + if (u != NULL && u->red) + { + n->parent->red = 0; + u->red = 0; + n = n->parent->parent; + n->red = 1; + continue; + } + + /* + * case 4 - parent is red but uncle is black, parent and + * grandparent on opposite sides. We need to start + * changing the structure now. This and case 5 will shorten + * our branch and lengthen the sibling, between them + * restoring balance. + */ + if (n == n->parent->right && + n->parent == n->parent->parent->left) + { + hlist_rotate_left(anchor, n->parent); + n = n->left; + } else if (n == n->parent->left && + n->parent == n->parent->parent->right) + { + hlist_rotate_right(anchor, n->parent); + n = n->right; + } + + /* + * case 5 - parent is red but uncle is black, parent and + * grandparent on same side + */ + n->parent->red = 0; + n->parent->parent->red = 1; + if (n == n->parent->left) + hlist_rotate_right(anchor, n->parent->parent); + else + hlist_rotate_left(anchor, n->parent->parent); + break; } - hl->hl_next = ihl->hl_next; - ihl->hl_next = hl; } /* @@ -496,12 +937,11 @@ create_hilites(linepos, start_index, end_index, chpos) int end_index; int *chpos; { - struct hilite *hl; + struct hilite hl; int i; /* Start the first hilite. */ - hl = (struct hilite *) ecalloc(1, sizeof(struct hilite)); - hl->hl_startpos = linepos + chpos[start_index]; + hl.hl_startpos = linepos + chpos[start_index]; /* * Step through the displayed chars. @@ -515,13 +955,12 @@ create_hilites(linepos, start_index, end_index, chpos) { if (chpos[i] != chpos[i-1] + 1 || i == end_index) { - hl->hl_endpos = linepos + chpos[i-1] + 1; - add_hilite(&hilite_anchor, hl); + hl.hl_endpos = linepos + chpos[i-1] + 1; + add_hilite(&hilite_anchor, &hl); /* Start new hilite unless this is the last char. */ if (i < end_index) { - hl = (struct hilite *) ecalloc(1, sizeof(struct hilite)); - hl->hl_startpos = linepos + chpos[i]; + hl.hl_startpos = linepos + chpos[i]; } } } @@ -545,8 +984,6 @@ hilite_line(linepos, line, line_len, chpos, sp, ep, cvt_ops) char *searchp; char *line_end = line + line_len; - if (sp == NULL || ep == NULL) - return; /* * sp and ep delimit the first match in the line. * Mark the corresponding file positions, then @@ -559,6 +996,8 @@ hilite_line(linepos, line, line_len, chpos, sp, ep, cvt_ops) */ searchp = line; do { + if (sp == NULL || ep == NULL) + return; create_hilites(linepos, sp-line, ep-line, chpos); /* * If we matched more than zero characters, @@ -694,11 +1133,10 @@ search_pos(search_type) * It starts at the jump target (if searching backwards), * or at the jump target plus one (if forwards). */ - linenum = jump_sline; + linenum = adjsline(jump_sline); if (search_type & SRCH_FORW) - add_one = 1; + add_one = 1; } - linenum = adjsline(linenum); pos = position(linenum); if (add_one) pos = forw_raw_line(pos, (char **)NULL, (int *)NULL); @@ -709,20 +1147,20 @@ search_pos(search_type) */ if (search_type & SRCH_FORW) { - while (pos == NULL_POSITION) - { - if (++linenum >= sc_height) - break; - pos = position(linenum); - } + while (pos == NULL_POSITION) + { + if (++linenum >= sc_height) + break; + pos = position(linenum); + } } else { - while (pos == NULL_POSITION) - { - if (--linenum < 0) - break; - pos = position(linenum); - } + while (pos == NULL_POSITION) + { + if (--linenum < 0) + break; + pos = position(linenum); + } } return (pos); } @@ -842,16 +1280,19 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos) * Check to see if the line matches the filter pattern. * If so, add an entry to the filter list. */ - if ((search_type & SRCH_FIND_ALL) && prev_pattern(&filter_info)) { + if (((search_type & SRCH_FIND_ALL) || + prep_startpos == NULL_POSITION || + linepos < prep_startpos || linepos >= prep_endpos) && + prev_pattern(&filter_info)) { int line_filter = match_pattern(info_compiled(&filter_info), filter_info.text, cline, line_len, &sp, &ep, 0, filter_info.search_type); if (line_filter) { - struct hilite *hl = (struct hilite *) - ecalloc(1, sizeof(struct hilite)); - hl->hl_startpos = linepos; - hl->hl_endpos = pos; - add_hilite(&filter_anchor, hl); + struct hilite hl; + hl.hl_startpos = linepos; + hl.hl_endpos = pos; + add_hilite(&filter_anchor, &hl); + continue; } } #endif @@ -1108,6 +1549,12 @@ prep_hilite(spos, epos, maxlines) return; /* + * Make sure our prep region always starts at the beginning of + * a line. (search_range takes care of the end boundary below.) + */ + spos = back_raw_line(spos+1, (char **)NULL, (int *)NULL); + + /* * If we're limited to a max number of lines, figure out the * file position we should stop at. */ @@ -1199,12 +1646,48 @@ prep_hilite(spos, epos, maxlines) { int search_type = SRCH_FORW | SRCH_FIND_ALL; search_type |= (search_info.search_type & SRCH_NO_REGEX); - result = search_range(spos, epos, search_type, 0, - maxlines, (POSITION*)NULL, &new_epos); - if (result < 0) - return; - if (prep_endpos == NULL_POSITION || new_epos > prep_endpos) - nprep_endpos = new_epos; + for (;;) + { + result = search_range(spos, epos, search_type, 0, maxlines, (POSITION*)NULL, &new_epos); + if (result < 0) + return; + if (prep_endpos == NULL_POSITION || new_epos > prep_endpos) + nprep_endpos = new_epos; + + /* + * Check both ends of the resulting prep region to + * make sure they're not filtered. If they are, + * keep going at least one more line until we find + * something that isn't filtered, or hit the end. + */ + if (prep_endpos == NULL_POSITION || nprep_endpos > prep_endpos) + { + if (new_epos >= nprep_endpos && is_filtered(new_epos-1)) + { + spos = nprep_endpos; + epos = forw_raw_line(nprep_endpos, (char **)NULL, (int *)NULL); + if (epos == NULL_POSITION) + break; + maxlines = 1; + continue; + } + } + + if (prep_startpos == NULL_POSITION || nprep_startpos < prep_startpos) + { + if (nprep_startpos > 0 && is_filtered(nprep_startpos)) + { + epos = nprep_startpos; + spos = back_raw_line(nprep_startpos, (char **)NULL, (int *)NULL); + if (spos == NULL_POSITION) + break; + nprep_startpos = spos; + maxlines = 1; + continue; + } + } + break; + } } prep_startpos = nprep_startpos; prep_endpos = nprep_endpos; @@ -1243,12 +1726,16 @@ is_filtering() * This function is called by the V8 regcomp to report * errors in regular expressions. */ +public int reg_show_error = 1; + void regerror(s) char *s; { PARG parg; + if (!reg_show_error) + return; parg.p_string = s; error("%s", &parg); } diff --git a/contrib/less/signal.c b/contrib/less/signal.c index 9c6c2f6..caa2143 100644 --- a/contrib/less/signal.c +++ b/contrib/less/signal.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/tags.c b/contrib/less/tags.c index 51fbb56..5acf374 100644 --- a/contrib/less/tags.c +++ b/contrib/less/tags.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -14,7 +14,8 @@ #if TAGS -public char *tags = "tags"; +public char ztags[] = "tags"; +public char *tags = ztags; static int total; static int curseq; @@ -287,7 +288,7 @@ findctag(tag) cleantags(); total = 0; - taglen = strlen(tag); + taglen = (int) strlen(tag); /* * Search the tags file for the desired tag. @@ -445,7 +446,7 @@ ctagsearch() * If tagendline is set, make sure we match all * the way to end of line (no extra chars after the match). */ - len = strlen(curtag->tag_pattern); + len = (int) strlen(curtag->tag_pattern); if (strncmp(curtag->tag_pattern, line, len) == 0 && (!curtag->tag_endline || line[len] == '\0' || line[len] == '\r')) { @@ -491,7 +492,7 @@ findgtag(tag, type) { fp = stdin; /* Set tag default because we cannot read stdin again. */ - tags = "tags"; + tags = ztags; } else { #if !HAVE_POPEN @@ -551,7 +552,7 @@ findgtag(tag, type) #endif return TAG_INTR; } - len = strlen(buf); + len = (int) strlen(buf); if (len > 0 && buf[len-1] == '\n') buf[len-1] = '\0'; else diff --git a/contrib/less/ttyin.c b/contrib/less/ttyin.c index db6e72e..129eea1 100644 --- a/contrib/less/ttyin.c +++ b/contrib/less/ttyin.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/ubin.uni b/contrib/less/ubin.uni new file mode 100644 index 0000000..39ec303 --- /dev/null +++ b/contrib/less/ubin.uni @@ -0,0 +1,32 @@ +/* Generated by "./mkutable -f2 Cc Cf Cs Co Zl Zp -- unicode/UnicodeData.txt" on Mon Jul 14 16:21:22 PDT 2014 */ + { 0x0000, 0x001f }, /* Cc */ + { 0x007f, 0x009f }, /* Cc */ + { 0x00ad, 0x00ad }, /* Cf */ + { 0x0600, 0x0605 }, /* Cf */ + { 0x061c, 0x061c }, /* Cf */ + { 0x06dd, 0x06dd }, /* Cf */ + { 0x070f, 0x070f }, /* Cf */ + { 0x180e, 0x180e }, /* Cf */ + { 0x200b, 0x200f }, /* Cf */ + { 0x2028, 0x2028 }, /* Zl */ + { 0x2029, 0x2029 }, /* Zp */ + { 0x202a, 0x202e }, /* Cf */ + { 0x2060, 0x2064 }, /* Cf */ + { 0x2066, 0x206f }, /* Cf */ + { 0xd800, 0xd800 }, /* Cs */ + { 0xdb7f, 0xdb80 }, /* Cs */ + { 0xdbff, 0xdc00 }, /* Cs */ + { 0xdfff, 0xdfff }, /* Cs */ + { 0xe000, 0xe000 }, /* Co */ + { 0xf8ff, 0xf8ff }, /* Co */ + { 0xfeff, 0xfeff }, /* Cf */ + { 0xfff9, 0xfffb }, /* Cf */ + { 0x110bd, 0x110bd }, /* Cf */ + { 0x1bca0, 0x1bca3 }, /* Cf */ + { 0x1d173, 0x1d17a }, /* Cf */ + { 0xe0001, 0xe0001 }, /* Cf */ + { 0xe0020, 0xe007f }, /* Cf */ + { 0xf0000, 0xf0000 }, /* Co */ + { 0xffffd, 0xffffd }, /* Co */ + { 0x100000, 0x100000 }, /* Co */ + { 0x10fffd, 0x10fffd }, /* Co */ diff --git a/contrib/less/version.c b/contrib/less/version.c index d3ecd14..87b0b42 100644 --- a/contrib/less/version.c +++ b/contrib/less/version.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2015 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -762,6 +762,35 @@ v455 11/5/12 Fix typo. v456 11/8/12 Fix option string incompatibility. v457 12/8/12 Use new option string syntax only after --use-backslash. v458 4/4/13 Fix display bug in using up/down in cmd buffer. +----------------------------------------------------------------- +v459 5/6/13 Fix ++ bug. +v460 6/19/13 Automate construction of Unicode tables. +v461 6/21/13 Collapse multiple CRs before LF. +v462 11/26/13 Don't overwrite history file, just append to it. +v463 7/13/14 Misc. fixes. +v464 7/19/14 Fix bugs & improve performance in & filtering + (thanks to John Sullivan). +v465 8/9/14 More fixes from John Sullivan. +v466 8/23/14 Add colon to LESSANSIMIDCHARS. +v467 9/18/14 Misc. fixes. +v468 9/18/14 Fix typo +v469 10/2/14 Allow extra string in command to append to a multichar + cmd without executing it; fix bug using GNU regex. +v470 10/5/14 Fix some compiler warnings. +v471 12/14/14 Fix unget issues with prompt. Allow disabling history + when compiled value of LESSHISTFILE = "-". +v473 12/19/14 Fix prompt bug with stdin and -^P in lesskey extra string. +v474 1/30/15 Fix bug in backwards search with match on bottom line. + Make follow mode reopen file if file shrinks. +v475 3/2/15 Fix possible buffer overrun with invalid UTF-8; + fix bug when compiled with no regex; fix non-match search. +v476 5/3/15 Update man pages. +v477 5/19/15 Fix off-by-one in jump_forw_buffered; + don't add FAKE_* files to cmd history. +v478 5/21/15 Fix nonportable pointer usage in hilite tree. +v479 7/6/15 Allow %% escapes in LESSOPEN variable. +v480 7/24/15 Fix bug in no-regex searches; support MSVC v1900. +v481 8/20/15 Fix broken -g option. */ -char version[] = "458"; +char version[] = "481"; diff --git a/contrib/less/wide.uni b/contrib/less/wide.uni new file mode 100644 index 0000000..b43f7d3 --- /dev/null +++ b/contrib/less/wide.uni @@ -0,0 +1,81 @@ +/* Generated by "./mkutable -f1 W -- unicode/EastAsianWidth.txt" on Mon Jul 14 16:21:23 PDT 2014 */ + { 0x1100, 0x1100 }, /* W */ + { 0x2329, 0x232a }, /* W */ + { 0x2e80, 0x2e80 }, /* W */ + { 0x2e9b, 0x2e9b }, /* W */ + { 0x2f00, 0x2f00 }, /* W */ + { 0x2ff0, 0x2ff0 }, /* W */ + { 0x3001, 0x3001 }, /* W */ + { 0x3004, 0x3012 }, /* W */ + { 0x3014, 0x301e }, /* W */ + { 0x3020, 0x3021 }, /* W */ + { 0x302a, 0x302a }, /* W */ + { 0x302e, 0x302e }, /* W */ + { 0x3030, 0x3031 }, /* W */ + { 0x3036, 0x3036 }, /* W */ + { 0x3038, 0x3038 }, /* W */ + { 0x303b, 0x303e }, /* W */ + { 0x3041, 0x3041 }, /* W */ + { 0x3099, 0x3099 }, /* W */ + { 0x309b, 0x309b }, /* W */ + { 0x309d, 0x309d }, /* W */ + { 0x309f, 0x30a1 }, /* W */ + { 0x30fb, 0x30fc }, /* W */ + { 0x30ff, 0x30ff }, /* W */ + { 0x3105, 0x3105 }, /* W */ + { 0x3131, 0x3131 }, /* W */ + { 0x3190, 0x3190 }, /* W */ + { 0x3192, 0x3192 }, /* W */ + { 0x3196, 0x3196 }, /* W */ + { 0x31a0, 0x31a0 }, /* W */ + { 0x31c0, 0x31c0 }, /* W */ + { 0x31f0, 0x31f0 }, /* W */ + { 0x3200, 0x3200 }, /* W */ + { 0x3220, 0x3220 }, /* W */ + { 0x322a, 0x322a }, /* W */ + { 0x3250, 0x3251 }, /* W */ + { 0x3260, 0x3260 }, /* W */ + { 0x3280, 0x3280 }, /* W */ + { 0x328a, 0x328a }, /* W */ + { 0x32b1, 0x32b1 }, /* W */ + { 0x32c0, 0x32c0 }, /* W */ + { 0x3300, 0x3300 }, /* W */ + { 0x3400, 0x3400 }, /* W */ + { 0x4db6, 0x4db6 }, /* W */ + { 0x4e00, 0x4e00 }, /* W */ + { 0x9fcd, 0x9fcd }, /* W */ + { 0xa000, 0xa000 }, /* W */ + { 0xa015, 0xa016 }, /* W */ + { 0xa490, 0xa490 }, /* W */ + { 0xa960, 0xa960 }, /* W */ + { 0xac00, 0xac00 }, /* W */ + { 0xf900, 0xf900 }, /* W */ + { 0xfa6e, 0xfa6e }, /* W */ + { 0xfa70, 0xfa70 }, /* W */ + { 0xfada, 0xfada }, /* W */ + { 0xfe10, 0xfe10 }, /* W */ + { 0xfe17, 0xfe19 }, /* W */ + { 0xfe30, 0xfe31 }, /* W */ + { 0xfe33, 0xfe33 }, /* W */ + { 0xfe35, 0xfe45 }, /* W */ + { 0xfe47, 0xfe49 }, /* W */ + { 0xfe4d, 0xfe4d }, /* W */ + { 0xfe50, 0xfe50 }, /* W */ + { 0xfe54, 0xfe54 }, /* W */ + { 0xfe58, 0xfe5f }, /* W */ + { 0xfe62, 0xfe64 }, /* W */ + { 0xfe68, 0xfe6a }, /* W */ + { 0x1b000, 0x1b000 }, /* W */ + { 0x1f200, 0x1f200 }, /* W */ + { 0x1f210, 0x1f210 }, /* W */ + { 0x1f240, 0x1f240 }, /* W */ + { 0x1f250, 0x1f250 }, /* W */ + { 0x20000, 0x20000 }, /* W */ + { 0x2a6d7, 0x2a6d7 }, /* W */ + { 0x2a700, 0x2a700 }, /* W */ + { 0x2b735, 0x2b735 }, /* W */ + { 0x2b740, 0x2b740 }, /* W */ + { 0x2b81e, 0x2b81e }, /* W */ + { 0x2f800, 0x2f800 }, /* W */ + { 0x2fa1e, 0x2fa1e }, /* W */ + { 0x30000, 0x30000 }, /* W */ diff --git a/contrib/llvm/projects/libunwind/src/AddressSpace.hpp b/contrib/llvm/projects/libunwind/src/AddressSpace.hpp index 567cbda..55828df 100644 --- a/contrib/llvm/projects/libunwind/src/AddressSpace.hpp +++ b/contrib/llvm/projects/libunwind/src/AddressSpace.hpp @@ -35,7 +35,12 @@ namespace libunwind { #include "Registers.hpp" #if _LIBUNWIND_ARM_EHABI -#ifdef __linux__ +#if defined(__FreeBSD__) + +#include <sys/link_elf.h> +typedef void *_Unwind_Ptr; + +#elif defined(__linux__) typedef long unsigned int *_Unwind_Ptr; extern "C" _Unwind_Ptr __gnu_Unwind_Find_exidx(_Unwind_Ptr addr, int *len); diff --git a/contrib/llvm/projects/libunwind/src/DwarfParser.hpp b/contrib/llvm/projects/libunwind/src/DwarfParser.hpp index 26993c4e..a19f051 100644 --- a/contrib/llvm/projects/libunwind/src/DwarfParser.hpp +++ b/contrib/llvm/projects/libunwind/src/DwarfParser.hpp @@ -380,7 +380,9 @@ bool CFI_Parser<A>::parseInstructions(A &addressSpace, pint_t instructions, uint64_t length; uint8_t opcode = addressSpace.get8(p); uint8_t operand; +#if !defined(_LIBUNWIND_NO_HEAP) PrologInfoStackEntry *entry; +#endif ++p; switch (opcode) { case DW_CFA_nop: @@ -492,6 +494,7 @@ bool CFI_Parser<A>::parseInstructions(A &addressSpace, pint_t instructions, fprintf(stderr, "DW_CFA_register(reg=%" PRIu64 ", reg2=%" PRIu64 ")\n", reg, reg2); break; +#if !defined(_LIBUNWIND_NO_HEAP) case DW_CFA_remember_state: // avoid operator new, because that would be an upward dependency entry = (PrologInfoStackEntry *)malloc(sizeof(PrologInfoStackEntry)); @@ -517,6 +520,7 @@ bool CFI_Parser<A>::parseInstructions(A &addressSpace, pint_t instructions, if (logDwarf) fprintf(stderr, "DW_CFA_restore_state\n"); break; +#endif case DW_CFA_def_cfa: reg = addressSpace.getULEB128(p, instructionsEnd); offset = (int64_t)addressSpace.getULEB128(p, instructionsEnd); diff --git a/contrib/llvm/projects/libunwind/src/UnwindCursor.hpp b/contrib/llvm/projects/libunwind/src/UnwindCursor.hpp index 040d13e..9068316 100644 --- a/contrib/llvm/projects/libunwind/src/UnwindCursor.hpp +++ b/contrib/llvm/projects/libunwind/src/UnwindCursor.hpp @@ -114,6 +114,7 @@ typename A::pint_t DwarfFDECache<A>::findFDE(pint_t mh, pint_t pc) { template <typename A> void DwarfFDECache<A>::add(pint_t mh, pint_t ip_start, pint_t ip_end, pint_t fde) { +#if !defined(_LIBUNWIND_NO_HEAP) _LIBUNWIND_LOG_NON_ZERO(::pthread_rwlock_wrlock(&_lock)); if (_bufferUsed >= _bufferEnd) { size_t oldSize = (size_t)(_bufferEnd - _buffer); @@ -139,6 +140,7 @@ void DwarfFDECache<A>::add(pint_t mh, pint_t ip_start, pint_t ip_end, } #endif _LIBUNWIND_LOG_NON_ZERO(::pthread_rwlock_unlock(&_lock)); +#endif } template <typename A> diff --git a/contrib/llvm/projects/libunwind/src/UnwindRegistersSave.S b/contrib/llvm/projects/libunwind/src/UnwindRegistersSave.S index 1275c2a..f84b711 100644 --- a/contrib/llvm/projects/libunwind/src/UnwindRegistersSave.S +++ b/contrib/llvm/projects/libunwind/src/UnwindRegistersSave.S @@ -87,6 +87,15 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) xorl %eax, %eax # return UNW_ESUCCESS ret +# elif defined(__mips__) + +# +# extern int unw_getcontext(unw_context_t* thread_state) +# +# Just trap for the time being. +DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) + teq $0, $0 + #elif defined(__ppc__) ; diff --git a/contrib/llvm/projects/libunwind/src/config.h b/contrib/llvm/projects/libunwind/src/config.h index 9b24634..ecc0a6b 100644 --- a/contrib/llvm/projects/libunwind/src/config.h +++ b/contrib/llvm/projects/libunwind/src/config.h @@ -41,7 +41,8 @@ #define _LIBUNWIND_BUILD_ZERO_COST_APIS (defined(__i386__) || \ defined(__x86_64__) || \ - defined(__arm64__)) + defined(__arm64__) || \ + defined(__mips__)) #define _LIBUNWIND_BUILD_SJLJ_APIS defined(__arm__) #define _LIBUNWIND_SUPPORT_FRAME_APIS (defined(__i386__) || \ defined(__x86_64__)) diff --git a/contrib/llvm/projects/libunwind/src/libunwind.cpp b/contrib/llvm/projects/libunwind/src/libunwind.cpp index a23dfcf..f9f32f0 100644 --- a/contrib/llvm/projects/libunwind/src/libunwind.cpp +++ b/contrib/llvm/projects/libunwind/src/libunwind.cpp @@ -64,6 +64,8 @@ _LIBUNWIND_EXPORT int unw_init_local(unw_cursor_t *cursor, #elif defined(__or1k__) new ((void *)cursor) UnwindCursor<LocalAddressSpace, Registers_or1k>( context, LocalAddressSpace::sThisAddressSpace); +#elif defined(__mips__) +#warning The MIPS architecture is not supported. #else #error Architecture not supported #endif diff --git a/contrib/ntp/ChangeLog b/contrib/ntp/ChangeLog index 5d8346b..304bd85 100644 --- a/contrib/ntp/ChangeLog +++ b/contrib/ntp/ChangeLog @@ -1,4 +1,61 @@ --- +(4.2.8p5) 2016/01/07 Released by Harlan Stenn <stenn@ntp.org> + +* [Sec 2956] small-step/big-step. Close the panic gate earlier. HStenn. +* CID 1339955: Free allocated memory in caljulian test. HStenn. +* CID 1339962: Explicitly initialize variable in caljulian test. HStenn. +* CID 1341527: Quiet a CHECKED_RETURN in sntp/tests/t-log.c. HStenn. +* CID 1341533: Missing assertion in sntp/tests/t-log.c. HStenn. +* CID 1341534: Resource leak in tests/ntpd/t-ntp_signd.c. HStenn. +* CID 1341535: Resource leak in tests/ntpd/t-ntp_signd.c. HStenn. +* CID 1341536: Resource leak in tests/ntpd/t-ntp_signd.c. HStenn. +* CID 1341537: Resource leak in tests/ntpd/t-ntp_signd.c. HStenn. +* CID 1341538: Memory leak in tests/ntpd/ntp_prio_q.c:262. HStenn. +* CID 1341677: Nits in sntp/tests/keyFile.c. HStenn. +* CID 1341678: Nits in sntp/tests/keyFile.c. HStenn. +* CID 1341679: Nits in sntp/tests/keyFile.c. HStenn. +* CID 1341680: Nits in sntp/tests/keyFile.c. HStenn. +* CID 1341681: Nits in sntp/tests/keyFile.c. HStenn. +* CID 1341682: Nit in libntp/authreadkeys.c. HStenn. +* CID 1341684: Nit in tests/ntpd/t-ntp_signd.c. HStenn. +* [Bug 2829] Look at pipe_fds in ntpd.c (did so. perlinger@ntp.org) +* [Bug 2887] stratum -1 config results as showing value 99 + - fudge stratum should only accept values [0..16]. perlinger@ntp.org +* [Bug 2932] Update leapsecond file info in miscopt.html. CWoodbury, HStenn. +* [Bug 2934] tests/ntpd/t-ntp_scanner.c has a magic constant wired in. HMurray +* [Bug 2944] errno is not preserved properly in ntpdate after sendto call. + - applied patch by Christos Zoulas. perlinger@ntp.org +* [Bug 2952] Symmetric active/passive mode is broken. HStenn. +* [Bug 2954] Version 4.2.8p4 crashes on startup with sig fault + - fixed data race conditions in threaded DNS worker. perlinger@ntp.org + - limit threading warm-up to linux; FreeBSD bombs on it. perlinger@ntp.org +* [Bug 2957] 'unsigned int' vs 'size_t' format clash. perlinger@ntp.org + - accept key file only if there are no parsing errors + - fixed size_t/u_int format clash + - fixed wrong use of 'strlcpy' +* [Bug 2958] ntpq: fatal error messages need a final newline. Craig Leres. +* [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets. perlinger@ntp.org + - fixed several other warnings (cast-alignment, missing const, missing prototypes) + - promote use of 'size_t' for values that express a size + - use ptr-to-const for read-only arguments + - make sure SOCKET values are not truncated (win32-specific) + - format string fixes +* [Bug 2965] Local clock didn't work since 4.2.8p4. Martin Burnicki. +* [Bug 2967] ntpdate command suffers an assertion failure + - fixed ntp_rfc2553.c to return proper address length. perlinger@ntp.org +* [Bug 2969] Seg fault from ntpq/mrulist when looking at server with + lots of clients. perlinger@ntp.org +* [Bug 2971] ntpq bails on ^C: select fails: Interrupted system call + - changed stacked/nested handling of CTRL-C. perlinger@ntp.org +* Unity cleanup for FreeBSD-6.4. Harlan Stenn. +* Unity test cleanup. Harlan Stenn. +* Libevent autoconf pthread fixes for FreeBSD-10. Harlan Stenn. +* Header cleanup in tests/sandbox/uglydate.c. Harlan Stenn. +* Header cleanup in tests/libntp/sfptostr.c. Harlan Stenn. +* Quiet a warning from clang. Harlan Stenn. +* Update the NEWS file. Harlan Stenn. +* Update scripts/calc_tickadj/Makefile.am. Harlan Stenn. +--- (4.2.8p4) 2015/10/21 Released by Harlan Stenn <stenn@ntp.org> (4.2.8p4-RC1) 2015/10/06 Released by Harlan Stenn <stenn@ntp.org> diff --git a/contrib/ntp/CommitLog b/contrib/ntp/CommitLog index 3366f2f..9caeaa2 100644 --- a/contrib/ntp/CommitLog +++ b/contrib/ntp/CommitLog @@ -1,3 +1,1480 @@ +ChangeSet@1.3623, 2016-01-07 23:33:11+00:00, stenn@deacon.udel.edu + NTP_4_2_8P5 + TAG: NTP_4_2_8P5 + + ChangeLog@1.1791 +1 -0 + NTP_4_2_8P5 + + ntpd/invoke-ntp.conf.texi@1.194 +1 -1 + NTP_4_2_8P5 + + ntpd/invoke-ntp.keys.texi@1.186 +1 -1 + NTP_4_2_8P5 + + ntpd/invoke-ntpd.texi@1.503 +2 -2 + NTP_4_2_8P5 + + ntpd/ntp.conf.5man@1.228 +3 -3 + NTP_4_2_8P5 + + ntpd/ntp.conf.5mdoc@1.228 +2 -2 + NTP_4_2_8P5 + + ntpd/ntp.conf.html@1.182 +1 -1 + NTP_4_2_8P5 + + ntpd/ntp.conf.man.in@1.228 +3 -3 + NTP_4_2_8P5 + + ntpd/ntp.conf.mdoc.in@1.228 +2 -2 + NTP_4_2_8P5 + + ntpd/ntp.keys.5man@1.220 +2 -2 + NTP_4_2_8P5 + + ntpd/ntp.keys.5mdoc@1.220 +2 -2 + NTP_4_2_8P5 + + ntpd/ntp.keys.html@1.182 +1 -1 + NTP_4_2_8P5 + + ntpd/ntp.keys.man.in@1.220 +2 -2 + NTP_4_2_8P5 + + ntpd/ntp.keys.mdoc.in@1.220 +2 -2 + NTP_4_2_8P5 + + ntpd/ntpd-opts.c@1.525 +7 -7 + NTP_4_2_8P5 + + ntpd/ntpd-opts.h@1.524 +3 -3 + NTP_4_2_8P5 + + ntpd/ntpd.1ntpdman@1.332 +3 -3 + NTP_4_2_8P5 + + ntpd/ntpd.1ntpdmdoc@1.332 +2 -2 + NTP_4_2_8P5 + + ntpd/ntpd.html@1.176 +2 -2 + NTP_4_2_8P5 + + ntpd/ntpd.man.in@1.332 +3 -3 + NTP_4_2_8P5 + + ntpd/ntpd.mdoc.in@1.332 +2 -2 + NTP_4_2_8P5 + + ntpdc/invoke-ntpdc.texi@1.500 +2 -2 + NTP_4_2_8P5 + + ntpdc/ntpdc-opts.c@1.518 +7 -7 + NTP_4_2_8P5 + + ntpdc/ntpdc-opts.h@1.517 +3 -3 + NTP_4_2_8P5 + + ntpdc/ntpdc.1ntpdcman@1.331 +3 -3 + NTP_4_2_8P5 + + ntpdc/ntpdc.1ntpdcmdoc@1.331 +2 -2 + NTP_4_2_8P5 + + ntpdc/ntpdc.html@1.344 +2 -2 + NTP_4_2_8P5 + + ntpdc/ntpdc.man.in@1.331 +3 -3 + NTP_4_2_8P5 + + ntpdc/ntpdc.mdoc.in@1.331 +2 -2 + NTP_4_2_8P5 + + ntpq/invoke-ntpq.texi@1.507 +2 -2 + NTP_4_2_8P5 + + ntpq/ntpq-opts.c@1.524 +7 -7 + NTP_4_2_8P5 + + ntpq/ntpq-opts.h@1.522 +3 -3 + NTP_4_2_8P5 + + ntpq/ntpq.1ntpqman@1.335 +3 -3 + NTP_4_2_8P5 + + ntpq/ntpq.1ntpqmdoc@1.335 +2 -2 + NTP_4_2_8P5 + + ntpq/ntpq.html@1.173 +2 -2 + NTP_4_2_8P5 + + ntpq/ntpq.man.in@1.335 +3 -3 + NTP_4_2_8P5 + + ntpq/ntpq.mdoc.in@1.335 +2 -2 + NTP_4_2_8P5 + + ntpsnmpd/invoke-ntpsnmpd.texi@1.502 +2 -2 + NTP_4_2_8P5 + + ntpsnmpd/ntpsnmpd-opts.c@1.520 +7 -7 + NTP_4_2_8P5 + + ntpsnmpd/ntpsnmpd-opts.h@1.519 +3 -3 + NTP_4_2_8P5 + + ntpsnmpd/ntpsnmpd.1ntpsnmpdman@1.331 +3 -3 + NTP_4_2_8P5 + + ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc@1.331 +2 -2 + NTP_4_2_8P5 + + ntpsnmpd/ntpsnmpd.html@1.171 +1 -1 + NTP_4_2_8P5 + + ntpsnmpd/ntpsnmpd.man.in@1.331 +3 -3 + NTP_4_2_8P5 + + ntpsnmpd/ntpsnmpd.mdoc.in@1.331 +2 -2 + NTP_4_2_8P5 + + packageinfo.sh@1.522 +2 -2 + NTP_4_2_8P5 + + scripts/calc_tickadj/calc_tickadj.1calc_tickadjman@1.92 +3 -3 + NTP_4_2_8P5 + + scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc@1.93 +2 -2 + NTP_4_2_8P5 + + scripts/calc_tickadj/calc_tickadj.html@1.94 +1 -1 + NTP_4_2_8P5 + + scripts/calc_tickadj/calc_tickadj.man.in@1.91 +3 -3 + NTP_4_2_8P5 + + scripts/calc_tickadj/calc_tickadj.mdoc.in@1.93 +2 -2 + NTP_4_2_8P5 + + scripts/calc_tickadj/invoke-calc_tickadj.texi@1.96 +1 -1 + NTP_4_2_8P5 + + scripts/invoke-plot_summary.texi@1.113 +2 -2 + NTP_4_2_8P5 + + scripts/invoke-summary.texi@1.113 +2 -2 + NTP_4_2_8P5 + + scripts/ntp-wait/invoke-ntp-wait.texi@1.323 +2 -2 + NTP_4_2_8P5 + + scripts/ntp-wait/ntp-wait-opts@1.59 +2 -2 + NTP_4_2_8P5 + + scripts/ntp-wait/ntp-wait.1ntp-waitman@1.320 +3 -3 + NTP_4_2_8P5 + + scripts/ntp-wait/ntp-wait.1ntp-waitmdoc@1.321 +2 -2 + NTP_4_2_8P5 + + scripts/ntp-wait/ntp-wait.html@1.340 +2 -2 + NTP_4_2_8P5 + + scripts/ntp-wait/ntp-wait.man.in@1.320 +3 -3 + NTP_4_2_8P5 + + scripts/ntp-wait/ntp-wait.mdoc.in@1.321 +2 -2 + NTP_4_2_8P5 + + scripts/ntpsweep/invoke-ntpsweep.texi@1.111 +2 -2 + NTP_4_2_8P5 + + scripts/ntpsweep/ntpsweep-opts@1.61 +2 -2 + NTP_4_2_8P5 + + scripts/ntpsweep/ntpsweep.1ntpsweepman@1.99 +3 -3 + NTP_4_2_8P5 + + scripts/ntpsweep/ntpsweep.1ntpsweepmdoc@1.99 +2 -2 + NTP_4_2_8P5 + + scripts/ntpsweep/ntpsweep.html@1.112 +2 -2 + NTP_4_2_8P5 + + scripts/ntpsweep/ntpsweep.man.in@1.99 +3 -3 + NTP_4_2_8P5 + + scripts/ntpsweep/ntpsweep.mdoc.in@1.100 +2 -2 + NTP_4_2_8P5 + + scripts/ntptrace/invoke-ntptrace.texi@1.112 +2 -2 + NTP_4_2_8P5 + + scripts/ntptrace/ntptrace-opts@1.61 +2 -2 + NTP_4_2_8P5 + + scripts/ntptrace/ntptrace.1ntptraceman@1.99 +3 -3 + NTP_4_2_8P5 + + scripts/ntptrace/ntptrace.1ntptracemdoc@1.100 +2 -2 + NTP_4_2_8P5 + + scripts/ntptrace/ntptrace.html@1.113 +2 -2 + NTP_4_2_8P5 + + scripts/ntptrace/ntptrace.man.in@1.99 +3 -3 + NTP_4_2_8P5 + + scripts/ntptrace/ntptrace.mdoc.in@1.101 +2 -2 + NTP_4_2_8P5 + + scripts/plot_summary-opts@1.61 +2 -2 + NTP_4_2_8P5 + + scripts/plot_summary.1plot_summaryman@1.111 +3 -3 + NTP_4_2_8P5 + + scripts/plot_summary.1plot_summarymdoc@1.111 +2 -2 + NTP_4_2_8P5 + + scripts/plot_summary.html@1.114 +2 -2 + NTP_4_2_8P5 + + scripts/plot_summary.man.in@1.111 +3 -3 + NTP_4_2_8P5 + + scripts/plot_summary.mdoc.in@1.111 +2 -2 + NTP_4_2_8P5 + + scripts/summary-opts@1.61 +2 -2 + NTP_4_2_8P5 + + scripts/summary.1summaryman@1.111 +3 -3 + NTP_4_2_8P5 + + scripts/summary.1summarymdoc@1.111 +2 -2 + NTP_4_2_8P5 + + scripts/summary.html@1.114 +2 -2 + NTP_4_2_8P5 + + scripts/summary.man.in@1.111 +3 -3 + NTP_4_2_8P5 + + scripts/summary.mdoc.in@1.111 +2 -2 + NTP_4_2_8P5 + + scripts/update-leap/invoke-update-leap.texi@1.12 +1 -1 + NTP_4_2_8P5 + + scripts/update-leap/update-leap-opts@1.12 +2 -2 + NTP_4_2_8P5 + + scripts/update-leap/update-leap.1update-leapman@1.12 +3 -3 + NTP_4_2_8P5 + + scripts/update-leap/update-leap.1update-leapmdoc@1.12 +2 -2 + NTP_4_2_8P5 + + scripts/update-leap/update-leap.html@1.12 +1 -1 + NTP_4_2_8P5 + + scripts/update-leap/update-leap.man.in@1.12 +3 -3 + NTP_4_2_8P5 + + scripts/update-leap/update-leap.mdoc.in@1.12 +2 -2 + NTP_4_2_8P5 + + sntp/invoke-sntp.texi@1.500 +2 -2 + NTP_4_2_8P5 + + sntp/sntp-opts.c@1.519 +7 -7 + NTP_4_2_8P5 + + sntp/sntp-opts.h@1.517 +3 -3 + NTP_4_2_8P5 + + sntp/sntp.1sntpman@1.335 +3 -3 + NTP_4_2_8P5 + + sntp/sntp.1sntpmdoc@1.335 +2 -2 + NTP_4_2_8P5 + + sntp/sntp.html@1.515 +2 -2 + NTP_4_2_8P5 + + sntp/sntp.man.in@1.335 +3 -3 + NTP_4_2_8P5 + + sntp/sntp.mdoc.in@1.335 +2 -2 + NTP_4_2_8P5 + + util/invoke-ntp-keygen.texi@1.503 +2 -2 + NTP_4_2_8P5 + + util/ntp-keygen-opts.c@1.521 +7 -7 + NTP_4_2_8P5 + + util/ntp-keygen-opts.h@1.519 +3 -3 + NTP_4_2_8P5 + + util/ntp-keygen.1ntp-keygenman@1.331 +3 -3 + NTP_4_2_8P5 + + util/ntp-keygen.1ntp-keygenmdoc@1.331 +2 -2 + NTP_4_2_8P5 + + util/ntp-keygen.html@1.177 +2 -2 + NTP_4_2_8P5 + + util/ntp-keygen.man.in@1.331 +3 -3 + NTP_4_2_8P5 + + util/ntp-keygen.mdoc.in@1.331 +2 -2 + NTP_4_2_8P5 + +ChangeSet@1.3622, 2016-01-07 17:52:24-05:00, stenn@deacon.udel.edu + ntp-4.2.8p5 + + packageinfo.sh@1.521 +1 -1 + ntp-4.2.8p5 + +ChangeSet@1.3621, 2016-01-07 22:20:05+00:00, stenn@psp-at1.ntp.org + cleanup + + NEWS@1.152 +2 -2 + cleanup + +ChangeSet@1.3620, 2016-01-07 09:33:11+00:00, stenn@psp-at1.ntp.org + typo in ntp_proto.c - leap smear. Reported by Martin Burnicki + + ntpd/ntp_proto.c@1.371 +1 -1 + typo in ntp_proto.c - leap smear. Reported by Martin Burnicki + +ChangeSet@1.3619, 2016-01-07 06:33:08+00:00, stenn@psp-at1.ntp.org + Update scripts/calc_tickadj/Makefile.am. Harlan Stenn. + + ChangeLog@1.1790 +1 -0 + Update scripts/calc_tickadj/Makefile.am. Harlan Stenn. + + scripts/calc_tickadj/Makefile.am@1.11 +2 -0 + Update scripts/calc_tickadj/Makefile.am. Harlan Stenn. + +ChangeSet@1.3616.1.1, 2016-01-05 10:57:45+00:00, stenn@psp-at1.ntp.org + Bug 2952 fixes + + ChangeLog@1.1787.1.1 +1 -0 + Bug 2952 fixes + + ntpd/ntp_proto.c@1.370 +165 -152 + Bug 2952 fixes + +ChangeSet@1.3617, 2016-01-05 09:56:31+00:00, stenn@psp-at1.ntp.org + ntp-4.2.8p5 prep + + ChangeLog@1.1788 +2 -1 + ntp-4.2.8p5 prep + + NEWS@1.151 +104 -3 + ntp-4.2.8p5 prep + +ChangeSet@1.3616, 2015-12-06 11:20:02+00:00, stenn@psp-deb1.ntp.org + Quiet a warning from clang. Harlan Stenn. + + ChangeLog@1.1787 +1 -0 + Quiet a warning from clang. Harlan Stenn. + + libntp/ntp_rfc2553.c@1.50 +3 -2 + Quiet a warning from clang. Harlan Stenn. + +ChangeSet@1.3615, 2015-12-05 10:41:51+00:00, stenn@psp-at1.ntp.org + CID 1341677: Nits in sntp/tests/keyFile.c. HStenn. + + ChangeLog@1.1786 +1 -0 + CID 1341677: Nits in sntp/tests/keyFile.c. HStenn. + + sntp/tests/keyFile.c@1.12 +5 -2 + CID 1341677: Nits in sntp/tests/keyFile.c. HStenn. + +ChangeSet@1.3614, 2015-12-05 10:38:28+00:00, stenn@psp-at1.ntp.org + CID 1341678: Nits in sntp/tests/keyFile.c. HStenn. + + ChangeLog@1.1785 +1 -0 + CID 1341678: Nits in sntp/tests/keyFile.c. HStenn. + + sntp/tests/keyFile.c@1.11 +5 -1 + CID 1341678: Nits in sntp/tests/keyFile.c. HStenn. + +ChangeSet@1.3613, 2015-12-05 10:31:39+00:00, stenn@psp-at1.ntp.org + CID 1341679: Nits in sntp/tests/keyFile.c. HStenn. + + ChangeLog@1.1784 +1 -0 + CID 1341679: Nits in sntp/tests/keyFile.c. HStenn. + + sntp/tests/keyFile.c@1.10 +4 -2 + CID 1341679: Nits in sntp/tests/keyFile.c. HStenn. + +ChangeSet@1.3612, 2015-12-05 10:27:40+00:00, stenn@psp-at1.ntp.org + CID 1341680: Nits in sntp/tests/keyFile.c. HStenn. + + ChangeLog@1.1783 +1 -0 + CID 1341680: Nits in sntp/tests/keyFile.c. HStenn. + + sntp/tests/keyFile.c@1.9 +4 -2 + CID 1341680: Nits in sntp/tests/keyFile.c. HStenn. + +ChangeSet@1.3611, 2015-12-05 10:21:07+00:00, stenn@psp-at1.ntp.org + CID 1341681: Nits in sntp/tests/keyFile.c. HStenn. + + ChangeLog@1.1782 +1 -0 + CID 1341681: Nits in sntp/tests/keyFile.c. HStenn. + +ChangeSet@1.3610, 2015-12-05 10:18:23+00:00, stenn@psp-at1.ntp.org + sntp/tests/keyFile.c lint + + sntp/tests/keyFile.c@1.8 +4 -2 + sntp/tests/keyFile.c lint + +ChangeSet@1.3609, 2015-12-05 10:01:47+00:00, stenn@psp-at1.ntp.org + CID 1341682: Nit in libntp/authreadkeys.c. HStenn. + + ChangeLog@1.1781 +1 -0 + CID 1341682: Nit in libntp/authreadkeys.c. HStenn. + + libntp/authreadkeys.c@1.24 +3 -4 + CID 1341682: Nit in libntp/authreadkeys.c. HStenn. + +ChangeSet@1.3608, 2015-12-05 09:40:44+00:00, stenn@psp-at1.ntp.org + CID 1341684: Nit in tests/ntpd/t-ntp_signd.c. HStenn. + + ChangeLog@1.1780 +1 -0 + CID 1341684: Nit in tests/ntpd/t-ntp_signd.c. HStenn. + + tests/ntpd/t-ntp_signd.c@1.15 +4 -0 + CID 1341684: Nit in tests/ntpd/t-ntp_signd.c. HStenn. + +ChangeSet@1.3607, 2015-12-03 12:07:30+00:00, stenn@psp-at1.ntp.org + Update some test runners + + tests/libntp/run-sfptostr.c@1.7 +9 -8 + update + + tests/sandbox/run-uglydate.c@1.7 +2 -1 + update + +ChangeSet@1.3606, 2015-12-03 03:28:15-08:00, cov-build@cov7.ntfo.org + Header cleanup in tests/libntp/sfptostr.c. Harlan Stenn. + + ChangeLog@1.1779 +1 -0 + Header cleanup in tests/libntp/sfptostr.c. Harlan Stenn. + + tests/libntp/sfptostr.c@1.5 +1 -0 + Header cleanup in tests/libntp/sfptostr.c. Harlan Stenn. + +ChangeSet@1.3605, 2015-12-03 03:26:50-08:00, cov-build@cov7.ntfo.org + Header cleanup in tests/sandbox/uglydate.c. Harlan Stenn. + + ChangeLog@1.1778 +1 -0 + Header cleanup in tests/sandbox/uglydate.c. Harlan Stenn. + + tests/sandbox/uglydate.c@1.6 +2 -1 + Header cleanup in tests/sandbox/uglydate.c. Harlan Stenn. + +ChangeSet@1.3604, 2015-12-03 02:16:02-08:00, cov-build@cov7.ntfo.org + CID 1341527: Quiet a CHECKED_RETURN in sntp/tests/t-log.c. HStenn. + + ChangeLog@1.1777 +1 -0 + CID 1341527: Quiet a CHECKED_RETURN in sntp/tests/t-log.c. HStenn. + + sntp/tests/t-log.c@1.7 +1 -1 + CID 1341527: Quiet a CHECKED_RETURN in sntp/tests/t-log.c. HStenn. + +ChangeSet@1.3603, 2015-12-03 02:00:58-08:00, cov-build@cov7.ntfo.org + CID 1341533: Missing assertion in sntp/tests/t-log.c. HStenn. + + ChangeLog@1.1776 +1 -0 + CID 1341533: Missing assertion in sntp/tests/t-log.c. HStenn. + + sntp/tests/t-log.c@1.6 +2 -0 + CID 1341533: Missing assertion in sntp/tests/t-log.c. HStenn. + +ChangeSet@1.3602, 2015-12-03 01:50:11-08:00, cov-build@cov7.ntfo.org + CID 134534-134537: Resource leaks in tests/ntpd/t-ntp_signd.c. HStenn. + + ChangeLog@1.1775 +4 -0 + CID 134534-134537: Resource leaks in tests/ntpd/t-ntp_signd.c. HStenn. + + tests/ntpd/t-ntp_signd.c@1.14 +9 -0 + CID 134534-134537: Resource leaks in tests/ntpd/t-ntp_signd.c. HStenn. + +ChangeSet@1.3601, 2015-12-03 01:22:22-08:00, cov-build@cov7.ntfo.org + CID 1341538: Memory leak in tests/ntpd/ntp_prio_q.c:262. HStenn. + + ChangeLog@1.1774 +1 -0 + CID 1341538: Memory leak in tests/ntpd/ntp_prio_q.c:262. HStenn. + + tests/ntpd/ntp_prio_q.c@1.3 +1 -0 + CID 1341538: Memory leak in tests/ntpd/ntp_prio_q.c:262. HStenn. + +ChangeSet@1.3597.4.1, 2015-11-30 06:03:47+01:00, jnperlin@hydra.localnet + [Bug 2829] Look at pipe_fds in ntpd.c (initial value issue) + + ChangeLog@1.1770.4.1 +1 -0 + [Bug 2829] Look at pipe_fds in ntpd.c + + ntpd/ntpd.c@1.167 +3 -0 + [Bug 2829] Look at pipe_fds in ntpd.c (initial value issue) + +ChangeSet@1.3597.3.1, 2015-11-29 13:03:58+01:00, jnperlin@hydra.localnet + [Bug 2887] stratum -1 config results as showing value 99 + - fudge stratum only accepts values [0..16]. + + ChangeLog@1.1770.3.1 +2 -0 + [Bug 2887] stratum -1 config results as showing value 99 + - fudge stratum only accepts values [0..16]. + + ntpd/ntp_parser.c@1.100 +178 -171 + [Bug 2887] stratum -1 config results as showing value 99 + - fudge stratum only accepts values [0..16]. (file regenerated by bison & trimmed manually) + + ntpd/ntp_parser.y@1.90 +8 -1 + [Bug 2887] stratum -1 config results as showing value 99 + - fudge stratum only accepts values [0..16], gives error otherwise + +ChangeSet@1.3597.2.1, 2015-11-28 22:59:39+01:00, jnperlin@hydra.localnet + [Bug 2944] errno is not preserved properly in ntpdate after sendto call. + - applied patch by Christos Zoulas. + + ChangeLog@1.1770.2.1 +2 -0 + [Bug 2944] errno is not preserved properly in ntpdate after sendto call. + - applied patch by Christos Zoulas. + + libntp/socktohost.c@1.16 +10 -2 + [Bug 2944] errno is not preserved properly in ntpdate after sendto call. + - save errno around calls to getnameinfo/getaddrinfo (patch by Christos Zoulas) + +ChangeSet@1.3597.1.4, 2015-11-28 19:09:53+01:00, jnperlin@hydra.localnet + Bug 2971 - ntpq bails on ^C: select fails: Interrupted system call + - changed stacked/nested handling of CTRL-C. + + ChangeLog@1.1770.1.2 +2 -0 + Bug 2971 - ntpq bails on ^C: select fails: Interrupted system call + - changed stacked/nested handling of CTRL-C. + + ntpq/ntpq-subs.c@1.114 +11 -8 + Bug 2971 - ntpq bails on ^C: select fails: Interrupted system call + - changed stacked/nested handling of CTRL-C. + + ntpq/ntpq.c@1.165 +57 -8 + Bug 2971 - ntpq bails on ^C: select fails: Interrupted system call + - changed stacked/nested handling of CTRL-C. + + ntpq/ntpq.h@1.31 +4 -0 + Bug 2971 - ntpq bails on ^C: select fails: Interrupted system call + - changed stacked/nested handling of CTRL-C. + +ChangeSet@1.3597.1.3, 2015-11-25 22:10:45-08:00, harlan@max.pfcs.com + Libevent autoconf pthread fixes for FreeBSD-10. Harlan Stenn. + + ChangeLog@1.1770.1.1 +1 -0 + Libevent autoconf pthread fixes for FreeBSD-10. Harlan Stenn. + + sntp/m4/ntp_libevent.m4@1.16 +2 -1 + Libevent autoconf pthread fixes for FreeBSD-10. Harlan Stenn. + +ChangeSet@1.3597.1.2, 2015-11-25 12:23:40+00:00, stenn@psp-at1.ntp.org + Unity test cleanup. Harlan Stenn. + + tests/ntpd/run-t-ntp_signd.c@1.11 +6 -6 + Unity test cleanup. Harlan Stenn. + + tests/ntpd/t-ntp_signd.c@1.13 +19 -5 + Unity test cleanup. Harlan Stenn. + +ChangeSet@1.3597.1.1, 2015-11-25 11:50:51+00:00, stenn@psp-at1.ntp.org + Unity test cleanup. Harlan Stenn. + + sntp/unity/unity_internals.h@1.5 +13 -1 + Unity test cleanup. Harlan Stenn. + + tests/libntp/calendar.c@1.12 +8 -3 + Unity test cleanup. Harlan Stenn. + + tests/ntpd/leapsec.c@1.4 +241 -82 + Unity test cleanup. Harlan Stenn. + + tests/ntpd/run-leapsec.c@1.6 +33 -33 + Unity test cleanup. Harlan Stenn. + + tests/ntpd/run-t-ntp_signd.c@1.10 +6 -6 + Unity test cleanup. Harlan Stenn. + + tests/ntpd/t-ntp_signd.c@1.12 +40 -13 + Unity test cleanup. Harlan Stenn. + + tests/sandbox/smeartest.c@1.10 +3 -0 + Unity test cleanup. Harlan Stenn. + +ChangeSet@1.3598, 2015-11-24 08:06:41+01:00, jnperlin@hydra.localnet + [Bug 2967] ntpdate command suffers an assertion failure + - fixed ntp_rfc2553.c to return proper address length. + + ChangeLog@1.1771 +2 -0 + [Bug 2967] ntpdate command suffers an assertion failure + - fixed ntp_rfc2553.c to return proper address length. + + libntp/ntp_rfc2553.c@1.49 +2 -1 + [Bug 2967] ntpdate command suffers an assertion failure + - fix do_nodename() to return the proper address length when name is NULL. + +ChangeSet@1.3597, 2015-11-23 10:55:16+00:00, stenn@psp-at1.ntp.org + ChangeLog, caljulian.c: + * CID 1339955: Free allocated memory in caljulian test. HStenn. + * CID 1339962: Explicitly initialize variable in caljulian test. HStenn. + + ChangeLog@1.1770 +2 -0 + * CID 1339955: Free allocated memory in caljulian test. HStenn. + * CID 1339962: Explicitly initialize variable in caljulian test. HStenn. + + tests/libntp/caljulian.c@1.14 +16 -10 + * CID 1339955: Free allocated memory in caljulian test. HStenn. + * CID 1339962: Explicitly initialize variable in caljulian test. HStenn. + +ChangeSet@1.3596, 2015-11-20 20:16:24-08:00, harlan@hms-mbp11.pfcs.com + Unity test cleanup. Harlan Stenn. + + sntp/tests/kodDatabase.c@1.9 +0 -4 + Unity test cleanup. Harlan Stenn. + + sntp/tests/run-kodDatabase.c@1.9 +5 -5 + Unity test cleanup. Harlan Stenn. + +ChangeSet@1.3595, 2015-11-20 19:41:16-08:00, harlan@hms-mbp11.pfcs.com + Unity test cleanup. Harlan Stenn. + + sntp/tests/kodDatabase.c@1.8 +6 -0 + Unity test cleanup. Harlan Stenn. + + sntp/tests/kodFile.c@1.9 +1 -0 + Unity test cleanup. Harlan Stenn. + + sntp/tests/run-kodDatabase.c@1.8 +6 -5 + Unity test cleanup. Harlan Stenn. + + sntp/tests/run-t-log.c@1.5 +3 -3 + Unity test cleanup. Harlan Stenn. + + sntp/tests/t-log.c@1.5 +32 -16 + Unity test cleanup. Harlan Stenn. + + tests/libntp/calendar.c@1.11 +11 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/caljulian.c@1.13 +1 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/decodenetnum.c@1.10 +10 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/humandate.c@1.7 +10 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/lfptostr.c@1.8 +9 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/modetoa.c@1.8 +10 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/msyslog.c@1.7 +10 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/netof.c@1.9 +10 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/numtoa.c@1.7 +11 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/numtohost.c@1.7 +11 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/prettydate.c@1.6 +10 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/recvbuff.c@1.7 +3 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/refidsmear.c@1.7 +10 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/refnumtoa.c@1.7 +10 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-calendar.c@1.11 +15 -15 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-decodenetnum.c@1.10 +6 -6 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-humandate.c@1.7 +2 -2 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-lfptostr.c@1.8 +11 -11 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-modetoa.c@1.12 +2 -2 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-msyslog.c@1.9 +8 -8 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-netof.c@1.8 +4 -4 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-numtoa.c@1.11 +2 -2 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-numtohost.c@1.11 +1 -1 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-prettydate.c@1.6 +1 -1 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-refidsmear.c@1.8 +1 -1 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-refnumtoa.c@1.9 +2 -2 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-sfptostr.c@1.6 +8 -8 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-socktoa.c@1.13 +6 -6 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-statestr.c@1.11 +4 -4 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-strtolfp.c@1.6 +7 -7 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-timespecops.c@1.11 +28 -28 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-timevalops.c@1.13 +28 -28 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-uglydate.c@1.11 +1 -1 + Unity test cleanup. Harlan Stenn. + + tests/libntp/sfptostr.c@1.4 +10 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/socktoa.c@1.11 +11 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/statestr.c@1.6 +11 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/strtolfp.c@1.7 +10 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/timespecops.c@1.10 +10 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/timevalops.c@1.13 +10 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/uglydate.c@1.10 +13 -1 + Unity test cleanup. Harlan Stenn. + + tests/sandbox/run-uglydate.c@1.6 +1 -1 + Unity test cleanup. Harlan Stenn. + + tests/sandbox/smeartest.c@1.9 +2 -0 + Unity test cleanup. Harlan Stenn. + + tests/sandbox/uglydate.c@1.5 +11 -0 + Unity test cleanup. Harlan Stenn. + +ChangeSet@1.3594, 2015-11-20 07:40:57+00:00, stenn@psp-at1.ntp.org + [Bug 2958] ntpq: fatal error messages need a final newline. Craig Leres. + + ChangeLog@1.1769 +1 -0 + [Bug 2958] ntpq: fatal error messages need a final newline. Craig Leres. + + ntpq/ntpq.c@1.164 +1 -1 + [Bug 2958] ntpq: fatal error messages need a final newline. Craig Leres. + +ChangeSet@1.3593, 2015-11-20 07:27:27+00:00, stenn@psp-at1.ntp.org + Unity test cleanup. Harlan Stenn. + + tests/libntp/authkeys.c@1.13 +36 -10 + Unity test cleanup. Harlan Stenn. + + tests/libntp/buftvtots.c@1.6 +18 -6 + Unity test cleanup. Harlan Stenn. + + tests/libntp/calendar.c@1.10 +100 -47 + Unity test cleanup. Harlan Stenn. + + tests/libntp/caljulian.c@1.12 +27 -9 + Unity test cleanup. Harlan Stenn. + + tests/libntp/clocktime.c@1.9 +48 -24 + Unity test cleanup. Harlan Stenn. + + tests/libntp/humandate.c@1.6 +6 -2 + Unity test cleanup. Harlan Stenn. + + tests/libntp/lfpfunc.c@1.15 +113 -69 + Unity test cleanup. Harlan Stenn. + + tests/libntp/netof.c@1.8 +22 -7 + Unity test cleanup. Harlan Stenn. + + tests/libntp/numtohost.c@1.6 +1 -1 + Unity test cleanup. Harlan Stenn. + + tests/libntp/octtoint.c@1.7 +36 -14 + Unity test cleanup. Harlan Stenn. + + tests/libntp/refidsmear.c@1.6 +1 -4 + Unity test cleanup. Harlan Stenn. + + tests/libntp/refnumtoa.c@1.6 +5 -5 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-lfpfunc.c@1.18 +9 -9 + Unity test cleanup. Harlan Stenn. + + tests/libntp/run-refidsmear.c@1.7 +1 -1 + Unity test cleanup. Harlan Stenn. + + tests/libntp/timespecops.c@1.9 +173 -48 + Unity test cleanup. Harlan Stenn. + + tests/libntp/timestructs.h@1.3 +22 -22 + Unity test cleanup. Harlan Stenn. + + tests/libntp/timevalops.c@1.12 +168 -52 + Unity test cleanup. Harlan Stenn. + +ChangeSet@1.3592, 2015-11-20 02:57:37+01:00, jnperlin@nemesis.localnet + [Bug 2969] Seg fault from ntpq/mrulist when looking at server with lots of clients + + ChangeLog@1.1768 +2 -0 + [Bug 2969] Seg fault from ntpq/mrulist when looking at server with lots of clients + + lib/isc/sockaddr.c@1.14 +1 -1 + [Bug 2969] Seg fault from ntpq/mrulist when looking at server with lots of clients + - cast fro size_t to u_int (no overflow danger); not related the bug, found while double-checking changes + + ntpq/ntpq-subs.c@1.113 +1 -1 + [Bug 2969] Seg fault from ntpq/mrulist when looking at server with lots of clients + - make end-of-buffer test unsigned-safe + +ChangeSet@1.3591, 2015-11-17 11:12:02+00:00, stenn@psp-at1.ntp.org + [Bug 2932] Update leapsecond file info in miscopt.html. CWoodbury, HStenn. + + ChangeLog@1.1767 +1 -0 + [Bug 2932] Update leapsecond file info in miscopt.html. CWoodbury, HStenn. + + html/miscopt.html@1.84 +3 -3 + [Bug 2932] Update leapsecond file info in miscopt.html. CWoodbury, HStenn. + +ChangeSet@1.3588, 2015-11-17 05:02:10+00:00, stenn@psp-at1.ntp.org + Credit Martin for 2965 + + ChangeLog@1.1764.1.3 +1 -1 + Credit Martin for 2965 + +ChangeSet@1.3587, 2015-11-17 04:53:39+00:00, stenn@psp-at1.ntp.org + cleanup + + ChangeLog@1.1764.1.2 +1 -1 + cleanup + +ChangeSet@1.3584.2.1, 2015-11-16 11:59:55+01:00, burnicki@pc-martin4. + [Bug 2965] Local clock didn't work since 4.2.8p4 + + ChangeLog@1.1764.1.1 +1 -0 + [Bug 2965] Local clock didn't work since 4.2.8p4 + + ntpd/refclock_local.c@1.22 +1 -0 + [Bug 2965] Local clock didn't work since 4.2.8p4 + +ChangeSet@1.3584.1.2, 2015-11-14 01:01:05+01:00, jnperlin@hydra.localnet + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - fix warnings in test cases + + tests/libntp/a_md5encrypt.c@1.14 +23 -15 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - fix terrible const/noconst and alignment mess + + tests/libntp/authkeys.c@1.12 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - fixed cast to const cast + + tests/libntp/run-a_md5encrypt.c@1.15 +5 -5 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - update generated file + + tests/ntpd/rc_cmdlength.c@1.3 +1 -0 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - add header to get prototype + + tests/ntpd/run-rc_cmdlength.c@1.4 +2 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + +ChangeSet@1.3584.1.1, 2015-11-13 22:54:35+01:00, jnperlin@hydra.localnet + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - fixed several other warnings (cast-alignment, missing const, missing prorotypes) + - promote use of 'size_t' for values that express a size + - use ptr-to-const for read-only arguments + - make sure SOCKET values are not truncated (win32-specific) + - format string fixes + + ChangeLog@1.1765 +6 -0 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets. + + include/Makefile.am@1.53 +1 -0 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - added 'safeconst.h' to noinstall-headers + + include/ntp_refclock.h@1.37 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - use ptr-to-const for read-only values + + include/ntp_stdlib.h@1.80 +4 -4 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + - use ptr-to-const for read-only data + + include/ntpd.h@1.193 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + + include/safecast.h@1.1 +34 -0 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - checked or saturated size conversion + - added unaligned pointer casts + + include/safecast.h@1.0 +0 -0 + + lib/isc/backtrace.c@1.3 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - avoid increased-alignment-earning in pointer cast + + lib/isc/buffer.c@1.2 +2 -2 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + + lib/isc/inet_aton.c@1.6 +2 -3 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + + lib/isc/inet_pton.c@1.7 +3 -3 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + + lib/isc/log.c@1.9 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + + lib/isc/netaddr.c@1.14 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - explicit cast (no overflow) to u_int + + lib/isc/sockaddr.c@1.13 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - explicit cast to 'u_int' (no overflow possible) + + lib/isc/task.c@1.8 +8 -8 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - avoid warnings about increased alignment requirements (not using 'safecast.h' since it's not in this lib) + + lib/isc/win32/interfaceiter.c@1.23 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - avoid truncation of SOCKET + + lib/isc/win32/net.c@1.17 +2 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - avoid truncation of SOCKET + + libntp/a_md5encrypt.c@1.35 +14 -14 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + - use ptr-to-const for read-only values + + libntp/atolfp.c@1.7 +2 -2 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - explit cast from size_t to u_long (no overflow possoble) + + libntp/authkeys.c@1.27.1.1 +4 -4 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + + libntp/authusekey.c@1.10 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + + libntp/dolfptoa.c@1.12 +3 -3 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - explicit cast to size_t to in (no overflow possible) + + libntp/hextolfp.c@1.5 +6 -4 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - explicit cast size_t to u_long (no overflow possible) + + libntp/mstolfp.c@1.5 +1 -2 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + + libntp/msyslog.c@1.54 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + + libntp/ntp_crypto_rnd.c@1.4 +2 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - use checked cast for interface with openSSL + + libntp/ntp_lineedit.c@1.14 +2 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - downcast of size_t (no risk here) + + libntp/ntp_worker.c@1.6 +2 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - downcast of size_t (no real risk of overflow) + + libntp/snprintf.c@1.13 +10 -10 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - use explicit downcasts in conversions + + libparse/clk_computime.c@1.13 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - use "%p" to format pointers + + libparse/clk_dcf7000.c@1.13 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - use "%p" to format pointers + + libparse/clk_hopf6021.c@1.12 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - use "%p" to format pointers + + libparse/clk_meinberg.c@1.16 +2 -2 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - use "%p" to format pointers + + libparse/clk_rawdcf.c@1.23 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - use "%p" to format pointers + + libparse/clk_rcc8000.c@1.12 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - use "%p" to format pointers + + libparse/clk_schmid.c@1.15 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - use "%p" to format pointers + + libparse/clk_trimtaip.c@1.13 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - use "%p" to format pointers + + libparse/clk_varitext.c@1.12 +6 -6 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - commented unused static const values + --- + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - use "%p" to format pointers + + libparse/clk_wharton.c@1.11 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - use "%p" to format pointers + + libparse/parse.c@1.21 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - use "%p" to format pointers + + ntpd/ntp_control.c@1.205 +5 -5 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + + ntpd/ntp_crypto.c@1.185 +2 -2 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - fix small signed/unsigned clash + + ntpd/ntp_io.c@1.409 +6 -6 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - remove cast-alignment warnings by casting via 'void*' + - proper cast from SOCKET to int when file descriptor needed + + ntpd/ntp_loopfilter.c@1.188 +2 -0 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - avoid 'unused' warnings + + ntpd/ntp_proto.c@1.369 +8 -6 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + - format string fixes + - fix signed/unsigned clash + + ntpd/ntp_refclock.c@1.121 +3 -3 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - use ptr-to-const for read-only parameters + + ntpd/ntp_request.c@1.115 +2 -2 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - avoid serious LP64 problem by using uint32_t instead of u_long + + ntpd/ntp_restrict.c@1.40 +2 -2 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + + ntpd/ntp_signd.c@1.5 +3 -2 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - fixed missing 'const' in cast + + ntpd/ntp_timer.c@1.93 +7 -6 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - avoid mixed float/int calculations + + ntpd/ntp_util.c@1.117 +3 -3 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + + ntpd/refclock_parse.c@1.82 +2 -2 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + + ntpd/refclock_shm.c@1.38 +3 -2 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - fixed some volatile madness & casts + + ntpd/refclock_true.c@1.25 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + + ntpd/refclock_tsyncpci.c@1.10 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - remove cast-alignment warnings by omitting superfluous cast + + ntpdate/ntpdate.c@1.97 +7 -7 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + - avoid truncation of SOCKET handles + + ntpdc/ntpdc.c@1.105 +36 -34 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + - format string fixes + + ntpdc/ntpdc.h@1.12 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + + ntpdc/ntpdc_ops.c@1.81 +109 -109 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + - format string fixes + + ntpq/libntpq.c@1.13 +7 -9 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + - format string fixes + + ntpq/libntpq.h@1.11 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - more size_t propagation and format string fixes + + ntpq/libntpq_subs.c@1.7 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - more size_t propagation and format string fixes + + ntpq/ntpq-subs.c@1.112 +39 -37 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + - format string fixes + + ntpq/ntpq.c@1.163 +34 -34 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + - format string fixes + + ntpq/ntpq.h@1.30 +7 -7 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + + ports/winnt/include/config.h@1.113 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - use ptr-to-const for read-only values + + ports/winnt/include/ntp_iocompletionport.h@1.21 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - avoid truncation of SOCKET identifiers + + ports/winnt/instsrv/instsrv.c@1.7 +6 -6 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - explicit cast to DWORD (overflow hardly possible) + + ports/winnt/libntp/termios.c@1.32 +18 -16 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - promote use of 'size_t' for values that express a size + - use ptr-to-const for read-only values + - avoid truncation of handle + + ports/winnt/ntpd/ntp_iocompletionport.c@1.72 +9 -6 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - avoid truncation of SOCKET handles + + ports/winnt/vs2008/common.vsprops@1.2 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - disable a size_t cast warnings + + ports/winnt/vs2008/ntpd/ntpd.vcproj@1.50 +49 -17 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - disable C4307 (integer constant overflow) on refclock_arc.c + + ports/winnt/vs2013/common.props@1.2 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - disable the annoying truncation-of-value error + + ports/winnt/vs2013/libntp/libntp.vcxproj@1.9 +1 -0 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - add 'safecast.h' header + + ports/winnt/vs2013/libntp/libntp.vcxproj.filters@1.7 +3 -0 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - add safecast.h header + + ports/winnt/vs2013/ntpd/ntpd.vcxproj@1.8 +7 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - refclock_arc is very noisy with integer constant overflow + + sntp/networking.c@1.67 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - remove cast-alignment warnings by casting via 'void*' + + tests/libntp/authkeys.c@1.11 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - fix missing 'const' in cast + + tests/ntpd/ntp_restrict.c@1.3 +1 -0 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - fix function declarations + + tests/ntpd/run-ntp_restrict.c@1.5 +8 -8 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - update auto-generated file + + tests/ntpd/run-t-ntp_signd.c@1.9 +7 -7 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - fix function prototypes + + tests/ntpd/t-ntp_scanner.c@1.7 +3 -3 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - add missing 'const' declarations + + tests/ntpd/t-ntp_signd.c@1.11 +24 -13 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - added missing prototypes and a fix serious pointer problem + + tests/sandbox/run-uglydate.c@1.3.1.1 +1 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - update generated file + + tests/sandbox/uglydate.c@1.2.1.1 +4 -1 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - add prototypes + + tests/sec-2853/sec-2853.c@1.7 +6 -6 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - fix size_t format + + util/ntp-keygen.c@1.107 +3 -3 + [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets + - let openssl sort out the string size + +ChangeSet@1.3585, 2015-11-07 23:46:41+00:00, stenn@psp-at1.ntp.org + Unity test cleanup. Harlan Stenn. + + sntp/tests/t-log.c@1.4 +1 -1 + Unity test cleanup. Harlan Stenn. + + tests/sandbox/run-uglydate.c@1.4 +1 -1 + Unity test cleanup. Harlan Stenn. + + tests/sandbox/uglydate.c@1.3 +2 -0 + Unity test cleanup. Harlan Stenn. + +ChangeSet@1.3581.1.1, 2015-11-06 08:33:23+01:00, jnperlin@hydra.localnet + [Bug 2957] format specifies type 'unsigned int' but the argument has type 'size_t' + - accept key file only if there are no parsing errors + - fixed size_t/u_int format clash + - restore pre-Bug1243 compatibility (revert 'strlcpy()' to 'strncpy()' as 'strlcpy()' is wrong here) + + ChangeLog@1.1761.1.1 +4 -0 + [Bug 2957] format specifies type 'unsigned int' but the argument has type 'size_t' + - accept key file only if there are no parsing errors + - fixed size_t/u_int format clash + - restore pre-Bug1243 compatibility (revert 'strlcpy()' to 'strncpy()' as 'strlcpy()' is wrong here) + + libntp/authkeys.c@1.28 +17 -5 + [Bug 2957] format specifies type 'unsigned int' but the argument has type 'size_t' + - restore pre-Bug1243 compatibility (revert 'strlcpy()' to 'strncpy()' as 'strlcpy()' is wrong here) + + libntp/authreadkeys.c@1.23 +68 -22 + [Bug 2957] format specifies type 'unsigned int' but the argument has type 'size_t' + - accept key file only if there are no parsing errors + - fixed size_t/u_int format clash + +ChangeSet@1.3584, 2015-11-05 11:47:50+00:00, stenn@psp-at1.ntp.org + Unity test cleanup. Harlan Stenn. + + ChangeLog@1.1764 +1 -0 + Unity test cleanup. Harlan Stenn. + + sntp/tests/run-t-log.c@1.4 +1 -1 + Unity test cleanup. Harlan Stenn. + + sntp/tests/t-log.c@1.3 +1 -0 + Unity test cleanup. Harlan Stenn. + + sntp/tests/utilities.c@1.5 +2 -2 + Unity test cleanup. Harlan Stenn. + + tests/bug-2803/bug-2803.c@1.10 +1 -1 + Unity test cleanup. Harlan Stenn. + + tests/bug-2803/run-bug-2803.c@1.9 +2 -0 + Unity test cleanup. Harlan Stenn. + + tests/libntp/a_md5encrypt.c@1.13 +2 -2 + Unity test cleanup. Harlan Stenn. + + tests/libntp/caljulian.c@1.11 +4 -4 + Unity test cleanup. Harlan Stenn. + + tests/libntp/lfpfunc.c@1.14 +9 -9 + Unity test cleanup. Harlan Stenn. + + tests/libntp/netof.c@1.7 +10 -10 + Unity test cleanup. Harlan Stenn. + + tests/libntp/prettydate.c@1.5 +3 -2 + Unity test cleanup. Harlan Stenn. + + tests/libntp/recvbuff.c@1.6 +1 -1 + Unity test cleanup. Harlan Stenn. + + tests/libntp/socktoa.c@1.10 +2 -2 + Unity test cleanup. Harlan Stenn. + + tests/libntp/uglydate.c@1.9 +2 -2 + Unity test cleanup. Harlan Stenn. + + tests/sandbox/smeartest.c@1.8 +1 -0 + Unity test cleanup. Harlan Stenn. + + tests/sandbox/uglydate.c@1.2 +2 -2 + Unity test cleanup. Harlan Stenn. + + tests/sec-2853/sec-2853.c@1.6 +1 -4 + Unity test cleanup. Harlan Stenn. + +ChangeSet@1.3583, 2015-11-05 10:37:38+00:00, stenn@psp-at1.ntp.org + Unity cleanup for FreeBSD-6.4. Harlan Stenn. + + ChangeLog@1.1763 +1 -1 + Unity cleanup for FreeBSD-6.4. Harlan Stenn. + + ChangeLog@1.1762 +1 -0 + Unity cleanup for FreeBSD-6.2. Harlan Stenn. + + sntp/m4/ntp_problemtests.m4@1.4 +4 -1 + Unity cleanup for FreeBSD-6.4. Harlan Stenn. + +ChangeSet@1.3582, 2015-11-05 10:01:57+00:00, stenn@psp-at1.ntp.org + Sec 2956 cleanup + + include/ntpd.h@1.192 +1 -0 + Sec 2956 cleanup + + libntp/systime.c@1.70 +2 -3 + Sec 2956 cleanup + + ntpd/ntp_loopfilter.c@1.187 +0 -2 + Sec 2956 cleanup + + ntpdate/ntpdate.c@1.96 +0 -3 + Sec 2956 cleanup + + ntpsnmpd/ntpsnmpd.c@1.10 +0 -3 + Sec 2956 cleanup + + sntp/main.c@1.98 +0 -3 + Sec 2956 cleanup + +ChangeSet@1.3581, 2015-11-04 10:02:25+00:00, stenn@psp-at1.ntp.org + [Bug 2934] tests/ntpd/t-ntp_scanner.c has a magic constant wired in. HMurray + + ChangeLog@1.1761 +2 -1 + [Bug 2934] tests/ntpd/t-ntp_scanner.c has a magic constant wired in. HMurray + + tests/ntpd/t-ntp_scanner.c@1.6 +1 -1 + [Bug 2934] tests/ntpd/t-ntp_scanner.c has a magic constant wired in. HMurray + +ChangeSet@1.3580, 2015-11-04 08:39:12+00:00, stenn@psp-at1.ntp.org + [Sec 2956] small-step/big-step. Close the panic gate earlier. + + ChangeLog@1.1760 +2 -0 + [Sec 2956] small-step/big-step. Close the panic gate earlier. + + libntp/systime.c@1.69 +23 -2 + [Sec 2956] small-step/big-step. Close the panic gate earlier. + + ntpd/ntp_loopfilter.c@1.186 +17 -27 + [Sec 2956] small-step/big-step. Close the panic gate earlier. + + ntpdate/ntpdate.c@1.95 +3 -0 + [Sec 2956] small-step/big-step. Close the panic gate earlier. + + ntpsnmpd/ntpsnmpd.c@1.9 +3 -0 + [Sec 2956] small-step/big-step. Close the panic gate earlier. + + sntp/main.c@1.97 +3 -0 + [Sec 2956] small-step/big-step. Close the panic gate earlier. + +ChangeSet@1.3579, 2015-11-03 22:08:46+01:00, jnperlin@hydra.localnet + [Bug 2954] Version 4.2.8p4 crashes on startup with sig fault + - limit threading warm-up to linux; FreeBSD bombs on it. perlinger@ntp.org + + ChangeLog@1.1759 +1 -0 + [Bug 2954] Version 4.2.8p4 crashes on startup with sig fault + - limit threading warm-up to linux; FreeBSD bombs on it. perlinger@ntp.org + + ntpd/ntpd.c@1.166 +9 -2 + [Bug 2954] Version 4.2.8p4 crashes on startup with sig fault + - limit threading warm-up to linux; FreeBSD bombs on it. perlinger@ntp.org + +ChangeSet@1.3578, 2015-10-31 18:04:18+00:00, perlinger@psp-deb1.ntp.org + [Bug 2954] Version 4.2.8p4 crashes on startup with sig fault + - fixed race conditions between worker and main thread in DNS worker + + ChangeLog@1.1758 +3 -0 + [Bug 2954] Version 4.2.8p4 crashes on startup with sig fault + - fixed race conditions between worker and main thread in DNS worker + + include/ntp_worker.h@1.4 +45 -21 + [Bug 2954] Version 4.2.8p4 crashes on startup with sig fault + - provide shared access lock based on semaphore + - better isolation of OS dependencies + + libntp/work_thread.c@1.18 +370 -231 + [Bug 2954] Version 4.2.8p4 crashes on startup with sig fault + - fixed race conditions between worker and main thread + - better (still not perfect) isolation of OS dependent code for semaphore handling + ChangeSet@1.3577, 2015-10-21 12:42:02-04:00, stenn@deacon.udel.edu NTP_4_2_8P4 TAG: NTP_4_2_8P4 diff --git a/contrib/ntp/NEWS b/contrib/ntp/NEWS index e16d937..32c9288 100644 --- a/contrib/ntp/NEWS +++ b/contrib/ntp/NEWS @@ -1,7 +1,108 @@ --- + +NTP 4.2.8p5 + +Focus: Security, Bug fixes, enhancements. + +Severity: MEDIUM + +In addition to bug fixes and enhancements, this release fixes the +following medium-severity vulnerability: + +* Small-step/big-step. Close the panic gate earlier. + References: Sec 2956, CVE-2015-5300 + Affects: All ntp-4 releases up to, but not including 4.2.8p5, and + 4.3.0 up to, but not including 4.3.78 + CVSS3: (AV:N/AC:H/PR:H/UI:R/S:C/C:L/I:N/A:L) Base Score: 4.0, MEDIUM + Summary: If ntpd is always started with the -g option, which is + common and against long-standing recommendation, and if at the + moment ntpd is restarted an attacker can immediately respond to + enough requests from enough sources trusted by the target, which + is difficult and not common, there is a window of opportunity + where the attacker can cause ntpd to set the time to an + arbitrary value. Similarly, if an attacker is able to respond + to enough requests from enough sources trusted by the target, + the attacker can cause ntpd to abort and restart, at which + point it can tell the target to set the time to an arbitrary + value if and only if ntpd was re-started against long-standing + recommendation with the -g flag, or if ntpd was not given the + -g flag, the attacker can move the target system's time by at + most 900 seconds' time per attack. + Mitigation: + Configure ntpd to get time from multiple sources. + Upgrade to 4.2.8p5, or later, from the NTP Project Download + Page or the NTP Public Services Project Download Page + As we've long documented, only use the -g option to ntpd in + cold-start situations. + Monitor your ntpd instances. + Credit: This weakness was discovered by Aanchal Malhotra, + Isaac E. Cohen, and Sharon Goldberg at Boston University. + + NOTE WELL: The -g flag disables the limit check on the panic_gate + in ntpd, which is 900 seconds by default. The bug identified by + the researchers at Boston University is that the panic_gate + check was only re-enabled after the first change to the system + clock that was greater than 128 milliseconds, by default. The + correct behavior is that the panic_gate check should be + re-enabled after any initial time correction. + + If an attacker is able to inject consistent but erroneous time + responses to your systems via the network or "over the air", + perhaps by spoofing radio, cellphone, or navigation satellite + transmissions, they are in a great position to affect your + system's clock. There comes a point where your very best + defenses include: + + Configure ntpd to get time from multiple sources. + Monitor your ntpd instances. + +Other fixes: + +* Coverity submission process updated from Coverity 5 to Coverity 7. + The NTP codebase has been undergoing regular Coverity scans on an + ongoing basis since 2006. As part of our recent upgrade from + Coverity 5 to Coverity 7, Coverity identified 16 nits in some of + the newly-written Unity test programs. These were fixed. +* [Bug 2829] Clean up pipe_fds in ntpd.c perlinger@ntp.org +* [Bug 2887] stratum -1 config results as showing value 99 + - fudge stratum should only accept values [0..16]. perlinger@ntp.org +* [Bug 2932] Update leapsecond file info in miscopt.html. CWoodbury, HStenn. +* [Bug 2934] tests/ntpd/t-ntp_scanner.c has a magic constant wired in. HMurray +* [Bug 2944] errno is not preserved properly in ntpdate after sendto call. + - applied patch by Christos Zoulas. perlinger@ntp.org +* [Bug 2952] Peer associations broken by fix for Bug 2901/CVE-2015-7704. +* [Bug 2954] Version 4.2.8p4 crashes on startup on some OSes. + - fixed data race conditions in threaded DNS worker. perlinger@ntp.org + - limit threading warm-up to linux; FreeBSD bombs on it. perlinger@ntp.org +* [Bug 2957] 'unsigned int' vs 'size_t' format clash. perlinger@ntp.org + - accept key file only if there are no parsing errors + - fixed size_t/u_int format clash + - fixed wrong use of 'strlcpy' +* [Bug 2958] ntpq: fatal error messages need a final newline. Craig Leres. +* [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets. perlinger@ntp.org + - fixed several other warnings (cast-alignment, missing const, missing prototypes) + - promote use of 'size_t' for values that express a size + - use ptr-to-const for read-only arguments + - make sure SOCKET values are not truncated (win32-specific) + - format string fixes +* [Bug 2965] Local clock didn't work since 4.2.8p4. Martin Burnicki. +* [Bug 2967] ntpdate command suffers an assertion failure + - fixed ntp_rfc2553.c to return proper address length. perlinger@ntp.org +* [Bug 2969] Seg fault from ntpq/mrulist when looking at server with + lots of clients. perlinger@ntp.org +* [Bug 2971] ntpq bails on ^C: select fails: Interrupted system call + - changed stacked/nested handling of CTRL-C. perlinger@ntp.org +* Unity cleanup for FreeBSD-6.4. Harlan Stenn. +* Unity test cleanup. Harlan Stenn. +* Libevent autoconf pthread fixes for FreeBSD-10. Harlan Stenn. +* Header cleanup in tests/sandbox/uglydate.c. Harlan Stenn. +* Header cleanup in tests/libntp/sfptostr.c. Harlan Stenn. +* Quiet a warning from clang. Harlan Stenn. + +--- NTP 4.2.8p4 -Focus: Security, Bug fies, enhancements. +Focus: Security, Bug fixes, enhancements. Severity: MEDIUM @@ -339,8 +440,8 @@ Credit: This weakness was discovered by Aleksandar Nikolic of Cisco Talos. Backward-Incompatible changes: * [Bug 2817] Default on Linux is now "rlimit memlock -1". -While the general default of 32M is still the case, under Linux -the default value has been changed to -1 (do not lock ntpd into + While the general default of 32M is still the case, under Linux + the default value has been changed to -1 (do not lock ntpd into memory). A value of 0 means "lock ntpd into memory with whatever memory it needs." If your ntp.conf file has an explicit "rlimit memlock" value in it, that value will continue to be used. diff --git a/contrib/ntp/configure b/contrib/ntp/configure index 04813a8..758ffa9 100755 --- a/contrib/ntp/configure +++ b/contrib/ntp/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for ntp 4.2.8p4. +# Generated by GNU Autoconf 2.69 for ntp 4.2.8p5. # # Report bugs to <http://bugs.ntp.org./>. # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='ntp' PACKAGE_TARNAME='ntp' -PACKAGE_VERSION='4.2.8p4' -PACKAGE_STRING='ntp 4.2.8p4' +PACKAGE_VERSION='4.2.8p5' +PACKAGE_STRING='ntp 4.2.8p5' PACKAGE_BUGREPORT='http://bugs.ntp.org./' PACKAGE_URL='http://www.ntp.org./' @@ -1616,7 +1616,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures ntp 4.2.8p4 to adapt to many kinds of systems. +\`configure' configures ntp 4.2.8p5 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1686,7 +1686,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of ntp 4.2.8p4:";; + short | recursive ) echo "Configuration of ntp 4.2.8p5:";; esac cat <<\_ACEOF @@ -1919,7 +1919,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -ntp configure 4.2.8p4 +ntp configure 4.2.8p5 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2749,7 +2749,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by ntp $as_me 4.2.8p4, which was +It was created by ntp $as_me 4.2.8p5, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3750,7 +3750,7 @@ fi # Define the identity of the package. PACKAGE='ntp' - VERSION='4.2.8p4' + VERSION='4.2.8p5' cat >>confdefs.h <<_ACEOF @@ -20018,9 +20018,10 @@ $as_echo "$as_me: Using the installed libevent" >&6;} # LDADD_LIBEVENT=`$PKG_CONFIG --libs libevent | sed 's:-levent::'` # So now we dance... LDADD_LIBEVENT= - for i in `$PKG_CONFIG --libs libevent` + for i in `$PKG_CONFIG --libs libevent` `$PKG_CONFIG --cflags-only-other libevent_pthreads` do case "$i" in + -D*) ;; -levent*) ;; *) case "$LDADD_LIBEVENT" in '') LDADD_LIBEVENT="$i" ;; @@ -37035,8 +37036,9 @@ $as_echo "$ntp_ept" >&6; } $as_echo_n "checking if we can run test-ntp_restrict... " >&6; } ntp_test_ntp_restrict="no" case "$ntp_ept:$cross:$host" in + no:0:*-*-freebsd6.4) ;; + no:0:*-*-hpux11.23*) ;; no:0:*-*-solaris*) ;; - no:0:*-*-hpux-11.23*) ;; *) ntp_test_ntp_restrict="yes" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_test_ntp_restrict" >&5 @@ -37054,6 +37056,7 @@ fi $as_echo_n "checking if we can run test-ntp_scanner... " >&6; } ntp_test_ntp_scanner="no" case "$ntp_ept:$cross:$host" in + no:0:*-*-freebsd6.4) ;; no:0:*-*-solaris*) ;; *) ntp_test_ntp_scanner="yes" ;; esac @@ -37072,6 +37075,7 @@ fi $as_echo_n "checking if we can run test-ntp_signd... " >&6; } ntp_test_ntp_signd="no" case "$ntp_ept:$cross:$host" in + no:0:*-*-freebsd6.4) ;; no:0:*-*-solaris*) ;; *) ntp_test_ntp_signd="yes" ;; esac @@ -37836,7 +37840,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by ntp $as_me 4.2.8p4, which was +This file was extended by ntp $as_me 4.2.8p5, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -37903,7 +37907,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -ntp config.status 4.2.8p4 +ntp config.status 4.2.8p5 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/contrib/ntp/html/miscopt.html b/contrib/ntp/html/miscopt.html index c619022..261b08f 100644 --- a/contrib/ntp/html/miscopt.html +++ b/contrib/ntp/html/miscopt.html @@ -3,7 +3,7 @@ <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> <title>Miscellaneous Commands and Options</title> -<!-- Changed by: Harlan Stenn, 29-Jun-2015 --> +<!-- Changed by: Harlan Stenn, 17-Nov-2015 --> <link href="scripts/style.css" type="text/css" rel="stylesheet"> </head> <body> @@ -11,7 +11,7 @@ <img src="pic/boom3.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Pogo</i>, Walt Kelly</a> <p>We have three, now looking for more.</p> <p>Last update: - <!-- #BeginDate format:En2m -->23-Sep-2015 10:20<!-- #EndDate --> + <!-- #BeginDate format:En2m -->17-Nov-2015 11:06<!-- #EndDate --> UTC</p> <br clear="left"> <h4>Related Links</h4> @@ -57,7 +57,7 @@ <dt id="interface"><tt>interface [listen | ignore | drop] [all | ipv4 | ipv6 | wildcard | <i>name</i> | <i>address</i>[/<i>prefixlen</i>]]</tt></dt> <dd>This command controls which network addresses <tt>ntpd</tt> opens, and whether input is dropped without processing. The first parameter determines the action for addresses which match the second parameter. That parameter specifies a class of addresses, or a specific interface name, or an address. In the address case, <tt><i>prefixlen</i></tt> determines how many bits must match for this rule to apply. <tt>ignore</tt> prevents opening matching addresses, <tt>drop</tt> causes <tt>ntpd</tt> to open the address and drop all received packets without examination. Multiple <tt>interface</tt> commands can be used. The last rule which matches a particular address determines the action for it. <tt>interface</tt> commands are disabled if any <a href="ntpd.html#--interface"><tt>-I</tt></a>, <a href="ntpd.html#--interface"><tt>--interface</tt></a>, <a href="ntpd.html#--novirtualips"><tt>-L</tt></a>, or <a href="ntpd.html#--novirtualips"><tt>--novirtualips</tt></a> command-line options are used. If none of those options are used and no <tt>interface</tt> actions are specified in the configuration file, all available network addresses are opened. The <tt>nic</tt> command is an alias for <tt>interface</tt>.</dd> <dt id="leapfile"><tt>leapfile <i>leapfile</i></tt></dt> - <dd>This command loads the NIST leapseconds file and initializes the leapsecond values for the next leapsecond time, expiration time and TAI offset. The file can be obtained directly from NIST national time servers using <tt>ftp</tt> as the ASCII file <tt>pub/leap-seconds</tt>.</dd> + <dd>This command loads the IERS leapseconds file and initializes the leapsecond values for the next leapsecond time, expiration time and TAI offset. The file can be obtained directly from the IERS at <a href="https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list">https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list</a> or <a href="ftp://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list">ftp://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list</a>.</dd> <dd>The <i>leapfile</i> is scanned when <tt>ntpd</tt> processes the <tt>leapfile</tt> directive or when <tt>ntpd</tt> detects that <i>leapfile</i> has changed. <tt>ntpd</tt> checks once a day to see if the <i>leapfile</i> has changed.</dd> <dd>While not strictly a security function, the Autokey protocol provides means to securely retrieve the current or updated leapsecond values from a server.</dd> <dt id="leapsmearinterval"><tt>leapsmearinterval <i>seconds</i></tt></dt> diff --git a/contrib/ntp/include/Makefile.am b/contrib/ntp/include/Makefile.am index f032c97..d8b4dd2 100644 --- a/contrib/ntp/include/Makefile.am +++ b/contrib/ntp/include/Makefile.am @@ -66,6 +66,7 @@ noinst_HEADERS = \ recvbuff.h \ refclock_atom.h \ refidsmear.h \ + safecast.h \ ssl_applink.c \ timepps-SCO.h \ timepps-Solaris.h \ diff --git a/contrib/ntp/include/Makefile.in b/contrib/ntp/include/Makefile.in index 8f0968b..6e45e93 100644 --- a/contrib/ntp/include/Makefile.in +++ b/contrib/ntp/include/Makefile.in @@ -551,6 +551,7 @@ noinst_HEADERS = \ recvbuff.h \ refclock_atom.h \ refidsmear.h \ + safecast.h \ ssl_applink.c \ timepps-SCO.h \ timepps-Solaris.h \ diff --git a/contrib/ntp/include/ntp_refclock.h b/contrib/ntp/include/ntp_refclock.h index f92d14c..b264dfa 100644 --- a/contrib/ntp/include/ntp_refclock.h +++ b/contrib/ntp/include/ntp_refclock.h @@ -220,7 +220,7 @@ extern void refclock_buginfo(sockaddr_u *, extern void refclock_control(sockaddr_u *, const struct refclockstat *, struct refclockstat *); -extern int refclock_open (char *, u_int, u_int); +extern int refclock_open (const char *, u_int, u_int); extern int refclock_setup (int, u_int, u_int); extern void refclock_timer (struct peer *); extern void refclock_transmit(struct peer *); diff --git a/contrib/ntp/include/ntp_stdlib.h b/contrib/ntp/include/ntp_stdlib.h index a2e62da..d735b41 100644 --- a/contrib/ntp/include/ntp_stdlib.h +++ b/contrib/ntp/include/ntp_stdlib.h @@ -65,8 +65,8 @@ typedef void (*ctrl_c_fn)(void); /* authkeys.c */ extern void auth_delkeys (void); extern int auth_havekey (keyid_t); -extern int authdecrypt (keyid_t, u_int32 *, int, int); -extern int authencrypt (keyid_t, u_int32 *, int); +extern int authdecrypt (keyid_t, u_int32 *, size_t, size_t); +extern size_t authencrypt (keyid_t, u_int32 *, size_t); extern int authhavekey (keyid_t); extern int authistrusted (keyid_t); extern int authreadkeys (const char *); @@ -95,8 +95,8 @@ extern void auth_prealloc_symkeys(int); extern int ymd2yd (int, int, int); /* a_md5encrypt.c */ -extern int MD5authdecrypt (int, u_char *, u_int32 *, int, int); -extern int MD5authencrypt (int, u_char *, u_int32 *, int); +extern int MD5authdecrypt (int, const u_char *, u_int32 *, size_t, size_t); +extern size_t MD5authencrypt (int, const u_char *, u_int32 *, size_t); extern void MD5auth_setkey (keyid_t, int, const u_char *, size_t); extern u_int32 addr2refid (sockaddr_u *); diff --git a/contrib/ntp/include/ntp_worker.h b/contrib/ntp/include/ntp_worker.h index f7e8d5b..50616b3 100644 --- a/contrib/ntp/include/ntp_worker.h +++ b/contrib/ntp/include/ntp_worker.h @@ -43,19 +43,22 @@ typedef struct blocking_pipe_header_tag { } blocking_pipe_header; # ifdef WORK_THREAD -# ifdef WORK_PIPE -typedef pthread_t * thr_ref; -typedef sem_t * sem_ref; +# ifdef SYS_WINNT +typedef struct { HANDLE thnd; } thread_type; +typedef struct { HANDLE shnd; } sema_type; # else -typedef HANDLE thr_ref; -typedef HANDLE sem_ref; +typedef pthread_t thread_type; +typedef sem_t sema_type; # endif +typedef thread_type *thr_ref; +typedef sema_type *sem_ref; # endif /* * */ -#ifdef WORK_FORK +#if defined(WORK_FORK) + typedef struct blocking_child_tag { int reusable; int pid; @@ -66,38 +69,59 @@ typedef struct blocking_child_tag { int resp_write_pipe; int ispipe; } blocking_child; + #elif defined(WORK_THREAD) + typedef struct blocking_child_tag { /* * blocking workitems and blocking_responses are dynamically-sized * one-dimensional arrays of pointers to blocking worker requests and * responses. + * + * IMPORTANT: This structure is shared between threads, and all access + * that is not atomic (especially queue operations) must hold the + * 'accesslock' semaphore to avoid data races. + * + * The resource management (thread/semaphore creation/destruction) + * functions and functions just testing a handle are safe because these + * are only changed by the main thread when no worker is running on the + * same data structure. */ int reusable; - thr_ref thread_ref; - u_int thread_id; - blocking_pipe_header * volatile * volatile + sem_ref accesslock; /* shared access lock */ + thr_ref thread_ref; /* thread 'handle' */ + + /* the reuest queue */ + blocking_pipe_header ** volatile workitems; volatile size_t workitems_alloc; - size_t next_workitem; /* parent */ - size_t next_workeritem; /* child */ - blocking_pipe_header * volatile * volatile + size_t head_workitem; /* parent */ + size_t tail_workitem; /* child */ + sem_ref workitems_pending; /* signalling */ + + /* the response queue */ + blocking_pipe_header ** volatile responses; volatile size_t responses_alloc; - size_t next_response; /* child */ - size_t next_workresp; /* parent */ + size_t head_response; /* child */ + size_t tail_response; /* parent */ + /* event handles / sem_t pointers */ - /* sem_ref child_is_blocking; */ - sem_ref blocking_req_ready; sem_ref wake_scheduled_sleep; + + /* some systems use a pipe for notification, others a semaphore. + * Both employ the queue above for the actual data transfer. + */ #ifdef WORK_PIPE - int resp_read_pipe; /* parent */ - int resp_write_pipe;/* child */ + int resp_read_pipe; /* parent */ + int resp_write_pipe; /* child */ int ispipe; - void * resp_read_ctx; /* child */ + void * resp_read_ctx; /* child */ #else - sem_ref blocking_response_ready; + sem_ref responses_pending; /* signalling */ #endif + sema_type sem_table[4]; + thread_type thr_table[1]; } blocking_child; #endif /* WORK_THREAD */ @@ -111,7 +135,7 @@ extern u_int available_blocking_child_slot(void); extern int queue_blocking_request(blocking_work_req, void *, size_t, blocking_work_callback, void *); -extern int queue_blocking_response(blocking_child *, +extern int queue_blocking_response(blocking_child *, blocking_pipe_header *, size_t, const blocking_pipe_header *); extern void process_blocking_resp(blocking_child *); diff --git a/contrib/ntp/include/ntpd.h b/contrib/ntp/include/ntpd.h index be3cd3e..362068c 100644 --- a/contrib/ntp/include/ntpd.h +++ b/contrib/ntp/include/ntpd.h @@ -156,7 +156,7 @@ extern u_int sys_tai; extern int freq_cnt; /* ntp_monitor.c */ -#define MON_HASH_SIZE (1U << mon_hash_bits) +#define MON_HASH_SIZE ((size_t)1U << mon_hash_bits) #define MON_HASH_MASK (MON_HASH_SIZE - 1) #define MON_HASH(addr) (sock_hash(addr) & MON_HASH_MASK) extern void init_mon (void); @@ -408,6 +408,7 @@ extern int hardpps_enable; /* kernel PPS discipline enabled */ extern int ext_enable; /* external clock enabled */ extern int cal_enable; /* refclock calibrate enable */ extern int allow_panic; /* allow panic correction (-g) */ +extern int enable_panic_check; /* Can we check allow_panic's state? */ extern int force_step_once; /* always step time once at startup (-G) */ extern int mode_ntpdate; /* exit on first clock set (-q) */ extern int peer_ntpdate; /* count of ntpdate peers */ diff --git a/contrib/ntp/include/safecast.h b/contrib/ntp/include/safecast.h new file mode 100644 index 0000000..9300463 --- /dev/null +++ b/contrib/ntp/include/safecast.h @@ -0,0 +1,34 @@ +#ifndef SAFECAST_H +#define SAFECAST_H + +#include <limits.h> +static inline int size2int_chk(size_t v) +{ + if (v > INT_MAX) + abort(); + return (int)(v); +} + +static inline int size2int_sat(size_t v) +{ + return (v > INT_MAX) ? INT_MAX : (int)v; +} + +/* Compilers can emit warning about increased alignment requirements + * when casting pointers. The impact is tricky: on machines where + * alignment is just a performance issue (x86,x64,...) this might just + * cause a performance penalty. On others, an address error can occur + * and the process dies... + * + * Still, there are many cases where the pointer arithmetic and the + * buffer alignment make sure this does not happen. OTOH, the compiler + * doesn't know this and still emits warnings. + * + * The following cast macros are going through void pointers to tell + * the compiler that there is no alignment requirement to watch. + */ +#define UA_PTR(ptype,pval) ((ptype *)(void*)(pval)) +#define UAC_PTR(ptype,pval) ((const ptype *)(const void*)(pval)) +#define UAV_PTR(ptype,pval) ((volatile ptype *)(volatile void*)(pval)) + +#endif diff --git a/contrib/ntp/lib/isc/backtrace.c b/contrib/ntp/lib/isc/backtrace.c index 4274da3..e0425e1 100644 --- a/contrib/ntp/lib/isc/backtrace.c +++ b/contrib/ntp/lib/isc/backtrace.c @@ -278,7 +278,7 @@ isc_backtrace_getsymbol(const void *addr, const char **symbolp, result = ISC_R_NOTFOUND; else { *symbolp = found->symbol; - *offsetp = (const char *)addr - (char *)found->addr; + *offsetp = (u_long)((const char *)addr - (char *)found->addr); } return (result); diff --git a/contrib/ntp/lib/isc/buffer.c b/contrib/ntp/lib/isc/buffer.c index 1b59e65..6a50985 100644 --- a/contrib/ntp/lib/isc/buffer.c +++ b/contrib/ntp/lib/isc/buffer.c @@ -406,7 +406,7 @@ isc__buffer_putmem(isc_buffer_t *b, const unsigned char *base, void isc__buffer_putstr(isc_buffer_t *b, const char *source) { - unsigned int l; + size_t l; unsigned char *cp; REQUIRE(ISC_BUFFER_VALID(b)); @@ -421,7 +421,7 @@ isc__buffer_putstr(isc_buffer_t *b, const char *source) { cp = isc_buffer_used(b); memcpy(cp, source, l); - b->used += l; + b->used += (u_int)l; /* checked above - no overflow here */ } isc_result_t diff --git a/contrib/ntp/lib/isc/inet_aton.c b/contrib/ntp/lib/isc/inet_aton.c index 14b4887..3fc3a4d 100644 --- a/contrib/ntp/lib/isc/inet_aton.c +++ b/contrib/ntp/lib/isc/inet_aton.c @@ -92,7 +92,7 @@ static char rcsid[] = "$Id: inet_aton.c,v 1.23 2008/12/01 23:47:45 tbox Exp $"; int isc_net_aton(const char *cp, struct in_addr *addr) { unsigned long val; - int base, n; + int base; unsigned char c; isc_uint8_t parts[4]; isc_uint8_t *pp = parts; @@ -166,8 +166,7 @@ isc_net_aton(const char *cp, struct in_addr *addr) { * Concoct the address according to * the number of parts specified. */ - n = pp - parts + 1; - switch (n) { + switch (pp - parts + 1) { case 1: /* a -- 32 bits */ break; diff --git a/contrib/ntp/lib/isc/inet_pton.c b/contrib/ntp/lib/isc/inet_pton.c index 66b5de0..eac631b 100644 --- a/contrib/ntp/lib/isc/inet_pton.c +++ b/contrib/ntp/lib/isc/inet_pton.c @@ -92,7 +92,7 @@ inet_pton4(const char *src, unsigned char *dst) { const char *pch; if ((pch = strchr(digits, ch)) != NULL) { - unsigned int newv = *tp * 10 + (pch - digits); + size_t newv = *tp * 10 + (pch - digits); if (saw_digit && *tp == 0) return (0); @@ -197,12 +197,12 @@ inet_pton6(const char *src, unsigned char *dst) { * Since some memmove()'s erroneously fail to handle * overlapping regions, we'll do the shift by hand. */ - const int n = tp - colonp; + const size_t n = tp - colonp; int i; if (tp == endp) return (0); - for (i = 1; i <= n; i++) { + for (i = 1; (size_t)i <= n; i++) { endp[- i] = colonp[n - i]; colonp[n - i] = 0; } diff --git a/contrib/ntp/lib/isc/log.c b/contrib/ntp/lib/isc/log.c index 38f0c4f..dfe4fdf 100644 --- a/contrib/ntp/lib/isc/log.c +++ b/contrib/ntp/lib/isc/log.c @@ -1146,7 +1146,7 @@ greatest_version(isc_logchannel_t *channel, int *greatestp) { char *basenam, *digit_end; const char *dirname; int version, greatest = -1; - unsigned int basenamelen; + size_t basenamelen; isc_dir_t dir; isc_result_t result; char sep = '/'; diff --git a/contrib/ntp/lib/isc/netaddr.c b/contrib/ntp/lib/isc/netaddr.c index 457576b..9710466 100644 --- a/contrib/ntp/lib/isc/netaddr.c +++ b/contrib/ntp/lib/isc/netaddr.c @@ -159,7 +159,7 @@ isc_netaddr_totext(const isc_netaddr_t *netaddr, isc_buffer_t *target) { if (r == NULL) return (ISC_R_FAILURE); - alen = strlen(abuf); + alen = (unsigned int)strlen(abuf); /* no overflow possible */ INSIST(alen < sizeof(abuf)); zlen = 0; diff --git a/contrib/ntp/lib/isc/sockaddr.c b/contrib/ntp/lib/isc/sockaddr.c index 1ae5e7c..c6932d4 100644 --- a/contrib/ntp/lib/isc/sockaddr.c +++ b/contrib/ntp/lib/isc/sockaddr.c @@ -134,7 +134,7 @@ isc_sockaddr_totext(const isc_sockaddr_t *sockaddr, isc_buffer_t *target) { break; #ifdef ISC_PLAFORM_HAVESYSUNH case AF_UNIX: - plen = strlen(sockaddr->type.sunix.sun_path); + plen = (unsigned int)strlen(sockaddr->type.sunix.sun_path); if (plen >= isc_buffer_availablelength(target)) return (ISC_R_NOSPACE); @@ -153,7 +153,7 @@ isc_sockaddr_totext(const isc_sockaddr_t *sockaddr, isc_buffer_t *target) { return (ISC_R_FAILURE); } - plen = strlen(pbuf); + plen = (unsigned int)strlen(pbuf); INSIST(plen < sizeof(pbuf)); isc_netaddr_fromsockaddr(&netaddr, sockaddr); diff --git a/contrib/ntp/lib/isc/task.c b/contrib/ntp/lib/isc/task.c index cd19d2d..5b899b3 100644 --- a/contrib/ntp/lib/isc/task.c +++ b/contrib/ntp/lib/isc/task.c @@ -329,7 +329,7 @@ ISC_TASKFUNC_SCOPE isc_result_t isc__task_create(isc_taskmgr_t *manager0, unsigned int quantum, isc_task_t **taskp) { - isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0; + isc__taskmgr_t *manager = (void*)manager0; isc__task_t *task; isc_boolean_t exiting; isc_result_t result; @@ -1463,7 +1463,7 @@ isc__taskmgr_destroy(isc_taskmgr_t **managerp) { */ REQUIRE(managerp != NULL); - manager = (isc__taskmgr_t *)*managerp; + manager = (void*)(*managerp); REQUIRE(VALID_MANAGER(manager)); #ifndef USE_WORKER_THREADS @@ -1559,7 +1559,7 @@ isc__taskmgr_destroy(isc_taskmgr_t **managerp) { ISC_TASKFUNC_SCOPE void isc__taskmgr_setmode(isc_taskmgr_t *manager0, isc_taskmgrmode_t mode) { - isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0; + isc__taskmgr_t *manager = (void*)manager0; LOCK(&manager->lock); manager->mode = mode; @@ -1568,7 +1568,7 @@ isc__taskmgr_setmode(isc_taskmgr_t *manager0, isc_taskmgrmode_t mode) { ISC_TASKFUNC_SCOPE isc_taskmgrmode_t isc__taskmgr_mode(isc_taskmgr_t *manager0) { - isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0; + isc__taskmgr_t *manager = (void*)manager0; isc_taskmgrmode_t mode; LOCK(&manager->lock); mode = manager->mode; @@ -1579,7 +1579,7 @@ isc__taskmgr_mode(isc_taskmgr_t *manager0) { #ifndef USE_WORKER_THREADS isc_boolean_t isc__taskmgr_ready(isc_taskmgr_t *manager0) { - isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0; + isc__taskmgr_t *manager = (void*)manager0; isc_boolean_t is_ready; #ifdef USE_SHARED_MANAGER @@ -1598,7 +1598,7 @@ isc__taskmgr_ready(isc_taskmgr_t *manager0) { isc_result_t isc__taskmgr_dispatch(isc_taskmgr_t *manager0) { - isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0; + isc__taskmgr_t *manager = (void*)manager0; #ifdef USE_SHARED_MANAGER if (manager == NULL) @@ -1615,7 +1615,7 @@ isc__taskmgr_dispatch(isc_taskmgr_t *manager0) { #else ISC_TASKFUNC_SCOPE void isc__taskmgr_pause(isc_taskmgr_t *manager0) { - isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0; + isc__taskmgr_t *manager = (void*)manager0; LOCK(&manager->lock); while (manager->tasks_running > 0) { WAIT(&manager->paused, &manager->lock); @@ -1626,7 +1626,7 @@ isc__taskmgr_pause(isc_taskmgr_t *manager0) { ISC_TASKFUNC_SCOPE void isc__taskmgr_resume(isc_taskmgr_t *manager0) { - isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0; + isc__taskmgr_t *manager = (void*)manager0; LOCK(&manager->lock); if (manager->pause_requested) { diff --git a/contrib/ntp/lib/isc/win32/interfaceiter.c b/contrib/ntp/lib/isc/win32/interfaceiter.c index 8753aa8..af52788 100644 --- a/contrib/ntp/lib/isc/win32/interfaceiter.c +++ b/contrib/ntp/lib/isc/win32/interfaceiter.c @@ -54,7 +54,7 @@ struct isc_interfaceiter { IP_ADAPTER_ADDRESSES * ipaaCur; /* enumeration position */ IP_ADAPTER_UNICAST_ADDRESS *ipuaCur; /* enumeration subposition */ /* fields used for the older address enumeration ioctls */ - int socket; + SOCKET socket; INTERFACE_INFO IFData; /* Current Interface Info */ int numIF; /* Current Interface count */ int v4IF; /* Number of IPv4 Interfaces */ diff --git a/contrib/ntp/lib/isc/win32/net.c b/contrib/ntp/lib/isc/win32/net.c index 12876da..53e1435 100644 --- a/contrib/ntp/lib/isc/win32/net.c +++ b/contrib/ntp/lib/isc/win32/net.c @@ -216,7 +216,8 @@ initialize_ipv6only(void) { static void try_ipv6pktinfo(void) { - int s, on; + SOCKET s; + int on; char strbuf[ISC_STRERRORSIZE]; isc_result_t result; int optname; diff --git a/contrib/ntp/libntp/a_md5encrypt.c b/contrib/ntp/libntp/a_md5encrypt.c index ffabc47..beaf6fd 100644 --- a/contrib/ntp/libntp/a_md5encrypt.c +++ b/contrib/ntp/libntp/a_md5encrypt.c @@ -16,12 +16,12 @@ * * Returns length of MAC including key ID and digest. */ -int +size_t MD5authencrypt( - int type, /* hash algorithm */ - u_char *key, /* key pointer */ - u_int32 *pkt, /* packet pointer */ - int length /* packet length */ + int type, /* hash algorithm */ + const u_char * key, /* key pointer */ + u_int32 * pkt, /* packet pointer */ + size_t length /* packet length */ ) { u_char digest[EVP_MAX_MD_SIZE]; @@ -44,7 +44,7 @@ MD5authencrypt( EVP_DigestInit(&ctx, EVP_get_digestbynid(type)); #endif EVP_DigestUpdate(&ctx, key, cache_secretsize); - EVP_DigestUpdate(&ctx, (u_char *)pkt, (u_int)length); + EVP_DigestUpdate(&ctx, (u_char *)pkt, length); EVP_DigestFinal(&ctx, digest, &len); memmove((u_char *)pkt + length + 4, digest, len); return (len + 4); @@ -58,11 +58,11 @@ MD5authencrypt( */ int MD5authdecrypt( - int type, /* hash algorithm */ - u_char *key, /* key pointer */ - u_int32 *pkt, /* packet pointer */ - int length, /* packet length */ - int size /* MAC size */ + int type, /* hash algorithm */ + const u_char * key, /* key pointer */ + u_int32 * pkt, /* packet pointer */ + size_t length, /* packet length */ + size_t size /* MAC size */ ) { u_char digest[EVP_MAX_MD_SIZE]; @@ -85,14 +85,14 @@ MD5authdecrypt( EVP_DigestInit(&ctx, EVP_get_digestbynid(type)); #endif EVP_DigestUpdate(&ctx, key, cache_secretsize); - EVP_DigestUpdate(&ctx, (u_char *)pkt, (u_int)length); + EVP_DigestUpdate(&ctx, (u_char *)pkt, length); EVP_DigestFinal(&ctx, digest, &len); - if ((u_int)size != len + 4) { + if (size != (size_t)len + 4) { msyslog(LOG_ERR, "MAC decrypt: MAC length error"); return (0); } - return !memcmp(digest, (char *)pkt + length + 4, len); + return !memcmp(digest, (const char *)pkt + length + 4, len); } /* diff --git a/contrib/ntp/libntp/atolfp.c b/contrib/ntp/libntp/atolfp.c index 9a2f691..439194e 100644 --- a/contrib/ntp/libntp/atolfp.c +++ b/contrib/ntp/libntp/atolfp.c @@ -68,7 +68,7 @@ atolfp( while (*cp != '\0' && (ind = strchr(digits, *cp)) != NULL) { dec_i = (dec_i << 3) + (dec_i << 1); /* multiply by 10 */ - dec_i += (ind - digits); + dec_i += (u_long)(ind - digits); cp++; } @@ -80,7 +80,7 @@ atolfp( && (ind = strchr(digits, *cp)) != NULL) { ndec++; dec_f = (dec_f << 3) + (dec_f << 1); /* *10 */ - dec_f += (ind - digits); + dec_f += (u_long)(ind - digits); cp++; } diff --git a/contrib/ntp/libntp/authkeys.c b/contrib/ntp/libntp/authkeys.c index 667ca29..f7462a2 100644 --- a/contrib/ntp/libntp/authkeys.c +++ b/contrib/ntp/libntp/authkeys.c @@ -63,7 +63,7 @@ symkey key_listhead; /* list of all in-use keys */; * keyid. We make this fairly big for potentially busy servers. */ #define DEF_AUTHHASHSIZE 64 -//#define HASHMASK ((HASHSIZE)-1) +/*#define HASHMASK ((HASHSIZE)-1)*/ #define KEYHASH(keyid) ((keyid) & authhashmask) int authhashdisabled; @@ -511,7 +511,17 @@ authistrusted( return TRUE; } - +/* Note: There are two locations below where 'strncpy()' is used. While + * this function is a hazard by itself, it's essential that it is used + * here. Bug 1243 involved that the secret was filled with NUL bytes + * after the first NUL encountered, and 'strlcpy()' simply does NOT have + * this behaviour. So disabling the fix and reverting to the buggy + * behaviour due to compatibility issues MUST also fill with NUL and + * this needs 'strncpy'. Also, the secret is managed as a byte blob of a + * given size, and eventually truncating it and replacing the last byte + * with a NUL would be a bug. + * perlinger@ntp.org 2015-10-10 + */ void MD5auth_setkey( keyid_t keyno, @@ -546,7 +556,8 @@ MD5auth_setkey( #ifndef DISABLE_BUG1243_FIX memcpy(sk->secret, key, secretsize); #else - strlcpy((char *)sk->secret, (const char *)key, + /* >MUST< use 'strncpy()' here! See above! */ + strncpy((char *)sk->secret, (const char *)key, secretsize); #endif if (cache_keyid == keyno) { @@ -565,7 +576,8 @@ MD5auth_setkey( #ifndef DISABLE_BUG1243_FIX memcpy(secret, key, secretsize); #else - strlcpy((char *)secret, (const char *)key, secretsize); + /* >MUST< use 'strncpy()' here! See above! */ + strncpy((char *)secret, (const char *)key, secretsize); #endif allocsymkey(bucket, keyno, 0, (u_short)keytype, 0, (u_short)secretsize, secret); @@ -641,13 +653,13 @@ auth_agekeys(void) * * Returns length of authenticator field, zero if key not found. */ -int +size_t authencrypt( keyid_t keyno, u_int32 * pkt, - int length + size_t length ) -{\ +{ /* * A zero key identifier means the sender has not verified * the last message was correctly authenticated. The MAC @@ -675,8 +687,8 @@ int authdecrypt( keyid_t keyno, u_int32 * pkt, - int length, - int size + size_t length, + size_t size ) { /* diff --git a/contrib/ntp/libntp/authreadkeys.c b/contrib/ntp/libntp/authreadkeys.c index 1c4c07c..95a357a 100644 --- a/contrib/ntp/libntp/authreadkeys.c +++ b/contrib/ntp/libntp/authreadkeys.c @@ -77,14 +77,23 @@ nexttok( * data on global/static level. */ -static const size_t nerr_loglimit = 5u; -static const size_t nerr_maxlimit = 15; +static const u_int nerr_loglimit = 5u; +static const u_int nerr_maxlimit = 15; -static void log_maybe(size_t*, const char*, ...) NTP_PRINTF(2, 3); +static void log_maybe(u_int*, const char*, ...) NTP_PRINTF(2, 3); + +typedef struct keydata KeyDataT; +struct keydata { + KeyDataT *next; /* queue/stack link */ + keyid_t keyid; /* stored key ID */ + u_short keytype; /* stored key type */ + u_short seclen; /* length of secret */ + u_char secbuf[1]; /* begin of secret (formal only)*/ +}; static void log_maybe( - size_t *pnerr, + u_int *pnerr, const char *fmt , ...) { @@ -113,25 +122,24 @@ authreadkeys( u_char keystr[32]; /* Bug 2537 */ size_t len; size_t j; - size_t nerr; + u_int nerr; + KeyDataT *list = NULL; + KeyDataT *next = NULL; /* * Open file. Complain and return if it can't be opened. */ fp = fopen(file, "r"); if (fp == NULL) { - msyslog(LOG_ERR, "authreadkeys: file %s: %m", + msyslog(LOG_ERR, "authreadkeys: file '%s': %m", file); - return (0); + goto onerror; } INIT_SSL(); /* - * Remove all existing keys - */ - auth_delkeys(); - - /* - * Now read lines from the file, looking for key entries + * Now read lines from the file, looking for key entries. Put + * the data into temporary store for later propagation to avoid + * two-pass processing. */ nerr = 0; while ((line = fgets(buf, sizeof buf, fp)) != NULL) { @@ -216,11 +224,16 @@ authreadkeys( "authreadkeys: no key for key %d", keyno); continue; } + next = NULL; len = strlen(token); if (len <= 20) { /* Bug 2537 */ - MD5auth_setkey(keyno, keytype, (u_char *)token, len); + next = emalloc(sizeof(KeyDataT) + len); + next->keyid = keyno; + next->keytype = keytype; + next->seclen = len; + memcpy(next->secbuf, token, len); } else { - char hex[] = "0123456789abcdef"; + static const char hex[] = "0123456789abcdef"; u_char temp; char *ptr; size_t jlim; @@ -242,19 +255,51 @@ authreadkeys( keyno); continue; } - MD5auth_setkey(keyno, keytype, keystr, jlim / 2); + len = jlim/2; /* hmmmm.... what about odd length?!? */ + next = emalloc(sizeof(KeyDataT) + len); + next->keyid = keyno; + next->keytype = keytype; + next->seclen = len; + memcpy(next->secbuf, keystr, len); } + INSIST(NULL != next); + next->next = list; + list = next; } fclose(fp); if (nerr > nerr_maxlimit) { msyslog(LOG_ERR, - "authreadkeys: emergency break after %u errors", - nerr); - return (0); - } else if (nerr > nerr_loglimit) { + "authreadkeys: rejecting file '%s' after %u errors (emergency break)", + file, nerr); + goto onerror; + } + if (nerr > 0) { msyslog(LOG_ERR, - "authreadkeys: found %u more error(s)", - nerr - nerr_loglimit); + "authreadkeys: rejecting file '%s' after %u error(s)", + file, nerr); + goto onerror; + } + + /* first remove old file-based keys */ + auth_delkeys(); + /* insert the new key material */ + while (NULL != (next = list)) { + list = next->next; + MD5auth_setkey(next->keyid, next->keytype, + next->secbuf, next->seclen); + /* purge secrets from memory before free()ing it */ + memset(next, 0, sizeof(*next) + next->seclen); + free(next); } return (1); + + onerror: + /* Mop up temporary storage before bailing out. */ + while (NULL != (next = list)) { + list = next->next; + /* purge secrets from memory before free()ing it */ + memset(next, 0, sizeof(*next) + next->seclen); + free(next); + } + return (0); } diff --git a/contrib/ntp/libntp/authusekey.c b/contrib/ntp/libntp/authusekey.c index c1d0813..0ccf522 100644 --- a/contrib/ntp/libntp/authusekey.c +++ b/contrib/ntp/libntp/authusekey.c @@ -23,7 +23,7 @@ authusekey( const u_char *str ) { - int len; + size_t len; len = strlen((const char *)str); if (0 == len) diff --git a/contrib/ntp/libntp/dolfptoa.c b/contrib/ntp/libntp/dolfptoa.c index 07ead95..68f56e1 100644 --- a/contrib/ntp/libntp/dolfptoa.c +++ b/contrib/ntp/libntp/dolfptoa.c @@ -40,7 +40,7 @@ dolfptoa( * including a possible rounding from the fractional part. */ cp = cpend = cpdec = &cbuf[10]; - for (dec = cp - cbuf; dec > 0 && fpi != 0; dec--) { + for (dec = (int)(cp - cbuf); dec > 0 && fpi != 0; dec--) { /* can add another digit */ u_int32 digit; @@ -62,7 +62,7 @@ dolfptoa( cpdec += 3; } if ((size_t)dec > sizeof(cbuf) - (cpend - cbuf)) - dec = sizeof(cbuf) - (cpend - cbuf); + dec = (int)(sizeof(cbuf) - (cpend - cbuf)); /* * If there's a fraction to deal with, do so. @@ -95,7 +95,7 @@ dolfptoa( u_char *tp = cpend; int carry = ((fpv & 0x80000000) != 0); - for (dec = tp - cbuf; carry && dec > 0; dec--) { + for (dec = (int)(tp - cbuf); carry && dec > 0; dec--) { *--tp += 1; if (*tp == 10) *tp = 0; diff --git a/contrib/ntp/libntp/hextolfp.c b/contrib/ntp/libntp/hextolfp.c index 2bff929..19a93cd 100644 --- a/contrib/ntp/libntp/hextolfp.c +++ b/contrib/ntp/libntp/hextolfp.c @@ -37,8 +37,9 @@ hextolfp( while (*cp != '\0' && (cp - cpstart) < 8 && (ind = strchr(digits, *cp)) != NULL) { dec_i = dec_i << 4; /* multiply by 16 */ - dec_i += ((ind - digits) > 15) ? (ind - digits) - 6 - : (ind - digits); + dec_i += ((ind - digits) > 15) + ? (u_long)(ind - digits - 6) + : (u_long)(ind - digits); cp++; } @@ -51,8 +52,9 @@ hextolfp( while (*cp != '\0' && (cp - cpstart) < 8 && (ind = strchr(digits, *cp)) != NULL) { dec_f = dec_f << 4; /* multiply by 16 */ - dec_f += ((ind - digits) > 15) ? (ind - digits) - 6 - : (ind - digits); + dec_f += ((ind - digits) > 15) + ? (u_long)(ind - digits - 6) + : (u_long)(ind - digits); cp++; } diff --git a/contrib/ntp/libntp/mstolfp.c b/contrib/ntp/libntp/mstolfp.c index 828b14c..7da20dc 100644 --- a/contrib/ntp/libntp/mstolfp.c +++ b/contrib/ntp/libntp/mstolfp.c @@ -70,8 +70,7 @@ mstolfp( */ *bp++ = '.'; if ((cpdec - cp) < 3) { - register int i = 3 - (cpdec - cp); - + size_t i = 3 - (cpdec - cp); do { *bp++ = '0'; } while (--i > 0); diff --git a/contrib/ntp/libntp/msyslog.c b/contrib/ntp/libntp/msyslog.c index cc8868f..9682d30 100644 --- a/contrib/ntp/libntp/msyslog.c +++ b/contrib/ntp/libntp/msyslog.c @@ -331,7 +331,7 @@ msnprintf( ) { va_list ap; - size_t rc; + int rc; va_start(ap, fmt); rc = mvsnprintf(buf, bufsiz, fmt, ap); diff --git a/contrib/ntp/libntp/ntp_crypto_rnd.c b/contrib/ntp/libntp/ntp_crypto_rnd.c index 96348f2..2a4f91a 100644 --- a/contrib/ntp/libntp/ntp_crypto_rnd.c +++ b/contrib/ntp/libntp/ntp_crypto_rnd.c @@ -16,6 +16,7 @@ #include <l_stdlib.h> #include <ntp_random.h> +#include "safecast.h" #ifdef USE_OPENSSL_CRYPTO_RAND #include <openssl/err.h> @@ -93,7 +94,7 @@ ntp_crypto_random_buf( #ifdef USE_OPENSSL_CRYPTO_RAND int rc; - rc = RAND_bytes(buf, nbytes); + rc = RAND_bytes(buf, size2int_chk(nbytes)); if (1 != rc) { unsigned long err; char *err_str; diff --git a/contrib/ntp/libntp/ntp_lineedit.c b/contrib/ntp/libntp/ntp_lineedit.c index a2b2d29..ebd456a 100644 --- a/contrib/ntp/libntp/ntp_lineedit.c +++ b/contrib/ntp/libntp/ntp_lineedit.c @@ -29,6 +29,7 @@ #include "ntp.h" #include "ntp_stdlib.h" #include "ntp_lineedit.h" +#include "safecast.h" #define MAXEDITLINE 512 @@ -213,7 +214,7 @@ ntp_readline( line = fgets(line_buf, sizeof(line_buf), stdin); if (NULL != line && *line) { - *pcount = strlen(line); + *pcount = (int)strlen(line); /* cannot overflow here */ line = estrdup(line); } else line = NULL; diff --git a/contrib/ntp/libntp/ntp_rfc2553.c b/contrib/ntp/libntp/ntp_rfc2553.c index a9ebb4b..8409629 100644 --- a/contrib/ntp/libntp/ntp_rfc2553.c +++ b/contrib/ntp/libntp/ntp_rfc2553.c @@ -203,11 +203,12 @@ copy_addrinfo_common( else ai_nxt = ai_src->ai_next; *ai_cpy = *ai_src; - REQUIRE(ai_src->ai_addrlen <= sizeof(sockaddr_u)); + DEBUG_INSIST(ai_cpy->ai_canonname == ai_src->ai_canonname); + INSIST(ai_src->ai_addrlen <= sizeof(sockaddr_u)); memcpy(psau, ai_src->ai_addr, ai_src->ai_addrlen); ai_cpy->ai_addr = &psau->sa; ++psau; - if (NULL != ai_cpy->ai_canonname) { + if (NULL != ai_src->ai_canonname) { ai_cpy->ai_canonname = pcanon; str_octets = 1 + strlen(ai_src->ai_canonname); memcpy(pcanon, ai_src->ai_canonname, str_octets); @@ -480,15 +481,16 @@ do_nodename( * set elsewhere so that we can set the appropriate wildcard */ if (nodename == NULL) { - ai->ai_addrlen = sizeof(struct sockaddr_storage); if (ai->ai_family == AF_INET) { + ai->ai_addrlen = sizeof(struct sockaddr_in); sockin = (struct sockaddr_in *)ai->ai_addr; sockin->sin_family = (short) ai->ai_family; sockin->sin_addr.s_addr = htonl(INADDR_ANY); } else { + ai->ai_addrlen = sizeof(struct sockaddr_in6); sockin6 = (struct sockaddr_in6 *)ai->ai_addr; sockin6->sin6_family = (short) ai->ai_family; /* diff --git a/contrib/ntp/libntp/ntp_worker.c b/contrib/ntp/libntp/ntp_worker.c index 32970da..f5642e1 100644 --- a/contrib/ntp/libntp/ntp_worker.c +++ b/contrib/ntp/libntp/ntp_worker.c @@ -150,7 +150,8 @@ available_blocking_child_slot(void) prev_octets); blocking_children_alloc = new_alloc; - return prev_alloc; + /* assume we'll never have enough workers to overflow u_int */ + return (u_int)prev_alloc; } diff --git a/contrib/ntp/libntp/snprintf.c b/contrib/ntp/libntp/snprintf.c index 2b6a374..f4685e1 100644 --- a/contrib/ntp/libntp/snprintf.c +++ b/contrib/ntp/libntp/snprintf.c @@ -889,19 +889,19 @@ rpl_vsnprintf(char *str, size_t size, const char *format, va_list args) switch (cflags) { case PRINT_C_CHAR: charptr = va_arg(args, signed char *); - *charptr = len; + *charptr = (signed char)len; break; case PRINT_C_SHORT: shortptr = va_arg(args, short int *); - *shortptr = len; + *shortptr = (short int)len; break; case PRINT_C_LONG: longptr = va_arg(args, long int *); - *longptr = len; + *longptr = (long int)len; break; case PRINT_C_LLONG: llongptr = va_arg(args, LLONG *); - *llongptr = len; + *llongptr = (LLONG)len; break; case PRINT_C_SIZE: /* @@ -912,19 +912,19 @@ rpl_vsnprintf(char *str, size_t size, const char *format, va_list args) * size_t argument." (7.19.6.1, 7) */ sizeptr = va_arg(args, SSIZE_T *); - *sizeptr = len; + *sizeptr = (SSIZE_T)len; break; case PRINT_C_INTMAX: intmaxptr = va_arg(args, INTMAX_T *); - *intmaxptr = len; + *intmaxptr = (INTMAX_T)len; break; case PRINT_C_PTRDIFF: ptrdiffptr = va_arg(args, PTRDIFF_T *); - *ptrdiffptr = len; + *ptrdiffptr = (PTRDIFF_T)len; break; default: intptr = va_arg(args, int *); - *intptr = len; + *intptr = (int)len; break; } break; @@ -1209,7 +1209,7 @@ again: * Factor of ten with the number of digits needed for the fractional * part. For example, if the precision is 3, the mask will be 1000. */ - mask = mypow10(precision); + mask = (UINTMAX_T)mypow10(precision); /* * We "cheat" by converting the fractional part to integer by * multiplying by a factor of ten. @@ -1461,7 +1461,7 @@ cast(LDOUBLE value) if (value >= UINTMAX_MAX) return UINTMAX_MAX; - result = value; + result = (UINTMAX_T)value; /* * At least on NetBSD/sparc64 3.0.2 and 4.99.30, casting long double to * an integer type converts e.g. 1.9 to 2 instead of 1 (which violates diff --git a/contrib/ntp/libntp/socktohost.c b/contrib/ntp/libntp/socktohost.c index 3d9ab960..fdf9adb 100644 --- a/contrib/ntp/libntp/socktohost.c +++ b/contrib/ntp/libntp/socktohost.c @@ -36,13 +36,18 @@ socktohost( sockaddr_u addr; size_t octets; int a_info; + int saved_errno; + + saved_errno = socket_errno(); /* reverse the address to purported DNS name */ LIB_GETBUF(pbuf); gni_flags = NI_DGRAM | NI_NAMEREQD; if (getnameinfo(&sock->sa, SOCKLEN(sock), pbuf, LIB_BUFLENGTH, - NULL, 0, gni_flags)) + NULL, 0, gni_flags)) { + errno = saved_errno; return stoa(sock); /* use address */ + } TRACE(1, ("%s reversed to %s\n", stoa(sock), pbuf)); @@ -97,8 +102,10 @@ socktohost( } freeaddrinfo(alist); - if (ai != NULL) + if (ai != NULL) { + errno = saved_errno; return pbuf; /* forward check passed */ + } forward_fail: TRACE(1, ("%s forward check lookup fail: %s\n", pbuf, @@ -106,5 +113,6 @@ socktohost( LIB_GETBUF(pliar); snprintf(pliar, LIB_BUFLENGTH, "%s (%s)", stoa(sock), pbuf); + errno = saved_errno; return pliar; } diff --git a/contrib/ntp/libntp/systime.c b/contrib/ntp/libntp/systime.c index f5eabcd..c89d157 100644 --- a/contrib/ntp/libntp/systime.c +++ b/contrib/ntp/libntp/systime.c @@ -25,6 +25,8 @@ # include <utmpx.h> #endif /* HAVE_UTMPX_H */ +int allow_panic = FALSE; /* allow panic correction (-g) */ +int enable_panic_check = TRUE; /* Can we check allow_panic's state? */ #ifndef USE_COMPILETIME_PIVOT # define USE_COMPILETIME_PIVOT 1 @@ -295,8 +297,13 @@ adj_systime( * EVNT_NSET adjtime() can be aborted by a tiny adjtime() * triggered by sys_residual. */ - if (0. == now) + if (0. == now) { + if (enable_panic_check && allow_panic) { + msyslog(LOG_ERR, "adj_systime: allow_panic is TRUE!"); + INSIST(!allow_panic); + } return TRUE; + } /* * Most Unix adjtime() implementations adjust the system clock @@ -333,9 +340,15 @@ adj_systime( if (adjtv.tv_sec != 0 || adjtv.tv_usec != 0) { if (adjtime(&adjtv, &oadjtv) < 0) { msyslog(LOG_ERR, "adj_systime: %m"); + if (enable_panic_check && allow_panic) { + msyslog(LOG_ERR, "adj_systime: allow_panic is TRUE!"); + } return FALSE; } } + if (enable_panic_check && allow_panic) { + msyslog(LOG_ERR, "adj_systime: allow_panic is TRUE!"); + } return TRUE; } #endif @@ -419,6 +432,9 @@ step_systime( /* now set new system time */ if (ntp_set_tod(&timetv, NULL) != 0) { msyslog(LOG_ERR, "step-systime: %m"); + if (enable_panic_check && allow_panic) { + msyslog(LOG_ERR, "step_systime: allow_panic is TRUE!"); + } return FALSE; } @@ -445,7 +461,7 @@ step_systime( * long ut_time; * }; * and appends line="|", name="date", host="", time for the OLD - * and appends line="{", name="date", host="", time for the NEW + * and appends line="{", name="date", host="", time for the NEW // } * to _PATH_WTMP . * * Some OSes have utmp, some have utmpx. @@ -564,6 +580,10 @@ step_systime( #endif /* UPDATE_WTMPX */ } + if (enable_panic_check && allow_panic) { + msyslog(LOG_ERR, "step_systime: allow_panic is TRUE!"); + INSIST(!allow_panic); + } return TRUE; } diff --git a/contrib/ntp/libntp/work_thread.c b/contrib/ntp/libntp/work_thread.c index 38d8747..49e90c1 100644 --- a/contrib/ntp/libntp/work_thread.c +++ b/contrib/ntp/libntp/work_thread.c @@ -32,16 +32,20 @@ #define THREAD_MINSTACKSIZE (64U * 1024) #endif -#ifndef DEVOLATILE -#define DEVOLATILE(type, var) ((type)(uintptr_t)(volatile void *)(var)) -#endif - #ifdef SYS_WINNT + # define thread_exit(c) _endthreadex(c) -# define tickle_sem SetEvent +# define tickle_sem(sh) ReleaseSemaphore((sh->shnd), 1, NULL) +u_int WINAPI blocking_thread(void *); +static BOOL same_os_sema(const sem_ref obj, void * osobj); + #else + # define thread_exit(c) pthread_exit((void*)(size_t)(c)) # define tickle_sem sem_post +void * blocking_thread(void *); +static void block_thread_signals(sigset_t *); + #endif #ifdef WORK_PIPE @@ -54,18 +58,10 @@ static void start_blocking_thread(blocking_child *); static void start_blocking_thread_internal(blocking_child *); static void prepare_child_sems(blocking_child *); static int wait_for_sem(sem_ref, struct timespec *); -static void ensure_workitems_empty_slot(blocking_child *); -static void ensure_workresp_empty_slot(blocking_child *); +static int ensure_workitems_empty_slot(blocking_child *); +static int ensure_workresp_empty_slot(blocking_child *); static int queue_req_pointer(blocking_child *, blocking_pipe_header *); static void cleanup_after_child(blocking_child *); -#ifdef SYS_WINNT -u_int WINAPI blocking_thread(void *); -#else -void * blocking_thread(void *); -#endif -#ifndef SYS_WINNT -static void block_thread_signals(sigset_t *); -#endif void @@ -76,7 +72,9 @@ exit_worker( thread_exit(exitcode); /* see #define thread_exit */ } - +/* -------------------------------------------------------------------- + * sleep for a given time or until the wakup semaphore is tickled. + */ int worker_sleep( blocking_child * c, @@ -98,9 +96,7 @@ worker_sleep( } # endif until.tv_sec += seconds; - do { - rc = wait_for_sem(c->wake_scheduled_sleep, &until); - } while (-1 == rc && EINTR == errno); + rc = wait_for_sem(c->wake_scheduled_sleep, &until); if (0 == rc) return -1; if (-1 == rc && ETIMEDOUT == errno) @@ -110,6 +106,9 @@ worker_sleep( } +/* -------------------------------------------------------------------- + * Wake up a worker that takes a nap. + */ void interrupt_worker_sleep(void) { @@ -124,65 +123,79 @@ interrupt_worker_sleep(void) } } - -static void +/* -------------------------------------------------------------------- + * Make sure there is an empty slot at the head of the request + * queue. Tell if the queue is currently empty. + */ +static int ensure_workitems_empty_slot( blocking_child *c ) { - const size_t each = sizeof(blocking_children[0]->workitems[0]); - size_t new_alloc; - size_t old_octets; - size_t new_octets; - void * nonvol_workitems; - - - if (c->workitems != NULL && - NULL == c->workitems[c->next_workitem]) - return; - - new_alloc = c->workitems_alloc + WORKITEMS_ALLOC_INC; - old_octets = c->workitems_alloc * each; - new_octets = new_alloc * each; - nonvol_workitems = DEVOLATILE(void *, c->workitems); - c->workitems = erealloc_zero(nonvol_workitems, new_octets, - old_octets); - if (0 == c->next_workitem) - c->next_workitem = c->workitems_alloc; - c->workitems_alloc = new_alloc; + /* + ** !!! PRECONDITION: caller holds access lock! + ** + ** This simply tries to increase the size of the buffer if it + ** becomes full. The resize operation does *not* maintain the + ** order of requests, but that should be irrelevant since the + ** processing is considered asynchronous anyway. + ** + ** Return if the buffer is currently empty. + */ + + static const size_t each = + sizeof(blocking_children[0]->workitems[0]); + + size_t new_alloc; + size_t slots_used; + + slots_used = c->head_workitem - c->tail_workitem; + if (slots_used >= c->workitems_alloc) { + new_alloc = c->workitems_alloc + WORKITEMS_ALLOC_INC; + c->workitems = erealloc(c->workitems, new_alloc * each); + c->tail_workitem = 0; + c->head_workitem = c->workitems_alloc; + c->workitems_alloc = new_alloc; + } + return (0 == slots_used); } - -static void +/* -------------------------------------------------------------------- + * Make sure there is an empty slot at the head of the response + * queue. Tell if the queue is currently empty. + */ +static int ensure_workresp_empty_slot( blocking_child *c ) { - const size_t each = sizeof(blocking_children[0]->responses[0]); - size_t new_alloc; - size_t old_octets; - size_t new_octets; - void * nonvol_responses; - - if (c->responses != NULL && - NULL == c->responses[c->next_response]) - return; - - new_alloc = c->responses_alloc + RESPONSES_ALLOC_INC; - old_octets = c->responses_alloc * each; - new_octets = new_alloc * each; - nonvol_responses = DEVOLATILE(void *, c->responses); - c->responses = erealloc_zero(nonvol_responses, new_octets, - old_octets); - if (0 == c->next_response) - c->next_response = c->responses_alloc; - c->responses_alloc = new_alloc; + /* + ** !!! PRECONDITION: caller holds access lock! + ** + ** Works like the companion function above. + */ + + static const size_t each = + sizeof(blocking_children[0]->responses[0]); + + size_t new_alloc; + size_t slots_used; + + slots_used = c->head_response - c->tail_response; + if (slots_used >= c->responses_alloc) { + new_alloc = c->responses_alloc + RESPONSES_ALLOC_INC; + c->responses = erealloc(c->responses, new_alloc * each); + c->tail_response = 0; + c->head_response = c->responses_alloc; + c->responses_alloc = new_alloc; + } + return (0 == slots_used); } -/* +/* -------------------------------------------------------------------- * queue_req_pointer() - append a work item or idle exit request to - * blocking_workitems[]. + * blocking_workitems[]. Employ proper locking. */ static int queue_req_pointer( @@ -190,21 +203,28 @@ queue_req_pointer( blocking_pipe_header * hdr ) { - c->workitems[c->next_workitem] = hdr; - c->next_workitem = (1 + c->next_workitem) % c->workitems_alloc; + size_t qhead; + + /* >>>> ACCESS LOCKING STARTS >>>> */ + wait_for_sem(c->accesslock, NULL); + ensure_workitems_empty_slot(c); + qhead = c->head_workitem; + c->workitems[qhead % c->workitems_alloc] = hdr; + c->head_workitem = 1 + qhead; + tickle_sem(c->accesslock); + /* <<<< ACCESS LOCKING ENDS <<<< */ - /* - * We only want to signal the wakeup event if the child is - * blocking on it, which is indicated by setting the blocking - * event. Wait with zero timeout to test. - */ - /* !!!! if (WAIT_OBJECT_0 == WaitForSingleObject(c->child_is_blocking, 0)) */ - tickle_sem(c->blocking_req_ready); + /* queue consumer wake-up notification */ + tickle_sem(c->workitems_pending); return 0; } - +/* -------------------------------------------------------------------- + * API function to make sure a worker is running, a proper private copy + * of the data is made, the data eneterd into the queue and the worker + * is signalled. + */ int send_blocking_req_internal( blocking_child * c, @@ -223,12 +243,8 @@ send_blocking_req_internal( return 1; /* failure */ payload_octets = hdr->octets - sizeof(*hdr); - ensure_workitems_empty_slot(c); - if (NULL == c->thread_ref) { - ensure_workresp_empty_slot(c); + if (NULL == c->thread_ref) start_blocking_thread(c); - } - threadcopy = emalloc(hdr->octets); memcpy(threadcopy, hdr, sizeof(*hdr)); memcpy((char *)threadcopy + sizeof(*hdr), data, payload_octets); @@ -236,43 +252,41 @@ send_blocking_req_internal( return queue_req_pointer(c, threadcopy); } - +/* -------------------------------------------------------------------- + * Wait for the 'incoming queue no longer empty' signal, lock the shared + * structure and dequeue an item. + */ blocking_pipe_header * receive_blocking_req_internal( blocking_child * c ) { blocking_pipe_header * req; - int rc; + size_t qhead, qtail; - /* - * Child blocks here when idle. SysV semaphores maintain a - * count and release from sem_wait() only when it reaches 0. - * Windows auto-reset events are simpler, and multiple SetEvent - * calls before any thread waits result in a single wakeup. - * On Windows, the child drains all workitems each wakeup, while - * with SysV semaphores wait_sem() is used before each item. - */ -#ifdef SYS_WINNT - while (NULL == c->workitems[c->next_workeritem]) { - /* !!!! SetEvent(c->child_is_blocking); */ - rc = wait_for_sem(c->blocking_req_ready, NULL); - INSIST(0 == rc); - /* !!!! ResetEvent(c->child_is_blocking); */ - } -#else + req = NULL; do { - rc = wait_for_sem(c->blocking_req_ready, NULL); - } while (-1 == rc && EINTR == errno); - INSIST(0 == rc); -#endif + /* wait for tickle from the producer side */ + wait_for_sem(c->workitems_pending, NULL); + + /* >>>> ACCESS LOCKING STARTS >>>> */ + wait_for_sem(c->accesslock, NULL); + qhead = c->head_workitem; + do { + qtail = c->tail_workitem; + if (qhead == qtail) + break; + c->tail_workitem = qtail + 1; + qtail %= c->workitems_alloc; + req = c->workitems[qtail]; + c->workitems[qtail] = NULL; + } while (NULL == req); + tickle_sem(c->accesslock); + /* <<<< ACCESS LOCKING ENDS <<<< */ + + } while (NULL == req); - req = c->workitems[c->next_workeritem]; INSIST(NULL != req); - c->workitems[c->next_workeritem] = NULL; - c->next_workeritem = (1 + c->next_workeritem) % - c->workitems_alloc; - if (CHILD_EXIT_REQ == req) { /* idled out */ send_blocking_resp_internal(c, CHILD_GONE_RESP); req = NULL; @@ -281,44 +295,74 @@ receive_blocking_req_internal( return req; } - +/* -------------------------------------------------------------------- + * Push a response into the return queue and eventually tickle the + * receiver. + */ int send_blocking_resp_internal( blocking_child * c, blocking_pipe_header * resp ) { - ensure_workresp_empty_slot(c); - - c->responses[c->next_response] = resp; - c->next_response = (1 + c->next_response) % c->responses_alloc; - -#ifdef WORK_PIPE - write(c->resp_write_pipe, "", 1); -#else - tickle_sem(c->blocking_response_ready); -#endif - + size_t qhead; + int empty; + + /* >>>> ACCESS LOCKING STARTS >>>> */ + wait_for_sem(c->accesslock, NULL); + empty = ensure_workresp_empty_slot(c); + qhead = c->head_response; + c->responses[qhead % c->responses_alloc] = resp; + c->head_response = 1 + qhead; + tickle_sem(c->accesslock); + /* <<<< ACCESS LOCKING ENDS <<<< */ + + /* queue consumer wake-up notification */ + if (empty) + { +# ifdef WORK_PIPE + write(c->resp_write_pipe, "", 1); +# else + tickle_sem(c->responses_pending); +# endif + } return 0; } #ifndef WORK_PIPE + +/* -------------------------------------------------------------------- + * Check if a (Windows-)hanndle to a semaphore is actually the same we + * are using inside the sema wrapper. + */ +static BOOL +same_os_sema( + const sem_ref obj, + void* osh + ) +{ + return obj && osh && (obj->shnd == (HANDLE)osh); +} + +/* -------------------------------------------------------------------- + * Find the shared context that associates to an OS handle and make sure + * the data is dequeued and processed. + */ void handle_blocking_resp_sem( void * context ) { - HANDLE ready; blocking_child * c; u_int idx; - ready = (HANDLE)context; c = NULL; for (idx = 0; idx < blocking_children_alloc; idx++) { c = blocking_children[idx]; - if (c != NULL && c->thread_ref != NULL && - ready == c->blocking_response_ready) + if (c != NULL && + c->thread_ref != NULL && + same_os_sema(c->responses_pending, context)) break; } if (idx < blocking_children_alloc) @@ -326,26 +370,41 @@ handle_blocking_resp_sem( } #endif /* !WORK_PIPE */ - +/* -------------------------------------------------------------------- + * Fetch the next response from the return queue. In case of signalling + * via pipe, make sure the pipe is flushed, too. + */ blocking_pipe_header * receive_blocking_resp_internal( blocking_child * c ) { blocking_pipe_header * removed; + size_t qhead, qtail, slot; + #ifdef WORK_PIPE int rc; char scratch[32]; - do { + do rc = read(c->resp_read_pipe, scratch, sizeof(scratch)); - } while (-1 == rc && EINTR == errno); + while (-1 == rc && EINTR == errno); #endif - removed = c->responses[c->next_workresp]; + + /* >>>> ACCESS LOCKING STARTS >>>> */ + wait_for_sem(c->accesslock, NULL); + qhead = c->head_response; + qtail = c->tail_response; + for (removed = NULL; !removed && (qhead != qtail); ++qtail) { + slot = qtail % c->responses_alloc; + removed = c->responses[slot]; + c->responses[slot] = NULL; + } + c->tail_response = qtail; + tickle_sem(c->accesslock); + /* <<<< ACCESS LOCKING ENDS <<<< */ + if (NULL != removed) { - c->responses[c->next_workresp] = NULL; - c->next_workresp = (1 + c->next_workresp) % - c->responses_alloc; DEBUG_ENSURE(CHILD_GONE_RESP == removed || BLOCKING_RESP_MAGIC == removed->magic_sig); } @@ -357,7 +416,9 @@ receive_blocking_resp_internal( return removed; } - +/* -------------------------------------------------------------------- + * Light up a new worker. + */ static void start_blocking_thread( blocking_child * c @@ -370,40 +431,45 @@ start_blocking_thread( start_blocking_thread_internal(c); } - +/* -------------------------------------------------------------------- + * Create a worker thread. There are several differences between POSIX + * and Windows, of course -- most notably the Windows thread is no + * detached thread, and we keep the handle around until we want to get + * rid of the thread. The notification scheme also differs: Windows + * makes use of semaphores in both directions, POSIX uses a pipe for + * integration with 'select()' or alike. + */ static void start_blocking_thread_internal( blocking_child * c ) #ifdef SYS_WINNT { - thr_ref blocking_child_thread; - u_int blocking_thread_id; BOOL resumed; - (*addremove_io_semaphore)(c->blocking_response_ready, FALSE); - blocking_child_thread = + c->thread_ref = NULL; + (*addremove_io_semaphore)(c->responses_pending->shnd, FALSE); + c->thr_table[0].thnd = (HANDLE)_beginthreadex( NULL, 0, &blocking_thread, c, CREATE_SUSPENDED, - &blocking_thread_id); + NULL); - if (NULL == blocking_child_thread) { + if (NULL == c->thr_table[0].thnd) { msyslog(LOG_ERR, "start blocking thread failed: %m"); exit(-1); } - c->thread_id = blocking_thread_id; - c->thread_ref = blocking_child_thread; /* remember the thread priority is only within the process class */ - if (!SetThreadPriority(blocking_child_thread, + if (!SetThreadPriority(c->thr_table[0].thnd, THREAD_PRIORITY_BELOW_NORMAL)) msyslog(LOG_ERR, "Error lowering blocking thread priority: %m"); - resumed = ResumeThread(blocking_child_thread); + resumed = ResumeThread(c->thr_table[0].thnd); DEBUG_INSIST(resumed); + c->thread_ref = &c->thr_table[0]; } #else /* pthreads start_blocking_thread_internal() follows */ { @@ -419,6 +485,8 @@ start_blocking_thread_internal( size_t stacksize; sigset_t saved_sig_mask; + c->thread_ref = NULL; + # ifdef NEED_PTHREAD_INIT /* * from lib/isc/unix/app.c: @@ -475,7 +543,7 @@ start_blocking_thread_internal( #endif c->thread_ref = emalloc_zero(sizeof(*c->thread_ref)); block_thread_signals(&saved_sig_mask); - rc = pthread_create(c->thread_ref, &thr_attr, + rc = pthread_create(&c->thr_table[0], &thr_attr, &blocking_thread, c); saved_errno = errno; pthread_sigmask(SIG_SETMASK, &saved_sig_mask, NULL); @@ -485,11 +553,11 @@ start_blocking_thread_internal( msyslog(LOG_ERR, "pthread_create() blocking child: %m"); exit(1); } + c->thread_ref = &c->thr_table[0]; } #endif - -/* +/* -------------------------------------------------------------------- * block_thread_signals() * * Temporarily block signals used by ntpd main thread, so that signal @@ -538,61 +606,101 @@ block_thread_signals( #endif /* !SYS_WINNT */ -/* +/* -------------------------------------------------------------------- + * Create & destroy semaphores. This is sufficiently different between + * POSIX and Windows to warrant wrapper functions and close enough to + * use the concept of synchronization via semaphore for all platforms. + */ +static sem_ref +create_sema( + sema_type* semptr, + u_int inival, + u_int maxval) +{ +#ifdef SYS_WINNT + + long svini, svmax; + if (NULL != semptr) { + svini = (inival < LONG_MAX) + ? (long)inival : LONG_MAX; + svmax = (maxval < LONG_MAX && maxval > 0) + ? (long)maxval : LONG_MAX; + semptr->shnd = CreateSemaphore(NULL, svini, svmax, NULL); + if (NULL == semptr->shnd) + semptr = NULL; + } + +#else + + (void)maxval; + if (semptr && sem_init(semptr, FALSE, inival)) + semptr = NULL; + +#endif + + return semptr; +} + +/* ------------------------------------------------------------------ */ +static sem_ref +delete_sema( + sem_ref obj) +{ + +# ifdef SYS_WINNT + + if (obj) { + if (obj->shnd) + CloseHandle(obj->shnd); + obj->shnd = NULL; + } + +# else + + if (obj) + sem_destroy(obj); + +# endif + + return NULL; +} + +/* -------------------------------------------------------------------- * prepare_child_sems() * - * create sync events (semaphores) - * child_is_blocking initially unset - * blocking_req_ready initially unset + * create sync & access semaphores * - * Child waits for blocking_req_ready to be set after - * setting child_is_blocking. blocking_req_ready and - * blocking_response_ready are auto-reset, so wake one - * waiter and become unset (unsignalled) in one operation. + * All semaphores are cleared, only the access semaphore has 1 unit. + * Childs wait on 'workitems_pending', then grabs 'sema_access' + * and dequeues jobs. When done, 'sema_access' is given one unit back. + * + * The producer grabs 'sema_access', manages the queue, restores + * 'sema_access' and puts one unit into 'workitems_pending'. + * + * The story goes the same for the response queue. */ static void prepare_child_sems( blocking_child *c ) -#ifdef SYS_WINNT -{ - if (NULL == c->blocking_req_ready) { - /* manual reset using ResetEvent() */ - /* !!!! c->child_is_blocking = CreateEvent(NULL, TRUE, FALSE, NULL); */ - /* auto reset - one thread released from wait each set */ - c->blocking_req_ready = CreateEvent(NULL, FALSE, FALSE, NULL); - c->blocking_response_ready = CreateEvent(NULL, FALSE, FALSE, NULL); - c->wake_scheduled_sleep = CreateEvent(NULL, FALSE, FALSE, NULL); - } else { - /* !!!! ResetEvent(c->child_is_blocking); */ - /* ResetEvent(c->blocking_req_ready); */ - /* ResetEvent(c->blocking_response_ready); */ - /* ResetEvent(c->wake_scheduled_sleep); */ - } -} -#else /* pthreads prepare_child_sems() follows */ { - size_t octets; - - if (NULL == c->blocking_req_ready) { - octets = sizeof(*c->blocking_req_ready); - octets += sizeof(*c->wake_scheduled_sleep); - /* !!!! octets += sizeof(*c->child_is_blocking); */ - c->blocking_req_ready = emalloc_zero(octets);; - c->wake_scheduled_sleep = 1 + c->blocking_req_ready; - /* !!!! c->child_is_blocking = 1 + c->wake_scheduled_sleep; */ - } else { - sem_destroy(c->blocking_req_ready); - sem_destroy(c->wake_scheduled_sleep); - /* !!!! sem_destroy(c->child_is_blocking); */ - } - sem_init(c->blocking_req_ready, FALSE, 0); - sem_init(c->wake_scheduled_sleep, FALSE, 0); - /* !!!! sem_init(c->child_is_blocking, FALSE, 0); */ + c->accesslock = create_sema(&c->sem_table[0], 1, 1); + c->workitems_pending = create_sema(&c->sem_table[1], 0, 0); + c->wake_scheduled_sleep = create_sema(&c->sem_table[2], 0, 1); +# ifndef WORK_PIPE + c->responses_pending = create_sema(&c->sem_table[3], 0, 0); +# endif } -#endif - +/* -------------------------------------------------------------------- + * wait for semaphore. Where the wait can be interrupted, it will + * internally resume -- When this function returns, there is either no + * semaphore at all, a timeout occurred, or the caller could + * successfully take a token from the semaphore. + * + * For untimed wait, not checking the result of this function at all is + * definitely an option. + */ static int wait_for_sem( sem_ref sem, @@ -605,6 +713,11 @@ wait_for_sem( DWORD msec; DWORD rc; + if (!(sem && sem->shnd)) { + errno = EINVAL; + return -1; + } + if (NULL == timeout) { msec = INFINITE; } else { @@ -619,7 +732,7 @@ wait_for_sem( msec += delta.tv_nsec / (1000 * 1000); } } - rc = WaitForSingleObject(sem, msec); + rc = WaitForSingleObject(sem->shnd, msec); if (WAIT_OBJECT_0 == rc) return 0; if (WAIT_TIMEOUT == rc) { @@ -632,24 +745,28 @@ wait_for_sem( } #else /* pthreads wait_for_sem() follows */ { - int rc; - - if (NULL == timeout) - rc = sem_wait(sem); + int rc = -1; + + if (sem) do { + if (NULL == timeout) + rc = sem_wait(sem); + else + rc = sem_timedwait(sem, timeout); + } while (rc == -1 && errno == EINTR); else - rc = sem_timedwait(sem, timeout); - + errno = EINVAL; + return rc; } #endif - -/* - * blocking_thread - thread functions have WINAPI calling convention +/* -------------------------------------------------------------------- + * blocking_thread - thread functions have WINAPI (aka 'stdcall') + * calling conventions under Windows and POSIX-defined signature + * otherwise. */ #ifdef SYS_WINNT -u_int -WINAPI +u_int WINAPI #else void * #endif @@ -666,20 +783,28 @@ blocking_thread( return 0; } - -/* +/* -------------------------------------------------------------------- * req_child_exit() runs in the parent. + * + * This function is called from from the idle timer, too, and possibly + * without a thread being there any longer. Since we have folded up our + * tent in that case and all the semaphores are already gone, we simply + * ignore this request in this case. + * + * Since the existence of the semaphores is controlled exclusively by + * the parent, there's no risk of data race here. */ int req_child_exit( blocking_child *c ) { - return queue_req_pointer(c, CHILD_EXIT_REQ); + return (c->accesslock) + ? queue_req_pointer(c, CHILD_EXIT_REQ) + : 0; } - -/* +/* -------------------------------------------------------------------- * cleanup_after_child() runs in parent. */ static void @@ -687,17 +812,27 @@ cleanup_after_child( blocking_child * c ) { - u_int idx; - DEBUG_INSIST(!c->reusable); -#ifdef SYS_WINNT - INSIST(CloseHandle(c->thread_ref)); -#else - free(c->thread_ref); -#endif + +# ifdef SYS_WINNT + /* The thread was not created in detached state, so we better + * clean up. + */ + if (c->thread_ref && c->thread_ref->thnd) { + WaitForSingleObject(c->thread_ref->thnd, INFINITE); + INSIST(CloseHandle(c->thread_ref->thnd)); + c->thread_ref->thnd = NULL; + } +# endif c->thread_ref = NULL; - c->thread_id = 0; -#ifdef WORK_PIPE + + /* remove semaphores and (if signalling vi IO) pipes */ + + c->accesslock = delete_sema(c->accesslock); + c->workitems_pending = delete_sema(c->workitems_pending); + c->wake_scheduled_sleep = delete_sema(c->wake_scheduled_sleep); + +# ifdef WORK_PIPE DEBUG_INSIST(-1 != c->resp_read_pipe); DEBUG_INSIST(-1 != c->resp_write_pipe); (*addremove_io_fd)(c->resp_read_pipe, c->ispipe, TRUE); @@ -705,18 +840,22 @@ cleanup_after_child( close(c->resp_read_pipe); c->resp_write_pipe = -1; c->resp_read_pipe = -1; -#else - DEBUG_INSIST(NULL != c->blocking_response_ready); - (*addremove_io_semaphore)(c->blocking_response_ready, TRUE); -#endif - for (idx = 0; idx < c->workitems_alloc; idx++) - c->workitems[idx] = NULL; - c->next_workitem = 0; - c->next_workeritem = 0; - for (idx = 0; idx < c->responses_alloc; idx++) - c->responses[idx] = NULL; - c->next_response = 0; - c->next_workresp = 0; +# else + DEBUG_INSIST(NULL != c->responses_pending); + (*addremove_io_semaphore)(c->responses_pending->shnd, TRUE); + c->responses_pending = delete_sema(c->responses_pending); +# endif + + /* Is it necessary to check if there are pending requests and + * responses? If so, and if there are, what to do with them? + */ + + /* re-init buffer index sequencers */ + c->head_workitem = 0; + c->tail_workitem = 0; + c->head_response = 0; + c->tail_response = 0; + c->reusable = TRUE; } diff --git a/contrib/ntp/libparse/clk_computime.c b/contrib/ntp/libparse/clk_computime.c index 5026232..7273ac7 100644 --- a/contrib/ntp/libparse/clk_computime.c +++ b/contrib/ntp/libparse/clk_computime.c @@ -157,7 +157,7 @@ inp_computime( { unsigned int rtc; - parseprintf(DD_PARSE, ("inp_computime(0x%lx, 0x%x, ...)\n", (long)parseio, ch)); + parseprintf(DD_PARSE, ("inp_computime(0x%p, 0x%x, ...)\n", (void*)parseio, ch)); switch (ch) { diff --git a/contrib/ntp/libparse/clk_dcf7000.c b/contrib/ntp/libparse/clk_dcf7000.c index f1da9ef..0621cd5 100644 --- a/contrib/ntp/libparse/clk_dcf7000.c +++ b/contrib/ntp/libparse/clk_dcf7000.c @@ -158,7 +158,7 @@ inp_dcf7000( { unsigned int rtc; - parseprintf(DD_PARSE, ("inp_dcf7000(0x%lx, 0x%x, ...)\n", (long)parseio, ch)); + parseprintf(DD_PARSE, ("inp_dcf7000(0x%p, 0x%x, ...)\n", (void*)parseio, ch)); switch (ch) { diff --git a/contrib/ntp/libparse/clk_hopf6021.c b/contrib/ntp/libparse/clk_hopf6021.c index 357ac2e..2359628 100644 --- a/contrib/ntp/libparse/clk_hopf6021.c +++ b/contrib/ntp/libparse/clk_hopf6021.c @@ -227,7 +227,7 @@ inp_hopf6021( { unsigned int rtc; - parseprintf(DD_PARSE, ("inp_hopf6021(0x%lx, 0x%x, ...)\n", (long)parseio, ch)); + parseprintf(DD_PARSE, ("inp_hopf6021(0x%p, 0x%x, ...)\n", (void*)parseio, ch)); switch (ch) { diff --git a/contrib/ntp/libparse/clk_meinberg.c b/contrib/ntp/libparse/clk_meinberg.c index 9d2b676..e4ebf0a 100644 --- a/contrib/ntp/libparse/clk_meinberg.c +++ b/contrib/ntp/libparse/clk_meinberg.c @@ -434,7 +434,7 @@ mbg_input( { unsigned int rtc; - parseprintf(DD_PARSE, ("mbg_input(0x%lx, 0x%x, ...)\n", (long)parseio, ch)); + parseprintf(DD_PARSE, ("mbg_input(0x%p, 0x%x, ...)\n", (void*)parseio, ch)); switch (ch) { @@ -602,7 +602,7 @@ gps_input( msg_buf = (struct msg_buf *)parseio->parse_pdata; - parseprintf(DD_PARSE, ("gps_input(0x%lx, 0x%x, ...)\n", (long)parseio, ch)); + parseprintf(DD_PARSE, ("gps_input(0x%p, 0x%x, ...)\n", (void*)parseio, ch)); if (!msg_buf) return PARSE_INP_SKIP; diff --git a/contrib/ntp/libparse/clk_rawdcf.c b/contrib/ntp/libparse/clk_rawdcf.c index ca43263..e22ebb0 100644 --- a/contrib/ntp/libparse/clk_rawdcf.c +++ b/contrib/ntp/libparse/clk_rawdcf.c @@ -627,7 +627,7 @@ inp_rawdcf( { static struct timeval timeout = { 1, 500000 }; /* 1.5 secongs denote second #60 */ - parseprintf(DD_PARSE, ("inp_rawdcf(0x%lx, 0x%x, ...)\n", (long)parseio, ch)); + parseprintf(DD_PARSE, ("inp_rawdcf(0x%p, 0x%x, ...)\n", (void*)parseio, ch)); parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */ diff --git a/contrib/ntp/libparse/clk_rcc8000.c b/contrib/ntp/libparse/clk_rcc8000.c index a690e588..11d52ac 100644 --- a/contrib/ntp/libparse/clk_rcc8000.c +++ b/contrib/ntp/libparse/clk_rcc8000.c @@ -141,7 +141,7 @@ inp_rcc8000( { unsigned int rtc; - parseprintf(DD_PARSE, ("inp_rcc8000(0x%lx, 0x%x, ...)\n", (long)parseio, ch)); + parseprintf(DD_PARSE, ("inp_rcc8000(0x%p, 0x%x, ...)\n", (void*)parseio, ch)); switch (ch) { diff --git a/contrib/ntp/libparse/clk_schmid.c b/contrib/ntp/libparse/clk_schmid.c index c4f02b0..d85b1a5 100644 --- a/contrib/ntp/libparse/clk_schmid.c +++ b/contrib/ntp/libparse/clk_schmid.c @@ -205,7 +205,7 @@ inp_schmid( { unsigned int rtc; - parseprintf(DD_PARSE, ("inp_schmid(0x%lx, 0x%x, ...)\n", (long)parseio, ch)); + parseprintf(DD_PARSE, ("inp_schmid(0x%p, 0x%x, ...)\n", (void*)parseio, ch)); switch ((uint8_t)ch) { diff --git a/contrib/ntp/libparse/clk_trimtaip.c b/contrib/ntp/libparse/clk_trimtaip.c index 426e897..a60d01e 100644 --- a/contrib/ntp/libparse/clk_trimtaip.c +++ b/contrib/ntp/libparse/clk_trimtaip.c @@ -155,7 +155,7 @@ inp_trimtaip( { unsigned int rtc; - parseprintf(DD_PARSE, ("inp_trimtaip(0x%lx, 0x%x, ...)\n", (long)parseio, ch)); + parseprintf(DD_PARSE, ("inp_trimtaip(0x%p, 0x%x, ...)\n", (void*)parseio, ch)); switch (ch) { diff --git a/contrib/ntp/libparse/clk_varitext.c b/contrib/ntp/libparse/clk_varitext.c index 022549e..0d83035 100644 --- a/contrib/ntp/libparse/clk_varitext.c +++ b/contrib/ntp/libparse/clk_varitext.c @@ -58,12 +58,12 @@ extern int printf (const char *, ...); #endif -static const u_char VT_INITIALISED = 0x01; -static const u_char VT_SYNCHRONISED = 0x02; -static const u_char VT_ALARM_STATE = 0x04; +/* static const u_char VT_INITIALISED = 0x01; */ +/* static const u_char VT_SYNCHRONISED = 0x02; */ +/* static const u_char VT_ALARM_STATE = 0x04; */ static const u_char VT_BST = 0x08; -static const u_char VT_SEASON_CHANGE = 0x10; -static const u_char VT_LAST_TELEGRAM_OK = 0x20; +/* static const u_char VT_SEASON_CHANGE = 0x10; */ +/* static const u_char VT_LAST_TELEGRAM_OK = 0x20; */ /* * The Varitext receiver sends a datagram in the following format every minute @@ -195,7 +195,7 @@ inp_varitext( struct varitext *t = (struct varitext *)parseio->parse_pdata; int rtc; - parseprintf(DD_PARSE, ("inp_varitext(0x%lx, 0x%x, ...)\n", (long)parseio, ch)); + parseprintf(DD_PARSE, ("inp_varitext(0x%p, 0x%x, ...)\n", (void*)parseio, ch)); if (!t) return PARSE_INP_SKIP; /* local data not allocated - sigh! */ diff --git a/contrib/ntp/libparse/clk_wharton.c b/contrib/ntp/libparse/clk_wharton.c index a65bc53..e9e3d84 100644 --- a/contrib/ntp/libparse/clk_wharton.c +++ b/contrib/ntp/libparse/clk_wharton.c @@ -137,7 +137,7 @@ inp_wharton_400a( { unsigned int rtc; - parseprintf(DD_PARSE, ("inp_wharton_400a(0x%lx, 0x%x, ...)\n", (long)parseio, ch)); + parseprintf(DD_PARSE, ("inp_wharton_400a(0x%p, 0x%x, ...)\n", (void*)parseio, ch)); switch (ch) { diff --git a/contrib/ntp/libparse/parse.c b/contrib/ntp/libparse/parse.c index 64167f1..69395ac 100644 --- a/contrib/ntp/libparse/parse.c +++ b/contrib/ntp/libparse/parse.c @@ -288,7 +288,7 @@ parse_ioread( break; } - parseprintf(DD_PARSE, ("parse_ioread(0x%lx, char=0x%x, ..., ...)\n", (unsigned long)parseio, ch & 0xFF)); + parseprintf(DD_PARSE, ("parse_ioread(0x%p, char=0x%x, ..., ...)\n", (void*)parseio, ch & 0xFF)); if (!clockformats[parseio->parse_lformat]->convert) { diff --git a/contrib/ntp/ntpd/invoke-ntp.conf.texi b/contrib/ntp/ntpd/invoke-ntp.conf.texi index 37427d6..32b41e6 100644 --- a/contrib/ntp/ntpd/invoke-ntp.conf.texi +++ b/contrib/ntp/ntpd/invoke-ntp.conf.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntp.conf.texi) # -# It has been AutoGen-ed October 21, 2015 at 12:38:16 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:30:49 PM by AutoGen 5.18.5 # From the definitions ntp.conf.def # and the template file agtexi-file.tpl @end ignore diff --git a/contrib/ntp/ntpd/invoke-ntp.keys.texi b/contrib/ntp/ntpd/invoke-ntp.keys.texi index 33fdb89..b755d97 100644 --- a/contrib/ntp/ntpd/invoke-ntp.keys.texi +++ b/contrib/ntp/ntpd/invoke-ntp.keys.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntp.keys.texi) # -# It has been AutoGen-ed October 21, 2015 at 12:38:19 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:30:52 PM by AutoGen 5.18.5 # From the definitions ntp.keys.def # and the template file agtexi-file.tpl @end ignore diff --git a/contrib/ntp/ntpd/invoke-ntpd.texi b/contrib/ntp/ntpd/invoke-ntpd.texi index a781b26..66ce19d 100644 --- a/contrib/ntp/ntpd/invoke-ntpd.texi +++ b/contrib/ntp/ntpd/invoke-ntpd.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntpd.texi) # -# It has been AutoGen-ed October 21, 2015 at 12:38:21 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:30:54 PM by AutoGen 5.18.5 # From the definitions ntpd-opts.def # and the template file agtexi-cmd.tpl @end ignore @@ -142,7 +142,7 @@ with a status code of 0. @exampleindent 0 @example -ntpd - NTP daemon program - Ver. 4.2.8p4 +ntpd - NTP daemon program - Ver. 4.2.8p5 Usage: ntpd [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... \ [ <server1> ... <serverN> ] Flg Arg Option-Name Description diff --git a/contrib/ntp/ntpd/ntp.conf.5man b/contrib/ntp/ntpd/ntp.conf.5man index ee457df4..6e6aa32 100644 --- a/contrib/ntp/ntpd/ntp.conf.5man +++ b/contrib/ntp/ntpd/ntp.conf.5man @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntp.conf 5man "21 Oct 2015" "4.2.8p4" "File Formats" +.TH ntp.conf 5man "07 Jan 2016" "4.2.8p5" "File Formats" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-9oaqYI/ag-OpaiXI) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-8qayqp/ag-Vraqpp) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:01 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:30:35 PM by AutoGen 5.18.5 .\" From the definitions ntp.conf.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/ntpd/ntp.conf.5mdoc b/contrib/ntp/ntpd/ntp.conf.5mdoc index a883aab..800e995 100644 --- a/contrib/ntp/ntpd/ntp.conf.5mdoc +++ b/contrib/ntp/ntpd/ntp.conf.5mdoc @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTP_CONF 5mdoc File Formats .Os .\" EDIT THIS FILE WITH CAUTION (ntp.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:24 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:30:57 PM by AutoGen 5.18.5 .\" From the definitions ntp.conf.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/ntpd/ntp.conf.html b/contrib/ntp/ntpd/ntp.conf.html index 1f0c819..d10a88d 100644 --- a/contrib/ntp/ntpd/ntp.conf.html +++ b/contrib/ntp/ntpd/ntp.conf.html @@ -33,7 +33,7 @@ Up: <a rel="up" accesskey="u" href="#dir">(dir)</a> <p>This document describes the configuration file for the NTP Project's <code>ntpd</code> program. - <p>This document applies to version 4.2.8p4 of <code>ntp.conf</code>. + <p>This document applies to version 4.2.8p5 of <code>ntp.conf</code>. <div class="shortcontents"> <h2>Short Contents</h2> diff --git a/contrib/ntp/ntpd/ntp.conf.man.in b/contrib/ntp/ntpd/ntp.conf.man.in index 7c8a39f..f701b41 100644 --- a/contrib/ntp/ntpd/ntp.conf.man.in +++ b/contrib/ntp/ntpd/ntp.conf.man.in @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntp.conf 5 "21 Oct 2015" "4.2.8p4" "File Formats" +.TH ntp.conf 5 "07 Jan 2016" "4.2.8p5" "File Formats" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-9oaqYI/ag-OpaiXI) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-8qayqp/ag-Vraqpp) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:01 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:30:35 PM by AutoGen 5.18.5 .\" From the definitions ntp.conf.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/ntpd/ntp.conf.mdoc.in b/contrib/ntp/ntpd/ntp.conf.mdoc.in index 613ee7a..7ad4cc1 100644 --- a/contrib/ntp/ntpd/ntp.conf.mdoc.in +++ b/contrib/ntp/ntpd/ntp.conf.mdoc.in @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTP_CONF 5 File Formats .Os .\" EDIT THIS FILE WITH CAUTION (ntp.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:24 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:30:57 PM by AutoGen 5.18.5 .\" From the definitions ntp.conf.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/ntpd/ntp.keys.5man b/contrib/ntp/ntpd/ntp.keys.5man index 3e5cb54..bb0028b 100644 --- a/contrib/ntp/ntpd/ntp.keys.5man +++ b/contrib/ntp/ntpd/ntp.keys.5man @@ -1,8 +1,8 @@ -.TH ntp.keys 5man "21 Oct 2015" "4.2.8p4" "File Formats" +.TH ntp.keys 5man "07 Jan 2016" "4.2.8p5" "File Formats" .\" .\" EDIT THIS FILE WITH CAUTION (ntp.man) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:08 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:30:41 PM by AutoGen 5.18.5 .\" From the definitions ntp.keys.def .\" and the template file agman-file.tpl .Sh NAME diff --git a/contrib/ntp/ntpd/ntp.keys.5mdoc b/contrib/ntp/ntpd/ntp.keys.5mdoc index 6355a39..9524989 100644 --- a/contrib/ntp/ntpd/ntp.keys.5mdoc +++ b/contrib/ntp/ntpd/ntp.keys.5mdoc @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTP_KEYS 5mdoc File Formats .Os SunOS 5.10 .\" EDIT THIS FILE WITH CAUTION (ntp.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:28 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:31:00 PM by AutoGen 5.18.5 .\" From the definitions ntp.keys.def .\" and the template file agmdoc-file.tpl .Sh NAME diff --git a/contrib/ntp/ntpd/ntp.keys.html b/contrib/ntp/ntpd/ntp.keys.html index 3671aaa..738f9e0 100644 --- a/contrib/ntp/ntpd/ntp.keys.html +++ b/contrib/ntp/ntpd/ntp.keys.html @@ -33,7 +33,7 @@ Up: <a rel="up" accesskey="u" href="#dir">(dir)</a> <p>This document describes the symmetric key file for the NTP Project's <code>ntpd</code> program. - <p>This document applies to version 4.2.8p4 of <code>ntp.keys</code>. + <p>This document applies to version 4.2.8p5 of <code>ntp.keys</code>. <div class="shortcontents"> <h2>Short Contents</h2> diff --git a/contrib/ntp/ntpd/ntp.keys.man.in b/contrib/ntp/ntpd/ntp.keys.man.in index bd64756..78d5f09 100644 --- a/contrib/ntp/ntpd/ntp.keys.man.in +++ b/contrib/ntp/ntpd/ntp.keys.man.in @@ -1,8 +1,8 @@ -.TH ntp.keys 5 "21 Oct 2015" "4.2.8p4" "File Formats" +.TH ntp.keys 5 "07 Jan 2016" "4.2.8p5" "File Formats" .\" .\" EDIT THIS FILE WITH CAUTION (ntp.man) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:08 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:30:41 PM by AutoGen 5.18.5 .\" From the definitions ntp.keys.def .\" and the template file agman-file.tpl .Sh NAME diff --git a/contrib/ntp/ntpd/ntp.keys.mdoc.in b/contrib/ntp/ntpd/ntp.keys.mdoc.in index 6600d57..40c821e 100644 --- a/contrib/ntp/ntpd/ntp.keys.mdoc.in +++ b/contrib/ntp/ntpd/ntp.keys.mdoc.in @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTP_KEYS 5 File Formats .Os SunOS 5.10 .\" EDIT THIS FILE WITH CAUTION (ntp.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:28 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:31:00 PM by AutoGen 5.18.5 .\" From the definitions ntp.keys.def .\" and the template file agmdoc-file.tpl .Sh NAME diff --git a/contrib/ntp/ntpd/ntp_control.c b/contrib/ntp/ntpd/ntp_control.c index 7736311..2e174d0 100644 --- a/contrib/ntp/ntpd/ntp_control.c +++ b/contrib/ntp/ntpd/ntp_control.c @@ -846,7 +846,7 @@ ctl_error( u_char errcode ) { - int maclen; + size_t maclen; numctlerrors++; DPRINTF(3, ("sending control error %u\n", errcode)); @@ -1248,10 +1248,10 @@ ctl_flushpkt( ) { size_t i; - int dlen; - int sendlen; - int maclen; - int totlen; + size_t dlen; + size_t sendlen; + size_t maclen; + size_t totlen; keyid_t keyid; dlen = datapt - rpkt.u.data; diff --git a/contrib/ntp/ntpd/ntp_crypto.c b/contrib/ntp/ntpd/ntp_crypto.c index 376b5b5..8574266 100644 --- a/contrib/ntp/ntpd/ntp_crypto.c +++ b/contrib/ntp/ntpd/ntp_crypto.c @@ -473,9 +473,9 @@ crypto_recv( } /* Check if the declared size fits into the remaining - * buffer. + * buffer. We *know* 'macbytes' > 0 here! */ - if (len > macbytes) { + if (len > (u_int)macbytes) { DPRINTF(1, ("crypto_recv: possible attack detected, associd %d\n", associd)); return XEVNT_LEN; diff --git a/contrib/ntp/ntpd/ntp_io.c b/contrib/ntp/ntpd/ntp_io.c index 5fc6ed5..dd23459 100644 --- a/contrib/ntp/ntpd/ntp_io.c +++ b/contrib/ntp/ntpd/ntp_io.c @@ -41,6 +41,7 @@ #include "timevalops.h" #include "timespecops.h" #include "ntpd-opts.h" +#include "safecast.h" /* Don't include ISC's version of IPv6 variables and structures */ #define ISC_IPV6_H 1 @@ -772,7 +773,7 @@ is_ip_address( hints.ai_flags |= AI_NUMERICHOST; if (getaddrinfo(tmpbuf, NULL, &hints, &result) == 0) { AF(addr) = AF_INET6; - resaddr6 = (struct sockaddr_in6 *)result->ai_addr; + resaddr6 = UA_PTR(struct sockaddr_in6, result->ai_addr); SET_ADDR6N(addr, resaddr6->sin6_addr); SET_SCOPE(addr, resaddr6->sin6_scope_id); @@ -3365,7 +3366,7 @@ fetch_timestamp( #endif /* HAVE_BINTIME */ #ifdef HAVE_TIMESTAMPNS case SCM_TIMESTAMPNS: - tsp = (struct timespec *)CMSG_DATA(cmsghdr); + tsp = UA_PTR(struct timespec, CMSG_DATA(cmsghdr)); if (sys_tick > measured_tick && sys_tick > 1e-9) { ticks = (unsigned long)((tsp->tv_nsec * 1e-9) / @@ -3666,8 +3667,7 @@ input_handler( fds = activefds; tvzero.tv_sec = tvzero.tv_usec = 0; - n = select(maxactivefd + 1, &fds, (fd_set *)0, (fd_set *)0, - &tvzero); + n = select(maxactivefd + 1, &fds, NULL, NULL, &tvzero); /* * If there are no packets waiting just return @@ -4447,7 +4447,7 @@ close_and_delete_fd_from_list( break; case FD_TYPE_FILE: - closeserial(lsock->fd); + closeserial((int)lsock->fd); break; default: @@ -4643,7 +4643,7 @@ process_routing_msgs(struct asyncio_reader *reader) * process routing message */ #ifdef HAVE_RTNETLINK - for (nh = (struct nlmsghdr *)buffer; + for (nh = UA_PTR(struct nlmsghdr, buffer); NLMSG_OK(nh, cnt); nh = NLMSG_NEXT(nh, cnt)) { msg_type = nh->nlmsg_type; diff --git a/contrib/ntp/ntpd/ntp_loopfilter.c b/contrib/ntp/ntpd/ntp_loopfilter.c index 42c30de..4b38aa8 100644 --- a/contrib/ntp/ntpd/ntp_loopfilter.c +++ b/contrib/ntp/ntpd/ntp_loopfilter.c @@ -154,7 +154,6 @@ int hardpps_enable; /* kernel PPS discipline enabled */ int ext_enable; /* external clock enabled */ int pps_stratum; /* pps stratum */ int kernel_status; /* from ntp_adjtime */ -int allow_panic = FALSE; /* allow panic correction (-g) */ int force_step_once = FALSE; /* always step time once at startup (-G) */ int mode_ntpdate = FALSE; /* exit on first clock set (-q) */ int freq_cnt; /* initial frequency clamp */ @@ -459,16 +458,16 @@ local_clock( double dtemp, etemp; /* double temps */ char tbuf[80]; /* report buffer */ + (void)ntp_adj_ret; /* not always used below... */ /* * If the loop is opened or the NIST LOCKCLOCK is in use, * monitor and record the offsets anyway in order to determine * the open-loop response and then go home. */ -#ifdef LOCKCLOCK +#ifndef LOCKCLOCK + if (!ntp_enable) +#endif /* not LOCKCLOCK */ { -#else - if (!ntp_enable) { -#endif /* LOCKCLOCK */ record_loop_stats(fp_offset, drift_comp, clock_jitter, clock_stability, sys_poll); return (0); @@ -493,6 +492,8 @@ local_clock( return (-1); } + allow_panic = FALSE; + /* * This section simulates ntpdate. If the offset exceeds the * step threshold (128 ms), step the clock to that time and @@ -538,12 +539,8 @@ local_clock( else dtemp = (peer->delay - sys_mindly) / 2; fp_offset += dtemp; -#ifdef DEBUG - if (debug) - printf( - "local_clock: size %d mindly %.6f huffpuff %.6f\n", - sys_hufflen, sys_mindly, dtemp); -#endif + DPRINTF(1, ("local_clock: size %d mindly %.6f huffpuff %.6f\n", + sys_hufflen, sys_mindly, dtemp)); } /* @@ -694,7 +691,6 @@ local_clock( * startup until the initial transient has subsided. */ default: - allow_panic = FALSE; if (freq_cnt == 0) { /* @@ -921,15 +917,11 @@ local_clock( */ record_loop_stats(clock_offset, drift_comp, clock_jitter, clock_stability, sys_poll); -#ifdef DEBUG - if (debug) - printf( - "local_clock: offset %.9f jit %.9f freq %.3f stab %.3f poll %d\n", + DPRINTF(1, ("local_clock: offset %.9f jit %.9f freq %.3f stab %.3f poll %d\n", clock_offset, clock_jitter, drift_comp * 1e6, - clock_stability * 1e6, sys_poll); -#endif /* DEBUG */ + clock_stability * 1e6, sys_poll)); return (rval); -#endif /* LOCKCLOCK */ +#endif /* not LOCKCLOCK */ } @@ -1005,7 +997,10 @@ adj_host_clock( * but does not automatically stop slewing when an offset * has decayed to zero. */ + DEBUG_INSIST(enable_panic_check == TRUE); + enable_panic_check = FALSE; adj_systime(offset_adj + freq_adj); + enable_panic_check = TRUE; #endif /* LOCKCLOCK */ } @@ -1019,12 +1014,9 @@ rstclock( double offset /* new offset */ ) { -#ifdef DEBUG - if (debug > 1) - printf("local_clock: mu %lu state %d poll %d count %d\n", + DPRINTF(2, ("rstclock: mu %lu state %d poll %d count %d\n", current_time - clock_epoch, trans, sys_poll, - tc_counter); -#endif + tc_counter)); if (trans != state && trans != EVNT_FSET) report_event(trans, NULL, NULL); state = trans; @@ -1075,6 +1067,7 @@ set_freq( const char * loop_desc; int ntp_adj_ret; + (void)ntp_adj_ret; /* not always used below... */ drift_comp = freq; loop_desc = "ntpd"; #ifdef KERNEL_PLL @@ -1236,10 +1229,7 @@ loop_config( int i; double ftemp; -#ifdef DEBUG - if (debug > 1) - printf("loop_config: item %d freq %f\n", item, freq); -#endif + DPRINTF(2, ("loop_config: item %d freq %f\n", item, freq)); switch (item) { /* diff --git a/contrib/ntp/ntpd/ntp_parser.c b/contrib/ntp/ntpd/ntp_parser.c index 6235033..cc17950 100644 --- a/contrib/ntp/ntpd/ntp_parser.c +++ b/contrib/ntp/ntpd/ntp_parser.c @@ -889,21 +889,21 @@ static const yytype_uint16 yyrline[] = 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 886, 891, 899, 904, 905, 906, 910, 915, 923, 928, 929, 930, 931, 932, 933, 934, 935, 943, 953, - 958, 966, 968, 970, 972, 974, 979, 980, 984, 985, - 986, 987, 995, 1000, 1005, 1013, 1018, 1019, 1020, 1029, - 1031, 1036, 1041, 1049, 1051, 1068, 1069, 1070, 1071, 1072, - 1073, 1077, 1078, 1086, 1091, 1096, 1104, 1109, 1110, 1111, - 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1127, 1128, 1129, - 1136, 1143, 1150, 1166, 1185, 1187, 1189, 1191, 1193, 1195, - 1202, 1207, 1208, 1209, 1213, 1217, 1226, 1227, 1231, 1232, - 1233, 1237, 1248, 1262, 1274, 1279, 1281, 1286, 1287, 1295, - 1297, 1305, 1310, 1318, 1343, 1350, 1360, 1361, 1365, 1366, - 1367, 1368, 1372, 1373, 1374, 1378, 1383, 1388, 1396, 1397, - 1398, 1399, 1400, 1401, 1402, 1412, 1417, 1425, 1430, 1438, - 1440, 1444, 1449, 1454, 1462, 1467, 1475, 1484, 1485, 1489, - 1490, 1499, 1517, 1521, 1526, 1534, 1539, 1540, 1544, 1549, - 1557, 1562, 1567, 1572, 1577, 1585, 1590, 1595, 1603, 1608, - 1609, 1610, 1611, 1612 + 958, 966, 968, 970, 979, 981, 986, 987, 991, 992, + 993, 994, 1002, 1007, 1012, 1020, 1025, 1026, 1027, 1036, + 1038, 1043, 1048, 1056, 1058, 1075, 1076, 1077, 1078, 1079, + 1080, 1084, 1085, 1093, 1098, 1103, 1111, 1116, 1117, 1118, + 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1134, 1135, 1136, + 1143, 1150, 1157, 1173, 1192, 1194, 1196, 1198, 1200, 1202, + 1209, 1214, 1215, 1216, 1220, 1224, 1233, 1234, 1238, 1239, + 1240, 1244, 1255, 1269, 1281, 1286, 1288, 1293, 1294, 1302, + 1304, 1312, 1317, 1325, 1350, 1357, 1367, 1368, 1372, 1373, + 1374, 1375, 1379, 1380, 1381, 1385, 1390, 1395, 1403, 1404, + 1405, 1406, 1407, 1408, 1409, 1419, 1424, 1432, 1437, 1445, + 1447, 1451, 1456, 1461, 1469, 1474, 1482, 1491, 1492, 1496, + 1497, 1506, 1524, 1528, 1533, 1541, 1546, 1547, 1551, 1556, + 1564, 1569, 1574, 1579, 1584, 1592, 1597, 1602, 1610, 1615, + 1616, 1617, 1618, 1619 }; #endif @@ -2684,90 +2684,97 @@ yyreduce: case 173: #line 971 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); } -#line 2689 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ + { + if ((yyvsp[0].Integer) >= 0 && (yyvsp[0].Integer) <= 16) { + (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); + } else { + (yyval.Attr_val) = NULL; + yyerror("fudge factor: stratum value not in [0..16], ignored"); + } + } +#line 2696 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 174: -#line 973 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 980 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); } -#line 2695 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2702 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 175: -#line 975 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 982 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); } -#line 2701 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2708 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 182: -#line 996 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1003 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { CONCAT_G_FIFOS(cfgt.rlimit, (yyvsp[0].Attr_val_fifo)); } -#line 2707 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2714 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 183: -#line 1001 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1008 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } -#line 2716 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2723 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 184: -#line 1006 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1013 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } -#line 2725 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2732 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 185: -#line 1014 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1021 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); } -#line 2731 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2738 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 189: -#line 1030 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1037 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { CONCAT_G_FIFOS(cfgt.enable_opts, (yyvsp[0].Attr_val_fifo)); } -#line 2737 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2744 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 190: -#line 1032 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1039 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { CONCAT_G_FIFOS(cfgt.disable_opts, (yyvsp[0].Attr_val_fifo)); } -#line 2743 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2750 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 191: -#line 1037 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1044 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } -#line 2752 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2759 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 192: -#line 1042 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1049 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } -#line 2761 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2768 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 193: -#line 1050 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1057 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); } -#line 2767 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2774 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 194: -#line 1052 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1059 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { if (lex_from_file()) { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); @@ -2781,74 +2788,74 @@ yyreduce: yyerror(err_str); } } -#line 2785 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2792 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 203: -#line 1087 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1094 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { CONCAT_G_FIFOS(cfgt.tinker, (yyvsp[0].Attr_val_fifo)); } -#line 2791 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2798 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 204: -#line 1092 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1099 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } -#line 2800 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2807 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 205: -#line 1097 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1104 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } -#line 2809 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2816 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 206: -#line 1105 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1112 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double)); } -#line 2815 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2822 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 219: -#line 1130 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1137 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { attr_val *av; av = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double)); APPEND_G_FIFO(cfgt.vars, av); } -#line 2826 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2833 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 220: -#line 1137 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1144 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { attr_val *av; av = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); APPEND_G_FIFO(cfgt.vars, av); } -#line 2837 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2844 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 221: -#line 1144 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1151 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { attr_val *av; av = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); APPEND_G_FIFO(cfgt.vars, av); } -#line 2848 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2855 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 222: -#line 1151 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1158 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { char error_text[64]; attr_val *av; @@ -2864,11 +2871,11 @@ yyreduce: yyerror(error_text); } } -#line 2868 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2875 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 223: -#line 1167 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1174 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { if (!lex_from_file()) { YYFREE((yyvsp[-1].String)); /* avoid leak */ @@ -2887,68 +2894,68 @@ yyreduce: } YYFREE((yyvsp[-1].String)); /* avoid leak */ } -#line 2891 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2898 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 224: -#line 1186 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1193 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { lex_flush_stack(); } -#line 2897 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2904 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 225: -#line 1188 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1195 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { /* see drift_parm below for actions */ } -#line 2903 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2910 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 226: -#line 1190 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1197 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { CONCAT_G_FIFOS(cfgt.logconfig, (yyvsp[0].Attr_val_fifo)); } -#line 2909 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2916 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 227: -#line 1192 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1199 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { CONCAT_G_FIFOS(cfgt.phone, (yyvsp[0].String_fifo)); } -#line 2915 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2922 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 228: -#line 1194 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1201 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { APPEND_G_FIFO(cfgt.setvar, (yyvsp[0].Set_var)); } -#line 2921 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2928 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 229: -#line 1196 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1203 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { addr_opts_node *aon; aon = create_addr_opts_node((yyvsp[-1].Address_node), (yyvsp[0].Attr_val_fifo)); APPEND_G_FIFO(cfgt.trap, aon); } -#line 2932 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2939 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 230: -#line 1203 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1210 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { CONCAT_G_FIFOS(cfgt.ttl, (yyvsp[0].Attr_val_fifo)); } -#line 2938 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2945 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 235: -#line 1218 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1225 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { #ifndef LEAP_SMEAR yyerror("Built without LEAP_SMEAR support."); #endif } -#line 2948 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2955 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 241: -#line 1238 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1245 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { if (lex_from_file()) { attr_val *av; @@ -2959,11 +2966,11 @@ yyreduce: yyerror("driftfile remote configuration ignored"); } } -#line 2963 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2970 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 242: -#line 1249 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1256 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { if (lex_from_file()) { attr_val *av; @@ -2976,11 +2983,11 @@ yyreduce: yyerror("driftfile remote configuration ignored"); } } -#line 2980 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 2987 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 243: -#line 1262 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1269 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { if (lex_from_file()) { attr_val *av; @@ -2990,71 +2997,71 @@ yyreduce: yyerror("driftfile remote configuration ignored"); } } -#line 2994 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3001 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 244: -#line 1275 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1282 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Set_var) = create_setvar_node((yyvsp[-3].String), (yyvsp[-1].String), (yyvsp[0].Integer)); } -#line 3000 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3007 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 246: -#line 1281 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1288 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Integer) = 0; } -#line 3006 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3013 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 247: -#line 1286 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1293 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; } -#line 3012 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3019 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 248: -#line 1288 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1295 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } -#line 3021 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3028 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 249: -#line 1296 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1303 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); } -#line 3027 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3034 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 250: -#line 1298 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1305 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), estrdup((yyvsp[0].Address_node)->address)); destroy_address_node((yyvsp[0].Address_node)); } -#line 3036 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3043 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 251: -#line 1306 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1313 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } -#line 3045 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3052 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 252: -#line 1311 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1318 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } -#line 3054 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3061 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 253: -#line 1319 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1326 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { char prefix; char * type; @@ -3076,141 +3083,141 @@ yyreduce: (yyval.Attr_val) = create_attr_sval(prefix, estrdup(type)); YYFREE((yyvsp[0].String)); } -#line 3080 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3087 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 254: -#line 1344 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1351 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { nic_rule_node *nrn; nrn = create_nic_rule_node((yyvsp[0].Integer), NULL, (yyvsp[-1].Integer)); APPEND_G_FIFO(cfgt.nic_rules, nrn); } -#line 3091 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3098 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 255: -#line 1351 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1358 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { nic_rule_node *nrn; nrn = create_nic_rule_node(0, (yyvsp[0].String), (yyvsp[-1].Integer)); APPEND_G_FIFO(cfgt.nic_rules, nrn); } -#line 3102 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3109 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 265: -#line 1379 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1386 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { CONCAT_G_FIFOS(cfgt.reset_counters, (yyvsp[0].Int_fifo)); } -#line 3108 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3115 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 266: -#line 1384 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1391 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Int_fifo) = (yyvsp[-1].Int_fifo); APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer))); } -#line 3117 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3124 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 267: -#line 1389 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1396 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Int_fifo) = NULL; APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer))); } -#line 3126 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3133 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 275: -#line 1413 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1420 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); APPEND_G_FIFO((yyval.Attr_val_fifo), create_int_node((yyvsp[0].Integer))); } -#line 3135 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3142 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 276: -#line 1418 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1425 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; APPEND_G_FIFO((yyval.Attr_val_fifo), create_int_node((yyvsp[0].Integer))); } -#line 3144 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3151 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 277: -#line 1426 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1433 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } -#line 3153 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3160 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 278: -#line 1431 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1438 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } -#line 3162 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3169 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 279: -#line 1439 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1446 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val) = create_attr_ival('i', (yyvsp[0].Integer)); } -#line 3168 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3175 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 281: -#line 1445 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1452 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val) = create_attr_rangeval('-', (yyvsp[-3].Integer), (yyvsp[-1].Integer)); } -#line 3174 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3181 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 282: -#line 1450 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1457 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.String_fifo) = (yyvsp[-1].String_fifo); APPEND_G_FIFO((yyval.String_fifo), create_string_node((yyvsp[0].String))); } -#line 3183 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3190 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 283: -#line 1455 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1462 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.String_fifo) = NULL; APPEND_G_FIFO((yyval.String_fifo), create_string_node((yyvsp[0].String))); } -#line 3192 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3199 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 284: -#line 1463 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1470 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Address_fifo) = (yyvsp[-1].Address_fifo); APPEND_G_FIFO((yyval.Address_fifo), (yyvsp[0].Address_node)); } -#line 3201 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3208 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 285: -#line 1468 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1475 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Address_fifo) = NULL; APPEND_G_FIFO((yyval.Address_fifo), (yyvsp[0].Address_node)); } -#line 3210 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3217 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 286: -#line 1476 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1483 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { if ((yyvsp[0].Integer) != 0 && (yyvsp[0].Integer) != 1) { yyerror("Integer value is not boolean (0 or 1). Assuming 1"); @@ -3219,29 +3226,29 @@ yyreduce: (yyval.Integer) = (yyvsp[0].Integer); } } -#line 3223 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3230 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 287: -#line 1484 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1491 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Integer) = 1; } -#line 3229 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3236 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 288: -#line 1485 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1492 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Integer) = 0; } -#line 3235 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3242 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 289: -#line 1489 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1496 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Double) = (double)(yyvsp[0].Integer); } -#line 3241 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3248 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 291: -#line 1500 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1507 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { sim_node *sn; @@ -3251,125 +3258,125 @@ yyreduce: /* Revert from ; to \n for end-of-command */ old_config_style = 1; } -#line 3255 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3262 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 292: -#line 1517 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1524 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { old_config_style = 0; } -#line 3261 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3268 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 293: -#line 1522 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1529 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = (yyvsp[-2].Attr_val_fifo); APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val)); } -#line 3270 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3277 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 294: -#line 1527 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1534 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val)); } -#line 3279 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3286 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 295: -#line 1535 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1542 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val) = create_attr_dval((yyvsp[-2].Integer), (yyvsp[0].Double)); } -#line 3285 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3292 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 298: -#line 1545 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1552 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Sim_server_fifo) = (yyvsp[-1].Sim_server_fifo); APPEND_G_FIFO((yyval.Sim_server_fifo), (yyvsp[0].Sim_server)); } -#line 3294 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3301 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 299: -#line 1550 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1557 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Sim_server_fifo) = NULL; APPEND_G_FIFO((yyval.Sim_server_fifo), (yyvsp[0].Sim_server)); } -#line 3303 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3310 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 300: -#line 1558 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1565 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Sim_server) = ONLY_SIM(create_sim_server((yyvsp[-4].Address_node), (yyvsp[-2].Double), (yyvsp[-1].Sim_script_fifo))); } -#line 3309 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3316 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 301: -#line 1563 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1570 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Double) = (yyvsp[-1].Double); } -#line 3315 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3322 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 302: -#line 1568 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1575 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Address_node) = (yyvsp[0].Address_node); } -#line 3321 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3328 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 303: -#line 1573 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1580 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Sim_script_fifo) = (yyvsp[-1].Sim_script_fifo); APPEND_G_FIFO((yyval.Sim_script_fifo), (yyvsp[0].Sim_script)); } -#line 3330 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3337 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 304: -#line 1578 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1585 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Sim_script_fifo) = NULL; APPEND_G_FIFO((yyval.Sim_script_fifo), (yyvsp[0].Sim_script)); } -#line 3339 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3346 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 305: -#line 1586 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1593 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Sim_script) = ONLY_SIM(create_sim_script_info((yyvsp[-3].Double), (yyvsp[-1].Attr_val_fifo))); } -#line 3345 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3352 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 306: -#line 1591 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1598 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = (yyvsp[-2].Attr_val_fifo); APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val)); } -#line 3354 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3361 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 307: -#line 1596 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1603 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val)); } -#line 3363 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3370 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 308: -#line 1604 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ +#line 1611 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val) = create_attr_dval((yyvsp[-2].Integer), (yyvsp[0].Double)); } -#line 3369 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3376 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; -#line 3373 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ +#line 3380 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -3597,7 +3604,7 @@ yyreturn: #endif return yyresult; } -#line 1615 "../../ntpd/ntp_parser.y" /* yacc.c:1906 */ +#line 1622 "../../ntpd/ntp_parser.y" /* yacc.c:1906 */ void diff --git a/contrib/ntp/ntpd/ntp_proto.c b/contrib/ntp/ntpd/ntp_proto.c index 2a15d72..f770472 100644 --- a/contrib/ntp/ntpd/ntp_proto.c +++ b/contrib/ntp/ntpd/ntp_proto.c @@ -15,6 +15,7 @@ #include "ntp_string.h" #include "ntp_leapsec.h" #include "refidsmear.h" +#include "lib_strbuf.h" #include <stdio.h> #ifdef HAVE_LIBSCF_H @@ -172,8 +173,14 @@ void pool_name_resolved (int, int, void *, const char *, const struct addrinfo *); #endif /* WORKER */ +const char * amtoa (int am); + + void -set_sys_leap(u_char new_sys_leap) { +set_sys_leap( + u_char new_sys_leap + ) +{ sys_leap = new_sys_leap; xmt_leap = sys_leap; @@ -189,8 +196,9 @@ set_sys_leap(u_char new_sys_leap) { #ifdef LEAP_SMEAR else { /* - * If leap smear is enabled in general we must never send a leap second warning - * to clients, so make sure we only send "in sync". + * If leap smear is enabled in general we must + * never send a leap second warning to clients, + * so make sure we only send "in sync". */ if (leap_smear.enabled) xmt_leap = LEAP_NOWARNING; @@ -199,34 +207,39 @@ set_sys_leap(u_char new_sys_leap) { } } + /* * Kiss Code check */ -int kiss_code_check(u_char hisleap, u_char hisstratum, u_char hismode, u_int32 refid) { +int +kiss_code_check( + u_char hisleap, + u_char hisstratum, + u_char hismode, + u_int32 refid + ) +{ - if ( hismode == MODE_SERVER - && hisleap == LEAP_NOTINSYNC - && hisstratum == STRATUM_UNSPEC) { - if(memcmp(&refid,"RATE", 4) == 0) { - return (RATEKISS); - } - else if(memcmp(&refid,"DENY", 4) == 0) { - return (DENYKISS); - } - else if(memcmp(&refid,"RSTR", 4) == 0) { - return (RSTRKISS); - } - else if(memcmp(&refid,"X", 1) == 0) { - return (XKISS); - } - else { - return (UNKNOWNKISS); - } - } - else { - return (NOKISS); + if ( hismode == MODE_SERVER + && hisleap == LEAP_NOTINSYNC + && hisstratum == STRATUM_UNSPEC) { + if(memcmp(&refid,"RATE", 4) == 0) { + return (RATEKISS); + } else if(memcmp(&refid,"DENY", 4) == 0) { + return (DENYKISS); + } else if(memcmp(&refid,"RSTR", 4) == 0) { + return (RSTRKISS); + } else if(memcmp(&refid,"X", 1) == 0) { + return (XKISS); + } else { + return (UNKNOWNKISS); } + } else { + return (NOKISS); + } } + + /* * transmit - transmit procedure called by poll timeout */ @@ -303,7 +316,7 @@ transmit( peer->outdate = current_time; if ( (peer_associations <= 2 * sys_maxclock) && ( peer_associations < sys_maxclock - || sys_survivors < sys_minclock)) + || sys_survivors < sys_minclock)) pool_xmit(peer); poll_update(peer, hpoll); return; @@ -416,6 +429,33 @@ transmit( if (peer->hmode != MODE_BCLIENT) peer_xmit(peer); poll_update(peer, hpoll); + + return; +} + + +const char * +amtoa( + int am + ) +{ + char *bp; + + switch(am) { + case AM_ERR: return "AM_ERR"; + case AM_NOMATCH: return "AM_NOMATCH"; + case AM_PROCPKT: return "AM_PROCPKT"; + case AM_BCST: return "AM_BCST"; + case AM_FXMIT: return "AM_FXMIT"; + case AM_MANYCAST: return "AM_MANYCAST"; + case AM_NEWPASS: return "AM_NEWPASS"; + case AM_NEWBCL: return "AM_NEWBCL"; + case AM_POSSBCL: return "AM_POSSBCL"; + default: + LIB_GETBUF(bp); + snprintf(bp, LIB_BUFLENGTH, "AM_#%d", am); + return bp; + } } @@ -434,16 +474,18 @@ receive( u_char hismode; /* packet mode */ u_char hisstratum; /* packet stratum */ u_short restrict_mask; /* restrict bits */ - int kissCode = NOKISS; /* Kiss Code */ + const char *hm_str; /* hismode string */ + const char *am_str; /* association match string */ + int kissCode = NOKISS; /* Kiss Code */ int has_mac; /* length of MAC field */ int authlen; /* offset of MAC field */ int is_authentic = 0; /* cryptosum ok */ int retcode = AM_NOMATCH; /* match code */ keyid_t skeyid = 0; /* key IDs */ u_int32 opcode = 0; /* extension field opcode */ - sockaddr_u *dstadr_sin; /* active runway */ + sockaddr_u *dstadr_sin; /* active runway */ struct peer *peer2; /* aux peer structure pointer */ - endpt * match_ep; /* newpeer() local address */ + endpt *match_ep; /* newpeer() local address */ l_fp p_org; /* origin timestamp */ l_fp p_rec; /* receive timestamp */ l_fp p_xmt; /* transmit timestamp */ @@ -474,11 +516,12 @@ receive( return; /* bogus port */ } restrict_mask = restrictions(&rbufp->recv_srcadr); - DPRINTF(2, ("receive: at %ld %s<-%s flags %x restrict %03x\n", - current_time, stoa(&rbufp->dstadr->sin), - stoa(&rbufp->recv_srcadr), - rbufp->dstadr->flags, restrict_mask)); pkt = &rbufp->recv_pkt; + DPRINTF(2, ("receive: at %ld %s<-%s flags %x restrict %03x org %#010x.%08x xmt %#010x.%08x\n", + current_time, stoa(&rbufp->dstadr->sin), + stoa(&rbufp->recv_srcadr), rbufp->dstadr->flags, + restrict_mask, ntohl(pkt->org.l_ui), ntohl(pkt->org.l_uf), + ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf))); hisversion = PKT_VERSION(pkt->li_vn_mode); hisleap = PKT_LEAP(pkt->li_vn_mode); hismode = (int)PKT_MODE(pkt->li_vn_mode); @@ -685,6 +728,8 @@ receive( NTOHL_FP(&pkt->org, &p_org); NTOHL_FP(&pkt->rec, &p_rec); NTOHL_FP(&pkt->xmt, &p_xmt); + hm_str = modetoa(hismode); + am_str = amtoa(retcode); /* * Authentication is conditioned by three switches: @@ -713,25 +758,21 @@ receive( if (has_mac == 0) { restrict_mask &= ~RES_MSSNTP; is_authentic = AUTH_NONE; /* not required */ -#ifdef DEBUG - if (debug) - printf( - "receive: at %ld %s<-%s mode %d len %d\n", + DPRINTF(2, ("receive: at %ld %s<-%s mode %d/%s:%s len %d org %#010x.%08x xmt %#010x.%08x NOMAC\n", current_time, stoa(dstadr_sin), - stoa(&rbufp->recv_srcadr), hismode, - authlen); -#endif + stoa(&rbufp->recv_srcadr), hismode, hm_str, am_str, + authlen, + ntohl(pkt->org.l_ui), ntohl(pkt->org.l_uf), + ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf))); } else if (has_mac == 4) { restrict_mask &= ~RES_MSSNTP; is_authentic = AUTH_CRYPTO; /* crypto-NAK */ -#ifdef DEBUG - if (debug) - printf( - "receive: at %ld %s<-%s mode %d keyid %08x len %d auth %d\n", + DPRINTF(2, ("receive: at %ld %s<-%s mode %d/%s:%s keyid %08x len %d auth %d org %#010x.%08x xmt %#010x.%08x MAC4\n", current_time, stoa(dstadr_sin), - stoa(&rbufp->recv_srcadr), hismode, skeyid, - authlen + has_mac, is_authentic); -#endif + stoa(&rbufp->recv_srcadr), hismode, hm_str, am_str, + skeyid, authlen + has_mac, is_authentic, + ntohl(pkt->org.l_ui), ntohl(pkt->org.l_uf), + ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf))); #ifdef HAVE_NTP_SIGND /* @@ -747,7 +788,7 @@ receive( && (restrict_mask & RES_MSSNTP) && (retcode == AM_FXMIT || retcode == AM_NEWPASS) && (memcmp(zero_key, (char *)pkt + authlen + 4, - MAX_MD5_LEN - 4) == 0)) { + MAX_MD5_LEN - 4) == 0)) { is_authentic = AUTH_NONE; #endif /* HAVE_NTP_SIGND */ @@ -856,14 +897,12 @@ receive( if (crypto_flags && skeyid > NTP_MAXKEY) authtrust(skeyid, 0); #endif /* AUTOKEY */ -#ifdef DEBUG - if (debug) - printf( - "receive: at %ld %s<-%s mode %d keyid %08x len %d auth %d\n", + DPRINTF(2, ("receive: at %ld %s<-%s mode %d/%s:%s keyid %08x len %d auth %d org %#010x.%08x xmt %#010x.%08x\n", current_time, stoa(dstadr_sin), - stoa(&rbufp->recv_srcadr), hismode, skeyid, - authlen + has_mac, is_authentic); -#endif + stoa(&rbufp->recv_srcadr), hismode, hm_str, am_str, + skeyid, authlen + has_mac, is_authentic, + ntohl(pkt->org.l_ui), ntohl(pkt->org.l_uf), + ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf))); } /* @@ -1194,11 +1233,11 @@ receive( * debug-printed and not logged to avoid log * flooding. */ - DPRINTF(1, ("receive: at %ld refusing to mobilize passive association" - " with unknown peer %s mode %d keyid %08x len %d auth %d\n", + DPRINTF(2, ("receive: at %ld refusing to mobilize passive association" + " with unknown peer %s mode %d/%s:%s keyid %08x len %d auth %d\n", current_time, stoa(&rbufp->recv_srcadr), - hismode, skeyid, (authlen + has_mac), - is_authentic)); + hismode, hm_str, am_str, skeyid, + (authlen + has_mac), is_authentic)); sys_declined++; return; } @@ -1321,26 +1360,36 @@ receive( } /* - * Check for bogus packet in basic mode. If found, switch to - * interleaved mode and resynchronize, but only after confirming - * the packet is not bogus in symmetric interleaved mode. + * Basic mode checks: + * + * If there is no origin timestamp, it's an initial packet. + * + * Otherwise, check for bogus packet in basic mode. + * If it is bogus, switch to interleaved mode and resynchronize, + * but only after confirming the packet is not bogus in + * symmetric interleaved mode. * * This could also mean somebody is forging packets claiming to * be from us, attempting to cause our server to KoD us. */ } else if (peer->flip == 0) { - if (!L_ISEQU(&p_org, &peer->aorg)) { + if (0 < hisstratum && L_ISZERO(&p_org)) { + L_CLR(&peer->aorg); + } else if (!L_ISEQU(&p_org, &peer->aorg)) { peer->bogusorg++; peer->flash |= TEST2; /* bogus */ msyslog(LOG_INFO, - "receive: Unexpected origin timestamp from %s", - ntoa(&peer->srcadr)); + "receive: Unexpected origin timestamp %#010x.%08x from %s xmt %#010x.%08x", + ntohl(pkt->org.l_ui), ntohl(pkt->org.l_uf), + ntoa(&peer->srcadr), + ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf)); if ( !L_ISZERO(&peer->dst) && L_ISEQU(&p_org, &peer->dst)) { + /* Might be the start of an interleave */ peer->flip = 1; report_event(PEVNT_XLEAVE, peer, NULL); } - return; /* Bogus packet, we are done */ + return; /* Bogus or possible interleave packet */ } else { L_CLR(&peer->aorg); } @@ -1694,11 +1743,8 @@ process_packet( */ if (peer->flash & PKT_TEST_MASK) { peer->seldisptoolarge++; -#ifdef DEBUG - if (debug) - printf("packet: flash header %04x\n", - peer->flash); -#endif + DPRINTF(1, ("packet: flash header %04x\n", + peer->flash)); return; } @@ -1871,15 +1917,12 @@ process_packet( * the roundtrip delay. Then it calculates the correction as a * fraction of d. */ - peer->t21 = t21; + peer->t21 = t21; peer->t21_last = peer->t21_bytes; peer->t34 = -t34; peer->t34_bytes = len; -#ifdef DEBUG - if (debug > 1) - printf("packet: t21 %.9lf %d t34 %.9lf %d\n", peer->t21, - peer->t21_bytes, peer->t34, peer->t34_bytes); -#endif + DPRINTF(2, ("packet: t21 %.9lf %d t34 %.9lf %d\n", peer->t21, + peer->t21_bytes, peer->t34, peer->t34_bytes)); if (peer->r21 > 0 && peer->r34 > 0 && p_del > 0) { if (peer->pmode != MODE_BROADCAST) td = (peer->r34 / (peer->r21 + peer->r34) - @@ -1888,7 +1931,7 @@ process_packet( td = 0; /* - * Unfortunately, in many cases the errors are + * Unfortunately, in many cases the errors are * unacceptable, so for the present the rates are not * used. In future, we might find conditions where the * calculations are useful, so this should be considered @@ -1896,12 +1939,9 @@ process_packet( */ t21 -= td; t34 -= td; -#ifdef DEBUG - if (debug > 1) - printf("packet: del %.6lf r21 %.1lf r34 %.1lf %.6lf\n", + DPRINTF(2, ("packet: del %.6lf r21 %.1lf r34 %.1lf %.6lf\n", p_del, peer->r21 / 1e3, peer->r34 / 1e3, - td); -#endif + td)); } #endif /* ASSYM */ @@ -1994,12 +2034,8 @@ clock_update( sys_rootdelay = peer->delay + peer->rootdelay; sys_reftime = peer->dst; -#ifdef DEBUG - if (debug) - printf( - "clock_update: at %lu sample %lu associd %d\n", - current_time, peer->epoch, peer->associd); -#endif + DPRINTF(1, ("clock_update: at %lu sample %lu associd %d\n", + current_time, peer->epoch, peer->associd)); /* * Comes now the moment of truth. Crank the clock discipline and @@ -2308,13 +2344,9 @@ peer_clear( #ifdef AUTOKEY peer->refresh = current_time + (1 << NTP_REFRESH); #endif /* AUTOKEY */ -#ifdef DEBUG - if (debug) - printf( - "peer_clear: at %ld next %ld associd %d refid %s\n", + DPRINTF(1, ("peer_clear: at %ld next %ld associd %d refid %s\n", current_time, peer->nextdate, peer->associd, - ident); -#endif + ident)); } @@ -2478,11 +2510,8 @@ clock_filter( * packets. */ if (peer->filter_epoch[k] <= peer->epoch) { -#if DEBUG - if (debug > 1) - printf("clock_filter: old sample %lu\n", current_time - - peer->filter_epoch[k]); -#endif + DPRINTF(2, ("clock_filter: old sample %lu\n", current_time - + peer->filter_epoch[k])); return; } peer->epoch = peer->filter_epoch[k]; @@ -2494,13 +2523,9 @@ clock_filter( */ record_peer_stats(&peer->srcadr, ctlpeerstatus(peer), peer->offset, peer->delay, peer->disp, peer->jitter); -#ifdef DEBUG - if (debug) - printf( - "clock_filter: n %d off %.6f del %.6f dsp %.6f jit %.6f\n", + DPRINTF(1, ("clock_filter: n %d off %.6f del %.6f dsp %.6f jit %.6f\n", m, peer->offset, peer->delay, peer->disp, - peer->jitter); -#endif + peer->jitter)); if (peer->burst == 0 || sys_leap == LEAP_NOTINSYNC) clock_select(); } @@ -3004,7 +3029,7 @@ clock_select(void) typesystem = typepps; sys_clockhop = 0; typesystem->new_status = CTL_PST_SEL_PPS; - sys_offset = typesystem->offset; + sys_offset = typesystem->offset; sys_jitter = typesystem->jitter; DPRINTF(1, ("select: pps offset %.9f jitter %.9f\n", sys_offset, sys_jitter)); @@ -3157,11 +3182,11 @@ peer_xmit( * might not be usable. */ sendlen = LEN_PKT_NOMAC; + if ( #ifdef AUTOKEY - if (!(peer->flags & FLAG_SKEY) && peer->keyid == 0) { -#else /* !AUTOKEY follows */ - if (peer->keyid == 0) { + !(peer->flags & FLAG_SKEY) && #endif /* !AUTOKEY */ + peer->keyid == 0) { /* * Transmit a-priori timestamps @@ -3207,13 +3232,11 @@ peer_xmit( } L_SUB(&xmt_ty, &xmt_tx); LFPTOD(&xmt_ty, peer->xleave); -#ifdef DEBUG - if (debug) - printf("transmit: at %ld %s->%s mode %d len %zu\n", - current_time, peer->dstadr ? - stoa(&peer->dstadr->sin) : "-", - stoa(&peer->srcadr), peer->hmode, sendlen); -#endif + DPRINTF(1, ("peer_xmit: at %ld %s->%s mode %d len %zu xmt %#010x.%08x\n", + current_time, + peer->dstadr ? stoa(&peer->dstadr->sin) : "-", + stoa(&peer->srcadr), peer->hmode, sendlen, + xmt_tx.l_ui, xmt_tx.l_uf)); return; } @@ -3498,7 +3521,7 @@ peer_xmit( authtrust(xkeyid, 0); #endif /* AUTOKEY */ if (sendlen > sizeof(xpkt)) { - msyslog(LOG_ERR, "proto: buffer overflow %zu", sendlen); + msyslog(LOG_ERR, "peer_xmit: buffer overflow %zu", sendlen); exit (-1); } peer->t21_bytes = sendlen; @@ -3521,30 +3544,33 @@ peer_xmit( L_SUB(&xmt_ty, &xmt_tx); LFPTOD(&xmt_ty, peer->xleave); #ifdef AUTOKEY -#ifdef DEBUG - if (debug) - printf("transmit: at %ld %s->%s mode %d keyid %08x len %zu index %d\n", + DPRINTF(1, ("peer_xmit: at %ld %s->%s mode %d keyid %08x len %zu index %d\n", current_time, latoa(peer->dstadr), ntoa(&peer->srcadr), peer->hmode, xkeyid, sendlen, - peer->keynumber); -#endif + peer->keynumber)); #else /* !AUTOKEY follows */ -#ifdef DEBUG - if (debug) - printf("transmit: at %ld %s->%s mode %d keyid %08x len %d\n", + DPRINTF(1, ("peer_xmit: at %ld %s->%s mode %d keyid %08x len %d\n", current_time, peer->dstadr ? ntoa(&peer->dstadr->sin) : "-", - ntoa(&peer->srcadr), peer->hmode, xkeyid, sendlen); -#endif + ntoa(&peer->srcadr), peer->hmode, xkeyid, sendlen)); #endif /* !AUTOKEY */ + + return; } #ifdef LEAP_SMEAR static void -leap_smear_add_offs(l_fp *t, l_fp *t_recv) { +leap_smear_add_offs( + l_fp *t, + l_fp *t_recv + ) +{ + L_ADD(t, &leap_smear.offset); + + return; } #endif /* LEAP_SMEAR */ @@ -3565,7 +3591,7 @@ fast_xmit( struct pkt xpkt; /* transmit packet structure */ struct pkt *rpkt; /* receive packet structure */ l_fp xmt_tx, xmt_ty; - int sendlen; + size_t sendlen; #ifdef AUTOKEY u_int32 temp32; #endif @@ -3684,13 +3710,10 @@ fast_xmit( if (rbufp->recv_length == sendlen) { sendpkt(&rbufp->recv_srcadr, rbufp->dstadr, 0, &xpkt, sendlen); -#ifdef DEBUG - if (debug) - printf( - "transmit: at %ld %s->%s mode %d len %d\n", + DPRINTF(1, ("fast_xmit: at %ld %s->%s mode %d len %lu\n", current_time, stoa(&rbufp->dstadr->sin), - stoa(&rbufp->recv_srcadr), xmode, sendlen); -#endif + stoa(&rbufp->recv_srcadr), xmode, + (u_long)sendlen)); return; } @@ -3717,7 +3740,7 @@ fast_xmit( */ cookie = session_key(&rbufp->recv_srcadr, &rbufp->dstadr->sin, 0, sys_private, 0); - if (rbufp->recv_length > sendlen + (int)MAX_MAC_LEN) { + if ((size_t)rbufp->recv_length > sendlen + MAX_MAC_LEN) { session_key(&rbufp->dstadr->sin, &rbufp->recv_srcadr, xkeyid, 0, 2); temp32 = CRYPTO_RESP; @@ -3741,13 +3764,10 @@ fast_xmit( get_systime(&xmt_ty); L_SUB(&xmt_ty, &xmt_tx); sys_authdelay = xmt_ty; -#ifdef DEBUG - if (debug) - printf( - "transmit: at %ld %s->%s mode %d keyid %08x len %d\n", + DPRINTF(1, ("fast_xmit: at %ld %s->%s mode %d keyid %08x len %lu\n", current_time, ntoa(&rbufp->dstadr->sin), - ntoa(&rbufp->recv_srcadr), xmode, xkeyid, sendlen); -#endif + ntoa(&rbufp->recv_srcadr), xmode, xkeyid, + (u_long)sendlen)); } @@ -3827,11 +3847,8 @@ pool_xmit( LEN_PKT_NOMAC); pool->sent++; pool->throttle += (1 << pool->minpoll) - 2; -#ifdef DEBUG - if (debug) - printf("transmit: at %ld %s->%s pool\n", - current_time, latoa(lcladr), stoa(rmtadr)); -#endif + DPRINTF(1, ("pool_xmit: at %ld %s->%s pool\n", + current_time, latoa(lcladr), stoa(rmtadr))); msyslog(LOG_INFO, "Soliciting pool server %s", stoa(rmtadr)); #endif /* WORKER */ } @@ -3849,7 +3866,8 @@ pool_xmit( * group different 1 ignore * * ignore if notrust */ -int group_test( +int +group_test( char *grp, char *ident ) @@ -3929,11 +3947,8 @@ key_expire( value_free(&peer->sndval); peer->keynumber = 0; peer->flags &= ~FLAG_ASSOC; -#ifdef DEBUG - if (debug) - printf("key_expire: at %lu associd %d\n", current_time, - peer->associd); -#endif + DPRINTF(1, ("key_expire: at %lu associd %d\n", current_time, + peer->associd)); } #endif /* AUTOKEY */ diff --git a/contrib/ntp/ntpd/ntp_refclock.c b/contrib/ntp/ntpd/ntp_refclock.c index 1f16ca7..d25cc2c 100644 --- a/contrib/ntp/ntpd/ntp_refclock.c +++ b/contrib/ntp/ntpd/ntp_refclock.c @@ -732,9 +732,9 @@ process_refclock_packet( */ int refclock_open( - char *dev, /* device name pointer */ - u_int speed, /* serial port speed (code) */ - u_int lflags /* line discipline flags */ + const char *dev, /* device name pointer */ + u_int speed, /* serial port speed (code) */ + u_int lflags /* line discipline flags */ ) { int fd; diff --git a/contrib/ntp/ntpd/ntp_request.c b/contrib/ntp/ntpd/ntp_request.c index 6073f99..fa78ce1 100644 --- a/contrib/ntp/ntpd/ntp_request.c +++ b/contrib/ntp/ntpd/ntp_request.c @@ -2006,11 +2006,11 @@ do_trustkey( u_long trust ) { - register u_long *kp; + register uint32_t *kp; register int items; items = INFO_NITEMS(inpkt->err_nitems); - kp = (u_long *)&inpkt->u; + kp = (uint32_t*)&inpkt->u; while (items-- > 0) { authtrust(*kp, trust); kp++; diff --git a/contrib/ntp/ntpd/ntp_restrict.c b/contrib/ntp/ntpd/ntp_restrict.c index 82bbaef..0b5fa2e 100644 --- a/contrib/ntp/ntpd/ntp_restrict.c +++ b/contrib/ntp/ntpd/ntp_restrict.c @@ -160,7 +160,7 @@ alloc_res4(void) const size_t count = INC_RESLIST4; restrict_u * rl; restrict_u * res; - int i; + size_t i; UNLINK_HEAD_SLIST(res, resfree4, link); if (res != NULL) @@ -186,7 +186,7 @@ alloc_res6(void) const size_t count = INC_RESLIST6; restrict_u * rl; restrict_u * res; - int i; + size_t i; UNLINK_HEAD_SLIST(res, resfree6, link); if (res != NULL) diff --git a/contrib/ntp/ntpd/ntp_signd.c b/contrib/ntp/ntpd/ntp_signd.c index 2ba11d0..857dcbf 100644 --- a/contrib/ntp/ntpd/ntp_signd.c +++ b/contrib/ntp/ntpd/ntp_signd.c @@ -66,7 +66,7 @@ write_all(int fd, const void *buf, size_t len) while (len) { int n = write(fd, buf, len); if (n <= 0) return total; - buf = n + (char *)buf; + buf = n + (const char *)buf; len -= n; total += n; } @@ -110,9 +110,10 @@ recv_packet(int fd, char **buf, uint32_t *len) { if (read_all(fd, len, sizeof(*len)) != sizeof(*len)) return -1; *len = ntohl(*len); - (*buf) = emalloc(*len); + *buf = emalloc(*len); if (read_all(fd, *buf, *len) != *len) { free(*buf); + *buf = NULL; return -1; } return 0; diff --git a/contrib/ntp/ntpd/ntp_timer.c b/contrib/ntp/ntpd/ntp_timer.c index 828aa8c..03084a3 100644 --- a/contrib/ntp/ntpd/ntp_timer.c +++ b/contrib/ntp/ntpd/ntp_timer.c @@ -626,18 +626,19 @@ check_leapsec( * announce the leap event has happened. */ const char *leapmsg = NULL; - if (lsdata.warped < 0) { + double lswarp = lsdata.warped; + if (lswarp < 0.0) { if (clock_max_back > 0.0 && - clock_max_back < fabs(lsdata.warped)) { - step_systime(lsdata.warped); + clock_max_back < -lswarp) { + step_systime(lswarp); leapmsg = leapmsg_p_step; } else { leapmsg = leapmsg_p_slew; } - } else if (lsdata.warped > 0) { + } else if (lswarp > 0.0) { if (clock_max_fwd > 0.0 && - clock_max_fwd < fabs(lsdata.warped)) { - step_systime(lsdata.warped); + clock_max_fwd < lswarp) { + step_systime(lswarp); leapmsg = leapmsg_n_step; } else { leapmsg = leapmsg_n_slew; diff --git a/contrib/ntp/ntpd/ntp_util.c b/contrib/ntp/ntpd/ntp_util.c index c4bc901..3a95819 100644 --- a/contrib/ntp/ntpd/ntp_util.c +++ b/contrib/ntp/ntpd/ntp_util.c @@ -334,7 +334,7 @@ stats_config( { FILE *fp; const char *value; - int len; + size_t len; double old_drift; l_fp now; time_t ttnow; @@ -437,7 +437,7 @@ stats_config( (int)sizeof(statsdir) - 2); } else { int add_dir_sep; - int value_l; + size_t value_l; /* Add a DIR_SEP unless we already have one. */ value_l = strlen(value); @@ -933,7 +933,7 @@ getauthkeys( const char *keyfile ) { - int len; + size_t len; len = strlen(keyfile); if (!len) diff --git a/contrib/ntp/ntpd/ntpd-opts.c b/contrib/ntp/ntpd/ntpd-opts.c index 1bbecfa..660884b 100644 --- a/contrib/ntp/ntpd/ntpd-opts.c +++ b/contrib/ntp/ntpd/ntpd-opts.c @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (ntpd-opts.c) * - * It has been AutoGen-ed October 21, 2015 at 12:36:00 PM by AutoGen 5.18.5 + * It has been AutoGen-ed January 7, 2016 at 11:28:29 PM by AutoGen 5.18.5 * From the definitions ntpd-opts.def * and the template file options * @@ -75,7 +75,7 @@ extern FILE * option_usage_fp; * static const strings for ntpd options */ static char const ntpd_opt_strs[3129] = -/* 0 */ "ntpd 4.2.8p4\n" +/* 0 */ "ntpd 4.2.8p5\n" "Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n" "This is free software. It is licensed for use, modification and\n" "redistribution under the terms of the NTP License, copies of which\n" @@ -205,12 +205,12 @@ static char const ntpd_opt_strs[3129] = /* 2900 */ "output version information and exit\0" /* 2936 */ "version\0" /* 2944 */ "NTPD\0" -/* 2949 */ "ntpd - NTP daemon program - Ver. 4.2.8p4\n" +/* 2949 */ "ntpd - NTP daemon program - Ver. 4.2.8p5\n" "Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n" "\t\t[ <server1> ... <serverN> ]\n\0" /* 3080 */ "http://bugs.ntp.org, bugs@ntp.org\0" /* 3114 */ "\n\0" -/* 3116 */ "ntpd 4.2.8p4"; +/* 3116 */ "ntpd 4.2.8p5"; /** * ipv4 option description with @@ -1529,7 +1529,7 @@ static void bogus_function(void) { translate option names. */ /* referenced via ntpdOptions.pzCopyright */ - puts(_("ntpd 4.2.8p4\n\ + puts(_("ntpd 4.2.8p5\n\ Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n\ This is free software. It is licensed for use, modification and\n\ redistribution under the terms of the NTP License, copies of which\n\ @@ -1670,7 +1670,7 @@ implied warranty.\n")); puts(_("output version information and exit")); /* referenced via ntpdOptions.pzUsageTitle */ - puts(_("ntpd - NTP daemon program - Ver. 4.2.8p4\n\ + puts(_("ntpd - NTP daemon program - Ver. 4.2.8p5\n\ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\ \t\t[ <server1> ... <serverN> ]\n")); @@ -1678,7 +1678,7 @@ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\ puts(_("\n")); /* referenced via ntpdOptions.pzFullVersion */ - puts(_("ntpd 4.2.8p4")); + puts(_("ntpd 4.2.8p5")); /* referenced via ntpdOptions.pzFullUsage */ puts(_("<<<NOT-FOUND>>>")); diff --git a/contrib/ntp/ntpd/ntpd-opts.h b/contrib/ntp/ntpd/ntpd-opts.h index d87c221..571fd34 100644 --- a/contrib/ntp/ntpd/ntpd-opts.h +++ b/contrib/ntp/ntpd/ntpd-opts.h @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (ntpd-opts.h) * - * It has been AutoGen-ed October 21, 2015 at 12:35:59 PM by AutoGen 5.18.5 + * It has been AutoGen-ed January 7, 2016 at 11:28:28 PM by AutoGen 5.18.5 * From the definitions ntpd-opts.def * and the template file options * @@ -106,9 +106,9 @@ typedef enum { /** count of all options for ntpd */ #define OPTION_CT 38 /** ntpd version */ -#define NTPD_VERSION "4.2.8p4" +#define NTPD_VERSION "4.2.8p5" /** Full ntpd version text */ -#define NTPD_FULL_VERSION "ntpd 4.2.8p4" +#define NTPD_FULL_VERSION "ntpd 4.2.8p5" /** * Interface defines for all options. Replace "n" with the UPPER_CASED diff --git a/contrib/ntp/ntpd/ntpd.1ntpdman b/contrib/ntp/ntpd/ntpd.1ntpdman index 187a79a..42d0caf 100644 --- a/contrib/ntp/ntpd/ntpd.1ntpdman +++ b/contrib/ntp/ntpd/ntpd.1ntpdman @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntpd 1ntpdman "21 Oct 2015" "4.2.8p4" "User Commands" +.TH ntpd 1ntpdman "07 Jan 2016" "4.2.8p5" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-dUaOfK/ag-qUaGeK) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-KDaWJq/ag-WDaOIq) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:11 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:30:44 PM by AutoGen 5.18.5 .\" From the definitions ntpd-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/ntpd/ntpd.1ntpdmdoc b/contrib/ntp/ntpd/ntpd.1ntpdmdoc index 139de52..dc06f58 100644 --- a/contrib/ntp/ntpd/ntpd.1ntpdmdoc +++ b/contrib/ntp/ntpd/ntpd.1ntpdmdoc @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTPD 1ntpdmdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntpd-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:30 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:31:02 PM by AutoGen 5.18.5 .\" From the definitions ntpd-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/ntpd/ntpd.c b/contrib/ntp/ntpd/ntpd.c index a517391..7630aee 100644 --- a/contrib/ntp/ntpd/ntpd.c +++ b/contrib/ntp/ntpd/ntpd.c @@ -27,12 +27,16 @@ #include "ntp_libopts.h" #include "ntpd-opts.h" -/* there's a short treatise below what the thread stuff is for */ +/* there's a short treatise below what the thread stuff is for. + * [Bug 2954] enable the threading warm-up only for Linux. + */ #if defined(HAVE_PTHREADS) && HAVE_PTHREADS && !defined(NO_THREADS) # ifdef HAVE_PTHREAD_H # include <pthread.h> # endif -# define NEED_PTHREAD_WARMUP +# if defined(linux) +# define NEED_PTHREAD_WARMUP +# endif #endif #ifdef HAVE_UNISTD_H @@ -269,6 +273,9 @@ static void library_unexpected_error(const char *, int, * This uses only the standard pthread API and should work with all * implementations of pthreads. It is not necessary everywhere, but it's * cheap enough to go on nearly unnoticed. + * + * Addendum: Bug 2954 showed that the assumption that this should work + * with all OS is wrong -- at least FreeBSD bombs heavily. */ #ifdef NEED_PTHREAD_WARMUP @@ -646,6 +653,9 @@ ntpdmain( # endif # ifdef HAVE_WORKING_FORK + /* make sure the FDs are initialised */ + pipe_fds[0] = -1; + pipe_fds[1] = -1; do { /* 'loop' once */ if (!HAVE_OPT( WAIT_SYNC )) break; diff --git a/contrib/ntp/ntpd/ntpd.html b/contrib/ntp/ntpd/ntpd.html index 8d6f9d6..ae3e17c 100644 --- a/contrib/ntp/ntpd/ntpd.html +++ b/contrib/ntp/ntpd/ntpd.html @@ -39,7 +39,7 @@ The program can operate in any of several modes, including client/server, symmetric and broadcast modes, and with both symmetric-key and public-key cryptography. - <p>This document applies to version 4.2.8p4 of <code>ntpd</code>. + <p>This document applies to version 4.2.8p5 of <code>ntpd</code>. <ul class="menu"> <li><a accesskey="1" href="#ntpd-Description">ntpd Description</a>: Description @@ -220,7 +220,7 @@ the usage text by passing it through a pager program. used to select the program, defaulting to <span class="file">more</span>. Both will exit with a status code of 0. -<pre class="example">ntpd - NTP daemon program - Ver. 4.2.8p4-sec-RC2 +<pre class="example">ntpd - NTP daemon program - Ver. 4.2.8p4 Usage: ntpd [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \ [ <server1> ... <serverN> ] Flg Arg Option-Name Description diff --git a/contrib/ntp/ntpd/ntpd.man.in b/contrib/ntp/ntpd/ntpd.man.in index 21bd884..222f0b3 100644 --- a/contrib/ntp/ntpd/ntpd.man.in +++ b/contrib/ntp/ntpd/ntpd.man.in @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntpd @NTPD_MS@ "21 Oct 2015" "4.2.8p4" "User Commands" +.TH ntpd @NTPD_MS@ "07 Jan 2016" "4.2.8p5" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-dUaOfK/ag-qUaGeK) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-KDaWJq/ag-WDaOIq) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:11 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:30:44 PM by AutoGen 5.18.5 .\" From the definitions ntpd-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/ntpd/ntpd.mdoc.in b/contrib/ntp/ntpd/ntpd.mdoc.in index ad71af9..e5be1ee 100644 --- a/contrib/ntp/ntpd/ntpd.mdoc.in +++ b/contrib/ntp/ntpd/ntpd.mdoc.in @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTPD @NTPD_MS@ User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntpd-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:30 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:31:02 PM by AutoGen 5.18.5 .\" From the definitions ntpd-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/ntpd/refclock_local.c b/contrib/ntp/ntpd/refclock_local.c index d816c55..8c0f74f 100644 --- a/contrib/ntp/ntpd/refclock_local.c +++ b/contrib/ntp/ntpd/refclock_local.c @@ -205,6 +205,7 @@ local_poll( pp->disp = 0; pp->jitter = 0; #else /* KERNEL_PLL LOCKCLOCK */ + pp->leap = LEAP_NOWARNING; pp->disp = DISPERSION; pp->jitter = 0; #endif /* KERNEL_PLL LOCKCLOCK */ diff --git a/contrib/ntp/ntpd/refclock_parse.c b/contrib/ntp/ntpd/refclock_parse.c index 8e90595..eb69dcb 100644 --- a/contrib/ntp/ntpd/refclock_parse.c +++ b/contrib/ntp/ntpd/refclock_parse.c @@ -1630,9 +1630,9 @@ list_err( static char * mkreadable( char *buffer, - long blen, + size_t blen, const char *src, - u_long srclen, + size_t srclen, int hex ) { diff --git a/contrib/ntp/ntpd/refclock_shm.c b/contrib/ntp/ntpd/refclock_shm.c index 6ab5d02..f3e7f51 100644 --- a/contrib/ntp/ntpd/refclock_shm.c +++ b/contrib/ntp/ntpd/refclock_shm.c @@ -381,7 +381,8 @@ static inline void memory_barrier(void) static enum segstat_t shm_query(volatile struct shmTime *shm_in, struct shm_stat_t *shm_stat) /* try to grab a sample from the specified SHM segment */ { - volatile struct shmTime shmcopy, *shm = shm_in; + struct shmTime shmcopy; + volatile struct shmTime *shm = shm_in; volatile int cnt; unsigned int cns_new, rns_new; @@ -418,7 +419,7 @@ static enum segstat_t shm_query(volatile struct shmTime *shm_in, struct shm_stat * (b) memset compiles to an uninterruptible single-instruction bitblt. */ memory_barrier(); - memcpy((void *)&shmcopy, (void *)shm, sizeof(struct shmTime)); + memcpy(&shmcopy, (void*)(uintptr_t)shm, sizeof(struct shmTime)); shm->valid = 0; memory_barrier(); diff --git a/contrib/ntp/ntpd/refclock_true.c b/contrib/ntp/ntpd/refclock_true.c index 67ba6df..2799f3e 100644 --- a/contrib/ntp/ntpd/refclock_true.c +++ b/contrib/ntp/ntpd/refclock_true.c @@ -637,7 +637,7 @@ true_send( pp = peer->procptr; if (!(pp->sloppyclockflag & CLK_FLAG1)) { - int len = strlen(cmd); + size_t len = strlen(cmd); true_debug(peer, "Send '%s'\n", cmd); if (write(pp->io.fd, cmd, (unsigned)len) != len) diff --git a/contrib/ntp/ntpd/refclock_tsyncpci.c b/contrib/ntp/ntpd/refclock_tsyncpci.c index e70a7cf..e14a3fd 100644 --- a/contrib/ntp/ntpd/refclock_tsyncpci.c +++ b/contrib/ntp/ntpd/refclock_tsyncpci.c @@ -549,7 +549,7 @@ static void tsync_poll(int unit, struct peer *peer) memcpy(ppsRef, pRefObj->pps, TSYNC_REF_LEN); // Extract the Clock Service Time Scale and convert to correct byte order - memcpy(&tmscl, ((TIME_SCALE*)(it1->payloads)), sizeof(tmscl)); + memcpy(&tmscl, it1->payloads, sizeof(tmscl)); tmscl = ntohl(tmscl); // Extract leap second info from ioctl payload and perform byte swapping diff --git a/contrib/ntp/ntpdate/ntpdate.c b/contrib/ntp/ntpdate/ntpdate.c index 9831929..a427160 100644 --- a/contrib/ntp/ntpdate/ntpdate.c +++ b/contrib/ntp/ntpdate/ntpdate.c @@ -561,8 +561,8 @@ ntpdatemain ( nfound = poll(rdfdes, (unsigned int)nbsock, timeout.tv_sec * 1000); #else - nfound = select(maxfd, &rdfdes, (fd_set *)0, - (fd_set *)0, &timeout); + nfound = select(maxfd, &rdfdes, NULL, NULL, + &timeout); #endif if (nfound > 0) input_handler(); @@ -696,7 +696,7 @@ transmit( * If not, just timestamp it and send it away. */ if (sys_authenticate) { - int len; + size_t len; xpkt.exten[0] = htonl(sys_authkey); get_systime(&server->xmt); @@ -808,11 +808,11 @@ receive( printf("receive: rpkt keyid=%ld sys_authkey=%ld decrypt=%ld\n", (long int)ntohl(rpkt->exten[0]), (long int)sys_authkey, (long int)authdecrypt(sys_authkey, (u_int32 *)rpkt, - LEN_PKT_NOMAC, (int)(rbufp->recv_length - LEN_PKT_NOMAC))); + LEN_PKT_NOMAC, (size_t)(rbufp->recv_length - LEN_PKT_NOMAC))); if (has_mac && ntohl(rpkt->exten[0]) == sys_authkey && authdecrypt(sys_authkey, (u_int32 *)rpkt, LEN_PKT_NOMAC, - (int)(rbufp->recv_length - LEN_PKT_NOMAC))) + (size_t)(rbufp->recv_length - LEN_PKT_NOMAC))) is_authentic = 1; if (debug) printf("receive: authentication %s\n", @@ -1888,7 +1888,7 @@ input_handler(void) #else fd_set fds; #endif - int fdc = 0; + SOCKET fdc = 0; /* * Do a poll to see if we have data @@ -1912,7 +1912,7 @@ input_handler(void) #else fds = fdmask; - n = select(maxfd, &fds, (fd_set *)0, (fd_set *)0, &tvzero); + n = select(maxfd, &fds, NULL, NULL, &tvzero); /* * Determine which socket received data diff --git a/contrib/ntp/ntpdc/invoke-ntpdc.texi b/contrib/ntp/ntpdc/invoke-ntpdc.texi index 0146069..f8283de 100644 --- a/contrib/ntp/ntpdc/invoke-ntpdc.texi +++ b/contrib/ntp/ntpdc/invoke-ntpdc.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntpdc.texi) # -# It has been AutoGen-ed October 21, 2015 at 12:38:54 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:31:26 PM by AutoGen 5.18.5 # From the definitions ntpdc-opts.def # and the template file agtexi-cmd.tpl @end ignore @@ -76,7 +76,7 @@ with a status code of 0. @exampleindent 0 @example -ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p4 +ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p5 Usage: ntpdc [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... [ host ...] Flg Arg Option-Name Description -4 no ipv4 Force IPv4 DNS name resolution diff --git a/contrib/ntp/ntpdc/ntpdc-opts.c b/contrib/ntp/ntpdc/ntpdc-opts.c index 6b4617a..da89ee2 100644 --- a/contrib/ntp/ntpdc/ntpdc-opts.c +++ b/contrib/ntp/ntpdc/ntpdc-opts.c @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (ntpdc-opts.c) * - * It has been AutoGen-ed October 21, 2015 at 12:38:40 PM by AutoGen 5.18.5 + * It has been AutoGen-ed January 7, 2016 at 11:31:12 PM by AutoGen 5.18.5 * From the definitions ntpdc-opts.def * and the template file options * @@ -69,7 +69,7 @@ extern FILE * option_usage_fp; * static const strings for ntpdc options */ static char const ntpdc_opt_strs[1911] = -/* 0 */ "ntpdc 4.2.8p4\n" +/* 0 */ "ntpdc 4.2.8p5\n" "Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n" "This is free software. It is licensed for use, modification and\n" "redistribution under the terms of the NTP License, copies of which\n" @@ -128,14 +128,14 @@ static char const ntpdc_opt_strs[1911] = /* 1694 */ "no-load-opts\0" /* 1707 */ "no\0" /* 1710 */ "NTPDC\0" -/* 1716 */ "ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p4\n" +/* 1716 */ "ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p5\n" "Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n\0" /* 1846 */ "$HOME\0" /* 1852 */ ".\0" /* 1854 */ ".ntprc\0" /* 1861 */ "http://bugs.ntp.org, bugs@ntp.org\0" /* 1895 */ "\n\0" -/* 1897 */ "ntpdc 4.2.8p4"; +/* 1897 */ "ntpdc 4.2.8p5"; /** * ipv4 option description with @@ -796,7 +796,7 @@ static void bogus_function(void) { translate option names. */ /* referenced via ntpdcOptions.pzCopyright */ - puts(_("ntpdc 4.2.8p4\n\ + puts(_("ntpdc 4.2.8p5\n\ Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n\ This is free software. It is licensed for use, modification and\n\ redistribution under the terms of the NTP License, copies of which\n\ @@ -862,14 +862,14 @@ implied warranty.\n")); puts(_("load options from a config file")); /* referenced via ntpdcOptions.pzUsageTitle */ - puts(_("ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p4\n\ + puts(_("ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p5\n\ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n")); /* referenced via ntpdcOptions.pzExplain */ puts(_("\n")); /* referenced via ntpdcOptions.pzFullVersion */ - puts(_("ntpdc 4.2.8p4")); + puts(_("ntpdc 4.2.8p5")); /* referenced via ntpdcOptions.pzFullUsage */ puts(_("<<<NOT-FOUND>>>")); diff --git a/contrib/ntp/ntpdc/ntpdc-opts.h b/contrib/ntp/ntpdc/ntpdc-opts.h index d2494fe..d3326a7 100644 --- a/contrib/ntp/ntpdc/ntpdc-opts.h +++ b/contrib/ntp/ntpdc/ntpdc-opts.h @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (ntpdc-opts.h) * - * It has been AutoGen-ed October 21, 2015 at 12:38:39 PM by AutoGen 5.18.5 + * It has been AutoGen-ed January 7, 2016 at 11:31:11 PM by AutoGen 5.18.5 * From the definitions ntpdc-opts.def * and the template file options * @@ -83,9 +83,9 @@ typedef enum { /** count of all options for ntpdc */ #define OPTION_CT 15 /** ntpdc version */ -#define NTPDC_VERSION "4.2.8p4" +#define NTPDC_VERSION "4.2.8p5" /** Full ntpdc version text */ -#define NTPDC_FULL_VERSION "ntpdc 4.2.8p4" +#define NTPDC_FULL_VERSION "ntpdc 4.2.8p5" /** * Interface defines for all options. Replace "n" with the UPPER_CASED diff --git a/contrib/ntp/ntpdc/ntpdc.1ntpdcman b/contrib/ntp/ntpdc/ntpdc.1ntpdcman index 71fd545..3e78896 100644 --- a/contrib/ntp/ntpdc/ntpdc.1ntpdcman +++ b/contrib/ntp/ntpdc/ntpdc.1ntpdcman @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntpdc 1ntpdcman "21 Oct 2015" "4.2.8p4" "User Commands" +.TH ntpdc 1ntpdcman "07 Jan 2016" "4.2.8p5" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-Gvay7L/ag-Svaq6L) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-EXaGzs/ag-QXayys) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:51 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:31:22 PM by AutoGen 5.18.5 .\" From the definitions ntpdc-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/ntpdc/ntpdc.1ntpdcmdoc b/contrib/ntp/ntpdc/ntpdc.1ntpdcmdoc index ff7656c..df53d89 100644 --- a/contrib/ntp/ntpdc/ntpdc.1ntpdcmdoc +++ b/contrib/ntp/ntpdc/ntpdc.1ntpdcmdoc @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTPDC 1ntpdcmdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntpdc-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:57 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:31:29 PM by AutoGen 5.18.5 .\" From the definitions ntpdc-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/ntpdc/ntpdc.c b/contrib/ntp/ntpdc/ntpdc.c index ab17788..bef9ca3 100644 --- a/contrib/ntp/ntpdc/ntpdc.c +++ b/contrib/ntp/ntpdc/ntpdc.c @@ -32,6 +32,7 @@ #include "ntp_libopts.h" #include "ntpdc-opts.h" +#include "safecast.h" #ifdef SYS_VXWORKS /* vxWorks needs mode flag -casey*/ @@ -74,8 +75,8 @@ int ntpdcmain (int, char **); static int openhost (const char *); static int sendpkt (void *, size_t); static void growpktdata (void); -static int getresponse (int, int, int *, int *, char **, int); -static int sendrequest (int, int, int, u_int, size_t, char *); +static int getresponse (int, int, size_t *, size_t *, const char **, size_t); +static int sendrequest (int, int, int, size_t, size_t, const char *); static void getcmds (void); static RETSIGTYPE abortcmd (int); static void docmd (const char *); @@ -526,10 +527,11 @@ openhost( #ifdef SYS_VXWORKS if (connect(sockfd, (struct sockaddr *)&hostaddr, - sizeof(hostaddr)) == -1) { + sizeof(hostaddr)) == -1) #else - if (connect(sockfd, ai->ai_addr, ai->ai_addrlen) == -1) { + if (connect(sockfd, ai->ai_addr, ai->ai_addrlen) == -1) #endif /* SYS_VXWORKS */ + { error("connect"); exit(-1); } @@ -582,18 +584,18 @@ static int getresponse( int implcode, int reqcode, - int *ritems, - int *rsize, - char **rdata, - int esize + size_t *ritems, + size_t *rsize, + const char **rdata, + size_t esize ) { struct resp_pkt rpkt; struct sock_timeval tvo; - int items; - int i; - int size; - int datasize; + size_t items; + size_t i; + size_t size; + size_t datasize; char *datap; char *tmp_data; char haveseq[MAXSEQ+1]; @@ -603,7 +605,7 @@ getresponse( int seq; fd_set fds; ssize_t n; - int pad; + size_t pad; /* * This is pretty tricky. We may get between 1 and many packets @@ -628,8 +630,7 @@ getresponse( tvo = tvsout; FD_SET(sockfd, &fds); - n = select(sockfd+1, &fds, (fd_set *)0, (fd_set *)0, &tvo); - + n = select(sockfd+1, &fds, NULL, NULL, &tvo); if (n == -1) { warning("select fails"); return -1; @@ -640,7 +641,8 @@ getresponse( */ if (firstpkt) { (void) fprintf(stderr, - "%s: timed out, nothing received\n", currenthost); + "%s: timed out, nothing received\n", + currenthost); return ERR_TIMEOUT; } else { (void) fprintf(stderr, @@ -740,7 +742,7 @@ getresponse( if ((size_t)datasize > (n-RESP_HEADER_SIZE)) { if (debug) printf( - "Received items %d, size %d (total %d), data in packet is %zu\n", + "Received items %zu, size %zu (total %zu), data in packet is %zu\n", items, size, datasize, n-RESP_HEADER_SIZE); goto again; } @@ -751,7 +753,7 @@ getresponse( */ if (!firstpkt && size != *rsize) { if (debug) - printf("Received itemsize %d, previous %d\n", + printf("Received itemsize %zu, previous %zu\n", size, *rsize); goto again; } @@ -781,7 +783,7 @@ getresponse( * So far, so good. Copy this data into the output array. */ if ((datap + datasize + (pad * items)) > (pktdata + pktdatasize)) { - int offset = datap - pktdata; + size_t offset = datap - pktdata; growpktdata(); *rdata = pktdata; /* might have been realloced ! */ datap = pktdata + offset; @@ -844,9 +846,9 @@ sendrequest( int implcode, int reqcode, int auth, - u_int qitems, + size_t qitems, size_t qsize, - char *qdata + const char *qdata ) { struct req_pkt qpkt; @@ -855,7 +857,7 @@ sendrequest( u_long key_id; l_fp ts; l_fp * ptstamp; - int maclen; + size_t maclen; char * pass; ZERO(qpkt); @@ -918,13 +920,14 @@ sendrequest( get_systime(&ts); L_ADD(&ts, &delay_time); HTONL_FP(&ts, ptstamp); - maclen = authencrypt(info_auth_keyid, (void *)&qpkt, reqsize); + maclen = authencrypt( + info_auth_keyid, (void *)&qpkt, size2int_chk(reqsize)); if (!maclen) { fprintf(stderr, "Key not found\n"); return 1; } else if (maclen != (int)(info_auth_hashlen + sizeof(keyid_t))) { fprintf(stderr, - "%d octet MAC, %zu expected with %zu octet digest\n", + "%zu octet MAC, %zu expected with %zu octet digest\n", maclen, (info_auth_hashlen + sizeof(keyid_t)), info_auth_hashlen); return 1; @@ -941,12 +944,12 @@ doquery( int implcode, int reqcode, int auth, - int qitems, - int qsize, - char *qdata, - int *ritems, - int *rsize, - char **rdata, + size_t qitems, + size_t qsize, + const char *qdata, + size_t *ritems, + size_t *rsize, + const char **rdata, int quiet_mask, int esize ) @@ -972,8 +975,7 @@ again: tvzero.tv_sec = tvzero.tv_usec = 0; FD_ZERO(&fds); FD_SET(sockfd, &fds); - res = select(sockfd+1, &fds, (fd_set *)0, (fd_set *)0, &tvzero); - + res = select(sockfd+1, &fds, NULL, NULL, &tvzero); if (res == -1) { warning("polling select"); return -1; @@ -1271,7 +1273,7 @@ findcmd( ) { register struct xcmd *cl; - register int clen; + size_t clen; int nmatch; struct xcmd *nearmatch = NULL; struct xcmd *clist; @@ -1384,7 +1386,7 @@ getarg( return 0; } argp->uval *= 10; - argp->uval += (cp - digits); + argp->uval += (u_long)(cp - digits); } while (*(++np) != '\0'); if (isneg) { diff --git a/contrib/ntp/ntpdc/ntpdc.h b/contrib/ntp/ntpdc/ntpdc.h index 6da4a5c..4dfd1eb 100644 --- a/contrib/ntp/ntpdc/ntpdc.h +++ b/contrib/ntp/ntpdc/ntpdc.h @@ -63,5 +63,5 @@ extern int impl_ver; extern int showhostnames; extern int s_port; -extern int doquery (int, int, int, int, int, char *, int *, int *, char **, int, int); +extern int doquery (int, int, int, size_t, size_t, const char *, size_t *, size_t *, const char **, int, int); extern const char * nntohost (sockaddr_u *); diff --git a/contrib/ntp/ntpdc/ntpdc.html b/contrib/ntp/ntpdc/ntpdc.html index cc552ca..107af9b 100644 --- a/contrib/ntp/ntpdc/ntpdc.html +++ b/contrib/ntp/ntpdc/ntpdc.html @@ -36,7 +36,7 @@ display the time offset of the system clock relative to the server clock. Run as root, it can correct the system clock to this offset as well. It can be run as an interactive command or from a cron job. - <p>This document applies to version 4.2.8p4 of <code>ntpdc</code>. + <p>This document applies to version 4.2.8p5 of <code>ntpdc</code>. <p>The program implements the SNTP protocol as defined by RFC 5905, the NTPv4 IETF specification. @@ -152,7 +152,7 @@ the usage text by passing it through a pager program. used to select the program, defaulting to <span class="file">more</span>. Both will exit with a status code of 0. -<pre class="example">ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p4 +<pre class="example">ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p5 Usage: ntpdc [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...] Flg Arg Option-Name Description -4 no ipv4 Force IPv4 DNS name resolution diff --git a/contrib/ntp/ntpdc/ntpdc.man.in b/contrib/ntp/ntpdc/ntpdc.man.in index f5df744..6662438 100644 --- a/contrib/ntp/ntpdc/ntpdc.man.in +++ b/contrib/ntp/ntpdc/ntpdc.man.in @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntpdc @NTPDC_MS@ "21 Oct 2015" "4.2.8p4" "User Commands" +.TH ntpdc @NTPDC_MS@ "07 Jan 2016" "4.2.8p5" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-Gvay7L/ag-Svaq6L) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-EXaGzs/ag-QXayys) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:51 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:31:22 PM by AutoGen 5.18.5 .\" From the definitions ntpdc-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/ntpdc/ntpdc.mdoc.in b/contrib/ntp/ntpdc/ntpdc.mdoc.in index 5a6e292..2e2fd31 100644 --- a/contrib/ntp/ntpdc/ntpdc.mdoc.in +++ b/contrib/ntp/ntpdc/ntpdc.mdoc.in @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTPDC @NTPDC_MS@ User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntpdc-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:57 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:31:29 PM by AutoGen 5.18.5 .\" From the definitions ntpdc-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/ntpdc/ntpdc_ops.c b/contrib/ntp/ntpdc/ntpdc_ops.c index be8ffa2..2f57768 100644 --- a/contrib/ntp/ntpdc/ntpdc_ops.c +++ b/contrib/ntp/ntpdc/ntpdc_ops.c @@ -31,9 +31,9 @@ /* * utility functions */ -static int checkitems (int, FILE *); -static int checkitemsize (int, int); -static int check1item (int, FILE *); +static int checkitems (size_t, FILE *); +static int checkitemsize (size_t, size_t); +static int check1item (size_t, FILE *); /* * Declarations for command handlers in here @@ -288,7 +288,7 @@ do { \ */ static int checkitems( - int items, + size_t items, FILE *fp ) { @@ -305,14 +305,14 @@ checkitems( */ static int checkitemsize( - int itemsize, - int expected + size_t itemsize, + size_t expected ) { if (itemsize != expected) { (void) fprintf(stderr, - "***Incorrect item size returned by remote host (%d should be %d)\n", - itemsize, expected); + "***Incorrect item size returned by remote host (%lu should be %lu)\n", + (u_long)itemsize, (u_long)expected); return 0; } return 1; @@ -324,7 +324,7 @@ checkitemsize( */ static int check1item( - int items, + size_t items, FILE *fp ) { @@ -333,8 +333,8 @@ check1item( return 0; } if (items > 1) { - (void) fprintf(fp, "Expected one item in response, got %d\n", - items); + (void) fprintf(fp, "Expected one item in response, got %lu\n", + (u_long)items); return 0; } return 1; @@ -353,8 +353,8 @@ peerlist( { struct info_peer_list *plist; sockaddr_u paddr; - int items; - int itemsize; + size_t items; + size_t itemsize; int res; again: @@ -430,8 +430,8 @@ dopeers( struct info_peer_summary *plist; sockaddr_u dstadr; sockaddr_u srcadr; - int items; - int itemsize; + size_t items; + size_t itemsize; int ntp_poll; int res; int c; @@ -679,10 +679,10 @@ showpeer( struct info_peer *pp; /* 4 is the maximum number of peers which will fit in a packet */ struct info_peer_list *pl, plist[min(MAXARGS, 4)]; - int qitemlim; - int qitems; - int items; - int itemsize; + size_t qitemlim; + size_t qitems; + size_t items; + size_t itemsize; int res; int sendsize; @@ -753,12 +753,12 @@ peerstats( /* 4 is the maximum number of peers which will fit in a packet */ struct info_peer_list *pl, plist[min(MAXARGS, 4)]; sockaddr_u src, dst; - int qitemlim; - int qitems; - int items; - int itemsize; + size_t qitemlim; + size_t qitems; + size_t items; + size_t itemsize; int res; - int sendsize; + size_t sendsize; again: if (impl_ver == IMPL_XNTPD) @@ -871,8 +871,8 @@ loopinfo( ) { struct info_loop *il; - int items; - int itemsize; + size_t items; + size_t itemsize; int oneline = 0; int res; l_fp tempts; @@ -946,8 +946,8 @@ sysinfo( { struct info_sys *is; sockaddr_u peeraddr; - int items; - int itemsize; + size_t items; + size_t itemsize; int res; l_fp tempts; @@ -1035,8 +1035,8 @@ sysstats( ) { struct info_sys_stats *ss; - int items; - int itemsize; + size_t items; + size_t itemsize; int res; again: @@ -1101,8 +1101,8 @@ iostats( ) { struct info_io_stats *io; - int items; - int itemsize; + size_t items; + size_t itemsize; int res; again: @@ -1162,8 +1162,8 @@ memstats( { struct info_mem_stats *mem; int i; - int items; - int itemsize; + size_t items; + size_t itemsize; int res; again: @@ -1219,8 +1219,8 @@ timerstats( ) { struct info_timer_stats *tim; - int items; - int itemsize; + size_t items; + size_t itemsize; int res; again: @@ -1314,9 +1314,9 @@ doconfig( ) { struct conf_peer cpeer; - int items; - int itemsize; - char *dummy; + size_t items; + size_t itemsize; + const char *dummy; u_long keyid; u_int version; u_char minpoll; @@ -1480,13 +1480,13 @@ unconfig( { /* 8 is the maximum number of peers which will fit in a packet */ struct conf_unpeer *pl, plist[min(MAXARGS, 8)]; - int qitemlim; - int qitems; - int items; - int itemsize; - char *dummy; + size_t qitemlim; + size_t qitems; + size_t items; + size_t itemsize; + const char *dummy; int res; - int sendsize; + size_t sendsize; again: if (impl_ver == IMPL_XNTPD) @@ -1564,9 +1564,9 @@ doset( ) { struct conf_sys_flags sys; - int items; - int itemsize; - char *dummy; + size_t items; + size_t itemsize; + const char *dummy; int res; sys.flags = 0; @@ -1675,8 +1675,8 @@ reslist( struct info_restrict *rl; sockaddr_u resaddr; sockaddr_u maskaddr; - int items; - int itemsize; + size_t items; + size_t itemsize; int res; int skip; const char *addr; @@ -1827,9 +1827,9 @@ do_restrict( ) { struct conf_restrict cres; - int items; - int itemsize; - char *dummy; + size_t items; + size_t itemsize; + const char *dummy; u_int32 num; u_long bit; int i; @@ -1946,14 +1946,14 @@ monlist( FILE *fp ) { - char *struct_star; - struct info_monitor *ml; - struct info_monitor_1 *m1; - struct old_info_monitor *oml; + const char *struct_star; + const struct info_monitor *ml; + const struct info_monitor_1 *m1; + const struct old_info_monitor *oml; sockaddr_u addr; sockaddr_u dstadr; - int items; - int itemsize; + size_t items; + size_t itemsize; int res; int version = -1; @@ -1987,7 +1987,7 @@ again: if (itemsize == sizeof(struct info_monitor_1) || itemsize == v4sizeof(struct info_monitor_1)) { - m1 = (void *)struct_star; + m1 = (const void*)struct_star; fprintf(fp, "remote address port local address count m ver rstr avgint lstint\n"); fprintf(fp, @@ -2014,7 +2014,7 @@ again: } else if (itemsize == sizeof(struct info_monitor) || itemsize == v4sizeof(struct info_monitor)) { - ml = (void *) struct_star; + ml = (const void *)struct_star; fprintf(fp, " address port count mode ver rstr avgint lstint\n"); fprintf(fp, @@ -2039,7 +2039,7 @@ again: } } else if (itemsize == sizeof(struct old_info_monitor)) { - oml = (void *)struct_star; + oml = (const void *)struct_star; fprintf(fp, " address port count mode version lasttime firsttime\n"); fprintf(fp, @@ -2091,9 +2091,9 @@ reset( ) { struct reset_flags rflags; - int items; - int itemsize; - char *dummy; + size_t items; + size_t itemsize; + const char *dummy; int i; size_t res; int err; @@ -2148,13 +2148,13 @@ preset( { /* 8 is the maximum number of peers which will fit in a packet */ struct conf_unpeer *pl, plist[min(MAXARGS, 8)]; - int qitemlim; - int qitems; - int items; - int itemsize; - char *dummy; + size_t qitemlim; + size_t qitems; + size_t items; + size_t itemsize; + const char *dummy; int res; - int sendsize; + size_t sendsize; again: if (impl_ver == IMPL_XNTPD) @@ -2205,9 +2205,9 @@ readkeys( FILE *fp ) { - int items; - int itemsize; - char *dummy; + size_t items; + size_t itemsize; + const char *dummy; int res; again: @@ -2263,9 +2263,9 @@ do_trustkey( { u_long keyids[MAXARGS]; size_t i; - int items; - int itemsize; - char *dummy; + size_t items; + size_t itemsize; + const char *dummy; int ritems; int res; @@ -2302,8 +2302,8 @@ authinfo( ) { struct info_auth *ia; - int items; - int itemsize; + size_t items; + size_t itemsize; int res; again: @@ -2356,11 +2356,11 @@ traps( FILE *fp ) { - int i; + size_t i; struct info_trap *it; sockaddr_u trap_addr, local_addr; - int items; - int itemsize; + size_t items; + size_t itemsize; int res; again: @@ -2446,9 +2446,9 @@ do_addclr_trap( ) { struct conf_trap ctrap; - int items; - int itemsize; - char *dummy; + size_t items; + size_t itemsize; + const char *dummy; int res; int sendsize; @@ -2545,9 +2545,9 @@ do_changekey( ) { u_long key; - int items; - int itemsize; - char *dummy; + size_t items; + size_t itemsize; + const char *dummy; int res; @@ -2581,8 +2581,8 @@ ctlstats( ) { struct info_control *ic; - int items; - int itemsize; + size_t items; + size_t itemsize; int res; again: @@ -2648,10 +2648,10 @@ clockstat( struct info_clock *cl; /* 8 is the maximum number of clocks which will fit in a packet */ u_long clist[min(MAXARGS, 8)]; - int qitemlim; - int qitems; - int items; - int itemsize; + size_t qitemlim; + size_t qitems; + size_t items; + size_t itemsize; int res; l_fp ts; struct clktype *clk; @@ -2735,9 +2735,9 @@ fudge( ) { struct conf_fudge fudgedata; - int items; - int itemsize; - char *dummy; + size_t items; + size_t itemsize; + const char *dummy; l_fp ts; int res; long val; @@ -2822,10 +2822,10 @@ clkbug( /* 8 is the maximum number of clocks which will fit in a packet */ u_long clist[min(MAXARGS, 8)]; u_int32 ltemp; - int qitemlim; - int qitems; - int items; - int itemsize; + size_t qitemlim; + size_t qitems; + size_t items; + size_t itemsize; int res; int needsp; l_fp ts; @@ -2916,8 +2916,8 @@ kerninfo( ) { struct info_kernel *ik; - int items; - int itemsize; + size_t items; + size_t itemsize; int res; unsigned status; double tscale = 1e-6; @@ -3050,8 +3050,8 @@ static void iflist( FILE *fp, struct info_if_stats *ifs, - int items, - int itemsize, + size_t items, + size_t itemsize, int res ) { @@ -3113,8 +3113,8 @@ get_if_stats( ) { struct info_if_stats *ifs; - int items; - int itemsize; + size_t items; + size_t itemsize; int res; res = doquery(impl_ver, REQ_IF_STATS, 1, 0, 0, (char *)NULL, &items, @@ -3131,8 +3131,8 @@ do_if_reload( ) { struct info_if_stats *ifs; - int items; - int itemsize; + size_t items; + size_t itemsize; int res; res = doquery(impl_ver, REQ_IF_RELOAD, 1, 0, 0, (char *)NULL, &items, diff --git a/contrib/ntp/ntpq/invoke-ntpq.texi b/contrib/ntp/ntpq/invoke-ntpq.texi index fa0f5d7..b01127c 100644 --- a/contrib/ntp/ntpq/invoke-ntpq.texi +++ b/contrib/ntp/ntpq/invoke-ntpq.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntpq.texi) # -# It has been AutoGen-ed October 21, 2015 at 12:39:27 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:32:00 PM by AutoGen 5.18.5 # From the definitions ntpq-opts.def # and the template file agtexi-cmd.tpl @end ignore @@ -847,7 +847,7 @@ with a status code of 0. @exampleindent 0 @example -ntpq - standard NTP query program - Ver. 4.2.8p4 +ntpq - standard NTP query program - Ver. 4.2.8p5 Usage: ntpq [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... [ host ...] Flg Arg Option-Name Description -4 no ipv4 Force IPv4 DNS name resolution diff --git a/contrib/ntp/ntpq/libntpq.c b/contrib/ntp/ntpq/libntpq.c index becd956..3070e47 100644 --- a/contrib/ntp/ntpq/libntpq.c +++ b/contrib/ntp/ntpq/libntpq.c @@ -132,7 +132,7 @@ ntpq_getvar( { char * name; char * value; - int idatalen; + size_t idatalen; value = NULL; idatalen = (int)datalen; @@ -181,8 +181,8 @@ int ntpq_queryhost(unsigned short VARSET, unsigned short association, char *resu { const char *datap; int res; - int dsize; - u_short rstatus; + size_t dsize; + u_short rstatus; if ( numhosts > 0 ) res = doquery(VARSET,association,0,0, (char *)0, &rstatus, &dsize, &datap); @@ -417,7 +417,7 @@ ntpq_read_assoc_peervars( { const char * datap; int res; - int dsize; + size_t dsize; u_short rstatus; res = doquery(CTL_OP_READVAR, associd, 0, 0, NULL, &rstatus, @@ -474,24 +474,22 @@ ntpq_read_sysvars( { const char * datap; int res; - int i_dsize; size_t dsize; u_short rstatus; res = doquery(CTL_OP_READVAR, 0, 0, 0, NULL, &rstatus, - &i_dsize, &datap); + &dsize, &datap); if (res != 0) return 0; - if (i_dsize == 0) { + if (dsize == 0) { if (numhosts > 1) fprintf(stderr, "server=%s ", currenthost); fprintf(stderr, "***No sysvar information returned\n"); return 0; } else { - dsize = max(0, i_dsize); dsize = min(dsize, maxsize); memcpy(resultbuf, datap, dsize); } @@ -661,7 +659,7 @@ ntpq_read_assoc_clockvars( { const char *datap; int res; - int dsize; + size_t dsize; u_short rstatus; res = ntpq_doquerylist(ntpq_varlist, CTL_OP_READCLOCK, associd, diff --git a/contrib/ntp/ntpq/libntpq.h b/contrib/ntp/ntpq/libntpq.h index 84a622b..74caf27 100644 --- a/contrib/ntp/ntpq/libntpq.h +++ b/contrib/ntp/ntpq/libntpq.h @@ -106,4 +106,4 @@ extern int ntpq_read_assoc_clockvars( associd_t associd, char *resultbuf, int ma extern int ntpq_dogetassoc(void); extern char ntpq_decodeaddrtype(sockaddr_u *sock); extern int ntpq_doquerylist(struct ntpq_varlist *, int, associd_t, int, - u_short *, int *, const char **datap); + u_short *, size_t *, const char **datap); diff --git a/contrib/ntp/ntpq/libntpq_subs.c b/contrib/ntp/ntpq/libntpq_subs.c index e53b419..b232065 100644 --- a/contrib/ntp/ntpq/libntpq_subs.c +++ b/contrib/ntp/ntpq/libntpq_subs.c @@ -42,7 +42,7 @@ ntpq_doquerylist( associd_t associd, int auth, u_short *rstatus, - int *dsize, + size_t *dsize, const char **datap ) { diff --git a/contrib/ntp/ntpq/ntpq-opts.c b/contrib/ntp/ntpq/ntpq-opts.c index 2232928..69f4881 100644 --- a/contrib/ntp/ntpq/ntpq-opts.c +++ b/contrib/ntp/ntpq/ntpq-opts.c @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (ntpq-opts.c) * - * It has been AutoGen-ed October 21, 2015 at 12:39:00 PM by AutoGen 5.18.5 + * It has been AutoGen-ed January 7, 2016 at 11:31:32 PM by AutoGen 5.18.5 * From the definitions ntpq-opts.def * and the template file options * @@ -69,7 +69,7 @@ extern FILE * option_usage_fp; * static const strings for ntpq options */ static char const ntpq_opt_strs[1925] = -/* 0 */ "ntpq 4.2.8p4\n" +/* 0 */ "ntpq 4.2.8p5\n" "Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n" "This is free software. It is licensed for use, modification and\n" "redistribution under the terms of the NTP License, copies of which\n" @@ -129,13 +129,13 @@ static char const ntpq_opt_strs[1925] = /* 1723 */ "no-load-opts\0" /* 1736 */ "no\0" /* 1739 */ "NTPQ\0" -/* 1744 */ "ntpq - standard NTP query program - Ver. 4.2.8p4\n" +/* 1744 */ "ntpq - standard NTP query program - Ver. 4.2.8p5\n" "Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n\0" /* 1863 */ "$HOME\0" /* 1869 */ ".\0" /* 1871 */ ".ntprc\0" /* 1878 */ "http://bugs.ntp.org, bugs@ntp.org\0" -/* 1912 */ "ntpq 4.2.8p4"; +/* 1912 */ "ntpq 4.2.8p5"; /** * ipv4 option description with @@ -786,7 +786,7 @@ static void bogus_function(void) { translate option names. */ /* referenced via ntpqOptions.pzCopyright */ - puts(_("ntpq 4.2.8p4\n\ + puts(_("ntpq 4.2.8p5\n\ Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n\ This is free software. It is licensed for use, modification and\n\ redistribution under the terms of the NTP License, copies of which\n\ @@ -852,11 +852,11 @@ implied warranty.\n")); puts(_("load options from a config file")); /* referenced via ntpqOptions.pzUsageTitle */ - puts(_("ntpq - standard NTP query program - Ver. 4.2.8p4\n\ + puts(_("ntpq - standard NTP query program - Ver. 4.2.8p5\n\ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n")); /* referenced via ntpqOptions.pzFullVersion */ - puts(_("ntpq 4.2.8p4")); + puts(_("ntpq 4.2.8p5")); /* referenced via ntpqOptions.pzFullUsage */ puts(_("<<<NOT-FOUND>>>")); diff --git a/contrib/ntp/ntpq/ntpq-opts.h b/contrib/ntp/ntpq/ntpq-opts.h index f82ccae..758817f 100644 --- a/contrib/ntp/ntpq/ntpq-opts.h +++ b/contrib/ntp/ntpq/ntpq-opts.h @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (ntpq-opts.h) * - * It has been AutoGen-ed October 21, 2015 at 12:39:00 PM by AutoGen 5.18.5 + * It has been AutoGen-ed January 7, 2016 at 11:31:32 PM by AutoGen 5.18.5 * From the definitions ntpq-opts.def * and the template file options * @@ -83,9 +83,9 @@ typedef enum { /** count of all options for ntpq */ #define OPTION_CT 15 /** ntpq version */ -#define NTPQ_VERSION "4.2.8p4" +#define NTPQ_VERSION "4.2.8p5" /** Full ntpq version text */ -#define NTPQ_FULL_VERSION "ntpq 4.2.8p4" +#define NTPQ_FULL_VERSION "ntpq 4.2.8p5" /** * Interface defines for all options. Replace "n" with the UPPER_CASED diff --git a/contrib/ntp/ntpq/ntpq-subs.c b/contrib/ntp/ntpq/ntpq-subs.c index 78143b3..438c7ca 100644 --- a/contrib/ntp/ntpq/ntpq-subs.c +++ b/contrib/ntp/ntpq/ntpq-subs.c @@ -22,9 +22,9 @@ static struct varlist *findlistvar (struct varlist *, char *); static void doaddvlist (struct varlist *, const char *); static void dormvlist (struct varlist *, const char *); static void doclearvlist (struct varlist *); -static void makequerydata (struct varlist *, int *, char *); +static void makequerydata (struct varlist *, size_t *, char *); static int doquerylist (struct varlist *, int, associd_t, int, - u_short *, int *, const char **); + u_short *, size_t *, const char **); static void doprintvlist (struct varlist *, FILE *); static void addvars (struct parse *, FILE *); static void rmvars (struct parse *, FILE *); @@ -56,7 +56,7 @@ static void authinfo (struct parse *, FILE *); static void pstats (struct parse *, FILE *); static long when (l_fp *, l_fp *, l_fp *); static char * prettyinterval (char *, size_t, long); -static int doprintpeers (struct varlist *, int, int, int, const char *, FILE *, int); +static int doprintpeers (struct varlist *, int, int, size_t, const char *, FILE *, int); static int dogetpeers (struct varlist *, associd_t, FILE *, int); static void dopeers (int, FILE *, int); static void peers (struct parse *, FILE *); @@ -343,7 +343,7 @@ typedef struct var_display_collection_tag { /* * other local function prototypes */ -void mrulist_ctrl_c_hook(void); +static int mrulist_ctrl_c_hook(void); static mru * add_mru(mru *); static int collect_mru_list(const char *, l_fp *); static int fetch_nonce(char *, size_t); @@ -440,7 +440,7 @@ doaddvlist( ) { struct varlist *vl; - int len; + size_t len; char *name; char *value; @@ -475,7 +475,7 @@ dormvlist( ) { struct varlist *vl; - int len; + size_t len; char *name; char *value; @@ -527,14 +527,14 @@ doclearvlist( static void makequerydata( struct varlist *vlist, - int *datalen, + size_t *datalen, char *data ) { register struct varlist *vl; register char *cp, *cpend; - register int namelen, valuelen; - register int totallen; + register size_t namelen, valuelen; + register size_t totallen; cp = data; cpend = data + *datalen; @@ -563,7 +563,7 @@ makequerydata( cp += valuelen; } } - *datalen = cp - data; + *datalen = (size_t)(cp - data); } @@ -577,12 +577,12 @@ doquerylist( associd_t associd, int auth, u_short *rstatus, - int *dsize, + size_t *dsize, const char **datap ) { char data[CTL_MAX_DATA_LEN]; - int datalen; + size_t datalen; datalen = sizeof(data); makequerydata(vlist, &datalen, data); @@ -686,7 +686,7 @@ dolist( { const char *datap; int res; - int dsize; + size_t dsize; u_short rstatus; int quiet; @@ -766,7 +766,7 @@ writelist( const char *datap; int res; associd_t associd; - int dsize; + size_t dsize; u_short rstatus; if (pcmd->nargs == 0) { @@ -808,8 +808,8 @@ readvar( ) { associd_t associd; - u_int tmpcount; - u_int u; + size_t tmpcount; + size_t u; int type; struct varlist tmplist[MAXLIST]; @@ -849,7 +849,7 @@ writevar( int res; associd_t associd; int type; - int dsize; + size_t dsize; u_short rstatus; struct varlist tmplist[MAXLIST]; @@ -1071,7 +1071,7 @@ dogetassoc( const char *datap; const u_short *pus; int res; - int dsize; + size_t dsize; u_short rstatus; res = doquery(CTL_OP_READSTAT, 0, 0, 0, (char *)0, &rstatus, @@ -1091,7 +1091,7 @@ dogetassoc( if (numhosts > 1) fprintf(stderr, "server=%s ", currenthost); fprintf(stderr, - "***Server returned %d octets, should be multiple of 4\n", + "***Server returned %zu octets, should be multiple of 4\n", dsize); return 0; } @@ -1379,7 +1379,7 @@ saveconfig( { const char *datap; int res; - int dsize; + size_t dsize; u_short rstatus; if (0 == pcmd->nargs) @@ -1396,7 +1396,7 @@ saveconfig( if (0 == dsize) fprintf(fp, "(no response message, curiously)"); else - fprintf(fp, "%.*s", dsize, datap); + fprintf(fp, "%.*s", (int)dsize, datap); /* cast is wobbly */ } @@ -1593,7 +1593,7 @@ doprintpeers( struct varlist *pvl, int associd, int rstatus, - int datalen, + size_t datalen, const char *data, FILE *fp, int af @@ -1602,7 +1602,7 @@ doprintpeers( char *name; char *value = NULL; int c; - int len; + size_t len; int have_srchost; int have_dstadr; int have_da_rid; @@ -1881,7 +1881,7 @@ dogetpeers( { const char *datap; int res; - int dsize; + size_t dsize; u_short rstatus; #ifdef notdef @@ -2186,7 +2186,7 @@ config ( { const char *cfgcmd; u_short rstatus; - int rsize; + size_t rsize; const char *rdata; char *resp; int res; @@ -2201,7 +2201,8 @@ config ( "Keyword = %s\n" "Command = %s\n", pcmd->keyword, cfgcmd); - res = doquery(CTL_OP_CONFIGURE, 0, 1, strlen(cfgcmd), cfgcmd, + res = doquery(CTL_OP_CONFIGURE, 0, 1, + strlen(cfgcmd), cfgcmd, &rstatus, &rsize, &rdata); if (res != 0) @@ -2251,7 +2252,7 @@ config_from_file ( ) { u_short rstatus; - int rsize; + size_t rsize; const char *rdata; int res; FILE *config_fd; @@ -2302,7 +2303,7 @@ config_from_file ( rsize--; if (rsize > 0 && '\r' == rdata[rsize - 1]) rsize--; - printf("Line No: %d %.*s: %s", i, rsize, rdata, + printf("Line No: %d %.*s: %s", i, (int)rsize, rdata, /* cast is wobbly */ config_cmd); } printf("Done sending file\n"); @@ -2319,9 +2320,9 @@ fetch_nonce( const char nonce_eq[] = "nonce="; int qres; u_short rstatus; - int rsize; + size_t rsize; const char * rdata; - int chars; + size_t chars; /* * Retrieve a nonce specific to this client to demonstrate to @@ -2338,7 +2339,7 @@ fetch_nonce( if ((size_t)rsize <= sizeof(nonce_eq) - 1 || strncmp(rdata, nonce_eq, sizeof(nonce_eq) - 1)) { fprintf(stderr, "unexpected nonce response format: %.*s\n", - rsize, rdata); + (int)rsize, rdata); /* cast is wobbly */ return FALSE; } chars = rsize - (sizeof(nonce_eq) - 1); @@ -2421,10 +2422,11 @@ add_mru( } while (0) -void +int mrulist_ctrl_c_hook(void) { mrulist_interrupted = TRUE; + return TRUE; } @@ -2449,10 +2451,10 @@ collect_mru_list( char req_buf[CTL_MAX_DATA_LEN]; char *req; char *req_end; - int chars; + size_t chars; int qres; u_short rstatus; - int rsize; + size_t rsize; const char *rdata; int limit; int frags; @@ -2495,11 +2497,6 @@ collect_mru_list( mon = emalloc_zero(cb); ZERO(*pnow); ZERO(last_older); - mrulist_interrupted = FALSE; - set_ctrl_c_hook(&mrulist_ctrl_c_hook); - fprintf(stderr, - "Ctrl-C will stop MRU retrieval and display partial results.\n"); - fflush(stderr); next_report = time(NULL) + MRU_REPORT_SECS; limit = min(3 * MAXFRAGS, ntpd_row_limit); @@ -2512,8 +2509,9 @@ collect_mru_list( if (debug) fprintf(stderr, "READ_MRU parms: %s\n", req_buf); - qres = doqueryex(CTL_OP_READ_MRU, 0, 0, strlen(req_buf), - req_buf, &rstatus, &rsize, &rdata, TRUE); + qres = doqueryex(CTL_OP_READ_MRU, 0, 0, + strlen(req_buf), req_buf, + &rstatus, &rsize, &rdata, TRUE); if (CERR_UNKNOWNVAR == qres && ri > 0) { /* @@ -2863,14 +2861,13 @@ collect_mru_list( ri, sptoa(&recent->addr), ri, recent->last.l_ui, recent->last.l_uf); chars = strlen(buf); - if (REQ_ROOM - chars < 1) + if (REQ_ROOM <= chars) break; memcpy(req, buf, chars + 1); req += chars; } } - set_ctrl_c_hook(NULL); c_mru_l_rc = TRUE; goto retain_hash_table; @@ -3080,6 +3077,12 @@ mrulist( int lstint; size_t i; + mrulist_interrupted = FALSE; + push_ctrl_c_handler(&mrulist_ctrl_c_hook); + fprintf(stderr, + "Ctrl-C will stop MRU retrieval and display partial results.\n"); + fflush(stderr); + order = MRUSORT_DEF; parms_buf[0] = '\0'; parms = parms_buf; @@ -3220,6 +3223,8 @@ cleanup_return: free(hash_table); hash_table = NULL; INIT_DLIST(mru_list, mlink); + + pop_ctrl_c_handler(&mrulist_ctrl_c_hook); } @@ -3317,7 +3322,7 @@ ifstats( const char up_fmt[] = "up.%u"; /* uptime */ const char * datap; int qres; - int dsize; + size_t dsize; u_short rstatus; char * tag; char * val; @@ -3533,7 +3538,7 @@ reslist( const int qdata_chars = COUNTOF(qdata) - 1; const char * datap; int qres; - int dsize; + size_t dsize; u_short rstatus; char * tag; char * val; @@ -3632,7 +3637,7 @@ collect_display_vdc( char tagbuf[32]; vdc *pvdc; u_short rstatus; - int rsize; + size_t rsize; const char *rdata; int qres; char *tag; diff --git a/contrib/ntp/ntpq/ntpq.1ntpqman b/contrib/ntp/ntpq/ntpq.1ntpqman index b4e45b2..1c26076 100644 --- a/contrib/ntp/ntpq/ntpq.1ntpqman +++ b/contrib/ntp/ntpq/ntpq.1ntpqman @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntpq 1ntpqman "21 Oct 2015" "4.2.8p4" "User Commands" +.TH ntpq 1ntpqman "07 Jan 2016" "4.2.8p5" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-joa4fN/ag-voaWeN) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-4VaaKt/ag-eWa4It) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:39:23 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:31:55 PM by AutoGen 5.18.5 .\" From the definitions ntpq-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/ntpq/ntpq.1ntpqmdoc b/contrib/ntp/ntpq/ntpq.1ntpqmdoc index 8239434..bf8d101 100644 --- a/contrib/ntp/ntpq/ntpq.1ntpqmdoc +++ b/contrib/ntp/ntpq/ntpq.1ntpqmdoc @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTPQ 1ntpqmdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntpq-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:39:29 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:32:02 PM by AutoGen 5.18.5 .\" From the definitions ntpq-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/ntpq/ntpq.c b/contrib/ntp/ntpq/ntpq.c index c8d5ece..5b3c9cb 100644 --- a/contrib/ntp/ntpq/ntpq.c +++ b/contrib/ntp/ntpq/ntpq.c @@ -39,6 +39,7 @@ #include "ntp_libopts.h" #include "ntpq-opts.h" +#include "safecast.h" #ifdef SYS_VXWORKS /* vxWorks needs mode flag -casey*/ # define open(name, flags) open(name, flags, 0777) @@ -168,13 +169,13 @@ int ntpqmain (int, char **); static int openhost (const char *, int); static void dump_hex_printable(const void *, size_t); static int sendpkt (void *, size_t); -static int getresponse (int, int, u_short *, int *, const char **, int); -static int sendrequest (int, associd_t, int, int, const char *); +static int getresponse (int, int, u_short *, size_t *, const char **, int); +static int sendrequest (int, associd_t, int, size_t, const char *); static char * tstflags (u_long); #ifndef BUILD_AS_LIB static void getcmds (void); #ifndef SYS_WINNT -static RETSIGTYPE abortcmd (int); +static int abortcmd (void); #endif /* SYS_WINNT */ static void docmd (const char *); static void tokenize (const char *, char **, int *); @@ -208,13 +209,14 @@ static void error (const char *, ...) __attribute__((__format__(__printf__, 1, 2))); static u_long getkeyid (const char *); static void atoascii (const char *, size_t, char *, size_t); -static void cookedprint (int, int, const char *, int, int, FILE *); -static void rawprint (int, int, const char *, int, int, FILE *); +static void cookedprint (int, size_t, const char *, int, int, FILE *); +static void rawprint (int, size_t, const char *, int, int, FILE *); static void startoutput (void); static void output (FILE *, const char *, const char *); static void endoutput (FILE *); static void outputarr (FILE *, char *, int, l_fp *); static int assoccmp (const void *, const void *); +static void on_ctrlc (void); u_short varfmt (const char *); void ntpq_custom_opt_handler (tOptions *, tOptDesc *); @@ -558,9 +560,10 @@ ntpqmain( interactive = 1; } + set_ctrl_c_hook(on_ctrlc); #ifndef SYS_WINNT /* Under NT cannot handle SIGINT, WIN32 spawns a handler */ if (interactive) - (void) signal_no_reset(SIGINT, abortcmd); + push_ctrl_c_handler(abortcmd); #endif /* SYS_WINNT */ if (numcmds == 0) { @@ -739,9 +742,9 @@ openhost( sizeof(hostaddr)) == -1) #else (connect(sockfd, (struct sockaddr *)ai->ai_addr, - ai->ai_addrlen) == -1) + ai->ai_addrlen) == -1) #endif /* SYS_VXWORKS */ - { + { error("connect"); freeaddrinfo(ai); return 0; @@ -802,7 +805,7 @@ sendpkt( if (debug >= 3) printf("Sending %zu octets\n", xdatalen); - if (send(sockfd, xdata, (size_t)xdatalen, 0) == -1) { + if (send(sockfd, xdata, xdatalen, 0) == -1) { warning("write to %s failed", currenthost); return -1; } @@ -822,7 +825,7 @@ getresponse( int opcode, int associd, u_short *rstatus, - int *rsize, + size_t *rsize, const char **rdata, int timeo ) @@ -871,8 +874,7 @@ getresponse( tvo = tvsout; FD_SET(sockfd, &fds); - n = select(sockfd + 1, &fds, NULL, NULL, &tvo); - + n = select(sockfd+1, &fds, NULL, NULL, &tvo); if (n == -1) { warning("select fails"); return -1; @@ -1171,22 +1173,22 @@ sendrequest( int opcode, associd_t associd, int auth, - int qsize, + size_t qsize, const char *qdata ) { struct ntp_control qpkt; - int pktsize; + size_t pktsize; u_long key_id; char * pass; - int maclen; + size_t maclen; /* * Check to make sure the data will fit in one packet */ if (qsize > CTL_MAX_DATA_LEN) { fprintf(stderr, - "***Internal error! qsize (%d) too large\n", + "***Internal error! qsize (%zu) too large\n", qsize); return 1; } @@ -1265,7 +1267,7 @@ sendrequest( return 1; } else if ((size_t)maclen != (info_auth_hashlen + sizeof(keyid_t))) { fprintf(stderr, - "%d octet MAC, %zu expected with %zu octet digest\n", + "%zu octet MAC, %zu expected with %zu octet digest\n", maclen, (info_auth_hashlen + sizeof(keyid_t)), info_auth_hashlen); return 1; @@ -1355,10 +1357,10 @@ doquery( int opcode, associd_t associd, int auth, - int qsize, + size_t qsize, const char *qdata, u_short *rstatus, - int *rsize, + size_t *rsize, const char **rdata ) { @@ -1376,10 +1378,10 @@ doqueryex( int opcode, associd_t associd, int auth, - int qsize, + size_t qsize, const char *qdata, u_short *rstatus, - int *rsize, + size_t *rsize, const char **rdata, int quiet ) @@ -1460,16 +1462,18 @@ getcmds(void) /* * abortcmd - catch interrupts and abort the current command */ -static RETSIGTYPE -abortcmd( - int sig - ) +static int +abortcmd(void) { if (current_output == stdout) - (void) fflush(stdout); + (void) fflush(stdout); putc('\n', stderr); (void) fflush(stderr); - if (jump) longjmp(interrupt_buf, 1); + if (jump) { + jump = 0; + longjmp(interrupt_buf, 1); + } + return TRUE; } #endif /* !SYS_WINNT && !BUILD_AS_LIB */ @@ -1743,7 +1747,7 @@ findcmd( ) { struct xcmd *cl; - int clen; + size_t clen; int nmatch; struct xcmd *nearmatch = NULL; struct xcmd *clist; @@ -2665,7 +2669,7 @@ vwarning(const char *fmt, va_list ap) int serrno = errno; (void) fprintf(stderr, "%s: ", progname); vfprintf(stderr, fmt, ap); - (void) fprintf(stderr, ": %s", strerror(serrno)); + (void) fprintf(stderr, ": %s\n", strerror(serrno)); } /* @@ -2800,7 +2804,7 @@ do { \ */ void makeascii( - int length, + size_t length, const char *data, FILE *fp ) @@ -2916,7 +2920,7 @@ int nextcb = 0; */ int nextvar( - int *datalen, + size_t *datalen, const char **datap, char **vname, char **vvalue @@ -2963,7 +2967,7 @@ nextvar( if (cp < cpend) cp++; *datap = cp; - *datalen = cpend - cp; + *datalen = size2int_sat(cpend - cp); *vvalue = NULL; return 1; } @@ -3003,7 +3007,7 @@ nextvar( if (np < cpend && ',' == *np) np++; *datap = np; - *datalen = cpend - np; + *datalen = size2int_sat(cpend - np); *vvalue = value; return 1; } @@ -3027,7 +3031,7 @@ varfmt(const char * varname) */ void printvars( - int length, + size_t length, const char *data, int status, int sttype, @@ -3048,7 +3052,7 @@ printvars( static void rawprint( int datatype, - int length, + size_t length, const char *data, int status, int quiet, @@ -3113,10 +3117,10 @@ output( const char *value ) { - size_t len; + int len; /* strlen of "name=value" */ - len = strlen(name) + 1 + strlen(value); + len = size2int_sat(strlen(name) + 1 + strlen(value)); if (out_chars != 0) { out_chars += 2; @@ -3161,10 +3165,10 @@ outputarr( l_fp *lfp ) { - register char *bp; - register char *cp; - register int i; - register int len; + char *bp; + char *cp; + size_t i; + size_t len; char buf[256]; bp = buf; @@ -3246,7 +3250,7 @@ tstflags( static void cookedprint( int datatype, - int length, + size_t length, const char *data, int status, int quiet, @@ -3430,7 +3434,7 @@ grow_assoc_cache(void) } assoc_cache = erealloc_zero(assoc_cache, new_sz, prior_sz); prior_sz = new_sz; - assoc_cache_slots = new_sz / sizeof(assoc_cache[0]); + assoc_cache_slots = (u_int)(new_sz / sizeof(assoc_cache[0])); } @@ -3566,3 +3570,48 @@ static char *list_digest_names(void) return list; } + +#define CTRLC_STACK_MAX 4 +static volatile size_t ctrlc_stack_len = 0; +static volatile Ctrl_C_Handler ctrlc_stack[CTRLC_STACK_MAX]; + + + +int/*BOOL*/ +push_ctrl_c_handler( + Ctrl_C_Handler func + ) +{ + size_t size = ctrlc_stack_len; + if (func && (size < CTRLC_STACK_MAX)) { + ctrlc_stack[size] = func; + ctrlc_stack_len = size + 1; + return TRUE; + } + return FALSE; +} + +int/*BOOL*/ +pop_ctrl_c_handler( + Ctrl_C_Handler func + ) +{ + size_t size = ctrlc_stack_len; + if (size) { + --size; + if (func == NULL || func == ctrlc_stack[size]) { + ctrlc_stack_len = size; + return TRUE; + } + } + return FALSE; +} + +static void +on_ctrlc(void) +{ + size_t size = ctrlc_stack_len; + while (size) + if ((*ctrlc_stack[--size])()) + break; +} diff --git a/contrib/ntp/ntpq/ntpq.h b/contrib/ntp/ntpq/ntpq.h index 2575b88..55ea0fb 100644 --- a/contrib/ntp/ntpq/ntpq.h +++ b/contrib/ntp/ntpq/ntpq.h @@ -136,19 +136,23 @@ extern int getnetnum (const char *, sockaddr_u *, char *, int); extern void sortassoc (void); extern void show_error_msg (int, associd_t); extern int dogetassoc (FILE *); -extern int doquery (int, associd_t, int, int, const char *, - u_short *, int *, const char **); -extern int doqueryex (int, associd_t, int, int, const char *, - u_short *, int *, const char **, int); +extern int doquery (int, associd_t, int, size_t, const char *, + u_short *, size_t *, const char **); +extern int doqueryex (int, associd_t, int, size_t, const char *, + u_short *, size_t *, const char **, int); extern const char * nntohost (sockaddr_u *); extern const char * nntohost_col (sockaddr_u *, size_t, int); extern const char * nntohostp (sockaddr_u *); extern int decodets (char *, l_fp *); extern int decodeuint (char *, u_long *); -extern int nextvar (int *, const char **, char **, char **); +extern int nextvar (size_t *, const char **, char **, char **); extern int decodetime (char *, l_fp *); -extern void printvars (int, const char *, int, int, int, FILE *); +extern void printvars (size_t, const char *, int, int, int, FILE *); extern int decodeint (char *, long *); -extern void makeascii (int, const char *, FILE *); +extern void makeascii (size_t, const char *, FILE *); extern const char * trunc_left (const char *, size_t); extern const char * trunc_right(const char *, size_t); + +typedef int/*BOOL*/ (*Ctrl_C_Handler)(void); +extern int/*BOOL*/ push_ctrl_c_handler(Ctrl_C_Handler); +extern int/*BOOL*/ pop_ctrl_c_handler(Ctrl_C_Handler); diff --git a/contrib/ntp/ntpq/ntpq.html b/contrib/ntp/ntpq/ntpq.html index e2c3740..16f2597 100644 --- a/contrib/ntp/ntpq/ntpq.html +++ b/contrib/ntp/ntpq/ntpq.html @@ -44,7 +44,7 @@ monitor the operational status and determine the performance of <code>ntpd</code>, the NTP daemon. - <p>This document applies to version 4.2.8p4 of <code>ntpq</code>. + <p>This document applies to version 4.2.8p5 of <code>ntpq</code>. <ul class="menu"> <li><a accesskey="1" href="#ntpq-Description">ntpq Description</a> @@ -769,7 +769,7 @@ the usage text by passing it through a pager program. used to select the program, defaulting to <span class="file">more</span>. Both will exit with a status code of 0. -<pre class="example">ntpq - standard NTP query program - Ver. 4.2.8p4-sec-RC2 +<pre class="example">ntpq - standard NTP query program - Ver. 4.2.8p4 Usage: ntpq [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...] Flg Arg Option-Name Description -4 no ipv4 Force IPv4 DNS name resolution diff --git a/contrib/ntp/ntpq/ntpq.man.in b/contrib/ntp/ntpq/ntpq.man.in index 0c0af5b..17ccb1c 100644 --- a/contrib/ntp/ntpq/ntpq.man.in +++ b/contrib/ntp/ntpq/ntpq.man.in @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntpq @NTPQ_MS@ "21 Oct 2015" "4.2.8p4" "User Commands" +.TH ntpq @NTPQ_MS@ "07 Jan 2016" "4.2.8p5" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-joa4fN/ag-voaWeN) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-4VaaKt/ag-eWa4It) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:39:23 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:31:55 PM by AutoGen 5.18.5 .\" From the definitions ntpq-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/ntpq/ntpq.mdoc.in b/contrib/ntp/ntpq/ntpq.mdoc.in index 2b20ddc..9214a66 100644 --- a/contrib/ntp/ntpq/ntpq.mdoc.in +++ b/contrib/ntp/ntpq/ntpq.mdoc.in @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTPQ @NTPQ_MS@ User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntpq-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:39:29 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:32:02 PM by AutoGen 5.18.5 .\" From the definitions ntpq-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/ntpsnmpd/invoke-ntpsnmpd.texi b/contrib/ntp/ntpsnmpd/invoke-ntpsnmpd.texi index ac8e69c..1185316 100644 --- a/contrib/ntp/ntpsnmpd/invoke-ntpsnmpd.texi +++ b/contrib/ntp/ntpsnmpd/invoke-ntpsnmpd.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntpsnmpd.texi) # -# It has been AutoGen-ed October 21, 2015 at 12:39:43 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:32:15 PM by AutoGen 5.18.5 # From the definitions ntpsnmpd-opts.def # and the template file agtexi-cmd.tpl @end ignore @@ -47,7 +47,7 @@ with a status code of 0. @exampleindent 0 @example -ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8p4 +ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8p5 Usage: ntpsnmpd [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... Flg Arg Option-Name Description -n no nofork Do not fork diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.c b/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.c index 01013fb..cb48b16 100644 --- a/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.c +++ b/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.c @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (ntpsnmpd-opts.c) * - * It has been AutoGen-ed October 21, 2015 at 12:39:32 PM by AutoGen 5.18.5 + * It has been AutoGen-ed January 7, 2016 at 11:32:05 PM by AutoGen 5.18.5 * From the definitions ntpsnmpd-opts.def * and the template file options * @@ -61,7 +61,7 @@ extern FILE * option_usage_fp; * static const strings for ntpsnmpd options */ static char const ntpsnmpd_opt_strs[1610] = -/* 0 */ "ntpsnmpd 4.2.8p4\n" +/* 0 */ "ntpsnmpd 4.2.8p5\n" "Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n" "This is free software. It is licensed for use, modification and\n" "redistribution under the terms of the NTP License, copies of which\n" @@ -101,14 +101,14 @@ static char const ntpsnmpd_opt_strs[1610] = /* 1414 */ "no-load-opts\0" /* 1427 */ "no\0" /* 1430 */ "NTPSNMPD\0" -/* 1439 */ "ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8p4\n" +/* 1439 */ "ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8p5\n" "Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n\0" /* 1542 */ "$HOME\0" /* 1548 */ ".\0" /* 1550 */ ".ntprc\0" /* 1557 */ "http://bugs.ntp.org, bugs@ntp.org\0" /* 1591 */ "\n\0" -/* 1593 */ "ntpsnmpd 4.2.8p4"; +/* 1593 */ "ntpsnmpd 4.2.8p5"; /** * nofork option description: @@ -554,7 +554,7 @@ static void bogus_function(void) { translate option names. */ /* referenced via ntpsnmpdOptions.pzCopyright */ - puts(_("ntpsnmpd 4.2.8p4\n\ + puts(_("ntpsnmpd 4.2.8p5\n\ Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n\ This is free software. It is licensed for use, modification and\n\ redistribution under the terms of the NTP License, copies of which\n\ @@ -599,14 +599,14 @@ implied warranty.\n")); puts(_("load options from a config file")); /* referenced via ntpsnmpdOptions.pzUsageTitle */ - puts(_("ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8p4\n\ + puts(_("ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8p5\n\ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n")); /* referenced via ntpsnmpdOptions.pzExplain */ puts(_("\n")); /* referenced via ntpsnmpdOptions.pzFullVersion */ - puts(_("ntpsnmpd 4.2.8p4")); + puts(_("ntpsnmpd 4.2.8p5")); /* referenced via ntpsnmpdOptions.pzFullUsage */ puts(_("<<<NOT-FOUND>>>")); diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.h b/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.h index 07756dd..8146eb9 100644 --- a/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.h +++ b/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.h @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (ntpsnmpd-opts.h) * - * It has been AutoGen-ed October 21, 2015 at 12:39:32 PM by AutoGen 5.18.5 + * It has been AutoGen-ed January 7, 2016 at 11:32:04 PM by AutoGen 5.18.5 * From the definitions ntpsnmpd-opts.def * and the template file options * @@ -76,9 +76,9 @@ typedef enum { /** count of all options for ntpsnmpd */ #define OPTION_CT 8 /** ntpsnmpd version */ -#define NTPSNMPD_VERSION "4.2.8p4" +#define NTPSNMPD_VERSION "4.2.8p5" /** Full ntpsnmpd version text */ -#define NTPSNMPD_FULL_VERSION "ntpsnmpd 4.2.8p4" +#define NTPSNMPD_FULL_VERSION "ntpsnmpd 4.2.8p5" /** * Interface defines for all options. Replace "n" with the UPPER_CASED diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdman b/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdman index 1a5dff3..e7fc2eb 100644 --- a/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdman +++ b/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdman @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntpsnmpd 1ntpsnmpdman "21 Oct 2015" "4.2.8p4" "User Commands" +.TH ntpsnmpd 1ntpsnmpdman "07 Jan 2016" "4.2.8p5" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-Xna4nO/ag-9naWmO) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-dZaaSu/ag-qZa4Qu) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:39:39 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:32:12 PM by AutoGen 5.18.5 .\" From the definitions ntpsnmpd-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc b/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc index e13b816..ba8d82a 100644 --- a/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc +++ b/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTPSNMPD 1ntpsnmpdmdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntpsnmpd-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:39:45 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:32:18 PM by AutoGen 5.18.5 .\" From the definitions ntpsnmpd-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd.html b/contrib/ntp/ntpsnmpd/ntpsnmpd.html index 1ad4ffc..94df056 100644 --- a/contrib/ntp/ntpsnmpd/ntpsnmpd.html +++ b/contrib/ntp/ntpsnmpd/ntpsnmpd.html @@ -42,7 +42,7 @@ Up: <a rel="up" accesskey="u" href="#dir">(dir)</a> <p>The <code>ntpsnmpd</code> utility program is used to monitor NTP daemon <code>ntpd</code> operations and determine performance. It uses the standard NTP mode 6 control - <p>This document applies to version 4.2.8p4 of <code>ntpsnmpd</code>. + <p>This document applies to version 4.2.8p5 of <code>ntpsnmpd</code>. <ul class="menu"> <li><a accesskey="1" href="#ntpsnmpd-Description">ntpsnmpd Description</a>: Description diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd.man.in b/contrib/ntp/ntpsnmpd/ntpsnmpd.man.in index 0da76ff..b5fe93d 100644 --- a/contrib/ntp/ntpsnmpd/ntpsnmpd.man.in +++ b/contrib/ntp/ntpsnmpd/ntpsnmpd.man.in @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntpsnmpd @NTPSNMPD_MS@ "21 Oct 2015" "4.2.8p4" "User Commands" +.TH ntpsnmpd @NTPSNMPD_MS@ "07 Jan 2016" "4.2.8p5" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-Xna4nO/ag-9naWmO) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-dZaaSu/ag-qZa4Qu) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:39:39 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:32:12 PM by AutoGen 5.18.5 .\" From the definitions ntpsnmpd-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd.mdoc.in b/contrib/ntp/ntpsnmpd/ntpsnmpd.mdoc.in index d2cebc4..9349c2f 100644 --- a/contrib/ntp/ntpsnmpd/ntpsnmpd.mdoc.in +++ b/contrib/ntp/ntpsnmpd/ntpsnmpd.mdoc.in @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTPSNMPD @NTPSNMPD_MS@ User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntpsnmpd-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:39:45 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:32:18 PM by AutoGen 5.18.5 .\" From the definitions ntpsnmpd-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/packageinfo.sh b/contrib/ntp/packageinfo.sh index 1e0a228..9b94198 100644 --- a/contrib/ntp/packageinfo.sh +++ b/contrib/ntp/packageinfo.sh @@ -83,7 +83,7 @@ CLTAG=NTP_4_2_0 # - Numeric values increment # - empty 'increments' to 1 # - NEW 'increments' to empty -point=4 +point=5 ### betapoint is normally modified by script. # ntp-stable Beta number (betapoint) diff --git a/contrib/ntp/scripts/calc_tickadj/Makefile.am b/contrib/ntp/scripts/calc_tickadj/Makefile.am index b98bc87..473b6e3 100644 --- a/contrib/ntp/scripts/calc_tickadj/Makefile.am +++ b/contrib/ntp/scripts/calc_tickadj/Makefile.am @@ -60,6 +60,8 @@ noinst_DATA = \ $(manpage_HACK) \ $(NULL) +BUILT_SOURCES = $(noinst_DATA) + calc_tickadj: $(srcdir)/calc_tickadj-opts $(srcdir)/calc_tickadj-opts: $(srcdir)/calc_tickadj-opts.def diff --git a/contrib/ntp/scripts/calc_tickadj/Makefile.in b/contrib/ntp/scripts/calc_tickadj/Makefile.in index c68c31d..18c5dae 100644 --- a/contrib/ntp/scripts/calc_tickadj/Makefile.in +++ b/contrib/ntp/scripts/calc_tickadj/Makefile.in @@ -516,7 +516,9 @@ noinst_DATA = \ $(manpage_HACK) \ $(NULL) -all: all-am +BUILT_SOURCES = $(noinst_DATA) +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @@ -785,13 +787,15 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am -check: check-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am all-am: Makefile $(SCRIPTS) $(MANS) $(DATA) installdirs: for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man8dir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done -install: install-am +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am @@ -822,6 +826,7 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am @@ -892,7 +897,7 @@ uninstall-am: uninstall-binSCRIPTS uninstall-libexecSCRIPTS \ uninstall-man: uninstall-man1 uninstall-man8 -.MAKE: install-am install-strip +.MAKE: all check install install-am install-strip .PHONY: all all-am check check-am clean clean-generic clean-libtool \ cscopelist-am ctags-am distclean distclean-generic \ diff --git a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjman b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjman index 9057b89..cfeca4d 100644 --- a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjman +++ b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjman @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH calc_tickadj 1calc_tickadjman "21 Oct 2015" "ntp (4.2.8p4)" "User Commands" +.TH calc_tickadj 1calc_tickadjman "07 Jan 2016" "ntp (4.2.8p5)" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-3baGnz/ag-dcaOmz) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-nyaOMf/ag-AyaWLf) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:33:58 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:26:26 PM by AutoGen 5.18.5 .\" From the definitions calc_tickadj-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc index 9c1245b..8aed38f 100644 --- a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc +++ b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt CALC_TICKADJ 1calc_tickadjmdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (calc_tickadj-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:02 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:26:28 PM by AutoGen 5.18.5 .\" From the definitions calc_tickadj-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.html b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.html index a88e28f..484e112 100644 --- a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.html +++ b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.html @@ -31,7 +31,7 @@ Up: <a rel="up" accesskey="u" href="#dir">(dir)</a> <h2 class="unnumbered">calc_tickadj User's Manual</h2> <p>This document describes the use of the NTP Project's <code>calc_tickadj</code> program. -This document applies to version 4.2.8p4 of <code>calc_tickadj</code>. +This document applies to version 4.2.8p5 of <code>calc_tickadj</code>. <div class="shortcontents"> <h2>Short Contents</h2> diff --git a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.man.in b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.man.in index 9057b89..cfeca4d 100644 --- a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.man.in +++ b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.man.in @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH calc_tickadj 1calc_tickadjman "21 Oct 2015" "ntp (4.2.8p4)" "User Commands" +.TH calc_tickadj 1calc_tickadjman "07 Jan 2016" "ntp (4.2.8p5)" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-3baGnz/ag-dcaOmz) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-nyaOMf/ag-AyaWLf) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:33:58 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:26:26 PM by AutoGen 5.18.5 .\" From the definitions calc_tickadj-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.mdoc.in b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.mdoc.in index 9c1245b..8aed38f 100644 --- a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.mdoc.in +++ b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.mdoc.in @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt CALC_TICKADJ 1calc_tickadjmdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (calc_tickadj-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:02 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:26:28 PM by AutoGen 5.18.5 .\" From the definitions calc_tickadj-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/scripts/calc_tickadj/invoke-calc_tickadj.texi b/contrib/ntp/scripts/calc_tickadj/invoke-calc_tickadj.texi index 2c66634..c78d53d 100644 --- a/contrib/ntp/scripts/calc_tickadj/invoke-calc_tickadj.texi +++ b/contrib/ntp/scripts/calc_tickadj/invoke-calc_tickadj.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-calc_tickadj.texi) # -# It has been AutoGen-ed October 21, 2015 at 12:34:04 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:26:30 PM by AutoGen 5.18.5 # From the definitions calc_tickadj-opts.def # and the template file agtexi-cmd.tpl @end ignore diff --git a/contrib/ntp/scripts/invoke-plot_summary.texi b/contrib/ntp/scripts/invoke-plot_summary.texi index 914c37b..93cc07a 100644 --- a/contrib/ntp/scripts/invoke-plot_summary.texi +++ b/contrib/ntp/scripts/invoke-plot_summary.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-plot_summary.texi) # -# It has been AutoGen-ed October 21, 2015 at 12:34:48 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:27:16 PM by AutoGen 5.18.5 # From the definitions plot_summary-opts.def # and the template file agtexi-cmd.tpl @end ignore @@ -41,7 +41,7 @@ with a status code of 0. @exampleindent 0 @example -plot_summary - plot statistics generated by summary script - Ver. 4.2.8p4 +plot_summary - plot statistics generated by summary script - Ver. 4.2.8p5 USAGE: plot_summary [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... --directory=str Where the summary files are diff --git a/contrib/ntp/scripts/invoke-summary.texi b/contrib/ntp/scripts/invoke-summary.texi index dc0dca7..521a7ff 100644 --- a/contrib/ntp/scripts/invoke-summary.texi +++ b/contrib/ntp/scripts/invoke-summary.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-summary.texi) # -# It has been AutoGen-ed October 21, 2015 at 12:34:54 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:27:22 PM by AutoGen 5.18.5 # From the definitions summary-opts.def # and the template file agtexi-cmd.tpl @end ignore @@ -42,7 +42,7 @@ with a status code of 0. @exampleindent 0 @example -summary - compute various stastics from NTP stat files - Ver. 4.2.8p4 +summary - compute various stastics from NTP stat files - Ver. 4.2.8p5 USAGE: summary [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... --directory=str Directory containing stat files diff --git a/contrib/ntp/scripts/ntp-wait/invoke-ntp-wait.texi b/contrib/ntp/scripts/ntp-wait/invoke-ntp-wait.texi index f626f33..f2de360 100644 --- a/contrib/ntp/scripts/ntp-wait/invoke-ntp-wait.texi +++ b/contrib/ntp/scripts/ntp-wait/invoke-ntp-wait.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntp-wait.texi) # -# It has been AutoGen-ed October 21, 2015 at 12:34:12 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:26:39 PM by AutoGen 5.18.5 # From the definitions ntp-wait-opts.def # and the template file agtexi-cmd.tpl @end ignore @@ -61,7 +61,7 @@ with a status code of 0. @exampleindent 0 @example -ntp-wait - Wait for ntpd to stabilize the system clock - Ver. 4.2.8p4 +ntp-wait - Wait for ntpd to stabilize the system clock - Ver. 4.2.8p5 USAGE: ntp-wait [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... -n, --tries=num Number of times to check ntpd diff --git a/contrib/ntp/scripts/ntp-wait/ntp-wait-opts b/contrib/ntp/scripts/ntp-wait/ntp-wait-opts index e2e2897..24db0a3 100644 --- a/contrib/ntp/scripts/ntp-wait/ntp-wait-opts +++ b/contrib/ntp/scripts/ntp-wait/ntp-wait-opts @@ -1,6 +1,6 @@ # EDIT THIS FILE WITH CAUTION (ntp-wait-opts) # -# It has been AutoGen-ed October 21, 2015 at 12:34:06 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:26:33 PM by AutoGen 5.18.5 # From the definitions ntp-wait-opts.def # and the template file perlopt @@ -40,7 +40,7 @@ sub processOptions { 'help|?', 'more-help')); $usage = <<'USAGE'; -ntp-wait - Wait for ntpd to stabilize the system clock - Ver. 4.2.8p4 +ntp-wait - Wait for ntpd to stabilize the system clock - Ver. 4.2.8p5 USAGE: ntp-wait [ -<flag> [<val>] | --<name>[{=| }<val>] ]... -n, --tries=num Number of times to check ntpd diff --git a/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitman b/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitman index 5a0d3cc..b49cd94 100644 --- a/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitman +++ b/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitman @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntp-wait 1ntp-waitman "21 Oct 2015" "ntp (4.2.8p4)" "User Commands" +.TH ntp-wait 1ntp-waitman "07 Jan 2016" "ntp (4.2.8p5)" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-fzaONA/ag-rzaWMA) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-7OaOah/ag-iPaW_g) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:08 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:26:35 PM by AutoGen 5.18.5 .\" From the definitions ntp-wait-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitmdoc b/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitmdoc index aedeec8..293bb0e 100644 --- a/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitmdoc +++ b/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitmdoc @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTP_WAIT 1ntp-waitmdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntp-wait-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:14 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:26:41 PM by AutoGen 5.18.5 .\" From the definitions ntp-wait-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/scripts/ntp-wait/ntp-wait.html b/contrib/ntp/scripts/ntp-wait/ntp-wait.html index 1a9ca50..e8f08d4 100644 --- a/contrib/ntp/scripts/ntp-wait/ntp-wait.html +++ b/contrib/ntp/scripts/ntp-wait/ntp-wait.html @@ -39,7 +39,7 @@ until the system's time has stabilized and synchronized, and only then start any applicaitons (like database servers) that require accurate and stable time. - <p>This document applies to version 4.2.8p4 of <code>ntp-wait</code>. + <p>This document applies to version 4.2.8p5 of <code>ntp-wait</code>. <div class="shortcontents"> <h2>Short Contents</h2> @@ -114,7 +114,7 @@ the usage text by passing it through a pager program. used to select the program, defaulting to <span class="file">more</span>. Both will exit with a status code of 0. -<pre class="example">ntp-wait - Wait for ntpd to stabilize the system clock - Ver. 4.2.8p4 +<pre class="example">ntp-wait - Wait for ntpd to stabilize the system clock - Ver. 4.2.8p5 USAGE: ntp-wait [ -<flag> [<val>] | --<name>[{=| }<val>] ]... -n, --tries=num Number of times to check ntpd diff --git a/contrib/ntp/scripts/ntp-wait/ntp-wait.man.in b/contrib/ntp/scripts/ntp-wait/ntp-wait.man.in index 12395fc..f7326de 100644 --- a/contrib/ntp/scripts/ntp-wait/ntp-wait.man.in +++ b/contrib/ntp/scripts/ntp-wait/ntp-wait.man.in @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntp-wait @NTP_WAIT_MS@ "21 Oct 2015" "ntp (4.2.8p4)" "User Commands" +.TH ntp-wait @NTP_WAIT_MS@ "07 Jan 2016" "ntp (4.2.8p5)" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-fzaONA/ag-rzaWMA) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-7OaOah/ag-iPaW_g) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:08 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:26:35 PM by AutoGen 5.18.5 .\" From the definitions ntp-wait-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/scripts/ntp-wait/ntp-wait.mdoc.in b/contrib/ntp/scripts/ntp-wait/ntp-wait.mdoc.in index 0798282..d3562ba 100644 --- a/contrib/ntp/scripts/ntp-wait/ntp-wait.mdoc.in +++ b/contrib/ntp/scripts/ntp-wait/ntp-wait.mdoc.in @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTP_WAIT @NTP_WAIT_MS@ User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntp-wait-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:14 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:26:41 PM by AutoGen 5.18.5 .\" From the definitions ntp-wait-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/scripts/ntpsweep/invoke-ntpsweep.texi b/contrib/ntp/scripts/ntpsweep/invoke-ntpsweep.texi index 5a2112d..0556da8 100644 --- a/contrib/ntp/scripts/ntpsweep/invoke-ntpsweep.texi +++ b/contrib/ntp/scripts/ntpsweep/invoke-ntpsweep.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntpsweep.texi) # -# It has been AutoGen-ed October 21, 2015 at 12:34:18 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:26:45 PM by AutoGen 5.18.5 # From the definitions ntpsweep-opts.def # and the template file agtexi-cmd.tpl @end ignore @@ -45,7 +45,7 @@ with a status code of 0. @exampleindent 0 @example -ntpsweep - Print various informations about given ntp servers - Ver. 4.2.8p4 +ntpsweep - Print various informations about given ntp servers - Ver. 4.2.8p5 USAGE: ntpsweep [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... [hostfile] -l, --host-list=str Host to execute actions on diff --git a/contrib/ntp/scripts/ntpsweep/ntpsweep-opts b/contrib/ntp/scripts/ntpsweep/ntpsweep-opts index 54d7f0d..2629d29 100644 --- a/contrib/ntp/scripts/ntpsweep/ntpsweep-opts +++ b/contrib/ntp/scripts/ntpsweep/ntpsweep-opts @@ -1,6 +1,6 @@ # EDIT THIS FILE WITH CAUTION (ntpsweep-opts) # -# It has been AutoGen-ed October 21, 2015 at 12:34:16 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:26:43 PM by AutoGen 5.18.5 # From the definitions ntpsweep-opts.def # and the template file perlopt @@ -43,7 +43,7 @@ sub processOptions { 'help|?', 'more-help')); $usage = <<'USAGE'; -ntpsweep - Print various informations about given ntp servers - Ver. 4.2.8p4 +ntpsweep - Print various informations about given ntp servers - Ver. 4.2.8p5 USAGE: ntpsweep [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [hostfile] -l, --host-list=str Host to execute actions on diff --git a/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepman b/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepman index 66deeba..0f61f64 100644 --- a/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepman +++ b/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepman @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntpsweep 1ntpsweepman "21 Oct 2015" "ntp (4.2.8p4)" "User Commands" +.TH ntpsweep 1ntpsweepman "07 Jan 2016" "ntp (4.2.8p5)" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-kqaGdC/ag-xqaOcC) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-eHaGCi/ag-rHaOBi) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:20 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:26:47 PM by AutoGen 5.18.5 .\" From the definitions ntpsweep-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepmdoc b/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepmdoc index a0f7e87..6d0c357 100644 --- a/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepmdoc +++ b/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepmdoc @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTPSWEEP 1ntpsweepmdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntpsweep-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:23 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:26:50 PM by AutoGen 5.18.5 .\" From the definitions ntpsweep-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/scripts/ntpsweep/ntpsweep.html b/contrib/ntp/scripts/ntpsweep/ntpsweep.html index fed2e2a..aba6b5f 100644 --- a/contrib/ntp/scripts/ntpsweep/ntpsweep.html +++ b/contrib/ntp/scripts/ntpsweep/ntpsweep.html @@ -30,7 +30,7 @@ Up: <a rel="up" accesskey="u" href="#dir">(dir)</a> <p>This document describes the use of the NTP Project's <code>ntpsweep</code> program. - <p>This document applies to version 4.2.8p4 of <code>ntpsweep</code>. + <p>This document applies to version 4.2.8p5 of <code>ntpsweep</code>. <div class="shortcontents"> <h2>Short Contents</h2> @@ -90,7 +90,7 @@ the usage text by passing it through a pager program. used to select the program, defaulting to <span class="file">more</span>. Both will exit with a status code of 0. -<pre class="example">ntpsweep - Print various informations about given ntp servers - Ver. 4.2.8p4 +<pre class="example">ntpsweep - Print various informations about given ntp servers - Ver. 4.2.8p5 USAGE: ntpsweep [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [hostfile] -l, --host-list=str Host to execute actions on diff --git a/contrib/ntp/scripts/ntpsweep/ntpsweep.man.in b/contrib/ntp/scripts/ntpsweep/ntpsweep.man.in index 66deeba..0f61f64 100644 --- a/contrib/ntp/scripts/ntpsweep/ntpsweep.man.in +++ b/contrib/ntp/scripts/ntpsweep/ntpsweep.man.in @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntpsweep 1ntpsweepman "21 Oct 2015" "ntp (4.2.8p4)" "User Commands" +.TH ntpsweep 1ntpsweepman "07 Jan 2016" "ntp (4.2.8p5)" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-kqaGdC/ag-xqaOcC) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-eHaGCi/ag-rHaOBi) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:20 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:26:47 PM by AutoGen 5.18.5 .\" From the definitions ntpsweep-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/scripts/ntpsweep/ntpsweep.mdoc.in b/contrib/ntp/scripts/ntpsweep/ntpsweep.mdoc.in index a0f7e87..6d0c357 100644 --- a/contrib/ntp/scripts/ntpsweep/ntpsweep.mdoc.in +++ b/contrib/ntp/scripts/ntpsweep/ntpsweep.mdoc.in @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTPSWEEP 1ntpsweepmdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntpsweep-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:23 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:26:50 PM by AutoGen 5.18.5 .\" From the definitions ntpsweep-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/scripts/ntptrace/invoke-ntptrace.texi b/contrib/ntp/scripts/ntptrace/invoke-ntptrace.texi index 4360728..29f48f4 100644 --- a/contrib/ntp/scripts/ntptrace/invoke-ntptrace.texi +++ b/contrib/ntp/scripts/ntptrace/invoke-ntptrace.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntptrace.texi) # -# It has been AutoGen-ed October 21, 2015 at 12:34:30 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:26:58 PM by AutoGen 5.18.5 # From the definitions ntptrace-opts.def # and the template file agtexi-cmd.tpl @end ignore @@ -62,7 +62,7 @@ with a status code of 0. @exampleindent 0 @example -ntptrace - Trace peers of an NTP server - Ver. 4.2.8p4 +ntptrace - Trace peers of an NTP server - Ver. 4.2.8p5 USAGE: ntptrace [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... [host] -n, --numeric Print IP addresses instead of hostnames diff --git a/contrib/ntp/scripts/ntptrace/ntptrace-opts b/contrib/ntp/scripts/ntptrace/ntptrace-opts index d6dbc53..d1cecf8 100644 --- a/contrib/ntp/scripts/ntptrace/ntptrace-opts +++ b/contrib/ntp/scripts/ntptrace/ntptrace-opts @@ -1,6 +1,6 @@ # EDIT THIS FILE WITH CAUTION (ntptrace-opts) # -# It has been AutoGen-ed October 21, 2015 at 12:34:25 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:26:52 PM by AutoGen 5.18.5 # From the definitions ntptrace-opts.def # and the template file perlopt @@ -40,7 +40,7 @@ sub processOptions { 'help|?', 'more-help')); $usage = <<'USAGE'; -ntptrace - Trace peers of an NTP server - Ver. 4.2.8p4 +ntptrace - Trace peers of an NTP server - Ver. 4.2.8p5 USAGE: ntptrace [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [host] -n, --numeric Print IP addresses instead of hostnames diff --git a/contrib/ntp/scripts/ntptrace/ntptrace.1ntptraceman b/contrib/ntp/scripts/ntptrace/ntptrace.1ntptraceman index c2362b7..33854e6 100644 --- a/contrib/ntp/scripts/ntptrace/ntptrace.1ntptraceman +++ b/contrib/ntp/scripts/ntptrace/ntptrace.1ntptraceman @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntptrace 1ntptraceman "21 Oct 2015" "ntp (4.2.8p4)" "User Commands" +.TH ntptrace 1ntptraceman "07 Jan 2016" "ntp (4.2.8p5)" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-h.aOvD/ag-u.aWuD) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-tqaWUj/ag-Gqa4Tj) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:27 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:26:54 PM by AutoGen 5.18.5 .\" From the definitions ntptrace-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/scripts/ntptrace/ntptrace.1ntptracemdoc b/contrib/ntp/scripts/ntptrace/ntptrace.1ntptracemdoc index 1734bcc..eea1d62 100644 --- a/contrib/ntp/scripts/ntptrace/ntptrace.1ntptracemdoc +++ b/contrib/ntp/scripts/ntptrace/ntptrace.1ntptracemdoc @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTPTRACE 1ntptracemdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntptrace-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:32 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:27:00 PM by AutoGen 5.18.5 .\" From the definitions ntptrace-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/scripts/ntptrace/ntptrace.html b/contrib/ntp/scripts/ntptrace/ntptrace.html index 4a4b746..fb96e71 100644 --- a/contrib/ntp/scripts/ntptrace/ntptrace.html +++ b/contrib/ntp/scripts/ntptrace/ntptrace.html @@ -31,7 +31,7 @@ Up: <a rel="up" accesskey="u" href="#dir">(dir)</a> <h2 class="unnumbered">Simple Network Time Protocol User Manual</h2> <p>This document describes the use of the NTP Project's <code>ntptrace</code> program. -This document applies to version 4.2.8p4 of <code>ntptrace</code>. +This document applies to version 4.2.8p5 of <code>ntptrace</code>. <div class="shortcontents"> <h2>Short Contents</h2> @@ -107,7 +107,7 @@ the usage text by passing it through a pager program. used to select the program, defaulting to <span class="file">more</span>. Both will exit with a status code of 0. -<pre class="example">ntptrace - Trace peers of an NTP server - Ver. 4.2.8p4 +<pre class="example">ntptrace - Trace peers of an NTP server - Ver. 4.2.8p5 USAGE: ntptrace [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [host] -n, --numeric Print IP addresses instead of hostnames diff --git a/contrib/ntp/scripts/ntptrace/ntptrace.man.in b/contrib/ntp/scripts/ntptrace/ntptrace.man.in index 5aca455..04c8c91 100644 --- a/contrib/ntp/scripts/ntptrace/ntptrace.man.in +++ b/contrib/ntp/scripts/ntptrace/ntptrace.man.in @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntptrace @NTPTRACE_MS@ "21 Oct 2015" "ntp (4.2.8p4)" "User Commands" +.TH ntptrace @NTPTRACE_MS@ "07 Jan 2016" "ntp (4.2.8p5)" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-h.aOvD/ag-u.aWuD) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-tqaWUj/ag-Gqa4Tj) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:27 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:26:54 PM by AutoGen 5.18.5 .\" From the definitions ntptrace-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/scripts/ntptrace/ntptrace.mdoc.in b/contrib/ntp/scripts/ntptrace/ntptrace.mdoc.in index 34be2a5..6e8b389 100644 --- a/contrib/ntp/scripts/ntptrace/ntptrace.mdoc.in +++ b/contrib/ntp/scripts/ntptrace/ntptrace.mdoc.in @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTPTRACE @NTPTRACE_MS@ User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntptrace-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:32 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:27:00 PM by AutoGen 5.18.5 .\" From the definitions ntptrace-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/scripts/plot_summary-opts b/contrib/ntp/scripts/plot_summary-opts index 2cb86c4..28ea583 100644 --- a/contrib/ntp/scripts/plot_summary-opts +++ b/contrib/ntp/scripts/plot_summary-opts @@ -1,6 +1,6 @@ # EDIT THIS FILE WITH CAUTION (plot_summary-opts) # -# It has been AutoGen-ed October 21, 2015 at 12:34:45 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:27:12 PM by AutoGen 5.18.5 # From the definitions plot_summary-opts.def # and the template file perlopt @@ -46,7 +46,7 @@ sub processOptions { 'help|?', 'more-help')); $usage = <<'USAGE'; -plot_summary - plot statistics generated by summary script - Ver. 4.2.8p4 +plot_summary - plot statistics generated by summary script - Ver. 4.2.8p5 USAGE: plot_summary [ -<flag> [<val>] | --<name>[{=| }<val>] ]... --directory=str Where the summary files are diff --git a/contrib/ntp/scripts/plot_summary.1plot_summaryman b/contrib/ntp/scripts/plot_summary.1plot_summaryman index fea03df..9094f8e 100644 --- a/contrib/ntp/scripts/plot_summary.1plot_summaryman +++ b/contrib/ntp/scripts/plot_summary.1plot_summaryman @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH plot_summary 1plot_summaryman "21 Oct 2015" "ntp (4.2.8p4)" "User Commands" +.TH plot_summary 1plot_summaryman "07 Jan 2016" "ntp (4.2.8p5)" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-EXaylG/ag-RXaGkG) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-xiaqKm/ag-KiayJm) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:51 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:27:18 PM by AutoGen 5.18.5 .\" From the definitions plot_summary-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/scripts/plot_summary.1plot_summarymdoc b/contrib/ntp/scripts/plot_summary.1plot_summarymdoc index 0eff78f..99c5d8c 100644 --- a/contrib/ntp/scripts/plot_summary.1plot_summarymdoc +++ b/contrib/ntp/scripts/plot_summary.1plot_summarymdoc @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt PLOT_SUMMARY 1plot_summarymdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (plot_summary-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:53 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:27:20 PM by AutoGen 5.18.5 .\" From the definitions plot_summary-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/scripts/plot_summary.html b/contrib/ntp/scripts/plot_summary.html index 7f0a594..3cb2ed4 100644 --- a/contrib/ntp/scripts/plot_summary.html +++ b/contrib/ntp/scripts/plot_summary.html @@ -31,7 +31,7 @@ Up: <a rel="up" accesskey="u" href="#dir">(dir)</a> <h2 class="unnumbered">Plot_summary User Manual</h2> <p>This document describes the use of the NTP Project's <code>plot_summary</code> program. -This document applies to version 4.2.8p4 of <code>plot_summary</code>. +This document applies to version 4.2.8p5 of <code>plot_summary</code>. <div class="shortcontents"> <h2>Short Contents</h2> @@ -89,7 +89,7 @@ the usage text by passing it through a pager program. used to select the program, defaulting to <span class="file">more</span>. Both will exit with a status code of 0. -<pre class="example">plot_summary - plot statistics generated by summary script - Ver. 4.2.8p4 +<pre class="example">plot_summary - plot statistics generated by summary script - Ver. 4.2.8p5 USAGE: plot_summary [ -<flag> [<val>] | --<name>[{=| }<val>] ]... --directory=str Where the summary files are diff --git a/contrib/ntp/scripts/plot_summary.man.in b/contrib/ntp/scripts/plot_summary.man.in index fea03df..9094f8e 100644 --- a/contrib/ntp/scripts/plot_summary.man.in +++ b/contrib/ntp/scripts/plot_summary.man.in @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH plot_summary 1plot_summaryman "21 Oct 2015" "ntp (4.2.8p4)" "User Commands" +.TH plot_summary 1plot_summaryman "07 Jan 2016" "ntp (4.2.8p5)" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-EXaylG/ag-RXaGkG) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-xiaqKm/ag-KiayJm) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:51 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:27:18 PM by AutoGen 5.18.5 .\" From the definitions plot_summary-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/scripts/plot_summary.mdoc.in b/contrib/ntp/scripts/plot_summary.mdoc.in index 0eff78f..99c5d8c 100644 --- a/contrib/ntp/scripts/plot_summary.mdoc.in +++ b/contrib/ntp/scripts/plot_summary.mdoc.in @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt PLOT_SUMMARY 1plot_summarymdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (plot_summary-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:53 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:27:20 PM by AutoGen 5.18.5 .\" From the definitions plot_summary-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/scripts/summary-opts b/contrib/ntp/scripts/summary-opts index 22f2c49..47661ee 100644 --- a/contrib/ntp/scripts/summary-opts +++ b/contrib/ntp/scripts/summary-opts @@ -1,6 +1,6 @@ # EDIT THIS FILE WITH CAUTION (summary-opts) # -# It has been AutoGen-ed October 21, 2015 at 12:34:47 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:27:14 PM by AutoGen 5.18.5 # From the definitions summary-opts.def # and the template file perlopt @@ -44,7 +44,7 @@ sub processOptions { 'help|?', 'more-help')); $usage = <<'USAGE'; -summary - compute various stastics from NTP stat files - Ver. 4.2.8p4 +summary - compute various stastics from NTP stat files - Ver. 4.2.8p5 USAGE: summary [ -<flag> [<val>] | --<name>[{=| }<val>] ]... --directory=str Directory containing stat files diff --git a/contrib/ntp/scripts/summary.1summaryman b/contrib/ntp/scripts/summary.1summaryman index 65b0eec..0573b11 100644 --- a/contrib/ntp/scripts/summary.1summaryman +++ b/contrib/ntp/scripts/summary.1summaryman @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH summary 1summaryman "21 Oct 2015" "ntp (4.2.8p4)" "User Commands" +.TH summary 1summaryman "07 Jan 2016" "ntp (4.2.8p5)" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-ghaazG/ag-shaiyG) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-.Ca4Xm/ag-lDaaXm) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:56 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:27:24 PM by AutoGen 5.18.5 .\" From the definitions summary-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/scripts/summary.1summarymdoc b/contrib/ntp/scripts/summary.1summarymdoc index 8bb1dfb..5e28a57 100644 --- a/contrib/ntp/scripts/summary.1summarymdoc +++ b/contrib/ntp/scripts/summary.1summarymdoc @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt SUMMARY 1summarymdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (summary-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:58 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:27:25 PM by AutoGen 5.18.5 .\" From the definitions summary-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/scripts/summary.html b/contrib/ntp/scripts/summary.html index 1329905..566531e 100644 --- a/contrib/ntp/scripts/summary.html +++ b/contrib/ntp/scripts/summary.html @@ -31,7 +31,7 @@ Up: <a rel="up" accesskey="u" href="#dir">(dir)</a> <h2 class="unnumbered">Summary User Manual</h2> <p>This document describes the use of the NTP Project's <code>summary</code> program. -This document applies to version 4.2.8p4 of <code>summary</code>. +This document applies to version 4.2.8p5 of <code>summary</code>. <div class="shortcontents"> <h2>Short Contents</h2> @@ -88,7 +88,7 @@ the usage text by passing it through a pager program. used to select the program, defaulting to <span class="file">more</span>. Both will exit with a status code of 0. -<pre class="example">summary - compute various stastics from NTP stat files - Ver. 4.2.8p4 +<pre class="example">summary - compute various stastics from NTP stat files - Ver. 4.2.8p5 USAGE: summary [ -<flag> [<val>] | --<name>[{=| }<val>] ]... --directory=str Directory containing stat files diff --git a/contrib/ntp/scripts/summary.man.in b/contrib/ntp/scripts/summary.man.in index 65b0eec..0573b11 100644 --- a/contrib/ntp/scripts/summary.man.in +++ b/contrib/ntp/scripts/summary.man.in @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH summary 1summaryman "21 Oct 2015" "ntp (4.2.8p4)" "User Commands" +.TH summary 1summaryman "07 Jan 2016" "ntp (4.2.8p5)" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-ghaazG/ag-shaiyG) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-.Ca4Xm/ag-lDaaXm) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:56 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:27:24 PM by AutoGen 5.18.5 .\" From the definitions summary-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/scripts/summary.mdoc.in b/contrib/ntp/scripts/summary.mdoc.in index 8bb1dfb..5e28a57 100644 --- a/contrib/ntp/scripts/summary.mdoc.in +++ b/contrib/ntp/scripts/summary.mdoc.in @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt SUMMARY 1summarymdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (summary-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:58 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:27:25 PM by AutoGen 5.18.5 .\" From the definitions summary-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/scripts/update-leap/invoke-update-leap.texi b/contrib/ntp/scripts/update-leap/invoke-update-leap.texi index da6df52..4231979 100644 --- a/contrib/ntp/scripts/update-leap/invoke-update-leap.texi +++ b/contrib/ntp/scripts/update-leap/invoke-update-leap.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-update-leap.texi) # -# It has been AutoGen-ed October 21, 2015 at 12:34:38 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:27:05 PM by AutoGen 5.18.5 # From the definitions update-leap-opts.def # and the template file agtexi-cmd.tpl @end ignore diff --git a/contrib/ntp/scripts/update-leap/update-leap-opts b/contrib/ntp/scripts/update-leap/update-leap-opts index debf333..506a746 100644 --- a/contrib/ntp/scripts/update-leap/update-leap-opts +++ b/contrib/ntp/scripts/update-leap/update-leap-opts @@ -1,6 +1,6 @@ # EDIT THIS FILE WITH CAUTION (update-leap-opts) # -# It has been AutoGen-ed October 21, 2015 at 12:34:44 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:27:11 PM by AutoGen 5.18.5 # From the definitions update-leap-opts.def # and the template file perlopt @@ -46,7 +46,7 @@ sub processOptions { 'help|?', 'more-help')); $usage = <<'USAGE'; -update-leap - leap-seconds file manager/updater - Ver. 4.2.8p4 +update-leap - leap-seconds file manager/updater - Ver. 4.2.8p5 USAGE: update-leap [ -<flag> [<val>] | --<name>[{=| }<val>] ]... -s, --source-url=str The URL of the master copy of the leapseconds file diff --git a/contrib/ntp/scripts/update-leap/update-leap.1update-leapman b/contrib/ntp/scripts/update-leap/update-leap.1update-leapman index dbe113c..4fdf467 100644 --- a/contrib/ntp/scripts/update-leap/update-leap.1update-leapman +++ b/contrib/ntp/scripts/update-leap/update-leap.1update-leapman @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH update-leap 1update-leapman "21 Oct 2015" "ntp (4.2.8p4)" "User Commands" +.TH update-leap 1update-leapman "07 Jan 2016" "ntp (4.2.8p5)" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-tXaylE/ag-FXaGkE) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-9hayKk/ag-kiaGJk) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:34 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:27:02 PM by AutoGen 5.18.5 .\" From the definitions update-leap-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/scripts/update-leap/update-leap.1update-leapmdoc b/contrib/ntp/scripts/update-leap/update-leap.1update-leapmdoc index cfbe34a..8827df7 100644 --- a/contrib/ntp/scripts/update-leap/update-leap.1update-leapmdoc +++ b/contrib/ntp/scripts/update-leap/update-leap.1update-leapmdoc @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt UPDATE_LEAP 1update-leapmdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (update-leap-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:42 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:27:10 PM by AutoGen 5.18.5 .\" From the definitions update-leap-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/scripts/update-leap/update-leap.html b/contrib/ntp/scripts/update-leap/update-leap.html index bea57b8..a7d2a70 100644 --- a/contrib/ntp/scripts/update-leap/update-leap.html +++ b/contrib/ntp/scripts/update-leap/update-leap.html @@ -30,7 +30,7 @@ Up: <a rel="up" accesskey="u" href="#dir">(dir)</a> <p>This document describes the use of the NTP Project's <code>update-leap</code> program. - <p>This document applies to version 4.2.8p4 of <code>update-leap</code>. + <p>This document applies to version 4.2.8p5 of <code>update-leap</code>. <div class="shortcontents"> <h2>Short Contents</h2> diff --git a/contrib/ntp/scripts/update-leap/update-leap.man.in b/contrib/ntp/scripts/update-leap/update-leap.man.in index dbe113c..4fdf467 100644 --- a/contrib/ntp/scripts/update-leap/update-leap.man.in +++ b/contrib/ntp/scripts/update-leap/update-leap.man.in @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH update-leap 1update-leapman "21 Oct 2015" "ntp (4.2.8p4)" "User Commands" +.TH update-leap 1update-leapman "07 Jan 2016" "ntp (4.2.8p5)" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-tXaylE/ag-FXaGkE) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-9hayKk/ag-kiaGJk) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:34 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:27:02 PM by AutoGen 5.18.5 .\" From the definitions update-leap-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/scripts/update-leap/update-leap.mdoc.in b/contrib/ntp/scripts/update-leap/update-leap.mdoc.in index cfbe34a..8827df7 100644 --- a/contrib/ntp/scripts/update-leap/update-leap.mdoc.in +++ b/contrib/ntp/scripts/update-leap/update-leap.mdoc.in @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt UPDATE_LEAP 1update-leapmdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (update-leap-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:34:42 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:27:10 PM by AutoGen 5.18.5 .\" From the definitions update-leap-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/sntp/configure b/contrib/ntp/sntp/configure index 74d0587..ce397ef 100755 --- a/contrib/ntp/sntp/configure +++ b/contrib/ntp/sntp/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for sntp 4.2.8p4. +# Generated by GNU Autoconf 2.69 for sntp 4.2.8p5. # # Report bugs to <http://bugs.ntp.org./>. # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='sntp' PACKAGE_TARNAME='sntp' -PACKAGE_VERSION='4.2.8p4' -PACKAGE_STRING='sntp 4.2.8p4' +PACKAGE_VERSION='4.2.8p5' +PACKAGE_STRING='sntp 4.2.8p5' PACKAGE_BUGREPORT='http://bugs.ntp.org./' PACKAGE_URL='http://www.ntp.org./' @@ -1491,7 +1491,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sntp 4.2.8p4 to adapt to many kinds of systems. +\`configure' configures sntp 4.2.8p5 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1561,7 +1561,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sntp 4.2.8p4:";; + short | recursive ) echo "Configuration of sntp 4.2.8p5:";; esac cat <<\_ACEOF @@ -1706,7 +1706,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sntp configure 4.2.8p4 +sntp configure 4.2.8p5 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2536,7 +2536,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sntp $as_me 4.2.8p4, which was +It was created by sntp $as_me 4.2.8p5, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3533,7 +3533,7 @@ fi # Define the identity of the package. PACKAGE='sntp' - VERSION='4.2.8p4' + VERSION='4.2.8p5' cat >>confdefs.h <<_ACEOF @@ -25155,9 +25155,10 @@ $as_echo "$as_me: Using the installed libevent" >&6;} # LDADD_LIBEVENT=`$PKG_CONFIG --libs libevent | sed 's:-levent::'` # So now we dance... LDADD_LIBEVENT= - for i in `$PKG_CONFIG --libs libevent` + for i in `$PKG_CONFIG --libs libevent` `$PKG_CONFIG --cflags-only-other libevent_pthreads` do case "$i" in + -D*) ;; -levent*) ;; *) case "$LDADD_LIBEVENT" in '') LDADD_LIBEVENT="$i" ;; @@ -31109,7 +31110,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sntp $as_me 4.2.8p4, which was +This file was extended by sntp $as_me 4.2.8p5, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -31176,7 +31177,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -sntp config.status 4.2.8p4 +sntp config.status 4.2.8p5 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/contrib/ntp/sntp/include/version.def b/contrib/ntp/sntp/include/version.def index 9f1ca6b..ddc02d4 100644 --- a/contrib/ntp/sntp/include/version.def +++ b/contrib/ntp/sntp/include/version.def @@ -1 +1 @@ -version = '4.2.8p4'; +version = '4.2.8p5'; diff --git a/contrib/ntp/sntp/include/version.texi b/contrib/ntp/sntp/include/version.texi index 64f037b..28b9357 100644 --- a/contrib/ntp/sntp/include/version.texi +++ b/contrib/ntp/sntp/include/version.texi @@ -1,3 +1,3 @@ -@set UPDATED 21 October 2015 -@set EDITION 4.2.8p4 -@set VERSION 4.2.8p4 +@set UPDATED 07 January 2016 +@set EDITION 4.2.8p5 +@set VERSION 4.2.8p5 diff --git a/contrib/ntp/sntp/invoke-sntp.texi b/contrib/ntp/sntp/invoke-sntp.texi index 9a726fa..6ca3b06 100644 --- a/contrib/ntp/sntp/invoke-sntp.texi +++ b/contrib/ntp/sntp/invoke-sntp.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-sntp.texi) # -# It has been AutoGen-ed October 21, 2015 at 12:30:56 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:23:24 PM by AutoGen 5.18.5 # From the definitions sntp-opts.def # and the template file agtexi-cmd.tpl @end ignore @@ -101,7 +101,7 @@ with a status code of 0. @exampleindent 0 @example -sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p4 +sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p5 Usage: sntp [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... \ [ hostname-or-IP ...] Flg Arg Option-Name Description diff --git a/contrib/ntp/sntp/m4/ntp_libevent.m4 b/contrib/ntp/sntp/m4/ntp_libevent.m4 index 895360e..a465d9b 100644 --- a/contrib/ntp/sntp/m4/ntp_libevent.m4 +++ b/contrib/ntp/sntp/m4/ntp_libevent.m4 @@ -89,9 +89,10 @@ case "$ntp_use_local_libevent" in # LDADD_LIBEVENT=`$PKG_CONFIG --libs libevent | sed 's:-levent::'` # So now we dance... LDADD_LIBEVENT= - for i in `$PKG_CONFIG --libs libevent` + for i in `$PKG_CONFIG --libs libevent` `$PKG_CONFIG --cflags-only-other libevent_pthreads` do case "$i" in + -D*) ;; -levent*) ;; *) case "$LDADD_LIBEVENT" in '') LDADD_LIBEVENT="$i" ;; diff --git a/contrib/ntp/sntp/m4/ntp_problemtests.m4 b/contrib/ntp/sntp/m4/ntp_problemtests.m4 index 4596e85..7cc14c9 100644 --- a/contrib/ntp/sntp/m4/ntp_problemtests.m4 +++ b/contrib/ntp/sntp/m4/ntp_problemtests.m4 @@ -28,8 +28,9 @@ AC_MSG_RESULT([$ntp_ept]) AC_MSG_CHECKING([if we can run test-ntp_restrict]) ntp_test_ntp_restrict="no" case "$ntp_ept:$cross:$host" in + no:0:*-*-freebsd6.4) ;; + no:0:*-*-hpux11.23*) ;; no:0:*-*-solaris*) ;; - no:0:*-*-hpux-11.23*) ;; *) ntp_test_ntp_restrict="yes" ;; esac AC_MSG_RESULT([$ntp_test_ntp_restrict]) @@ -38,6 +39,7 @@ AM_CONDITIONAL([BUILD_TEST_NTP_RESTRICT], [test x$ntp_test_ntp_restrict = xyes]) AC_MSG_CHECKING([if we can run test-ntp_scanner]) ntp_test_ntp_scanner="no" case "$ntp_ept:$cross:$host" in + no:0:*-*-freebsd6.4) ;; no:0:*-*-solaris*) ;; *) ntp_test_ntp_scanner="yes" ;; esac @@ -47,6 +49,7 @@ AM_CONDITIONAL([BUILD_TEST_NTP_SCANNER], [test x$ntp_test_ntp_scanner = xyes]) AC_MSG_CHECKING([if we can run test-ntp_signd]) ntp_test_ntp_signd="no" case "$ntp_ept:$cross:$host" in + no:0:*-*-freebsd6.4) ;; no:0:*-*-solaris*) ;; *) ntp_test_ntp_signd="yes" ;; esac diff --git a/contrib/ntp/sntp/m4/version.m4 b/contrib/ntp/sntp/m4/version.m4 index 7d51426..b8f98b5 100644 --- a/contrib/ntp/sntp/m4/version.m4 +++ b/contrib/ntp/sntp/m4/version.m4 @@ -1 +1 @@ -m4_define([VERSION_NUMBER],[4.2.8p4]) +m4_define([VERSION_NUMBER],[4.2.8p5]) diff --git a/contrib/ntp/sntp/networking.c b/contrib/ntp/sntp/networking.c index ddd45ef..6a176c5 100644 --- a/contrib/ntp/sntp/networking.c +++ b/contrib/ntp/sntp/networking.c @@ -136,7 +136,7 @@ process_pkt ( return PACKET_UNUSEABLE; } /* Note: pkt_len must be a multiple of 4 at this point! */ - packet_end = (u_int32*)((char*)rpkt + pkt_len); + packet_end = (void*)((char*)rpkt + pkt_len); exten_end = skip_efields(rpkt->exten, packet_end); if (NULL == exten_end) { msyslog(LOG_ERR, diff --git a/contrib/ntp/sntp/sntp-opts.c b/contrib/ntp/sntp/sntp-opts.c index e46a80c..69fb786 100644 --- a/contrib/ntp/sntp/sntp-opts.c +++ b/contrib/ntp/sntp/sntp-opts.c @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (sntp-opts.c) * - * It has been AutoGen-ed October 21, 2015 at 12:30:23 PM by AutoGen 5.18.5 + * It has been AutoGen-ed January 7, 2016 at 11:22:49 PM by AutoGen 5.18.5 * From the definitions sntp-opts.def * and the template file options * @@ -70,7 +70,7 @@ extern FILE * option_usage_fp; * static const strings for sntp options */ static char const sntp_opt_strs[2549] = -/* 0 */ "sntp 4.2.8p4\n" +/* 0 */ "sntp 4.2.8p5\n" "Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n" "This is free software. It is licensed for use, modification and\n" "redistribution under the terms of the NTP License, copies of which\n" @@ -155,7 +155,7 @@ static char const sntp_opt_strs[2549] = /* 2298 */ "LOAD_OPTS\0" /* 2308 */ "no-load-opts\0" /* 2321 */ "SNTP\0" -/* 2326 */ "sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p4\n" +/* 2326 */ "sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p5\n" "Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n" "\t\t[ hostname-or-IP ...]\n\0" /* 2485 */ "$HOME\0" @@ -163,7 +163,7 @@ static char const sntp_opt_strs[2549] = /* 2493 */ ".ntprc\0" /* 2500 */ "http://bugs.ntp.org, bugs@ntp.org\0" /* 2534 */ "\n\0" -/* 2536 */ "sntp 4.2.8p4"; +/* 2536 */ "sntp 4.2.8p5"; /** * ipv4 option description with @@ -1173,7 +1173,7 @@ static void bogus_function(void) { translate option names. */ /* referenced via sntpOptions.pzCopyright */ - puts(_("sntp 4.2.8p4\n\ + puts(_("sntp 4.2.8p5\n\ Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n\ This is free software. It is licensed for use, modification and\n\ redistribution under the terms of the NTP License, copies of which\n\ @@ -1263,7 +1263,7 @@ implied warranty.\n")); puts(_("load options from a config file")); /* referenced via sntpOptions.pzUsageTitle */ - puts(_("sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p4\n\ + puts(_("sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p5\n\ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\ \t\t[ hostname-or-IP ...]\n")); @@ -1271,7 +1271,7 @@ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\ puts(_("\n")); /* referenced via sntpOptions.pzFullVersion */ - puts(_("sntp 4.2.8p4")); + puts(_("sntp 4.2.8p5")); /* referenced via sntpOptions.pzFullUsage */ puts(_("<<<NOT-FOUND>>>")); diff --git a/contrib/ntp/sntp/sntp-opts.h b/contrib/ntp/sntp/sntp-opts.h index 895421e..78951ab 100644 --- a/contrib/ntp/sntp/sntp-opts.h +++ b/contrib/ntp/sntp/sntp-opts.h @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (sntp-opts.h) * - * It has been AutoGen-ed October 21, 2015 at 12:30:22 PM by AutoGen 5.18.5 + * It has been AutoGen-ed January 7, 2016 at 11:22:48 PM by AutoGen 5.18.5 * From the definitions sntp-opts.def * and the template file options * @@ -91,9 +91,9 @@ typedef enum { /** count of all options for sntp */ #define OPTION_CT 23 /** sntp version */ -#define SNTP_VERSION "4.2.8p4" +#define SNTP_VERSION "4.2.8p5" /** Full sntp version text */ -#define SNTP_FULL_VERSION "sntp 4.2.8p4" +#define SNTP_FULL_VERSION "sntp 4.2.8p5" /** * Interface defines for all options. Replace "n" with the UPPER_CASED diff --git a/contrib/ntp/sntp/sntp.1sntpman b/contrib/ntp/sntp/sntp.1sntpman index 89facc6..792fc52 100644 --- a/contrib/ntp/sntp/sntp.1sntpman +++ b/contrib/ntp/sntp/sntp.1sntpman @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH sntp 1sntpman "21 Oct 2015" "4.2.8p4" "User Commands" +.TH sntp 1sntpman "07 Jan 2016" "4.2.8p5" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-hEaqbg/ag-UEaiag) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-e.aO3S/ag-r.aG2S) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:30:52 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:23:20 PM by AutoGen 5.18.5 .\" From the definitions sntp-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/sntp/sntp.1sntpmdoc b/contrib/ntp/sntp/sntp.1sntpmdoc index b1b3940..8005e9a 100644 --- a/contrib/ntp/sntp/sntp.1sntpmdoc +++ b/contrib/ntp/sntp/sntp.1sntpmdoc @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt SNTP 1sntpmdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (sntp-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:30:59 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:23:27 PM by AutoGen 5.18.5 .\" From the definitions sntp-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/sntp/sntp.html b/contrib/ntp/sntp/sntp.html index 5ea532e..6aa66fb 100644 --- a/contrib/ntp/sntp/sntp.html +++ b/contrib/ntp/sntp/sntp.html @@ -36,7 +36,7 @@ display the time offset of the system clock relative to the server clock. Run as root, it can correct the system clock to this offset as well. It can be run as an interactive command or from a cron job. - <p>This document applies to version 4.2.8p4 of <code>sntp</code>. + <p>This document applies to version 4.2.8p5 of <code>sntp</code>. <p>The program implements the SNTP protocol as defined by RFC 5905, the NTPv4 IETF specification. @@ -176,7 +176,7 @@ the usage text by passing it through a pager program. used to select the program, defaulting to <span class="file">more</span>. Both will exit with a status code of 0. -<pre class="example">sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p4 +<pre class="example">sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p5 Usage: sntp [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \ [ hostname-or-IP ...] Flg Arg Option-Name Description diff --git a/contrib/ntp/sntp/sntp.man.in b/contrib/ntp/sntp/sntp.man.in index 84afa7e..1d5e571 100644 --- a/contrib/ntp/sntp/sntp.man.in +++ b/contrib/ntp/sntp/sntp.man.in @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH sntp @SNTP_MS@ "21 Oct 2015" "4.2.8p4" "User Commands" +.TH sntp @SNTP_MS@ "07 Jan 2016" "4.2.8p5" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-hEaqbg/ag-UEaiag) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-e.aO3S/ag-r.aG2S) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:30:52 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:23:20 PM by AutoGen 5.18.5 .\" From the definitions sntp-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/sntp/sntp.mdoc.in b/contrib/ntp/sntp/sntp.mdoc.in index 0313e5e..5168a99 100644 --- a/contrib/ntp/sntp/sntp.mdoc.in +++ b/contrib/ntp/sntp/sntp.mdoc.in @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt SNTP @SNTP_MS@ User Commands .Os .\" EDIT THIS FILE WITH CAUTION (sntp-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:30:59 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:23:27 PM by AutoGen 5.18.5 .\" From the definitions sntp-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/sntp/tests/keyFile.c b/contrib/ntp/sntp/tests/keyFile.c index 77dfee7..883658a 100644 --- a/contrib/ntp/sntp/tests/keyFile.c +++ b/contrib/ntp/sntp/tests/keyFile.c @@ -62,20 +62,27 @@ CompareKeysAlternative(int key_id, void test_ReadEmptyKeyFile(void) { struct key* keys = NULL; + const char *path = CreatePath("key-test-empty", INPUT_DIR); - TEST_ASSERT_EQUAL(0, auth_init(CreatePath("key-test-empty", INPUT_DIR), &keys)); + TEST_ASSERT_NOT_NULL(path); + TEST_ASSERT_EQUAL(0, auth_init(path, &keys)); TEST_ASSERT_NULL(keys); + + free((void *)path); } void test_ReadASCIIKeys(void) { struct key* keys = NULL; + const char *path = CreatePath("key-test-ascii", INPUT_DIR); - TEST_ASSERT_EQUAL(2, auth_init(CreatePath("key-test-ascii", INPUT_DIR), &keys)); - + TEST_ASSERT_NOT_NULL(path); + TEST_ASSERT_EQUAL(2, auth_init(path, &keys)); TEST_ASSERT_NOT_NULL(keys); + free((void *)path); + struct key* result = NULL; get_key(40, &result); TEST_ASSERT_NOT_NULL(result); @@ -91,10 +98,12 @@ test_ReadASCIIKeys(void) { void test_ReadHexKeys(void) { struct key* keys = NULL; + const char *path = CreatePath("key-test-hex", INPUT_DIR); - TEST_ASSERT_EQUAL(3, auth_init(CreatePath("key-test-hex", INPUT_DIR), &keys)); - + TEST_ASSERT_NOT_NULL(path); + TEST_ASSERT_EQUAL(3, auth_init(path, &keys)); TEST_ASSERT_NOT_NULL(keys); + free((void *)path); struct key* result = NULL; get_key(10, &result); @@ -119,10 +128,12 @@ test_ReadHexKeys(void) { void test_ReadKeyFileWithComments(void) { struct key* keys = NULL; + const char *path = CreatePath("key-test-comments", INPUT_DIR); - TEST_ASSERT_EQUAL(2, auth_init(CreatePath("key-test-comments", INPUT_DIR), &keys)); - + TEST_ASSERT_NOT_NULL(path); + TEST_ASSERT_EQUAL(2, auth_init(path, &keys)); TEST_ASSERT_NOT_NULL(keys); + free((void *)path); struct key* result = NULL; get_key(10, &result); @@ -140,10 +151,12 @@ test_ReadKeyFileWithComments(void) { void test_ReadKeyFileWithInvalidHex(void) { struct key* keys = NULL; + const char *path = CreatePath("key-test-invalid-hex", INPUT_DIR); - TEST_ASSERT_EQUAL(1, auth_init(CreatePath("key-test-invalid-hex", INPUT_DIR), &keys)); - + TEST_ASSERT_NOT_NULL(path); + TEST_ASSERT_EQUAL(1, auth_init(path, &keys)); TEST_ASSERT_NOT_NULL(keys); + free((void *)path); struct key* result = NULL; get_key(10, &result); diff --git a/contrib/ntp/sntp/tests/kodDatabase.c b/contrib/ntp/sntp/tests/kodDatabase.c index 0c3615d..3c05694 100644 --- a/contrib/ntp/sntp/tests/kodDatabase.c +++ b/contrib/ntp/sntp/tests/kodDatabase.c @@ -1,5 +1,6 @@ #include "config.h" +#include "ntp_workimpl.h" #include "ntp_types.h" #include "sntptest.h" #include "ntp_stdlib.h" @@ -20,6 +21,7 @@ void test_DeleteEntry(void); void setUp(void) { kod_init_kod_db("/dev/null", TRUE); + init_lib(); } diff --git a/contrib/ntp/sntp/tests/kodFile.c b/contrib/ntp/sntp/tests/kodFile.c index 6eb0971..f99d8cf 100644 --- a/contrib/ntp/sntp/tests/kodFile.c +++ b/contrib/ntp/sntp/tests/kodFile.c @@ -28,6 +28,7 @@ void setUp(void) { kod_db_cnt = 0; kod_db = NULL; + init_lib(); } diff --git a/contrib/ntp/sntp/tests/run-kodDatabase.c b/contrib/ntp/sntp/tests/run-kodDatabase.c index e5bf3d7..f655a6a 100644 --- a/contrib/ntp/sntp/tests/run-kodDatabase.c +++ b/contrib/ntp/sntp/tests/run-kodDatabase.c @@ -23,6 +23,7 @@ #include <setjmp.h> #include <stdio.h> #include "config.h" +#include "ntp_workimpl.h" #include "ntp_types.h" #include "sntptest.h" #include "ntp_stdlib.h" @@ -56,11 +57,11 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("kodDatabase.c"); - RUN_TEST(test_SingleEntryHandling, 13); - RUN_TEST(test_MultipleEntryHandling, 14); - RUN_TEST(test_NoMatchInSearch, 15); - RUN_TEST(test_AddDuplicate, 16); - RUN_TEST(test_DeleteEntry, 17); + RUN_TEST(test_SingleEntryHandling, 14); + RUN_TEST(test_MultipleEntryHandling, 15); + RUN_TEST(test_NoMatchInSearch, 16); + RUN_TEST(test_AddDuplicate, 17); + RUN_TEST(test_DeleteEntry, 18); return (UnityEnd()); } diff --git a/contrib/ntp/sntp/tests/run-t-log.c b/contrib/ntp/sntp/tests/run-t-log.c index dc9fa04..8d12345 100644 --- a/contrib/ntp/sntp/tests/run-t-log.c +++ b/contrib/ntp/sntp/tests/run-t-log.c @@ -49,9 +49,9 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("t-log.c"); - RUN_TEST(testChangePrognameInMysyslog, 9); - RUN_TEST(testOpenLogfileTest, 10); - RUN_TEST(testWriteInCustomLogfile, 35); + RUN_TEST(testChangePrognameInMysyslog, 10); + RUN_TEST(testOpenLogfileTest, 11); + RUN_TEST(testWriteInCustomLogfile, 12); return (UnityEnd()); } diff --git a/contrib/ntp/sntp/tests/t-log.c b/contrib/ntp/sntp/tests/t-log.c index 1546584..08d4b6c 100644 --- a/contrib/ntp/sntp/tests/t-log.c +++ b/contrib/ntp/sntp/tests/t-log.c @@ -6,63 +6,82 @@ //#include "log.h" #include "log.c" +void setUp(void); void testChangePrognameInMysyslog(void); void testOpenLogfileTest(void); +void testWriteInCustomLogfile(void); + + +void +setUp(void) { + init_lib(); +} //in var/log/syslog (may differ depending on your OS), logged name of the program will be "TEST_PROGNAME". -void testChangePrognameInMysyslog(void){ +void +testChangePrognameInMysyslog(void) +{ sntp_init_logging("TEST_PROGNAME"); - msyslog(LOG_ERR, "TESTING sntp_init_logging()"); //%m will print the last errno? + msyslog(LOG_ERR, "TESTING sntp_init_logging()"); + + return; } //writes log files in your own file instead of syslog! (MAY BE USEFUL TO SUPPRESS ERROR MESSAGES!) -void testOpenLogfileTest(void){ +void +testOpenLogfileTest(void) +{ sntp_init_logging("TEST_PROGNAME2"); //this name is consistent through the entire program unless changed - open_logfile("testLogfile.log"); + open_logfile("testLogfile.log"); //open_logfile("/var/log/syslog"); //this gives me "Permission Denied" when i do %m - + msyslog(LOG_ERR, "Cannot open log file %s","abcXX"); //cleanup_log(); //unnecessary after log.c fix! - + + return; } //multiple cleanup_log() causes segfault. Probably the reason it's static. Opening multiple open_logfile(name) will cause segfault x.x I'm guessing it's not intended to be changed. Cleanup after unity test doesn't fix it, looks like. Calling in tearDown() also causes issues. -void testWriteInCustomLogfile(void){ +void +testWriteInCustomLogfile(void) +{ char testString[256] = "12345 ABC"; char testName[256] = "TEST_PROGNAME3"; - remove("testLogfile2.log"); + (void)remove("testLogfile2.log"); sntp_init_logging(testName); open_logfile("testLogfile2.log"); // ./ causing issues //sntp_init_logging(testName); - - msyslog(LOG_ERR, testString); + + msyslog(LOG_ERR, "%s", testString); FILE * f = fopen("testLogfile2.log","r"); char line[256]; + TEST_ASSERT_TRUE( f != NULL); + //should be only 1 line - while (fgets(line, sizeof(line), f)) { - printf("%s", line); - } - + while (fgets(line, sizeof(line), f)) { + printf("%s", line); + } + char* x = strstr(line,testName); - + TEST_ASSERT_TRUE( x != NULL); x = strstr(line,testString); TEST_ASSERT_TRUE( x != NULL); //cleanup_log(); - fclose(f); //using this will also cause segfault, because at the end, log.c will call (using atexit(func) function) cleanup_log(void)-> fclose(syslog_file); + fclose(f); //using this will also cause segfault, because at the end, log.c will call (using atexit(func) function) cleanup_log(void)-> fclose(syslog_file); //After the 1st fclose, syslog_file = NULL, and is never reset -> hopefully fixed by editing log.c //TEST_ASSERT_EQUAL_STRING(testString,line); //doesn't work, line is dynamic because the process name is random. -} - + return; +} diff --git a/contrib/ntp/sntp/tests/utilities.c b/contrib/ntp/sntp/tests/utilities.c index 39d22d6..a68aaac 100644 --- a/contrib/ntp/sntp/tests/utilities.c +++ b/contrib/ntp/sntp/tests/utilities.c @@ -96,12 +96,12 @@ test_IPv4Address(void) { void test_IPv6Address(void) { - const struct in6_addr address = { + const struct in6_addr address = { { { 0x20, 0x01, 0x0d, 0xb8, 0x85, 0xa3, 0x08, 0xd3, 0x13, 0x19, 0x8a, 0x2e, 0x03, 0x70, 0x73, 0x34 - }; + } } }; const char * expected = "2001:db8:85a3:8d3:1319:8a2e:370:7334"; sockaddr_u input; struct addrinfo inputA; diff --git a/contrib/ntp/sntp/unity/unity_internals.h b/contrib/ntp/sntp/unity/unity_internals.h index c2aabc3..bf1bf3d 100644 --- a/contrib/ntp/sntp/unity/unity_internals.h +++ b/contrib/ntp/sntp/unity/unity_internals.h @@ -305,6 +305,18 @@ extern int UNITY_OUTPUT_CHAR(int); # undef UNITY_WEAK_PRAGMA #endif +#if !defined(UNITY_NORETURN_ATTRIBUTE) +# ifdef __GNUC__ // includes clang +# if !(defined(__WIN32__) && defined(__clang__)) +# define UNITY_NORETURN_ATTRIBUTE __attribute__((noreturn)) +# endif +# endif +#endif + +#ifndef UNITY_NORETURN_ATTRIBUTE +# define UNITY_NORETURN_ATTRIBUTE +#endif + //------------------------------------------------------- // Internal Structs Needed @@ -465,7 +477,7 @@ void UnityAssertNumbersWithin(const _U_SINT delta, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style); -void UnityFail(const char* message, const UNITY_LINE_TYPE line); +void UnityFail(const char* message, const UNITY_LINE_TYPE line) UNITY_NORETURN_ATTRIBUTE; void UnityIgnore(const char* message, const UNITY_LINE_TYPE line); diff --git a/contrib/ntp/sntp/version.c b/contrib/ntp/sntp/version.c index 4c87128..eb0e92b 100644 --- a/contrib/ntp/sntp/version.c +++ b/contrib/ntp/sntp/version.c @@ -2,4 +2,4 @@ * version file for sntp */ #include <config.h> -const char * Version = "sntp 4.2.8p4@1.3265-o Wed Oct 21 16:41:07 UTC 2015 (25)"; +const char * Version = "sntp 4.2.8p4@1.3265-o Thu Jan 7 23:23:18 UTC 2016 (26)"; diff --git a/contrib/ntp/tests/bug-2803/bug-2803.c b/contrib/ntp/tests/bug-2803/bug-2803.c index 4ee6f02..df9dcde 100644 --- a/contrib/ntp/tests/bug-2803/bug-2803.c +++ b/contrib/ntp/tests/bug-2803/bug-2803.c @@ -15,7 +15,7 @@ int simpleTest(void); void setUp(void); void tearDown(void); -//void test_main(void); +void test_main(void); static int verbose = 1; // if not 0, also print results if test passed static int exit_on_err = 0; // if not 0, exit if test failed diff --git a/contrib/ntp/tests/bug-2803/run-bug-2803.c b/contrib/ntp/tests/bug-2803/run-bug-2803.c index 05e6a5d..f4066f2 100644 --- a/contrib/ntp/tests/bug-2803/run-bug-2803.c +++ b/contrib/ntp/tests/bug-2803/run-bug-2803.c @@ -31,6 +31,7 @@ //=======External Functions This Runner Calls===== extern void setUp(void); extern void tearDown(void); +extern void test_main(void); extern void test_main(void ); @@ -51,6 +52,7 @@ int main(int argc, char *argv[]) progname = argv[0]; UnityBegin("bug-2803.c"); RUN_TEST(test_main, 18); + RUN_TEST(test_main, 18); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/a_md5encrypt.c b/contrib/ntp/tests/libntp/a_md5encrypt.c index f46376e..d8e7ab9 100644 --- a/contrib/ntp/tests/libntp/a_md5encrypt.c +++ b/contrib/ntp/tests/libntp/a_md5encrypt.c @@ -16,14 +16,25 @@ u_long current_time = 4; * Example packet with MD5 hash calculated manually. */ const int keytype = KEY_TYPE_MD5; -const char *key = "abcdefgh"; +const u_char *key = (const u_char*)"abcdefgh"; const u_short keyLength = 8; -const char *packet = "ijklmnopqrstuvwx"; +const u_char *packet = (const u_char*)"ijklmnopqrstuvwx"; #define packetLength 16 #define keyIdLength 4 #define digestLength 16 -const int totalLength = packetLength + keyIdLength + digestLength; -const char *expectedPacket = "ijklmnopqrstuvwx\0\0\0\0\x0c\x0e\x84\xcf\x0b\xb7\xa8\x68\x8e\x52\x38\xdb\xbc\x1c\x39\x53"; +#define totalLength (packetLength + keyIdLength + digestLength) +union { + u_char u8 [totalLength]; + uint32_t u32[1]; +} expectedPacket = { + "ijklmnopqrstuvwx\0\0\0\0\x0c\x0e\x84\xcf\x0b\xb7\xa8\x68\x8e\x52\x38\xdb\xbc\x1c\x39\x53" +}; +union { + u_char u8 [totalLength]; + uint32_t u32[1]; +} invalidPacket = { + "ijklmnopqrstuvwx\0\0\0\0\x0c\x0e\x84\xcf\x0b\xb7\xa8\x68\x8e\x52\x38\xdb\xbc\x1c\x39\x54" +}; void test_Encrypt(void); @@ -35,7 +46,7 @@ void test_IPv6AddressToRefId(void); void test_Encrypt(void) { - char *packetPtr; + u_int32 *packetPtr; int length; packetPtr = emalloc(totalLength * sizeof(*packetPtr)); @@ -45,12 +56,12 @@ test_Encrypt(void) { cache_secretsize = keyLength; - length = MD5authencrypt(keytype, (u_char*)key, (u_int32*)packetPtr, packetLength); + length = MD5authencrypt(keytype, key, packetPtr, packetLength); - TEST_ASSERT_TRUE(MD5authdecrypt(keytype, (u_char*)key, (u_int32*)packetPtr, packetLength, length)); + TEST_ASSERT_TRUE(MD5authdecrypt(keytype, key, packetPtr, packetLength, length)); TEST_ASSERT_EQUAL(20, length); - TEST_ASSERT_EQUAL_MEMORY(expectedPacket, packetPtr, totalLength); + TEST_ASSERT_EQUAL_MEMORY(expectedPacket.u8, packetPtr, totalLength); free(packetPtr); } @@ -58,17 +69,13 @@ test_Encrypt(void) { void test_DecryptValid(void) { cache_secretsize = keyLength; - - TEST_ASSERT_TRUE(MD5authdecrypt(keytype, (u_char*)key, (u_int32*)expectedPacket, packetLength, 20)); + TEST_ASSERT_TRUE(MD5authdecrypt(keytype, key, expectedPacket.u32, packetLength, 20)); } void test_DecryptInvalid(void) { cache_secretsize = keyLength; - - const char *invalidPacket = "ijklmnopqrstuvwx\0\0\0\0\x0c\x0e\x84\xcf\x0b\xb7\xa8\x68\x8e\x52\x38\xdb\xbc\x1c\x39\x54"; - - TEST_ASSERT_FALSE(MD5authdecrypt(keytype, (u_char*)key, (u_int32*)invalidPacket, packetLength, 20)); + TEST_ASSERT_FALSE(MD5authdecrypt(keytype, key, invalidPacket.u32, packetLength, 20)); } void @@ -87,23 +94,24 @@ test_IPv4AddressToRefId(void) { void test_IPv6AddressToRefId(void) { - const struct in6_addr address = { + const int expected = 0x75cffd52; + const struct in6_addr address = { { { 0x20, 0x01, 0x0d, 0xb8, 0x85, 0xa3, 0x08, 0xd3, 0x13, 0x19, 0x8a, 0x2e, 0x03, 0x70, 0x73, 0x34 - }; + } } }; sockaddr_u addr; addr.sa6.sin6_family = AF_INET6; addr.sa6.sin6_addr = address; - const int expected = 0x75cffd52; #if 0 TEST_ASSERT_EQUAL(expected, addr2refid(&addr)); #else + (void)expected; TEST_IGNORE_MESSAGE("Skipping because of big endian problem?"); #endif } diff --git a/contrib/ntp/tests/libntp/authkeys.c b/contrib/ntp/tests/libntp/authkeys.c index 6a10c01..2ddbce5 100644 --- a/contrib/ntp/tests/libntp/authkeys.c +++ b/contrib/ntp/tests/libntp/authkeys.c @@ -51,18 +51,21 @@ setUp(void) cache_flags = 0; cache_secret = NULL; cache_secretsize = 0; + + return; } void tearDown(void) { - + return; } static const int KEYTYPE = KEY_TYPE_MD5; void -AddTrustedKey(keyid_t keyno) { +AddTrustedKey(keyid_t keyno) +{ /* * We need to add a MD5-key in addition to setting the * trust, because authhavekey() requires type != 0. @@ -70,15 +73,21 @@ AddTrustedKey(keyid_t keyno) { MD5auth_setkey(keyno, KEYTYPE, NULL, 0); authtrust(keyno, TRUE); + + return; } void -AddUntrustedKey(keyid_t keyno) { +AddUntrustedKey(keyid_t keyno) +{ authtrust(keyno, FALSE); + + return; } void -test_AddTrustedKeys(void) { +test_AddTrustedKeys(void) +{ const keyid_t KEYNO1 = 5; const keyid_t KEYNO2 = 8; @@ -87,48 +96,65 @@ test_AddTrustedKeys(void) { TEST_ASSERT_TRUE(authistrusted(KEYNO1)); TEST_ASSERT_TRUE(authistrusted(KEYNO2)); + + return; } void -test_AddUntrustedKey(void) { +test_AddUntrustedKey(void) +{ const keyid_t KEYNO = 3; AddUntrustedKey(KEYNO); TEST_ASSERT_FALSE(authistrusted(KEYNO)); + + return; } void -test_HaveKeyCorrect(void) { +test_HaveKeyCorrect(void) +{ const keyid_t KEYNO = 3; AddTrustedKey(KEYNO); TEST_ASSERT_TRUE(auth_havekey(KEYNO)); TEST_ASSERT_TRUE(authhavekey(KEYNO)); + + return; } void -test_HaveKeyIncorrect(void) { +test_HaveKeyIncorrect(void) +{ const keyid_t KEYNO = 2; TEST_ASSERT_FALSE(auth_havekey(KEYNO)); TEST_ASSERT_FALSE(authhavekey(KEYNO)); + + return; } void -test_AddWithAuthUseKey(void) { +test_AddWithAuthUseKey(void) +{ const keyid_t KEYNO = 5; const char* KEY = "52a"; - TEST_ASSERT_TRUE(authusekey(KEYNO, KEYTYPE, (u_char*)KEY)); + TEST_ASSERT_TRUE(authusekey(KEYNO, KEYTYPE, (const u_char*)KEY)); + + return; } void -test_EmptyKey(void) { +test_EmptyKey(void) +{ const keyid_t KEYNO = 3; const char* KEY = ""; - TEST_ASSERT_FALSE(authusekey(KEYNO, KEYTYPE, (u_char*)KEY)); + TEST_ASSERT_FALSE(authusekey(KEYNO, KEYTYPE, (const u_char*)KEY)); + + return; } diff --git a/contrib/ntp/tests/libntp/buftvtots.c b/contrib/ntp/tests/libntp/buftvtots.c index efde009..b6b81a2 100644 --- a/contrib/ntp/tests/libntp/buftvtots.c +++ b/contrib/ntp/tests/libntp/buftvtots.c @@ -18,7 +18,8 @@ void test_AlwaysFalseOnWindows(void); void -test_ZeroBuffer(void) { +test_ZeroBuffer(void) +{ #ifndef SYS_WINNT const struct timeval input = {0, 0}; const l_fp expected = {{0 + JAN_1970}, 0}; @@ -30,10 +31,14 @@ test_ZeroBuffer(void) { #else TEST_IGNORE_MESSAGE("Test only for Windows, skipping..."); #endif + + return; } + void -test_IntegerAndFractionalBuffer(void) { +test_IntegerAndFractionalBuffer(void) +{ #ifndef SYS_WINNT const struct timeval input = {5, 500000}; /* 5.5 */ const l_fp expected = {{5 + JAN_1970}, HALF}; @@ -53,24 +58,30 @@ test_IntegerAndFractionalBuffer(void) { #else TEST_IGNORE_MESSAGE("Test only for Windows, skipping..."); #endif + + return; } void -test_IllegalMicroseconds(void) { +test_IllegalMicroseconds(void) +{ #ifndef SYS_WINNT const struct timeval input = {0, 1100000}; /* > 999 999 microseconds. */ - + l_fp actual; TEST_ASSERT_FALSE(buftvtots((const char*)(&input), &actual)); #else TEST_IGNORE_MESSAGE("Test only for Windows, skipping..."); #endif + + return; } void -test_AlwaysFalseOnWindows(void) { +test_AlwaysFalseOnWindows(void) +{ #ifdef SYS_WINNT /* * Under Windows, buftvtots will just return @@ -81,5 +92,6 @@ test_AlwaysFalseOnWindows(void) { #else TEST_IGNORE_MESSAGE("Non-Windows test, skipping..."); #endif -} + return; +} diff --git a/contrib/ntp/tests/libntp/calendar.c b/contrib/ntp/tests/libntp/calendar.c index 2c8a2d5..9d25c41 100644 --- a/contrib/ntp/tests/libntp/calendar.c +++ b/contrib/ntp/tests/libntp/calendar.c @@ -8,31 +8,42 @@ static int leapdays(int year); -int isGT(int first, int second); -int leapdays(int year); -char * CalendarFromCalToString(const struct calendar *cal); -char * CalendarFromIsoToString(const struct isodate *iso); -int IsEqualCal(const struct calendar *expected, const struct calendar *actual); -int IsEqualIso(const struct isodate *expected, const struct isodate *actual); -char * DateFromCalToString(const struct calendar *cal); -char * DateFromIsoToString(const struct isodate *iso); -int IsEqualDateCal(const struct calendar *expected, const struct calendar *actual); -int IsEqualDateIso(const struct isodate *expected, const struct isodate *actual); -void test_DaySplitMerge(void); -void test_SplitYearDays1(void); -void test_SplitYearDays2(void); -void test_RataDie1(void); -void test_LeapYears1(void); -void test_LeapYears2(void); -void test_RoundTripDate(void); -void test_RoundTripYearStart(void); -void test_RoundTripMonthStart(void); -void test_RoundTripWeekStart(void); -void test_RoundTripDayStart(void); -void test_IsoCalYearsToWeeks(void); -void test_IsoCalWeeksToYearStart(void); -void test_IsoCalWeeksToYearEnd(void); -void test_DaySecToDate(void); +void setUp(void); +int isGT(int first, int second); +int leapdays(int year); +char * CalendarFromCalToString(const struct calendar *cal); +char * CalendarFromIsoToString(const struct isodate *iso); +int IsEqualCal(const struct calendar *expected, const struct calendar *actual); +int IsEqualIso(const struct isodate *expected, const struct isodate *actual); +char * DateFromCalToString(const struct calendar *cal); +char * DateFromIsoToString(const struct isodate *iso); +int IsEqualDateCal(const struct calendar *expected, const struct calendar *actual); +int IsEqualDateIso(const struct isodate *expected, const struct isodate *actual); +void test_DaySplitMerge(void); +void test_SplitYearDays1(void); +void test_SplitYearDays2(void); +void test_RataDie1(void); +void test_LeapYears1(void); +void test_LeapYears2(void); +void test_RoundTripDate(void); +void test_RoundTripYearStart(void); +void test_RoundTripMonthStart(void); +void test_RoundTripWeekStart(void); +void test_RoundTripDayStart(void); +void test_IsoCalYearsToWeeks(void); +void test_IsoCalWeeksToYearStart(void); +void test_IsoCalWeeksToYearEnd(void); +void test_DaySecToDate(void); + + +void +setUp(void) +{ + init_lib(); + + return; +} + /* * --------------------------------------------------------------------- @@ -42,7 +53,7 @@ void test_DaySecToDate(void); int isGT(int first, int second) { - if(first > second) { + if(first > second) { return TRUE; } else { return FALSE; @@ -100,9 +111,14 @@ IsEqualCal( expected->second == actual->second) { return TRUE; } else { - printf("expected: %s but was %s", - CalendarFromCalToString(expected), - CalendarFromCalToString(actual)); + char *p_exp = CalendarFromCalToString(expected); + char *p_act = CalendarFromCalToString(actual); + + printf("expected: %s but was %s", p_exp, p_act); + + free(p_exp); + free(p_act); + return FALSE; } } @@ -215,8 +231,10 @@ static const u_short real_month_days[2][14] = { * the 'vint64' is definitely needed. */ void -test_DaySplitMerge(void) { +test_DaySplitMerge(void) +{ int32 day,sec; + for (day = -1000000; day <= 1000000; day += 100) { for (sec = -100000; sec <= 186400; sec += 10000) { vint64 merge; @@ -242,11 +260,15 @@ test_DaySplitMerge(void) { TEST_ASSERT_EQUAL(esec, split.lo); } } + + return; } void -test_SplitYearDays1(void) { +test_SplitYearDays1(void) +{ int32 eyd; + for (eyd = -1; eyd <= 365; eyd++) { ntpcal_split split = ntpcal_split_yeardays(eyd, 0); if (split.lo >= 0 && split.hi >= 0) { @@ -257,11 +279,15 @@ test_SplitYearDays1(void) { } else TEST_ASSERT_TRUE(eyd < 0 || eyd > 364); } + + return; } - + void -test_SplitYearDays2(void) { +test_SplitYearDays2(void) +{ int32 eyd; + for (eyd = -1; eyd <= 366; eyd++) { ntpcal_split split = ntpcal_split_yeardays(eyd, 1); if (split.lo >= 0 && split.hi >= 0) { @@ -274,21 +300,27 @@ test_SplitYearDays2(void) { } else TEST_ASSERT_TRUE(eyd < 0 || eyd > 365); } + + return; } - + void -test_RataDie1(void) { +test_RataDie1(void) +{ int32 testDate = 1; /* 0001-01-01 (proleptic date) */ struct calendar expected = { 1, 1, 1, 1 }; struct calendar actual; ntpcal_rd_to_date(&actual, testDate); TEST_ASSERT_TRUE(IsEqualDateCal(&expected, &actual)); + + return; } /* check last day of february for first 10000 years */ void -test_LeapYears1(void) { +test_LeapYears1(void) +{ struct calendar dateIn, dateOut; for (dateIn.year = 1; dateIn.year < 10000; ++dateIn.year) { @@ -300,11 +332,14 @@ test_LeapYears1(void) { TEST_ASSERT_TRUE(IsEqualDateCal(&dateIn, &dateOut)); } + + return; } /* check first day of march for first 10000 years */ void -test_LeapYears2(void) { +test_LeapYears2(void) +{ struct calendar dateIn, dateOut; for (dateIn.year = 1; dateIn.year < 10000; ++dateIn.year) { @@ -315,6 +350,8 @@ test_LeapYears2(void) { ntpcal_rd_to_date(&dateOut, ntpcal_date_to_rd(&dateIn)); TEST_ASSERT_TRUE(IsEqualDateCal(&dateIn, &dateOut)); } + + return; } /* Full roundtrip from 1601-01-01 to 2400-12-31 @@ -324,7 +361,8 @@ test_LeapYears2(void) { * invalid output can occur.) */ void -test_RoundTripDate(void) { +test_RoundTripDate(void) +{ struct calendar truDate, expDate = { 1600, 0, 12, 31 };; int leaps; int32 truRdn, expRdn = ntpcal_date_to_rd(&expDate); @@ -335,7 +373,7 @@ test_RoundTripDate(void) { expDate.yearday = 0; leaps = leapdays(expDate.year); while (expDate.month < 12) { - expDate.month++; + expDate.month++; expDate.monthday = 0; while (expDate.monthday < real_month_days[leaps][expDate.month]) { expDate.monthday++; @@ -350,11 +388,14 @@ test_RoundTripDate(void) { } } } + + return; } /* Roundtrip testing on calyearstart */ void -test_RoundTripYearStart(void) { +test_RoundTripYearStart(void) +{ static const time_t pivot = 0; u_int32 ntp, expys, truys; struct calendar date; @@ -367,11 +408,14 @@ test_RoundTripYearStart(void) { expys = ntpcal_date_to_ntp(&date); TEST_ASSERT_EQUAL(expys, truys); } -} + + return; +} /* Roundtrip testing on calmonthstart */ void -test_RoundTripMonthStart(void) { +test_RoundTripMonthStart(void) +{ static const time_t pivot = 0; u_int32 ntp, expms, trums; struct calendar date; @@ -384,11 +428,14 @@ test_RoundTripMonthStart(void) { expms = ntpcal_date_to_ntp(&date); TEST_ASSERT_EQUAL(expms, trums); } -} + + return; +} /* Roundtrip testing on calweekstart */ void -test_RoundTripWeekStart(void) { +test_RoundTripWeekStart(void) +{ static const time_t pivot = 0; u_int32 ntp, expws, truws; struct isodate date; @@ -401,11 +448,14 @@ test_RoundTripWeekStart(void) { expws = isocal_date_to_ntp(&date); TEST_ASSERT_EQUAL(expws, truws); } -} + + return; +} /* Roundtrip testing on caldaystart */ void -test_RoundTripDayStart(void) { +test_RoundTripDayStart(void) +{ static const time_t pivot = 0; u_int32 ntp, expds, truds; struct calendar date; @@ -417,6 +467,8 @@ test_RoundTripDayStart(void) { expds = ntpcal_date_to_ntp(&date); TEST_ASSERT_EQUAL(expds, truds); } + + return; } /* --------------------------------------------------------------------- @@ -444,6 +496,7 @@ refimpl_WeeksInIsoYears( int32_t years) { int32_t days, weeks; + days = ntpcal_weekday_close( ntpcal_days_in_years(years) + 1, CAL_MONDAY) - 1; @@ -455,6 +508,7 @@ refimpl_WeeksInIsoYears( weeks = days / 7; days = days % 7; TEST_ASSERT_EQUAL(0, days); /* paranoia check... */ + return weeks; } @@ -462,9 +516,11 @@ refimpl_WeeksInIsoYears( * they are not, the calendar needs a better implementation... */ void -test_IsoCalYearsToWeeks(void) { +test_IsoCalYearsToWeeks(void) +{ int32_t years; int32_t wref, wcal; + for (years = -1000; years < 4000; ++years) { /* get number of weeks before years (reference) */ wref = refimpl_WeeksInIsoYears(years); @@ -472,13 +528,17 @@ test_IsoCalYearsToWeeks(void) { wcal = isocal_weeks_in_years(years); TEST_ASSERT_EQUAL(wref, wcal); } + + return; } void -test_IsoCalWeeksToYearStart(void) { +test_IsoCalWeeksToYearStart(void) +{ int32_t years; int32_t wref; ntpcal_split ysplit; + for (years = -1000; years < 4000; ++years) { /* get number of weeks before years (reference) */ wref = refimpl_WeeksInIsoYears(years); @@ -488,13 +548,17 @@ test_IsoCalWeeksToYearStart(void) { TEST_ASSERT_EQUAL(years, ysplit.hi); TEST_ASSERT_EQUAL(0, ysplit.lo); } + + return; } void -test_IsoCalWeeksToYearEnd(void) { +test_IsoCalWeeksToYearEnd(void) +{ int32_t years; int32_t wref; ntpcal_split ysplit; + for (years = -1000; years < 4000; ++years) { /* get last week of previous year */ wref = refimpl_WeeksInIsoYears(years) - 1; @@ -504,10 +568,13 @@ test_IsoCalWeeksToYearEnd(void) { TEST_ASSERT_EQUAL(years-1, ysplit.hi); TEST_ASSERT(ysplit.lo == 51 || ysplit.lo == 52); } + + return; } void -test_DaySecToDate(void) { +test_DaySecToDate(void) +{ struct calendar cal; int32_t days; @@ -538,4 +605,6 @@ test_DaySecToDate(void) { days = ntpcal_daysec_to_date(&cal, 86400); TEST_ASSERT_MESSAGE((days==1 && cal.hour==0 && cal.minute==0 && cal.second==0), "failed for 86400"); + + return; } diff --git a/contrib/ntp/tests/libntp/caljulian.c b/contrib/ntp/tests/libntp/caljulian.c index ecf5d9255..b25f8ac 100644 --- a/contrib/ntp/tests/libntp/caljulian.c +++ b/contrib/ntp/tests/libntp/caljulian.c @@ -20,10 +20,12 @@ void test_uLongWrapped(void); char * -CalendarToString(const struct calendar cal) { +CalendarToString(const struct calendar cal) +{ char * str = emalloc (sizeof (char) * 100); - char buffer[100] =""; + + *str = '\0'; snprintf(buffer, 100, "%u", cal.year); strcat(str, buffer); strcat(str, "-"); @@ -48,19 +50,25 @@ CalendarToString(const struct calendar cal) { } int // technically boolean -IsEqual(const struct calendar expected, const struct calendar actual) { - if (expected.year == actual.year && - (expected.yearday == actual.yearday || - (expected.month == actual.month && - expected.monthday == actual.monthday)) && - expected.hour == actual.hour && - expected.minute == actual.minute && - expected.second == actual.second) { +IsEqual(const struct calendar expected, const struct calendar actual) +{ + if ( expected.year == actual.year + && ( expected.yearday == actual.yearday + || ( expected.month == actual.month + && expected.monthday == actual.monthday)) + && expected.hour == actual.hour + && expected.minute == actual.minute + && expected.second == actual.second) { return TRUE; } else { - printf("expected: %s but was %s", CalendarToString(expected) ,CalendarToString(actual)); + char *p_exp, *p_act; + + p_exp = CalendarToString(expected); + p_act = CalendarToString(actual); + printf("expected: %s but was %s", p_exp, p_act); + free(p_exp); + free(p_act); return FALSE; - } } @@ -70,17 +78,23 @@ setUp() { ntpcal_set_timefunc(timefunc); settime(1970, 1, 1, 0, 0, 0); + init_lib(); + + return; } void tearDown() { ntpcal_set_timefunc(NULL); + + return; } void -test_RegularTime(void) { +test_RegularTime(void) +{ u_long testDate = 3485080800UL; // 2010-06-09 14:00:00 struct calendar expected = {2010,160,6,9,14,0,0}; @@ -89,10 +103,13 @@ test_RegularTime(void) { caljulian(testDate, &actual); TEST_ASSERT_TRUE(IsEqual(expected, actual)); + + return; } void -test_LeapYear(void) { +test_LeapYear(void) +{ u_long input = 3549902400UL; // 2012-06-28 20:00:00Z struct calendar expected = {2012, 179, 6, 28, 20, 0, 0}; @@ -101,28 +118,36 @@ test_LeapYear(void) { caljulian(input, &actual); TEST_ASSERT_TRUE(IsEqual(expected, actual)); + + return; } void -test_uLongBoundary(void) { - u_long time = 4294967295UL; // 2036-02-07 6:28:15 +test_uLongBoundary(void) +{ + u_long enc_time = 4294967295UL; // 2036-02-07 6:28:15 struct calendar expected = {2036,0,2,7,6,28,15}; struct calendar actual; - caljulian(time, &actual); + caljulian(enc_time, &actual); TEST_ASSERT_TRUE(IsEqual(expected, actual)); + + return; } void -test_uLongWrapped(void) { - u_long time = 0; +test_uLongWrapped(void) +{ + u_long enc_time = 0; struct calendar expected = {2036,0,2,7,6,28,16}; struct calendar actual; - caljulian(time, &actual); + caljulian(enc_time, &actual); TEST_ASSERT_TRUE(IsEqual(expected, actual)); + + return; } diff --git a/contrib/ntp/tests/libntp/clocktime.c b/contrib/ntp/tests/libntp/clocktime.c index 67ca401..ed2d4b2 100644 --- a/contrib/ntp/tests/libntp/clocktime.c +++ b/contrib/ntp/tests/libntp/clocktime.c @@ -30,14 +30,18 @@ void test_AlwaysInLimit(void); void setUp() { - ntpcal_set_timefunc(timefunc); - settime(2000, 1, 1, 0, 0, 0); + ntpcal_set_timefunc(timefunc); + settime(2000, 1, 1, 0, 0, 0); + + return; } void tearDown() { - ntpcal_set_timefunc(NULL); + ntpcal_set_timefunc(NULL); + + return; } /* --------------------------------------------------------------------- @@ -45,23 +49,27 @@ tearDown() */ void -test_CurrentYear(void) { +test_CurrentYear(void) +{ /* Timestamp: 2010-06-24 12:50:00Z */ const u_int32 timestamp = 3486372600UL; const u_int32 expected = timestamp; /* exactly the same. */ const int yday=175, hour=12, minute=50, second=0, tzoff=0; - u_long yearstart=0; + u_long yearstart = 0; u_int32 actual; - TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp, - &yearstart, &actual)); + TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, + timestamp, &yearstart, &actual)); TEST_ASSERT_EQUAL(expected, actual); + + return; } void -test_CurrentYearFuzz(void) { +test_CurrentYearFuzz(void) +{ /* * Timestamp (rec_ui) is: 2010-06-24 12:50:00 * Time sent into function is 12:00:00. @@ -78,13 +86,16 @@ test_CurrentYearFuzz(void) { u_long yearstart=0; u_int32 actual; - TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp, - &yearstart, &actual)); + TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, + timestamp, &yearstart, &actual)); TEST_ASSERT_EQUAL(expected, actual); + + return; } void -test_TimeZoneOffset(void) { +test_TimeZoneOffset(void) +{ /* * Timestamp (rec_ui) is: 2010-06-24 12:00:00 +0800 * (which is 2010-06-24 04:00:00Z) @@ -105,7 +116,8 @@ test_TimeZoneOffset(void) { } void -test_WrongYearStart(void) { +test_WrongYearStart(void) +{ /* * Timestamp (rec_ui) is: 2010-01-02 11:00:00Z * Time sent into function is 11:00:00. @@ -125,7 +137,8 @@ test_WrongYearStart(void) { } void -test_PreviousYear(void) { +test_PreviousYear(void) +{ /* * Timestamp is: 2010-01-01 01:00:00Z * Time sent into function is 23:00:00 @@ -145,7 +158,8 @@ test_PreviousYear(void) { } void -test_NextYear(void) { +test_NextYear(void) +{ /* * Timestamp is: 2009-12-31 23:00:00Z * Time sent into function is 01:00:00 @@ -158,28 +172,35 @@ test_NextYear(void) { u_long yearstart = 0; u_int32 actual; - TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp, - &yearstart, &actual)); + TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, + timestamp, &yearstart, &actual)); TEST_ASSERT_EQUAL(expected, actual); + + return; } void -test_NoReasonableConversion(void) { +test_NoReasonableConversion(void) +{ /* Timestamp is: 2010-01-02 11:00:00Z */ const u_int32 timestamp = 3471418800UL; - + const int yday=100, hour=12, minute=0, second=0, tzoff=0; u_long yearstart = 0; u_int32 actual; - TEST_ASSERT_FALSE(clocktime(yday, hour, minute, second, tzoff, timestamp, - &yearstart, &actual)); + TEST_ASSERT_FALSE(clocktime(yday, hour, minute, second, tzoff, + timestamp, &yearstart, &actual)); + + return; } int/*BOOL*/ -isLE(u_int32 diff,u_int32 actual){ - if(diff <= actual){ +isLE(u_int32 diff,u_int32 actual) +{ + + if (diff <= actual) { return TRUE; } else return FALSE; @@ -187,7 +208,8 @@ isLE(u_int32 diff,u_int32 actual){ void -test_AlwaysInLimit(void) { +test_AlwaysInLimit(void) +{ /* Timestamp is: 2010-01-02 11:00:00Z */ const u_int32 timestamp = 3471418800UL; const u_short prime_incs[] = { 127, 151, 163, 179 }; @@ -210,7 +232,8 @@ test_AlwaysInLimit(void) { for (hour = -204; hour < 204; hour += 2) { for (minute = -60; minute < 60; minute++) { clocktime(yday, hour, minute, 30, 0, - timestamp, &yearstart, &actual); + timestamp, &yearstart, + &actual); diff = actual - timestamp; if (diff >= 0x80000000UL) diff = ~diff + 1; @@ -219,4 +242,5 @@ test_AlwaysInLimit(void) { } } } + return; } diff --git a/contrib/ntp/tests/libntp/decodenetnum.c b/contrib/ntp/tests/libntp/decodenetnum.c index 0e9bc34..0d2b0b5 100644 --- a/contrib/ntp/tests/libntp/decodenetnum.c +++ b/contrib/ntp/tests/libntp/decodenetnum.c @@ -4,6 +4,7 @@ #include "unity.h" +void setUp(void); extern void test_IPv4AddressOnly(void); extern void test_IPv4AddressWithPort(void); //#ifdef ISC_PLATFORM_HAVEIPV6 @@ -15,6 +16,15 @@ extern void test_IllegalCharInPort(void); void +setUp(void) +{ + init_lib(); + + return; +} + + +void test_IPv4AddressOnly(void) { const char *str = "192.0.2.1"; sockaddr_u actual; diff --git a/contrib/ntp/tests/libntp/humandate.c b/contrib/ntp/tests/libntp/humandate.c index 3a28f59..de3c751 100644 --- a/contrib/ntp/tests/libntp/humandate.c +++ b/contrib/ntp/tests/libntp/humandate.c @@ -5,11 +5,21 @@ #include "unity.h" +void setUp(void); void test_RegularTime(void); void test_CurrentTime(void); void +setUp(void) +{ + init_lib(); + + return; +} + + +void test_RegularTime(void) { time_t sample = 1276601278; @@ -17,11 +27,13 @@ test_RegularTime(void) struct tm* tm; tm = localtime(&sample); - TEST_ASSERT_TRUE(time != NULL); + TEST_ASSERT_TRUE(tm != NULL); snprintf(expected, 15, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec); TEST_ASSERT_EQUAL_STRING(expected, humantime(sample)); + + return; } void @@ -34,9 +46,11 @@ test_CurrentTime(void) time(&sample); tm = localtime(&sample); - TEST_ASSERT_TRUE(time != NULL); + TEST_ASSERT_TRUE(tm != NULL); snprintf(expected, 15, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec); TEST_ASSERT_EQUAL_STRING(expected, humantime(sample)); + + return; } diff --git a/contrib/ntp/tests/libntp/lfpfunc.c b/contrib/ntp/tests/libntp/lfpfunc.c index 1a13f37..cedbb60 100644 --- a/contrib/ntp/tests/libntp/lfpfunc.c +++ b/contrib/ntp/tests/libntp/lfpfunc.c @@ -9,17 +9,18 @@ #include <math.h> -/* replaced TEST_ASSERT_EQUAL_MEMORY(&a, &b, sizeof(a)) with TEST_ASSERT_EQUAL_l_fp(a, b). - It's safer this way, because structs can be compared even if they aren't initiated - with memset (due to padding bytes). +/* + replaced: TEST_ASSERT_EQUAL_MEMORY(&a, &b, sizeof(a)) + with: TEST_ASSERT_EQUAL_l_fp(a, b). + It's safer this way, because structs can be compared even if they + aren't initiated with memset (due to padding bytes). */ -#define TEST_ASSERT_EQUAL_l_fp(a, b) { \ - TEST_ASSERT_EQUAL_MESSAGE(a.l_i, b.l_i, "Field l_i"); \ - TEST_ASSERT_EQUAL_UINT_MESSAGE(a.l_uf, b.l_uf, "Field l_uf"); \ +#define TEST_ASSERT_EQUAL_l_fp(a, b) { \ + TEST_ASSERT_EQUAL_MESSAGE(a.l_i, b.l_i, "Field l_i"); \ + TEST_ASSERT_EQUAL_UINT_MESSAGE(a.l_uf, b.l_uf, "Field l_uf"); \ } - typedef int bool; // typedef enum { FALSE, TRUE } boolean; -> can't use this because TRUE and FALSE are already defined @@ -28,23 +29,23 @@ typedef struct { } lfp_hl; -int l_fp_scmp(const l_fp first, const l_fp second); -int l_fp_ucmp(const l_fp first, l_fp second ); -l_fp l_fp_init(int32 i, u_int32 f); -l_fp l_fp_add(const l_fp first, const l_fp second); -l_fp l_fp_subtract(const l_fp first, const l_fp second); -l_fp l_fp_negate(const l_fp first); -l_fp l_fp_abs(const l_fp first); -int l_fp_signum(const l_fp first); -double l_fp_convert_to_double(const l_fp first); -l_fp l_fp_init_from_double( double rhs); -void l_fp_swap(l_fp * first, l_fp *second); -bool l_isgt(const l_fp first, const l_fp second); -bool l_isgtu(const l_fp first, const l_fp second); -bool l_ishis(const l_fp first, const l_fp second); -bool l_isgeq(const l_fp first, const l_fp second); -bool l_isequ(const l_fp first, const l_fp second); -double eps(double d); +int l_fp_scmp(const l_fp first, const l_fp second); +int l_fp_ucmp(const l_fp first, l_fp second); +l_fp l_fp_init(int32 i, u_int32 f); +l_fp l_fp_add(const l_fp first, const l_fp second); +l_fp l_fp_subtract(const l_fp first, const l_fp second); +l_fp l_fp_negate(const l_fp first); +l_fp l_fp_abs(const l_fp first); +int l_fp_signum(const l_fp first); +double l_fp_convert_to_double(const l_fp first); +l_fp l_fp_init_from_double( double rhs); +void l_fp_swap(l_fp * first, l_fp *second); +bool l_isgt(const l_fp first, const l_fp second); +bool l_isgtu(const l_fp first, const l_fp second); +bool l_ishis(const l_fp first, const l_fp second); +bool l_isgeq(const l_fp first, const l_fp second); +bool l_isequ(const l_fp first, const l_fp second); +double eps(double d); void test_AdditionLR(void); @@ -58,7 +59,6 @@ void test_SignedRelOps(void); void test_UnsignedRelOps(void); - static int cmp_work(u_int32 a[3], u_int32 b[3]); //---------------------------------------------------------------------- @@ -72,10 +72,10 @@ int l_fp_scmp(const l_fp first, const l_fp second) { u_int32 a[3], b[3]; - + const l_fp op1 = first; const l_fp op2 = second; - + a[0] = op1.l_uf; a[1] = op1.l_ui; a[2] = 0; b[0] = op2.l_uf; b[1] = op2.l_ui; b[2] = 0; @@ -86,12 +86,12 @@ l_fp_scmp(const l_fp first, const l_fp second) } int -l_fp_ucmp(const l_fp first, l_fp second ) +l_fp_ucmp(const l_fp first, l_fp second) { u_int32 a[3], b[3]; const l_fp op1 = first; const l_fp op2 = second; - + a[0] = op1.l_uf; a[1] = op1.l_ui; a[2] = 0; b[0] = op2.l_uf; b[1] = op2.l_ui; b[2] = 0; @@ -142,7 +142,7 @@ l_fp_subtract(const l_fp first, const l_fp second) { l_fp temp = first; L_SUB(&temp, &second); - + return temp; } @@ -151,7 +151,7 @@ l_fp_negate(const l_fp first) { l_fp temp = first; L_NEG(&temp); - + return temp; } @@ -189,11 +189,14 @@ l_fp_init_from_double( double rhs) } void -l_fp_swap(l_fp * first, l_fp *second){ +l_fp_swap(l_fp * first, l_fp *second) +{ l_fp temp = *second; *second = *first; *first = temp; + + return; } //---------------------------------------------------------------------- @@ -204,27 +207,37 @@ l_fp_swap(l_fp * first, l_fp *second){ bool -l_isgt (const l_fp first, const l_fp second) { +l_isgt (const l_fp first, const l_fp second) +{ + return L_ISGT(&first, &second); } bool -l_isgtu(const l_fp first, const l_fp second) { +l_isgtu(const l_fp first, const l_fp second) +{ + return L_ISGTU(&first, &second); } bool -l_ishis(const l_fp first, const l_fp second) { +l_ishis(const l_fp first, const l_fp second) +{ + return L_ISHIS(&first, &second); } bool -l_isgeq(const l_fp first, const l_fp second) { +l_isgeq(const l_fp first, const l_fp second) +{ + return L_ISGEQ(&first, &second); } bool -l_isequ(const l_fp first, const l_fp second) { +l_isequ(const l_fp first, const l_fp second) +{ + return L_ISEQU(&first, &second); } @@ -275,6 +288,7 @@ static const size_t addsub_tot = (sizeof(addsub_tab)/sizeof(addsub_tab[0][0])); double eps(double d) { + return fmax(ldexp(1.0, -31), ldexp(fabs(d), -53)); } @@ -282,61 +296,71 @@ eps(double d) // test addition //---------------------------------------------------------------------- void -test_AdditionLR(void) { - +test_AdditionLR(void) +{ size_t idx = 0; + for (idx = 0; idx < addsub_cnt; ++idx) { l_fp op1 = l_fp_init(addsub_tab[idx][0].h, addsub_tab[idx][0].l); l_fp op2 = l_fp_init(addsub_tab[idx][1].h, addsub_tab[idx][1].l); - l_fp exp = l_fp_init(addsub_tab[idx][2].h, addsub_tab[idx][2].l); - l_fp res = l_fp_add(op1, op2); + l_fp e_res = l_fp_init(addsub_tab[idx][2].h, addsub_tab[idx][2].l); + l_fp res = l_fp_add(op1, op2); - TEST_ASSERT_EQUAL_l_fp(exp, res); - } + TEST_ASSERT_EQUAL_l_fp(e_res, res); + } + return; } void -test_AdditionRL(void) { +test_AdditionRL(void) +{ size_t idx = 0; + for (idx = 0; idx < addsub_cnt; ++idx) { l_fp op2 = l_fp_init(addsub_tab[idx][0].h, addsub_tab[idx][0].l); l_fp op1 = l_fp_init(addsub_tab[idx][1].h, addsub_tab[idx][1].l); - l_fp exp = l_fp_init(addsub_tab[idx][2].h, addsub_tab[idx][2].l); + l_fp e_res = l_fp_init(addsub_tab[idx][2].h, addsub_tab[idx][2].l); l_fp res = l_fp_add(op1, op2); - TEST_ASSERT_EQUAL_l_fp(exp, res); - } + TEST_ASSERT_EQUAL_l_fp(e_res, res); + } + return; } - //---------------------------------------------------------------------- // test subtraction //---------------------------------------------------------------------- void -test_SubtractionLR(void) { +test_SubtractionLR(void) +{ size_t idx = 0; + for (idx = 0; idx < addsub_cnt; ++idx) { l_fp op2 = l_fp_init(addsub_tab[idx][0].h, addsub_tab[idx][0].l); - l_fp exp = l_fp_init(addsub_tab[idx][1].h, addsub_tab[idx][1].l); + l_fp e_res = l_fp_init(addsub_tab[idx][1].h, addsub_tab[idx][1].l); l_fp op1 = l_fp_init(addsub_tab[idx][2].h, addsub_tab[idx][2].l); l_fp res = l_fp_subtract(op1, op2); - - TEST_ASSERT_EQUAL_l_fp(exp, res); - } + + TEST_ASSERT_EQUAL_l_fp(e_res, res); + } + return; } void -test_SubtractionRL(void) { +test_SubtractionRL(void) +{ size_t idx = 0; + for (idx = 0; idx < addsub_cnt; ++idx) { - l_fp exp = l_fp_init(addsub_tab[idx][0].h, addsub_tab[idx][0].l); + l_fp e_res = l_fp_init(addsub_tab[idx][0].h, addsub_tab[idx][0].l); l_fp op2 = l_fp_init(addsub_tab[idx][1].h, addsub_tab[idx][1].l); l_fp op1 = l_fp_init(addsub_tab[idx][2].h, addsub_tab[idx][2].l); l_fp res = l_fp_subtract(op1, op2); - TEST_ASSERT_EQUAL_l_fp(exp, res); - } + TEST_ASSERT_EQUAL_l_fp(e_res, res); + } + return; } //---------------------------------------------------------------------- @@ -344,18 +368,20 @@ test_SubtractionRL(void) { //---------------------------------------------------------------------- void -test_Negation(void) { - +test_Negation(void) +{ size_t idx = 0; + for (idx = 0; idx < addsub_cnt; ++idx) { l_fp op1 = l_fp_init(addsub_tab[idx][0].h, addsub_tab[idx][0].l); l_fp op2 = l_fp_negate(op1); l_fp sum = l_fp_add(op1, op2); - + l_fp zero = l_fp_init(0, 0); TEST_ASSERT_EQUAL_l_fp(zero, sum); - } + } + return; } @@ -364,21 +390,23 @@ test_Negation(void) { // test absolute value //---------------------------------------------------------------------- void -test_Absolute(void) { +test_Absolute(void) +{ size_t idx = 0; + for (idx = 0; idx < addsub_cnt; ++idx) { l_fp op1 = l_fp_init(addsub_tab[idx][0].h, addsub_tab[idx][0].l); l_fp op2 = l_fp_abs(op1); - TEST_ASSERT_TRUE(l_fp_signum(op2) >= 0); + TEST_ASSERT_TRUE(l_fp_signum(op2) >= 0); if (l_fp_signum(op1) >= 0) - op1 = l_fp_subtract(op1, op2); + op1 = l_fp_subtract(op1, op2); else op1 = l_fp_add(op1, op2); - + l_fp zero = l_fp_init(0, 0); - + TEST_ASSERT_EQUAL_l_fp(zero, op1); } @@ -390,6 +418,8 @@ test_Absolute(void) { TEST_ASSERT_EQUAL(-1, l_fp_signum(minVal)); TEST_ASSERT_EQUAL_l_fp(minVal, minAbs); + + return; } @@ -397,14 +427,17 @@ test_Absolute(void) { // fp -> double -> fp rountrip test //---------------------------------------------------------------------- void -test_FDF_RoundTrip(void) { +test_FDF_RoundTrip(void) +{ + size_t idx = 0; + // since a l_fp has 64 bits in it's mantissa and a double has // only 54 bits available (including the hidden '1') we have to // make a few concessions on the roundtrip precision. The 'eps()' // function makes an educated guess about the avilable precision // and checks the difference in the two 'l_fp' values against // that limit. - size_t idx = 0; + for (idx = 0; idx < addsub_cnt; ++idx) { l_fp op1 = l_fp_init(addsub_tab[idx][0].h, addsub_tab[idx][0].l); double op2 = l_fp_convert_to_double(op1); @@ -412,8 +445,10 @@ test_FDF_RoundTrip(void) { l_fp temp = l_fp_subtract(op1, op3); double d = l_fp_convert_to_double(temp); - TEST_ASSERT_DOUBLE_WITHIN(eps(op2), 0.0, fabs(d)); - } + TEST_ASSERT_DOUBLE_WITHIN(eps(op2), 0.0, fabs(d)); + } + + return; } @@ -424,14 +459,16 @@ test_FDF_RoundTrip(void) { // macros in 'ntp_fp.h' produce mathing results. // ---------------------------------------------------------------------- void -test_SignedRelOps(void) { +test_SignedRelOps(void) +{ const lfp_hl * tv = (&addsub_tab[0][0]); size_t lc ; + for (lc = addsub_tot - 1; lc; --lc, ++tv) { l_fp op1 = l_fp_init(tv[0].h, tv[0].l); l_fp op2 = l_fp_init(tv[1].h, tv[1].l); - int cmp = l_fp_scmp(op1, op2); - + int cmp = l_fp_scmp(op1, op2); + switch (cmp) { case -1: //printf("op1:%d %d, op2:%d %d\n",op1.l_uf,op1.l_ui,op2.l_uf,op2.l_ui); @@ -458,15 +495,19 @@ test_SignedRelOps(void) { TEST_ASSERT_TRUE (l_isequ(op2, op1)); break; default: - TEST_FAIL_MESSAGE("unexpected UCMP result: " ); + TEST_FAIL_MESSAGE("unexpected UCMP result: "); } } + + return; } void -test_UnsignedRelOps(void) { - const lfp_hl * tv =(&addsub_tab[0][0]); +test_UnsignedRelOps(void) +{ + const lfp_hl * tv =(&addsub_tab[0][0]); size_t lc; + for (lc = addsub_tot - 1; lc; --lc, ++tv) { l_fp op1 = l_fp_init(tv[0].h, tv[0].l); l_fp op2 = l_fp_init(tv[1].h, tv[1].l); @@ -492,10 +533,13 @@ test_UnsignedRelOps(void) { TEST_ASSERT_TRUE (l_ishis(op2, op1)); break; default: - TEST_FAIL_MESSAGE("unexpected UCMP result: " ); + TEST_FAIL_MESSAGE("unexpected UCMP result: "); } } + + return; } + /* */ diff --git a/contrib/ntp/tests/libntp/lfptostr.c b/contrib/ntp/tests/libntp/lfptostr.c index 142e6c7..ed32853 100644 --- a/contrib/ntp/tests/libntp/lfptostr.c +++ b/contrib/ntp/tests/libntp/lfptostr.c @@ -20,6 +20,7 @@ static const int HALF_PROMILLE_UP = 2147484; /* slightly more than 0.0005 */ static const int HALF_PROMILLE_DOWN = 2147483; /* slightly less than 0.0005 */ +void setUp(void); void test_PositiveInteger(void); void test_NegativeInteger(void); void test_PositiveIntegerWithFraction(void); @@ -33,6 +34,14 @@ void test_MillisecondsRoundingDown(void); void test_UnsignedInteger(void); +void +setUp(void) +{ + init_lib(); + + return; +} + void test_PositiveInteger(void) { diff --git a/contrib/ntp/tests/libntp/modetoa.c b/contrib/ntp/tests/libntp/modetoa.c index 267b44e..03b384c 100644 --- a/contrib/ntp/tests/libntp/modetoa.c +++ b/contrib/ntp/tests/libntp/modetoa.c @@ -4,11 +4,21 @@ #include "unity.h" +void setUp(void); void test_KnownMode(void); void test_UnknownMode(void); void +setUp(void) +{ + init_lib(); + + return; +} + + +void test_KnownMode(void) { const int MODE = 3; // Should be "client" diff --git a/contrib/ntp/tests/libntp/msyslog.c b/contrib/ntp/tests/libntp/msyslog.c index dec8d85..987c814 100644 --- a/contrib/ntp/tests/libntp/msyslog.c +++ b/contrib/ntp/tests/libntp/msyslog.c @@ -10,6 +10,7 @@ void format_errmsg(char *, size_t, const char *, int); #endif +void setUp(void); void test_msnprintf(void); void test_msnprintfLiteralPercentm(void); void test_msnprintfBackslashLiteralPercentm(void); @@ -21,6 +22,15 @@ void test_msnprintfTruncate(void); void +setUp(void) +{ + init_lib(); + + return; +} + + +void test_msnprintf(void) { #define FMT_PREFIX "msyslog.cpp ENOENT: " char exp_buf[512]; diff --git a/contrib/ntp/tests/libntp/netof.c b/contrib/ntp/tests/libntp/netof.c index 2fde6cc..59dd709 100644 --- a/contrib/ntp/tests/libntp/netof.c +++ b/contrib/ntp/tests/libntp/netof.c @@ -8,14 +8,25 @@ #include "sockaddrtest.h" +void setUp(void); void test_ClassBAddress(void); void test_ClassCAddress(void); void test_ClassAAddress(void); void test_IPv6Address(void); +void +setUp(void) +{ + init_lib(); -void test_ClassBAddress(void) { + return; +} + + +void +test_ClassBAddress(void) +{ sockaddr_u input = CreateSockaddr4("172.16.2.1", NTP_PORT); sockaddr_u expected = CreateSockaddr4("172.16.0.0", NTP_PORT); @@ -23,9 +34,13 @@ void test_ClassBAddress(void) { TEST_ASSERT_TRUE(actual != NULL); TEST_ASSERT_TRUE(IsEqual(expected, *actual)); + + return; } -void test_ClassCAddress(void) { +void +test_ClassCAddress(void) +{ sockaddr_u input = CreateSockaddr4("192.0.2.255", NTP_PORT); sockaddr_u expected = CreateSockaddr4("192.0.2.0", NTP_PORT); @@ -33,9 +48,14 @@ void test_ClassCAddress(void) { TEST_ASSERT_TRUE(actual != NULL); TEST_ASSERT_TRUE(IsEqual(expected, *actual)); + + return; } -void test_ClassAAddress(void) { + +void +test_ClassAAddress(void) +{ /* Class A addresses are assumed to be classless, * thus the same address should be returned. */ @@ -46,24 +66,28 @@ void test_ClassAAddress(void) { TEST_ASSERT_TRUE(actual != NULL); TEST_ASSERT_TRUE(IsEqual(expected, *actual)); + + return; } -void test_IPv6Address(void) { +void +test_IPv6Address(void) +{ /* IPv6 addresses are assumed to have 64-bit host- and 64-bit network parts. */ - const struct in6_addr input_address = { + const struct in6_addr input_address = { { { 0x20, 0x01, 0x0d, 0xb8, - 0x85, 0xa3, 0x08, 0xd3, - 0x13, 0x19, 0x8a, 0x2e, - 0x03, 0x70, 0x73, 0x34 - }; // 2001:0db8:85a3:08d3:1319:8a2e:0370:7334 + 0x85, 0xa3, 0x08, 0xd3, + 0x13, 0x19, 0x8a, 0x2e, + 0x03, 0x70, 0x73, 0x34 + } } }; // 2001:0db8:85a3:08d3:1319:8a2e:0370:7334 - const struct in6_addr expected_address = { + const struct in6_addr expected_address = { { { 0x20, 0x01, 0x0d, 0xb8, - 0x85, 0xa3, 0x08, 0xd3, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 - }; // 2001:0db8:85a3:08d3:0000:0000:0000:0000 - + 0x85, 0xa3, 0x08, 0xd3, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 + } } }; // 2001:0db8:85a3:08d3:0000:0000:0000:0000 + sockaddr_u input; input.sa6.sin6_family = AF_INET6; input.sa6.sin6_addr = input_address; @@ -78,5 +102,6 @@ void test_IPv6Address(void) { TEST_ASSERT_TRUE(actual != NULL); TEST_ASSERT_TRUE(IsEqual(expected, *actual)); -} + return; +} diff --git a/contrib/ntp/tests/libntp/numtoa.c b/contrib/ntp/tests/libntp/numtoa.c index 5c7a663..42638b6 100644 --- a/contrib/ntp/tests/libntp/numtoa.c +++ b/contrib/ntp/tests/libntp/numtoa.c @@ -5,9 +5,20 @@ #include "unity.h" +void setUp(void); void test_Address(void); void test_Netmask(void); + +void +setUp(void) +{ + init_lib(); + + return; +} + + void test_Address(void) { const u_int32 input = htonl(3221225472UL + 512UL + 1UL); // 192.0.2.1 diff --git a/contrib/ntp/tests/libntp/numtohost.c b/contrib/ntp/tests/libntp/numtohost.c index cfce2d8..1c095eb 100644 --- a/contrib/ntp/tests/libntp/numtohost.c +++ b/contrib/ntp/tests/libntp/numtohost.c @@ -5,8 +5,19 @@ #include "unity.h" +void setUp(void); void test_LoopbackNetNonResolve(void); + +void +setUp(void) +{ + init_lib(); + + return; +} + + void test_LoopbackNetNonResolve(void) { /* A loopback address in 127.0.0.0/8 is chosen, and @@ -15,6 +26,6 @@ test_LoopbackNetNonResolve(void) { */ const u_int32 input = 127*256*256*256 + 1*256 + 1; // 127.0.1.1 - + TEST_ASSERT_EQUAL_STRING("127.0.1.1", numtohost(htonl(input))); } diff --git a/contrib/ntp/tests/libntp/octtoint.c b/contrib/ntp/tests/libntp/octtoint.c index 5c03d6d..83a1c99 100644 --- a/contrib/ntp/tests/libntp/octtoint.c +++ b/contrib/ntp/tests/libntp/octtoint.c @@ -14,61 +14,83 @@ void test_IllegalCharacter(void); void test_IllegalDigit(void); -void test_SingleDigit(void) { +void +test_SingleDigit(void) +{ const char* str = "5"; u_long actual; - TEST_ASSERT_TRUE(octtoint(str, &actual) ); + TEST_ASSERT_TRUE(octtoint(str, &actual)); TEST_ASSERT_EQUAL(5, actual); + + return; } -void test_MultipleDigits(void){ +void +test_MultipleDigits(void) +{ const char* str = "271"; u_long actual; - TEST_ASSERT_TRUE(octtoint(str, &actual) ); + TEST_ASSERT_TRUE(octtoint(str, &actual)); TEST_ASSERT_EQUAL(185, actual); + return; } -void test_Zero(void){ +void +test_Zero(void) +{ const char* str = "0"; u_long actual; - TEST_ASSERT_TRUE(octtoint(str, &actual) ); + TEST_ASSERT_TRUE(octtoint(str, &actual)); TEST_ASSERT_EQUAL(0, actual); + return; } -void test_MaximumUnsigned32bit(void){ +void +test_MaximumUnsigned32bit(void) +{ const char* str = "37777777777"; u_long actual; - TEST_ASSERT_TRUE(octtoint(str, &actual) ); + TEST_ASSERT_TRUE(octtoint(str, &actual)); TEST_ASSERT_EQUAL(4294967295UL, actual); + return; } -void test_Overflow(void){ +void +test_Overflow(void) +{ const char* str = "40000000000"; u_long actual; - TEST_ASSERT_FALSE(octtoint(str, &actual) ); + TEST_ASSERT_FALSE(octtoint(str, &actual)); + return; } -void test_IllegalCharacter(void){ +void +test_IllegalCharacter(void) +{ const char* str = "5ac2"; u_long actual; - TEST_ASSERT_FALSE(octtoint(str, &actual) ); + TEST_ASSERT_FALSE(octtoint(str, &actual)); + return; } -void test_IllegalDigit(void){ +void +test_IllegalDigit(void) +{ const char* str = "5283"; u_long actual; - TEST_ASSERT_FALSE(octtoint(str, &actual) ); + TEST_ASSERT_FALSE(octtoint(str, &actual)); + return; } diff --git a/contrib/ntp/tests/libntp/prettydate.c b/contrib/ntp/tests/libntp/prettydate.c index e1292bf..c940e2a 100644 --- a/contrib/ntp/tests/libntp/prettydate.c +++ b/contrib/ntp/tests/libntp/prettydate.c @@ -6,15 +6,26 @@ #include "unity.h" +void setUp(void); void test_ConstantDate(void); void +setUp(void) +{ + init_lib(); + + return; +} + + +void test_ConstantDate(void) { const u_int32 HALF = 2147483648UL; - l_fp time = {{3485080800UL}, HALF}; /* 2010-06-09 14:00:00.5 */ + l_fp e_time = {{3485080800UL}, HALF}; /* 2010-06-09 14:00:00.5 */ TEST_ASSERT_EQUAL_STRING("cfba1ce0.80000000 Wed, Jun 9 2010 14:00:00.500", - gmprettydate(&time)); + gmprettydate(&e_time)); + return; } diff --git a/contrib/ntp/tests/libntp/recvbuff.c b/contrib/ntp/tests/libntp/recvbuff.c index 6d6cf8e..6c089bb 100644 --- a/contrib/ntp/tests/libntp/recvbuff.c +++ b/contrib/ntp/tests/libntp/recvbuff.c @@ -13,6 +13,9 @@ void setUp(void) { init_recvbuff(RECV_INIT); + init_lib(); + + return; } void @@ -36,7 +39,7 @@ test_GetAndFree(void) { void test_GetAndFill(void) { - int initial = free_recvbuffs(); + // int initial = free_recvbuffs(); recvbuf_t* buf = get_free_recv_buffer(); add_full_recv_buffer(buf); diff --git a/contrib/ntp/tests/libntp/refidsmear.c b/contrib/ntp/tests/libntp/refidsmear.c index 04f396c..da1ebff 100644 --- a/contrib/ntp/tests/libntp/refidsmear.c +++ b/contrib/ntp/tests/libntp/refidsmear.c @@ -29,12 +29,21 @@ */ - +void setUp(void); void rtol(uint32_t r, char *es); void rtoltor(uint32_t er, char *es); void ltor(l_fp l, char *er); void test_refidsmear(void); + +void +setUp(void) +{ + init_lib(); + + return; +} + void rtol(uint32_t r, char *es) { @@ -48,7 +57,7 @@ rtol(uint32_t r, char *es) l = convertRefIDToLFP(htonl(r)); as = lfptoa(&l, 8); - + //printf("refid %#x, smear %s\n", r, as); TEST_ASSERT_NOT_NULL_MESSAGE(as, msg); @@ -58,8 +67,6 @@ rtol(uint32_t r, char *es) } - - void rtoltor(uint32_t er, char *es) { diff --git a/contrib/ntp/tests/libntp/refnumtoa.c b/contrib/ntp/tests/libntp/refnumtoa.c index 33ad3aa..9db5fb1 100644 --- a/contrib/ntp/tests/libntp/refnumtoa.c +++ b/contrib/ntp/tests/libntp/refnumtoa.c @@ -9,11 +9,21 @@ /* Might need to be updated if a new refclock gets this id. */ static const int UNUSED_REFCLOCK_ID = 250; +void setUp(void); void test_LocalClock(void); void test_UnknownId(void); void +setUp(void) +{ + init_lib(); + + return; +} + + +void test_LocalClock(void) { #ifdef REFCLOCK /* clockname() is useless otherwise */ /* We test with a refclock address of type LOCALCLOCK. @@ -26,7 +36,7 @@ test_LocalClock(void) { sockaddr_u address; address.sa4.sin_family = AF_INET; address.sa4.sin_addr.s_addr = htonl(addr); - + char stringStart[100]= ""; strcat(stringStart, clockname(REFCLK_LOCALCLOCK)); @@ -35,7 +45,7 @@ test_LocalClock(void) { char * expected = stringStart; TEST_ASSERT_EQUAL_STRING(expected, refnumtoa(&address)); -#else +#else TEST_IGNORE_MESSAGE("REFCLOCK NOT DEFINED, SKIPPING TEST"); #endif /* REFCLOCK */ } @@ -51,16 +61,16 @@ test_UnknownId(void) { sockaddr_u address; address.sa4.sin_family = AF_INET; address.sa4.sin_addr.s_addr = htonl(addr); - + char stringStart[100]= "REFCLK("; - char value[100] ; + char value[100] ; snprintf(value, sizeof(value), "%d", UNUSED_REFCLOCK_ID); strcat(stringStart,value); strcat(stringStart,",4)"); char * expected = stringStart; TEST_ASSERT_EQUAL_STRING(expected, refnumtoa(&address)); -#else +#else TEST_IGNORE_MESSAGE("REFCLOCK NOT DEFINED, SKIPPING TEST"); #endif /* REFCLOCK */ } diff --git a/contrib/ntp/tests/libntp/run-a_md5encrypt.c b/contrib/ntp/tests/libntp/run-a_md5encrypt.c index 122ed93..a4bfa36 100644 --- a/contrib/ntp/tests/libntp/run-a_md5encrypt.c +++ b/contrib/ntp/tests/libntp/run-a_md5encrypt.c @@ -52,11 +52,11 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("a_md5encrypt.c"); - RUN_TEST(test_Encrypt, 29); - RUN_TEST(test_DecryptValid, 30); - RUN_TEST(test_DecryptInvalid, 31); - RUN_TEST(test_IPv4AddressToRefId, 32); - RUN_TEST(test_IPv6AddressToRefId, 33); + RUN_TEST(test_Encrypt, 40); + RUN_TEST(test_DecryptValid, 41); + RUN_TEST(test_DecryptInvalid, 42); + RUN_TEST(test_IPv4AddressToRefId, 43); + RUN_TEST(test_IPv6AddressToRefId, 44); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-calendar.c b/contrib/ntp/tests/libntp/run-calendar.c index 50c5b20..555f3ba 100644 --- a/contrib/ntp/tests/libntp/run-calendar.c +++ b/contrib/ntp/tests/libntp/run-calendar.c @@ -63,21 +63,21 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("calendar.c"); - RUN_TEST(test_DaySplitMerge, 21); - RUN_TEST(test_SplitYearDays1, 22); - RUN_TEST(test_SplitYearDays2, 23); - RUN_TEST(test_RataDie1, 24); - RUN_TEST(test_LeapYears1, 25); - RUN_TEST(test_LeapYears2, 26); - RUN_TEST(test_RoundTripDate, 27); - RUN_TEST(test_RoundTripYearStart, 28); - RUN_TEST(test_RoundTripMonthStart, 29); - RUN_TEST(test_RoundTripWeekStart, 30); - RUN_TEST(test_RoundTripDayStart, 31); - RUN_TEST(test_IsoCalYearsToWeeks, 32); - RUN_TEST(test_IsoCalWeeksToYearStart, 33); - RUN_TEST(test_IsoCalWeeksToYearEnd, 34); - RUN_TEST(test_DaySecToDate, 35); + RUN_TEST(test_DaySplitMerge, 22); + RUN_TEST(test_SplitYearDays1, 23); + RUN_TEST(test_SplitYearDays2, 24); + RUN_TEST(test_RataDie1, 25); + RUN_TEST(test_LeapYears1, 26); + RUN_TEST(test_LeapYears2, 27); + RUN_TEST(test_RoundTripDate, 28); + RUN_TEST(test_RoundTripYearStart, 29); + RUN_TEST(test_RoundTripMonthStart, 30); + RUN_TEST(test_RoundTripWeekStart, 31); + RUN_TEST(test_RoundTripDayStart, 32); + RUN_TEST(test_IsoCalYearsToWeeks, 33); + RUN_TEST(test_IsoCalWeeksToYearStart, 34); + RUN_TEST(test_IsoCalWeeksToYearEnd, 35); + RUN_TEST(test_DaySecToDate, 36); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-decodenetnum.c b/contrib/ntp/tests/libntp/run-decodenetnum.c index 014151e..57b955c 100644 --- a/contrib/ntp/tests/libntp/run-decodenetnum.c +++ b/contrib/ntp/tests/libntp/run-decodenetnum.c @@ -53,12 +53,12 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("decodenetnum.c"); - RUN_TEST(test_IPv4AddressOnly, 7); - RUN_TEST(test_IPv4AddressWithPort, 8); - RUN_TEST(test_IPv6AddressOnly, 10); - RUN_TEST(test_IPv6AddressWithPort, 11); - RUN_TEST(test_IllegalAddress, 13); - RUN_TEST(test_IllegalCharInPort, 14); + RUN_TEST(test_IPv4AddressOnly, 8); + RUN_TEST(test_IPv4AddressWithPort, 9); + RUN_TEST(test_IPv6AddressOnly, 11); + RUN_TEST(test_IPv6AddressWithPort, 12); + RUN_TEST(test_IllegalAddress, 14); + RUN_TEST(test_IllegalCharInPort, 15); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-humandate.c b/contrib/ntp/tests/libntp/run-humandate.c index 1f2e717..690895f 100644 --- a/contrib/ntp/tests/libntp/run-humandate.c +++ b/contrib/ntp/tests/libntp/run-humandate.c @@ -49,8 +49,8 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("humandate.c"); - RUN_TEST(test_RegularTime, 8); - RUN_TEST(test_CurrentTime, 9); + RUN_TEST(test_RegularTime, 9); + RUN_TEST(test_CurrentTime, 10); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-lfpfunc.c b/contrib/ntp/tests/libntp/run-lfpfunc.c index ac6700f..83f9668 100644 --- a/contrib/ntp/tests/libntp/run-lfpfunc.c +++ b/contrib/ntp/tests/libntp/run-lfpfunc.c @@ -58,15 +58,15 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("lfpfunc.c"); - RUN_TEST(test_AdditionLR, 50); - RUN_TEST(test_AdditionRL, 51); - RUN_TEST(test_SubtractionLR, 52); - RUN_TEST(test_SubtractionRL, 53); - RUN_TEST(test_Negation, 54); - RUN_TEST(test_Absolute, 55); - RUN_TEST(test_FDF_RoundTrip, 56); - RUN_TEST(test_SignedRelOps, 57); - RUN_TEST(test_UnsignedRelOps, 58); + RUN_TEST(test_AdditionLR, 51); + RUN_TEST(test_AdditionRL, 52); + RUN_TEST(test_SubtractionLR, 53); + RUN_TEST(test_SubtractionRL, 54); + RUN_TEST(test_Negation, 55); + RUN_TEST(test_Absolute, 56); + RUN_TEST(test_FDF_RoundTrip, 57); + RUN_TEST(test_SignedRelOps, 58); + RUN_TEST(test_UnsignedRelOps, 59); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-lfptostr.c b/contrib/ntp/tests/libntp/run-lfptostr.c index bae0f85..fbdeb7a 100644 --- a/contrib/ntp/tests/libntp/run-lfptostr.c +++ b/contrib/ntp/tests/libntp/run-lfptostr.c @@ -58,17 +58,17 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("lfptostr.c"); - RUN_TEST(test_PositiveInteger, 23); - RUN_TEST(test_NegativeInteger, 24); - RUN_TEST(test_PositiveIntegerWithFraction, 25); - RUN_TEST(test_NegativeIntegerWithFraction, 26); - RUN_TEST(test_RoundingDownToInteger, 27); - RUN_TEST(test_RoundingMiddleToInteger, 28); - RUN_TEST(test_RoundingUpToInteger, 29); - RUN_TEST(test_SingleDecimal, 30); - RUN_TEST(test_MillisecondsRoundingUp, 31); - RUN_TEST(test_MillisecondsRoundingDown, 32); - RUN_TEST(test_UnsignedInteger, 33); + RUN_TEST(test_PositiveInteger, 24); + RUN_TEST(test_NegativeInteger, 25); + RUN_TEST(test_PositiveIntegerWithFraction, 26); + RUN_TEST(test_NegativeIntegerWithFraction, 27); + RUN_TEST(test_RoundingDownToInteger, 28); + RUN_TEST(test_RoundingMiddleToInteger, 29); + RUN_TEST(test_RoundingUpToInteger, 30); + RUN_TEST(test_SingleDecimal, 31); + RUN_TEST(test_MillisecondsRoundingUp, 32); + RUN_TEST(test_MillisecondsRoundingDown, 33); + RUN_TEST(test_UnsignedInteger, 34); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-modetoa.c b/contrib/ntp/tests/libntp/run-modetoa.c index 20e2d95..0c1558e 100644 --- a/contrib/ntp/tests/libntp/run-modetoa.c +++ b/contrib/ntp/tests/libntp/run-modetoa.c @@ -48,8 +48,8 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("modetoa.c"); - RUN_TEST(test_KnownMode, 7); - RUN_TEST(test_UnknownMode, 8); + RUN_TEST(test_KnownMode, 8); + RUN_TEST(test_UnknownMode, 9); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-msyslog.c b/contrib/ntp/tests/libntp/run-msyslog.c index 544fbc1..ff264f8 100644 --- a/contrib/ntp/tests/libntp/run-msyslog.c +++ b/contrib/ntp/tests/libntp/run-msyslog.c @@ -54,14 +54,14 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("msyslog.c"); - RUN_TEST(test_msnprintf, 13); - RUN_TEST(test_msnprintfLiteralPercentm, 14); - RUN_TEST(test_msnprintfBackslashLiteralPercentm, 15); - RUN_TEST(test_msnprintfBackslashPercent, 16); - RUN_TEST(test_msnprintfHangingPercent, 17); - RUN_TEST(test_format_errmsgHangingPercent, 18); - RUN_TEST(test_msnprintfNullTarget, 19); - RUN_TEST(test_msnprintfTruncate, 20); + RUN_TEST(test_msnprintf, 14); + RUN_TEST(test_msnprintfLiteralPercentm, 15); + RUN_TEST(test_msnprintfBackslashLiteralPercentm, 16); + RUN_TEST(test_msnprintfBackslashPercent, 17); + RUN_TEST(test_msnprintfHangingPercent, 18); + RUN_TEST(test_format_errmsgHangingPercent, 19); + RUN_TEST(test_msnprintfNullTarget, 20); + RUN_TEST(test_msnprintfTruncate, 21); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-netof.c b/contrib/ntp/tests/libntp/run-netof.c index 7a714f5..9301b84 100644 --- a/contrib/ntp/tests/libntp/run-netof.c +++ b/contrib/ntp/tests/libntp/run-netof.c @@ -52,10 +52,10 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("netof.c"); - RUN_TEST(test_ClassBAddress, 11); - RUN_TEST(test_ClassCAddress, 12); - RUN_TEST(test_ClassAAddress, 13); - RUN_TEST(test_IPv6Address, 14); + RUN_TEST(test_ClassBAddress, 12); + RUN_TEST(test_ClassCAddress, 13); + RUN_TEST(test_ClassAAddress, 14); + RUN_TEST(test_IPv6Address, 15); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-numtoa.c b/contrib/ntp/tests/libntp/run-numtoa.c index 640e61c..f3368a7 100644 --- a/contrib/ntp/tests/libntp/run-numtoa.c +++ b/contrib/ntp/tests/libntp/run-numtoa.c @@ -49,8 +49,8 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("numtoa.c"); - RUN_TEST(test_Address, 8); - RUN_TEST(test_Netmask, 9); + RUN_TEST(test_Address, 9); + RUN_TEST(test_Netmask, 10); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-numtohost.c b/contrib/ntp/tests/libntp/run-numtohost.c index 5ebe15b..49b5264 100644 --- a/contrib/ntp/tests/libntp/run-numtohost.c +++ b/contrib/ntp/tests/libntp/run-numtohost.c @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("numtohost.c"); - RUN_TEST(test_LoopbackNetNonResolve, 8); + RUN_TEST(test_LoopbackNetNonResolve, 9); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-prettydate.c b/contrib/ntp/tests/libntp/run-prettydate.c index e6c5ff3..e034cc2 100644 --- a/contrib/ntp/tests/libntp/run-prettydate.c +++ b/contrib/ntp/tests/libntp/run-prettydate.c @@ -49,7 +49,7 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("prettydate.c"); - RUN_TEST(test_ConstantDate, 9); + RUN_TEST(test_ConstantDate, 10); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-refnumtoa.c b/contrib/ntp/tests/libntp/run-refnumtoa.c index bb9fb60..d829580 100644 --- a/contrib/ntp/tests/libntp/run-refnumtoa.c +++ b/contrib/ntp/tests/libntp/run-refnumtoa.c @@ -49,8 +49,8 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("refnumtoa.c"); - RUN_TEST(test_LocalClock, 12); - RUN_TEST(test_UnknownId, 13); + RUN_TEST(test_LocalClock, 13); + RUN_TEST(test_UnknownId, 14); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-sfptostr.c b/contrib/ntp/tests/libntp/run-sfptostr.c index 1ebe43c..1dba912 100644 --- a/contrib/ntp/tests/libntp/run-sfptostr.c +++ b/contrib/ntp/tests/libntp/run-sfptostr.c @@ -24,6 +24,7 @@ #include <stdio.h> #include "config.h" #include "ntp_fp.h" +#include "ntp_stdlib.h" //=======External Functions This Runner Calls===== extern void setUp(void); @@ -54,14 +55,14 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("sfptostr.c"); - RUN_TEST(test_PositiveInteger, 11); - RUN_TEST(test_NegativeInteger, 12); - RUN_TEST(test_PositiveIntegerPositiveFraction, 13); - RUN_TEST(test_NegativeIntegerNegativeFraction, 14); - RUN_TEST(test_PositiveIntegerNegativeFraction, 15); - RUN_TEST(test_NegativeIntegerPositiveFraction, 16); - RUN_TEST(test_SingleDecimalInteger, 17); - RUN_TEST(test_SingleDecimalRounding, 18); + RUN_TEST(test_PositiveInteger, 13); + RUN_TEST(test_NegativeInteger, 14); + RUN_TEST(test_PositiveIntegerPositiveFraction, 15); + RUN_TEST(test_NegativeIntegerNegativeFraction, 16); + RUN_TEST(test_PositiveIntegerNegativeFraction, 17); + RUN_TEST(test_NegativeIntegerPositiveFraction, 18); + RUN_TEST(test_SingleDecimalInteger, 19); + RUN_TEST(test_SingleDecimalRounding, 20); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-socktoa.c b/contrib/ntp/tests/libntp/run-socktoa.c index a5066e3..df6ec9c 100644 --- a/contrib/ntp/tests/libntp/run-socktoa.c +++ b/contrib/ntp/tests/libntp/run-socktoa.c @@ -54,12 +54,12 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("socktoa.c"); - RUN_TEST(test_IPv4AddressWithPort, 10); - RUN_TEST(test_IPv6AddressWithPort, 12); - RUN_TEST(test_IgnoreIPv6Fields, 13); - RUN_TEST(test_ScopedIPv6AddressWithPort, 15); - RUN_TEST(test_HashEqual, 16); - RUN_TEST(test_HashNotEqual, 17); + RUN_TEST(test_IPv4AddressWithPort, 11); + RUN_TEST(test_IPv6AddressWithPort, 13); + RUN_TEST(test_IgnoreIPv6Fields, 14); + RUN_TEST(test_ScopedIPv6AddressWithPort, 16); + RUN_TEST(test_HashEqual, 17); + RUN_TEST(test_HashNotEqual, 18); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-statestr.c b/contrib/ntp/tests/libntp/run-statestr.c index 9cfe0bc..f0f9386 100644 --- a/contrib/ntp/tests/libntp/run-statestr.c +++ b/contrib/ntp/tests/libntp/run-statestr.c @@ -52,10 +52,10 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("statestr.c"); - RUN_TEST(test_PeerRestart, 9); - RUN_TEST(test_SysUnspecified, 10); - RUN_TEST(test_ClockCodeExists, 11); - RUN_TEST(test_ClockCodeUnknown, 12); + RUN_TEST(test_PeerRestart, 10); + RUN_TEST(test_SysUnspecified, 11); + RUN_TEST(test_ClockCodeExists, 12); + RUN_TEST(test_ClockCodeUnknown, 13); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-strtolfp.c b/contrib/ntp/tests/libntp/run-strtolfp.c index 7472319..404f57f 100644 --- a/contrib/ntp/tests/libntp/run-strtolfp.c +++ b/contrib/ntp/tests/libntp/run-strtolfp.c @@ -55,13 +55,13 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("strtolfp.c"); - RUN_TEST(test_PositiveInteger, 11); - RUN_TEST(test_NegativeInteger, 12); - RUN_TEST(test_PositiveFraction, 13); - RUN_TEST(test_NegativeFraction, 14); - RUN_TEST(test_PositiveMsFraction, 15); - RUN_TEST(test_NegativeMsFraction, 16); - RUN_TEST(test_InvalidChars, 17); + RUN_TEST(test_PositiveInteger, 12); + RUN_TEST(test_NegativeInteger, 13); + RUN_TEST(test_PositiveFraction, 14); + RUN_TEST(test_NegativeFraction, 15); + RUN_TEST(test_PositiveMsFraction, 16); + RUN_TEST(test_NegativeMsFraction, 17); + RUN_TEST(test_InvalidChars, 18); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-timespecops.c b/contrib/ntp/tests/libntp/run-timespecops.c index 6c26521..badc84a 100644 --- a/contrib/ntp/tests/libntp/run-timespecops.c +++ b/contrib/ntp/tests/libntp/run-timespecops.c @@ -78,34 +78,34 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("timespecops.c"); - RUN_TEST(test_Helpers1, 36); - RUN_TEST(test_Normalise, 37); - RUN_TEST(test_SignNoFrac, 38); - RUN_TEST(test_SignWithFrac, 39); - RUN_TEST(test_CmpFracEQ, 40); - RUN_TEST(test_CmpFracGT, 41); - RUN_TEST(test_CmpFracLT, 42); - RUN_TEST(test_AddFullNorm, 43); - RUN_TEST(test_AddFullOflow1, 44); - RUN_TEST(test_AddNsecNorm, 45); - RUN_TEST(test_AddNsecOflow1, 46); - RUN_TEST(test_SubFullNorm, 47); - RUN_TEST(test_SubFullOflow, 48); - RUN_TEST(test_SubNsecNorm, 49); - RUN_TEST(test_SubNsecOflow, 50); - RUN_TEST(test_Neg, 51); - RUN_TEST(test_AbsNoFrac, 52); - RUN_TEST(test_AbsWithFrac, 53); - RUN_TEST(test_Helpers2, 54); - RUN_TEST(test_ToLFPbittest, 55); - RUN_TEST(test_ToLFPrelPos, 56); - RUN_TEST(test_ToLFPrelNeg, 57); - RUN_TEST(test_ToLFPabs, 58); - RUN_TEST(test_FromLFPbittest, 59); - RUN_TEST(test_FromLFPrelPos, 60); - RUN_TEST(test_FromLFPrelNeg, 61); - RUN_TEST(test_LFProundtrip, 62); - RUN_TEST(test_ToString, 63); + RUN_TEST(test_Helpers1, 37); + RUN_TEST(test_Normalise, 38); + RUN_TEST(test_SignNoFrac, 39); + RUN_TEST(test_SignWithFrac, 40); + RUN_TEST(test_CmpFracEQ, 41); + RUN_TEST(test_CmpFracGT, 42); + RUN_TEST(test_CmpFracLT, 43); + RUN_TEST(test_AddFullNorm, 44); + RUN_TEST(test_AddFullOflow1, 45); + RUN_TEST(test_AddNsecNorm, 46); + RUN_TEST(test_AddNsecOflow1, 47); + RUN_TEST(test_SubFullNorm, 48); + RUN_TEST(test_SubFullOflow, 49); + RUN_TEST(test_SubNsecNorm, 50); + RUN_TEST(test_SubNsecOflow, 51); + RUN_TEST(test_Neg, 52); + RUN_TEST(test_AbsNoFrac, 53); + RUN_TEST(test_AbsWithFrac, 54); + RUN_TEST(test_Helpers2, 55); + RUN_TEST(test_ToLFPbittest, 56); + RUN_TEST(test_ToLFPrelPos, 57); + RUN_TEST(test_ToLFPrelNeg, 58); + RUN_TEST(test_ToLFPabs, 59); + RUN_TEST(test_FromLFPbittest, 60); + RUN_TEST(test_FromLFPrelPos, 61); + RUN_TEST(test_FromLFPrelNeg, 62); + RUN_TEST(test_LFProundtrip, 63); + RUN_TEST(test_ToString, 64); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-timevalops.c b/contrib/ntp/tests/libntp/run-timevalops.c index 4a9351c..df39ab9 100644 --- a/contrib/ntp/tests/libntp/run-timevalops.c +++ b/contrib/ntp/tests/libntp/run-timevalops.c @@ -77,34 +77,34 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("timevalops.c"); - RUN_TEST(test_Helpers1, 38); - RUN_TEST(test_Normalise, 39); - RUN_TEST(test_SignNoFrac, 40); - RUN_TEST(test_SignWithFrac, 41); - RUN_TEST(test_CmpFracEQ, 42); - RUN_TEST(test_CmpFracGT, 43); - RUN_TEST(test_CmpFracLT, 44); - RUN_TEST(test_AddFullNorm, 45); - RUN_TEST(test_AddFullOflow1, 46); - RUN_TEST(test_AddUsecNorm, 47); - RUN_TEST(test_AddUsecOflow1, 48); - RUN_TEST(test_SubFullNorm, 49); - RUN_TEST(test_SubFullOflow, 50); - RUN_TEST(test_SubUsecNorm, 51); - RUN_TEST(test_SubUsecOflow, 52); - RUN_TEST(test_Neg, 53); - RUN_TEST(test_AbsNoFrac, 54); - RUN_TEST(test_AbsWithFrac, 55); - RUN_TEST(test_Helpers2, 56); - RUN_TEST(test_ToLFPbittest, 57); - RUN_TEST(test_ToLFPrelPos, 58); - RUN_TEST(test_ToLFPrelNeg, 59); - RUN_TEST(test_ToLFPabs, 60); - RUN_TEST(test_FromLFPbittest, 61); - RUN_TEST(test_FromLFPrelPos, 62); - RUN_TEST(test_FromLFPrelNeg, 63); - RUN_TEST(test_LFProundtrip, 64); - RUN_TEST(test_ToString, 65); + RUN_TEST(test_Helpers1, 39); + RUN_TEST(test_Normalise, 40); + RUN_TEST(test_SignNoFrac, 41); + RUN_TEST(test_SignWithFrac, 42); + RUN_TEST(test_CmpFracEQ, 43); + RUN_TEST(test_CmpFracGT, 44); + RUN_TEST(test_CmpFracLT, 45); + RUN_TEST(test_AddFullNorm, 46); + RUN_TEST(test_AddFullOflow1, 47); + RUN_TEST(test_AddUsecNorm, 48); + RUN_TEST(test_AddUsecOflow1, 49); + RUN_TEST(test_SubFullNorm, 50); + RUN_TEST(test_SubFullOflow, 51); + RUN_TEST(test_SubUsecNorm, 52); + RUN_TEST(test_SubUsecOflow, 53); + RUN_TEST(test_Neg, 54); + RUN_TEST(test_AbsNoFrac, 55); + RUN_TEST(test_AbsWithFrac, 56); + RUN_TEST(test_Helpers2, 57); + RUN_TEST(test_ToLFPbittest, 58); + RUN_TEST(test_ToLFPrelPos, 59); + RUN_TEST(test_ToLFPrelNeg, 60); + RUN_TEST(test_ToLFPabs, 61); + RUN_TEST(test_FromLFPbittest, 62); + RUN_TEST(test_FromLFPrelPos, 63); + RUN_TEST(test_FromLFPrelNeg, 64); + RUN_TEST(test_LFProundtrip, 65); + RUN_TEST(test_ToString, 66); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-uglydate.c b/contrib/ntp/tests/libntp/run-uglydate.c index 6ec50f6..5667b70 100644 --- a/contrib/ntp/tests/libntp/run-uglydate.c +++ b/contrib/ntp/tests/libntp/run-uglydate.c @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("uglydate.c"); - RUN_TEST(test_ConstantDateTime, 8); + RUN_TEST(test_ConstantDateTime, 9); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/sfptostr.c b/contrib/ntp/tests/libntp/sfptostr.c index b115ae1..c7616c7 100644 --- a/contrib/ntp/tests/libntp/sfptostr.c +++ b/contrib/ntp/tests/libntp/sfptostr.c @@ -4,10 +4,12 @@ */ #include "config.h" #include "ntp_fp.h" +#include "ntp_stdlib.h" #include "unity.h" #define SFP_MAX_PRECISION 6 +void setUp(void); void test_PositiveInteger(void); void test_NegativeInteger(void); void test_PositiveIntegerPositiveFraction(void); @@ -18,6 +20,15 @@ void test_SingleDecimalInteger(void); void test_SingleDecimalRounding(void); +void +setUp(void) +{ + init_lib(); + + return; +} + + void test_PositiveInteger(void) { s_fp test = 300 << 16; // exact 300.000000 diff --git a/contrib/ntp/tests/libntp/socktoa.c b/contrib/ntp/tests/libntp/socktoa.c index 6661fa5..8423106 100644 --- a/contrib/ntp/tests/libntp/socktoa.c +++ b/contrib/ntp/tests/libntp/socktoa.c @@ -7,6 +7,7 @@ #include "sockaddrtest.h" +void setUp(void); void test_IPv4AddressWithPort(void); //#ifdef ISC_PLATFORM_HAVEIPV6 void test_IPv6AddressWithPort(void); @@ -16,6 +17,16 @@ void test_ScopedIPv6AddressWithPort(void); void test_HashEqual(void); void test_HashNotEqual(void); + +void +setUp(void) +{ + init_lib(); + + return; +} + + void test_IPv4AddressWithPort(void) { sockaddr_u input = CreateSockaddr4("192.0.2.10", 123); @@ -62,12 +73,12 @@ test_IPv6AddressWithPort(void) { void test_ScopedIPv6AddressWithPort(void) { #ifdef ISC_PLATFORM_HAVESCOPEID - const struct in6_addr address = { + const struct in6_addr address = { { { 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x12, 0x3f, 0xff, 0xfe, 0x29, 0xff, 0xfa - }; + } } }; const char* expected = "fe80::212:3fff:fe29:fffa%5"; diff --git a/contrib/ntp/tests/libntp/statestr.c b/contrib/ntp/tests/libntp/statestr.c index 810ee6b..e7a1bd7 100644 --- a/contrib/ntp/tests/libntp/statestr.c +++ b/contrib/ntp/tests/libntp/statestr.c @@ -6,11 +6,22 @@ #include "unity.h" +void setUp(void); void test_PeerRestart(void); void test_SysUnspecified(void); void test_ClockCodeExists(void); void test_ClockCodeUnknown(void); + +void +setUp(void) +{ + init_lib(); + + return; +} + + // eventstr() void test_PeerRestart(void) { diff --git a/contrib/ntp/tests/libntp/strtolfp.c b/contrib/ntp/tests/libntp/strtolfp.c index f40ab50..6855d9b 100644 --- a/contrib/ntp/tests/libntp/strtolfp.c +++ b/contrib/ntp/tests/libntp/strtolfp.c @@ -8,6 +8,7 @@ /* This file tests both atolfp and mstolfp */ +void setUp(void); void test_PositiveInteger(void); void test_NegativeInteger(void); void test_PositiveFraction(void); @@ -17,6 +18,15 @@ void test_NegativeMsFraction(void); void test_InvalidChars(void); +void +setUp(void) +{ + init_lib(); + + return; +} + + void test_PositiveInteger(void) { const char *str = "500"; const char *str_ms = "500000"; diff --git a/contrib/ntp/tests/libntp/timespecops.c b/contrib/ntp/tests/libntp/timespecops.c index 86df7a1..68a472a 100644 --- a/contrib/ntp/tests/libntp/timespecops.c +++ b/contrib/ntp/tests/libntp/timespecops.c @@ -10,14 +10,14 @@ #include <string.h> -#define TEST_ASSERT_EQUAL_timespec(a, b) { \ - TEST_ASSERT_EQUAL_MESSAGE(a.tv_sec, b.tv_sec, "Field tv_sec"); \ +#define TEST_ASSERT_EQUAL_timespec(a, b) { \ + TEST_ASSERT_EQUAL_MESSAGE(a.tv_sec, b.tv_sec, "Field tv_sec"); \ TEST_ASSERT_EQUAL_MESSAGE(a.tv_nsec, b.tv_nsec, "Field tv_nsec"); \ } -#define TEST_ASSERT_EQUAL_l_fp(a, b) { \ - TEST_ASSERT_EQUAL_MESSAGE(a.l_i, b.l_i, "Field l_i"); \ +#define TEST_ASSERT_EQUAL_l_fp(a, b) { \ + TEST_ASSERT_EQUAL_MESSAGE(a.l_i, b.l_i, "Field l_i"); \ TEST_ASSERT_EQUAL_UINT_MESSAGE(a.l_uf, b.l_uf, "Field l_uf"); \ } @@ -33,6 +33,7 @@ struct lfpfracdata { }; +void setUp(void); void test_Helpers1(void); void test_Normalise(void); void test_SignNoFrac(void); @@ -64,35 +65,52 @@ void test_ToString(void); typedef int bool; -const bool timespec_isValid(struct timespec V); +const bool timespec_isValid(struct timespec V); struct timespec timespec_init(time_t hi, long lo); -l_fp l_fp_init(int32 i, u_int32 f); -bool AssertFpClose(const l_fp m, const l_fp n, const l_fp limit); -bool AssertTimespecClose(const struct timespec m, const struct timespec n, const struct timespec limit); +l_fp l_fp_init(int32 i, u_int32 f); +bool AssertFpClose(const l_fp m, const l_fp n, const l_fp limit); +bool AssertTimespecClose(const struct timespec m, + const struct timespec n, + const struct timespec limit); -//******************************************MY CUSTOM FUNCTIONS******************************* +//***************************MY CUSTOM FUNCTIONS*************************** +void +setUp(void) +{ + init_lib(); + + return; +} + const bool -timespec_isValid(struct timespec V) { +timespec_isValid(struct timespec V) +{ + return V.tv_nsec >= 0 && V.tv_nsec < 1000000000; } struct timespec -timespec_init(time_t hi, long lo) { - struct timespec V; +timespec_init(time_t hi, long lo) +{ + struct timespec V; + V.tv_sec = hi; V.tv_nsec = lo; + return V; } l_fp -l_fp_init(int32 i, u_int32 f) { +l_fp_init(int32 i, u_int32 f) +{ l_fp temp; + temp.l_i = i; temp.l_uf = f; @@ -101,7 +119,8 @@ l_fp_init(int32 i, u_int32 f) { bool -AssertFpClose(const l_fp m, const l_fp n, const l_fp limit) { +AssertFpClose(const l_fp m, const l_fp n, const l_fp limit) +{ l_fp diff; if (L_ISGEQ(&m, &n)) { @@ -111,7 +130,7 @@ AssertFpClose(const l_fp m, const l_fp n, const l_fp limit) { diff = n; L_SUB(&diff, &m); } - if (L_ISGEQ(&limit, &diff)){ + if (L_ISGEQ(&limit, &diff)) { return TRUE; } else { @@ -122,7 +141,9 @@ AssertFpClose(const l_fp m, const l_fp n, const l_fp limit) { bool -AssertTimespecClose(const struct timespec m, const struct timespec n, const struct timespec limit) { +AssertTimespecClose(const struct timespec m, const struct timespec n, + const struct timespec limit) +{ struct timespec diff; diff = abs_tspec(sub_tspec(m, n)); @@ -156,11 +177,13 @@ static const struct lfpfracdata fdata[] = { u_int32 -my_tick_to_tsf(u_int32 ticks) { +my_tick_to_tsf(u_int32 ticks) +{ // convert nanoseconds to l_fp fractional units, using double // precision float calculations or, if available, 64bit integer // arithmetic. This should give the precise fraction, rounded to // the nearest representation. + #ifdef HAVE_U_INT64 return (u_int32)((( ((u_int64)(ticks)) << 32) + 500000000) / 1000000000); #else @@ -172,7 +195,9 @@ my_tick_to_tsf(u_int32 ticks) { u_int32 -my_tsf_to_tick(u_int32 tsf) { +my_tsf_to_tick(u_int32 tsf) +{ + // Inverse operation: converts fraction to microseconds. #ifdef HAVE_U_INT64 return (u_int32)(( ((u_int64)(tsf)) * 1000000000 + 0x80000000) >> 32); @@ -189,7 +214,8 @@ my_tsf_to_tick(u_int32 tsf) { // --------------------------------------------------------------------- void -test_Helpers1(void) { +test_Helpers1(void) +{ struct timespec x; for (x.tv_sec = -2; x.tv_sec < 3; x.tv_sec++) { @@ -202,6 +228,8 @@ test_Helpers1(void) { x.tv_nsec = 1000000000; TEST_ASSERT_FALSE(timespec_isValid(x)); } + + return; } @@ -210,14 +238,18 @@ test_Helpers1(void) { //---------------------------------------------------------------------- void -test_Normalise(void) { +test_Normalise(void) +{ long ns; + for ( ns = -2000000000; ns <= 2000000000; ns += 10000000) { struct timespec x = timespec_init(0, ns); x = normalize_tspec(x); TEST_ASSERT_TRUE(timespec_isValid(x)); } + + return; } //---------------------------------------------------------------------- @@ -225,9 +257,11 @@ test_Normalise(void) { //---------------------------------------------------------------------- void -test_SignNoFrac(void) { +test_SignNoFrac(void) +{ // sign test, no fraction int i; + for (i = -4; i <= 4; ++i) { struct timespec a = timespec_init(i, 0); int E = (i > 0) - (i < 0); @@ -235,26 +269,34 @@ test_SignNoFrac(void) { TEST_ASSERT_EQUAL(E, r); } + + return; } void -test_SignWithFrac(void) { +test_SignWithFrac(void) +{ // sign test, with fraction int i; + for (i = -4; i <= 4; ++i) { struct timespec a = timespec_init(i, 10); int E = (i >= 0) - (i < 0); int r = test_tspec(a); + TEST_ASSERT_EQUAL(E, r); } + + return; } //---------------------------------------------------------------------- // test compare //---------------------------------------------------------------------- void -test_CmpFracEQ(void) { +test_CmpFracEQ(void) +{ // fractions are equal int i, j; for (i = -4; i <= 4; ++i) @@ -263,38 +305,51 @@ test_CmpFracEQ(void) { struct timespec b = timespec_init( j , 200); int E = (i > j) - (i < j); int r = cmp_tspec_denorm(a, b); + TEST_ASSERT_EQUAL(E, r); } + + return; } void -test_CmpFracGT(void) { +test_CmpFracGT(void) +{ // fraction a bigger fraction b int i, j; + for (i = -4; i <= 4; ++i) for (j = -4; j <= 4; ++j) { struct timespec a = timespec_init(i, 999999800); struct timespec b = timespec_init(j, 200); int E = (i >= j) - (i < j); int r = cmp_tspec_denorm(a, b); + TEST_ASSERT_EQUAL(E, r); } + + return; } void -test_CmpFracLT(void) { +test_CmpFracLT(void) +{ // fraction a less fraction b int i, j; + for (i = -4; i <= 4; ++i) for (j = -4; j <= 4; ++j) { struct timespec a = timespec_init(i, 200); struct timespec b = timespec_init(j, 999999800); int E = (i > j) - (i <= j); int r = cmp_tspec_denorm(a, b); + TEST_ASSERT_EQUAL(E, r); } + + return; } //---------------------------------------------------------------------- @@ -302,8 +357,10 @@ test_CmpFracLT(void) { //---------------------------------------------------------------------- void -test_AddFullNorm(void) { +test_AddFullNorm(void) +{ int i, j; + for (i = -4; i <= 4; ++i) for (j = -4; j <= 4; ++j) { struct timespec a = timespec_init(i, 200); @@ -314,12 +371,16 @@ test_AddFullNorm(void) { c = add_tspec(a, b); TEST_ASSERT_EQUAL_timespec(E, c); } + + return; } void -test_AddFullOflow1(void) { +test_AddFullOflow1(void) +{ int i, j; + for (i = -4; i <= 4; ++i) for (j = -4; j <= 4; ++j) { struct timespec a = timespec_init(i, 200); @@ -330,12 +391,15 @@ test_AddFullOflow1(void) { c = add_tspec(a, b); TEST_ASSERT_EQUAL_timespec(E, c); } + + return; } void test_AddNsecNorm(void) { int i; + for (i = -4; i <= 4; ++i) { struct timespec a = timespec_init(i, 200); struct timespec E = timespec_init(i, 600); @@ -344,12 +408,16 @@ test_AddNsecNorm(void) { c = add_tspec_ns(a, 600 - 200); TEST_ASSERT_EQUAL_timespec(E, c); } + + return; } void -test_AddNsecOflow1(void) { +test_AddNsecOflow1(void) +{ int i; + for (i = -4; i <= 4; ++i) { struct timespec a = timespec_init(i, 200); struct timespec E = timespec_init(i + 1, 100); @@ -358,6 +426,8 @@ test_AddNsecOflow1(void) { c = add_tspec_ns(a, NANOSECONDS - 100); TEST_ASSERT_EQUAL_timespec(E, c); } + + return; } //---------------------------------------------------------------------- @@ -365,8 +435,10 @@ test_AddNsecOflow1(void) { //---------------------------------------------------------------------- void -test_SubFullNorm(void) { +test_SubFullNorm(void) +{ int i, j; + for (i = -4; i <= 4; ++i) for (j = -4; j <= 4; ++j) { struct timespec a = timespec_init( i , 600); @@ -377,12 +449,16 @@ test_SubFullNorm(void) { c = sub_tspec(a, b); TEST_ASSERT_EQUAL_timespec(E, c); } + + return; } void -test_SubFullOflow(void) { +test_SubFullOflow(void) +{ int i, j; + for (i = -4; i <= 4; ++i) for (j = -4; j <= 4; ++j) { struct timespec a = timespec_init(i, 100); @@ -393,12 +469,16 @@ test_SubFullOflow(void) { c = sub_tspec(a, b); TEST_ASSERT_EQUAL_timespec(E, c); } + + return; } void -test_SubNsecNorm(void) { +test_SubNsecNorm(void) +{ int i; + for (i = -4; i <= 4; ++i) { struct timespec a = timespec_init(i, 600); struct timespec E = timespec_init(i, 200); @@ -407,12 +487,16 @@ test_SubNsecNorm(void) { c = sub_tspec_ns(a, 600 - 200); TEST_ASSERT_EQUAL_timespec(E, c); } + + return; } void -test_SubNsecOflow(void) { +test_SubNsecOflow(void) +{ int i; + for (i = -4; i <= 4; ++i) { struct timespec a = timespec_init( i , 100); struct timespec E = timespec_init(i-1, 200); @@ -421,6 +505,8 @@ test_SubNsecOflow(void) { c = sub_tspec_ns(a, NANOSECONDS - 100); TEST_ASSERT_EQUAL_timespec(E, c); } + + return; } //---------------------------------------------------------------------- @@ -429,8 +515,10 @@ test_SubNsecOflow(void) { void -test_Neg(void) { +test_Neg(void) +{ int i; + for (i = -4; i <= 4; ++i) { struct timespec a = timespec_init(i, 100); struct timespec b; @@ -440,6 +528,8 @@ test_Neg(void) { c = add_tspec(a, b); TEST_ASSERT_EQUAL(0, test_tspec(c)); } + + return; } //---------------------------------------------------------------------- @@ -447,8 +537,10 @@ test_Neg(void) { //---------------------------------------------------------------------- void -test_AbsNoFrac(void) { +test_AbsNoFrac(void) +{ int i; + for (i = -4; i <= 4; ++i) { struct timespec a = timespec_init(i , 0); struct timespec b; @@ -456,12 +548,16 @@ test_AbsNoFrac(void) { b = abs_tspec(a); TEST_ASSERT_EQUAL((i != 0), test_tspec(b)); } + + return; } void -test_AbsWithFrac(void) { +test_AbsWithFrac(void) +{ int i; + for (i = -4; i <= 4; ++i) { struct timespec a = timespec_init(i, 100); struct timespec b; @@ -469,6 +565,8 @@ test_AbsWithFrac(void) { b = abs_tspec(a); TEST_ASSERT_EQUAL(1, test_tspec(b)); } + + return; } // --------------------------------------------------------------------- @@ -476,9 +574,9 @@ test_AbsWithFrac(void) { // --------------------------------------------------------------------- void -test_Helpers2(void) { +test_Helpers2(void) +{ struct timespec limit = timespec_init(0, 2); - struct timespec x, y; long i; @@ -489,7 +587,7 @@ test_Helpers2(void) { for (i = -4; i < 5; ++i) { y = x; y.tv_nsec += i; - if (i >= -2 && i <= 2){ + if (i >= -2 && i <= 2) { TEST_ASSERT_TRUE(AssertTimespecClose(x, y, limit)); } else @@ -498,6 +596,8 @@ test_Helpers2(void) { } } } + + return; } //---------------------------------------------------------------------- @@ -505,9 +605,11 @@ test_Helpers2(void) { //---------------------------------------------------------------------- void -test_ToLFPbittest(void) { +test_ToLFPbittest(void) +{ l_fp lfpClose = l_fp_init(0, 1); u_int32 i; + for (i = 0; i < 1000000000; i+=1000) { struct timespec a = timespec_init(1, i); l_fp E= l_fp_init(1, my_tick_to_tsf(i)); @@ -516,12 +618,16 @@ test_ToLFPbittest(void) { r = tspec_intv_to_lfp(a); TEST_ASSERT_TRUE(AssertFpClose(E, r, lfpClose)); } + + return; } void -test_ToLFPrelPos(void) { +test_ToLFPrelPos(void) +{ int i; + for (i = 0; i < COUNTOF(fdata); ++i) { struct timespec a = timespec_init(1, fdata[i].nsec); l_fp E = l_fp_init(1, fdata[i].frac); @@ -530,12 +636,16 @@ test_ToLFPrelPos(void) { r = tspec_intv_to_lfp(a); TEST_ASSERT_EQUAL_l_fp(E, r); } + + return; } void -test_ToLFPrelNeg(void) { +test_ToLFPrelNeg(void) +{ int i; + for (i = 0; i < COUNTOF(fdata); ++i) { struct timespec a = timespec_init(-1, fdata[i].nsec); l_fp E = l_fp_init(~0, fdata[i].frac); @@ -544,12 +654,16 @@ test_ToLFPrelNeg(void) { r = tspec_intv_to_lfp(a); TEST_ASSERT_EQUAL_l_fp(E, r); } + + return; } void -test_ToLFPabs(void) { +test_ToLFPabs(void) +{ int i; + for (i = 0; i < COUNTOF(fdata); ++i) { struct timespec a = timespec_init(1, fdata[i].nsec); l_fp E = l_fp_init(1 + JAN_1970, fdata[i].frac); @@ -558,6 +672,8 @@ test_ToLFPabs(void) { r = tspec_stamp_to_lfp(a); TEST_ASSERT_EQUAL_l_fp(E, r); } + + return; } //---------------------------------------------------------------------- @@ -565,7 +681,8 @@ test_ToLFPabs(void) { //---------------------------------------------------------------------- void -test_FromLFPbittest(void) { +test_FromLFPbittest(void) +{ struct timespec limit = timespec_init(0, 2); // Not *exactly* a bittest, because 2**32 tests would take a @@ -582,13 +699,17 @@ test_FromLFPbittest(void) { // comparing to calculated value. TEST_ASSERT_TRUE(AssertTimespecClose(E, r, limit)); } + + return; } void -test_FromLFPrelPos(void) { +test_FromLFPrelPos(void) +{ struct timespec limit = timespec_init(0, 2); int i; + for (i = 0; i < COUNTOF(fdata); ++i) { l_fp a = l_fp_init(1, fdata[i].frac); struct timespec E = timespec_init(1, fdata[i].nsec); @@ -597,13 +718,17 @@ test_FromLFPrelPos(void) { r = lfp_intv_to_tspec(a); TEST_ASSERT_TRUE(AssertTimespecClose(E, r, limit)); } + + return; } void -test_FromLFPrelNeg(void) { +test_FromLFPrelNeg(void) +{ struct timespec limit = timespec_init(0, 2); int i; + for (i = 0; i < COUNTOF(fdata); ++i) { l_fp a = l_fp_init(~0, fdata[i].frac); struct timespec E = timespec_init(-1, fdata[i].nsec); @@ -612,14 +737,18 @@ test_FromLFPrelNeg(void) { r = lfp_intv_to_tspec(a); TEST_ASSERT_TRUE(AssertTimespecClose(E, r, limit)); } + + return; } // nsec -> frac -> nsec roundtrip, using a prime start and increment void -test_LFProundtrip(void) { +test_LFProundtrip(void) +{ int32_t t; u_int32 i; + for (t = -1; t < 2; ++t) for (i = 4999; i < 1000000000; i += 10007) { struct timespec E = timespec_init(t, i); @@ -630,6 +759,8 @@ test_LFProundtrip(void) { r = lfp_intv_to_tspec(a); TEST_ASSERT_EQUAL_timespec(E, r); } + + return; } //---------------------------------------------------------------------- @@ -637,7 +768,8 @@ test_LFProundtrip(void) { //---------------------------------------------------------------------- void -test_ToString(void) { +test_ToString(void) +{ static const struct { time_t sec; long nsec; @@ -653,12 +785,15 @@ test_ToString(void) { {-1,-1, "-1.000000001" }, }; int i; + for (i = 0; i < COUNTOF(data); ++i) { struct timespec a = timespec_init(data[i].sec, data[i].nsec); const char * E = data[i].repr; const char * r = tspectoa(a); TEST_ASSERT_EQUAL_STRING(E, r); } + + return; } // -*- EOF -*- diff --git a/contrib/ntp/tests/libntp/timevalops.c b/contrib/ntp/tests/libntp/timevalops.c index a2d9358..99a48eb 100644 --- a/contrib/ntp/tests/libntp/timevalops.c +++ b/contrib/ntp/tests/libntp/timevalops.c @@ -11,8 +11,8 @@ #include "unity.h" -#define TEST_ASSERT_EQUAL_timeval(a, b) { \ - TEST_ASSERT_EQUAL_MESSAGE(a.tv_sec, b.tv_sec, "Field tv_sec"); \ +#define TEST_ASSERT_EQUAL_timeval(a, b) { \ + TEST_ASSERT_EQUAL_MESSAGE(a.tv_sec, b.tv_sec, "Field tv_sec"); \ TEST_ASSERT_EQUAL_MESSAGE(a.tv_usec, b.tv_usec, "Field tv_usec"); \ } @@ -35,6 +35,7 @@ l_fp l_fp_init(int32 i, u_int32 f); bool AssertTimevalClose(const struct timeval m, const struct timeval n, const struct timeval limit); bool AssertFpClose(const l_fp m, const l_fp n, const l_fp limit); +void setUp(void); void test_Helpers1(void); void test_Normalise(void); void test_SignNoFrac(void); @@ -65,28 +66,43 @@ void test_LFProundtrip(void); void test_ToString(void); -//******************************************MY CUSTOM FUNCTIONS******************************* +//**********************************MY CUSTOM FUNCTIONS*********************** +void +setUp(void) +{ + init_lib(); + + return; +} + struct timeval -timeval_init( time_t hi, long lo){ +timeval_init(time_t hi, long lo) +{ struct timeval V; + V.tv_sec = hi; V.tv_usec = lo; + return V; } const bool -timeval_isValid(struct timeval V) { +timeval_isValid(struct timeval V) +{ + return V.tv_usec >= 0 && V.tv_usec < 1000000; } l_fp -l_fp_init(int32 i, u_int32 f) { +l_fp_init(int32 i, u_int32 f) +{ l_fp temp; + temp.l_i = i; temp.l_uf = f; @@ -95,25 +111,26 @@ l_fp_init(int32 i, u_int32 f) { bool -AssertTimevalClose(const struct timeval m, const struct timeval n, const struct timeval limit) { +AssertTimevalClose(const struct timeval m, const struct timeval n, const struct timeval limit) +{ struct timeval diff; diff = abs_tval(sub_tval(m, n)); if (cmp_tval(limit, diff) >= 0) return TRUE; - else { printf("m_expr which is %ld.%lu \nand\nn_expr which is %ld.%lu\nare not close; diff=%ld.%luusec\n", m.tv_sec, m.tv_usec, n.tv_sec, n.tv_usec, diff.tv_sec, diff.tv_usec); //I don't have variables m_expr and n_expr in unity, those are command line arguments which only getst has!!! - + return FALSE; } } bool -AssertFpClose(const l_fp m, const l_fp n, const l_fp limit) { +AssertFpClose(const l_fp m, const l_fp n, const l_fp limit) +{ l_fp diff; if (L_ISGEQ(&m, &n)) { @@ -123,7 +140,7 @@ AssertFpClose(const l_fp m, const l_fp n, const l_fp limit) { diff = n; L_SUB(&diff, &m); } - if (L_ISGEQ(&limit, &diff)){ + if (L_ISGEQ(&limit, &diff)) { return TRUE; } else { @@ -155,11 +172,13 @@ static const lfpfracdata fdata[] = { u_int32 -my_tick_to_tsf(u_int32 ticks) { +my_tick_to_tsf(u_int32 ticks) +{ // convert microseconds to l_fp fractional units, using double // precision float calculations or, if available, 64bit integer // arithmetic. This should give the precise fraction, rounded to // the nearest representation. + #ifdef HAVE_U_INT64 return (u_int32)((( ((u_int64)(ticks)) << 32) + 500000) / 1000000); //I put too much () when casting just to be safe #else @@ -171,7 +190,8 @@ my_tick_to_tsf(u_int32 ticks) { u_int32 -my_tsf_to_tick(u_int32 tsf) { +my_tsf_to_tick(u_int32 tsf) +{ // Inverse operation: converts fraction to microseconds. #ifdef HAVE_U_INT64 return (u_int32)( ((u_int64)(tsf) * 1000000 + 0x80000000) >> 32); //CHECK ME!!! @@ -182,7 +202,7 @@ my_tsf_to_tick(u_int32 tsf) { } -//***************************************END OF CUSTOM FUNCTIONS***************************** +//*******************************END OF CUSTOM FUNCTIONS********************* // --------------------------------------------------------------------- @@ -190,7 +210,8 @@ my_tsf_to_tick(u_int32 tsf) { // --------------------------------------------------------------------- void -test_Helpers1(void) { +test_Helpers1(void) +{ struct timeval x; for (x.tv_sec = -2; x.tv_sec < 3; x.tv_sec++) { @@ -203,6 +224,8 @@ test_Helpers1(void) { x.tv_usec = 1000000; TEST_ASSERT_FALSE(timeval_isValid(x)); } + + return; } @@ -211,14 +234,18 @@ test_Helpers1(void) { //---------------------------------------------------------------------- void -test_Normalise(void) { +test_Normalise(void) +{ long ns; + for (ns = -2000000000; ns <= 2000000000; ns += 10000000) { struct timeval x = timeval_init(0, ns); - + x = normalize_tval(x); TEST_ASSERT_TRUE(timeval_isValid(x)); } + + return; } //---------------------------------------------------------------------- @@ -226,8 +253,10 @@ test_Normalise(void) { //---------------------------------------------------------------------- void -test_SignNoFrac(void) { +test_SignNoFrac(void) +{ int i; + // sign test, no fraction for (i = -4; i <= 4; ++i) { struct timeval a = timeval_init(i, 0); @@ -236,13 +265,17 @@ test_SignNoFrac(void) { TEST_ASSERT_EQUAL(E, r); } + + return; } void -test_SignWithFrac(void) { +test_SignWithFrac(void) +{ // sign test, with fraction int i; + for (i = -4; i <= 4; ++i) { struct timeval a = timeval_init(i, 10); int E = (i >= 0) - (i < 0); @@ -250,14 +283,18 @@ test_SignWithFrac(void) { TEST_ASSERT_EQUAL(E, r); } + + return; } //---------------------------------------------------------------------- // test compare //---------------------------------------------------------------------- void -test_CmpFracEQ(void) { +test_CmpFracEQ(void) +{ int i, j; + // fractions are equal for (i = -4; i <= 4; ++i) for (j = -4; j <= 4; ++j) { @@ -268,13 +305,17 @@ test_CmpFracEQ(void) { TEST_ASSERT_EQUAL(E, r); } + + return; } void -test_CmpFracGT(void) { +test_CmpFracGT(void) +{ // fraction a bigger fraction b int i, j; + for (i = -4; i <= 4; ++i) for (j = -4; j <= 4; ++j) { struct timeval a = timeval_init( i , 999800); @@ -284,13 +325,17 @@ test_CmpFracGT(void) { TEST_ASSERT_EQUAL(E, r); } + + return; } void -test_CmpFracLT(void) { +test_CmpFracLT(void) +{ // fraction a less fraction b int i, j; + for (i = -4; i <= 4; ++i) for (j = -4; j <= 4; ++j) { struct timeval a = timeval_init(i, 200); @@ -300,6 +345,8 @@ test_CmpFracLT(void) { TEST_ASSERT_EQUAL(E, r); } + + return; } //---------------------------------------------------------------------- @@ -307,8 +354,10 @@ test_CmpFracLT(void) { //---------------------------------------------------------------------- void -test_AddFullNorm(void) { +test_AddFullNorm(void) +{ int i, j; + for (i = -4; i <= 4; ++i) for (j = -4; j <= 4; ++j) { struct timeval a = timeval_init(i, 200); @@ -319,12 +368,16 @@ test_AddFullNorm(void) { c = add_tval(a, b); TEST_ASSERT_EQUAL_timeval(E, c); } + + return; } void -test_AddFullOflow1(void) { +test_AddFullOflow1(void) +{ int i, j; + for (i = -4; i <= 4; ++i) for (j = -4; j <= 4; ++j) { struct timeval a = timeval_init(i, 200); @@ -335,12 +388,16 @@ test_AddFullOflow1(void) { c = add_tval(a, b); TEST_ASSERT_EQUAL_timeval(E, c); } + + return; } void -test_AddUsecNorm(void) { +test_AddUsecNorm(void) +{ int i; + for (i = -4; i <= 4; ++i) { struct timeval a = timeval_init(i, 200); struct timeval E = timeval_init(i, 600); @@ -349,12 +406,16 @@ test_AddUsecNorm(void) { c = add_tval_us(a, 600 - 200); TEST_ASSERT_EQUAL_timeval(E, c); } + + return; } void -test_AddUsecOflow1(void) { +test_AddUsecOflow1(void) +{ int i; + for (i = -4; i <= 4; ++i) { struct timeval a = timeval_init(i, 200); struct timeval E = timeval_init(i + 1, 100); @@ -363,6 +424,8 @@ test_AddUsecOflow1(void) { c = add_tval_us(a, MICROSECONDS - 100); TEST_ASSERT_EQUAL_timeval(E, c); } + + return; } //---------------------------------------------------------------------- @@ -370,8 +433,10 @@ test_AddUsecOflow1(void) { //---------------------------------------------------------------------- void -test_SubFullNorm(void) { +test_SubFullNorm(void) +{ int i, j; + for (i = -4; i <= 4; ++i) for (j = -4; j <= 4; ++j) { struct timeval a = timeval_init(i, 600); @@ -382,12 +447,16 @@ test_SubFullNorm(void) { c = sub_tval(a, b); TEST_ASSERT_EQUAL_timeval(E, c); } + + return; } void -test_SubFullOflow(void) { +test_SubFullOflow(void) +{ int i, j; + for (i = -4; i <= 4; ++i) for (j = -4; j <= 4; ++j) { struct timeval a = timeval_init(i, 100); @@ -398,12 +467,16 @@ test_SubFullOflow(void) { c = sub_tval(a, b); TEST_ASSERT_EQUAL_timeval(E, c); } + + return; } void -test_SubUsecNorm(void) { +test_SubUsecNorm(void) +{ int i = -4; + for (i = -4; i <= 4; ++i) { struct timeval a = timeval_init(i, 600); struct timeval E = timeval_init(i, 200); @@ -412,12 +485,16 @@ test_SubUsecNorm(void) { c = sub_tval_us(a, 600 - 200); TEST_ASSERT_EQUAL_timeval(E, c); } + + return; } void -test_SubUsecOflow(void) { +test_SubUsecOflow(void) +{ int i = -4; + for (i = -4; i <= 4; ++i) { struct timeval a = timeval_init(i, 100); struct timeval E = timeval_init(i - 1, 200); @@ -426,6 +503,8 @@ test_SubUsecOflow(void) { c = sub_tval_us(a, MICROSECONDS - 100); TEST_ASSERT_EQUAL_timeval(E, c); } + + return; } //---------------------------------------------------------------------- @@ -433,8 +512,10 @@ test_SubUsecOflow(void) { //---------------------------------------------------------------------- void -test_Neg(void) { +test_Neg(void) +{ int i = -4; + for (i = -4; i <= 4; ++i) { struct timeval a = timeval_init(i, 100); struct timeval b; @@ -444,6 +525,8 @@ test_Neg(void) { c = add_tval(a, b); TEST_ASSERT_EQUAL(0, test_tval(c)); } + + return; } //---------------------------------------------------------------------- @@ -451,8 +534,10 @@ test_Neg(void) { //---------------------------------------------------------------------- void -test_AbsNoFrac(void) { +test_AbsNoFrac(void) +{ int i = -4; + for (i = -4; i <= 4; ++i) { struct timeval a = timeval_init(i, 0); struct timeval b; @@ -460,12 +545,16 @@ test_AbsNoFrac(void) { b = abs_tval(a); TEST_ASSERT_EQUAL((i != 0), test_tval(b)); } + + return; } void -test_AbsWithFrac(void) { +test_AbsWithFrac(void) +{ int i = -4; + for (i = -4; i <= 4; ++i) { struct timeval a = timeval_init(i, 100); struct timeval b; @@ -473,6 +562,8 @@ test_AbsWithFrac(void) { b = abs_tval(a); TEST_ASSERT_EQUAL(1, test_tval(b)); } + + return; } // --------------------------------------------------------------------- @@ -481,20 +572,20 @@ test_AbsWithFrac(void) { void -test_Helpers2(void) { - +test_Helpers2(void) +{ struct timeval limit = timeval_init(0, 2); struct timeval x, y; - long i; + long i; - for (x.tv_sec = -2; x.tv_sec < 3; x.tv_sec++){ + for (x.tv_sec = -2; x.tv_sec < 3; x.tv_sec++) { for (x.tv_usec = 1; x.tv_usec < 1000000; x.tv_usec += 499999) { for (i = -4; i < 5; ++i) { y = x; y.tv_usec += i; - if (i >= -2 && i <= 2){ + if (i >= -2 && i <= 2) { TEST_ASSERT_TRUE(AssertTimevalClose(x, y, limit));//ASSERT_PRED_FORMAT2(isClose, x, y); } else { @@ -503,6 +594,8 @@ test_Helpers2(void) { } } } + + return; } // and the global predicate instances we're using here @@ -515,8 +608,9 @@ test_Helpers2(void) { //---------------------------------------------------------------------- void -test_ToLFPbittest(void) { - l_fp lfpClose = l_fp_init(0, 1); +test_ToLFPbittest(void) +{ + l_fp lfpClose = l_fp_init(0, 1); u_int32 i = 0; for (i = 0; i < 1000000; ++i) { @@ -527,14 +621,17 @@ test_ToLFPbittest(void) { r = tval_intv_to_lfp(a); TEST_ASSERT_TRUE(AssertFpClose(E, r, lfpClose)); //ASSERT_PRED_FORMAT2(FpClose, E, r); } + + return; } void -test_ToLFPrelPos(void) { +test_ToLFPrelPos(void) +{ l_fp lfpClose = l_fp_init(0, 1); - int i = 0; + for (i = 0; i < COUNTOF(fdata); ++i) { struct timeval a = timeval_init(1, fdata[i].usec); l_fp E = l_fp_init(1, fdata[i].frac); @@ -543,13 +640,17 @@ test_ToLFPrelPos(void) { r = tval_intv_to_lfp(a); TEST_ASSERT_TRUE(AssertFpClose(E, r, lfpClose)); } + + return; } void -test_ToLFPrelNeg(void) { +test_ToLFPrelNeg(void) +{ l_fp lfpClose = l_fp_init(0, 1); int i = 0; + for (i = 0; i < COUNTOF(fdata); ++i) { struct timeval a = timeval_init(-1, fdata[i].usec); l_fp E = l_fp_init(~0, fdata[i].frac); @@ -558,14 +659,17 @@ test_ToLFPrelNeg(void) { r = tval_intv_to_lfp(a); TEST_ASSERT_TRUE(AssertFpClose(E, r, lfpClose)); } + + return; } void -test_ToLFPabs(void) { +test_ToLFPabs(void) +{ l_fp lfpClose = l_fp_init(0, 1); - int i = 0; + for (i = 0; i < COUNTOF(fdata); ++i) { struct timeval a = timeval_init(1, fdata[i].usec); l_fp E = l_fp_init(1 + JAN_1970, fdata[i].frac); @@ -574,6 +678,8 @@ test_ToLFPabs(void) { r = tval_stamp_to_lfp(a); TEST_ASSERT_TRUE(AssertFpClose(E, r, lfpClose)); } + + return; } //---------------------------------------------------------------------- @@ -581,12 +687,14 @@ test_ToLFPabs(void) { //---------------------------------------------------------------------- void -test_FromLFPbittest(void) { +test_FromLFPbittest(void) +{ struct timeval timevalClose = timeval_init(0, 1); // Not *exactly* a bittest, because 2**32 tests would take a // really long time even on very fast machines! So we do test // every 1000 fractional units. u_int32 tsf = 0; + for (tsf = 0; tsf < ~((u_int32)(1000)); tsf += 1000) { struct timeval E = timeval_init(1, my_tsf_to_tick(tsf)); l_fp a = l_fp_init(1, tsf); @@ -597,13 +705,17 @@ test_FromLFPbittest(void) { // comparing to calculated value. TEST_ASSERT_TRUE(AssertTimevalClose(E, r, timevalClose)); } + + return; } void -test_FromLFPrelPos(void) { +test_FromLFPrelPos(void) +{ struct timeval timevalClose = timeval_init(0, 1); - int i = 0; + int i = 0; + for (i = 0; i < COUNTOF(fdata); ++i) { l_fp a = l_fp_init(1, fdata[i].frac); struct timeval E = timeval_init(1, fdata[i].usec); @@ -612,13 +724,17 @@ test_FromLFPrelPos(void) { r = lfp_intv_to_tval(a); TEST_ASSERT_TRUE(AssertTimevalClose(E, r, timevalClose)); } + + return; } void -test_FromLFPrelNeg(void) { +test_FromLFPrelNeg(void) +{ struct timeval timevalClose = timeval_init(0, 1); int i = 0; + for (i = 0; i < COUNTOF(fdata); ++i) { l_fp a = l_fp_init(~0, fdata[i].frac); struct timeval E = timeval_init(-1, fdata[i].usec); @@ -627,14 +743,18 @@ test_FromLFPrelNeg(void) { r = lfp_intv_to_tval(a); TEST_ASSERT_TRUE(AssertTimevalClose(E, r, timevalClose)); } + + return; } // usec -> frac -> usec roundtrip, using a prime start and increment void -test_LFProundtrip(void) { +test_LFProundtrip(void) +{ int32_t t = -1; u_int32 i = 5; + for (t = -1; t < 2; ++t) for (i = 5; i < 1000000; i += 11) { struct timeval E = timeval_init(t, i); @@ -645,6 +765,8 @@ test_LFProundtrip(void) { r = lfp_intv_to_tval(a); TEST_ASSERT_EQUAL_timeval(E, r); } + + return; } //---------------------------------------------------------------------- @@ -652,7 +774,8 @@ test_LFProundtrip(void) { //---------------------------------------------------------------------- void -test_ToString(void) { +test_ToString(void) +{ static const struct { time_t sec; long usec; @@ -668,6 +791,7 @@ test_ToString(void) { {-1,-1, "-1.000001" }, }; int i; + for (i = 0; i < COUNTOF(data); ++i) { struct timeval a = timeval_init(data[i].sec, data[i].usec); const char * E = data[i].repr; @@ -675,6 +799,8 @@ test_ToString(void) { TEST_ASSERT_EQUAL_STRING(E, r); } + + return; } // -*- EOF -*- diff --git a/contrib/ntp/tests/libntp/uglydate.c b/contrib/ntp/tests/libntp/uglydate.c index f47f3e4..3a5aa8a 100644 --- a/contrib/ntp/tests/libntp/uglydate.c +++ b/contrib/ntp/tests/libntp/uglydate.c @@ -5,14 +5,26 @@ #include "unity.h" +void setUp(void); void test_ConstantDateTime(void); + +void +setUp(void) +{ + init_lib(); + + return; +} + void -test_ConstantDateTime(void) { +test_ConstantDateTime(void) +{ const u_int32 HALF = 2147483648UL; - l_fp time = {{3485080800UL}, HALF}; /* 2010-06-09 14:00:00.5 */ + l_fp e_time = {{3485080800UL}, HALF}; /* 2010-06-09 14:00:00.5 */ TEST_ASSERT_EQUAL_STRING("3485080800.500000 10:159:14:00:00.500", - uglydate(&time)); + uglydate(&e_time)); + return; } diff --git a/contrib/ntp/tests/ntpd/leapsec.c b/contrib/ntp/tests/ntpd/leapsec.c index 37e4398..36ecd39 100644 --- a/contrib/ntp/tests/ntpd/leapsec.c +++ b/contrib/ntp/tests/ntpd/leapsec.c @@ -234,6 +234,7 @@ static const uint32_t lsec2015 = 3644697600u; // +36, 1 Jul 2015, 00:00:00 utc int stringreader(void* farg) { const char ** cpp = (const char**)farg; + if (**cpp) return *(*cpp)++; else @@ -247,6 +248,7 @@ setup_load_table( { int rc; leap_table_t * pt = leapsec_get_table(0); + rc = (pt != NULL) && leapsec_load(pt, stringreader, &cp, blim); rc = rc && leapsec_set_table(pt); return rc; @@ -257,6 +259,7 @@ setup_clear_table(void) { int rc; leap_table_t * pt = leapsec_get_table(0); + if (pt) leapsec_clear(pt); rc = leapsec_set_table(pt); @@ -264,10 +267,13 @@ setup_clear_table(void) } -char * CalendarToString(const struct calendar cal) { +char * +CalendarToString(const struct calendar cal) +{ char * ss = malloc (sizeof (char) * 100); - char buffer[100] =""; + + *ss = '\0'; sprintf(buffer, "%u", cal.year); strcat(ss,buffer); strcat(ss,"-"); @@ -293,34 +299,47 @@ char * CalendarToString(const struct calendar cal) { } -int IsEqual(const struct calendar expected, const struct calendar actual) { - if (expected.year == actual.year && - (expected.yearday == actual.yearday || - (expected.month == actual.month && - expected.monthday == actual.monthday)) && - expected.hour == actual.hour && - expected.minute == actual.minute && - expected.second == actual.second) { +int +IsEqual(const struct calendar expected, const struct calendar actual) +{ + + if ( expected.year == actual.year + && ( expected.yearday == actual.yearday + || ( expected.month == actual.month + && expected.monthday == actual.monthday)) + && expected.hour == actual.hour + && expected.minute == actual.minute + && expected.second == actual.second) { return TRUE; } else { - printf("expected: %s but was %s", CalendarToString(expected) ,CalendarToString(actual)); + char *p_exp = CalendarToString(expected); + char *p_act = CalendarToString(actual); + + printf("expected: %s but was %s", p_exp, p_act); + + free(p_exp); + free(p_act); return FALSE; - } } //------------------------- -void setUp(void) +void +setUp(void) { ntpcal_set_timefunc(timefunc); settime(1970, 1, 1, 0, 0, 0); leapsec_ut_pristine(); + + return; } -void tearDown(void) +void +tearDown(void) { ntpcal_set_timefunc(NULL); + return; } // ===================================================================== @@ -328,45 +347,73 @@ void tearDown(void) // ===================================================================== // ---------------------------------------------------------------------- -void test_ValidateGood(void) { +void +test_ValidateGood(void) +{ const char *cp = leap_ghash; int rc = leapsec_validate(stringreader, &cp); + TEST_ASSERT_EQUAL(LSVALID_GOODHASH, rc); + return; } // ---------------------------------------------------------------------- -void test_ValidateNoHash(void) { +void +test_ValidateNoHash(void) +{ const char *cp = leap2; int rc = leapsec_validate(stringreader, &cp); + TEST_ASSERT_EQUAL(LSVALID_NOHASH, rc); + return; } // ---------------------------------------------------------------------- -void test_ValidateBad(void) { +void +test_ValidateBad(void) +{ const char *cp = leap_bhash; int rc = leapsec_validate(stringreader, &cp); + TEST_ASSERT_EQUAL(LSVALID_BADHASH, rc); + + return; } // ---------------------------------------------------------------------- -void test_ValidateMalformed(void) { +void +test_ValidateMalformed(void) +{ const char *cp = leap_mhash; int rc = leapsec_validate(stringreader, &cp); + TEST_ASSERT_EQUAL(LSVALID_BADFORMAT, rc); + + return; } // ---------------------------------------------------------------------- -void test_ValidateMalformedShort(void) { +void +test_ValidateMalformedShort(void) +{ const char *cp = leap_shash; int rc = leapsec_validate(stringreader, &cp); + TEST_ASSERT_EQUAL(LSVALID_BADFORMAT, rc); + + return; } // ---------------------------------------------------------------------- -void test_ValidateNoLeadZero(void) { +void +test_ValidateNoLeadZero(void) +{ const char *cp = leap_gthash; int rc = leapsec_validate(stringreader, &cp); + TEST_ASSERT_EQUAL(LSVALID_GOODHASH, rc); + + return; } // ===================================================================== @@ -375,7 +422,9 @@ void test_ValidateNoLeadZero(void) { // ---------------------------------------------------------------------- // test table selection -void test_tableSelect(void) { +void +test_tableSelect(void) +{ leap_table_t *pt1, *pt2, *pt3, *pt4; pt1 = leapsec_get_table(0); @@ -406,12 +455,16 @@ void test_tableSelect(void) { pt3 = leapsec_get_table(1); TEST_ASSERT_EQUAL(pt1, pt2); TEST_ASSERT_NOT_EQUAL(pt2, pt3); + + return; } // ---------------------------------------------------------------------- // load file & check expiration -void test_loadFileExpire(void) { +void +test_loadFileExpire(void) +{ const char *cp = leap1; int rc; leap_table_t * pt = leapsec_get_table(0); @@ -423,18 +476,21 @@ void test_loadFileExpire(void) { TEST_ASSERT_EQUAL(0, rc); rc = leapsec_expired(3610569601u, NULL); TEST_ASSERT_EQUAL(1, rc); + + return; } // ---------------------------------------------------------------------- // load file & check time-to-live -void test_loadFileTTL(void) { - const char *cp = leap1; - int rc; - leap_table_t * pt = leapsec_get_table(0); - time_t pivot = 0x70000000u; - - const uint32_t limit = 3610569600u; +void +test_loadFileTTL(void) +{ + const char *cp = leap1; + int rc; + leap_table_t * pt = leapsec_get_table(0); + time_t pivot = 0x70000000u; + const uint32_t limit = 3610569600u; rc = leapsec_load(pt, stringreader, &cp, FALSE) && leapsec_set_table(pt); @@ -442,16 +498,18 @@ void test_loadFileTTL(void) { // exactly 1 day to live rc = leapsec_daystolive(limit - 86400, &pivot); - TEST_ASSERT_EQUAL( 1, rc); + TEST_ASSERT_EQUAL( 1, rc); // less than 1 day to live rc = leapsec_daystolive(limit - 86399, &pivot); - TEST_ASSERT_EQUAL( 0, rc); + TEST_ASSERT_EQUAL( 0, rc); // hit expiration exactly rc = leapsec_daystolive(limit, &pivot); - TEST_ASSERT_EQUAL( 0, rc); + TEST_ASSERT_EQUAL( 0, rc); // expired since 1 sec rc = leapsec_daystolive(limit + 1, &pivot); - TEST_ASSERT_EQUAL(-1, rc); + TEST_ASSERT_EQUAL(-1, rc); + + return; } // ===================================================================== @@ -460,19 +518,25 @@ void test_loadFileTTL(void) { // ---------------------------------------------------------------------- // test query in pristine state (bug#2745 misbehaviour) -void test_lsQueryPristineState(void) { +void +test_lsQueryPristineState(void) +{ int rc; leap_result_t qr; - + rc = leapsec_query(&qr, lsec2012, NULL); TEST_ASSERT_EQUAL(FALSE, rc); TEST_ASSERT_EQUAL(0, qr.warped ); TEST_ASSERT_EQUAL(LSPROX_NOWARN, qr.proximity); + + return; } // ---------------------------------------------------------------------- // ad-hoc jump: leap second at 2009.01.01 -60days -void test_ls2009faraway(void) { +void +test_ls2009faraway(void) +{ int rc; leap_result_t qr; @@ -485,11 +549,15 @@ void test_ls2009faraway(void) { TEST_ASSERT_EQUAL(33, qr.tai_offs); TEST_ASSERT_EQUAL(0, qr.tai_diff); TEST_ASSERT_EQUAL(LSPROX_NOWARN, qr.proximity); + + return; } // ---------------------------------------------------------------------- // ad-hoc jump: leap second at 2009.01.01 -1week -void test_ls2009weekaway(void) { +void +test_ls2009weekaway(void) +{ int rc; leap_result_t qr; @@ -502,11 +570,15 @@ void test_ls2009weekaway(void) { TEST_ASSERT_EQUAL(33, qr.tai_offs); TEST_ASSERT_EQUAL(1, qr.tai_diff); TEST_ASSERT_EQUAL(LSPROX_SCHEDULE, qr.proximity); + + return; } // ---------------------------------------------------------------------- // ad-hoc jump: leap second at 2009.01.01 -1hr -void test_ls2009houraway(void) { +void +test_ls2009houraway(void) +{ int rc; leap_result_t qr; @@ -519,11 +591,15 @@ void test_ls2009houraway(void) { TEST_ASSERT_EQUAL(33, qr.tai_offs); TEST_ASSERT_EQUAL(1, qr.tai_diff); TEST_ASSERT_EQUAL(LSPROX_ANNOUNCE, qr.proximity); + + return; } // ---------------------------------------------------------------------- // ad-hoc jump: leap second at 2009.01.01 -1sec -void test_ls2009secaway(void) { +void +test_ls2009secaway(void) +{ int rc; leap_result_t qr; @@ -536,11 +612,15 @@ void test_ls2009secaway(void) { TEST_ASSERT_EQUAL(33, qr.tai_offs); TEST_ASSERT_EQUAL(1, qr.tai_diff); TEST_ASSERT_EQUAL(LSPROX_ALERT, qr.proximity); + + return; } // ---------------------------------------------------------------------- // ad-hoc jump to leap second at 2009.01.01 -void test_ls2009onspot(void) { +void +test_ls2009onspot(void) +{ int rc; leap_result_t qr; @@ -553,11 +633,15 @@ void test_ls2009onspot(void) { TEST_ASSERT_EQUAL(34, qr.tai_offs); TEST_ASSERT_EQUAL(0, qr.tai_diff); TEST_ASSERT_EQUAL(LSPROX_NOWARN, qr.proximity); + + return; } // ---------------------------------------------------------------------- // test handling of the leap second at 2009.01.01 without table -void test_ls2009nodata(void) { +void +test_ls2009nodata(void) +{ int rc; leap_result_t qr; @@ -570,11 +654,15 @@ void test_ls2009nodata(void) { TEST_ASSERT_EQUAL(0, qr.tai_offs); TEST_ASSERT_EQUAL(0, qr.tai_diff); TEST_ASSERT_EQUAL(LSPROX_NOWARN, qr.proximity); + + return; } // ---------------------------------------------------------------------- // test handling of the leap second at 2009.01.01 with culled data -void test_ls2009limdata(void) { +void +test_ls2009limdata(void) +{ int rc; leap_result_t qr; @@ -591,15 +679,19 @@ void test_ls2009limdata(void) { TEST_ASSERT_TRUE(35 >= qr.tai_offs); TEST_ASSERT_EQUAL(0, qr.tai_diff); TEST_ASSERT_EQUAL(LSPROX_NOWARN, qr.proximity); + + return; } // ---------------------------------------------------------------------- // Far-distance forward jump into a transiton window. -void test_qryJumpFarAhead(void) { +void +test_qryJumpFarAhead(void) +{ int rc; leap_result_t qr; int last, idx; - int mode; + int mode; for (mode=0; mode < 2; ++mode) { leapsec_ut_pristine(); @@ -618,10 +710,10 @@ void test_qryJumpFarAhead(void) { // ---------------------------------------------------------------------- // Forward jump into the next transition window void test_qryJumpAheadToTransition(void) { - int rc; - leap_result_t qr; - int last, idx; - int mode; + int rc; + leap_result_t qr; + int last, idx; + int mode; for (mode=0; mode < 2; ++mode) { leapsec_ut_pristine(); @@ -635,15 +727,19 @@ void test_qryJumpAheadToTransition(void) { rc = leapsec_query(&qr, lsec2009+1, NULL); TEST_ASSERT_EQUAL(TRUE, rc); } + + return; } // ---------------------------------------------------------------------- // Forward jump over the next transition window -void test_qryJumpAheadOverTransition(void) { - int rc; - leap_result_t qr; - int last, idx; - int mode; +void +test_qryJumpAheadOverTransition(void) +{ + int rc; + leap_result_t qr; + int last, idx; + int mode; for (mode=0; mode < 2; ++mode) { leapsec_ut_pristine(); @@ -657,6 +753,8 @@ void test_qryJumpAheadOverTransition(void) { rc = leapsec_query(&qr, lsec2009+5, NULL); TEST_ASSERT_EQUAL(FALSE, rc); } + + return; } // ===================================================================== @@ -665,7 +763,9 @@ void test_qryJumpAheadOverTransition(void) { // ---------------------------------------------------------------------- // add dynamic leap second (like from peer/clock) -void test_addDynamic(void) { +void +test_addDynamic(void) +{ int rc; leap_result_t qr; @@ -683,8 +783,7 @@ void test_addDynamic(void) { rc = setup_load_table(leap2, FALSE); TEST_ASSERT_EQUAL(1, rc); - leap_table_t * pt = leapsec_get_table(0); - int idx; + int idx; for (idx=1; insns[idx]; ++idx) { rc = leapsec_add_dyn(TRUE, insns[idx] - 20*SECSPERDAY - 100, NULL); @@ -693,13 +792,18 @@ void test_addDynamic(void) { // try to slip in a previous entry rc = leapsec_add_dyn(TRUE, insns[0] - 20*SECSPERDAY - 100, NULL); TEST_ASSERT_EQUAL(FALSE, rc); + //leap_table_t * pt = leapsec_get_table(0); //leapsec_dump(pt, (leapsec_dumper)fprintf, stdout); + + return; } // ---------------------------------------------------------------------- // add fixed leap seconds (like from network packet) #if 0 /* currently unused -- possibly revived later */ -void FAILtest_addFixed(void) { +void +FAILtest_addFixed(void) +{ int rc; leap_result_t qr; @@ -716,8 +820,8 @@ void FAILtest_addFixed(void) { rc = setup_load_table(leap2, FALSE); TEST_ASSERT_EQUAL(1, rc); + int idx; - leap_table_t * pt = leapsec_get_table(0); // try to get in BAD time stamps... for (idx=0; insns[idx].tt; ++idx) { rc = leapsec_add_fix( @@ -743,14 +847,19 @@ void FAILtest_addFixed(void) { insns[0].tt + SECSPERDAY, NULL); TEST_ASSERT_EQUAL(FALSE, rc); + //leap_table_t * pt = leapsec_get_table(0); //leapsec_dump(pt, (leapsec_dumper)fprintf, stdout); + + return; } #endif // ---------------------------------------------------------------------- // add fixed leap seconds (like from network packet) #if 0 /* currently unused -- possibly revived later */ -void FAILtest_addFixedExtend(void) { +void +FAILtest_addFixedExtend(void) +{ int rc; leap_result_t qr; int last, idx; @@ -764,7 +873,6 @@ void FAILtest_addFixedExtend(void) { rc = setup_load_table(leap2, FALSE); TEST_ASSERT_EQUAL(1, rc); - leap_table_t * pt = leapsec_get_table(FALSE); for (last=idx=0; insns[idx].tt; ++idx) { last = idx; rc = leapsec_add_fix( @@ -774,7 +882,7 @@ void FAILtest_addFixedExtend(void) { NULL); TEST_ASSERT_EQUAL(TRUE, rc); } - + // try to extend the expiration of the last entry rc = leapsec_add_fix( insns[last].of, @@ -782,7 +890,7 @@ void FAILtest_addFixedExtend(void) { insns[last].tt + 128*SECSPERDAY, NULL); TEST_ASSERT_EQUAL(TRUE, rc); - + // try to extend the expiration of the last entry with wrong offset rc = leapsec_add_fix( insns[last].of+1, @@ -790,7 +898,10 @@ void FAILtest_addFixedExtend(void) { insns[last].tt + 129*SECSPERDAY, NULL); TEST_ASSERT_EQUAL(FALSE, rc); + //leap_table_t * pt = leapsec_get_table(FALSE); //leapsec_dump(pt, (leapsec_dumper)fprintf, stdout); + + return; } #endif @@ -799,7 +910,9 @@ void FAILtest_addFixedExtend(void) { // empty table and test queries before / between /after the tabulated // values. #if 0 /* currently unused -- possibly revived later */ -void FAILtest_setFixedExtend(void) { +void +FAILtest_setFixedExtend(void) +{ int rc; leap_result_t qr; int last, idx; @@ -810,7 +923,6 @@ void FAILtest_setFixedExtend(void) { {0,0} // sentinel }; - leap_table_t * pt = leapsec_get_table(0); for (last=idx=0; insns[idx].tt; ++idx) { last = idx; rc = leapsec_add_fix( @@ -820,7 +932,7 @@ void FAILtest_setFixedExtend(void) { NULL); TEST_ASSERT_EQUAL(TRUE, rc); } - + rc = leapsec_query(&qr, insns[0].tt - 86400, NULL); TEST_ASSERT_EQUAL(28, qr.tai_offs); @@ -833,7 +945,10 @@ void FAILtest_setFixedExtend(void) { rc = leapsec_query(&qr, insns[1].tt + 86400, NULL); TEST_ASSERT_EQUAL(30, qr.tai_offs); + //leap_table_t * pt = leapsec_get_table(0); //leapsec_dump(pt, (leapsec_dumper)fprintf, stdout); + + return; } #endif @@ -846,7 +961,7 @@ void FAILtest_setFixedExtend(void) { void test_taiEmptyTable(void) { int rc; - rc = leapsec_autokey_tai(35, lsec2015-30*86400, NULL); + rc = leapsec_autokey_tai(35, lsec2015-30*86400, NULL); TEST_ASSERT_EQUAL(TRUE, rc); rc = leapsec_autokey_tai(35, lsec2015-29*86400, NULL); @@ -855,7 +970,9 @@ void test_taiEmptyTable(void) { // ---------------------------------------------------------------------- // Check that with fixed entries the operation fails -void test_taiTableFixed(void) { +void +test_taiTableFixed(void) +{ int rc; rc = setup_load_table(leap1, FALSE); @@ -863,11 +980,15 @@ void test_taiTableFixed(void) { rc = leapsec_autokey_tai(35, lsec2015-30*86400, NULL); TEST_ASSERT_EQUAL(FALSE, rc); + + return; } // ---------------------------------------------------------------------- // test adjustment with a dynamic entry already there -void test_taiTableDynamic(void) { +void +test_taiTableDynamic(void) +{ int rc; leap_era_t era; @@ -879,7 +1000,7 @@ void test_taiTableDynamic(void) { leapsec_query_era(&era, lsec2015+10, NULL); TEST_ASSERT_EQUAL(1, era.taiof); - rc = leapsec_autokey_tai(35, lsec2015-19*86400, NULL); + rc = leapsec_autokey_tai(35, lsec2015-19*86400, NULL); TEST_ASSERT_EQUAL(TRUE, rc); rc = leapsec_autokey_tai(35, lsec2015-19*86400, NULL); @@ -889,21 +1010,27 @@ void test_taiTableDynamic(void) { TEST_ASSERT_EQUAL(35, era.taiof); leapsec_query_era(&era, lsec2015+10, NULL); TEST_ASSERT_EQUAL(36, era.taiof); + + return; } // ---------------------------------------------------------------------- // test adjustment with a dynamic entry already there in dead zone -void test_taiTableDynamicDeadZone(void) { +void +test_taiTableDynamicDeadZone(void) +{ int rc; rc = leapsec_add_dyn(TRUE, lsec2015-20*SECSPERDAY, NULL); TEST_ASSERT_EQUAL(TRUE, rc); - rc = leapsec_autokey_tai(35, lsec2015-5, NULL); + rc = leapsec_autokey_tai(35, lsec2015-5, NULL); TEST_ASSERT_EQUAL(FALSE, rc); rc = leapsec_autokey_tai(35, lsec2015+5, NULL); TEST_ASSERT_EQUAL(FALSE, rc); + + return; } @@ -913,7 +1040,9 @@ void test_taiTableDynamicDeadZone(void) { // ---------------------------------------------------------------------- // leap second insert at 2009.01.01, electric mode -void test_ls2009seqInsElectric(void) { +void +test_ls2009seqInsElectric(void) +{ int rc; leap_result_t qr; @@ -952,11 +1081,15 @@ void test_ls2009seqInsElectric(void) { TEST_ASSERT_EQUAL(FALSE, rc); TEST_ASSERT_EQUAL(0, qr.warped ); TEST_ASSERT_EQUAL(LSPROX_NOWARN, qr.proximity); + + return; } // ---------------------------------------------------------------------- // leap second insert at 2009.01.01, dumb mode -void test_ls2009seqInsDumb(void) { +void +test_ls2009seqInsDumb(void) +{ int rc; leap_result_t qr; @@ -999,12 +1132,16 @@ void test_ls2009seqInsDumb(void) { TEST_ASSERT_EQUAL(FALSE, rc); TEST_ASSERT_EQUAL(0, qr.warped ); TEST_ASSERT_EQUAL(LSPROX_NOWARN, qr.proximity); + + return; } // ---------------------------------------------------------------------- // fake leap second remove at 2009.01.01, electric mode -void test_ls2009seqDelElectric(void) { +void +test_ls2009seqDelElectric(void) +{ int rc; leap_result_t qr; @@ -1043,11 +1180,15 @@ void test_ls2009seqDelElectric(void) { TEST_ASSERT_EQUAL(FALSE, rc); TEST_ASSERT_EQUAL(0, qr.warped ); TEST_ASSERT_EQUAL(LSPROX_NOWARN, qr.proximity); + + return; } // ---------------------------------------------------------------------- // fake leap second remove at 2009.01.01. dumb mode -void test_ls2009seqDelDumb(void) { +void +test_ls2009seqDelDumb(void) +{ int rc; leap_result_t qr; @@ -1085,11 +1226,15 @@ void test_ls2009seqDelDumb(void) { TEST_ASSERT_EQUAL(FALSE, rc); TEST_ASSERT_EQUAL(0, qr.warped ); TEST_ASSERT_EQUAL(LSPROX_NOWARN, qr.proximity); + + return; } // ---------------------------------------------------------------------- // leap second insert at 2012.07.01, electric mode -void test_ls2012seqInsElectric(void) { +void +test_ls2012seqInsElectric(void) +{ int rc; leap_result_t qr; @@ -1128,11 +1273,15 @@ void test_ls2012seqInsElectric(void) { TEST_ASSERT_EQUAL(FALSE, rc); TEST_ASSERT_EQUAL(0, qr.warped ); TEST_ASSERT_EQUAL(LSPROX_NOWARN, qr.proximity); + + return; } // ---------------------------------------------------------------------- // leap second insert at 2012.07.01, dumb mode -void test_ls2012seqInsDumb(void) { +void +test_ls2012seqInsDumb(void) +{ int rc; leap_result_t qr; @@ -1177,11 +1326,15 @@ void test_ls2012seqInsDumb(void) { TEST_ASSERT_EQUAL(FALSE, rc); TEST_ASSERT_EQUAL(0, qr.warped ); TEST_ASSERT_EQUAL(LSPROX_NOWARN, qr.proximity); + + return; } // ---------------------------------------------------------------------- // test repeated query on empty table in dumb mode -void test_lsEmptyTableDumb(void) { +void +test_lsEmptyTableDumb(void) +{ int rc; leap_result_t qr; @@ -1189,7 +1342,7 @@ void test_lsEmptyTableDumb(void) { time_t pivot; pivot = lsec2012; // const - //time_t pivot(lsec2012); + //time_t pivot(lsec2012); const uint32_t t0 = lsec2012 - 10; const uint32_t tE = lsec2012 + 10; @@ -1202,20 +1355,24 @@ void test_lsEmptyTableDumb(void) { TEST_ASSERT_EQUAL(0, qr.warped ); TEST_ASSERT_EQUAL(LSPROX_NOWARN, qr.proximity); } + + return; } // ---------------------------------------------------------------------- // test repeated query on empty table in electric mode -void test_lsEmptyTableElectric(void) { +void +test_lsEmptyTableElectric(void) +{ int rc; leap_result_t qr; - + leapsec_electric(1); TEST_ASSERT_EQUAL(1, leapsec_electric(-1)); //const time_t pivot;//(lsec2012); - pivot = lsec2012; + pivot = lsec2012; const uint32_t t0 = lsec2012 - 10; const uint32_t tE = lsec2012 + 10; @@ -1226,4 +1383,6 @@ void test_lsEmptyTableElectric(void) { TEST_ASSERT_EQUAL(0, qr.warped ); TEST_ASSERT_EQUAL(LSPROX_NOWARN, qr.proximity); } + + return; } diff --git a/contrib/ntp/tests/ntpd/ntp_prio_q.c b/contrib/ntp/tests/ntpd/ntp_prio_q.c index c2d4f76..4b27157 100644 --- a/contrib/ntp/tests/ntpd/ntp_prio_q.c +++ b/contrib/ntp/tests/ntpd/ntp_prio_q.c @@ -251,6 +251,7 @@ test_AppendQueues(void) { free_node(e3_ptr); free_node(e4_ptr); free_node(e5_ptr); + free_node(e6_ptr); TEST_ASSERT_EQUAL(0, get_no_of_elements(q4)); diff --git a/contrib/ntp/tests/ntpd/ntp_restrict.c b/contrib/ntp/tests/ntpd/ntp_restrict.c index 98d6e83..08d236e 100644 --- a/contrib/ntp/tests/ntpd/ntp_restrict.c +++ b/contrib/ntp/tests/ntpd/ntp_restrict.c @@ -26,6 +26,7 @@ setUp(void) { } +void tearDown(void) { restrict_u *empty_restrict = malloc(sizeof(restrict_u)); memset(empty_restrict, 0, sizeof(restrict_u)); diff --git a/contrib/ntp/tests/ntpd/rc_cmdlength.c b/contrib/ntp/tests/ntpd/rc_cmdlength.c index e3d599f..dfe5316 100644 --- a/contrib/ntp/tests/ntpd/rc_cmdlength.c +++ b/contrib/ntp/tests/ntpd/rc_cmdlength.c @@ -3,6 +3,7 @@ #include "ntp.h" #include "ntp_calendar.h" #include "ntp_stdlib.h" +#include "rc_cmdlength.h" #include "unity.h" diff --git a/contrib/ntp/tests/ntpd/run-leapsec.c b/contrib/ntp/tests/ntpd/run-leapsec.c index c02cfa8..03b633e 100644 --- a/contrib/ntp/tests/ntpd/run-leapsec.c +++ b/contrib/ntp/tests/ntpd/run-leapsec.c @@ -84,39 +84,39 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("leapsec.c"); - RUN_TEST(test_ValidateGood, 331); - RUN_TEST(test_ValidateNoHash, 338); - RUN_TEST(test_ValidateBad, 345); - RUN_TEST(test_ValidateMalformed, 352); - RUN_TEST(test_ValidateMalformedShort, 359); - RUN_TEST(test_ValidateNoLeadZero, 366); - RUN_TEST(test_tableSelect, 378); - RUN_TEST(test_loadFileExpire, 414); - RUN_TEST(test_loadFileTTL, 431); - RUN_TEST(test_lsQueryPristineState, 463); - RUN_TEST(test_ls2009faraway, 475); - RUN_TEST(test_ls2009weekaway, 492); - RUN_TEST(test_ls2009houraway, 509); - RUN_TEST(test_ls2009secaway, 526); - RUN_TEST(test_ls2009onspot, 543); - RUN_TEST(test_ls2009nodata, 560); - RUN_TEST(test_ls2009limdata, 577); - RUN_TEST(test_qryJumpFarAhead, 598); - RUN_TEST(test_qryJumpAheadToTransition, 620); - RUN_TEST(test_qryJumpAheadOverTransition, 642); - RUN_TEST(test_addDynamic, 668); - RUN_TEST(test_taiEmptyTable, 846); - RUN_TEST(test_taiTableFixed, 858); - RUN_TEST(test_taiTableDynamic, 870); - RUN_TEST(test_taiTableDynamicDeadZone, 896); - RUN_TEST(test_ls2009seqInsElectric, 916); - RUN_TEST(test_ls2009seqInsDumb, 959); - RUN_TEST(test_ls2009seqDelElectric, 1007); - RUN_TEST(test_ls2009seqDelDumb, 1050); - RUN_TEST(test_ls2012seqInsElectric, 1092); - RUN_TEST(test_ls2012seqInsDumb, 1135); - RUN_TEST(test_lsEmptyTableDumb, 1184); - RUN_TEST(test_lsEmptyTableElectric, 1209); + RUN_TEST(test_ValidateGood, 351); + RUN_TEST(test_ValidateNoHash, 362); + RUN_TEST(test_ValidateBad, 373); + RUN_TEST(test_ValidateMalformed, 385); + RUN_TEST(test_ValidateMalformedShort, 397); + RUN_TEST(test_ValidateNoLeadZero, 409); + RUN_TEST(test_tableSelect, 426); + RUN_TEST(test_loadFileExpire, 466); + RUN_TEST(test_loadFileTTL, 487); + RUN_TEST(test_lsQueryPristineState, 522); + RUN_TEST(test_ls2009faraway, 538); + RUN_TEST(test_ls2009weekaway, 559); + RUN_TEST(test_ls2009houraway, 580); + RUN_TEST(test_ls2009secaway, 601); + RUN_TEST(test_ls2009onspot, 622); + RUN_TEST(test_ls2009nodata, 643); + RUN_TEST(test_ls2009limdata, 664); + RUN_TEST(test_qryJumpFarAhead, 689); + RUN_TEST(test_qryJumpAheadToTransition, 712); + RUN_TEST(test_qryJumpAheadOverTransition, 737); + RUN_TEST(test_addDynamic, 767); + RUN_TEST(test_taiEmptyTable, 961); + RUN_TEST(test_taiTableFixed, 974); + RUN_TEST(test_taiTableDynamic, 990); + RUN_TEST(test_taiTableDynamicDeadZone, 1020); + RUN_TEST(test_ls2009seqInsElectric, 1044); + RUN_TEST(test_ls2009seqInsDumb, 1091); + RUN_TEST(test_ls2009seqDelElectric, 1143); + RUN_TEST(test_ls2009seqDelDumb, 1190); + RUN_TEST(test_ls2012seqInsElectric, 1236); + RUN_TEST(test_ls2012seqInsDumb, 1283); + RUN_TEST(test_lsEmptyTableDumb, 1336); + RUN_TEST(test_lsEmptyTableElectric, 1365); return (UnityEnd()); } diff --git a/contrib/ntp/tests/ntpd/run-ntp_restrict.c b/contrib/ntp/tests/ntpd/run-ntp_restrict.c index 0d945eb..d884462 100644 --- a/contrib/ntp/tests/ntpd/run-ntp_restrict.c +++ b/contrib/ntp/tests/ntpd/run-ntp_restrict.c @@ -55,14 +55,14 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("ntp_restrict.c"); - RUN_TEST(test_RestrictionsAreEmptyAfterInit, 59); - RUN_TEST(test_ReturnsCorrectDefaultRestrictions, 85); - RUN_TEST(test_HackingDefaultRestriction, 96); - RUN_TEST(test_CantRemoveDefaultEntry, 119); - RUN_TEST(test_AddingNewRestriction, 130); - RUN_TEST(test_TheMostFittingRestrictionIsMatched, 143); - RUN_TEST(test_DeletedRestrictionIsNotMatched, 165); - RUN_TEST(test_RestrictUnflagWorks, 189); + RUN_TEST(test_RestrictionsAreEmptyAfterInit, 60); + RUN_TEST(test_ReturnsCorrectDefaultRestrictions, 86); + RUN_TEST(test_HackingDefaultRestriction, 97); + RUN_TEST(test_CantRemoveDefaultEntry, 120); + RUN_TEST(test_AddingNewRestriction, 131); + RUN_TEST(test_TheMostFittingRestrictionIsMatched, 144); + RUN_TEST(test_DeletedRestrictionIsNotMatched, 166); + RUN_TEST(test_RestrictUnflagWorks, 190); return (UnityEnd()); } diff --git a/contrib/ntp/tests/ntpd/run-rc_cmdlength.c b/contrib/ntp/tests/ntpd/run-rc_cmdlength.c index c6fb7cc..927a45e 100644 --- a/contrib/ntp/tests/ntpd/run-rc_cmdlength.c +++ b/contrib/ntp/tests/ntpd/run-rc_cmdlength.c @@ -26,6 +26,7 @@ #include "ntp.h" #include "ntp_calendar.h" #include "ntp_stdlib.h" +#include "rc_cmdlength.h" #include "test-libntp.h" #include <string.h> @@ -51,7 +52,7 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("rc_cmdlength.c"); - RUN_TEST(test_EvaluateCommandLength, 15); + RUN_TEST(test_EvaluateCommandLength, 16); return (UnityEnd()); } diff --git a/contrib/ntp/tests/ntpd/run-t-ntp_signd.c b/contrib/ntp/tests/ntpd/run-t-ntp_signd.c index 662cada..5226f7f 100644 --- a/contrib/ntp/tests/ntpd/run-t-ntp_signd.c +++ b/contrib/ntp/tests/ntpd/run-t-ntp_signd.c @@ -36,7 +36,7 @@ extern void test_connect_correct_socket(void); extern void test_write_all(void); extern void test_send_packet(void); extern void test_recv_packet(void); -extern void test_send_via_ntp_signd(); +extern void test_send_via_ntp_signd(void); //=======Test Reset Option===== @@ -55,12 +55,12 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("t-ntp_signd.c"); - RUN_TEST(test_connect_incorrect_socket, 49); - RUN_TEST(test_connect_correct_socket, 54); - RUN_TEST(test_write_all, 74); - RUN_TEST(test_send_packet, 84); - RUN_TEST(test_recv_packet, 93); - RUN_TEST(test_send_via_ntp_signd, 104); + RUN_TEST(test_connect_incorrect_socket, 67); + RUN_TEST(test_connect_correct_socket, 68); + RUN_TEST(test_write_all, 69); + RUN_TEST(test_send_packet, 70); + RUN_TEST(test_recv_packet, 71); + RUN_TEST(test_send_via_ntp_signd, 72); return (UnityEnd()); } diff --git a/contrib/ntp/tests/ntpd/t-ntp_scanner.c b/contrib/ntp/tests/ntpd/t-ntp_scanner.c index 9bc77c4..862a2ee 100644 --- a/contrib/ntp/tests/ntpd/t-ntp_scanner.c +++ b/contrib/ntp/tests/ntpd/t-ntp_scanner.c @@ -26,13 +26,13 @@ void test_InitializeLexStack(void); void test_keywordIncorrectToken(void){ - char * temp = keyword(999); + const char * temp = keyword(999); //printf("%s\n",temp); TEST_ASSERT_EQUAL_STRING("(keyword not found)",temp); } void test_keywordServerToken(void){ - char * temp = keyword(401); + const char * temp = keyword(T_Server); //printf("%s",temp); //143 or 401 ? TEST_ASSERT_EQUAL_STRING("server",temp); } @@ -127,7 +127,7 @@ void test_EOC(void){ temp = is_EOC(';'); TEST_ASSERT_TRUE(temp); } - temp = is_EOC("A"); + temp = is_EOC('A'); TEST_ASSERT_FALSE(temp); temp = is_EOC('1'); TEST_ASSERT_FALSE(temp); diff --git a/contrib/ntp/tests/ntpd/t-ntp_signd.c b/contrib/ntp/tests/ntpd/t-ntp_signd.c index 45972fb..534c940 100644 --- a/contrib/ntp/tests/ntpd/t-ntp_signd.c +++ b/contrib/ntp/tests/ntpd/t-ntp_signd.c @@ -9,7 +9,6 @@ #include "test-libntp.h" - #define HAVE_NTP_SIGND #include "ntp_signd.c" @@ -20,41 +19,70 @@ extern int ux_socket_connect(const char *name); //MOCKED FUNCTIONS //this connect function overrides/mocks connect() from <sys/socket.h> -int connect(int socket, const struct sockaddr *address, -socklen_t address_len){ +int +connect(int socket, const struct sockaddr *address, socklen_t address_len) +{ return 1; } -//mocked write will only send 4 bytes at a time. This is so write_all can be properly tested -ssize_t write(int fd, void const * buf, size_t len){ - if(len >= 4){return 4;} - else return len; +/* +** Mocked read() and write() calls. +** +** These will only operate 4 bytes at a time. +** +** This is so write_all can be properly tested. +*/ + +static char rw_buf[4]; + +ssize_t +write(int fd, void const * buf, size_t len) +{ + REQUIRE(0 <= len); + if (len >= 4) len = 4; /* 4 bytes, max */ + (void)memcpy(rw_buf, buf, len); + + return len; } -ssize_t read(int fd, void * buf, size_t len){ - if(len >= 4){return 4;} - else return len; +ssize_t +read(int fd, void * buf, size_t len) +{ + REQUIRE(0 <= len); + if (len >= 4) len = 4; + (void)memcpy(buf, rw_buf, len); + return len; } //END OF MOCKED FUNCTIONS -int isGE(int a,int b){ - if(a >= b) {return 1;} +static int +isGE(int a,int b) +{ + if (a >= b) {return 1;} else {return 0;} } +extern void test_connect_incorrect_socket(void); +extern void test_connect_correct_socket(void); +extern void test_write_all(void); +extern void test_send_packet(void); +extern void test_recv_packet(void); +extern void test_send_via_ntp_signd(void); + void -test_connect_incorrect_socket(void){ +test_connect_incorrect_socket(void) +{ TEST_ASSERT_EQUAL(-1, ux_socket_connect(NULL)); + + return; } void -test_connect_correct_socket(void){ - - - +test_connect_correct_socket(void) +{ int temp = ux_socket_connect("/socket"); //risky, what if something is listening on :123, or localhost isnt 127.0.0.1? @@ -67,50 +95,87 @@ test_connect_correct_socket(void){ //char *socketName = "Random_Socket_Name"; //int length = strlen(socketName); + return; } void -test_write_all(void){ +test_write_all(void) +{ int fd = ux_socket_connect("/socket"); - TEST_ASSERT_TRUE(isGE(fd,0)); + + TEST_ASSERT_TRUE(isGE(fd, 0)); + char * str = "TEST123"; int temp = write_all(fd, str,strlen(str)); - TEST_ASSERT_EQUAL(strlen(str),temp); + TEST_ASSERT_EQUAL(strlen(str), temp); + + (void)close(fd); + return; } void -test_send_packet(void){ +test_send_packet(void) +{ int fd = ux_socket_connect("/socket"); + + TEST_ASSERT_TRUE(isGE(fd, 0)); + char * str2 = "PACKET12345"; int temp = send_packet(fd, str2, strlen(str2)); + TEST_ASSERT_EQUAL(0,temp); + + (void)close(fd); + return; } +/* +** HMS: What's going on here? +** Looks like this needs more work. +*/ void -test_recv_packet(void){ +test_recv_packet(void) +{ int fd = ux_socket_connect("/socket"); - int size = 256; - char str[size]; + TEST_ASSERT_TRUE(isGE(fd, 0)); + + uint32_t size = 256; + char *str = NULL; int temp = recv_packet(fd, &str, &size); + send_packet(fd, str, strlen(str)); + free(str); TEST_ASSERT_EQUAL(0,temp); //0 because nobody sent us anything (yet!) + + (void)close(fd); + return; } void -test_send_via_ntp_signd(){ - +test_send_via_ntp_signd(void) +{ struct recvbuf *rbufp = (struct recvbuf *) malloc(sizeof(struct recvbuf)); int xmode = 1; keyid_t xkeyid = 12345; - int flags =0; + int flags = 0; struct pkt *xpkt = (struct pkt *) malloc(sizeof(struct pkt)); //defined in ntp.h + TEST_ASSERT_NOT_NULL(rbufp); + TEST_ASSERT_NOT_NULL(xpkt); + memset(xpkt, 0, sizeof(struct pkt)); + //send_via_ntp_signd(NULL,NULL,NULL,NULL,NULL); //doesn't work + /* + ** Send the xpkt to Samba, read the response back in rbufp + */ send_via_ntp_signd(rbufp,xmode,xkeyid,flags,xpkt); + free(rbufp); + free(xpkt); + return; } diff --git a/contrib/ntp/tests/sandbox/run-uglydate.c b/contrib/ntp/tests/sandbox/run-uglydate.c index e65cd01..5a5a716 100644 --- a/contrib/ntp/tests/sandbox/run-uglydate.c +++ b/contrib/ntp/tests/sandbox/run-uglydate.c @@ -24,6 +24,7 @@ #include <stdio.h> #include "config.h" #include "ntp_fp.h" +#include "ntp_stdlib.h" //=======External Functions This Runner Calls===== extern void setUp(void); @@ -47,7 +48,7 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("uglydate.c"); - RUN_TEST(test_ConstantDateTime, 9); + RUN_TEST(test_ConstantDateTime, 10); return (UnityEnd()); } diff --git a/contrib/ntp/tests/sandbox/smeartest.c b/contrib/ntp/tests/sandbox/smeartest.c index a8ee210..cc4e503 100644 --- a/contrib/ntp/tests/sandbox/smeartest.c +++ b/contrib/ntp/tests/sandbox/smeartest.c @@ -2,6 +2,7 @@ #include <ntp.h> #include <ntp_fp.h> +#include <ntp_assert.h> /* * we want to test a refid format of: @@ -125,11 +126,14 @@ ltor(l_fp l) } +int main() { l_fp l; int rc; + init_lib(); + rtol(0xfe800000); rtol(0xfe800001); rtol(0xfe8ffffe); @@ -167,6 +171,8 @@ main() rtoltor(0xfe7fffff); rc = atolfp("-.932087", &l); + INSIST(1 == rc); + ltor(l); rtol(0xfec458b0); printf("%x -> %d.%d.%d.%d\n", diff --git a/contrib/ntp/tests/sandbox/uglydate.c b/contrib/ntp/tests/sandbox/uglydate.c index a7879c1..ba8377e 100644 --- a/contrib/ntp/tests/sandbox/uglydate.c +++ b/contrib/ntp/tests/sandbox/uglydate.c @@ -2,15 +2,30 @@ #include "ntp_fp.h" #include "unity.h" -//#include "ntp_stdlib.h" +#include "ntp_stdlib.h" + //#include "libntptest.h" +void setUp(void); +void test_ConstantDateTime(void); + + +void +setUp(void) +{ + init_lib(); + + return; +} + + void -test_ConstantDateTime(void) { +test_ConstantDateTime(void) +{ const u_int32 HALF = 2147483648UL; - l_fp time = {3485080800UL, HALF}; // 2010-06-09 14:00:00.5 + l_fp e_time = {{3485080800UL}, HALF}; // 2010-06-09 14:00:00.5 TEST_ASSERT_EQUAL_STRING("3485080800.500000 10:159:14:00:00.500", - uglydate(&time)); + uglydate(&e_time)); } diff --git a/contrib/ntp/tests/sec-2853/sec-2853.c b/contrib/ntp/tests/sec-2853/sec-2853.c index 49589d2..f9255b0 100644 --- a/contrib/ntp/tests/sec-2853/sec-2853.c +++ b/contrib/ntp/tests/sec-2853/sec-2853.c @@ -13,7 +13,7 @@ int embedded_nul( void ); int trailing_space( void ); static int verbose = 1; // if not 0, also print results if test passed -static int exit_on_err = 0; // if not 0, exit if test failed +// static int exit_on_err = 0; // if not 0, exit if test failed void setUp(void) @@ -49,7 +49,6 @@ int basic_good( void ) { const char string[] = "good"; const char *EOstring; - char *cp; size_t len; int failed; @@ -60,9 +59,9 @@ int basic_good( void ) failed = ( 4 != len ); if ( failed || verbose ) - printf( "remoteconfig_cmdlength(\"%s\") returned %d, expected %d: %s\n", + printf( "remoteconfig_cmdlength(\"%s\") returned %llu, expected %u: %s\n", string, - len, + (unsigned long long)len, 4, failed ? "NO <<" : "yes" ); @@ -74,7 +73,6 @@ int embedded_nul( void ) { const char string[] = "nul\0 there"; const char *EOstring; - char *cp; size_t len; int failed; @@ -85,9 +83,9 @@ int embedded_nul( void ) failed = ( 3 != len ); if ( failed || verbose ) - printf( "remoteconfig_cmdlength(\"%s\") returned %d, expected %d: %s\n", + printf( "remoteconfig_cmdlength(\"%s\") returned %llu, expected %u: %s\n", string, - len, + (unsigned long long)len, 3, failed ? "NO <<" : "yes" ); @@ -99,7 +97,6 @@ int trailing_space( void ) { const char string[] = "trailing space "; const char *EOstring; - char *cp; size_t len; int failed; @@ -110,9 +107,9 @@ int trailing_space( void ) failed = ( 14 != len ); if ( failed || verbose ) - printf( "remoteconfig_cmdlength(\"%s\") returned %d, expected %d: %s\n", + printf( "remoteconfig_cmdlength(\"%s\") returned %llu, expected %u: %s\n", string, - len, + (unsigned long long)len, 14, failed ? "NO <<" : "yes" ); diff --git a/contrib/ntp/util/invoke-ntp-keygen.texi b/contrib/ntp/util/invoke-ntp-keygen.texi index eafcb43..36a1a42 100644 --- a/contrib/ntp/util/invoke-ntp-keygen.texi +++ b/contrib/ntp/util/invoke-ntp-keygen.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntp-keygen.texi) # -# It has been AutoGen-ed October 21, 2015 at 12:40:07 PM by AutoGen 5.18.5 +# It has been AutoGen-ed January 7, 2016 at 11:32:40 PM by AutoGen 5.18.5 # From the definitions ntp-keygen-opts.def # and the template file agtexi-cmd.tpl @end ignore @@ -886,7 +886,7 @@ with a status code of 0. @exampleindent 0 @example -ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p4 +ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p5 Usage: ntp-keygen [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... Flg Arg Option-Name Description -b Num imbits identity modulus bits diff --git a/contrib/ntp/util/ntp-keygen-opts.c b/contrib/ntp/util/ntp-keygen-opts.c index 1f256f9..f41bff4 100644 --- a/contrib/ntp/util/ntp-keygen-opts.c +++ b/contrib/ntp/util/ntp-keygen-opts.c @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (ntp-keygen-opts.c) * - * It has been AutoGen-ed October 21, 2015 at 12:39:50 PM by AutoGen 5.18.5 + * It has been AutoGen-ed January 7, 2016 at 11:32:25 PM by AutoGen 5.18.5 * From the definitions ntp-keygen-opts.def * and the template file options * @@ -72,7 +72,7 @@ extern FILE * option_usage_fp; * static const strings for ntp-keygen options */ static char const ntp_keygen_opt_strs[2419] = -/* 0 */ "ntp-keygen (ntp) 4.2.8p4\n" +/* 0 */ "ntp-keygen (ntp) 4.2.8p5\n" "Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n" "This is free software. It is licensed for use, modification and\n" "redistribution under the terms of the NTP License, copies of which\n" @@ -164,14 +164,14 @@ static char const ntp_keygen_opt_strs[2419] = /* 2202 */ "no-load-opts\0" /* 2215 */ "no\0" /* 2218 */ "NTP_KEYGEN\0" -/* 2229 */ "ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p4\n" +/* 2229 */ "ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p5\n" "Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n\0" /* 2343 */ "$HOME\0" /* 2349 */ ".\0" /* 2351 */ ".ntprc\0" /* 2358 */ "http://bugs.ntp.org, bugs@ntp.org\0" /* 2392 */ "\n\0" -/* 2394 */ "ntp-keygen (ntp) 4.2.8p4"; +/* 2394 */ "ntp-keygen (ntp) 4.2.8p5"; /** * imbits option description: @@ -1309,7 +1309,7 @@ static void bogus_function(void) { translate option names. */ /* referenced via ntp_keygenOptions.pzCopyright */ - puts(_("ntp-keygen (ntp) 4.2.8p4\n\ + puts(_("ntp-keygen (ntp) 4.2.8p5\n\ Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n\ This is free software. It is licensed for use, modification and\n\ redistribution under the terms of the NTP License, copies of which\n\ @@ -1408,14 +1408,14 @@ implied warranty.\n")); puts(_("load options from a config file")); /* referenced via ntp_keygenOptions.pzUsageTitle */ - puts(_("ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p4\n\ + puts(_("ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p5\n\ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n")); /* referenced via ntp_keygenOptions.pzExplain */ puts(_("\n")); /* referenced via ntp_keygenOptions.pzFullVersion */ - puts(_("ntp-keygen (ntp) 4.2.8p4")); + puts(_("ntp-keygen (ntp) 4.2.8p5")); /* referenced via ntp_keygenOptions.pzFullUsage */ puts(_("<<<NOT-FOUND>>>")); diff --git a/contrib/ntp/util/ntp-keygen-opts.h b/contrib/ntp/util/ntp-keygen-opts.h index c88bef8..1205494 100644 --- a/contrib/ntp/util/ntp-keygen-opts.h +++ b/contrib/ntp/util/ntp-keygen-opts.h @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (ntp-keygen-opts.h) * - * It has been AutoGen-ed October 21, 2015 at 12:39:50 PM by AutoGen 5.18.5 + * It has been AutoGen-ed January 7, 2016 at 11:32:24 PM by AutoGen 5.18.5 * From the definitions ntp-keygen-opts.def * and the template file options * @@ -94,9 +94,9 @@ typedef enum { /** count of all options for ntp-keygen */ #define OPTION_CT 26 /** ntp-keygen version */ -#define NTP_KEYGEN_VERSION "4.2.8p4" +#define NTP_KEYGEN_VERSION "4.2.8p5" /** Full ntp-keygen version text */ -#define NTP_KEYGEN_FULL_VERSION "ntp-keygen (ntp) 4.2.8p4" +#define NTP_KEYGEN_FULL_VERSION "ntp-keygen (ntp) 4.2.8p5" /** * Interface defines for all options. Replace "n" with the UPPER_CASED diff --git a/contrib/ntp/util/ntp-keygen.1ntp-keygenman b/contrib/ntp/util/ntp-keygen.1ntp-keygenman index 99d9925..195e3d2 100644 --- a/contrib/ntp/util/ntp-keygen.1ntp-keygenman +++ b/contrib/ntp/util/ntp-keygen.1ntp-keygenman @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntp-keygen 1ntp-keygenman "21 Oct 2015" "ntp (4.2.8p4)" "User Commands" +.TH ntp-keygen 1ntp-keygenman "07 Jan 2016" "ntp (4.2.8p5)" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-r5aiQP/ag-E5aaPP) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-LNaiiw/ag-XNaahw) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:40:02 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:32:36 PM by AutoGen 5.18.5 .\" From the definitions ntp-keygen-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/util/ntp-keygen.1ntp-keygenmdoc b/contrib/ntp/util/ntp-keygen.1ntp-keygenmdoc index 7b749fd..18c38fb 100644 --- a/contrib/ntp/util/ntp-keygen.1ntp-keygenmdoc +++ b/contrib/ntp/util/ntp-keygen.1ntp-keygenmdoc @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTP_KEYGEN 1ntp-keygenmdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntp-keygen-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:40:10 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:32:43 PM by AutoGen 5.18.5 .\" From the definitions ntp-keygen-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/ntp/util/ntp-keygen.c b/contrib/ntp/util/ntp-keygen.c index 9568adc..ab34927 100644 --- a/contrib/ntp/util/ntp-keygen.c +++ b/contrib/ntp/util/ntp-keygen.c @@ -187,7 +187,7 @@ readlink( int len ) { - return strlen(file); + return (int)strlen(file); /* assume no overflow possible */ } /* @@ -1957,10 +1957,10 @@ x509 ( X509_time_adj(X509_get_notAfter(cert), lifetime * SECSPERDAY, &epoch); subj = X509_get_subject_name(cert); X509_NAME_add_entry_by_txt(subj, "commonName", MBSTRING_ASC, - (u_char *)name, strlen(name), -1, 0); + (u_char *)name, -1, -1, 0); subj = X509_get_issuer_name(cert); X509_NAME_add_entry_by_txt(subj, "commonName", MBSTRING_ASC, - (u_char *)name, strlen(name), -1, 0); + (u_char *)name, -1, -1, 0); if (!X509_set_pubkey(cert, pkey)) { fprintf(stderr, "Assign certificate signing key fails\n%s\n", ERR_error_string(ERR_get_error(), NULL)); diff --git a/contrib/ntp/util/ntp-keygen.html b/contrib/ntp/util/ntp-keygen.html index 39d911e..f7a6073 100644 --- a/contrib/ntp/util/ntp-keygen.html +++ b/contrib/ntp/util/ntp-keygen.html @@ -70,7 +70,7 @@ All other files are in PEM-encoded printable ASCII format so they can be embedded as MIME attachments in mail to other sites. - <p>This document applies to version 4.2.8p4 of <code>ntp-keygen</code>. + <p>This document applies to version 4.2.8p5 of <code>ntp-keygen</code>. <div class="node"> <p><hr> @@ -1085,7 +1085,7 @@ the usage text by passing it through a pager program. used to select the program, defaulting to <span class="file">more</span>. Both will exit with a status code of 0. -<pre class="example">ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p4-sec-RC2 +<pre class="example">ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p4 Usage: ntp-keygen [ -<flag> [<val>] | --<name>[{=| }<val>] ]... Flg Arg Option-Name Description -b Num imbits identity modulus bits diff --git a/contrib/ntp/util/ntp-keygen.man.in b/contrib/ntp/util/ntp-keygen.man.in index a928768..c76c4df 100644 --- a/contrib/ntp/util/ntp-keygen.man.in +++ b/contrib/ntp/util/ntp-keygen.man.in @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntp-keygen @NTP_KEYGEN_MS@ "21 Oct 2015" "ntp (4.2.8p4)" "User Commands" +.TH ntp-keygen @NTP_KEYGEN_MS@ "07 Jan 2016" "ntp (4.2.8p5)" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-r5aiQP/ag-E5aaPP) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-LNaiiw/ag-XNaahw) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:40:02 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:32:36 PM by AutoGen 5.18.5 .\" From the definitions ntp-keygen-opts.def .\" and the template file agman-cmd.tpl .SH NAME diff --git a/contrib/ntp/util/ntp-keygen.mdoc.in b/contrib/ntp/util/ntp-keygen.mdoc.in index 4d035cb..9e6675b 100644 --- a/contrib/ntp/util/ntp-keygen.mdoc.in +++ b/contrib/ntp/util/ntp-keygen.mdoc.in @@ -1,9 +1,9 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTP_KEYGEN @NTP_KEYGEN_MS@ User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntp-keygen-opts.mdoc) .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:40:10 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:32:43 PM by AutoGen 5.18.5 .\" From the definitions ntp-keygen-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/contrib/pf/pflogd/pflogd.c b/contrib/pf/pflogd/pflogd.c index 2fc2338..de8d4ac 100644 --- a/contrib/pf/pflogd/pflogd.c +++ b/contrib/pf/pflogd/pflogd.c @@ -766,7 +766,7 @@ main(int argc, char **argv) np = pcap_dispatch(hpcap, PCAP_NUM_PKTS, phandler, (u_char *)dpcap); if (np < 0) { - if (!if_exists(interface) == -1) { + if (!if_exists(interface)) { logmsg(LOG_NOTICE, "interface %s went away", interface); ret = -1; diff --git a/etc/Makefile b/etc/Makefile index cf97988..5484c11 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -154,6 +154,9 @@ MTREE= BSD.debug.dist BSD.include.dist BSD.root.dist BSD.usr.dist BSD.var.dist .if ${MK_LIB32} != "no" MTREE+= BSD.lib32.dist .endif +.if ${MK_LIBSOFT} != "no" +MTREE+= BSD.libsoft.dist +.endif .if ${MK_TESTS} != "no" MTREE+= BSD.tests.dist .endif @@ -354,6 +357,10 @@ MTREES+= mtree/BSD.groff.dist /usr MTREES+= mtree/BSD.lib32.dist /usr MTREES+= mtree/BSD.lib32.dist /usr/lib/debug/usr .endif +.if ${MK_LIBSOFT} != "no" +MTREES+= mtree/BSD.libsoft.dist /usr +MTREES+= mtree/BSD.libsoft.dist /usr/lib/debug/usr +.endif .if ${MK_TESTS} != "no" MTREES+= mtree/BSD.tests.dist ${TESTSBASE} MTREES+= mtree/BSD.tests.dist /usr/lib/debug/${TESTSBASE} diff --git a/etc/master.passwd b/etc/master.passwd index f2a4523..fc7fef5 100644 --- a/etc/master.passwd +++ b/etc/master.passwd @@ -22,5 +22,6 @@ uucp:*:66:66::0:0:UUCP pseudo-user:/var/spool/uucppublic:/usr/local/libexec/uucp pop:*:68:6::0:0:Post Office Owner:/nonexistent:/usr/sbin/nologin auditdistd:*:78:77::0:0:Auditdistd unprivileged user:/var/empty:/usr/sbin/nologin www:*:80:80::0:0:World Wide Web Owner:/nonexistent:/usr/sbin/nologin +_ypldap:*:93:93::0:0:YP Ldap unprivileged user:/var/empty:/usr/sbin/nologin hast:*:845:845::0:0:HAST unprivileged user:/var/empty:/usr/sbin/nologin nobody:*:65534:65534::0:0:Unprivileged user:/nonexistent:/usr/sbin/nologin diff --git a/etc/mtree/BSD.libsoft.dist b/etc/mtree/BSD.libsoft.dist new file mode 100644 index 0000000..69026a7 --- /dev/null +++ b/etc/mtree/BSD.libsoft.dist @@ -0,0 +1,14 @@ +# $FreeBSD$ +# +# Please see the file src/etc/mtree/README before making changes to this file. +# + +/set type=dir uname=root gname=wheel mode=0755 +. + libsoft + dtrace + .. + i18n + .. + .. +.. diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index be83bc4..9ec59be 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -660,6 +660,8 @@ .. pw .. + rpcbind + .. sa .. .. diff --git a/etc/mtree/Makefile b/etc/mtree/Makefile index 1a941e4..d8df25d 100644 --- a/etc/mtree/Makefile +++ b/etc/mtree/Makefile @@ -6,6 +6,7 @@ FILES= ${_BSD.debug.dist} \ BSD.include.dist \ BSD.root.dist \ ${_BSD.lib32.dist} \ + ${_BSD.libsoft.dist} \ ${_BSD.sendmail.dist} \ ${_BSD.tests.dist} \ BSD.usr.dist \ @@ -20,6 +21,9 @@ _BSD.groff.dist= BSD.groff.dist .if ${MK_LIB32} != "no" _BSD.lib32.dist= BSD.lib32.dist .endif +.if ${MK_LIBSOFT} != "no" +_BSD.libsoft.dist= BSD.libsoft.dist +.endif .if ${MK_SENDMAIL} != "no" _BSD.sendmail.dist= BSD.sendmail.dist .endif diff --git a/etc/ntp/leap-seconds b/etc/ntp/leap-seconds index b8b41f2..8fa6225 100644 --- a/etc/ntp/leap-seconds +++ b/etc/ntp/leap-seconds @@ -1,119 +1,221 @@ # # $FreeBSD$ # -# ATOMIC TIME. -# The Coordinated Universal Time (UTC) is the reference time scale derived -# from The "Temps Atomique International" (TAI) calculated by the Bureau -# International des Poids et Mesures (BIPM) using a worldwide network of atomic -# clocks. UTC differs from TAI by an integer number of seconds; it is the basis -# of all activities in the world. -# -# -# ASTRONOMICAL TIME (UT1) is the time scale based on the rate of rotation of the earth. -# It is now mainly derived from Very Long Baseline Interferometry (VLBI). The various -# irregular fluctuations progressively detected in the rotation rate of the Earth lead -# in 1972 to the replacement of UT1 by UTC as the reference time scale. -# -# -# LEAP SECOND -# Atomic clocks are more stable than the rate of the earth rotatiob since the later -# undergoes a full range of geophysical perturbations at various time scales (lunisolar -# and core-mantle torques,atmospheric and oceanic effetcs, ...) -# Leap seconds are needed to keep the two time scales in agreement, i.e. UT1-UTC smaller -# than 0.9 second. So, when necessary a "leap second" is introduced in UTC. -# Since the adoption of this system in 1972 it has been necessary to add 26 seconds to UTC, -# firstly due to the initial choice of the value of the second (1/86400 mean solar day of -# the year 1820) and secondly to the general slowing down of the Earth's rotation. It is -# theorically possible to have a negative leap second (a second removed from UTC), but so far, -# all leap seconds have been positive (a second has been added to UTC). Based on what we know about the earth's rotation, -# it is unlikely that we will ever have a negative leap second. -# -# -# HISTORY -# The first leap second was added on June 30, 1972. Until 2000, it was necessary in average to add a leap second at a rate -# of 1 to 2 years. Since 2000, due to the fact that the earth rate of rotation is accelerating, leap seconds are introduced -# with an average frequency of 3 to 4 years. -# -# -# RESPONSABILITY OF THE DECISION TO INTRODUCE A LEAP SECOND IN UTC -# The decision to introduce a leap second in UTC is the responsibility of the Earth Orientation Center of -# the International Earth Rotation and reference System Service (IERS). This center is located at Paris -# Observatory. According to international agreements, leap second date have to occur at fixed date : -# first preference is given to the end of December and June, and second preference at the end of March -# and September. Since the system was introduced in 1972, only dates in June and December were used. -# -# Questions or comments to: -# Daniel Gambis, daniel.gambis@obspm.fr -# Christian Bizouard: christian.bizouard@obspm.fr -# Earth orientation Center of the IERS -# Paris Observatory, France -# -# -# -# VALIDITY OF THE FILE -# It is important to express the validity of the file. These next two dates are -# given in units of seconds since 1900.0. -# -# 1) Last update of the file. -# -# Updated through IERS Bulletin C (ftp://hpiers.obspm.fr/iers/bul/bulc/bulletinc.dat) -# -# The following line shows the last update of this file in NTP timestamp: -# -#$ 3645216000 -# -# 2) Expiration date of the file given on a semi-annual basis: last June or last December -# -# File expires on 28 December 2015 -# -# Expire date in NTP timestamp: -# -#@ 3660249600 -# -# -# LIST OF LEAP SECONDS -# NTP timestamp (X parameter) is the number of seconds since 1900.0 -# -# MJD: The Modified Julian Day number. MJD = X/86400 + 15020 -# -# DTAI: The difference DTAI= TAI-UTC in units of seconds -# It is the quantity to add to UTC to get the time in TAI -# -# Day Month Year : epoch in clear -# -#NTP Time DTAI Day Month Year -# -2272060800 10 # 1 Jan 1972 -2287785600 11 # 1 Jul 1972 -2303683200 12 # 1 Jan 1973 -2335219200 13 # 1 Jan 1974 -2366755200 14 # 1 Jan 1975 -2398291200 15 # 1 Jan 1976 -2429913600 16 # 1 Jan 1977 -2461449600 17 # 1 Jan 1978 -2492985600 18 # 1 Jan 1979 -2524521600 19 # 1 Jan 1980 -2571782400 20 # 1 Jul 1981 -2603318400 21 # 1 Jul 1982 -2634854400 22 # 1 Jul 1983 -2698012800 23 # 1 Jul 1985 -2776982400 24 # 1 Jan 1988 -2840140800 25 # 1 Jan 1990 -2871676800 26 # 1 Jan 1991 -2918937600 27 # 1 Jul 1992 -2950473600 28 # 1 Jul 1993 -2982009600 29 # 1 Jul 1994 -3029443200 30 # 1 Jan 1996 -3076704000 31 # 1 Jul 1997 -3124137600 32 # 1 Jan 1999 -3345062400 33 # 1 Jan 2006 -3439756800 34 # 1 Jan 2009 -3550089600 35 # 1 Jul 2012 -3644697600 36 # 1 Jul 2015 -# -# In order to verify the integrity of this file, a hash code -# has been generated. For more information how to use -# this hash code, please consult the README file under the -# 'sha' repertory. -# -#h 620ba8af 37900668 95ac09ba d77640f9 6fd75493 +# In the following text, the symbol '#' introduces +# a comment, which continues from that symbol until +# the end of the line. A plain comment line has a +# whitespace character following the comment indicator. +# There are also special comment lines defined below. +# A special comment will always have a non-whitespace +# character in column 2. +# +# A blank line should be ignored. +# +# The following table shows the corrections that must +# be applied to compute International Atomic Time (TAI) +# from the Coordinated Universal Time (UTC) values that +# are transmitted by almost all time services. +# +# The first column shows an epoch as a number of seconds +# since 1900.0 and the second column shows the number of +# seconds that must be added to UTC to compute TAI for +# any timestamp at or after that epoch. The value on +# each line is valid from the indicated initial instant +# until the epoch given on the next one or indefinitely +# into the future if there is no next line. +# (The comment on each line shows the representation of +# the corresponding initial epoch in the usual +# day-month-year format. The epoch always begins at +# 00:00:00 UTC on the indicated day. See Note 5 below.) +# +# Important notes: +# +# 1. Coordinated Universal Time (UTC) is often referred to +# as Greenwich Mean Time (GMT). The GMT time scale is no +# longer used, and the use of GMT to designate UTC is +# discouraged. +# +# 2. The UTC time scale is realized by many national +# laboratories and timing centers. Each laboratory +# identifies its realization with its name: Thus +# UTC(NIST), UTC(USNO), etc. The differences among +# these different realizations are typically on the +# order of a few nanoseconds (i.e., 0.000 000 00x s) +# and can be ignored for many purposes. These differences +# are tabulated in Circular T, which is published monthly +# by the International Bureau of Weights and Measures +# (BIPM). See www.bipm.fr for more information. +# +# 3. The current defintion of the relationship between UTC +# and TAI dates from 1 January 1972. A number of different +# time scales were in use before than epoch, and it can be +# quite difficult to compute precise timestamps and time +# intervals in those "prehistoric" days. For more information, +# consult: +# +# The Explanatory Supplement to the Astronomical +# Ephemeris. +# or +# Terry Quinn, "The BIPM and the Accurate Measurement +# of Time," Proc. of the IEEE, Vol. 79, pp. 894-905, +# July, 1991. +# +# 4. The insertion of leap seconds into UTC is currently the +# responsibility of the International Earth Rotation Service, +# which is located at the Paris Observatory: +# +# Central Bureau of IERS +# 61, Avenue de l'Observatoire +# 75014 Paris, France. +# +# Leap seconds are announced by the IERS in its Bulletin C +# +# See hpiers.obspm.fr or www.iers.org for more details. +# +# All national laboratories and timing centers use the +# data from the BIPM and the IERS to construct their +# local realizations of UTC. +# +# Although the definition also includes the possibility +# of dropping seconds ("negative" leap seconds), this has +# never been done and is unlikely to be necessary in the +# foreseeable future. +# +# 5. If your system keeps time as the number of seconds since +# some epoch (e.g., NTP timestamps), then the algorithm for +# assigning a UTC time stamp to an event that happens during a positive +# leap second is not well defined. The official name of that leap +# second is 23:59:60, but there is no way of representing that time +# in these systems. +# Many systems of this type effectively stop the system clock for +# one second during the leap second and use a time that is equivalent +# to 23:59:59 UTC twice. For these systems, the corresponding TAI +# timestamp would be obtained by advancing to the next entry in the +# following table when the time equivalent to 23:59:59 UTC +# is used for the second time. Thus the leap second which +# occurred on 30 June 1972 at 23:59:59 UTC would have TAI +# timestamps computed as follows: +# +# ... +# 30 June 1972 23:59:59 (2287785599, first time): TAI= UTC + 10 seconds +# 30 June 1972 23:59:60 (2287785599,second time): TAI= UTC + 11 seconds +# 1 July 1972 00:00:00 (2287785600) TAI= UTC + 11 seconds +# ... +# +# If your system realizes the leap second by repeating 00:00:00 UTC twice +# (this is possible but not usual), then the advance to the next entry +# in the table must occur the second time that a time equivlent to +# 00:00:00 UTC is used. Thus, using the same example as above: +# +# ... +# 30 June 1972 23:59:59 (2287785599): TAI= UTC + 10 seconds +# 30 June 1972 23:59:60 (2287785600, first time): TAI= UTC + 10 seconds +# 1 July 1972 00:00:00 (2287785600,second time): TAI= UTC + 11 seconds +# ... +# +# in both cases the use of timestamps based on TAI produces a smooth +# time scale with no discontinuity in the time interval. +# +# This complexity would not be needed for negative leap seconds (if they +# are ever used). The UTC time would skip 23:59:59 and advance from +# 23:59:58 to 00:00:00 in that case. The TAI offset would decrease by +# 1 second at the same instant. This is a much easier situation to deal +# with, since the difficulty of unambiguously representing the epoch +# during the leap second does not arise. +# +# Questions or comments to: +# Jeff Prillaman +# Time Service Department +# US Naval Observatory +# Washington, DC +# jeffrey.prillaman@usno.navy.mil +# +# Last Update of leap second values: 31 Dec 2015 +# +# The following line shows this last update date in NTP timestamp +# format. This is the date on which the most recent change to +# the leap second data was added to the file. This line can +# be identified by the unique pair of characters in the first two +# columns as shown below. +# +#$ 3660508800 +# +# The data in this file will be updated periodically as new leap +# seconds are announced. In addition to being entered on the line +# above, the update time (in NTP format) will be added to the basic +# file name leap-seconds to form the name leap-seconds.<NTP TIME>. +# In addition, the generic name leap-seconds.list will always point to +# the most recent version of the file. +# +# This update procedure will be performed only when a new leap second +# is announced. +# +# The following entry specifies the expiration date of the data +# in this file in units of seconds since 1900.0. This expiration date +# will be changed at least twice per year whether or not a new leap +# second is announced. These semi-annual changes will be made no +# later than 1 June and 1 December of each year to indicate what +# action (if any) is to be taken on 30 June and 31 December, +# respectively. (These are the customary effective dates for new +# leap seconds.) This expiration date will be identified by a +# unique pair of characters in columns 1 and 2 as shown below. +# In the unlikely event that a leap second is announced with an +# effective date other than 30 June or 31 December, then this +# file will be edited to include that leap second as soon as it is +# announced or at least one month before the effective date +# (whichever is later). +# If an announcement by the IERS specifies that no leap second is +# scheduled, then only the expiration date of the file will +# be advanced to show that the information in the file is still +# current -- the update time stamp, the data and the name of the file +# will not change. +# +# Updated through IERS Bulletin C 50 +# File expires on: 1 Jun 2016 +# +#@ 3673728000 +# +2272060800 10 # 1 Jan 1972 +2287785600 11 # 1 Jul 1972 +2303683200 12 # 1 Jan 1973 +2335219200 13 # 1 Jan 1974 +2366755200 14 # 1 Jan 1975 +2398291200 15 # 1 Jan 1976 +2429913600 16 # 1 Jan 1977 +2461449600 17 # 1 Jan 1978 +2492985600 18 # 1 Jan 1979 +2524521600 19 # 1 Jan 1980 +2571782400 20 # 1 Jul 1981 +2603318400 21 # 1 Jul 1982 +2634854400 22 # 1 Jul 1983 +2698012800 23 # 1 Jul 1985 +2776982400 24 # 1 Jan 1988 +2840140800 25 # 1 Jan 1990 +2871676800 26 # 1 Jan 1991 +2918937600 27 # 1 Jul 1992 +2950473600 28 # 1 Jul 1993 +2982009600 29 # 1 Jul 1994 +3029443200 30 # 1 Jan 1996 +3076704000 31 # 1 Jul 1997 +3124137600 32 # 1 Jan 1999 +3345062400 33 # 1 Jan 2006 +3439756800 34 # 1 Jan 2009 +3550089600 35 # 1 Jul 2012 +3644697600 36 # 1 Jul 2015 +# +# the following special comment contains the +# hash value of the data in this file computed +# use the secure hash algorithm as specified +# by FIPS 180-1. See the files in ~/sha for +# the details of how this hash value is +# computed. Note that the hash computation +# ignores comments and whitespace characters +# in data lines. It includes the NTP values +# of both the last modification time and the +# expiration time of the file, but not the +# white space on those lines. +# the hash line is also ignored in the +# computation. +# +#h 44a44c49 35b22601 a9c7054c 8c56cf57 9b6f6ed5 +# @@ -130,12 +130,21 @@ for _rc_elem in ${files}; do done # Remove the firstboot sentinel, and reboot if it was requested. +# Be a bit paranoid about removing it to handle the common failure +# modes since the consequence of failure can be big. +# Note: this assumes firstboot_sentinel is on / when we have +# a read-only /, or that it is on media that's writable. if [ -e ${firstboot_sentinel} ]; then - rm ${firstboot_sentinel} + [ ${root_rw_mount} = "yes" ] || mount -uw / + chflags -R 0 ${firstboot_sentinel} + rm -rf ${firstboot_sentinel} if [ -e ${firstboot_sentinel}-reboot ]; then - rm ${firstboot_sentinel}-reboot + chflags -R 0 ${firstboot_sentinel}-reboot + rm -rf ${firstboot_sentinel}-reboot + [ ${root_rw_mount} = "yes" ] || mount -ur / kill -INT 1 fi + [ ${root_rw_mount} = "yes" ] || mount -ur / fi echo '' diff --git a/gnu/lib/libgcc/Makefile b/gnu/lib/libgcc/Makefile index 6972146..ad4e0f1 100644 --- a/gnu/lib/libgcc/Makefile +++ b/gnu/lib/libgcc/Makefile @@ -2,6 +2,9 @@ GCCDIR= ${.CURDIR}/../../../contrib/gcc GCCLIB= ${.CURDIR}/../../../contrib/gcclibs +COMPILERRTDIR= ${.CURDIR}/../../../contrib/compiler-rt +UNWINDINCDIR= ${.CURDIR}/../../../contrib/llvm/projects/libunwind/include +UNWINDSRCDIR= ${.CURDIR}/../../../contrib/llvm/projects/libunwind/src SHLIB_NAME= libgcc_s.so.1 SHLIBDIR?= /lib @@ -67,8 +70,37 @@ LIB2ADD = $(LIB2FUNCS_EXTRA) LIB2ADD_ST = $(LIB2FUNCS_STATIC_EXTRA) # Additional sources to handle exceptions; overridden by targets as needed. +.if ${MK_LLVM_LIBUNWIND} != "no" + +.PATH: ${COMPILERRTDIR}/lib/builtins +.PATH: ${UNWINDSRCDIR} +LIB2ADDEH = gcc_personality_v0.c \ + int_util.c \ + Unwind-EHABI.cpp \ + Unwind-sjlj.c \ + UnwindLevel1-gcc-ext.c \ + UnwindLevel1.c \ + UnwindRegistersRestore.S \ + UnwindRegistersSave.S \ + libunwind.cpp + +CFLAGS+= -I${UNWINDINCDIR} -I${.CURDIR} +.if empty(CXXFLAGS:M-std=*) +CXXFLAGS+= -std=c++11 +.endif +CXXFLAGS+= -fno-rtti + +.else # MK_LLVM_LIBUNWIND + +.if ${TARGET_CPUARCH} == "arm" +LIB2ADDEH = unwind-arm.c libunwind.S pr-support.c unwind-c.c +.else LIB2ADDEH = unwind-dw2.c unwind-dw2-fde-glibc.c unwind-sjlj.c gthr-gnat.c \ unwind-c.c +.endif + +.endif # MK_LLVM_LIBUNWIND + LIB2ADDEHSTATIC = $(LIB2ADDEH) LIB2ADDEHSHARED = $(LIB2ADDEH) @@ -116,7 +148,6 @@ CFLAGS.clang+= -fheinous-gnu-extensions LIB1ASMSRC = lib1funcs.asm LIB1ASMFUNCS = _dvmd_tls _bb_init_func -LIB2ADDEH = unwind-arm.c libunwind.S pr-support.c unwind-c.c # Some compilers generate __aeabi_ functions libgcc_s is missing LIBADD+= compiler_rt .endif @@ -160,7 +191,10 @@ LIB2_DIVMOD_FUNCS:= ${LIB2_DIVMOD_FUNCS:S/${sym}//g} .endfor .endif -COMMONHDRS= tm.h tconfig.h options.h unwind.h gthr-default.h +COMMONHDRS= tm.h tconfig.h options.h gthr-default.h +.if ${MK_LLVM_LIBUNWIND} == no +COMMONHDRS+= unwind.h +.endif #----------------------------------------------------------------------- # @@ -170,6 +204,9 @@ HIDE = -fvisibility=hidden -DHIDE_EXPORTS CC_T = ${CC} -c ${CFLAGS} ${HIDE} -fPIC CC_P = ${CC} -c ${CFLAGS} ${HIDE} -p -fPIC CC_S = ${CC} -c ${CFLAGS} ${PICFLAG} -DSHARED +CXX_T = ${CXX} -c ${CXXFLAGS} ${HIDE} -fPIC +CXX_P = ${CXX} -c ${CXXFLAGS} ${HIDE} -p -fPIC +CXX_S = ${CXX} -c ${CXXFLAGS} ${PICFLAG} -DSHARED #----------------------------------------------------------------------- # @@ -284,16 +321,26 @@ EH_OBJS_S = ${LIB2ADDEHSHARED:R:S/$/.So/} EH_CFLAGS = -fexceptions -D__GLIBC__=3 -DElfW=__ElfN SOBJS += ${EH_OBJS_S} -.for _src in ${LIB2ADDEHSTATIC} +.for _src in ${LIB2ADDEHSTATIC:M*.c} ${_src:R:S/$/.o/}: ${_src} ${COMMONHDRS} ${CC_T} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC} ${_src:R:S/$/.po/}: ${_src} ${COMMONHDRS} ${CC_P} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC} .endfor -.for _src in ${LIB2ADDEHSHARED} +.for _src in ${LIB2ADDEHSTATIC:M*.cpp} +${_src:R:S/$/.o/}: ${_src} ${COMMONHDRS} + ${CXX_T} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC} +${_src:R:S/$/.po/}: ${_src} ${COMMONHDRS} + ${CXX_P} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC} +.endfor +.for _src in ${LIB2ADDEHSHARED:M*.c} ${_src:R:S/$/.So/}: ${_src} ${COMMONHDRS} ${CC_S} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC} .endfor +.for _src in ${LIB2ADDEHSHARED:M*.cpp} +${_src:R:S/$/.So/}: ${_src} ${COMMONHDRS} + ${CXX_S} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC} +.endfor #----------------------------------------------------------------------- diff --git a/gnu/usr.bin/binutils/ld/Makefile b/gnu/usr.bin/binutils/ld/Makefile index 5058c0a..5bc3846 100644 --- a/gnu/usr.bin/binutils/ld/Makefile +++ b/gnu/usr.bin/binutils/ld/Makefile @@ -6,7 +6,8 @@ ELF_SCR_EXT= x xbn xc xd xdc xdw xn xr xs xsc xsw xu xw .PATH: ${SRCDIR}/ld -PROG= ld +PROG= ld.bfd +MAN= ld.1 SCRIPTDIR= /usr/libdata/ldscripts SRCS+= ldcref.c \ ldctor.c \ @@ -48,7 +49,7 @@ CLEANFILES+= ldemul-list.h stringify.sed FILES= ${LDSCRIPTS:S|^|ldscripts/|} FILESDIR= ${SCRIPTDIR} -LINKS= ${BINDIR}/ld ${BINDIR}/ld.bfd +LINKS= ${BINDIR}/ld.bfd ${BINDIR}/ld HOST= ${TARGET_TUPLE} LIBSEARCHPATH= \"=/lib\":\"=/usr/lib\" diff --git a/include/limits.h b/include/limits.h index 3910928..a1e1b98 100644 --- a/include/limits.h +++ b/include/limits.h @@ -59,10 +59,12 @@ #define _POSIX_TZNAME_MAX 3 #endif +#if __POSIX_VISIBLE >= 200112 #define BC_BASE_MAX 99 /* max ibase/obase values in bc(1) */ #define BC_DIM_MAX 2048 /* max array elements in bc(1) */ #define BC_SCALE_MAX 99 /* max scale value in bc(1) */ #define BC_STRING_MAX 1000 /* max const string length in bc(1) */ +#define CHARCLASS_NAME_MAX 14 /* max character class name size */ #define COLL_WEIGHTS_MAX 10 /* max weights for order keyword */ #define EXPR_NEST_MAX 32 /* max expressions nested in expr(1) */ #define LINE_MAX 2048 /* max bytes in an input line */ @@ -72,11 +74,14 @@ #define _POSIX2_BC_DIM_MAX 2048 #define _POSIX2_BC_SCALE_MAX 99 #define _POSIX2_BC_STRING_MAX 1000 +#define _POSIX2_CHARCLASS_NAME_MAX 14 +#define _POSIX2_COLL_WEIGHTS_MAX 2 #define _POSIX2_EQUIV_CLASS_MAX 2 #define _POSIX2_EXPR_NEST_MAX 32 #define _POSIX2_LINE_MAX 2048 #define _POSIX2_RE_DUP_MAX 255 #endif +#endif #if __POSIX_VISIBLE >= 199309 #define _POSIX_AIO_LISTIO_MAX 2 @@ -110,8 +115,6 @@ #define _POSIX_TRACE_SYS_MAX 8 #define _POSIX_TRACE_USER_EVENT_MAX 32 #define _POSIX_TTY_NAME_MAX 9 -#define _POSIX2_CHARCLASS_NAME_MAX 14 -#define _POSIX2_COLL_WEIGHTS_MAX 2 #define _POSIX_RE_DUP_MAX _POSIX2_RE_DUP_MAX #endif diff --git a/include/paths.h b/include/paths.h index 89c9fc9..af18c26 100644 --- a/include/paths.h +++ b/include/paths.h @@ -36,7 +36,7 @@ #include <sys/cdefs.h> /* Default search path. */ -#define _PATH_DEFPATH "/usr/bin:/bin" +#define _PATH_DEFPATH "/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin" /* All standard utilities path. */ #define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin" /* Locate system binaries. */ @@ -108,7 +108,7 @@ __END_DECLS #ifdef RESCUE #undef _PATH_DEFPATH -#define _PATH_DEFPATH "/rescue:/usr/bin:/bin" +#define _PATH_DEFPATH "/rescue:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin" #undef _PATH_STDPATH #define _PATH_STDPATH "/rescue:/usr/bin:/bin:/usr/sbin:/sbin" #undef _PATH_SYSPATH diff --git a/lib/csu/arm/Makefile b/lib/csu/arm/Makefile index 9747619..1b3a6f8 100644 --- a/lib/csu/arm/Makefile +++ b/lib/csu/arm/Makefile @@ -7,6 +7,7 @@ OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= Scrt1.o gcrt1.o CFLAGS+= -I${.CURDIR}/../common \ -I${.CURDIR}/../../libc/include +STATIC_CFLAGS+= -mlong-calls FILES= ${OBJS} FILESMODE= ${LIBMODE} @@ -23,14 +24,14 @@ CLEANFILES+= crt1.s gcrt1.s Scrt1.s # directly compiled to .o files. crt1.s: crt1.c - ${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c + ${CC} ${CFLAGS} ${STATIC_CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c sed ${SED_FIX_NOTE} ${.TARGET} crt1.o: crt1.s ${CC} ${ACFLAGS} -c -o ${.TARGET} crt1.s gcrt1.s: crt1.c - ${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c + ${CC} ${CFLAGS} ${STATIC_CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c sed ${SED_FIX_NOTE} ${.TARGET} gcrt1.o: gcrt1.s diff --git a/lib/libc/gen/exec.3 b/lib/libc/gen/exec.3 index c9d32b4..0805c62 100644 --- a/lib/libc/gen/exec.3 +++ b/lib/libc/gen/exec.3 @@ -28,7 +28,7 @@ .\" @(#)exec.3 8.3 (Berkeley) 1/24/94 .\" $FreeBSD$ .\" -.Dd December 12, 2015 +.Dd January 5, 2016 .Dt EXEC 3 .Os .Sh NAME @@ -161,7 +161,7 @@ the default path is set according to the definition in .In paths.h , which is set to -.Dq Ev /usr/bin:/bin . +.Dq Ev /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin . For .Fn execvP , the search path is specified as an argument to the function. diff --git a/lib/libc/gen/posix_spawn.3 b/lib/libc/gen/posix_spawn.3 index 2c9131b..ebbf05a 100644 --- a/lib/libc/gen/posix_spawn.3 +++ b/lib/libc/gen/posix_spawn.3 @@ -34,7 +34,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 17, 2011 +.Dd January 5, 2016 .Dt POSIX_SPAWN 3 .Os .Sh NAME @@ -126,7 +126,7 @@ the default path is set according to the definition in .In paths.h , which is set to -.Dq Ev /usr/bin:/bin . +.Dq Ev /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin . .Pp If .Fa file_actions diff --git a/lib/libc/rpc/rpc_soc.c b/lib/libc/rpc/rpc_soc.c index 11fc803..64516a9 100644 --- a/lib/libc/rpc/rpc_soc.c +++ b/lib/libc/rpc/rpc_soc.c @@ -483,7 +483,7 @@ svcunix_create(int sock, u_int sendsize, u_int recvsize, char *path) break; } if (nconf == NULL) - return(xprt); + goto done; if ((sock = __rpc_nconf2fd(nconf)) < 0) goto done; diff --git a/lib/libc/rpc/rpcb_clnt.c b/lib/libc/rpc/rpcb_clnt.c index 49300ed..8477505 100644 --- a/lib/libc/rpc/rpcb_clnt.c +++ b/lib/libc/rpc/rpcb_clnt.c @@ -661,11 +661,11 @@ __rpcbind_is_up(void) strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) break; } + endnetconfig(localhandle); + if (nconf == NULL) return (FALSE); - endnetconfig(localhandle); - memset(&sun, 0, sizeof sun); sock = _socket(AF_LOCAL, SOCK_STREAM, 0); if (sock < 0) diff --git a/lib/libc/rpc/rpcb_prot.c b/lib/libc/rpc/rpcb_prot.c index b793eca..2b87f34 100644 --- a/lib/libc/rpc/rpcb_prot.c +++ b/lib/libc/rpc/rpcb_prot.c @@ -207,14 +207,14 @@ xdr_rpcb_entry_list_ptr(XDR *xdrs, rpcb_entry_list_ptr *rp) * the case of freeing we must remember the next object * before we free the current object ... */ - if (freeing) + if (freeing && *rp) next = (*rp)->rpcb_entry_next; if (! xdr_reference(xdrs, (caddr_t *)rp, (u_int)sizeof (rpcb_entry_list), (xdrproc_t)xdr_rpcb_entry)) { return (FALSE); } - if (freeing && *rp) { + if (freeing) { next_copy = next; rp = &next_copy; /* diff --git a/lib/libc/sys/futimens.c b/lib/libc/sys/futimens.c index 2014cc5..59fb37f 100644 --- a/lib/libc/sys/futimens.c +++ b/lib/libc/sys/futimens.c @@ -42,8 +42,11 @@ futimens(int fd, const struct timespec times[2]) { struct timeval now, tv[2], *tvp; struct stat sb; + int osreldate; - if (__getosreldate() >= 1100056) + osreldate = __getosreldate(); + if (osreldate >= 1100056 || + (osreldate >= 1002506 && osreldate < 1100000)) return (__sys_futimens(fd, times)); if (times == NULL || (times[0].tv_nsec == UTIME_NOW && diff --git a/lib/libc/sys/sendfile.2 b/lib/libc/sys/sendfile.2 index b363382..2b52dd9 100644 --- a/lib/libc/sys/sendfile.2 +++ b/lib/libc/sys/sendfile.2 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 7, 2010 +.Dd January 7, 2016 .Dt SENDFILE 2 .Os .Sh NAME @@ -46,7 +46,7 @@ The .Fn sendfile system call -sends a regular file specified by descriptor +sends a regular file or shared memory object specified by descriptor .Fa fd out a stream socket specified by descriptor .Fa s . @@ -101,32 +101,55 @@ the system will write the total number of bytes sent on the socket to the variable pointed to by .Fa sbytes . .Pp -The +The least significant 16 bits of .Fa flags argument is a bitmap of these values: -.Bl -item -offset indent -.It -.Dv SF_NODISKIO . -This flag causes any -.Fn sendfile -call which would block on disk I/O to instead -return -.Er EBUSY . -Busy servers may benefit by transferring requests that would -block to a separate I/O worker thread. -.It -.Dv SF_MNOWAIT . -Do not wait for some kernel resource to become available, -in particular, -.Vt mbuf -and -.Vt sf_buf . -The flag does not make the -.Fn sendfile -syscall truly non-blocking, since other resources are still allocated -in a blocking fashion. -.It -.Dv SF_SYNC . +.Bl -tag -offset indent +.It Dv SF_NODISKIO +This flag causes +.Nm +to return +.Er EBUSY +instead of blocking when a busy page is encountered. +This rare situation can happen if some other process is now working +with the same region of the file. +It is advised to retry the operation after a short period. +.Pp +Note that in older +.Fx +versions the +.Dv SF_NODISKIO +had slightly different notion. +The flag prevented +.Nm +to run I/O operations in case if an invalid (not cached) page is encountered, +thus avoiding blocking on I/O. +Starting with +.Fx 11 +.Nm +sending files off the +.Xr ffs 7 +filesystem doesn't block on I/O +(see +.Sx IMPLEMENTATION NOTES +), so the condition no longer applies. +However, it is safe if an application utilizes +.Dv SF_NODISKIO +and on +.Er EBUSY +performs the same action as it did in +older +.Fx +versions, e.g. +.Xr aio_read 2, +.Xr read 2 +or +.Nm +in a different context. +.It Dv SF_NOCACHE +The data sent to socket will not be cached by the virtual memory system, +and will be freed directly to the pool of free pages. +.It Dv SF_SYNC .Nm sleeps until the network stack no longer references the VM pages of the file, making subsequent modifications to it safe. @@ -134,6 +157,22 @@ Please note that this is not a guarantee that the data has actually been sent. .El .Pp +The most significant 16 bits of +.Fa flags +specify amount of pages that +.Nm +may read ahead when reading the file. +A macro +.Fn SF_FLAGS +is provided to combine readahead amount and flags. +Example shows specifing readahead of 16 pages and +.Dv SF_NOCACHE +flag: +.Pp +.Bd -literal -offset indent -compact + SF_FLAGS(16, SF_NOCACHE) +.Ed +.Pp When using a socket marked for non-blocking I/O, .Fn sendfile may send fewer bytes than requested. @@ -149,6 +188,18 @@ The .Fx implementation of .Fn sendfile +doesn't block on disk I/O when it sends a file off the +.Xr ffs 7 +filesystem. +The syscall returns success before the actual I/O completes, and data +is put into the socket later unattended. +However, the order of data in the socket is preserved, so it is safe +to do further writes to the socket. +.Pp +The +.Fx +implementation of +.Fn sendfile is "zero-copy", meaning that it has been optimized so that copying of the file data is avoided. .Sh TUNING On some architectures, this system call internally uses a special @@ -232,12 +283,10 @@ The argument is not a valid socket descriptor. .It Bq Er EBUSY -Completing the entire transfer would have required disk I/O, so -it was aborted. -Partial data may have been sent. -(This error can only occur when +A busy page was encountered and .Dv SF_NODISKIO -is specified.) +had been specified. +Partial data may have been sent. .It Bq Er EFAULT An invalid address was specified for an argument. .It Bq Er EINTR @@ -310,9 +359,19 @@ first appeared in .Fx 3.0 . This manual page first appeared in .Fx 3.1 . +In +.Fx 10 +support for sending shared memory descriptors had been introduced. +In +.Fx 11 +a non-blocking implementation had been introduced. .Sh AUTHORS -The +The initial implementation of .Fn sendfile system call and this manual page were written by .An David G. Lawrence Aq Mt dg@dglawrence.com . +The +.Fx 11 +implementation was written by +.An Gleb Smirnoff Aq Mt glebius@FreeBSD.org . diff --git a/lib/libc/sys/utimensat.2 b/lib/libc/sys/utimensat.2 index 0f397c6..57ad904 100644 --- a/lib/libc/sys/utimensat.2 +++ b/lib/libc/sys/utimensat.2 @@ -31,7 +31,7 @@ .\" @(#)utimes.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd January 23, 2015 +.Dd January 12, 2016 .Dt UTIMENSAT 2 .Os .Sh NAME @@ -289,4 +289,4 @@ The and .Fn utimensat system calls appeared in -.Fx 11.0 . +.Fx 10.3 . diff --git a/lib/libc/sys/utimensat.c b/lib/libc/sys/utimensat.c index 67d19cb..a1c3c21 100644 --- a/lib/libc/sys/utimensat.c +++ b/lib/libc/sys/utimensat.c @@ -42,8 +42,11 @@ utimensat(int fd, const char *path, const struct timespec times[2], int flag) { struct timeval now, tv[2], *tvp; struct stat sb; + int osreldate; - if (__getosreldate() >= 1100056) + osreldate = __getosreldate(); + if (osreldate >= 1100056 || + (osreldate >= 1002506 && osreldate < 1100000)) return (__sys_utimensat(fd, path, times, flag)); if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0) { diff --git a/lib/libdpv/util.h b/lib/libdpv/util.h index 7bb3b18..d746cb6 100644 --- a/lib/libdpv/util.h +++ b/lib/libdpv/util.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013-2014 Devin Teske <dteske@FreeBSD.org> + * Copyright (c) 2013-2016 Devin Teske <dteske@FreeBSD.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,7 @@ #define PATH_SHELL "/bin/sh" #endif -#define CMDBUFMAX 4096 +#define CMDBUFMAX 65536 __BEGIN_DECLS int shell_spawn_pipecmd(const char *_cmd, const char *_label, pid_t *_pid); diff --git a/lib/libgssapi/gss_release_oid_set.c b/lib/libgssapi/gss_release_oid_set.c index bedb90b..a46853a 100644 --- a/lib/libgssapi/gss_release_oid_set.c +++ b/lib/libgssapi/gss_release_oid_set.c @@ -32,15 +32,25 @@ OM_uint32 gss_release_oid_set(OM_uint32 *minor_status, - gss_OID_set *set) + gss_OID_set *setp) { + gss_OID_set set; + gss_OID o; + size_t i; *minor_status = 0; - if (set && *set) { - if ((*set)->elements) - free((*set)->elements); - free(*set); - *set = GSS_C_NO_OID_SET; + if (setp) { + set = *setp; + if (set) { + for (i = 0; i < set->count; i++) { + o = &set->elements[i]; + if (o->elements) + free(o->elements); + } + free(set->elements); + free(set); + *setp = GSS_C_NO_OID_SET; + } } return (GSS_S_COMPLETE); } diff --git a/lib/libmd/Makefile.depend b/lib/libmd/Makefile.depend index 00038a0..e3acaaf 100644 --- a/lib/libmd/Makefile.depend +++ b/lib/libmd/Makefile.depend @@ -33,6 +33,9 @@ sha1hl.po: sha1hl.c sha256hl.So: sha256hl.c sha256hl.o: sha256hl.c sha256hl.po: sha256hl.c +sha384hl.So: sha384hl.c +sha384hl.o: sha384hl.c +sha384hl.po: sha384hl.c sha512hl.So: sha512hl.c sha512hl.o: sha512hl.c sha512hl.po: sha512hl.c diff --git a/lib/libnv/tests/dnv_tests.cc b/lib/libnv/tests/dnv_tests.cc index fe80d00..a21a91d 100644 --- a/lib/libnv/tests/dnv_tests.cc +++ b/lib/libnv/tests/dnv_tests.cc @@ -27,6 +27,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/types.h> #include <sys/dnv.h> #include <sys/nv.h> diff --git a/lib/libnv/tests/nv_array_tests.cc b/lib/libnv/tests/nv_array_tests.cc index 3de0ee8..f6ffcef 100644 --- a/lib/libnv/tests/nv_array_tests.cc +++ b/lib/libnv/tests/nv_array_tests.cc @@ -27,8 +27,9 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include <sys/nv.h> +#include <sys/param.h> #include <sys/types.h> +#include <sys/nv.h> #include <sys/socket.h> #include <atf-c++.hpp> @@ -50,7 +51,7 @@ ATF_TEST_CASE_BODY(nvlist_bool_array__basic) const bool *const_result; bool *result; nvlist_t *nvl; - size_t nitems; + size_t num_items; unsigned int i; const char *key; @@ -69,16 +70,16 @@ ATF_TEST_CASE_BODY(nvlist_bool_array__basic) ATF_REQUIRE(nvlist_exists_bool_array(nvl, key)); ATF_REQUIRE(nvlist_exists_bool_array(nvl, "nvl/bool")); - const_result = nvlist_get_bool_array(nvl, key, &nitems); - ATF_REQUIRE_EQ(nitems, 16); + const_result = nvlist_get_bool_array(nvl, key, &num_items); + ATF_REQUIRE_EQ(num_items, 16); ATF_REQUIRE(const_result != NULL); - for (i = 0; i < nitems; i++) + for (i = 0; i < num_items; i++) ATF_REQUIRE_EQ(const_result[i], testbool[i]); - result = nvlist_take_bool_array(nvl, key, &nitems); - ATF_REQUIRE_EQ(nitems, 16); + result = nvlist_take_bool_array(nvl, key, &num_items); + ATF_REQUIRE_EQ(num_items, 16); ATF_REQUIRE(const_result != NULL); - for (i = 0; i < nitems; i++) + for (i = 0; i < num_items; i++) ATF_REQUIRE_EQ(result[i], testbool[i]); ATF_REQUIRE(!nvlist_exists_bool_array(nvl, key)); @@ -95,10 +96,10 @@ ATF_TEST_CASE_BODY(nvlist_string_array__basic) const char * const *const_result; char **result; nvlist_t *nvl; - size_t nitems; + size_t num_items; unsigned int i; const char *key; - const char *string[8] = { "a", "b", "kot", "foo", + const char *string_arr[8] = { "a", "b", "kot", "foo", "tests", "nice test", "", "abcdef" }; key = "nvl/string"; @@ -107,32 +108,33 @@ ATF_TEST_CASE_BODY(nvlist_string_array__basic) ATF_REQUIRE(nvlist_empty(nvl)); ATF_REQUIRE(!nvlist_exists_string_array(nvl, key)); - nvlist_add_string_array(nvl, key, string, 8); + nvlist_add_string_array(nvl, key, string_arr, nitems(string_arr)); ATF_REQUIRE_EQ(nvlist_error(nvl), 0); ATF_REQUIRE(!nvlist_empty(nvl)); ATF_REQUIRE(nvlist_exists_string_array(nvl, key)); ATF_REQUIRE(nvlist_exists_string_array(nvl, "nvl/string")); - const_result = nvlist_get_string_array(nvl, key, &nitems); + const_result = nvlist_get_string_array(nvl, key, &num_items); ATF_REQUIRE(!nvlist_empty(nvl)); ATF_REQUIRE(const_result != NULL); - ATF_REQUIRE(nitems == 8); - for (i = 0; i < nitems; i++) { - if (string[i] != NULL) { - ATF_REQUIRE(strcmp(const_result[i], string[i]) == 0); + ATF_REQUIRE(num_items == nitems(string_arr)); + for (i = 0; i < num_items; i++) { + if (string_arr[i] != NULL) { + ATF_REQUIRE(strcmp(const_result[i], + string_arr[i]) == 0); } else { - ATF_REQUIRE(const_result[i] == string[i]); + ATF_REQUIRE(const_result[i] == string_arr[i]); } } - result = nvlist_take_string_array(nvl, key, &nitems); + result = nvlist_take_string_array(nvl, key, &num_items); ATF_REQUIRE(result != NULL); - ATF_REQUIRE_EQ(nitems, 8); - for (i = 0; i < nitems; i++) { - if (string[i] != NULL) { - ATF_REQUIRE_EQ(strcmp(result[i], string[i]), 0); + ATF_REQUIRE_EQ(num_items, nitems(string_arr)); + for (i = 0; i < num_items; i++) { + if (string_arr[i] != NULL) { + ATF_REQUIRE_EQ(strcmp(result[i], string_arr[i]), 0); } else { - ATF_REQUIRE_EQ(result[i], string[i]); + ATF_REQUIRE_EQ(result[i], string_arr[i]); } } @@ -140,7 +142,7 @@ ATF_TEST_CASE_BODY(nvlist_string_array__basic) ATF_REQUIRE(nvlist_empty(nvl)); ATF_REQUIRE_EQ(nvlist_error(nvl), 0); - for (i = 0; i < 8; i++) + for (i = 0; i < num_items; i++) free(result[i]); free(result); nvlist_destroy(nvl); @@ -152,11 +154,11 @@ ATF_TEST_CASE_BODY(nvlist_descriptor_array__basic) int fd[32], *result; const int *const_result; nvlist_t *nvl; - size_t nitems; + size_t num_items; unsigned int i; const char *key; - for (i = 0; i < 32; i++) { + for (i = 0; i < nitems(fd); i++) { fd[i] = dup(STDERR_FILENO); ATF_REQUIRE(fd_is_valid(fd[i])); } @@ -167,26 +169,26 @@ ATF_TEST_CASE_BODY(nvlist_descriptor_array__basic) ATF_REQUIRE(nvlist_empty(nvl)); ATF_REQUIRE(!nvlist_exists_descriptor_array(nvl, key)); - nvlist_add_descriptor_array(nvl, key, fd, 32); + nvlist_add_descriptor_array(nvl, key, fd, nitems(fd)); ATF_REQUIRE_EQ(nvlist_error(nvl), 0); ATF_REQUIRE(!nvlist_empty(nvl)); ATF_REQUIRE(nvlist_exists_descriptor_array(nvl, key)); ATF_REQUIRE(nvlist_exists_descriptor_array(nvl, "nvl/descriptor")); - const_result = nvlist_get_descriptor_array(nvl, key, &nitems); + const_result = nvlist_get_descriptor_array(nvl, key, &num_items); ATF_REQUIRE(!nvlist_empty(nvl)); ATF_REQUIRE(const_result != NULL); - ATF_REQUIRE(nitems == 32); - for (i = 0; i < nitems; i++) { + ATF_REQUIRE(num_items == nitems(fd)); + for (i = 0; i < num_items; i++) { ATF_REQUIRE(fd_is_valid(const_result[i])); if (i > 0) ATF_REQUIRE(const_result[i] != const_result[i - 1]); } - result = nvlist_take_descriptor_array(nvl, key, &nitems); + result = nvlist_take_descriptor_array(nvl, key, &num_items); ATF_REQUIRE(result != NULL); - ATF_REQUIRE_EQ(nitems, 32); - for (i = 0; i < nitems; i++) { + ATF_REQUIRE_EQ(num_items, nitems(fd)); + for (i = 0; i < num_items; i++) { ATF_REQUIRE(fd_is_valid(result[i])); if (i > 0) ATF_REQUIRE(const_result[i] != const_result[i - 1]); @@ -196,7 +198,7 @@ ATF_TEST_CASE_BODY(nvlist_descriptor_array__basic) ATF_REQUIRE(nvlist_empty(nvl)); ATF_REQUIRE_EQ(nvlist_error(nvl), 0); - for (i = 0; i < nitems; i++) { + for (i = 0; i < num_items; i++) { close(result[i]); close(fd[i]); } @@ -210,7 +212,7 @@ ATF_TEST_CASE_BODY(nvlist_number_array__basic) const uint64_t *const_result; uint64_t *result; nvlist_t *nvl; - size_t nitems; + size_t num_items; unsigned int i; const char *key; const uint64_t number[8] = { 0, UINT_MAX, 7, 123, 90, @@ -222,23 +224,23 @@ ATF_TEST_CASE_BODY(nvlist_number_array__basic) ATF_REQUIRE(nvlist_empty(nvl)); ATF_REQUIRE(!nvlist_exists_string_array(nvl, key)); - nvlist_add_number_array(nvl, key, number, 8); + nvlist_add_number_array(nvl, key, number, nitems(number)); ATF_REQUIRE_EQ(nvlist_error(nvl), 0); ATF_REQUIRE(!nvlist_empty(nvl)); ATF_REQUIRE(nvlist_exists_number_array(nvl, key)); ATF_REQUIRE(nvlist_exists_number_array(nvl, "nvl/number")); - const_result = nvlist_get_number_array(nvl, key, &nitems); + const_result = nvlist_get_number_array(nvl, key, &num_items); ATF_REQUIRE(!nvlist_empty(nvl)); ATF_REQUIRE(const_result != NULL); - ATF_REQUIRE(nitems == 8); - for (i = 0; i < nitems; i++) + ATF_REQUIRE(num_items == nitems(number)); + for (i = 0; i < num_items; i++) ATF_REQUIRE_EQ(const_result[i], number[i]); - result = nvlist_take_number_array(nvl, key, &nitems); + result = nvlist_take_number_array(nvl, key, &num_items); ATF_REQUIRE(result != NULL); - ATF_REQUIRE_EQ(nitems, 8); - for (i = 0; i < nitems; i++) + ATF_REQUIRE_EQ(num_items, nitems(number)); + for (i = 0; i < num_items; i++) ATF_REQUIRE_EQ(result[i], number[i]); ATF_REQUIRE(!nvlist_exists_string_array(nvl, key)); @@ -256,7 +258,7 @@ ATF_TEST_CASE_BODY(nvlist_nvlist_array__basic) const nvlist_t * const *const_result; nvlist_t **result; nvlist_t *nvl; - size_t nitems; + size_t num_items; unsigned int i; const char *somestr[8] = { "a", "b", "c", "d", "e", "f", "g", "h" }; const char *key; @@ -282,14 +284,14 @@ ATF_TEST_CASE_BODY(nvlist_nvlist_array__basic) ATF_REQUIRE(nvlist_exists_nvlist_array(nvl, key)); ATF_REQUIRE(nvlist_exists_nvlist_array(nvl, "nvl/nvlist")); - const_result = nvlist_get_nvlist_array(nvl, key, &nitems); + const_result = nvlist_get_nvlist_array(nvl, key, &num_items); ATF_REQUIRE(!nvlist_empty(nvl)); ATF_REQUIRE(const_result != NULL); - ATF_REQUIRE(nitems == 8); + ATF_REQUIRE(num_items == nitems(testnvl)); - for (i = 0; i < nitems; i++) { + for (i = 0; i < num_items; i++) { ATF_REQUIRE_EQ(nvlist_error(const_result[i]), 0); - if (i < nitems - 1) { + if (i < num_items - 1) { ATF_REQUIRE(nvlist_get_array_next(const_result[i]) == const_result[i + 1]); } else { @@ -304,10 +306,10 @@ ATF_TEST_CASE_BODY(nvlist_nvlist_array__basic) "nvl/string"), somestr[i]) == 0); } - result = nvlist_take_nvlist_array(nvl, key, &nitems); + result = nvlist_take_nvlist_array(nvl, key, &num_items); ATF_REQUIRE(result != NULL); - ATF_REQUIRE_EQ(nitems, 8); - for (i = 0; i < nitems; i++) { + ATF_REQUIRE_EQ(num_items, 8); + for (i = 0; i < num_items; i++) { ATF_REQUIRE_EQ(nvlist_error(result[i]), 0); ATF_REQUIRE(nvlist_get_array_next(result[i]) == NULL); ATF_REQUIRE(nvlist_get_array_next(const_result[i]) == NULL); @@ -335,19 +337,19 @@ ATF_TEST_CASE_BODY(nvlist_clone_array) const nvlist_t *nvl; bool testbool[16]; int testfd[16]; - size_t i, nitems; - const char *string[8] = { "a", "b", "kot", "foo", + size_t i, num_items; + const char *string_arr[8] = { "a", "b", "kot", "foo", "tests", "nice test", "", "abcdef" }; const char *somestr[8] = { "a", "b", "c", "d", "e", "f", "g", "h" }; const uint64_t number[8] = { 0, UINT_MAX, 7, 123, 90, 100000, 8, 1 }; - for (i = 0; i < 16; i++) { + for (i = 0; i < nitems(testfd); i++) { testbool[i] = (i % 2 == 0); testfd[i] = dup(STDERR_FILENO); ATF_REQUIRE(fd_is_valid(testfd[i])); } - for (i = 0; i < 8; i++) { + for (i = 0; i < nitems(testnvl); i++) { testnvl[i] = nvlist_create(0); ATF_REQUIRE(nvlist_error(testnvl[i]) == 0); nvlist_add_string(testnvl[i], "nvl/nvl/teststr", somestr[i]); @@ -358,28 +360,30 @@ ATF_TEST_CASE_BODY(nvlist_clone_array) ATF_REQUIRE(nvlist_error(src) == 0); ATF_REQUIRE(!nvlist_exists_bool_array(src, "nvl/bool")); - nvlist_add_bool_array(src, "nvl/bool", testbool, 16); + nvlist_add_bool_array(src, "nvl/bool", testbool, nitems(testbool)); ATF_REQUIRE_EQ(nvlist_error(src), 0); ATF_REQUIRE(nvlist_exists_bool_array(src, "nvl/bool")); ATF_REQUIRE(!nvlist_exists_string_array(src, "nvl/string")); - nvlist_add_string_array(src, "nvl/string", string, 8); + nvlist_add_string_array(src, "nvl/string", string_arr, + nitems(string_arr)); ATF_REQUIRE_EQ(nvlist_error(src), 0); ATF_REQUIRE(nvlist_exists_string_array(src, "nvl/string")); ATF_REQUIRE(!nvlist_exists_descriptor_array(src, "nvl/fd")); - nvlist_add_descriptor_array(src, "nvl/fd", testfd, 16); + nvlist_add_descriptor_array(src, "nvl/fd", testfd, nitems(testfd)); ATF_REQUIRE_EQ(nvlist_error(src), 0); ATF_REQUIRE(nvlist_exists_descriptor_array(src, "nvl/fd")); ATF_REQUIRE(!nvlist_exists_number_array(src, "nvl/number")); - nvlist_add_number_array(src, "nvl/number", number, 8); + nvlist_add_number_array(src, "nvl/number", number, + nitems(number)); ATF_REQUIRE_EQ(nvlist_error(src), 0); ATF_REQUIRE(nvlist_exists_number_array(src, "nvl/number")); ATF_REQUIRE(!nvlist_exists_nvlist_array(src, "nvl/array")); nvlist_add_nvlist_array(src, "nvl/array", - (const nvlist_t * const *)testnvl, 8); + (const nvlist_t * const *)testnvl, nitems(testnvl)); ATF_REQUIRE_EQ(nvlist_error(src), 0); ATF_REQUIRE(nvlist_exists_nvlist_array(src, "nvl/array")); @@ -387,62 +391,62 @@ ATF_TEST_CASE_BODY(nvlist_clone_array) ATF_REQUIRE(dst != NULL); ATF_REQUIRE(nvlist_exists_bool_array(dst, "nvl/bool")); - (void) nvlist_get_bool_array(dst, "nvl/bool", &nitems); - ATF_REQUIRE_EQ(nitems, 16); - for (i = 0; i < nitems; i++) { + (void) nvlist_get_bool_array(dst, "nvl/bool", &num_items); + ATF_REQUIRE_EQ(num_items, nitems(testbool)); + for (i = 0; i < num_items; i++) { ATF_REQUIRE( - nvlist_get_bool_array(dst, "nvl/bool", &nitems)[i] == - nvlist_get_bool_array(src, "nvl/bool", &nitems)[i]); + nvlist_get_bool_array(dst, "nvl/bool", &num_items)[i] == + nvlist_get_bool_array(src, "nvl/bool", &num_items)[i]); } ATF_REQUIRE(nvlist_exists_string_array(dst, "nvl/string")); - (void) nvlist_get_string_array(dst, "nvl/string", &nitems); - ATF_REQUIRE_EQ(nitems, 8); - for (i = 0; i < nitems; i++) { + (void) nvlist_get_string_array(dst, "nvl/string", &num_items); + ATF_REQUIRE_EQ(num_items, nitems(string_arr)); + for (i = 0; i < num_items; i++) { if (nvlist_get_string_array(dst, "nvl/string", - &nitems)[i] == NULL) { + &num_items)[i] == NULL) { ATF_REQUIRE(nvlist_get_string_array(dst, "nvl/string", - &nitems)[i] == nvlist_get_string_array(src, - "nvl/string", &nitems)[i]); + &num_items)[i] == nvlist_get_string_array(src, + "nvl/string", &num_items)[i]); } else { ATF_REQUIRE(strcmp(nvlist_get_string_array(dst, - "nvl/string", &nitems)[i], nvlist_get_string_array( - src, "nvl/string", &nitems)[i]) == 0); + "nvl/string", &num_items)[i], nvlist_get_string_array( + src, "nvl/string", &num_items)[i]) == 0); } } ATF_REQUIRE(nvlist_exists_descriptor_array(dst, "nvl/fd")); - (void) nvlist_get_descriptor_array(dst, "nvl/fd", &nitems); - ATF_REQUIRE_EQ(nitems, 16); - for (i = 0; i < nitems; i++) { + (void) nvlist_get_descriptor_array(dst, "nvl/fd", &num_items); + ATF_REQUIRE_EQ(num_items, nitems(testfd)); + for (i = 0; i < num_items; i++) { ATF_REQUIRE(fd_is_valid( - nvlist_get_descriptor_array(dst, "nvl/fd", &nitems)[i])); + nvlist_get_descriptor_array(dst, "nvl/fd", &num_items)[i])); } ATF_REQUIRE(nvlist_exists_number_array(dst, "nvl/number")); - (void) nvlist_get_number_array(dst, "nvl/number", &nitems); - ATF_REQUIRE_EQ(nitems, 8); + (void) nvlist_get_number_array(dst, "nvl/number", &num_items); + ATF_REQUIRE_EQ(num_items, nitems(number)); - for (i = 0; i < nitems; i++) { + for (i = 0; i < num_items; i++) { ATF_REQUIRE( - nvlist_get_number_array(dst, "nvl/number", &nitems)[i] == - nvlist_get_number_array(src, "nvl/number", &nitems)[i]); + nvlist_get_number_array(dst, "nvl/number", &num_items)[i] == + nvlist_get_number_array(src, "nvl/number", &num_items)[i]); } ATF_REQUIRE(nvlist_exists_nvlist_array(dst, "nvl/array")); - (void) nvlist_get_nvlist_array(dst, "nvl/array", &nitems); - ATF_REQUIRE_EQ(nitems, 8); - for (i = 0; i < nitems; i++) { - nvl = nvlist_get_nvlist_array(dst, "nvl/array", &nitems)[i]; + (void) nvlist_get_nvlist_array(dst, "nvl/array", &num_items); + ATF_REQUIRE_EQ(num_items, nitems(testnvl)); + for (i = 0; i < num_items; i++) { + nvl = nvlist_get_nvlist_array(dst, "nvl/array", &num_items)[i]; ATF_REQUIRE(nvlist_exists_string(nvl, "nvl/nvl/teststr")); ATF_REQUIRE(strcmp(nvlist_get_string(nvl, "nvl/nvl/teststr"), somestr[i]) == 0); } - for (i = 0; i < 16; i++) { + for (i = 0; i < nitems(testfd); i++) { close(testfd[i]); - if (i < 8) { - nvlist_destroy(testnvl[i]); - } + } + for (i = 0; i < nitems(testnvl); i++) { + nvlist_destroy(testnvl[i]); } nvlist_destroy(src); nvlist_destroy(dst); @@ -454,7 +458,7 @@ ATF_TEST_CASE_BODY(nvlist_bool_array__move) bool *testbool; const bool *const_result; nvlist_t *nvl; - size_t nitems, count; + size_t num_items, count; unsigned int i; const char *key; @@ -475,11 +479,11 @@ ATF_TEST_CASE_BODY(nvlist_bool_array__move) ATF_REQUIRE(!nvlist_empty(nvl)); ATF_REQUIRE(nvlist_exists_bool_array(nvl, key)); - const_result = nvlist_get_bool_array(nvl, key, &nitems); - ATF_REQUIRE_EQ(nitems, count); + const_result = nvlist_get_bool_array(nvl, key, &num_items); + ATF_REQUIRE_EQ(num_items, count); ATF_REQUIRE(const_result != NULL); ATF_REQUIRE(const_result == testbool); - for (i = 0; i < nitems; i++) + for (i = 0; i < num_items; i++) ATF_REQUIRE_EQ(const_result[i], (i % 2 == 0)); nvlist_destroy(nvl); @@ -491,7 +495,7 @@ ATF_TEST_CASE_BODY(nvlist_string_array__move) char **teststr; const char * const *const_result; nvlist_t *nvl; - size_t nitems, count; + size_t num_items, count; unsigned int i; const char *key; @@ -516,11 +520,11 @@ ATF_TEST_CASE_BODY(nvlist_string_array__move) ATF_REQUIRE(!nvlist_empty(nvl)); ATF_REQUIRE(nvlist_exists_string_array(nvl, key)); - const_result = nvlist_get_string_array(nvl, key, &nitems); - ATF_REQUIRE_EQ(nitems, count); + const_result = nvlist_get_string_array(nvl, key, &num_items); + ATF_REQUIRE_EQ(num_items, count); ATF_REQUIRE(const_result != NULL); ATF_REQUIRE((intptr_t)const_result == (intptr_t)teststr); - for (i = 0; i < nitems; i++) { + for (i = 0; i < num_items; i++) { ATF_REQUIRE_EQ(const_result[i][0], (char)('a' + i)); ATF_REQUIRE_EQ(const_result[i][1], '\0'); } @@ -534,7 +538,7 @@ ATF_TEST_CASE_BODY(nvlist_nvlist_array__move) nvlist **testnv; const nvlist * const *const_result; nvlist_t *nvl; - size_t nitems, count; + size_t num_items, count; unsigned int i; const char *key; @@ -557,14 +561,14 @@ ATF_TEST_CASE_BODY(nvlist_nvlist_array__move) ATF_REQUIRE(!nvlist_empty(nvl)); ATF_REQUIRE(nvlist_exists_nvlist_array(nvl, key)); - const_result = nvlist_get_nvlist_array(nvl, key, &nitems); - ATF_REQUIRE_EQ(nitems, count); + const_result = nvlist_get_nvlist_array(nvl, key, &num_items); + ATF_REQUIRE_EQ(num_items, count); ATF_REQUIRE(const_result != NULL); ATF_REQUIRE((intptr_t)const_result == (intptr_t)testnv); - for (i = 0; i < nitems; i++) { + for (i = 0; i < num_items; i++) { ATF_REQUIRE_EQ(nvlist_error(const_result[i]), 0); ATF_REQUIRE(nvlist_empty(const_result[i])); - if (i < nitems - 1) { + if (i < num_items - 1) { ATF_REQUIRE(nvlist_get_array_next(const_result[i]) == const_result[i + 1]); } else { @@ -584,7 +588,7 @@ ATF_TEST_CASE_BODY(nvlist_number_array__move) uint64_t *testnumber; const uint64_t *const_result; nvlist_t *nvl; - size_t nitems, count; + size_t num_items, count; unsigned int i; const char *key; @@ -605,11 +609,11 @@ ATF_TEST_CASE_BODY(nvlist_number_array__move) ATF_REQUIRE(!nvlist_empty(nvl)); ATF_REQUIRE(nvlist_exists_number_array(nvl, key)); - const_result = nvlist_get_number_array(nvl, key, &nitems); - ATF_REQUIRE_EQ(nitems, count); + const_result = nvlist_get_number_array(nvl, key, &num_items); + ATF_REQUIRE_EQ(num_items, count); ATF_REQUIRE(const_result != NULL); ATF_REQUIRE(const_result == testnumber); - for (i = 0; i < nitems; i++) + for (i = 0; i < num_items; i++) ATF_REQUIRE_EQ(const_result[i], i); nvlist_destroy(nvl); @@ -621,7 +625,7 @@ ATF_TEST_CASE_BODY(nvlist_descriptor_array__move) int *testfd; const int *const_result; nvlist_t *nvl; - size_t nitems, count; + size_t num_items, count; unsigned int i; const char *key; @@ -644,11 +648,11 @@ ATF_TEST_CASE_BODY(nvlist_descriptor_array__move) ATF_REQUIRE(!nvlist_empty(nvl)); ATF_REQUIRE(nvlist_exists_descriptor_array(nvl, key)); - const_result = nvlist_get_descriptor_array(nvl, key, &nitems); - ATF_REQUIRE_EQ(nitems, count); + const_result = nvlist_get_descriptor_array(nvl, key, &num_items); + ATF_REQUIRE_EQ(num_items, count); ATF_REQUIRE(const_result != NULL); ATF_REQUIRE(const_result == testfd); - for (i = 0; i < nitems; i++) + for (i = 0; i < num_items; i++) ATF_REQUIRE(fd_is_valid(const_result[i])); nvlist_destroy(nvl); @@ -764,11 +768,12 @@ ATF_TEST_CASE_BODY(nvlist_nvlist_array__travel) { nvlist_t *nvl, *test[5], *nasted; const nvlist_t *travel; - void *cookie; - int index, i, type; const char *name; + void *cookie; + int type; + unsigned int i, index; - for (i = 0; i < 5; i++) { + for (i = 0; i < nitems(test); i++) { test[i] = nvlist_create(0); ATF_REQUIRE(test[i] != NULL); nvlist_add_number(test[i], "nvl/number", i); @@ -776,11 +781,12 @@ ATF_TEST_CASE_BODY(nvlist_nvlist_array__travel) } nvl = nvlist_create(0); ATF_REQUIRE(nvl != NULL); - nvlist_add_nvlist_array(nvl, "nvl/nvlist_array", test, 5); + nvlist_add_nvlist_array(nvl, "nvl/nvlist_array", test, nitems(test)); ATF_REQUIRE(nvlist_error(nvl) == 0); nasted = nvlist_create(0); ATF_REQUIRE(nasted != NULL); - nvlist_add_nvlist_array(nasted, "nvl/nvl/nvlist_array", test, 5); + nvlist_add_nvlist_array(nasted, "nvl/nvl/nvlist_array", test, + nitems(test)); ATF_REQUIRE(nvlist_error(nasted) == 0); nvlist_move_nvlist(nvl, "nvl/nvl", nasted); ATF_REQUIRE(nvlist_error(nvl) == 0); @@ -794,15 +800,16 @@ ATF_TEST_CASE_BODY(nvlist_nvlist_array__travel) while ((name = nvlist_next(travel, &type, &cookie)) != NULL) { if (index == 0) { ATF_REQUIRE(type == NV_TYPE_NVLIST_ARRAY); - } else if (index >= 1 && index <= 5) { + } else if (index >= 1 && index <= nitems(test)) { ATF_REQUIRE(type == NV_TYPE_NUMBER); - } else if (index == 6) { + } else if (index == nitems(test) + 1) { ATF_REQUIRE(type == NV_TYPE_NVLIST); - } else if (index == 7) { + } else if (index == nitems(test) + 2) { ATF_REQUIRE(type == NV_TYPE_NVLIST_ARRAY); - } else if (index >= 8 && index <= 12) { + } else if (index >= nitems(test) + 3 && + index <= 2 * nitems(test) + 2) { ATF_REQUIRE(type == NV_TYPE_NUMBER); - } else if (index == 13) { + } else if (index == 2 * nitems(test) + 3) { ATF_REQUIRE(type == NV_TYPE_STRING); } @@ -818,7 +825,7 @@ ATF_TEST_CASE_BODY(nvlist_nvlist_array__travel) } } while ((travel = nvlist_get_pararr(travel, &cookie)) != NULL); - for (i = 0; i < 5; i++) + for (i = 0; i < nitems(test); i++) nvlist_destroy(test[i]); nvlist_destroy(nvl); @@ -908,7 +915,7 @@ ATF_TEST_CASE_BODY(nvlist_bool_array__pack) const bool *const_result; bool testbool[16]; - for (i = 0; i < 16; i++) + for (i = 0; i < nitems(testbool); i++) testbool[i] = (i % 2 == 0); key = "nvl/bool"; @@ -917,7 +924,7 @@ ATF_TEST_CASE_BODY(nvlist_bool_array__pack) ATF_REQUIRE(nvlist_empty(nvl)); ATF_REQUIRE(!nvlist_exists_string_array(nvl, key)); - nvlist_add_bool_array(nvl, key, testbool, 16); + nvlist_add_bool_array(nvl, key, testbool, nitems(testbool)); ATF_REQUIRE_EQ(nvlist_error(nvl), 0); ATF_REQUIRE(!nvlist_empty(nvl)); ATF_REQUIRE(nvlist_exists_bool_array(nvl, key)); @@ -931,7 +938,7 @@ ATF_TEST_CASE_BODY(nvlist_bool_array__pack) ATF_REQUIRE(nvlist_exists_bool_array(unpacked, key)); const_result = nvlist_get_bool_array(unpacked, key, &count); - ATF_REQUIRE_EQ(count, 16); + ATF_REQUIRE_EQ(count, nitems(testbool)); for (i = 0; i < count; i++) { ATF_REQUIRE_EQ(testbool[i], const_result[i]); } @@ -973,7 +980,7 @@ ATF_TEST_CASE_BODY(nvlist_number_array__pack) ATF_REQUIRE(nvlist_exists_number_array(unpacked, key)); const_result = nvlist_get_number_array(unpacked, key, &count); - ATF_REQUIRE_EQ(count, 8); + ATF_REQUIRE_EQ(count, nitems(number)); for (i = 0; i < count; i++) { ATF_REQUIRE_EQ(number[i], const_result[i]); } @@ -988,7 +995,7 @@ ATF_TEST_CASE_BODY(nvlist_descriptor_array__pack) { nvlist_t *nvl; const char *key; - size_t nitems; + size_t num_items; unsigned int i; const int *const_result; int desc[32], fd, socks[2]; @@ -1004,7 +1011,7 @@ ATF_TEST_CASE_BODY(nvlist_descriptor_array__pack) /* Child. */ fd = socks[0]; close(socks[1]); - for (i = 0; i < 32; i++) { + for (i = 0; i < nitems(desc); i++) { desc[i] = dup(STDERR_FILENO); ATF_REQUIRE(fd_is_valid(desc[i])); } @@ -1014,14 +1021,14 @@ ATF_TEST_CASE_BODY(nvlist_descriptor_array__pack) ATF_REQUIRE(nvlist_empty(nvl)); ATF_REQUIRE(!nvlist_exists_descriptor_array(nvl, key)); - nvlist_add_descriptor_array(nvl, key, desc, 32); + nvlist_add_descriptor_array(nvl, key, desc, nitems(desc)); ATF_REQUIRE_EQ(nvlist_error(nvl), 0); ATF_REQUIRE(!nvlist_empty(nvl)); ATF_REQUIRE(nvlist_exists_descriptor_array(nvl, key)); ATF_REQUIRE(nvlist_send(fd, nvl) >= 0); - for (i = 0; i < nitems; i++) + for (i = 0; i < nitems(desc); i++) close(desc[i]); } else { /* Parent */ @@ -1034,10 +1041,10 @@ ATF_TEST_CASE_BODY(nvlist_descriptor_array__pack) ATF_REQUIRE_EQ(nvlist_error(nvl), 0); ATF_REQUIRE(nvlist_exists_descriptor_array(nvl, key)); - const_result = nvlist_get_descriptor_array(nvl, key, &nitems); + const_result = nvlist_get_descriptor_array(nvl, key, &num_items); ATF_REQUIRE(const_result != NULL); - ATF_REQUIRE_EQ(nitems, 32); - for (i = 0; i < nitems; i++) + ATF_REQUIRE_EQ(num_items, nitems(desc)); + for (i = 0; i < num_items; i++) ATF_REQUIRE(fd_is_valid(const_result[i])); atf::utils::wait(pid, 0, "", ""); @@ -1056,7 +1063,7 @@ ATF_TEST_CASE_BODY(nvlist_string_array__pack) void *packed; unsigned int i; const char * const *const_result; - const char *string[8] = { "a", "b", "kot", "foo", + const char *string_arr[8] = { "a", "b", "kot", "foo", "tests", "nice test", "", "abcdef" }; key = "nvl/string"; @@ -1065,7 +1072,7 @@ ATF_TEST_CASE_BODY(nvlist_string_array__pack) ATF_REQUIRE(nvlist_empty(nvl)); ATF_REQUIRE(!nvlist_exists_string_array(nvl, key)); - nvlist_add_string_array(nvl, key, string, 8); + nvlist_add_string_array(nvl, key, string_arr, nitems(string_arr)); ATF_REQUIRE_EQ(nvlist_error(nvl), 0); ATF_REQUIRE(!nvlist_empty(nvl)); ATF_REQUIRE(nvlist_exists_string_array(nvl, key)); @@ -1079,9 +1086,9 @@ ATF_TEST_CASE_BODY(nvlist_string_array__pack) ATF_REQUIRE(nvlist_exists_string_array(unpacked, key)); const_result = nvlist_get_string_array(unpacked, key, &count); - ATF_REQUIRE_EQ(count, 8); + ATF_REQUIRE_EQ(count, nitems(string_arr)); for (i = 0; i < count; i++) { - ATF_REQUIRE_EQ(strcmp(string[i], const_result[i]), 0); + ATF_REQUIRE_EQ(strcmp(string_arr[i], const_result[i]), 0); } nvlist_destroy(nvl); @@ -1094,15 +1101,14 @@ ATF_TEST_CASE_BODY(nvlist_nvlist_array__pack) { nvlist_t *testnvl[8], *unpacked; const nvlist_t * const *const_result; - nvlist_t **result; nvlist_t *nvl; - size_t nitems, packed_size; + size_t num_items, packed_size; unsigned int i; void *packed; const char *somestr[8] = { "a", "b", "c", "d", "e", "f", "g", "h" }; const char *key; - for (i = 0; i < 8; i++) { + for (i = 0; i < nitems(testnvl); i++) { testnvl[i] = nvlist_create(0); ATF_REQUIRE(testnvl[i] != NULL); ATF_REQUIRE_EQ(nvlist_error(testnvl[i]), 0); @@ -1130,12 +1136,12 @@ ATF_TEST_CASE_BODY(nvlist_nvlist_array__pack) ATF_REQUIRE_EQ(nvlist_error(unpacked), 0); ATF_REQUIRE(nvlist_exists_nvlist_array(unpacked, key)); - const_result = nvlist_get_nvlist_array(unpacked, key, &nitems); + const_result = nvlist_get_nvlist_array(unpacked, key, &num_items); ATF_REQUIRE(const_result != NULL); - ATF_REQUIRE_EQ(nitems, 8); - for (i = 0; i < nitems; i++) { + ATF_REQUIRE_EQ(num_items, nitems(testnvl)); + for (i = 0; i < num_items; i++) { ATF_REQUIRE_EQ(nvlist_error(const_result[i]), 0); - if (i < nitems - 1) { + if (i < num_items - 1) { ATF_REQUIRE(nvlist_get_array_next(const_result[i]) == const_result[i + 1]); } else { @@ -1150,9 +1156,8 @@ ATF_TEST_CASE_BODY(nvlist_nvlist_array__pack) "nvl/string"), somestr[i]) == 0); } - for (i = 0; i < 8; i++) + for (i = 0; i < nitems(testnvl); i++) nvlist_destroy(testnvl[i]); - free(result); nvlist_destroy(nvl); nvlist_destroy(unpacked); free(packed); diff --git a/lib/libstand/Makefile b/lib/libstand/Makefile index 3126c1c..c85b694 100644 --- a/lib/libstand/Makefile +++ b/lib/libstand/Makefile @@ -11,13 +11,14 @@ MK_SSP= no .include <src.opts.mk> -LIBSTAND_SRC= ${.CURDIR} +LIBSTAND_SRC?= ${.CURDIR} +LIBSTAND_CPUARCH?=${MACHINE_CPUARCH} LIBC_SRC= ${LIBSTAND_SRC}/../libc LIB= stand NO_PIC= -INCS= stand.h -MAN= libstand.3 +INCS?= stand.h +MAN?= libstand.3 WARNS?= 0 @@ -37,8 +38,9 @@ SRCS+= ntoh.c # string functions from libc .PATH: ${LIBC_SRC}/string -SRCS+= bcmp.c bcopy.c bzero.c ffs.c memccpy.c memchr.c memcmp.c memcpy.c \ - memmove.c memset.c qdivrem.c strcat.c strchr.c strcmp.c strcpy.c \ +SRCS+= bcmp.c bcopy.c bzero.c ffs.c fls.c \ + memccpy.c memchr.c memcmp.c memcpy.c memmove.c memset.c \ + qdivrem.c strcat.c strchr.c strcmp.c strcpy.c \ strcspn.c strlcat.c strlcpy.c strlen.c strncat.c strncmp.c strncpy.c \ strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c .if ${MACHINE_CPUARCH} == "arm" @@ -78,7 +80,7 @@ SRCS+= syncicache.c SRCS+= uuid_create_nil.c uuid_equal.c uuid_from_string.c uuid_is_nil.c uuid_to_string.c # _setjmp/_longjmp -.PATH: ${LIBSTAND_SRC}/${MACHINE_CPUARCH} +.PATH: ${LIBSTAND_SRC}/${LIBSTAND_CPUARCH} SRCS+= _setjmp.S # decompression functionality from libbz2 diff --git a/lib/libstand/uuid_to_string.c b/lib/libstand/uuid_to_string.c index efe921c..d878af4 100644 --- a/lib/libstand/uuid_to_string.c +++ b/lib/libstand/uuid_to_string.c @@ -46,7 +46,7 @@ tohex(char **buf, int len, uint32_t val) char *walker = *buf; int i; - for (i = len - 1; i >= 0; i++) { + for (i = len - 1; i >= 0; i--) { walker[i] = hexstr[val & 0xf]; val >>= 4; } @@ -107,5 +107,5 @@ uuid_to_string(const uuid_t *u, char **s, uint32_t *status) tohex(&w, 2, u->node[3]); tohex(&w, 2, u->node[4]); tohex(&w, 2, u->node[5]); - *w++ - '\0'; + *w++ = '\0'; } diff --git a/lib/libsysdecode/Makefile.depend b/lib/libsysdecode/Makefile.depend new file mode 100644 index 0000000..653f526 --- /dev/null +++ b/lib/libsysdecode/Makefile.depend @@ -0,0 +1,22 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + gnu/lib/libgcc \ + include \ + include/rpc \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +ioctl.So: ioctl.c +ioctl.o: ioctl.c +ioctl.po: ioctl.c +.endif diff --git a/libexec/rtld-elf/aarch64/rtld_machdep.h b/libexec/rtld-elf/aarch64/rtld_machdep.h index 943e3e6..a2fc74a 100644 --- a/libexec/rtld-elf/aarch64/rtld_machdep.h +++ b/libexec/rtld-elf/aarch64/rtld_machdep.h @@ -80,4 +80,6 @@ extern void *__tls_get_addr(tls_index *ti); #define RTLD_DEFAULT_STACK_PF_EXEC PF_X #define RTLD_DEFAULT_STACK_EXEC PROT_EXEC +#define md_abi_variant_hook(x) + #endif diff --git a/libexec/rtld-elf/amd64/reloc.c b/libexec/rtld-elf/amd64/reloc.c index 53d2bdc..9895944 100644 --- a/libexec/rtld-elf/amd64/reloc.c +++ b/libexec/rtld-elf/amd64/reloc.c @@ -228,8 +228,8 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags, /* * These are deferred until all other relocations have * been done. All we do here is make sure that the COPY - * relocation is not in a shared library. They are allowed - * only in executable files. + * relocation is not in a shared library. They are + * allowed only in executable files. */ if (!obj->mainprog) { _rtld_error("%s: Unexpected R_X86_64_COPY " diff --git a/libexec/rtld-elf/amd64/rtld_machdep.h b/libexec/rtld-elf/amd64/rtld_machdep.h index cb5e9a1..a8696fe 100644 --- a/libexec/rtld-elf/amd64/rtld_machdep.h +++ b/libexec/rtld-elf/amd64/rtld_machdep.h @@ -79,4 +79,6 @@ void *__tls_get_addr(tls_index *ti) __exported; #define RTLD_DEFAULT_STACK_PF_EXEC PF_X #define RTLD_DEFAULT_STACK_EXEC PROT_EXEC +#define md_abi_variant_hook(x) + #endif diff --git a/libexec/rtld-elf/arm/reloc.c b/libexec/rtld-elf/arm/reloc.c index d0bf987..6bdda73 100644 --- a/libexec/rtld-elf/arm/reloc.c +++ b/libexec/rtld-elf/arm/reloc.c @@ -18,6 +18,41 @@ __FBSDID("$FreeBSD$"); #include "paths.h" void +arm_abi_variant_hook(Elf_Auxinfo **aux_info) +{ + Elf_Word ehdr; + + /* + * If we're running an old kernel that doesn't provide any data fail + * safe by doing nothing. + */ + if (aux_info[AT_EHDRFLAGS] == NULL) + return; + ehdr = aux_info[AT_EHDRFLAGS]->a_un.a_val; + + /* + * Hard float ABI binaries are the default, and use the default paths + * and such. + */ + if ((ehdr & EF_ARM_VFP_FLOAT) != 0) + return; + + /* + * This is a soft float ABI binary. We need to use the soft float + * settings. For the moment, the standard library path includes the hard + * float paths as well. When upgrading, we need to execute the wrong + * kind of binary until we've installed the new binaries. We could go + * off whether or not /libsoft exists, but the simplicity of having it + * in the path wins. + */ + ld_elf_hints_default = _PATH_SOFT_ELF_HINTS; + ld_path_libmap_conf = _PATH_SOFT_LIBMAP_CONF; + ld_path_rtld = _PATH_SOFT_RTLD; + ld_standard_library_path = SOFT_STANDARD_LIBRARY_PATH; + ld_env_prefix = LD_SOFT_; +} + +void init_pltgot(Obj_Entry *obj) { if (obj->pltgot != NULL) { diff --git a/libexec/rtld-elf/arm/rtld_machdep.h b/libexec/rtld-elf/arm/rtld_machdep.h index f980de0..c61bce0 100644 --- a/libexec/rtld-elf/arm/rtld_machdep.h +++ b/libexec/rtld-elf/arm/rtld_machdep.h @@ -75,4 +75,9 @@ extern void *__tls_get_addr(tls_index *ti); #define RTLD_DEFAULT_STACK_PF_EXEC PF_X #define RTLD_DEFAULT_STACK_EXEC PROT_EXEC +extern void arm_abi_variant_hook(Elf_Auxinfo **); + +#define md_abi_variant_hook(x) arm_abi_variant_hook(x) +#define RTLD_VARIANT_ENV_NAMES + #endif diff --git a/libexec/rtld-elf/i386/rtld_machdep.h b/libexec/rtld-elf/i386/rtld_machdep.h index 5c328da..5237d4f 100644 --- a/libexec/rtld-elf/i386/rtld_machdep.h +++ b/libexec/rtld-elf/i386/rtld_machdep.h @@ -80,4 +80,6 @@ void *__tls_get_addr(tls_index *ti) __exported; #define RTLD_DEFAULT_STACK_PF_EXEC PF_X #define RTLD_DEFAULT_STACK_EXEC PROT_EXEC +#define md_abi_variant_hook(x) + #endif diff --git a/libexec/rtld-elf/mips/rtld_machdep.h b/libexec/rtld-elf/mips/rtld_machdep.h index befbf13..34e8f3c 100644 --- a/libexec/rtld-elf/mips/rtld_machdep.h +++ b/libexec/rtld-elf/mips/rtld_machdep.h @@ -75,4 +75,6 @@ extern void *__tls_get_addr(tls_index *ti); #define RTLD_DEFAULT_STACK_PF_EXEC PF_X #define RTLD_DEFAULT_STACK_EXEC PROT_EXEC +#define md_abi_variant_hook(x) + #endif diff --git a/libexec/rtld-elf/paths.h b/libexec/rtld-elf/paths.h index 709e4d3..abfeb3f 100644 --- a/libexec/rtld-elf/paths.h +++ b/libexec/rtld-elf/paths.h @@ -1,8 +1,6 @@ /*- * Copyright 1996, 1997, 1998, 1999, 2000 John D. Polstra. * Copyright 2003 Alexander Kabaev <kan@FreeBSD.ORG>. - * Copyright 2009-2012 Konstantin Belousov <kib@FreeBSD.ORG>. - * Copyright 2012 John Marino <draco@marino.st>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -61,7 +59,13 @@ #define LD_ "LD_" #endif -extern char *ld_path_elf_hints; +#define _PATH_SOFT_ELF_HINTS "/var/run/ld-elf-soft.so.hints" +#define _PATH_SOFT_LIBMAP_CONF "/etc/libmap-soft.conf" +#define _PATH_SOFT_RTLD "/libexec/ld-elf.so.1" +#define SOFT_STANDARD_LIBRARY_PATH "/libsoft:/usr/libsoft:/lib:/usr/lib" +#define LD_SOFT_ "LD_SOFT_" + +extern char *ld_elf_hints_default; extern char *ld_path_libmap_conf; extern char *ld_path_rtld; extern char *ld_standard_library_path; diff --git a/libexec/rtld-elf/powerpc/rtld_machdep.h b/libexec/rtld-elf/powerpc/rtld_machdep.h index 1ddf1bc..3e39c82 100644 --- a/libexec/rtld-elf/powerpc/rtld_machdep.h +++ b/libexec/rtld-elf/powerpc/rtld_machdep.h @@ -90,4 +90,6 @@ extern void *__tls_get_addr(tls_index* ti); #define RTLD_DEFAULT_STACK_PF_EXEC PF_X #define RTLD_DEFAULT_STACK_EXEC PROT_EXEC +#define md_abi_variant_hook(x) + #endif diff --git a/libexec/rtld-elf/powerpc64/reloc.c b/libexec/rtld-elf/powerpc64/reloc.c index 0c75a2a..c428d6b 100644 --- a/libexec/rtld-elf/powerpc64/reloc.c +++ b/libexec/rtld-elf/powerpc64/reloc.c @@ -338,26 +338,19 @@ static int reloc_plt_object(Obj_Entry *obj, const Elf_Rela *rela) { Elf_Addr *where = (Elf_Addr *)(obj->relocbase + rela->r_offset); -#if !defined(_CALL_ELF) || _CALL_ELF == 1 - Elf_Addr *glink; -#endif long reloff; reloff = rela - obj->pltrela; -#if !defined(_CALL_ELF) || _CALL_ELF == 1 - if (obj->priv == NULL) - obj->priv = xmalloc(obj->pltrelasize); - glink = obj->priv + reloff*sizeof(Elf_Addr)*2; - - dbg(" reloc_plt_object: where=%p,reloff=%lx,glink=%p", (void *)where, reloff, glink); + dbg(" reloc_plt_object: where=%p,reloff=%lx,glink=%#lx", (void *)where, + reloff, obj->glink); - memcpy(where, _rtld_bind_start, sizeof(struct funcdesc)); - ((struct funcdesc *)(where))->env = (Elf_Addr)glink; - *(glink++) = (Elf_Addr)obj; - *(glink++) = reloff*sizeof(Elf_Rela); +#if !defined(_CALL_ELF) || _CALL_ELF == 1 + /* Glink code is 3 instructions after the first 32k, 2 before */ + *where = (Elf_Addr)obj->glink + 32 + + 8*((reloff < 0x8000) ? reloff : 0x8000) + + 12*((reloff < 0x8000) ? 0 : (reloff - 0x8000)); #else - dbg(" reloc_plt_object: where=%p,reloff=%lx,glink=%#lx", (void *)where, reloff, obj->glink); *where = (Elf_Addr)obj->glink + 4*reloff + 32; #endif @@ -416,13 +409,6 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate) target = (Elf_Addr)(defobj->relocbase + def->st_value); -#if 0 - /* PG XXX */ - dbg("\"%s\" in \"%s\" --> %p in \"%s\"", - defobj->strtab + def->st_name, basename(obj->path), - (void *)target, basename(defobj->path)); -#endif - if (def == &sym_zero) { /* Zero undefined weak symbols */ #if !defined(_CALL_ELF) || _CALL_ELF == 1 @@ -461,12 +447,28 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *defobj, (void *)wherep, (void *)target, *(Elf_Addr *)target, (Elf_Addr)defobj->relocbase); + /* + * For the trampoline, the second two elements of the function + * descriptor are unused, so we are fine replacing those at any time + * with the real ones with no thread safety implications. However, we + * need to make sure the main entry point pointer ([0]) is seen to be + * modified *after* the second two elements. This can't be done in + * general, since there are no barriers in the reading code, but put in + * some isyncs to at least make it a little better. + */ memcpy(wherep, (void *)target, sizeof(struct funcdesc)); + wherep[2] = ((Elf_Addr *)target)[2]; + wherep[1] = ((Elf_Addr *)target)[1]; + __asm __volatile ("isync" : : : "memory"); + wherep[0] = ((Elf_Addr *)target)[0]; + __asm __volatile ("isync" : : : "memory"); + if (((struct funcdesc *)(wherep))->addr < (Elf_Addr)defobj->relocbase) { /* - * XXX: It is possible (e.g. LD_BIND_NOW) that the function + * It is possible (LD_BIND_NOW) that the function * descriptor we are copying has not yet been relocated. - * If this happens, fix it. + * If this happens, fix it. Don't worry about threading in + * this case since LD_BIND_NOW makes it irrelevant. */ ((struct funcdesc *)(wherep))->addr += @@ -481,8 +483,6 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *defobj, *wherep = target; #endif - __asm __volatile("sync" ::: "memory"); - return (target); } @@ -506,7 +506,6 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flags, void init_pltgot(Obj_Entry *obj) { -#if defined(_CALL_ELF) && _CALL_ELF == 2 Elf_Addr *pltcall; pltcall = obj->pltgot; @@ -515,10 +514,12 @@ init_pltgot(Obj_Entry *obj) return; } +#if defined(_CALL_ELF) && _CALL_ELF == 2 pltcall[0] = (Elf_Addr)&_rtld_bind_start; pltcall[1] = (Elf_Addr)obj; - - __asm __volatile("sync" ::: "memory"); +#else + memcpy(pltcall, _rtld_bind_start, sizeof(struct funcdesc)); + pltcall[2] = (Elf_Addr)obj; #endif } diff --git a/libexec/rtld-elf/powerpc64/rtld_machdep.h b/libexec/rtld-elf/powerpc64/rtld_machdep.h index b88ed9d..32c7d12 100644 --- a/libexec/rtld-elf/powerpc64/rtld_machdep.h +++ b/libexec/rtld-elf/powerpc64/rtld_machdep.h @@ -82,4 +82,6 @@ extern void *__tls_get_addr(tls_index* ti); #define RTLD_DEFAULT_STACK_PF_EXEC PF_X #define RTLD_DEFAULT_STACK_EXEC PROT_EXEC +#define md_abi_variant_hook(x) + #endif diff --git a/libexec/rtld-elf/powerpc64/rtld_start.S b/libexec/rtld-elf/powerpc64/rtld_start.S index ee04d97..c274b6f 100644 --- a/libexec/rtld-elf/powerpc64/rtld_start.S +++ b/libexec/rtld-elf/powerpc64/rtld_start.S @@ -111,10 +111,7 @@ _ENTRY(_rtld_start) * * Call into the MI binder. This routine is reached via the PLT call cell * - * For ELFv1, on entry, %r11 contains a pointer to the (object, relocation) - * tuple. - * - * For ELFv2, %r11 contains an object pointer and %r0 contains the PLT index. + * On entry, %r11 contains an object pointer and %r0 contains the PLT index. * * Save all registers, call into the binder to resolve and fixup the external * routine, and then transfer to the external routine on return. @@ -122,7 +119,7 @@ _ENTRY(_rtld_start) .globl _rtld_bind _ENTRY(_rtld_bind_start) - mr %r12,%r0 # shunt r0 immediately to r12 for ELFv2 + mr %r12,%r0 # save r0 (index) immediately to r12 mflr %r0 std %r0,16(%r1) # save lr mfcr %r0 @@ -139,13 +136,9 @@ _ENTRY(_rtld_bind_start) std %r9,64+6*8(%r1) std %r10,64+7*8(%r1) -#if !defined(_CALL_ELF) || _CALL_ELF == 1 - ld %r3,0(%r11) - ld %r4,8(%r11) -#else mr %r3,%r11 - mulli %r4,%r12,24 /* Multiply index by sizeof(Elf_Rela) */ -#endif + mulli %r4,%r12,24 # Multiply index by sizeof(Elf_Rela) + bl _rtld_bind # target addr = _rtld_bind(obj, reloff) nop diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 4eee6c5..ad5d359 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -204,8 +204,6 @@ extern Elf_Dyn _DYNAMIC; #define RTLD_IS_DYNAMIC() (&_DYNAMIC != NULL) #endif -#define _LD(x) LD_ x - int dlclose(void *) __exported; char *dlerror(void) __exported; void *dlopen(const char *, int) __exported; @@ -325,6 +323,24 @@ ld_utrace_log(int event, void *handle, void *mapbase, size_t mapsize, utrace(&ut, sizeof(ut)); } +#ifdef RTLD_VARIANT_ENV_NAMES +/* + * construct the env variable based on the type of binary that's + * running. + */ +static inline const char * +_LD(const char *var) +{ + static char buffer[128]; + + strlcpy(buffer, ld_env_prefix, sizeof(buffer)); + strlcat(buffer, var, sizeof(buffer)); + return (buffer); +} +#else +#define _LD(x) LD_ x +#endif + /* * Main entry point for dynamic linking. The first argument is the * stack pointer. The stack is expected to be laid out as described @@ -419,6 +435,8 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) trust = !issetugid(); +/* md_abi_variant_hook(aux_info); */ + ld_bind_now = getenv(_LD("BIND_NOW")); /* * If the process is tainted, then we un-set the dangerous environment diff --git a/libexec/rtld-elf/sparc64/rtld_machdep.h b/libexec/rtld-elf/sparc64/rtld_machdep.h index 44fe2cf..9df63b8 100644 --- a/libexec/rtld-elf/sparc64/rtld_machdep.h +++ b/libexec/rtld-elf/sparc64/rtld_machdep.h @@ -71,4 +71,6 @@ extern void *__tls_get_addr(tls_index *ti); #define RTLD_DEFAULT_STACK_PF_EXEC 0 #define RTLD_DEFAULT_STACK_EXEC 0 +#define md_abi_variant_hook(x) + #endif diff --git a/release/Makefile b/release/Makefile index d9dbb4f..ba1ca80 100644 --- a/release/Makefile +++ b/release/Makefile @@ -176,7 +176,7 @@ disc1: packagesystem MK_DEBUG_FILES=no # Copy distfiles mkdir -p ${.TARGET}/usr/freebsd-dist - for dist in MANIFEST $$(ls *.txz | grep -v -- '-dbg'); \ + for dist in MANIFEST $$(ls *.txz | grep -vE -- '(base|lib32)-dbg'); \ do cp $${dist} ${.TARGET}/usr/freebsd-dist; \ done # Copy documentation, if generated @@ -225,7 +225,7 @@ dvd: packagesystem MK_TESTS=no MK_DEBUG_FILES=no # Copy distfiles mkdir -p ${.TARGET}/usr/freebsd-dist - for dist in MANIFEST $$(ls *.txz | grep -v -- '-dbg'); \ + for dist in MANIFEST $$(ls *.txz | grep -v -- '(base|lib32)-dbg'); \ do cp $${dist} ${.TARGET}/usr/freebsd-dist; \ done # Copy documentation, if generated @@ -281,7 +281,11 @@ ftp: packagesystem cp *.txz MANIFEST ftp release: real-release vm-release cloudware-release - touch ${.TARGET} + ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} release-done + true + +release-done: + touch release real-release: ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj diff --git a/release/Makefile.ec2 b/release/Makefile.ec2 index 2695183..221ea6c 100644 --- a/release/Makefile.ec2 +++ b/release/Makefile.ec2 @@ -51,7 +51,7 @@ ec2ami: cw-ec2 ${CW_EC2_PORTINSTALL} @echo "--------------------------------------------------------------" @false .endif - /usr/local/bin/bsdec2-image-upload ${PUBLISH} \ + /usr/local/bin/bsdec2-image-upload ${PUBLISH} --sriov \ ${.OBJDIR}/ec2.raw \ "${TYPE} ${REVISION}-${BRANCH}-${TARGET}${AMINAMESUFFIX}" \ "${TYPE} ${REVISION}-${BRANCH}-${TARGET}" \ diff --git a/release/amd64/make-memstick.sh b/release/amd64/make-memstick.sh index 6c289e0..52e17cc 100755 --- a/release/amd64/make-memstick.sh +++ b/release/amd64/make-memstick.sh @@ -29,12 +29,14 @@ if [ -e ${2} ]; then fi echo '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > ${1}/etc/fstab +echo 'root_rw_mount="NO"' > ${1}/etc/rc.conf.local makefs -B little -o label=FreeBSD_Install ${2}.part ${1} if [ $? -ne 0 ]; then echo "makefs failed" exit 1 fi rm ${1}/etc/fstab +rm ${1}/etc/rc.conf.local mkimg -s gpt -b ${1}/boot/pmbr -p efi:=${1}/boot/boot1.efifat -p freebsd-boot:=${1}/boot/gptboot -p freebsd-ufs:=${2}.part -p freebsd-swap::1M -o ${2} rm ${2}.part diff --git a/release/amd64/mkisoimages.sh b/release/amd64/mkisoimages.sh index 755fb52..f72dd9e 100644 --- a/release/amd64/mkisoimages.sh +++ b/release/amd64/mkisoimages.sh @@ -56,5 +56,5 @@ NAME="$1"; shift publisher="The FreeBSD Project. http://www.FreeBSD.org/" echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$1/etc/fstab" makefs -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$@" -rm "$1/etc/fstab" +rm -f "$1/etc/fstab" rm -f efiboot.img diff --git a/release/arm64/make-memstick.sh b/release/arm64/make-memstick.sh index 27ebf27..af73276 100755 --- a/release/arm64/make-memstick.sh +++ b/release/arm64/make-memstick.sh @@ -29,12 +29,14 @@ if [ -e ${2} ]; then fi echo '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > ${1}/etc/fstab +echo 'root_rw_mount="NO"' > ${1}/etc/rc.conf.local makefs -B little -o label=FreeBSD_Install ${2}.part ${1} if [ $? -ne 0 ]; then echo "makefs failed" exit 1 fi rm ${1}/etc/fstab +rm ${1}/etc/rc.conf.local mkimg -s mbr -p efi:=${1}/boot/boot1.efifat -p freebsd:=${2}.part -o ${2} rm ${2}.part diff --git a/release/doc/en_US.ISO8859-1/hardware/article.xml b/release/doc/en_US.ISO8859-1/hardware/article.xml index 191ac57..4b66434 100644 --- a/release/doc/en_US.ISO8859-1/hardware/article.xml +++ b/release/doc/en_US.ISO8859-1/hardware/article.xml @@ -1017,6 +1017,9 @@ &hwlist.rsu; + <para>Realtek RTL8188CE based PCIe IEEE 802.11b/g/n wireless network + adapters (&man.rtwn.4; driver)</para> + &hwlist.rum; &hwlist.run; diff --git a/release/i386/make-memstick.sh b/release/i386/make-memstick.sh index 27979ae7..f824382 100755 --- a/release/i386/make-memstick.sh +++ b/release/i386/make-memstick.sh @@ -29,12 +29,14 @@ if [ -e ${2} ]; then fi echo '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > ${1}/etc/fstab +echo 'root_rw_mount="NO"' > ${1}/etc/rc.conf.local makefs -B little -o label=FreeBSD_Install ${2}.part ${1} if [ $? -ne 0 ]; then echo "makefs failed" exit 1 fi rm ${1}/etc/fstab +rm ${1}/etc/rc.conf.local mkimg -s gpt -b ${1}/boot/pmbr -p freebsd-boot:=${1}/boot/gptboot -p freebsd-ufs:=${2}.part -p freebsd-swap::1M -o ${2} rm ${2}.part diff --git a/release/i386/mkisoimages.sh b/release/i386/mkisoimages.sh index a250105..c6c2517 100644 --- a/release/i386/mkisoimages.sh +++ b/release/i386/mkisoimages.sh @@ -42,4 +42,4 @@ NAME="$1"; shift publisher="The FreeBSD Project. http://www.FreeBSD.org/" echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$1/etc/fstab" makefs -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$@" -rm "$1/etc/fstab" +rm -f "$1/etc/fstab" diff --git a/release/pc98/mkisoimages.sh b/release/pc98/mkisoimages.sh index 074fe09..5e7a046 100644 --- a/release/pc98/mkisoimages.sh +++ b/release/pc98/mkisoimages.sh @@ -42,4 +42,4 @@ NAME="$1"; shift publisher="The FreeBSD Project. http://www.FreeBSD.org/" echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$1/etc/fstab" makefs -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$@" -rm "$1/etc/fstab" +rm -f "$1/etc/fstab" diff --git a/release/powerpc/make-memstick.sh b/release/powerpc/make-memstick.sh index 4f6b69d..3c1cfa4 100755 --- a/release/powerpc/make-memstick.sh +++ b/release/powerpc/make-memstick.sh @@ -33,6 +33,7 @@ if [ -e ${2} ]; then fi echo '/dev/da0s3 / ufs ro,noatime 1 1' > ${1}/etc/fstab +echo 'root_rw_mount="NO"' > ${1}/etc/rc.conf.local rm -f ${tempfile} makefs -B big ${tempfile} ${1} if [ $? -ne 0 ]; then @@ -40,6 +41,7 @@ if [ $? -ne 0 ]; then exit 1 fi rm ${1}/etc/fstab +rm ${1}/etc/rc.conf.local mkimg -s apm -p freebsd-boot:=${1}/boot/boot1.hfs -p freebsd-ufs/FreeBSD_Install:=${tempfile} -o ${2} diff --git a/release/powerpc/mkisoimages.sh b/release/powerpc/mkisoimages.sh index c92072d..e69f32d 100644 --- a/release/powerpc/mkisoimages.sh +++ b/release/powerpc/mkisoimages.sh @@ -64,6 +64,6 @@ NAME="$1"; shift publisher="The FreeBSD Project. http://www.FreeBSD.org/" echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$1/etc/fstab" makefs -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$@" -rm "$1/etc/fstab" -rm /tmp/hfs-boot-block +rm -f "$1/etc/fstab" +rm -f /tmp/hfs-boot-block rm -rf "$1/ppc" diff --git a/release/release.sh b/release/release.sh index 313a16c..caa6f26 100755 --- a/release/release.sh +++ b/release/release.sh @@ -275,6 +275,7 @@ extra_chroot_setup() { PBUILD_FLAGS="${PBUILD_FLAGS} OSREL=${REVISION}" chroot ${CHROOTDIR} make -C /usr/ports/textproc/docproj \ ${PBUILD_FLAGS} OPTIONS_UNSET="FOP IGOR" \ + FORCE_PKG_REGISTER=1 \ install clean distclean fi fi diff --git a/release/scripts/make-manifest.sh b/release/scripts/make-manifest.sh index b21e8f5..79cea70 100755 --- a/release/scripts/make-manifest.sh +++ b/release/scripts/make-manifest.sh @@ -9,18 +9,64 @@ # # $FreeBSD$ -desc_base="Base system (MANDATORY)" -desc_kernel="Kernel (MANDATORY)" -desc_doc="Additional documentation" -doc_default=off -desc_lib32="32-bit compatibility libraries" -desc_ports="Ports tree" -desc_src="System source code" -desc_tests="Test suite" -src_default=off -tests_default=off - -for i in $*; do - echo "`basename $i` `sha256 -q $i` `tar tvf $i | wc -l | tr -d ' '` `basename $i .txz` \"`eval echo \\\$desc_$(basename $i .txz)`\" `eval echo \\\${$(basename $i .txz)_default:-on}`" +base="Base system" +doc="Additional Documentation" +kernel="Kernel" +ports="Ports tree" +src="System source tree" +lib32="32-bit compatibility libraries" +tests="Test suite" + +desc_base="${base} (MANDATORY)" +desc_base_dbg="${base} (Debugging)" +desc_doc="${doc}" +desc_kernel="${kernel} (MANDATORY)" +desc_kernel_dbg="${kernel} (Debugging)" +desc_kernel_alt="Alternate ${kernel}" +desc_kernel_alt_dbg="Alternate ${kernel} (Debugging)" +desc_lib32="${lib32}" +desc_lib32_dbg="${lib32} (Debugging)" +desc_ports="${ports}" +desc_src="${src}" +desc_tests="${tests}" + +default_doc=off +default_src=off +default_tests=off +default_base_dbg=off +default_lib32_dbg=off +default_kernel_alt=off +default_kernel_dbg=on +default_kernel_alt_dbg=off + +for i in ${*}; do + dist="${i}" + distname="${i%%.txz}" + distname="$(echo ${distname} | tr '-' '_')" + distname="$(echo ${distname} | tr 'kernel.' 'kernel_')" + hash="$(sha256 -q ${i})" + nfiles="$(tar tvf ${i} | wc -l | tr -d ' ')" + default="$(eval echo \${default_${distname}:-on})" + desc="$(eval echo \"\${desc_${distname}}\")" + + case ${i} in + kernel-dbg.txz) + desc="${desc_kernel_dbg}" + ;; + kernel.*-dbg.txz) + desc="$(eval echo \"${desc_kernel_alt_dbg}\")" + desc="${desc}: $(eval echo ${i%%-dbg.txz} | cut -f 2 -d '.')" + default="$(eval echo \"${default_kernel_alt_dbg}\")" + ;; + kernel.*.txz) + desc="$(eval echo \"${desc_kernel_alt}\")" + desc="${desc}: $(eval echo ${i%%.txz} | cut -f 2 -d '.')" + default="$(eval echo \"${default_kernel_alt}\")" + ;; + *) + ;; + esac + + printf "${dist}\t${hash}\t${nfiles}\t${distname}\t\"${desc}\"\t${default}\n" done diff --git a/release/sparc64/mkisoimages.sh b/release/sparc64/mkisoimages.sh index 337db40..10c11b4 100644 --- a/release/sparc64/mkisoimages.sh +++ b/release/sparc64/mkisoimages.sh @@ -38,7 +38,7 @@ BASEBITSDIR="$1" publisher="The FreeBSD Project. http://www.FreeBSD.org/" echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$BASEBITSDIR/etc/fstab" makefs -t cd9660 -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME.tmp" "$@" -rm "$BASEBITSDIR/etc/fstab" +rm -f "$BASEBITSDIR/etc/fstab" if [ "x$BOPT" != "x-b" ]; then mv "$NAME.tmp" "$NAME" diff --git a/sbin/geom/class/eli/Makefile b/sbin/geom/class/eli/Makefile index 50de651..5eff32c 100644 --- a/sbin/geom/class/eli/Makefile +++ b/sbin/geom/class/eli/Makefile @@ -4,6 +4,7 @@ GEOM_CLASS= eli SRCS= g_eli_crypto.c +SRCS+= g_eli_hmac.c SRCS+= g_eli_key.c SRCS+= pkcs5v2.c SRCS+= sha256c.c diff --git a/share/examples/ypldap/ypldap.conf b/share/examples/ypldap/ypldap.conf new file mode 100644 index 0000000..83d25ac --- /dev/null +++ b/share/examples/ypldap/ypldap.conf @@ -0,0 +1,40 @@ +$FreeBSD$ +domain "freebsd.org" +interval 60 +provide map "passwd.byname" +provide map "passwd.byuid" +provide map "group.byname" +provide map "group.bygid" +provide map "netid.byname" + +directory "127.0.0.1" { + # directory options + binddn "cn=ldap,dc=freebsd,dc=org" + bindcred "secret" + basedn "dc=freebsd.,dc=org" + # starting point for groups directory search, default to basedn + groupdn "ou=Groups,dc=freebsd,dc=org" + + # passwd maps configuration (RFC 2307 posixAccount object class) + passwd filter "(objectClass=posixAccount)" + + attribute name maps to "uid" + fixed attribute passwd "*" + attribute uid maps to "uidNumber" + attribute gid maps to "gidNumber" + attribute gecos maps to "cn" + attribute home maps to "homeDirectory" + attribute shell maps to "loginShell" + fixed attribute change "0" + fixed attribute expire "0" + fixed attribute class "" + + # group maps configuration (RFC 2307 posixGroup object class) + group filter "(objectClass=posixGroup)" + + attribute groupname maps to "cn" + fixed attribute grouppasswd "*" + attribute groupgid maps to "gidNumber" + # memberUid returns multiple group members + list groupmembers maps to "memberUid" +} diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 6cf392a..d5050ac 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -424,6 +424,8 @@ MAN= aac.4 \ rndtest.4 \ route.4 \ rp.4 \ + rtwn.4 \ + rtwnfw.4 \ rue.4 \ rum.4 \ run.4 \ diff --git a/share/man/man4/ioat.4 b/share/man/man4/ioat.4 index dd467b2..10f2663 100644 --- a/share/man/man4/ioat.4 +++ b/share/man/man4/ioat.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 17, 2015 +.Dd January 7, 2016 .Dt IOAT 4 .Os .Sh NAME @@ -65,12 +65,16 @@ In .Fn ioat_put_dmaengine "bus_dmaengine_t dmaengine" .Ft int .Fn ioat_get_hwversion "bus_dmaengine_t dmaengine" +.Ft size_t +.Fn ioat_get_max_io_size "bus_dmaengine_t dmaengine" .Ft int .Fn ioat_set_interrupt_coalesce "bus_dmaengine_t dmaengine" "uint16_t delay" .Ft uint16_t .Fn ioat_get_max_coalesce_period "bus_dmaengine_t dmaengine" .Ft void .Fn ioat_acquire "bus_dmaengine_t dmaengine" +.Ft int +.Fn ioat_acquire_reserve "bus_dmaengine_t dmaengine" "uint32_t n" "int mflags" .Ft void .Fn ioat_release "bus_dmaengine_t dmaengine" .Ft struct bus_dmadesc * @@ -176,6 +180,14 @@ When the user wants to offload a copy, they will first the .Ar bus_dmaengine_t object for exclusive access to enqueue operations on that channel. +Optionally, the user can reserve space by using +.Fn ioat_acquire_reserve +instead. +If +.Fn ioat_acquire_reserve +succeeds, there is guaranteed to be room for +.Fa N +new operations in the internal ring buffer. Then, they will submit one or more operations using .Fn ioat_blockfill , .Fn ioat_copy , diff --git a/share/man/man4/ismt.4 b/share/man/man4/ismt.4 index 63a3952..b027f6f 100644 --- a/share/man/man4/ismt.4 +++ b/share/man/man4/ismt.4 @@ -33,7 +33,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 9, 2014 +.Dd January 11, 2016 .Dt ISMT 4 .Os .Sh NAME @@ -54,6 +54,6 @@ in the Intel Atom S1200 and C2000 CPUs. The .Nm driver first appeared in -.Fx 11.0 . +.Fx 10.3 . .Sh AUTHORS .An Jim Harris Aq Mt jimharris@FreeBSD.org diff --git a/share/man/man4/nvme.4 b/share/man/man4/nvme.4 index 068b006..83ca8ae 100644 --- a/share/man/man4/nvme.4 +++ b/share/man/man4/nvme.4 @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 2012-2014 Intel Corporation +.\" Copyright (c) 2012-2016 Intel Corporation .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -33,7 +33,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 18, 2014 +.Dd January 7, 2016 .Dt NVME 4 .Os .Sh NAME @@ -89,7 +89,10 @@ not 0, and this driver follows that convention. By default, .Nm will create an I/O queue pair for each CPU, provided enough MSI-X vectors -can be allocated. +and NVMe queue pairs can be allocated. If not enough vectors or queue +pairs are available, nvme(4) will use a smaller number of queue pairs and +assign multiple CPUs per queue pair. +.Pp To force a single I/O queue pair shared by all CPUs, set the following tunable value in .Xr loader.conf 5 : @@ -97,6 +100,13 @@ tunable value in hw.nvme.per_cpu_io_queues=0 .Ed .Pp +To assign more than one CPU per I/O queue pair, thereby reducing the number +of MSI-X vectors consumed by the device, set the following tunable value in +.Xr loader.conf 5 : +.Bd -literal -offset indent +hw.nvme.min_cpus_per_ioq=X +.Ed +.Pp To force legacy interrupts for all .Nm driver instances, set the following tunable value in @@ -109,6 +119,8 @@ Note that use of INTx implies disabling of per-CPU I/O queue pairs. .Sh SYSCTL VARIABLES The following controller-level sysctls are currently implemented: .Bl -tag -width indent +.It Va dev.nvme.0.num_cpus_per_ioq +(R) Number of CPUs associated with each I/O queue pair. .It Va dev.nvme.0.int_coal_time (R/W) Interrupt coalescing timer period in microseconds. Set to 0 to disable. diff --git a/share/man/man4/rtwn.4 b/share/man/man4/rtwn.4 new file mode 100644 index 0000000..1025849 --- /dev/null +++ b/share/man/man4/rtwn.4 @@ -0,0 +1,165 @@ +.\" $OpenBSD: rtwn.4,v 1.2 2015/07/09 11:28:53 stsp Exp $ +.\" +.\" Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> +.\" Copyright (c) 2015 Stefan Sperling <stsp@openbsd.org> +.\" +.\" Permission to use, copy, modify, and 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$ +.\" +.Dd October 28, 2015 +.Dt RTWN 4 +.Os +.Sh NAME +.Nm rtwn +.Nd Realtek RTL8188CE PCIe IEEE 802.11b/g/n wireless network device +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device rtwn" +.Cd "device rtwnfw" +.Cd "device wlan" +.Cd "device firmware" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +if_rtwn_load="YES" +.Ed +.Pp +After you have read the license in +.Pa /usr/share/doc/legal/realtek.LICENSE +you will want to add the following lines to +.Xr loader.conf 5 : +.Bd -literal -offset indent +legal.realtek.license_ack=1 +rtwn-rtl8192cfwU_load="YES" +rtwn-rtl8192cfwU_B_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver supports PCIe wireless network devices based on the Realtek +RTL8188CE chipset. +.Pp +The RTL8188CE is a highly integrated 802.11n adapter that combines a MAC, +a 1T1R capable baseband and an RF in a single chip. +It operates in the 2GHz spectrum only. +.Pp +These are the modes the +.Nm +driver can operate in: +.Bl -tag -width "IBSS-masterXX" +.It BSS mode +Also known as +.Em infrastructure +mode, this is used when associating with an access point, through +which all traffic passes. +This mode is the default. +.It monitor mode +In this mode the driver is able to receive packets without +associating with an access point. +This disables the internal receive filter and enables the card to +capture packets from networks which it wouldn't normally have access to, +or to scan for access points. +.El +.Pp +The +.Nm +driver can be configured to use +Wired Equivalent Privacy (WEP) or +Wi-Fi Protected Access (WPA-PSK and WPA2-PSK). +WPA is the current encryption standard for wireless networks. +It is strongly recommended that WEP +not be used as the sole mechanism +to secure wireless communication, +due to serious weaknesses in it. +.Pp +The +.Nm +driver can be configured at runtime with +.Xr ifconfig 8 . +.Sh FILES +The driver needs at least version 1.0 of the following firmware files, +which are loaded when an interface is brought up: +.Pp +.Bl -tag -width Ds -offset indent -compact +.It Pa /boot/kernel/rtwn-rtl8192cfwU.ko +.It Pa /boot/kernel/rtwn-rtl8192cfwU_B.ko +.El +.Sh EXAMPLES +Join an existing BSS network (i.e., connect to an access point): +.Bd -literal -offset indent +ifconfig wlan create wlandev rtwn0 inet 192.168.0.20 \e + netmask 0xffffff00 +.Ed +.Pp +Join a specific BSS network with network name +.Dq Li my_net : +.Pp +.Dl "ifconfig wlan create wlandev rtwn0 ssid my_net up" +.Pp +Join a specific BSS network with 64-bit WEP encryption: +.Bd -literal -offset indent +ifconfig wlan create wlandev rtwn0 ssid my_net \e + wepmode on wepkey 0x1234567890 weptxkey 1 up +.Ed +.Sh DIAGNOSTICS +.Bl -diag +.It "could not read firmware %s" +For some reason, the driver was unable to read the microcode file from the +filesystem. +The file might be missing or corrupted. +.It "device timeout" +A frame dispatched to the hardware for transmission did not complete in time. +The driver will reset the hardware. +This should not happen. +.El +.Sh SEE ALSO +.Xr pci 4 , +.Xr rtwnfw 4 , +.Xr wlan 4 , +.Xr wlan_ccmp 4 , +.Xr wlan_tkip 4 , +.Xr wlan_wep 4 , +.Xr ifconfig 8 , +.Xr wpa_supplicant 8 +.Sh HISTORY +The +.Nm +driver first appeared in +.Ox 5.8 . +.Sh AUTHORS +The +.Nm +driver was written by +.An -nosplit +.An Stefan Sperling Aq Mt stsp@openbsd.org +and ported by +.An Kevin Lo Aq Mt kevlo@freebsd.org . +It was based on the +.Xr urtwn 4 +driver written by +.An Damien Bergamini Aq Mt damien.bergamini@free.fr . +.Sh CAVEATS +The +.Nm +driver does not support any of the 802.11n capabilities offered by the +adapters. +Additional work is required in +.Xr ieee80211 9 +before those features can be supported. diff --git a/share/man/man4/rtwnfw.4 b/share/man/man4/rtwnfw.4 new file mode 100644 index 0000000..e4ab346 --- /dev/null +++ b/share/man/man4/rtwnfw.4 @@ -0,0 +1,74 @@ +.\" Copyright (c) 2015 Kevin Lo +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd October 28, 2015 +.Dt RTWNFW 4 +.Os +.Sh NAME +.Nm rtwnfw +.Nd "Firmware Module for Realtek Wireless driver" +.Sh SYNOPSIS +To compile this module into the kernel, +place the following line in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device rtwnfw" +.Ed +.Pp +This will include three firmware images inside the kernel. +If you want to pick only the firmware image for your network adapter choose one +of the following: +.Bd -ragged -offset indent +.Cd "device rtwn-rtl8192cfwU" +.Cd "device rtwn-rtl8192cfwU_B" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +rtwn-rtl8192cfwU_load="YES" +rtwn-rtl8192cfwU_B_load="YES" +.Ed +.Sh DESCRIPTION +This module provides access to firmware sets for the +Realtek RTL8188CE chip based PCIe adapters. +It may be +statically linked into the kernel, or loaded as a module. +.Pp +For the loaded firmware to be enabled for use the license at +.Pa /usr/share/doc/legal/realtek.LICENSE +must be agreed to by adding the following line to +.Xr loader.conf 5 : +.Pp +.Dl "legal.realtek.license_ack=1" +.Sh FILES +.Bl -tag -width ".Pa /usr/share/doc/legal/realtek.LICENSE" -compact +.It Pa /usr/share/doc/legal/realtek.LICENSE +.Nm +firmware license +.El +.Sh SEE ALSO +.Xr rtwn 4 , +.Xr firmware 9 diff --git a/share/man/man4/splash.4 b/share/man/man4/splash.4 index 5c3d6e6..fdc770f 100644 --- a/share/man/man4/splash.4 +++ b/share/man/man4/splash.4 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 29, 2010 +.Dd December 31, 2015 .Dt SPLASH 4 .Os .Sh NAME @@ -130,6 +130,8 @@ the screen will also be powered off. Animated graphical .Fx logo. +.It Pa plasma_saver.ko +Draws an animated interference pattern. .It Pa rain_saver.ko Draws a shower on the screen. .It Pa snake_saver.ko @@ -282,6 +284,14 @@ based on the code, with some additional inspiration from the .Pa daemon_saver code. +The +.Pa logo_saver , +.Pa plasma_saver , +.Pa rain_saver +and +.Pa warp_saver +modules were written by +.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org . .Sh CAVEATS Both the splash screen and the screen saver work with .Xr syscons 4 diff --git a/share/man/man4/uart.4 b/share/man/man4/uart.4 index 3fca2f8..138e049 100644 --- a/share/man/man4/uart.4 +++ b/share/man/man4/uart.4 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 10, 2015 +.Dd December 9, 2015 .Dt UART 4 .Os .Sh NAME @@ -160,7 +160,9 @@ The API, accessed via is available on the tty device. To use the PPS capture feature with .Xr ntpd 8 , -symlink the tty device to +symlink the tty callout device +.Va /dev/cuau? +to .Va /dev/pps0. .Pp The @@ -175,15 +177,54 @@ it can be set in .Xr loader.conf 5 or .Xr sysctl.conf 5 . +.Pp The following capture modes are available: .Bl -tag -compact -offset "mmmm" -width "mmmm" -.It 0 +.It 0x00 Capture disabled. -.It 1 +.It 0x01 Capture pulses on the CTS line. -.It 2 -Capture pulses on the DCD line (default). +.It 0x02 +Capture pulses on the DCD line. +.El +.Pp +The following values may be ORed with the capture mode to configure +capture processing options: +.Bl -tag -compact -offset "mmmm" -width "mmmm" +.It 0x10 +Invert the pulse (RS-232 logic low = ASSERT, high = CLEAR). +.It 0x20 +Attempt to capture narrow pulses. .El +.Pp +Add the narrow pulse option when the incoming PPS pulse width is small +enough to prevent reliable capture in normal mode. +In narrow mode the driver uses the hardware's ability to latch a line +state change; not all hardware has this capability. +The hardware latch provides a reliable indication that a pulse occurred, +but prevents distinguishing between the CLEAR and ASSERT edges of the pulse. +For each detected pulse, the driver synthesizes both an ASSERT and a CLEAR +event, using the same timestamp for each. +To prevent spurious events when the hardware is intermittently able to +see both edges of a pulse, the driver will not generate a new pair of +events within a half second of the prior pair. +Both normal and narrow pulse modes work with +.Xr ntpd 8 . +.Pp +Add the invert option when the connection to the uart device uses TTL +level signals, or when the PPS source emits inverted pulses. +RFC 2783 defines an ASSERT event as a higher-voltage line level, and a CLEAR +event as a lower-voltage line level, in the context of the RS-232 protocol. +The modem control signals on a TTL-level connection are typically +inverted from the RS-232 levels. +For example, carrier presence is indicated by a high signal on an RS-232 +DCD line, and by a low signal on a TTL DCD line. +This is due to the use of inverting line driver buffers to convert between +TTL and RS-232 line levels in most hardware designs. +Generally speaking, a connection to a DB-9 style connector is an RS-232 +level signal at up to 12 volts. +A connection to header pins or an edge-connector on an embedded board +is typically a TTL signal at 3.3 or 5 volts. .Sh FILES .Bl -tag -width ".Pa /dev/ttyu?.init" -compact .It Pa /dev/ttyu? diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 index 4994aab..60bf53a 100644 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -1,7 +1,7 @@ .\" DO NOT EDIT-- this file is automatically generated. .\" from FreeBSD: head/tools/build/options/makeman 292283 2015-12-15 18:42:30Z bdrewery .\" $FreeBSD$ -.Dd December 15, 2015 +.Dd January 9, 2016 .Dt SRC.CONF 5 .Os .Sh NAME @@ -948,9 +948,30 @@ Set to not build the .Nm libthr (1:1 threading) library. +.It Va WITHOUT_LLDB +.\" from FreeBSD: head/tools/build/options/WITHOUT_LLDB 289275 2015-10-14 00:23:31Z emaste +Set to not build the LLDB debugger. +.Pp +It is a default setting on +arm/arm, arm/armeb, arm/armv6, arm/armv6hf, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, pc98/i386, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64. .It Va WITH_LLDB .\" from FreeBSD: head/tools/build/options/WITH_LLDB 255722 2013-09-20 01:52:02Z emaste Set to build the LLDB debugger. +.Pp +It is a default setting on +amd64/amd64 and arm64/aarch64. +.It Va WITHOUT_LLVM_LIBUNWIND +.\" from FreeBSD: head/tools/build/options/WITHOUT_LLVM_LIBUNWIND 293450 2016-01-09 00:42:07Z emaste +Set to use GCC's stack unwinder (instead of LLVM's libunwind). +.Pp +It is a default setting on +amd64/amd64, arm/arm, arm/armeb, arm/armv6, arm/armv6hf, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, pc98/i386, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64. +.It Va WITH_LLVM_LIBUNWIND +.\" from FreeBSD: head/tools/build/options/WITH_LLVM_LIBUNWIND 293450 2016-01-09 00:42:07Z emaste +Set to use LLVM's libunwind stack unwinder (instead of GCC's unwinder). +.Pp +It is a default setting on +arm64/aarch64. .It Va WITHOUT_LOCALES .\" from FreeBSD: head/tools/build/options/WITHOUT_LOCALES 156932 2006-03-21 07:50:50Z ru Set to not build localization files; see diff --git a/share/man/man7/ascii.7 b/share/man/man7/ascii.7 index a9c75ad..aa02af9 100644 --- a/share/man/man7/ascii.7 +++ b/share/man/man7/ascii.7 @@ -28,7 +28,7 @@ .\" @(#)ascii.7 8.1 (Berkeley) 6/5/93 .\" $FreeBSD$ .\" -.Dd June 5, 1993 +.Dd January 6, 2016 .Dt ASCII 7 .Os .Sh NAME @@ -42,7 +42,7 @@ The set: .Bd -literal -offset left 000 NUL 001 SOH 002 STX 003 ETX 004 EOT 005 ENQ 006 ACK 007 BEL -010 BS 011 HT 012 NL 013 VT 014 NP 015 CR 016 SO 017 SI +010 BS 011 HT 012 LF 013 VT 014 FF 015 CR 016 SO 017 SI 020 DLE 021 DC1 022 DC2 023 DC3 024 DC4 025 NAK 026 SYN 027 ETB 030 CAN 031 EM 032 SUB 033 ESC 034 FS 035 GS 036 RS 037 US 040 SP 041 ! 042 " 043 # 044 $ 045 % 046 & 047 ' @@ -64,7 +64,7 @@ The set: .Bd -literal -offset left 00 NUL 01 SOH 02 STX 03 ETX 04 EOT 05 ENQ 06 ACK 07 BEL -08 BS 09 HT 0A NL 0B VT 0C NP 0D CR 0E SO 0F SI +08 BS 09 HT 0A LF 0B VT 0C FF 0D CR 0E SO 0F SI 10 DLE 11 DC1 12 DC2 13 DC3 14 DC4 15 NAK 16 SYN 17 ETB 18 CAN 19 EM 1A SUB 1B ESC 1C FS 1D GS 1E RS 1F US 20 SP 21 ! 22 " 23 # 24 $ 25 % 26 & 27 ' @@ -86,7 +86,7 @@ The set: .Bd -literal -offset left 0 NUL 1 SOH 2 STX 3 ETX 4 EOT 5 ENQ 6 ACK 7 BEL - 8 BS 9 HT 10 NL 11 VT 12 NP 13 CR 14 SO 15 SI + 8 BS 9 HT 10 LF 11 VT 12 FF 13 CR 14 SO 15 SI 16 DLE 17 DC1 18 DC2 19 DC3 20 DC4 21 NAK 22 SYN 23 ETB 24 CAN 25 EM 26 SUB 27 ESC 28 FS 29 GS 30 RS 31 US 32 SP 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' diff --git a/share/man/man9/DEVICE_PROBE.9 b/share/man/man9/DEVICE_PROBE.9 index 86b8339..5fef21f 100644 --- a/share/man/man9/DEVICE_PROBE.9 +++ b/share/man/man9/DEVICE_PROBE.9 @@ -100,7 +100,8 @@ This is for source or binary drivers that are not yet integrated into the tree. Its use in the base OS is prohibited. .It BUS_PROBE_DEFAULT -The device is a normal device matching some plug and play ID. This is +The device is a normal device matching some plug and play ID. +This is the normal return value for drivers to use. It is intended that nearly all of the drivers in the tree should return this value. diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index 3cd6f7f..def2936 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -1013,7 +1013,8 @@ MLINKS+=make_dev.9 destroy_dev.9 \ make_dev.9 make_dev_alias_p.9 \ make_dev.9 make_dev_cred.9 \ make_dev.9 make_dev_credf.9 \ - make_dev.9 make_dev_p.9 + make_dev.9 make_dev_p.9 \ + make_dev.9 make_dev_s.9 MLINKS+=malloc.9 free.9 \ malloc.9 MALLOC_DECLARE.9 \ malloc.9 MALLOC_DEFINE.9 \ diff --git a/share/man/man9/kern_testfrwk.9 b/share/man/man9/kern_testfrwk.9 index 0838c72..653cb5e 100644 --- a/share/man/man9/kern_testfrwk.9 +++ b/share/man/man9/kern_testfrwk.9 @@ -65,7 +65,6 @@ When your test loads, you register your tests with the kernel test framework. You do that through a call to .Fn kern_testframework_register . Usually this is done at the module load event as shown below: -.Pp .Bd -literal -offset indent switch (type) { case MOD_LOAD: @@ -122,7 +121,6 @@ field is a test-specific set of information that is an opaque blob. It is passed in from user space and has a maximum size of 256 bytes. You can pass arbitrary test input in the space. In the case of callout_test we reshape that to: -.Pp .Bd -literal -offset indent struct callout_test { int number_of_callouts; @@ -133,7 +131,6 @@ struct callout_test { So the first lines of .Fn run_callout_test does the following to get at the user specific data: -.Pp .\" This is a bad example and violates strict aliasing. It should be replaced. .Bd -literal -offset indent struct callout_test *u; diff --git a/share/man/man9/make_dev.9 b/share/man/man9/make_dev.9 index 78345fa..0c53e8d 100644 --- a/share/man/man9/make_dev.9 +++ b/share/man/man9/make_dev.9 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd Dec 22, 2012 +.Dd Jan 3, 2016 .Dt MAKE_DEV 9 .Os .Sh NAME @@ -32,6 +32,7 @@ .Nm make_dev_cred , .Nm make_dev_credf , .Nm make_dev_p , +.Nm make_dev_s , .Nm make_dev_alias , .Nm make_dev_alias_p , .Nm destroy_dev , @@ -45,16 +46,10 @@ and DEVFS registration for devices .Sh SYNOPSIS .In sys/param.h .In sys/conf.h -.Ft struct cdev * -.Fn make_dev "struct cdevsw *cdevsw" "int unit" "uid_t uid" "gid_t gid" "int perms" "const char *fmt" ... -.Ft struct cdev * -.Fn make_dev_cred "struct cdevsw *cdevsw" "int unit" "struct ucred *cr" "uid_t uid" "gid_t gid" "int perms" "const char *fmt" ... -.Ft struct cdev * -.Fn make_dev_credf "int flags" "struct cdevsw *cdevsw" "int unit" "struct ucred *cr" "uid_t uid" "gid_t gid" "int perms" "const char *fmt" ... +.Ft void +.Fn make_dev_args_init "struct make_dev_args *args" .Ft int -.Fn make_dev_p "int flags" "struct cdev **cdev" "struct cdevsw *devsw" "struct ucred *cr" "uid_t uid" "gid_t gid" "int mode" "const char *fmt" ... -.Ft struct cdev * -.Fn make_dev_alias "struct cdev *pdev" "const char *fmt" ... +.Fn make_dev_s "struct make_dev_args *args" "struct cdev **cdev" "const char *fmt" ... .Ft int .Fn make_dev_alias_p "int flags" "struct cdev **cdev" "struct cdev *pdev" "const char *fmt" ... .Ft void @@ -67,12 +62,26 @@ and DEVFS registration for devices .Fn destroy_dev_drain "struct cdevsw *csw" .Ft void .Fn dev_depends "struct cdev *pdev" "struct cdev *cdev" +.Pp +LEGACY INTERFACES +.Ft struct cdev * +.Fn make_dev "struct cdevsw *cdevsw" "int unit" "uid_t uid" "gid_t gid" "int perms" "const char *fmt" ... +.Ft struct cdev * +.Fn make_dev_cred "struct cdevsw *cdevsw" "int unit" "struct ucred *cr" "uid_t uid" "gid_t gid" "int perms" "const char *fmt" ... +.Ft struct cdev * +.Fn make_dev_credf "int flags" "struct cdevsw *cdevsw" "int unit" "struct ucred *cr" "uid_t uid" "gid_t gid" "int perms" "const char *fmt" ... +.Ft int +.Fn make_dev_p "int flags" "struct cdev **cdev" "struct cdevsw *devsw" "struct ucred *cr" "uid_t uid" "gid_t gid" "int mode" "const char *fmt" ... +.Ft struct cdev * +.Fn make_dev_alias "struct cdev *pdev" "const char *fmt" ... .Sh DESCRIPTION The -.Fn make_dev_credf +.Fn make_dev_s function creates a .Fa cdev -structure for a new device. +structure for a new device, which is returned into the +.Fa cdev +argument. It also notifies .Xr devfs 5 of the presence of the new device, that causes corresponding nodes @@ -80,10 +89,34 @@ to be created. Besides this, a .Xr devctl 4 notification is sent. -The device will be owned by -.Va uid , +The function takes the structure +.Va struct make_dev_args args , +which specifies the parameters for the device creation: +.Pp +.Bd -literal -offset indent -compact +struct make_dev_args { + size_t mda_size; + int mda_flags; + struct cdevsw *mda_devsw; + struct ucred *mda_cr; + uid_t mda_uid; + gid_t mda_gid; + int mda_mode; + int mda_unit; + void *mda_si_drv1; + void *mda_si_drv2; +}; +.Ed +Before use and filling with the desired values, the structure must be +initialized by the +.Fn make_dev_args_init +function, which ensures that future kernel interface expansion does +not affect driver source code or binary interface. +.Pp +The created device will be owned by +.Va args.mda_uid , with the group ownership as -.Va gid . +.Va args.mda_gid . The name is the expansion of .Va fmt and following arguments as @@ -97,7 +130,7 @@ mount point and may contain slash .Ql / characters to denote subdirectories. The permissions of the file specified in -.Va perms +.Va args.mda_mode are defined in .In sys/stat.h : .Pp @@ -126,29 +159,28 @@ are defined in .Ed .Pp The -.Va cr +.Va args.mda_cr argument specifies credentials that will be stored in the .Fa si_cred member of the initialized .Fa struct cdev . +.Pp The -.Va flags +.Va args.mda_flags argument alters the operation of -.Fn make_dev_credf -or -.Fn make_dev_p . +.Fn make_dev_s. The following values are currently accepted: .Pp -.Bl -tag -width "MAKEDEV_CHECKNAME" -compact -offset indent -.It MAKEDEV_REF +.Bl -tag -width "It Dv MAKEDEV_CHECKNAME" -compact -offset indent +.It Dv MAKEDEV_REF reference the created device -.It MAKEDEV_NOWAIT +.It Dv MAKEDEV_NOWAIT do not sleep, the call may fail -.It MAKEDEV_WAITOK +.It Dv MAKEDEV_WAITOK allow the function to sleep to satisfy malloc -.It MAKEDEV_ETERNAL +.It Dv MAKEDEV_ETERNAL created device will be never destroyed -.It MAKEDEV_CHECKNAME +.It Dv MAKEDEV_CHECKNAME return an error if the device name is invalid or already exists .El .Pp @@ -189,10 +221,49 @@ For the convenience, use the flag for the code that can be compiled into kernel or loaded (and unloaded) as loadable module. .Pp -A panic will occur if the MAKEDEV_CHECKNAME flag is not specified +A panic will occur if the +.Dv MAKEDEV_CHECKNAME +flag is not specified and the device name is invalid or already exists. .Pp The +.Fn make_dev_p +use of the form +.Bd -literal -offset indent +struct cdev *dev; +int res; +res = make_dev_p(flags, &dev, cdevsw, cred, uid, gid, perms, name); +.Ed +is equivalent to the code +.Bd -literal -offset indent +struct cdev *dev; +struct make_dev_args args; +int res; + +make_dev_args_init(&args); +args.mda_flags = flags; +args.mda_devsw = cdevsw; +args.mda_cred = cred; +args.mda_uid = uid; +args.mda_gid = gid; +args.mda_mode = perms; +res = make_dev_s(&args, &dev, name); +.Ed +.Pp +Similarly, the +.Fn make_dev_credf +function call is equivalent to +.Bd -literal -offset indent + (void) make_dev_s(&args, &dev, name); +.Ed +In other words, +.Fn make_dev_credf +does not allow the caller to obtain the return value, and in +kernels compiled with the +.Va INVARIANTS +options, the function asserts that the device creation succeeded. +.Pp +The .Fn make_dev_cred function is equivalent to the call .Bd -literal -offset indent @@ -207,45 +278,55 @@ make_dev_credf(0, cdevsw, unit, NULL, uid, gid, perms, fmt, ...); .Ed .Pp The -.Fn make_dev_p -function is similar to -.Fn make_dev_credf -but it may return an error number and takes a pointer to the resulting -.Ft *cdev -as an argument. -.Pp -The -.Fn make_dev_alias +.Fn make_dev_alias_p function takes the returned .Ft cdev from .Fn make_dev and makes another (aliased) name for this device. It is an error to call -.Fn make_dev_alias +.Fn make_dev_alias_p prior to calling .Fn make_dev . .Pp -.Fn make_dev_alias_p +The +.Fn make_dev_alias function is similar to .Fn make_dev_alias -but it takes a pointer to the resulting +but it returns the resulting aliasing .Ft *cdev -as an argument and may return an error. +and may not return an error. .Pp The .Fa cdev returned by -.Fn make_dev +.Fn make_dev_s and -.Fn make_dev_alias +.Fn make_dev_alias_p has two fields, .Fa si_drv1 and .Fa si_drv2 , that are available to store state. Both fields are of type -.Ft void * . +.Ft void * , +and can be initialized simultaneously with the +.Va cdev +allocation by filling +.Va args.mda_si_drv1 +and +.Va args.mda_si_drv2 +members of the +.Fn make_dev_s +argument structure, or filled after the +.Va cdev +is allocated, if using legacy interfaces. +In the latter case, the driver should handle the race of +accessing uninitialized +.Va si_drv1 +and +.Va si_drv2 +itself. These are designed to replace the .Fa unit argument to @@ -331,8 +412,10 @@ unload until is actually finished for all of them. .Sh RETURN VALUES If successful, +.Fn make_dev_s +and .Fn make_dev_p -will return 0, otherwise it will return an error. +will return 0, otherwise they will return an error. If successful, .Fn make_dev_credf will return a valid @@ -341,10 +424,11 @@ pointer, otherwise it will return .Dv NULL . .Sh ERRORS The +.Fn make_dev_s , .Fn make_dev_p and .Fn make_dev_alias_p -call will fail and the device will be not registered if: +calls will fail and the device will be not registered if: .Bl -tag -width Er .It Bq Er ENOMEM The @@ -403,3 +487,7 @@ The function .Fn make_dev_p first appeared in .Fx 8.2 . +The function +.Fn make_dev_s +first appeared in +.Fx 11.0 . diff --git a/share/man/man9/malloc.9 b/share/man/man9/malloc.9 index eec2c86..81d40dc 100644 --- a/share/man/man9/malloc.9 +++ b/share/man/man9/malloc.9 @@ -229,7 +229,7 @@ may sleep when called with never sleeps. However, .Fn malloc , -.Fn realloc, +.Fn realloc , .Fn reallocf and .Fn free diff --git a/share/man/man9/timeout.9 b/share/man/man9/timeout.9 index 58905bc..3f5b4dc 100644 --- a/share/man/man9/timeout.9 +++ b/share/man/man9/timeout.9 @@ -261,7 +261,7 @@ returns zero it will arrange for the function .Fa drain to be called using the same argument given to the .Fn callout_reset -function. +function. .Fn callout_async_drain If the callout has an associated lock, then that lock must be held when this function is called. diff --git a/share/misc/ascii b/share/misc/ascii index b7bcef5..2a71a43 100644 --- a/share/misc/ascii +++ b/share/misc/ascii @@ -1,5 +1,5 @@ |000 nul|001 soh|002 stx|003 etx|004 eot|005 enq|006 ack|007 bel| -|010 bs |011 ht |012 nl |013 vt |014 np |015 cr |016 so |017 si | +|010 bs |011 ht |012 lf |013 vt |014 ff |015 cr |016 so |017 si | |020 dle|021 dc1|022 dc2|023 dc3|024 dc4|025 nak|026 syn|027 etb| |030 can|031 em |032 sub|033 esc|034 fs |035 gs |036 rs |037 us | |040 sp |041 ! |042 " |043 # |044 $ |045 % |046 & |047 ' | @@ -16,7 +16,7 @@ |170 x |171 y |172 z |173 { |174 | |175 } |176 ~ |177 del| | 00 nul| 01 soh| 02 stx| 03 etx| 04 eot| 05 enq| 06 ack| 07 bel| -| 08 bs | 09 ht | 0a nl | 0b vt | 0c np | 0d cr | 0e so | 0f si | +| 08 bs | 09 ht | 0a lf | 0b vt | 0c ff | 0d cr | 0e so | 0f si | | 10 dle| 11 dc1| 12 dc2| 13 dc3| 14 dc4| 15 nak| 16 syn| 17 etb| | 18 can| 19 em | 1a sub| 1b esc| 1c fs | 1d gs | 1e rs | 1f us | | 20 sp | 21 ! | 22 " | 23 # | 24 $ | 25 % | 26 & | 27 ' | @@ -33,7 +33,7 @@ | 78 x | 79 y | 7a z | 7b { | 7c | | 7d } | 7e ~ | 7f del| | 0 nul| 1 soh| 2 stx| 3 etx| 4 eot| 5 enq| 6 ack| 7 bel| -| 8 bs | 9 ht | 10 nl | 11 vt | 12 np | 13 cr | 14 so | 15 si | +| 8 bs | 9 ht | 10 lf | 11 vt | 12 ff | 13 cr | 14 so | 15 si | | 16 dle| 17 dc1| 18 dc2| 19 dc3| 20 dc4| 21 nak| 22 syn| 23 etb| | 24 can| 25 em | 26 sub| 27 esc| 28 fs | 29 gs | 30 rs | 31 us | | 32 sp | 33 ! | 34 " | 35 # | 36 $ | 37 % | 38 & | 39 ' | diff --git a/share/misc/committers-src.dot b/share/misc/committers-src.dot index 24893fb..63012fd 100644 --- a/share/misc/committers-src.dot +++ b/share/misc/committers-src.dot @@ -344,6 +344,7 @@ adrian -> loos adrian -> monthadar adrian -> ray adrian -> rmh +adrian -> sephe ae -> melifaro @@ -404,6 +405,7 @@ das -> rodrigc delphij -> gabor delphij -> rafan +delphij -> sephe des -> anholt des -> hmp diff --git a/share/mk/bsd.compiler.mk b/share/mk/bsd.compiler.mk index d7763e4..dee6a1d 100644 --- a/share/mk/bsd.compiler.mk +++ b/share/mk/bsd.compiler.mk @@ -138,7 +138,7 @@ COMPILER_TYPE:= clang . endif .endif .if !defined(COMPILER_VERSION) -COMPILER_VERSION!=echo ${_v:M[1-9].[0-9]*} | awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}' +COMPILER_VERSION!=echo "${_v:M[1-9].[0-9]*}" | awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}' .endif .undef _v .endif diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index 65c4348..678c31e 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -180,6 +180,7 @@ __DEFAULT_NO_OPTIONS = \ DTRACE_TESTS \ EISA \ HESIOD \ + LIBSOFT \ NAND \ OFED \ OPENLDAP \ @@ -230,9 +231,9 @@ __DEFAULT_NO_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC # In-tree binutils/gcc are older versions without modern architecture support. .if ${__T} == "aarch64" || ${__T} == "riscv64" BROKEN_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP GCC GCC_BOOTSTRAP GDB -__DEFAULT_YES_OPTIONS+=ELFCOPY_AS_OBJCOPY +__DEFAULT_YES_OPTIONS+=ELFCOPY_AS_OBJCOPY LLVM_LIBUNWIND .else -__DEFAULT_NO_OPTIONS+=ELFCOPY_AS_OBJCOPY +__DEFAULT_NO_OPTIONS+=ELFCOPY_AS_OBJCOPY LLVM_LIBUNWIND .endif .if ${__T} == "riscv64" BROKEN_OPTIONS+=PROFILE # "sorry, unimplemented: profiler support for RISC-V" @@ -248,6 +249,10 @@ __DEFAULT_NO_OPTIONS+=LLDB .if ${__T} == "arm" || ${__T} == "armeb" BROKEN_OPTIONS+=LLDB .endif +# Only doing soft float API stuff on armv6 +.if ${__T} != "armv6" +BROKEN_OPTIONS+=LIBSOFT +.endif .include <bsd.mkopt.mk> diff --git a/share/vt/keymaps/gr.101.acc.kbd b/share/vt/keymaps/gr.101.acc.kbd index 89a931f..7e8e661 100644 --- a/share/vt/keymaps/gr.101.acc.kbd +++ b/share/vt/keymaps/gr.101.acc.kbd @@ -18,7 +18,7 @@ 009 '8' '*' nop nop '8' '*' nop nop O 010 '9' '(' nop nop '9' '(' nop nop O 011 '0' ')' nop nop '0' ')' nop nop O - 012 '-' '_' ns ns '-' '_' ns ns O + 012 '-' '_' us us '-' '_' us us O 013 '=' '+' nop nop '=' '+' nop nop O 014 bs bs del del bs bs del del O 015 ht btab nop nop ht btab nop nop O @@ -90,7 +90,7 @@ 081 fkey59 '3' '3' '3' '3' '3' '3' '3' N 082 fkey60 '0' '0' '0' '0' '0' '0' '0' N 083 del '.' '.' '.' '.' '.' boot boot N - 084 ns ns ns ns ns ns ns ns O + 084 us us us us us us us us O 085 nop nop nop nop nop nop nop nop O 086 '\' '|' nop nop '\' '|' nop nop O 087 fkey11 fkey23 fkey35 fkey47 scr11 scr11 scr11 scr11 O @@ -148,7 +148,7 @@ 137 '8' '*' nop nop '8' '*' nop nop O 138 '9' '(' nop nop '9' '(' nop nop O 139 '0' ')' nop nop '0' ')' nop nop O - 140 '-' '_' ns ns '-' '_' ns ns O + 140 '-' '_' us us '-' '_' us us O 141 '=' '+' nop nop '=' '+' nop nop O 142 bs bs del del bs bs del del O 143 ht btab nop nop ht btab nop nop O @@ -220,7 +220,7 @@ 209 fkey59 '3' '3' '3' '3' '3' '3' '3' N 210 fkey60 '0' '0' '0' '0' '0' '0' '0' N 211 del '.' '.' '.' '.' '.' boot boot N - 212 ns ns ns ns ns ns ns ns O + 212 us us us us us us us us O 213 nop nop nop nop nop nop nop nop O 214 '\' '|' nop nop '\' '|' nop nop O 215 fkey11 fkey23 fkey35 fkey47 scr11 scr11 scr11 scr11 O diff --git a/share/vt/keymaps/gr.elot.acc.kbd b/share/vt/keymaps/gr.elot.acc.kbd index 1a758a7..061717f 100644 --- a/share/vt/keymaps/gr.elot.acc.kbd +++ b/share/vt/keymaps/gr.elot.acc.kbd @@ -18,7 +18,7 @@ 009 '8' '*' nop nop '8' '*' nop nop O 010 '9' '(' nop nop '9' '(' nop nop O 011 '0' ')' nop nop '0' ')' nop nop O - 012 '-' '_' ns ns '-' '_' ns ns O + 012 '-' '_' us us '-' '_' us us O 013 '=' '+' nop nop '=' '+' nop nop O 014 bs bs del del bs bs del del O 015 ht btab nop nop ht btab nop nop O @@ -90,7 +90,7 @@ 081 fkey59 '3' '3' '3' '3' '3' '3' '3' N 082 fkey60 '0' '0' '0' '0' '0' '0' '0' N 083 del '.' '.' '.' '.' '.' boot boot N - 084 ns ns ns ns ns ns ns ns O + 084 us us us us us us us us O 085 nop nop nop nop nop nop nop nop O 086 '\' '|' nop nop '\' '|' nop nop O 087 fkey11 fkey23 fkey35 fkey47 scr11 scr11 scr11 scr11 O @@ -148,7 +148,7 @@ 137 '8' '*' nop nop '8' '*' nop nop O 138 '9' '(' nop nop '9' '(' nop nop O 139 '0' ')' nop nop '0' ')' nop nop O - 140 '-' '_' ns ns '-' '_' ns ns O + 140 '-' '_' us us '-' '_' us us O 141 '=' '+' nop nop '=' '+' nop nop O 142 bs bs del del bs bs del del O 143 ht btab nop nop ht btab nop nop O @@ -220,7 +220,7 @@ 209 fkey59 '3' '3' '3' '3' '3' '3' '3' N 210 fkey60 '0' '0' '0' '0' '0' '0' '0' N 211 del '.' '.' '.' '.' '.' boot boot N - 212 ns ns ns ns ns ns ns ns O + 212 us us us us us us us us O 213 nop nop nop nop nop nop nop nop O 214 '\' '|' nop nop '\' '|' nop nop O 215 fkey11 fkey23 fkey35 fkey47 scr11 scr11 scr11 scr11 O diff --git a/share/vt/keymaps/hu.101.kbd b/share/vt/keymaps/hu.101.kbd index 3101b36..07be2b1 100644 --- a/share/vt/keymaps/hu.101.kbd +++ b/share/vt/keymaps/hu.101.kbd @@ -46,7 +46,7 @@ 009 '8' '*' nop nop '8' '*' nop nop O 010 '9' '(' nop nop '9' '(' nop nop O 011 '0' ')' nop nop 0xf6 0xd6 nop nop O - 012 '-' '_' ns ns 0xfc 0xdc ns ns C + 012 '-' '_' us us 0xfc 0xdc us us C 013 '=' '+' nop nop 0xf3 0xd3 nop nop C 014 bs bs del del bs bs del del O 015 ht btab nop nop ht btab nop nop O @@ -175,7 +175,7 @@ 137 '8' '*' nop nop '8' '*' nop nop O 138 '9' '(' nop nop '9' '(' nop nop O 139 0xf6 0xd6 nop nop '0' ')' nop nop O - 140 0xfc 0xdc ns ns '-' '_' ns ns C + 140 0xfc 0xdc us us '-' '_' us us C 141 0xf3 0xd3 nop nop '=' '+' nop nop C 142 bs bs del del bs bs del del O 143 ht btab nop nop ht btab nop nop O diff --git a/share/vt/keymaps/hu.102.kbd b/share/vt/keymaps/hu.102.kbd index 532cbd8..244db9e 100644 --- a/share/vt/keymaps/hu.102.kbd +++ b/share/vt/keymaps/hu.102.kbd @@ -60,7 +60,7 @@ 050 'm' 'M' cr cr '<' nop cr cr C 051 ',' '?' nop nop ';' nop nop nop O 052 '.' ':' nop nop '>' nop nop nop O - 053 '-' '_' ns ns '*' nop nop nop O + 053 '-' '_' us us '*' nop nop nop O 054 rshift rshift rshift rshift rshift rshift rshift rshift O 055 '*' '*' '*' '*' '*' '*' '*' '*' O 056 lalt lalt lalt lalt lalt lalt lalt lalt O diff --git a/share/vt/keymaps/lt.kbd b/share/vt/keymaps/lt.kbd index 0f7ac09..ac8b17b 100644 --- a/share/vt/keymaps/lt.kbd +++ b/share/vt/keymaps/lt.kbd @@ -15,7 +15,7 @@ 009 '8' '*' nop nop 0x016b 0x0172 nop nop O 010 '9' '(' nop nop '9' '(' nop nop O 011 '0' ')' nop nop '0' ')' nop nop O - 012 '-' '_' ns ns '-' '_' ns ns O + 012 '-' '_' us us '-' '_' us us O 013 '=' '+' nop nop 0x017e 0x017d nop nop O 014 bs bs del del bs bs del del O 015 ht btab nop nop ht btab nop nop O @@ -87,7 +87,7 @@ 081 fkey59 '3' '3' '3' '3' '3' '3' '3' N 082 fkey60 '0' '0' '0' '0' '0' '0' '0' N 083 del '.' ',' ',' del ',' boot boot N - 084 ns ns ns ns ns ns ns ns O + 084 us us us us us us us us O 085 nop nop nop nop nop nop nop nop O 086 ralt ralt ralt ralt ralt ralt ralt ralt O 087 fkey11 fkey23 fkey35 fkey47 scr11 scr11 scr11 scr11 O @@ -143,7 +143,7 @@ 137 0x016b 0x016a nop nop '8' '*' nop nop C 138 '9' '(' nop nop '9' '(' nop nop O 139 '0' ')' nop nop '0' ')' nop nop O - 140 '-' '_' ns ns '-' '_' ns ns O + 140 '-' '_' us us '-' '_' us us O 141 0x017e 0x017d nop nop '=' '+' nop nop C 142 bs bs del del bs bs del del O 143 ht btab nop nop ht btab nop nop O @@ -215,7 +215,7 @@ 209 fkey59 '3' '3' '3' '3' '3' '3' '3' N 210 fkey60 '0' '0' '0' '0' '0' '0' '0' N 211 del ',' '.' '.' del '.' boot boot N - 212 ns ns ns ns ns ns ns ns O + 212 us us us us us us us us O 213 nop nop nop nop nop nop nop nop O 214 ralt ralt ralt ralt ralt ralt ralt ralt O 215 fkey11 fkey23 fkey35 fkey47 scr11 scr11 scr11 scr11 O diff --git a/share/vt/keymaps/pt.acc.kbd b/share/vt/keymaps/pt.acc.kbd index 02ee9b5..8b6ee3b 100644 --- a/share/vt/keymaps/pt.acc.kbd +++ b/share/vt/keymaps/pt.acc.kbd @@ -17,7 +17,7 @@ 009 '8' '(' nop nop '[' '*' nop nop O 010 '9' ')' nop nop ']' '(' nop nop O 011 '0' '=' nop nop '}' ')' nop nop O - 012 ''' '?' ns ns '-' '_' ns ns O + 012 ''' '?' us us '-' '_' us us O 013 '=' '+' nop nop '=' '+' nop nop O 014 bs bs del del bs bs del del O 015 ht btab nop nop ht btab nop nop O diff --git a/share/vt/keymaps/pt.kbd b/share/vt/keymaps/pt.kbd index 46f781e..addd275 100644 --- a/share/vt/keymaps/pt.kbd +++ b/share/vt/keymaps/pt.kbd @@ -17,7 +17,7 @@ 009 '8' '(' nop nop '[' '*' nop nop O 010 '9' ')' nop nop ']' '(' nop nop O 011 '0' '=' nop nop '}' ')' nop nop O - 012 ''' '?' ns ns '-' '_' ns ns O + 012 ''' '?' us us '-' '_' us us O 013 '=' '+' nop nop '=' '+' nop nop O 014 bs bs del del bs bs del del O 015 ht btab nop nop ht btab nop nop O diff --git a/share/vt/keymaps/ua.kbd b/share/vt/keymaps/ua.kbd index d031f1d..3c20b8e 100644 --- a/share/vt/keymaps/ua.kbd +++ b/share/vt/keymaps/ua.kbd @@ -15,7 +15,7 @@ 009 '8' '*' nop nop '8' ';' nop nop O 010 '9' '(' nop nop '9' '?' nop nop O 011 '0' ')' nop nop '0' '%' nop nop O - 012 '-' '_' ns ns '-' '_' ns ns O + 012 '-' '_' us us '-' '_' us us O 013 '=' '+' nop nop '=' '+' nop nop O 014 bs bs del del bs bs del del O 015 ht btab nop nop btab btab nop nop O @@ -144,7 +144,7 @@ 137 '8' ';' nop nop '8' '*' nop nop O 138 '9' '?' nop nop '9' '(' nop nop O 139 '0' '%' nop nop '0' ')' nop nop O - 140 '-' '_' ns ns '-' '_' ns ns O + 140 '-' '_' us us '-' '_' us us O 141 '=' '+' nop nop '=' '+' nop nop O 142 bs bs del del bs bs del del O 143 ht btab nop nop btab btab nop nop O diff --git a/share/vt/keymaps/ua.shift.alt.kbd b/share/vt/keymaps/ua.shift.alt.kbd index cef2c27..3159e9a 100644 --- a/share/vt/keymaps/ua.shift.alt.kbd +++ b/share/vt/keymaps/ua.shift.alt.kbd @@ -27,7 +27,7 @@ 009 '8' '*' nop nop '8' '*' nop nop O 010 '9' '(' nop nop '9' '(' nop nop O 011 '0' ')' nop nop '0' ')' nop nop O - 012 '-' '_' ns ns 0x0456 0x0406 0xf7 0xf7 O + 012 '-' '_' us us 0x0456 0x0406 0xf7 0xf7 O 013 '=' '+' nop nop 0x0454 0x0404 nop nop O 014 bs bs del del bs bs 0x042a 0x042a O 015 ht btab nop nop ht btab nop nop O @@ -155,7 +155,7 @@ 137 '8' '*' nop nop '8' '*' nop nop O 138 '9' '(' nop nop '9' '(' nop nop O 139 '0' ')' nop nop '0' ')' nop nop O - 140 0x0456 0x0406 ns ns '-' '_' 0xf7 0xf7 O + 140 0x0456 0x0406 us us '-' '_' 0xf7 0xf7 O 141 0x0454 0x0404 nop nop '=' '+' nop nop O 142 bs bs del del bs bs 0x042a 0x042a O 143 ht btab nop nop ht btab nop nop O diff --git a/sys/amd64/amd64/elf_machdep.c b/sys/amd64/amd64/elf_machdep.c index c6520f3..ca07adc 100644 --- a/sys/amd64/amd64/elf_machdep.c +++ b/sys/amd64/amd64/elf_machdep.c @@ -80,6 +80,7 @@ struct sysentvec elf64_freebsd_sysvec = { .sv_shared_page_len = PAGE_SIZE, .sv_schedtail = NULL, .sv_thread_detach = NULL, + .sv_trap = NULL, }; INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec); diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 6bf251f..1bf735f 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -1484,6 +1484,7 @@ static caddr_t native_parse_preload_data(u_int64_t modulep) { caddr_t kmdp; + char *envp; #ifdef DDB vm_offset_t ksym_start; vm_offset_t ksym_end; @@ -1495,7 +1496,10 @@ native_parse_preload_data(u_int64_t modulep) if (kmdp == NULL) kmdp = preload_search_by_type("elf64 kernel"); boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int); - kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *) + KERNBASE; + envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); + if (envp != NULL) + envp += KERNBASE; + init_static_kenv(envp, 0); #ifdef DDB ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t); ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t); diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index 776f90c..620a461 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -322,6 +322,13 @@ trap(struct trapframe *frame) break; case T_PAGEFLT: /* page fault */ + /* + * Emulator can take care about this trap? + */ + if (*p->p_sysent->sv_trap != NULL && + (*p->p_sysent->sv_trap)(td) == 0) + goto userout; + addr = frame->tf_addr; i = trap_pfault(frame, TRUE); if (i == -1) diff --git a/sys/amd64/include/metadata.h b/sys/amd64/include/metadata.h index e13eba0..98d0272 100644 --- a/sys/amd64/include/metadata.h +++ b/sys/amd64/include/metadata.h @@ -1,57 +1,6 @@ /*- - * Copyright (c) 2003 Peter Wemm <peter@FreeBSD.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ + * This file is in the public domain. */ +/* $FreeBSD$ */ -#ifndef _MACHINE_METADATA_H_ -#define _MACHINE_METADATA_H_ - -#define MODINFOMD_SMAP 0x1001 -#define MODINFOMD_SMAP_XATTR 0x1002 -#define MODINFOMD_DTBP 0x1003 -#define MODINFOMD_EFI_MAP 0x1004 -#define MODINFOMD_EFI_FB 0x1005 -#define MODINFOMD_MODULEP 0x1006 - -struct efi_map_header { - uint64_t memory_size; - uint64_t descriptor_size; - uint32_t descriptor_version; -}; - -struct efi_fb { - uint64_t fb_addr; - uint64_t fb_size; - uint32_t fb_height; - uint32_t fb_width; - uint32_t fb_stride; - uint32_t fb_mask_red; - uint32_t fb_mask_green; - uint32_t fb_mask_blue; - uint32_t fb_mask_reserved; -}; - -#endif /* !_MACHINE_METADATA_H_ */ +#include <x86/metadata.h> diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c index 96428b8..d49ca79 100644 --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -129,6 +129,7 @@ static void linux_set_syscall_retval(struct thread *td, int error); static int linux_fetch_syscall_args(struct thread *td, struct syscall_args *sa); static void linux_exec_setregs(struct thread *td, struct image_params *imgp, u_long stack); +static int linux_vsyscall(struct thread *td); /* * Linux syscalls return negative errno's, we do positive and map them @@ -746,6 +747,53 @@ exec_linux_imgact_try(struct image_params *imgp) return(error); } +#define LINUX_VSYSCALL_START (-10UL << 20) +#define LINUX_VSYSCALL_SZ 1024 + +const unsigned long linux_vsyscall_vector[] = { + LINUX_SYS_gettimeofday, + LINUX_SYS_linux_time, + /* getcpu not implemented */ +}; + +static int +linux_vsyscall(struct thread *td) +{ + struct trapframe *frame; + uint64_t retqaddr; + int code, traced; + int error; + + frame = td->td_frame; + + /* Check %rip for vsyscall area */ + if (__predict_true(frame->tf_rip < LINUX_VSYSCALL_START)) + return (EINVAL); + if ((frame->tf_rip & (LINUX_VSYSCALL_SZ - 1)) != 0) + return (EINVAL); + code = (frame->tf_rip - LINUX_VSYSCALL_START) / LINUX_VSYSCALL_SZ; + if (code >= nitems(linux_vsyscall_vector)) + return (EINVAL); + + /* + * vsyscall called as callq *(%rax), so we must + * use return address from %rsp and also fixup %rsp + */ + error = copyin((void *)frame->tf_rsp, &retqaddr, sizeof(retqaddr)); + if (error) + return (error); + + frame->tf_rip = retqaddr; + frame->tf_rax = linux_vsyscall_vector[code]; + frame->tf_rsp += 8; + + traced = (frame->tf_flags & PSL_T); + + amd64_syscall(td, traced); + + return (0); +} + struct sysentvec elf_linux_sysvec = { .sv_size = LINUX_SYS_MAXSYSCALL, .sv_table = linux_sysent, @@ -778,7 +826,8 @@ struct sysentvec elf_linux_sysvec = { .sv_shared_page_base = SHAREDPAGE, .sv_shared_page_len = PAGE_SIZE, .sv_schedtail = linux_schedtail, - .sv_thread_detach = linux_thread_detach + .sv_thread_detach = linux_thread_detach, + .sv_trap = linux_vsyscall, }; static void diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c index 693f003..7d3615e 100644 --- a/sys/amd64/linux32/linux32_sysvec.c +++ b/sys/amd64/linux32/linux32_sysvec.c @@ -1040,6 +1040,7 @@ struct sysentvec elf_linux_sysvec = { .sv_shared_page_len = PAGE_SIZE, .sv_schedtail = linux_schedtail, .sv_thread_detach = linux_thread_detach, + .sv_trap = NULL, }; static void diff --git a/sys/arm/arm/db_interface.c b/sys/arm/arm/db_interface.c index 25d1706..4383146 100644 --- a/sys/arm/arm/db_interface.c +++ b/sys/arm/arm/db_interface.c @@ -152,6 +152,10 @@ int db_frame(struct db_variable *vp, db_expr_t *valp, int rw) void db_show_mdpcpu(struct pcpu *pc) { + +#if __ARM_ARCH >= 6 + db_printf("curpmap = %p\n", pc->pc_curpmap); +#endif } int db_validate_address(vm_offset_t addr) diff --git a/sys/arm/arm/elf_machdep.c b/sys/arm/arm/elf_machdep.c index 02f7128..84b87f7 100644 --- a/sys/arm/arm/elf_machdep.c +++ b/sys/arm/arm/elf_machdep.c @@ -86,6 +86,7 @@ struct sysentvec elf32_freebsd_sysvec = { .sv_shared_page_len = PAGE_SIZE, .sv_schedtail = NULL, .sv_thread_detach = NULL, + .sv_trap = NULL, }; INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec); diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c index af7ee99..b8e3ffd 100644 --- a/sys/arm/arm/machdep.c +++ b/sys/arm/arm/machdep.c @@ -194,6 +194,8 @@ int _min_bzero_size = 0; extern int *end; #ifdef FDT +static char *loader_envp; + vm_paddr_t pmap_pa; #ifdef ARM_NEW_PMAP @@ -1002,6 +1004,8 @@ fake_preload_metadata(struct arm_boot_params *abp __unused) fake_preload[i] = 0; preload_metadata = (void *)fake_preload; + init_static_kenv(NULL, 0); + return (lastaddr); } @@ -1074,6 +1078,8 @@ linux_parse_boot_param(struct arm_boot_params *abp) bcopy(atag_list, atags, (char *)walker - (char *)atag_list + ATAG_SIZE(walker)); + init_static_kenv(NULL, 0); + return fake_preload_metadata(abp); } #endif @@ -1106,7 +1112,8 @@ freebsd_parse_boot_param(struct arm_boot_params *abp) return 0; boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int); - kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); + loader_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); + init_static_kenv(loader_envp, 0); lastaddr = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t); #ifdef DDB ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t); @@ -1429,13 +1436,13 @@ print_kenv(void) char *cp; debugf("loader passed (static) kenv:\n"); - if (kern_envp == NULL) { + if (loader_envp == NULL) { debugf(" no env, null ptr\n"); return; } - debugf(" kern_envp = 0x%08x\n", (uint32_t)kern_envp); + debugf(" loader_envp = 0x%08x\n", (uint32_t)loader_envp); - for (cp = kern_envp; cp != NULL; cp = kenv_next(cp)) + for (cp = loader_envp; cp != NULL; cp = kenv_next(cp)) debugf(" %x %s\n", (uint32_t)cp, cp); } diff --git a/sys/arm/arm/physmem.c b/sys/arm/arm/physmem.c index a922163..566ab85 100644 --- a/sys/arm/arm/physmem.c +++ b/sys/arm/arm/physmem.c @@ -161,7 +161,7 @@ static size_t regions_to_avail(vm_paddr_t *avail, uint32_t exflags, long *pavail) { size_t acnt, exi, hwi; - vm_paddr_t end, start, xend, xstart; + uint64_t end, start, xend, xstart; long availmem; const struct region *exp, *hwp; @@ -171,7 +171,7 @@ regions_to_avail(vm_paddr_t *avail, uint32_t exflags, long *pavail) for (hwi = 0, hwp = hwregions; hwi < hwcnt; ++hwi, ++hwp) { start = hwp->addr; end = hwp->size + start; - realmem += arm32_btop(end - start); + realmem += arm32_btop((vm_offset_t)(end - start)); for (exi = 0, exp = exregions; exi < excnt; ++exi, ++exp) { /* * If the excluded region does not match given flags, @@ -212,9 +212,10 @@ regions_to_avail(vm_paddr_t *avail, uint32_t exflags, long *pavail) * could affect the remainder of this hw region. */ if ((xstart > start) && (xend < end)) { - avail[acnt++] = start; - avail[acnt++] = xstart; - availmem += arm32_btop(xstart - start); + avail[acnt++] = (vm_paddr_t)start; + avail[acnt++] = (vm_paddr_t)xstart; + availmem += + arm32_btop((vm_offset_t)(xstart - start)); start = xend; continue; } @@ -233,9 +234,9 @@ regions_to_avail(vm_paddr_t *avail, uint32_t exflags, long *pavail) * available entry for it. */ if (end > start) { - avail[acnt++] = start; - avail[acnt++] = end; - availmem += arm32_btop(end - start); + avail[acnt++] = (vm_paddr_t)start; + avail[acnt++] = (vm_paddr_t)end; + availmem += arm32_btop((vm_offset_t)(end - start)); } if (acnt >= MAX_AVAIL_ENTRIES) panic("Not enough space in the dump/phys_avail arrays"); @@ -279,10 +280,22 @@ arm_physmem_hardware_region(vm_paddr_t pa, vm_size_t sz) /* * Filter out the page at PA 0x00000000. The VM can't handle it, as * pmap_extract() == 0 means failure. + * + * Also filter out the page at the end of the physical address space -- + * if addr is non-zero and addr+size is zero we wrapped to the next byte + * beyond what vm_paddr_t can express. That leads to a NULL pointer + * deref early in startup; work around it by leaving the last page out. + * + * XXX This just in: subtract out a whole megabyte, not just 1 page. + * Reducing the size by anything less than 1MB results in the NULL + * pointer deref in _vm_map_lock_read(). Better to give up a megabyte + * than leave some folks with an unusable system while we investigate. */ if (pa == 0) { pa = PAGE_SIZE; sz -= PAGE_SIZE; + } else if (pa + sz == 0) { + sz -= 1024 * 1024; } /* diff --git a/sys/arm/arm/pmap-v6-new.c b/sys/arm/arm/pmap-v6-new.c index 5d7e571..9a756cf 100644 --- a/sys/arm/arm/pmap-v6-new.c +++ b/sys/arm/arm/pmap-v6-new.c @@ -1109,7 +1109,7 @@ pmap_bootstrap(vm_offset_t firstaddr) * mapping of pages. */ #define SYSMAP(c, p, v, n) do { \ - v = (c)pmap_preboot_reserve_pages(1); \ + v = (c)pmap_preboot_reserve_pages(n); \ p = pt2map_entry((vm_offset_t)v); \ } while (0) diff --git a/sys/arm/xscale/ixp425/avila_machdep.c b/sys/arm/xscale/ixp425/avila_machdep.c index e48fbb6..e033e13 100644 --- a/sys/arm/xscale/ixp425/avila_machdep.c +++ b/sys/arm/xscale/ixp425/avila_machdep.c @@ -225,8 +225,8 @@ initarm(struct arm_boot_params *abp) pcpu_init(pcpup, 0, sizeof(struct pcpu)); PCPU_SET(curthread, &thread0); - if (envmode == 1) - kern_envp = static_env; + init_static_kenv(NULL, 0); + /* Do basic tuning, hz etc */ init_param1(); @@ -426,10 +426,6 @@ initarm(struct arm_boot_params *abp) init_param2(physmem); kdb_init(); - /* use static kernel environment if so configured */ - if (envmode == 1) - kern_envp = static_env; - return ((void *)(kernelstack.pv_va + USPACE_SVC_STACK_TOP - sizeof(struct pcb))); #undef next_page diff --git a/sys/arm64/arm64/elf_machdep.c b/sys/arm64/arm64/elf_machdep.c index 9ba2541..fb2c163 100644 --- a/sys/arm64/arm64/elf_machdep.c +++ b/sys/arm64/arm64/elf_machdep.c @@ -87,6 +87,8 @@ static struct sysentvec elf64_freebsd_sysvec = { .sv_shared_page_base = SHAREDPAGE, .sv_shared_page_len = PAGE_SIZE, .sv_schedtail = NULL, + .sv_thread_detach = NULL, + .sv_trap = NULL, }; INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec); diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index f7e1456..f256260 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -820,7 +820,7 @@ initarm(struct arm64_bootparams *abp) kmdp = preload_search_by_type("elf64 kernel"); boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int); - kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); + init_static_kenv(MD_FETCH(kmdp, MODINFOMD_ENVP, char *), 0); #ifdef FDT try_load_dtb(kmdp); diff --git a/sys/arm64/arm64/ofw_machdep.c b/sys/arm64/arm64/ofw_machdep.c new file mode 100644 index 0000000..6a0b714 --- /dev/null +++ b/sys/arm64/arm64/ofw_machdep.c @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 2015 Ian Lepore <ian@freebsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/bus.h> + +#include <machine/bus.h> + +#include <dev/ofw/openfirm.h> +#include <dev/ofw/ofw_subr.h> + +extern struct bus_space memmap_bus; + +int +OF_decode_addr(phandle_t dev, int regno, bus_space_tag_t *tag, + bus_space_handle_t *handle) +{ + bus_addr_t addr; + bus_size_t size; + int err; + + err = ofw_reg_to_paddr(dev, regno, &addr, &size, NULL); + if (err != 0) + return (err); + + *tag = &memmap_bus; + return (bus_space_map(*tag, addr, size, 0, handle)); +} diff --git a/sys/arm64/include/ofw_machdep.h b/sys/arm64/include/ofw_machdep.h index e9c65ef..511fc8d 100644 --- a/sys/arm64/include/ofw_machdep.h +++ b/sys/arm64/include/ofw_machdep.h @@ -41,7 +41,4 @@ struct mem_region { vm_size_t mr_size; }; -/* FDT follows ePAPR */ -#define OFW_EPAPR - #endif /* _MACHINE_OFW_MACHDEP_H_ */ diff --git a/sys/boot/arm64/libarm64/cache.c b/sys/boot/arm64/libarm64/cache.c index 2b3c0b1..25766ef 100644 --- a/sys/boot/arm64/libarm64/cache.c +++ b/sys/boot/arm64/libarm64/cache.c @@ -67,7 +67,7 @@ cpu_flush_dcache(const void *ptr, size_t len) cl_size = get_dcache_line_size(); /* Calculate end address to clean */ - end = (vm_offset_t)(ptr + len); + end = (vm_offset_t)ptr + (vm_offset_t)len; /* Align start address to cache line */ addr = (vm_offset_t)ptr; addr = rounddown2(addr, cl_size); diff --git a/sys/boot/common/load_elf.c b/sys/boot/common/load_elf.c index 7db1867..0ff1a15 100644 --- a/sys/boot/common/load_elf.c +++ b/sys/boot/common/load_elf.c @@ -886,7 +886,7 @@ __elfN(parse_modmetadata)(struct preloaded_file *fp, elf_file_t ef, error = __elfN(reloc_ptr)(fp, ef, v, &md, sizeof(md)); if (error == EOPNOTSUPP) { md.md_cval += ef->off; - md.md_data += ef->off; + md.md_data = (void *)((uintptr_t)md.md_data + ef->off); } else if (error != 0) return (error); #endif diff --git a/sys/boot/common/load_elf_obj.c b/sys/boot/common/load_elf_obj.c index 453bb79..869f020 100644 --- a/sys/boot/common/load_elf_obj.c +++ b/sys/boot/common/load_elf_obj.c @@ -520,10 +520,8 @@ __elfN(obj_symaddr)(struct elf_file *ef, Elf_Size symidx) { Elf_Sym sym; Elf_Addr base; - int symcnt; - symcnt = ef->e_shdr[ef->symtabindex].sh_size / sizeof(Elf_Sym); - if (symidx >= symcnt) + if (symidx >= ef->e_shdr[ef->symtabindex].sh_size / sizeof(Elf_Sym)) return (0); COPYOUT(ef->e_shdr[ef->symtabindex].sh_addr + symidx * sizeof(Elf_Sym), &sym, sizeof(sym)); diff --git a/sys/boot/common/misc.c b/sys/boot/common/misc.c index 990df61..9b938af 100644 --- a/sys/boot/common/misc.c +++ b/sys/boot/common/misc.c @@ -118,7 +118,6 @@ kern_bzero(vm_offset_t dest, size_t len) int kern_pread(int fd, vm_offset_t dest, size_t len, off_t off) { - ssize_t nread; if (lseek(fd, off, SEEK_SET) == -1) { #ifdef DEBUG @@ -126,8 +125,7 @@ kern_pread(int fd, vm_offset_t dest, size_t len, off_t off) #endif return (-1); } - nread = archsw.arch_readin(fd, dest, len); - if (nread != len) { + if ((size_t)archsw.arch_readin(fd, dest, len) != len) { #ifdef DEBUG printf("\nreadin failed\n"); #endif @@ -144,7 +142,6 @@ void * alloc_pread(int fd, off_t off, size_t len) { void *buf; - ssize_t nread; buf = malloc(len); if (buf == NULL) { @@ -160,8 +157,7 @@ alloc_pread(int fd, off_t off, size_t len) free(buf); return (NULL); } - nread = read(fd, buf, len); - if (nread != len) { + if ((size_t)read(fd, buf, len) != len) { #ifdef DEBUG printf("\nread failed\n"); #endif diff --git a/sys/boot/common/module.c b/sys/boot/common/module.c index 163814b..b01b497 100644 --- a/sys/boot/common/module.c +++ b/sys/boot/common/module.c @@ -983,7 +983,7 @@ moduledir_rebuild(void) { struct moduledir *mdp, *mtmp; const char *path, *cp, *ep; - int cplen; + size_t cplen; path = getenv("module_path"); if (path == NULL) diff --git a/sys/boot/common/part.c b/sys/boot/common/part.c index 8638f02..3fad5dd 100644 --- a/sys/boot/common/part.c +++ b/sys/boot/common/part.c @@ -102,7 +102,7 @@ static struct parttypes { const char * parttype2str(enum partition_type type) { - int i; + size_t i; for (i = 0; i < sizeof(ptypes) / sizeof(ptypes[0]); i++) if (ptypes[i].type == type) @@ -203,7 +203,7 @@ gpt_checktbl(const struct gpt_hdr *hdr, u_char *tbl, size_t size, uint64_t lba_last) { struct gpt_ent *ent; - int i, cnt; + uint32_t i, cnt; cnt = size / hdr->hdr_entsz; if (hdr->hdr_entries <= cnt) { @@ -234,8 +234,8 @@ ptable_gptread(struct ptable *table, void *dev, diskread_t dread) struct gpt_ent *ent; u_char *buf, *tbl; uint64_t offset; - int pri, sec, i; - size_t size; + int pri, sec; + size_t size, i; buf = malloc(table->sectorsize); if (buf == NULL) @@ -358,7 +358,7 @@ mbr_parttype(uint8_t type) return (PART_UNKNOWN); } -struct ptable* +static struct ptable* ptable_ebrread(struct ptable *table, void *dev, diskread_t dread) { struct dos_partition *dp; @@ -436,7 +436,7 @@ bsd_parttype(uint8_t type) return (PART_UNKNOWN); } -struct ptable* +static struct ptable* ptable_bsdread(struct ptable *table, void *dev, diskread_t dread) { struct disklabel *dl; diff --git a/sys/boot/common/self_reloc.c b/sys/boot/common/self_reloc.c index 9864a48..29b9c5f 100644 --- a/sys/boot/common/self_reloc.c +++ b/sys/boot/common/self_reloc.c @@ -61,6 +61,8 @@ __FBSDID("$FreeBSD$"); #define RELOC_TYPE_RELATIVE R_386_RELATIVE #endif +void self_reloc(Elf_Addr baseaddr, ElfW_Dyn *dynamic); + /* * A simple elf relocator. */ @@ -118,6 +120,6 @@ self_reloc(Elf_Addr baseaddr, ElfW_Dyn *dynamic) /* XXX: do we need other relocations ? */ break; } - rel = (ElfW_Rel *) ((caddr_t) rel + relent); + rel = (ElfW_Rel *)(void *)((caddr_t) rel + relent); } } diff --git a/sys/boot/common/ufsread.c b/sys/boot/common/ufsread.c index c02010f..acff1e5 100644 --- a/sys/boot/common/ufsread.c +++ b/sys/boot/common/ufsread.c @@ -207,11 +207,10 @@ fsread(ufs_ino_t inode, void *buf, size_t nbyte) #endif ) && fs.fs_bsize <= MAXBSIZE && - fs.fs_bsize >= sizeof(struct fs)) + fs.fs_bsize >= (int32_t)sizeof(struct fs)) break; } if (sblock_try[n] == -1) { - printf("Not ufs\n"); return -1; } dsk_meta++; @@ -232,10 +231,10 @@ fsread(ufs_ino_t inode, void *buf, size_t nbyte) sizeof(struct ufs2_dinode)); #else if (fs.fs_magic == FS_UFS1_MAGIC) - memcpy(&dp1, (struct ufs1_dinode *)blkbuf + n, + memcpy(&dp1, (struct ufs1_dinode *)(void *)blkbuf + n, sizeof(struct ufs1_dinode)); else - memcpy(&dp2, (struct ufs2_dinode *)blkbuf + n, + memcpy(&dp2, (struct ufs2_dinode *)(void *)blkbuf + n, sizeof(struct ufs2_dinode)); #endif inomap = inode; @@ -284,7 +283,7 @@ fsread(ufs_ino_t inode, void *buf, size_t nbyte) return -1; vbaddr = fsbtodb(&fs, addr2) + (off >> VBLKSHIFT) * DBPERVBLK; vboff = off & VBLKMASK; - n = sblksize(&fs, size, lbn) - (off & ~VBLKMASK); + n = sblksize(&fs, (off_t)size, lbn) - (off & ~VBLKMASK); if (n > VBLKSIZE) n = VBLKSIZE; if (blkmap != vbaddr) { diff --git a/sys/boot/efi/boot1/Makefile b/sys/boot/efi/boot1/Makefile index c1b3714..9a003ce 100644 --- a/sys/boot/efi/boot1/Makefile +++ b/sys/boot/efi/boot1/Makefile @@ -11,6 +11,7 @@ MK_SSP= no PROG= boot1.sym INTERNALPROG= +WARNS?= 6 # architecture-specific loader code SRCS= boot1.c self_reloc.c start.S @@ -41,14 +42,13 @@ CFLAGS+= -fPIC LDFLAGS+= -Wl,-znocombreloc .endif -.if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "i386" # # Add libstand for the runtime functions used by the compiler - for example # __aeabi_* (arm) or __divdi3 (i386). +# as well as required string and memory functions for all platforms. # DPADD+= ${LIBSTAND} LDADD+= -lstand -.endif DPADD+= ${LDSCRIPT} @@ -79,8 +79,15 @@ boot1.o: ${.CURDIR}/../../common/ufsread.c # created by generate-fat.sh .include "${.CURDIR}/Makefile.fat" +BOOT1_MAXSIZE?= 131072 boot1.efifat: boot1.efi + @set -- `ls -l boot1.efi`; \ + x=$$(($$5-${BOOT1_MAXSIZE})); \ + if [ $$x -ge 0 ]; then \ + echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\ + exit 1; \ + fi echo ${.OBJDIR} uudecode ${.CURDIR}/fat-${MACHINE}.tmpl.bz2.uu mv fat-${MACHINE}.tmpl.bz2 ${.TARGET}.bz2 diff --git a/sys/boot/efi/boot1/boot1.c b/sys/boot/efi/boot1/boot1.c index be59993..2b000e0 100644 --- a/sys/boot/efi/boot1/boot1.c +++ b/sys/boot/efi/boot1/boot1.c @@ -24,6 +24,7 @@ __FBSDID("$FreeBSD$"); #include <sys/dirent.h> #include <machine/elf.h> #include <machine/stdarg.h> +#include <stand.h> #include <efi.h> #include <eficonsctl.h> @@ -33,28 +34,9 @@ __FBSDID("$FreeBSD$"); #define BSIZEMAX 16384 -typedef int putc_func_t(char c, void *arg); - -struct sp_data { - char *sp_buf; - u_int sp_len; - u_int sp_size; -}; - -static const char digits[] = "0123456789abcdef"; - -static void panic(const char *fmt, ...) __dead2; -static int printf(const char *fmt, ...); -static int putchar(char c, void *arg); -static int vprintf(const char *fmt, va_list ap); -static int vsnprintf(char *str, size_t sz, const char *fmt, va_list ap); - -static int __printf(const char *fmt, putc_func_t *putc, void *arg, va_list ap); -static int __putc(char c, void *arg); -static int __puts(const char *s, putc_func_t *putc, void *arg); -static int __sputc(char c, void *arg); -static char *__uitoa(char *buf, u_int val, int base); -static char *__ultoa(char *buf, u_long val, int base); +void panic(const char *fmt, ...) __dead2; +void putchar(int c); +EFI_STATUS efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE* Xsystab); static int domount(EFI_DEVICE_PATH *device, EFI_BLOCK_IO *blkio, int quiet); static void load(const char *fname); @@ -62,39 +44,6 @@ static void load(const char *fname); static EFI_SYSTEM_TABLE *systab; static EFI_HANDLE *image; -static void -bcopy(const void *src, void *dst, size_t len) -{ - const char *s = src; - char *d = dst; - - while (len-- != 0) - *d++ = *s++; -} - -static void -memcpy(void *dst, const void *src, size_t len) -{ - bcopy(src, dst, len); -} - -static void -bzero(void *b, size_t len) -{ - char *p = b; - - while (len-- != 0) - *p++ = 0; -} - -static int -strcmp(const char *s1, const char *s2) -{ - for (; *s1 == *s2 && *s1; s1++, s2++) - ; - return ((u_char)*s1 - (u_char)*s2); -} - static EFI_GUID BlockIoProtocolGUID = BLOCK_IO_PROTOCOL; static EFI_GUID DevicePathGUID = DEVICE_PATH_PROTOCOL; static EFI_GUID LoadedImageGUID = LOADED_IMAGE_PROTOCOL; @@ -114,7 +63,7 @@ EFI_STATUS efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE* Xsystab) EFI_BOOT_SERVICES *BS; EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl = NULL; SIMPLE_TEXT_OUTPUT_INTERFACE *conout = NULL; - char *path = _PATH_LOADER; + const char *path = _PATH_LOADER; systab = Xsystab; image = Ximage; @@ -132,8 +81,7 @@ EFI_STATUS efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE* Xsystab) conout->Reset(conout, TRUE); max_dim = best_mode = 0; for (i = 0; ; i++) { - status = conout->QueryMode(conout, i, - &cols, &rows); + status = conout->QueryMode(conout, i, &cols, &rows); if (EFI_ERROR(status)) break; if (cols * rows > max_dim) { @@ -210,7 +158,6 @@ fsstat(ufs_ino_t inode) { #ifndef UFS2_ONLY static struct ufs1_dinode dp1; - ufs1_daddr_t addr1; #endif #ifndef UFS1_ONLY static struct ufs2_dinode dp2; @@ -219,11 +166,8 @@ fsstat(ufs_ino_t inode) static ufs_ino_t inomap; char *blkbuf; void *indbuf; - size_t n, nb, size, off, vboff; - ufs_lbn_t lbn; - ufs2_daddr_t addr2, vbaddr; + size_t n, size; static ufs2_daddr_t blkmap, indmap; - u_int u; blkbuf = dmadat->blkbuf; indbuf = dmadat->indbuf; @@ -247,11 +191,10 @@ fsstat(ufs_ino_t inode) #endif ) && fs.fs_bsize <= MAXBSIZE && - fs.fs_bsize >= sizeof(struct fs)) + fs.fs_bsize >= (int32_t)sizeof(struct fs)) break; } if (sblock_try[n] == -1) { - printf("Not ufs\n"); return -1; } dsk_meta++; @@ -272,10 +215,10 @@ fsstat(ufs_ino_t inode) sizeof(struct ufs2_dinode)); #else if (fs.fs_magic == FS_UFS1_MAGIC) - memcpy(&dp1, (struct ufs1_dinode *)blkbuf + n, + memcpy(&dp1, (struct ufs1_dinode *)(void *)blkbuf + n, sizeof(struct ufs1_dinode)); else - memcpy(&dp2, (struct ufs2_dinode *)blkbuf + n, + memcpy(&dp2, (struct ufs2_dinode *)(void *)blkbuf + n, sizeof(struct ufs2_dinode)); #endif inomap = inode; @@ -331,54 +274,38 @@ load(const char *fname) buffer, bufsize, &loaderhandle); if (EFI_ERROR(status)) printf("LoadImage failed with error %lu\n", - status & ~EFI_ERROR_MASK); + EFI_ERROR_CODE(status)); status = systab->BootServices->HandleProtocol(loaderhandle, &LoadedImageGUID, (VOID**)&loaded_image); if (EFI_ERROR(status)) printf("HandleProtocol failed with error %lu\n", - status & ~EFI_ERROR_MASK); + EFI_ERROR_CODE(status)); loaded_image->DeviceHandle = bootdevhandle; status = systab->BootServices->StartImage(loaderhandle, NULL, NULL); if (EFI_ERROR(status)) printf("StartImage failed with error %lu\n", - status & ~EFI_ERROR_MASK); + EFI_ERROR_CODE(status)); } -static void +void panic(const char *fmt, ...) { - char buf[128]; va_list ap; + printf("panic: "); va_start(ap, fmt); - vsnprintf(buf, sizeof buf, fmt, ap); - printf("panic: %s\n", buf); + vprintf(fmt, ap); va_end(ap); + printf("\n"); while (1) {} } -static int -printf(const char *fmt, ...) -{ - va_list ap; - int ret; - - /* Don't annoy the user as we probe for partitions */ - if (strcmp(fmt,"Not ufs\n") == 0) - return 0; - - va_start(ap, fmt); - ret = vprintf(fmt, ap); - va_end(ap); - return (ret); -} - -static int -putchar(char c, void *arg) +void +putchar(int c) { CHAR16 buf[2]; @@ -390,187 +317,4 @@ putchar(char c, void *arg) buf[0] = c; buf[1] = 0; systab->ConOut->OutputString(systab->ConOut, buf); - return (1); -} - -static int -vprintf(const char *fmt, va_list ap) -{ - int ret; - - ret = __printf(fmt, putchar, 0, ap); - return (ret); -} - -static int -vsnprintf(char *str, size_t sz, const char *fmt, va_list ap) -{ - struct sp_data sp; - int ret; - - sp.sp_buf = str; - sp.sp_len = 0; - sp.sp_size = sz; - ret = __printf(fmt, __sputc, &sp, ap); - return (ret); -} - -static int -__printf(const char *fmt, putc_func_t *putc, void *arg, va_list ap) -{ - char buf[(sizeof(long) * 8) + 1]; - char *nbuf; - u_long ul; - u_int ui; - int lflag; - int sflag; - char *s; - int pad; - int ret; - int c; - - nbuf = &buf[sizeof buf - 1]; - ret = 0; - while ((c = *fmt++) != 0) { - if (c != '%') { - ret += putc(c, arg); - continue; - } - lflag = 0; - sflag = 0; - pad = 0; -reswitch: c = *fmt++; - switch (c) { - case '#': - sflag = 1; - goto reswitch; - case '%': - ret += putc('%', arg); - break; - case 'c': - c = va_arg(ap, int); - ret += putc(c, arg); - break; - case 'd': - if (lflag == 0) { - ui = (u_int)va_arg(ap, int); - if (ui < (int)ui) { - ui = -ui; - ret += putc('-', arg); - } - s = __uitoa(nbuf, ui, 10); - } else { - ul = (u_long)va_arg(ap, long); - if (ul < (long)ul) { - ul = -ul; - ret += putc('-', arg); - } - s = __ultoa(nbuf, ul, 10); - } - ret += __puts(s, putc, arg); - break; - case 'l': - lflag = 1; - goto reswitch; - case 'o': - if (lflag == 0) { - ui = (u_int)va_arg(ap, u_int); - s = __uitoa(nbuf, ui, 8); - } else { - ul = (u_long)va_arg(ap, u_long); - s = __ultoa(nbuf, ul, 8); - } - ret += __puts(s, putc, arg); - break; - case 'p': - ul = (u_long)va_arg(ap, void *); - s = __ultoa(nbuf, ul, 16); - ret += __puts("0x", putc, arg); - ret += __puts(s, putc, arg); - break; - case 's': - s = va_arg(ap, char *); - ret += __puts(s, putc, arg); - break; - case 'u': - if (lflag == 0) { - ui = va_arg(ap, u_int); - s = __uitoa(nbuf, ui, 10); - } else { - ul = va_arg(ap, u_long); - s = __ultoa(nbuf, ul, 10); - } - ret += __puts(s, putc, arg); - break; - case 'x': - if (lflag == 0) { - ui = va_arg(ap, u_int); - s = __uitoa(nbuf, ui, 16); - } else { - ul = va_arg(ap, u_long); - s = __ultoa(nbuf, ul, 16); - } - if (sflag) - ret += __puts("0x", putc, arg); - ret += __puts(s, putc, arg); - break; - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - pad = pad * 10 + c - '0'; - goto reswitch; - default: - break; - } - } - return (ret); -} - -static int -__sputc(char c, void *arg) -{ - struct sp_data *sp; - - sp = arg; - if (sp->sp_len < sp->sp_size) - sp->sp_buf[sp->sp_len++] = c; - sp->sp_buf[sp->sp_len] = '\0'; - return (1); -} - -static int -__puts(const char *s, putc_func_t *putc, void *arg) -{ - const char *p; - int ret; - - ret = 0; - for (p = s; *p != '\0'; p++) - ret += putc(*p, arg); - return (ret); -} - -static char * -__uitoa(char *buf, u_int ui, int base) -{ - char *p; - - p = buf; - *p = '\0'; - do - *--p = digits[ui % base]; - while ((ui /= base) != 0); - return (p); -} - -static char * -__ultoa(char *buf, u_long ul, int base) -{ - char *p; - - p = buf; - *p = '\0'; - do - *--p = digits[ul % base]; - while ((ul /= base) != 0); - return (p); } diff --git a/sys/boot/efi/boot1/fat-amd64.tmpl.bz2.uu b/sys/boot/efi/boot1/fat-amd64.tmpl.bz2.uu index d8a44b7..85a4b0f 100644 --- a/sys/boot/efi/boot1/fat-amd64.tmpl.bz2.uu +++ b/sys/boot/efi/boot1/fat-amd64.tmpl.bz2.uu @@ -2,19 +2,25 @@ FAT template boot filesystem created by generate-fat.sh DO NOT EDIT $FreeBSD$ begin 644 fat-amd64.tmpl.bz2 -M0EIH.3%!629362AK*D(`&I+____[ZZKJZ_^N_ZO^Z_Z_OJ[L`4`!7I0$#&$" -M0$!$3&(<P`(;J*C:0E0E#30&AH`T````9#0```9````#)ZF0:,-3U/409,`) -M@`"8`C3",````$R:8F@P`C`````"24U,D>I-DTU,)ZAZ0VA-!M0T'J`>H#"9 -M'I#0-H&HQI&0&3&FH>H>*`JHHU3V]1%/4/2``T#0`!H``#0`````#1H,@``6 -M'1&G'&@?$6[T#A)?X8$A160"20BO#")0J4TB1*4GXF$B4I,&>43+=_?K=#3* -M6]<E0HE`UBF?(J%8BRF#?8OQ2'D)`)(EL2;F4.'R>R"ZNKJZI,9*68E8*E2Q -M4J5*E3'(1830A"$(12A-"<(0A#]VD)H0A"$,>I0FA"$(0I\>P^=F5:M6K5JU -M:DI3:64UN;[7%5B]Y-^\]@_K@B:N\/,5F%&H<\G#IXQXAEFC&D?![6%0'6MR -MX1@@%FC"FD`M7,/SXFNG:2`'-0<-C$8^+$N.7M1B,^6)9,DV9,0A\OL<:C"L -ML1V&,<\9YRB>XV#BG")'6NKRK^("UF2XO?_L!#29">MGDF$R3).!PX&%E,4C -M''=(FL1.`_3?CN@-IB2PI3!FF\<8X.X@D,>CA90I)#M$XRPNDFJELL<3=1?8 -M2B7\5Z64,!7Z;EEBW-MXN-4IJ@W$462]-*\YCR,-B,5[W?=3&L/U>SX,WV#\ -M\B`:I"'0Z)5"$1B.E)(K[5I4RS`%R$>Y\D0NR*,;<9CZ:^V3P(I?D<D#!UC) -D^M-HEE3SAN-8O0FQ$(`$(DF`?ZQ]'U2F_XNY(IPH2!0UE2$` +M0EIH.3%!62936;D*A>0`&T#_____ZZKJ[_^N_^O^Z_Z[OJ_NJ^JK^KZNKNNJ +MZ^KNZOJ^P`+\&$`!D#0T:`80&@T#`@`-`:9`:`P"`R::```:8)II@@,FC(-& +M$`!D,(:9`E5%&3_]*J?ZHC(--&@::#3)HQ#0`&C330,"9,F$::9!D#`F30#3 +M3)H9-&1DTR`R:,3"`&0-#1H!A`:#0,"``T!ID!H#`(#)IH``!I@FFF"`R:,@ +MT80`&0PAID!5)$)Y0@R&HQ#3U-I--,@-&0R-&@T-`&FF@9-!IIIH-&1ILHTT +M&ADQ#-$\B;1-/2-H93$\4\34Q9ZDM*M:U49"2K6F0C'21$(GD$1$085)7RB( +M00A7Q'^3"!"&CM$T+&UM5A49]7/"3^:EK7GMDVS9MRWK=+E>.(OG-?ZZMDA: +MR74C/HR\T0"$,Y+,YBA.JO&6C*K-DV26*@S24I%*E-2I4J5*JH43)*%"A0H4 +M*5-"E)2E2I4J5+!RPP]&&&&&&,P(9X]&&&&&&.IMKISQPX<.'#AP@0A"$(0A +M"$(0A"(MX]&&&&&&&$(0A"$(0(0A"$(?ME2N'#APX<.'"+EZ,,,,,,,($(0A +M"$0>NEGIM!8-(Y6FM$:.>9*3D219:RJKD^H2><E'K)-B^-<-VW[]G'7J_835 +MV`;*SC5&G@`GJ:N1`"ME+C<;GOI5H@!F'<0==<-#$2A&BJ%];5)UFHN9,G4? +M]G6ARV-EJBOU_NY'021>1%9\LD8<E236-:]ILVV?0M6\<%=N2Y;G.DQ&<9G; +MYJUNKRLLL]6X.TJQ;DFP1"P)D;"2W:]/XKP9*EC5W57(SUF^DRDD9N1\+:MN +MLGV-ZX"Y<5R'+7S`832.Y=383)I.'I9>O.X4EIVM=.HDTT1'B:J=8;[A9NLU +M"OX%C.X>0U/WZ^E74T&IHJ3EG))(^U[S\6_?HX;B.,Y*]7SGN@PV*_(O+^9# +M+^Q,N_S1'42+=METV+CK9;+US'.8#H,%B,9Y*RD-/)TYXB8XQHI(RLF')')< +MI>OZ<QW[FL!T6"X+#8C:LZZ5O?(VDD<W&Y\YA<5&NDFDA@-2Z#HNDWC!83#; +MMB/W8SIL=EC%D8\FXDOI':7&/BN`UTRVDB;11`(0E`!CSIY+M)?HOW^+N2*< +'*$A<A4+R```` ` end diff --git a/sys/boot/efi/boot1/fat-arm.tmpl.bz2.uu b/sys/boot/efi/boot1/fat-arm.tmpl.bz2.uu index 15b59d8..7356bde 100644 --- a/sys/boot/efi/boot1/fat-arm.tmpl.bz2.uu +++ b/sys/boot/efi/boot1/fat-arm.tmpl.bz2.uu @@ -2,25 +2,24 @@ FAT template boot filesystem created by generate-fat.sh DO NOT EDIT $FreeBSD$ begin 644 fat-arm.tmpl.bz2 -M0EIH.3%!629365NH-?4`&T!_____ZZ[J[_ZN_ZO^J_Z[OJ_^J^J[^KZNKNNJ -MZNKNZOJ^P`+\#$``0`&AD:,@TTTT-&C30#$R&FF1H:!B&)D&F@```-&AB::# -M1HP0-,AD`T8F(TTP2JII&?^I5/]4`@TTT-&(T8FAB:&@T:8F(Q!@!`9,1DR9 -M`-,$:,FC)B&FC"8"#3"#(-,0`&AD:,@TTTT-&C30#$R&FF1H:!B&)D&F@``` -M-&AB::#1HP0-,AD`T8F(TTP*HI)D\DFDVC0AIIH]3(:-``80>HTTR!IH::#$ -M-`Q`:`/2:::&)IDP"/0$T:>IFD]$R8---3HUK2<PNK%<6\J]BA",-*(A%:0B -M(B#G5%F8B$$(68C_:!`A#OL<HAB+JZ6UHRRU>*K9].C:!IWS-2UK9M<WC]W[ -M+]QW,9%V2,?<"ZEO9B("$,I.0ZFE66K/,<N6+8ITS$J3))F2I4HJ5*E2I74J -M:$J5*E2I4JE5*I*I-2I4J5.;84I4J5*E2I6ZU4Q*E2I4J5+X<SOK,65E965D -MT:($(0A"$(0A"$(0C>.3@8,&#!@P8(0A"$(0@0A"$(0[;_L-&C1HT:-&B+YP -M,&#!@P8,$"$(0A"-?NW$*YY:V9IQ,:B93+AX^A7B),5HN_4JV=2\Y,:-+W'Q -MKQKVU7KA+YR'.:*V#48N-"7<`%:TT4D`/;N;SZM9X,V(@!D'=P==+O)9*\H8 -MI8W<L9:.AU[N;G"QEHLZBWB/2B.SKCGRM):%ZK3-2U3ZV1;%MUZX:^?X_Y@N -MM=0SN1R7Z\&PN,I8VVWKMS$1-X41%"V)-;+V9:MI5;.+M*TMZ]K7HQ-ALY1\ -M4LG)\#5/I7#7-D_1<KUPE\OW)<YEW=.GMJ%$MUF)TE9N)8[M[6LIEXF@H6?S -MW%U89M5M+:LW6(\?7Z6I:U4F>IM*Q<2E)KFG;%M&U;INV]<)Q%^P'*<]T6R; -M^7`P.+I+N(HA%=#(^Q0WVV0]=$2=5)>-XWKW7!95E7$<5QW)<IS6"PF@7&+H -M&<ETI.`9F48V7/E&??ROG%<9FU^Y#E.8W+GL%]#L7+U=^CY91Q\+`K'-WPF4 -M.2S[EM@S38.8YKG.@P6_83I,-<G1DPY84N-)VMWK,/!;AIJ&3E%&7B`0A,`& -3'65I7J6`B^?^+N2*<*$@MU!KZ@`` +M0EIH.3%!629368U&4)@`&T#_____^ZKJ[_ZN_^O^J_[[OJ_NJ^JK^KZNKN^J +MZNKNZOJ^P`+\```"!H:-`,(#0:!@0`&@-,@-`8!`9--```-,$TTP0&31D&C" +M``R&$-,A`T-&@&$!H-`P(`#0&F0&@,`@,FF@``&F"::8(#)HR#1A``9#"&F0 +M@:&C0#"`T&@8$`!H#3(#0&`0&330``#3!--,$!DT9!HP@`,AA#3("J**'Y%( +M1D]&IH`]3(#0``T-`-``&@&F@#0``9``-`:-&"--!H;4T]1HPF:GJ;VW`G0L +M;"P1EY8.%8A&4E$0BV0B(B#=7%\Q$((0OB/ZL$"$.9SBR&6QL9AX#0*.D6]> +MGO'8M.]!X[V'QO:?6V;6L=^[<.#;YP\P:^3CD9VR(!"&?G@>`JM8+J&<8C-- +M];XRRIPJ9DN7++ERY<N8*JMB5555555RZJY*Y-RY<N7-SA*I5555559=16)5 +M55555>7SNPOB]>O7KUZ]0HHHHHHHHHHHHHHHHY&)5555555444444444**** +M***,/F?'O7KUZ]>O7J-;*JJJJJJJA1111111B\A/&6:##:%^>;:*3FK;$R_" +M49GMN<56Z-+L4QW:7AO-:E[[YFN;)^C(;II,,-/FH[0Z.`"W`TDD`/"Q-3ZO +ML:*<*(`<"YB#/:ER\1,(YK`,_;8S*FLEB8#_>+<MF\G$P%_BV#=RS$NU=T[Y +MIWFO5<$^%JVN;-M&V?XWCAF*]'?M#*-K$<'PNNV5S$XG"^G58,:@EX*(9@L/ +M9EX4M2TRW1NB2P,O@TP;,QA/DD8DGDO.>FWU[;5/F:QL'WOT8[^6Z<VXABX= +MBR7U\Y.EM9&LL8O*5M72X*(CI.RM9;Y=9C83I5_SY:U]F7ZCX=-<I=4ZFN!: +M9J4I/=>,U3YVK?8UK[7X-H_=D-NW;>OD/OR+$,[IK&Q^A$8LFH>@V#PVR9YG +MFT;5MG].4;EO&2ZIF9'12_Z38G,2C$ENY1LWXMH_5^S1,=D-NW#Z6[;QY[BG +M]^GM3.Q$O,EW$F/D[:TW.P$RAD.J;=[[^WP-PW+=/];QL62_YE,0WLF5+)EC +ER<EJ,K>OH:6QGY19C1`(0F`#*M6RUZ60C(?^+N2*<*$A&HRA,``` ` end diff --git a/sys/boot/efi/boot1/fat-arm64.tmpl.bz2.uu b/sys/boot/efi/boot1/fat-arm64.tmpl.bz2.uu index 031815c..e555837 100644 --- a/sys/boot/efi/boot1/fat-arm64.tmpl.bz2.uu +++ b/sys/boot/efi/boot1/fat-arm64.tmpl.bz2.uu @@ -2,25 +2,25 @@ FAT template boot filesystem created by generate-fat.sh DO NOT EDIT $FreeBSD$ begin 644 fat-arm64.tmpl.bz2 -M0EIH.3%!62936:2BH:(`&T#_____ZZKJ[_^N_ZO_J_Z[OJ_NJ^JK^KZNKNNJ -MZNKNZOJ^P`+\```"``:`9,@T&F3$,@!B`,AIHP$#0-`T``,09--&31IH9#)D -M,(#$T&)B!A``-`,F0:#3)B&0`Q`&0TT8"!H&@:``&(,FFC)HTT,ADR&$!B:# -M$Q`P@`&@&3(-!IDQ#(`8@#(::,!`T#0-``#$&331DT::&0R9#"`Q-!B8@8"J -M*0GY$I&GH"-&AZ@T```T`:`!HT```&@&@-,C0`-`#U,(-`&)ZF(PGIJ>IO;U -M^=&QL3`-\E@Q+$(RTHB$7I"(B(-W:73$0@A#;S##$3$`A#FL\LAF,;&8;[CE -M&D=@ON\:9IWHO):QK7LL=LFN;1M6Y:%F>-1G^&O-A*(@0AQ,\#H*KRCJF>9Q -MFF_,RWU4X-,R6K5EJU:M6L"JMB5555555JVJU*U-JU:M6MUB*I555555;XHJ -ME555555YM='L;(N7+ERY<N4****************.2B55555555%%%%%%%%"B -MBBBBBC#S/DW+ERY<N7+E&NE55555550HHHHHHHS_(SQEG'X7.OTSKFY=#*]* -M9?C*,7MM&JO=0EIDQW:7C-0U;WGRM>_!^S^F[=KA#3YJ.S-)`!>O]K)`#-ZO -MU=9T,X(@!H',-+,1Q'-6'#ZNQORGURS=]_O%.6SF5G,PC`G#X_@7W$RC>2Q) -M9MW3P&G:AJFA?`^AKWXOV?R_QDL9F^`=5H>$UWWT9K&Q/HS.!KXB)U)9$6,) -M*/!EJ7>+W2L65_C\&LP69G$?'M$18.(LL.G:AZ;%>TUKYF.V+9/W9AMF[<VT -MS/X;%DL?1SW5Y]4L]R=+RLNCTMB[6_5C8C2+?DPWF/F.G]WN[5+:G4UOWC%E -M*3V7BO??&^=COL?:V3]&T9#<-XWKX3\,BQ#[KW01%D(X'O<#8?*B.`D]1J&O -M>&^]HFB?J_AM6V;ANF2RG7,61I)?])L35<Y8C.RWDHV3\GZOW;-TC:MLW#<O -MG;QDO2<6_S5;,T$1["/3W^^]&4;3*_F\:?7"90R&E;=N']O@;ENF[?ZR6Q93 -M_F6SAO9,N65+9R:#69>2^EX5C12BSAX@$(3`!EWEZ6P2R$9#_Q=R13A0D*2B -"H:(` +M0EIH.3%!629360E-\T``&T#_____ZZKJ[__N_^O^J_Z[OJ_NJ^JK^KZNKNNJ +MZNKNZOJ^P`+<#$``@`-#(T9!IIIH:-&F@&)D--,C0T#$,3(--````:-#$TT& +MC1@@:9#(!HQ,1II@E532,_]2J?ZH!!IIH:,1HQ-#$T-!HTQ,1B#`"`R8C)DR +M`:8(T9-&3$--&$P$&F$&0:8@`-#(T9!IIIH:-&F@&)D--,C0T#$,3(--```` +M:-#$TT&C1@@:9#(!HQ,1II@511(>21,:&D:`])Z0-`T&FC30:&1D`R:!IDT: +M#30&FC1ZFC1H::8FF3$VB,(TTT])@38C)J85-B<VNK6T&+E:6M"$8B41"*9" +M(B(,"LLS$0@A"S$<J@0(0S-RHABKJZ6]AEEL\13YB=*T+W'R/=:]M'V-VX+> +M+YQG-=.Q@NI[!'1T;V8B`A#*STN3J4K5GURR"X8UC&+5'4IF2M6HK5JU:M:* +ME5"52I4J5*E:NI6E6FM6K5JU_:JDJE2I4J5,6ME42J5*E2I4^'O-]9BRLK*R +MLFC1`A"$(0A"$(0A"$;QR<#!@P8,&#!"$(0A"$"$(0A"';?U+1HT:-&C1HB^ +M<#!@P8,&#!`A"$(0C7[MQ"N?8V[-.'W]RCNJ:$RX4HQWHVBV4YY+0IC2I>VU +M;7-BVR]<!Q'(8#1VX:JXC1&<@`IL:.2`&/UUYK^^FTB`&3=Q!E-<[>(F$9BP +M=730QJVW4L?8<[K';9##R%A9U.GI9677RQN6E'U1%+!E3+1M(]9JFL:Y=-DW +M"]<)Q'^O^<]E5STS6]5E-YO[9<7=KN-9:1>$M0B%N4(U$KQIE.=8Z5C+VGUV +ME&,M6TD7<GO-6UK&M@V;\FY;UP'$7SDL!WKN62MZ%$MUFYTM+(Q&YH49>VI5 +M2V,1&=T5*WVNYREJSRSML52\#%Y_8Z:M;5U&@JL4EQ*4FP:ELFU?FW3=M\X+ +MAKYQW+8+";,W_'H0Z33T+W;(C)2?.^->O:?NNUVX;BN,Y+EK]SV&\=CI&<ET +M)-\9B49"6#*."_AFG$<5WZ^<ARW-;=@N>UCK7,O.*CXI1_F'QM)8+^]$RAQV +M@<IRW,;)S5^P'.<]^##=!B,B84F)+#E?2=I]&)A-NTU"[E%&9B`0A,`&)2IE +0O4N0CD/_%W)%.%"0"4WS0``` ` end diff --git a/sys/boot/efi/boot1/fat-i386.tmpl.bz2.uu b/sys/boot/efi/boot1/fat-i386.tmpl.bz2.uu index 2bdebf0..0e38ebb 100644 --- a/sys/boot/efi/boot1/fat-i386.tmpl.bz2.uu +++ b/sys/boot/efi/boot1/fat-i386.tmpl.bz2.uu @@ -2,25 +2,24 @@ FAT template boot filesystem created by generate-fat.sh DO NOT EDIT $FreeBSD$ begin 644 fat-i386.tmpl.bz2 -M0EIH.3%!629368LPC"P`&T#_____[ZKJ[_ZN_ZO^J_Z[OJ_OJ^JK_KZNKNNJ -MZNKNZOJ^P`+\``4`15/%`]3U!H:-`:,C0```&@:9!H`T`!D````&@&@:9HF1 -MA``R:``:"``T,C1D&FFFAHT::`8F0TTR-#0,0Q,@TT```!HT,330:-&"!ID, -M@&C$Q&FF(`#0R-&0::::&C1IH!B9#33(T-`Q#$R#30```&C0Q--!HT8(&F0R -M`:,3$::8%4DDT_(HDQDFC$TR8F31H#0R,@T-!IH`#0R-`:9`TT--&C0-,C(R -M--/0C"---/28$P:::G.M7$NU9*YMC#26[FI",))$0BU((B(@Y=99)$((0LB) -M<:0@0AFL6JA=Y+)+JX9A-W:UXB7H/&:9\#3OG;)]#;MZOE^X3DL>PXZ:3<R. -MJ1C*H@$(=/+'8VBTMO`8MBEXQ##KM0R"4I%:M56K5JU:VHI4DHHHHHHK5T5I -M*TJU:M6K<JY4244444489-2)******/<SFZLBQ8L6+%BQ,FFFFFFFFFFFFFF -MFFZV)*******)IIIIIIIIDTTTTTTUUFM/8L6+%BQ8L37TE%%%%%%$R:::::: -M;HNLR]568NF=;_H3.25=S.TN8C:-Q*3(SMM])&*T6=89:T"3R4HTB33/?:UL -M&T;EO'`<1RVBN@U%Y'F&?@`M7&BD0`O=;\FNSTK<0`QK-P9;M*C)ZVIAUSMY -M+RX<WJ797N#>Z7)W*[T]0YDF(D\UI%&H:I\KI&Q?FW+,N`_U_S`9%EL9H,?D -M+[=S7F7N=K>6VVB(EK"J(J71=U(].36-&M9]E)+CJ[>NMXBU<ME(921[;4OB -M8E]+[GX-LW+>.`OW%#X"4"I`L0*`H@*982S&"L)%`M'-HP#B!/4PH$;I)EK" -M?`??(&!3=]_K])6G70T%+BT8F221>O8;!LVT?HV[=-ZWZ_<-QW,<YL3*[OAV -MEUANWB*H1:7J(DC':.IN-FB,9(U;4KYX3]V595OW!<)Q7'<I@,%H6)DE$D=U -M)SY&X7$29N2,5)S+BI&\;YOW`<%GE^XCCN2VCF,!JF6<C5_VCU)(X.#PK1RK -MX2DAPVA<9QW(:]R7*<MS6`W#!<]A,4<Z3`DPI,&2_D==K<+`;5I:F4DBK,Q` -8(0E`!A6EJ2^2<1'$?^+N2*<*$A%F$86` +M0EIH.3%!629363V[U-``&T#_____^ZKJ[_ZN_^O^J_Z[OJ_NK^JO^KZNKNNJ +MZNKNZOJ^P`+\&$`!(&AHT`P@-!H&!``:`TR`T!@$!DTT```TP333!`9-&0:, +M(`#(80TR!*J:B:?_I5/]51H9!D:`80&C"8(&@--,$`!H#30R,@P$R:`T`9`: +M-`T`T``:`:(&AHT`P@-!H&!``:`TR`T!@$!DTT```TP333!`9-&0:,(`#(80 +MTR`JBIJ9-JF28Q31Z1ZFFTU&0T!H:#0::`TT#0:!B`&@#)H8C330TTTTTR:> +MAHF"/4]33TFT:38F)J8U%A.A7-:J,G*K6J(1D)1$(HD(B(@PZ3)3$0@A#)1' +M+J"!"&@RZI"SN;E96#/+%WZCR4ZAIFK:Y[S9MPVC>N*WZ_<AS5PRF:F#@2ZQ +M%O4A`0AU$])F*ZA5>(RZV6C*LHLU<S*9DI4JE*E2I4JJNKU$JZNKJZNKJ5-= +M2E2FE2I4J6%6,0######$4(:%`,,,,,,<//>!X3CCCCCCB!"$(0A"$(0A"$( +MS<*`88888880A"$(0A`A"$(0C!3?!<<<<<<<<1=P#######"!"$(0A$;FH,M +M4SUDT*]Z%WLG;45$RXTHRWG]PKJ/#2TR8U"7MOD;%M7Z+QQ%\P&&T]D'NVD> +M::.`"BPT\D`+78Z_9=Y-6(`9AVD&;V+LXB81H+`NJ*C*K&[E:V#G9QG[;'MM +M5=5EG[E08DLK+SGIJ[5M8V"X?@W:\<9?/]?\Q6:9VWUUQF=]P[%:=76W7"JQ +MKR7KHA<:*4;Z(Z`RE9'L2V#5*/!9R5AV-79U;6BLW$C)R?`UCYUJVC;MR_9P +M'$7R_<IANY7#HK*HJ2N]#.IM;!O)9?/UZ%,M'$1X'E4+/<;RYK/"9+<V="[R +M>DVNJI6--<TM>PH+24I-HU;;/S;I=MZX+BKU?N2P6(QFW.'R:@M8B5OZE1>; +MDBWE6DU[6M^\APETNEZX[D.4P6$Q6.TK+2-'+GR<`[646TL24<1QEZOG':)? +ML!@N:W;$8KYF=<S8<=&ME'^8_(H,*\$RAR6D<M@N8VSFL)AN<Q7!8[GLA;&- +J)D2QY7\G7;+(QGZM349N45-!$`A"8`,BA1*\2P$8!_Q=R13A0D#V[U-` ` end diff --git a/sys/boot/efi/boot1/generate-fat.sh b/sys/boot/efi/boot1/generate-fat.sh index 7992b55..8b3fae8 100755 --- a/sys/boot/efi/boot1/generate-fat.sh +++ b/sys/boot/efi/boot1/generate-fat.sh @@ -55,14 +55,25 @@ BOOT1_OFFSET=$(hd $OUTPUT_FILE | grep 'Boot1 START' | cut -f 1 -d ' ') # Convert to number of blocks BOOT1_OFFSET=$(echo 0x$BOOT1_OFFSET | awk '{printf("%x\n",$1/512);}') +# Record maximum boot1 size in bytes +case $BOOT1_SIZE in +*k) + BOOT1_MAXSIZE=$(expr ${BOOT1_SIZE%k} '*' 1024) + ;; +*) + BOOT1_MAXSIZE=$BOOT1_SIZE + ;; +esac + echo '# This file autogenerated by generate-fat.sh - DO NOT EDIT' > Makefile.fat -echo '# $FreeBSD$' >> Makefile.fat +echo "# \$FreeBSD\$" >> Makefile.fat echo "BOOT1_OFFSET=0x$BOOT1_OFFSET" >> Makefile.fat +echo "BOOT1_MAXSIZE=$BOOT1_MAXSIZE" >> Makefile.fat bzip2 $OUTPUT_FILE echo 'FAT template boot filesystem created by generate-fat.sh' > $OUTPUT_FILE.bz2.uu echo 'DO NOT EDIT' >> $OUTPUT_FILE.bz2.uu -echo '$FreeBSD$' >> $OUTPUT_FILE.bz2.uu +echo "\$FreeBSD\$" >> $OUTPUT_FILE.bz2.uu uuencode $OUTPUT_FILE.bz2 $OUTPUT_FILE.bz2 >> $OUTPUT_FILE.bz2.uu rm $OUTPUT_FILE.bz2 diff --git a/sys/boot/efi/fdt/Makefile b/sys/boot/efi/fdt/Makefile index 19a4c49..15862dc 100644 --- a/sys/boot/efi/fdt/Makefile +++ b/sys/boot/efi/fdt/Makefile @@ -6,6 +6,7 @@ LIB= efi_fdt INTERNALLIB= +WARNS?= 6 SRCS= efi_fdt.c diff --git a/sys/boot/efi/fdt/efi_fdt.c b/sys/boot/efi/fdt/efi_fdt.c index d6ee85c..d675768 100644 --- a/sys/boot/efi/fdt/efi_fdt.c +++ b/sys/boot/efi/fdt/efi_fdt.c @@ -44,7 +44,6 @@ int fdt_platform_load_dtb(void) { struct fdt_header *hdr; - int err; hdr = efi_get_table(&fdtdtb); if (hdr != NULL) { @@ -54,7 +53,7 @@ fdt_platform_load_dtb(void) } } - return (err); + return (1); } void diff --git a/sys/boot/efi/include/amd64/efibind.h b/sys/boot/efi/include/amd64/efibind.h index 3d70b58a..d7a8dc0 100644 --- a/sys/boot/efi/include/amd64/efibind.h +++ b/sys/boot/efi/include/amd64/efibind.h @@ -39,7 +39,7 @@ Revision History // No ANSI C 1999/2000 stdint.h integer width declarations - #if _MSC_EXTENSIONS + #ifdef _MSC_EXTENSIONS // Use Microsoft C compiler integer width declarations @@ -164,7 +164,7 @@ typedef uint64_t UINTN; #endif #ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options - #if _MSC_EXTENSIONS + #ifdef _MSC_EXTENSIONS #define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler #else #define EFIAPI // Substitute expresion to force C calling convention @@ -265,7 +265,7 @@ typedef uint64_t UINTN; #endif #endif /* __FreeBSD__ */ -#if _MSC_EXTENSIONS +#ifdef _MSC_EXTENSIONS #pragma warning ( disable : 4731 ) // Suppress warnings about modification of EBP #endif diff --git a/sys/boot/efi/include/arm64/efibind.h b/sys/boot/efi/include/arm64/efibind.h index 21f0d25..142f162 100644 --- a/sys/boot/efi/include/arm64/efibind.h +++ b/sys/boot/efi/include/arm64/efibind.h @@ -39,7 +39,7 @@ Revision History // No ANSI C 1999/2000 stdint.h integer width declarations - #if _MSC_EXTENSIONS + #ifdef _MSC_EXTENSIONS // Use Microsoft C compiler integer width declarations @@ -127,7 +127,6 @@ typedef uint64_t UINTN; #define BAD_POINTER 0xFBFBFBFBFBFBFBFB #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF -#pragma intrinsic (__break) #define BREAKPOINT() __break(0) // @@ -159,7 +158,7 @@ typedef uint64_t UINTN; // #ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options - #if _MSC_EXTENSIONS + #ifdef _MSC_EXTENSIONS #define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler #else #define EFIAPI // Substitute expresion to force C calling convention @@ -180,7 +179,6 @@ typedef uint64_t UINTN; // BugBug: Need to find out if this is portable accross compliers. // void __mfa (void); -#pragma intrinsic (__mfa) #define MEMORY_FENCE() __mfa() #ifdef EFI_NO_INTERFACE_DECL diff --git a/sys/boot/efi/include/efi_nii.h b/sys/boot/efi/include/efi_nii.h index 5222232..561cbd4 100644 --- a/sys/boot/efi/include/efi_nii.h +++ b/sys/boot/efi/include/efi_nii.h @@ -26,9 +26,9 @@ Revision history: --*/ #define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL \ - { 0xE18541CD, 0xF755, 0x4f73, 0x92, 0x8D, 0x64, 0x3C, 0x8A, 0x79, 0xB2, 0x29 } + { 0xE18541CD, 0xF755, 0x4f73, {0x92, 0x8D, 0x64, 0x3C, 0x8A, 0x79, 0xB2, 0x29} } #define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_31 \ - { 0x1ACED566, 0x76ED, 0x4218, 0xBC, 0x81, 0x76, 0x7F, 0x1F, 0x97, 0x7A, 0x89 } + { 0x1ACED566, 0x76ED, 0x4218, {0xBC, 0x81, 0x76, 0x7F, 0x1F, 0x97, 0x7A, 0x89} } #define EFI_NETWORK_INTERFACE_IDENTIFIER_INTERFACE_REVISION 0x00010000 #define EFI_NETWORK_INTERFACE_IDENTIFIER_INTERFACE_REVISION_31 0x00010001 diff --git a/sys/boot/efi/include/efiapi.h b/sys/boot/efi/include/efiapi.h index 9c2dfbb..b1a7b45 100644 --- a/sys/boot/efi/include/efiapi.h +++ b/sys/boot/efi/include/efiapi.h @@ -214,8 +214,8 @@ VOID // EFI platform varibles // -#define EFI_GLOBAL_VARIABLE \ - { 0x8BE4DF61, 0x93CA, 0x11d2, 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C } +#define EFI_GLOBAL_VARIABLE \ + { 0x8BE4DF61, 0x93CA, 0x11d2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C} } // Variable attributes #define EFI_VARIABLE_NON_VOLATILE 0x00000001 @@ -363,8 +363,8 @@ EFI_STATUS // Image handle -#define LOADED_IMAGE_PROTOCOL \ - { 0x5B1B31A1, 0x9562, 0x11d2, 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B } +#define LOADED_IMAGE_PROTOCOL \ + { 0x5B1B31A1, 0x9562, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} } #define EFI_LOADED_IMAGE_INFORMATION_REVISION 0x1000 typedef struct { @@ -827,35 +827,35 @@ typedef struct { // EFI Configuration Table and GUID definitions // -#define MPS_TABLE_GUID \ - { 0xeb9d2d2f, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } +#define MPS_TABLE_GUID \ + { 0xeb9d2d2f, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } -#define ACPI_TABLE_GUID \ - { 0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } +#define ACPI_TABLE_GUID \ + { 0xeb9d2d30, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } -#define ACPI_20_TABLE_GUID \ - { 0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } +#define ACPI_20_TABLE_GUID \ + { 0x8868e871, 0xe4f1, 0x11d3, {0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} } -#define SMBIOS_TABLE_GUID \ - { 0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } +#define SMBIOS_TABLE_GUID \ + { 0xeb9d2d31, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } -#define SAL_SYSTEM_TABLE_GUID \ - { 0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } +#define SAL_SYSTEM_TABLE_GUID \ + { 0xeb9d2d32, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } -#define FDT_TABLE_GUID \ - { 0xb1b621d5, 0xf19c, 0x41a5, 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } +#define FDT_TABLE_GUID \ + { 0xb1b621d5, 0xf19c, 0x41a5, {0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0} } -#define DXE_SERVICES_TABLE_GUID \ - { 0x5ad34ba, 0x6f02, 0x4214, 0x95, 0x2e, 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9 } +#define DXE_SERVICES_TABLE_GUID \ + { 0x5ad34ba, 0x6f02, 0x4214, {0x95, 0x2e, 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9} } -#define HOB_LIST_TABLE_GUID \ - { 0x7739f24c, 0x93d7, 0x11d4, 0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } +#define HOB_LIST_TABLE_GUID \ + { 0x7739f24c, 0x93d7, 0x11d4, {0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } #define MEMORY_TYPE_INFORMATION_TABLE_GUID \ - { 0x4c19049f, 0x4137, 0x4dd3, 0x9c, 0x10, 0x8b, 0x97, 0xa8, 0x3f, 0xfd, 0xfa } + { 0x4c19049f, 0x4137, 0x4dd3, {0x9c, 0x10, 0x8b, 0x97, 0xa8, 0x3f, 0xfd, 0xfa} } #define DEBUG_IMAGE_INFO_TABLE_GUID \ - { 0x49152e77, 0x1ada, 0x4764, 0xb7, 0xa2, 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b } + { 0x49152e77, 0x1ada, 0x4764, {0xb7, 0xa2, 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b} } typedef struct _EFI_CONFIGURATION_TABLE { EFI_GUID VendorGuid; diff --git a/sys/boot/efi/include/eficon.h b/sys/boot/efi/include/eficon.h index ef4af81..2f719e7 100644 --- a/sys/boot/efi/include/eficon.h +++ b/sys/boot/efi/include/eficon.h @@ -32,7 +32,7 @@ Revision History // #define SIMPLE_TEXT_OUTPUT_PROTOCOL \ - { 0x387477c2, 0x69c7, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } + { 0x387477c2, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } INTERFACE_DECL(_SIMPLE_TEXT_OUTPUT_INTERFACE); @@ -239,8 +239,8 @@ typedef struct _SIMPLE_TEXT_OUTPUT_INTERFACE { // Text input protocol // -#define SIMPLE_TEXT_INPUT_PROTOCOL \ - { 0x387477c1, 0x69c7, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } +#define SIMPLE_TEXT_INPUT_PROTOCOL \ + { 0x387477c1, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } INTERFACE_DECL(_SIMPLE_INPUT_INTERFACE); diff --git a/sys/boot/efi/include/eficonsctl.h b/sys/boot/efi/include/eficonsctl.h index 36dd2c1..68be3d6 100644 --- a/sys/boot/efi/include/eficonsctl.h +++ b/sys/boot/efi/include/eficonsctl.h @@ -35,7 +35,7 @@ #define _EFI_CONS_CTL_H #define EFI_CONSOLE_CONTROL_PROTOCOL_GUID \ - { 0xf42f7782, 0x12e, 0x4c12, {0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21} } + { 0xf42f7782, 0x12e, 0x4c12, {0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21} } typedef struct _EFI_CONSOLE_CONTROL_PROTOCOL EFI_CONSOLE_CONTROL_PROTOCOL; diff --git a/sys/boot/efi/include/efidevp.h b/sys/boot/efi/include/efidevp.h index a332af5..f0f49ef 100644 --- a/sys/boot/efi/include/efidevp.h +++ b/sys/boot/efi/include/efidevp.h @@ -110,7 +110,7 @@ typedef struct _VENDOR_DEVICE_PATH { } VENDOR_DEVICE_PATH; #define UNKNOWN_DEVICE_GUID \ - { 0xcf31fac5, 0xc24e, 0x11d2, 0x85, 0xf3, 0x0, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b } + { 0xcf31fac5, 0xc24e, 0x11d2, {0x85, 0xf3, 0x0, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b} } typedef struct _UKNOWN_DEVICE_VENDOR_DP { VENDOR_DEVICE_PATH DevicePath; @@ -274,16 +274,16 @@ typedef struct _UART_DEVICE_PATH { /* Use VENDOR_DEVICE_PATH struct */ #define DEVICE_PATH_MESSAGING_PC_ANSI \ - { 0xe0c14753, 0xf9be, 0x11d2, 0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } + { 0xe0c14753, 0xf9be, 0x11d2, {0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } #define DEVICE_PATH_MESSAGING_VT_100 \ - { 0xdfa66065, 0xb419, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } + { 0xdfa66065, 0xb419, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } #define DEVICE_PATH_MESSAGING_VT_100_PLUS \ - { 0x7baec70b, 0x57e0, 0x4c76, 0x8e, 0x87, 0x2f, 0x9e, 0x28, 0x08, 0x83, 0x43 } + { 0x7baec70b, 0x57e0, 0x4c76, {0x8e, 0x87, 0x2f, 0x9e, 0x28, 0x08, 0x83, 0x43} } #define DEVICE_PATH_MESSAGING_VT_UTF8 \ - { 0xad15a0d6, 0x8bec, 0x4acf, 0xa0, 0x73, 0xd0, 0x1d, 0xe7, 0x7e, 0x2d, 0x88 } + { 0xad15a0d6, 0x8bec, 0x4acf, {0xa0, 0x73, 0xd0, 0x1d, 0xe7, 0x7e, 0x2d, 0x88} } #define MEDIA_DEVICE_PATH 0x04 diff --git a/sys/boot/efi/include/efierr.h b/sys/boot/efi/include/efierr.h index dc57f0e..a8b6557 100644 --- a/sys/boot/efi/include/efierr.h +++ b/sys/boot/efi/include/efierr.h @@ -30,7 +30,8 @@ Revision History #define EFIWARN(a) (a) -#define EFI_ERROR(a) (((INTN) a) < 0) +#define EFI_ERROR(a) (((INTN) a) < 0) +#define EFI_ERROR_CODE(a) (unsigned long)(a & ~EFI_ERROR_MASK) #define EFI_SUCCESS 0 diff --git a/sys/boot/efi/include/efifpswa.h b/sys/boot/efi/include/efifpswa.h index 3e039ef..21823c5 100644 --- a/sys/boot/efi/include/efifpswa.h +++ b/sys/boot/efi/include/efifpswa.h @@ -7,7 +7,7 @@ */ #define EFI_INTEL_FPSWA \ - { 0xc41b6531, 0x97b9, 0x11d3, 0x9a, 0x29, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } + { 0xc41b6531, 0x97b9, 0x11d3, {0x9a, 0x29, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } INTERFACE_DECL(_FPSWA_INTERFACE); diff --git a/sys/boot/efi/include/efigop.h b/sys/boot/efi/include/efigop.h index dfc4bba..104fa6e 100644 --- a/sys/boot/efi/include/efigop.h +++ b/sys/boot/efi/include/efigop.h @@ -27,9 +27,8 @@ Revision History #ifndef _EFIGOP_H #define _EFIGOP_H -#define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \ - { 0x9042a9de, 0x23dc, 0x4a38, 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, \ - 0x51, 0x6a } +#define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \ + { 0x9042a9de, 0x23dc, 0x4a38, {0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a} } INTERFACE_DECL(_EFI_GRAPHICS_OUTPUT); diff --git a/sys/boot/efi/include/efilib.h b/sys/boot/efi/include/efilib.h index ef03028..b67ffc5 100644 --- a/sys/boot/efi/include/efilib.h +++ b/sys/boot/efi/include/efilib.h @@ -50,3 +50,4 @@ time_t efi_time(EFI_TIME *); EFI_STATUS main(int argc, CHAR16 *argv[]); void exit(EFI_STATUS status); +void delay(int usecs); diff --git a/sys/boot/efi/include/efinet.h b/sys/boot/efi/include/efinet.h index b4996d9..3ac58b2 100644 --- a/sys/boot/efi/include/efinet.h +++ b/sys/boot/efi/include/efinet.h @@ -29,7 +29,7 @@ Revision History // #define EFI_SIMPLE_NETWORK_PROTOCOL \ - { 0xA19832B9, 0xAC25, 0x11D3, 0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D } + { 0xA19832B9, 0xAC25, 0x11D3, {0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D} } INTERFACE_DECL(_EFI_SIMPLE_NETWORK); diff --git a/sys/boot/efi/include/efipciio.h b/sys/boot/efi/include/efipciio.h index 6ab49ba..b00d6ec 100644 --- a/sys/boot/efi/include/efipciio.h +++ b/sys/boot/efi/include/efipciio.h @@ -21,9 +21,7 @@ /// Global ID for the PCI I/O Protocol /// #define EFI_PCI_IO_PROTOCOL_GUID \ - { \ - 0x4cf5b200, 0x68b8, 0x4ca5, {0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x2, 0x9a } \ - } + { 0x4cf5b200, 0x68b8, 0x4ca5, {0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x2, 0x9a} } typedef struct _EFI_PCI_IO_PROTOCOL EFI_PCI_IO_PROTOCOL; diff --git a/sys/boot/efi/include/efiprot.h b/sys/boot/efi/include/efiprot.h index fac4568..28cec59 100644 --- a/sys/boot/efi/include/efiprot.h +++ b/sys/boot/efi/include/efiprot.h @@ -31,8 +31,8 @@ Revision History // Device Path protocol // -#define DEVICE_PATH_PROTOCOL \ - { 0x9576e91, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } +#define DEVICE_PATH_PROTOCOL \ + { 0x9576e91, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } // @@ -40,7 +40,7 @@ Revision History // #define BLOCK_IO_PROTOCOL \ - { 0x964e5b21, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } + { 0x964e5b21, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } #define EFI_BLOCK_IO_INTERFACE_REVISION 0x00010000 INTERFACE_DECL(_EFI_BLOCK_IO); @@ -116,7 +116,7 @@ typedef struct _EFI_BLOCK_IO { // #define DISK_IO_PROTOCOL \ - { 0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } + { 0xce345171, 0xba0b, 0x11d2, {0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } #define EFI_DISK_IO_INTERFACE_REVISION 0x00010000 INTERFACE_DECL(_EFI_DISK_IO); @@ -155,7 +155,7 @@ typedef struct _EFI_DISK_IO { // #define SIMPLE_FILE_SYSTEM_PROTOCOL \ - { 0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } + { 0x964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } INTERFACE_DECL(_EFI_FILE_IO_INTERFACE); INTERFACE_DECL(_EFI_FILE_HANDLE); @@ -290,8 +290,8 @@ typedef struct _EFI_FILE_HANDLE { // File information types // -#define EFI_FILE_INFO_ID \ - { 0x9576e92, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } +#define EFI_FILE_INFO_ID \ + { 0x9576e92, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } typedef struct { UINT64 Size; @@ -314,8 +314,8 @@ typedef struct { #define SIZE_OF_EFI_FILE_INFO EFI_FIELD_OFFSET(EFI_FILE_INFO,FileName) -#define EFI_FILE_SYSTEM_INFO_ID \ - { 0x9576e93, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } +#define EFI_FILE_SYSTEM_INFO_ID \ + { 0x9576e93, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } typedef struct { UINT64 Size; @@ -336,8 +336,8 @@ typedef struct { #define SIZE_OF_EFI_FILE_SYSTEM_INFO EFI_FIELD_OFFSET(EFI_FILE_SYSTEM_INFO,VolumeLabel) -#define EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID \ - { 0xDB47D7D3,0xFE81, 0x11d3, 0x9A, 0x35, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D } +#define EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID \ + { 0xDB47D7D3,0xFE81, 0x11d3, {0x9A, 0x35, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D} } typedef struct { CHAR16 VolumeLabel[1]; @@ -351,7 +351,7 @@ typedef struct { #define LOAD_FILE_PROTOCOL \ - { 0x56EC3091, 0x954C, 0x11d2, 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B } + { 0x56EC3091, 0x954C, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} } INTERFACE_DECL(_EFI_LOAD_FILE_INTERFACE); @@ -375,7 +375,7 @@ typedef struct _EFI_LOAD_FILE_INTERFACE { // #define DEVICE_IO_PROTOCOL \ - { 0xaf6ac311, 0x84c3, 0x11d2, 0x8e, 0x3c, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } + { 0xaf6ac311, 0x84c3, 0x11d2, {0x8e, 0x3c, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } INTERFACE_DECL(_EFI_DEVICE_IO_INTERFACE); @@ -485,7 +485,7 @@ typedef struct _EFI_DEVICE_IO_INTERFACE { // #define UNICODE_COLLATION_PROTOCOL \ - { 0x1d85cd7f, 0xf43d, 0x11d2, 0x9a, 0xc, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } + { 0x1d85cd7f, 0xf43d, 0x11d2, {0x9a, 0xc, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } #define UNICODE_BYTE_ORDER_MARK (CHAR16)(0xfeff) diff --git a/sys/boot/efi/include/efipxebc.h b/sys/boot/efi/include/efipxebc.h index 3781a67..ba0b2e9 100644 --- a/sys/boot/efi/include/efipxebc.h +++ b/sys/boot/efi/include/efipxebc.h @@ -32,7 +32,7 @@ Revision History // #define EFI_PXE_BASE_CODE_PROTOCOL \ - { 0x03c4e603, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } + { 0x03c4e603, 0xac28, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } INTERFACE_DECL(_EFI_PXE_BASE_CODE); @@ -425,7 +425,7 @@ typedef struct _EFI_PXE_BASE_CODE { // #define EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL \ - { 0x245dca21, 0xfb7b, 0x11d3, 0x8f, 0x01, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } + { 0x245dca21, 0xfb7b, 0x11d3, {0x8f, 0x01, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } // // Revision Number diff --git a/sys/boot/efi/include/efiser.h b/sys/boot/efi/include/efiser.h index 1f3fe4a..e3d66e2 100644 --- a/sys/boot/efi/include/efiser.h +++ b/sys/boot/efi/include/efiser.h @@ -30,7 +30,7 @@ Revision History // #define SERIAL_IO_PROTOCOL \ - { 0xBB25CF6F, 0xF1D4, 0x11D2, 0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD } + { 0xBB25CF6F, 0xF1D4, 0x11D2, {0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD} } INTERFACE_DECL(_SERIAL_IO_INTERFACE); diff --git a/sys/boot/efi/include/efiuga.h b/sys/boot/efi/include/efiuga.h index ad129e3..6dfaf50 100644 --- a/sys/boot/efi/include/efiuga.h +++ b/sys/boot/efi/include/efiuga.h @@ -22,9 +22,7 @@ #define __UGA_DRAW_H__ #define EFI_UGA_DRAW_PROTOCOL_GUID \ - { \ - 0x982c298b, 0xf4fa, 0x41cb, {0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39 } \ - } + { 0x982c298b, 0xf4fa, 0x41cb, {0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39} } typedef struct _EFI_UGA_DRAW_PROTOCOL EFI_UGA_DRAW_PROTOCOL; diff --git a/sys/boot/efi/include/i386/efibind.h b/sys/boot/efi/include/i386/efibind.h index de3658f..6e5a716 100644 --- a/sys/boot/efi/include/i386/efibind.h +++ b/sys/boot/efi/include/i386/efibind.h @@ -39,7 +39,7 @@ Revision History // No ANSI C 1999/2000 stdint.h integer width declarations - #if _MSC_EXTENSIONS + #ifdef _MSC_EXTENSIONS // Use Microsoft C compiler integer width declarations @@ -160,7 +160,7 @@ typedef uint32_t UINTN; // #ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options - #if _MSC_EXTENSIONS + #ifdef _MSC_EXTENSIONS #define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler #else #define EFIAPI // Substitute expresion to force C calling convention @@ -261,7 +261,7 @@ typedef uint32_t UINTN; #endif #endif /* __FreeBSD__ */ -#if _MSC_EXTENSIONS +#ifdef _MSC_EXTENSIONS #pragma warning ( disable : 4731 ) // Suppress warnings about modification of EBP #endif diff --git a/sys/boot/efi/libefi/Makefile b/sys/boot/efi/libefi/Makefile index d248927..bb2f9ea 100644 --- a/sys/boot/efi/libefi/Makefile +++ b/sys/boot/efi/libefi/Makefile @@ -2,6 +2,7 @@ LIB= efi INTERNALLIB= +WARNS?= 2 SRCS= delay.c efi_console.c efinet.c efipart.c errno.c handles.c \ libefi.c time.c @@ -21,5 +22,6 @@ CFLAGS+= -I${.CURDIR}/../../common # Handle FreeBSD specific %b and %D printf format specifiers CFLAGS+= ${FORMAT_EXTENSIONS} +CFLAGS+= -DTERM_EMU .include <bsd.lib.mk> diff --git a/sys/boot/efi/libefi/efi_console.c b/sys/boot/efi/libefi/efi_console.c index 3538994..daf1338 100644 --- a/sys/boot/efi/libefi/efi_console.c +++ b/sys/boot/efi/libefi/efi_console.c @@ -35,6 +35,71 @@ __FBSDID("$FreeBSD$"); static SIMPLE_TEXT_OUTPUT_INTERFACE *conout; static SIMPLE_INPUT_INTERFACE *conin; +#ifdef TERM_EMU +#define DEFAULT_FGCOLOR EFI_LIGHTGRAY +#define DEFAULT_BGCOLOR EFI_BLACK + +#define MAXARGS 8 +static int args[MAXARGS], argc; +static int fg_c, bg_c, curx, cury; +static int esc; + +void get_pos(int *x, int *y); +void curs_move(int *_x, int *_y, int x, int y); +static void CL(int); +void HO(void); +void end_term(void); +#endif + +static void efi_cons_probe(struct console *); +static int efi_cons_init(int); +void efi_cons_putchar(int); +int efi_cons_getchar(void); +void efi_cons_efiputchar(int); +int efi_cons_poll(void); + +struct console efi_console = { + "efi", + "EFI console", + 0, + efi_cons_probe, + efi_cons_init, + efi_cons_putchar, + efi_cons_getchar, + efi_cons_poll +}; + +#ifdef TERM_EMU + +/* Get cursor position. */ +void +get_pos(int *x, int *y) +{ + *x = conout->Mode->CursorColumn; + *y = conout->Mode->CursorRow; +} + +/* Move cursor to x rows and y cols (0-based). */ +void +curs_move(int *_x, int *_y, int x, int y) +{ + conout->SetCursorPosition(conout, x, y); + if (_x != NULL) + *_x = conout->Mode->CursorColumn; + if (_y != NULL) + *_y = conout->Mode->CursorRow; +} + +/* Clear internal state of the terminal emulation code. */ +void +end_term(void) +{ + esc = 0; + argc = -1; +} + +#endif + static void efi_cons_probe(struct console *cp) { @@ -46,22 +111,314 @@ efi_cons_probe(struct console *cp) static int efi_cons_init(int arg) { - conout->SetAttribute(conout, EFI_TEXT_ATTR(EFI_LIGHTGRAY, EFI_BLACK)); + conout->SetAttribute(conout, EFI_TEXT_ATTR(DEFAULT_FGCOLOR, + DEFAULT_BGCOLOR)); +#ifdef TERM_EMU + end_term(); + get_pos(&curx, &cury); + curs_move(&curx, &cury, curx, cury); + fg_c = DEFAULT_FGCOLOR; + bg_c = DEFAULT_BGCOLOR; +#endif + conout->EnableCursor(conout, TRUE); return 0; } +static void +efi_cons_rawputchar(int c) +{ + int i; + UINTN x, y; + conout->QueryMode(conout, conout->Mode->Mode, &x, &y); + + if (c == '\t') + /* XXX lame tab expansion */ + for (i = 0; i < 8; i++) + efi_cons_rawputchar(' '); + else { +#ifndef TERM_EMU + if (c == '\n') + efi_cons_efiputchar('\r'); + else + efi_cons_efiputchar(c); +#else + switch (c) { + case '\r': + curx = 0; + curs_move(&curx, &cury, curx, cury); + return; + case '\n': + cury++; + if (cury >= y) { + efi_cons_efiputchar('\n'); + cury--; + } else + curs_move(&curx, &cury, curx, cury); + return; + case '\b': + if (curx > 0) { + curx--; + curs_move(&curx, &cury, curx, cury); + } + return; + default: + efi_cons_efiputchar(c); + curx++; + if (curx > x-1) { + curx = 0; + cury++; + } + if (cury > y-1) { + curx = 0; + cury--; + } + } + curs_move(&curx, &cury, curx, cury); +#endif + } +} + +/* Gracefully exit ESC-sequence processing in case of misunderstanding. */ +static void +bail_out(int c) +{ + char buf[16], *ch; + int i; + + if (esc) { + efi_cons_rawputchar('\033'); + if (esc != '\033') + efi_cons_rawputchar(esc); + for (i = 0; i <= argc; ++i) { + sprintf(buf, "%d", args[i]); + ch = buf; + while (*ch) + efi_cons_rawputchar(*ch++); + } + } + efi_cons_rawputchar(c); + end_term(); +} + +/* Clear display from current position to end of screen. */ +static void +CD(void) { + int i; + UINTN x, y; + + get_pos(&curx, &cury); + if (curx == 0 && cury == 0) { + conout->ClearScreen(conout); + end_term(); + return; + } + + conout->QueryMode(conout, conout->Mode->Mode, &x, &y); + CL(0); /* clear current line from cursor to end */ + for (i = cury + 1; i < y-1; i++) { + curs_move(NULL, NULL, 0, i); + CL(0); + } + curs_move(NULL, NULL, curx, cury); + end_term(); +} + +/* + * Absolute cursor move to args[0] rows and args[1] columns + * (the coordinates are 1-based). + */ +static void +CM(void) +{ + if (args[0] > 0) + args[0]--; + if (args[1] > 0) + args[1]--; + curs_move(&curx, &cury, args[1], args[0]); + end_term(); +} + +/* Home cursor (left top corner), also called from mode command. */ void -efi_cons_putchar(int c) +HO(void) { - CHAR16 buf[2]; + argc = 1; + args[0] = args[1] = 1; + CM(); +} - if (c == '\n') - efi_cons_putchar('\r'); +/* Clear line from current position to end of line */ +static void +CL(int direction) +{ + int i, len; + UINTN x, y; + CHAR16 *line; - buf[0] = c; - buf[1] = 0; + conout->QueryMode(conout, conout->Mode->Mode, &x, &y); + switch (direction) { + case 0: /* from cursor to end */ + len = x - curx + 1; + break; + case 1: /* from beginning to cursor */ + len = curx; + break; + case 2: /* entire line */ + len = x; + break; + } - conout->OutputString(conout, buf); + if (cury == y - 1) + len--; + + line = malloc(len * sizeof (CHAR16)); + if (line == NULL) { + printf("out of memory\n"); + return; + } + for (i = 0; i < len; i++) + line[i] = ' '; + line[len-1] = 0; + + if (direction != 0) + curs_move(NULL, NULL, 0, cury); + + conout->OutputString(conout, line); + /* restore cursor position */ + curs_move(NULL, NULL, curx, cury); + free(line); + end_term(); +} + +static void +get_arg(int c) +{ + if (argc < 0) + argc = 0; + args[argc] *= 10; + args[argc] += c - '0'; +} + +/* Emulate basic capabilities of cons25 terminal */ +static void +efi_term_emu(int c) +{ + static int ansi_col[] = { + 0, 4, 2, 6, 1, 5, 3, 7 + }; + int t, i; + + switch (esc) { + case 0: + switch (c) { + case '\033': + esc = c; + break; + default: + efi_cons_rawputchar(c); + break; + } + break; + case '\033': + switch (c) { + case '[': + esc = c; + args[0] = 0; + argc = -1; + break; + default: + bail_out(c); + break; + } + break; + case '[': + switch (c) { + case ';': + if (argc < 0) + argc = 0; + else if (argc + 1 >= MAXARGS) + bail_out(c); + else + args[++argc] = 0; + break; + case 'H': /* ho = \E[H */ + if (argc < 0) + HO(); + else if (argc == 1) + CM(); + else + bail_out(c); + break; + case 'J': /* cd = \E[J */ + if (argc < 0) + CD(); + else + bail_out(c); + break; + case 'm': + if (argc < 0) { + fg_c = DEFAULT_FGCOLOR; + bg_c = DEFAULT_BGCOLOR; + } + for (i = 0; i <= argc; ++i) { + switch (args[i]) { + case 0: /* back to normal */ + fg_c = DEFAULT_FGCOLOR; + bg_c = DEFAULT_BGCOLOR; + break; + case 1: /* bold */ + fg_c |= 0x8; + break; + case 4: /* underline */ + case 5: /* blink */ + bg_c |= 0x8; + break; + case 7: /* reverse */ + t = fg_c; + fg_c = bg_c; + bg_c = t; + break; + case 30: case 31: case 32: case 33: + case 34: case 35: case 36: case 37: + fg_c = ansi_col[args[i] - 30]; + break; + case 39: /* normal */ + fg_c = DEFAULT_FGCOLOR; + break; + case 40: case 41: case 42: case 43: + case 44: case 45: case 46: case 47: + bg_c = ansi_col[args[i] - 40]; + break; + case 49: /* normal */ + bg_c = DEFAULT_BGCOLOR; + break; + } + } + conout->SetAttribute(conout, EFI_TEXT_ATTR(fg_c, bg_c)); + end_term(); + break; + default: + if (isdigit(c)) + get_arg(c); + else + bail_out(c); + break; + } + break; + default: + bail_out(c); + break; + } +} + +void +efi_cons_putchar(int c) +{ +#ifdef TERM_EMU + efi_term_emu(c); +#else + efi_cons_rawputchar(c); +#endif } int @@ -77,6 +434,12 @@ efi_cons_getchar() BS->WaitForEvent(1, &conin->WaitForKey, &junk); status = conin->ReadKeyStroke(conin, &key); } + switch (key.ScanCode) { + case 0x17: /* ESC */ + return (0x1b); /* esc */ + } + + /* this can return */ return (key.UnicodeChar); } @@ -87,13 +450,36 @@ efi_cons_poll() return (BS->CheckEvent(conin->WaitForKey) == EFI_SUCCESS); } -struct console efi_console = { - "efi", - "EFI console", - 0, - efi_cons_probe, - efi_cons_init, - efi_cons_putchar, - efi_cons_getchar, - efi_cons_poll -}; +/* Plain direct access to EFI OutputString(). */ +void +efi_cons_efiputchar(int c) +{ + CHAR16 buf[2]; + + /* + * translate box chars to unicode + */ + switch (c) { + /* single frame */ + case 0xb3: buf[0] = BOXDRAW_VERTICAL; break; + case 0xbf: buf[0] = BOXDRAW_DOWN_LEFT; break; + case 0xc0: buf[0] = BOXDRAW_UP_RIGHT; break; + case 0xc4: buf[0] = BOXDRAW_HORIZONTAL; break; + case 0xda: buf[0] = BOXDRAW_DOWN_RIGHT; break; + case 0xd9: buf[0] = BOXDRAW_UP_LEFT; break; + + /* double frame */ + case 0xba: buf[0] = BOXDRAW_DOUBLE_VERTICAL; break; + case 0xbb: buf[0] = BOXDRAW_DOUBLE_DOWN_LEFT; break; + case 0xbc: buf[0] = BOXDRAW_DOUBLE_UP_LEFT; break; + case 0xc8: buf[0] = BOXDRAW_DOUBLE_UP_RIGHT; break; + case 0xc9: buf[0] = BOXDRAW_DOUBLE_DOWN_RIGHT; break; + case 0xcd: buf[0] = BOXDRAW_DOUBLE_HORIZONTAL; break; + + default: + buf[0] = c; + } + buf[1] = 0; /* terminate string */ + + conout->OutputString(conout, buf); +} diff --git a/sys/boot/efi/libefi/efipart.c b/sys/boot/efi/libefi/efipart.c index 0831a98..757d64f 100644 --- a/sys/boot/efi/libefi/efipart.c +++ b/sys/boot/efi/libefi/efipart.c @@ -67,7 +67,6 @@ efipart_init(void) EFI_HANDLE *hin, *hout, *aliases, handle; EFI_STATUS status; UINTN sz; - CHAR16 *path; u_int n, nin, nout; int err; size_t devpathlen; diff --git a/sys/boot/efi/libefi/libefi.c b/sys/boot/efi/libefi/libefi.c index 3c66b04..f87b89a 100644 --- a/sys/boot/efi/libefi/libefi.c +++ b/sys/boot/efi/libefi/libefi.c @@ -179,7 +179,7 @@ efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table) argv = malloc((argc + 1) * sizeof(CHAR16*)); argc = 0; if (addprog) - argv[argc++] = L"loader.efi"; + argv[argc++] = (CHAR16 *)L"loader.efi"; argp = args; while (argp != NULL && *argp != 0) { argp = arg_skipsep(argp); diff --git a/sys/boot/efi/loader/Makefile b/sys/boot/efi/loader/Makefile index d6bd9c7..56f3cab 100644 --- a/sys/boot/efi/loader/Makefile +++ b/sys/boot/efi/loader/Makefile @@ -11,6 +11,7 @@ MK_SSP= no PROG= loader.sym INTERNALPROG= +WARNS?= 3 # architecture-specific loader code SRCS= autoload.c \ diff --git a/sys/boot/efi/loader/arch/amd64/elf64_freebsd.c b/sys/boot/efi/loader/arch/amd64/elf64_freebsd.c index c1dbec2..1b95cde 100644 --- a/sys/boot/efi/loader/arch/amd64/elf64_freebsd.c +++ b/sys/boot/efi/loader/arch/amd64/elf64_freebsd.c @@ -100,7 +100,6 @@ elf64_exec(struct preloaded_file *fp) ACPI_TABLE_RSDP *rsdp; char buf[24]; int revision; - EFI_STATUS status; rsdp = efi_get_table(&acpi20_guid); if (rsdp == NULL) { diff --git a/sys/boot/efi/loader/arch/amd64/framebuffer.c b/sys/boot/efi/loader/arch/amd64/framebuffer.c index eb78f7b..d861ee4 100644 --- a/sys/boot/efi/loader/arch/amd64/framebuffer.c +++ b/sys/boot/efi/loader/arch/amd64/framebuffer.c @@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$"); #include <efipciio.h> #include <machine/metadata.h> +#include "framebuffer.h" + static EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; static EFI_GUID pciio_guid = EFI_PCI_IO_PROTOCOL_GUID; static EFI_GUID uga_guid = EFI_UGA_DRAW_PROTOCOL_GUID; @@ -178,7 +180,7 @@ efifb_uga_find_pixel(EFI_UGA_DRAW_PROTOCOL *uga, u_int line, printf("No change detected in frame buffer"); fail: - printf(" -- error %lu\n", status & ~EFI_ERROR_MASK); + printf(" -- error %lu\n", EFI_ERROR_CODE(status)); free(data1); return (-1); } @@ -270,7 +272,7 @@ efifb_from_uga(struct efi_fb *efifb, EFI_UGA_DRAW_PROTOCOL *uga) char *ev, *p; EFI_STATUS status; ssize_t offset; - uint64_t fbaddr, fbsize; + uint64_t fbaddr; uint32_t horiz, vert, stride; uint32_t np, depth, refresh; @@ -473,7 +475,7 @@ command_gop(int argc, char *argv[]) status = BS->LocateProtocol(&gop_guid, NULL, (VOID **)&gop); if (EFI_ERROR(status)) { sprintf(command_errbuf, "%s: Graphics Output Protocol not " - "present (error=%lu)", argv[0], status & ~EFI_ERROR_MASK); + "present (error=%lu)", argv[0], EFI_ERROR_CODE(status)); return (CMD_ERROR); } @@ -494,7 +496,7 @@ command_gop(int argc, char *argv[]) if (EFI_ERROR(status)) { sprintf(command_errbuf, "%s: Unable to set mode to " "%u (error=%lu)", argv[0], mode, - status & ~EFI_ERROR_MASK); + EFI_ERROR_CODE(status)); return (CMD_ERROR); } } else if (!strcmp(argv[1], "get")) { @@ -541,7 +543,7 @@ command_uga(int argc, char *argv[]) status = BS->LocateProtocol(&uga_guid, NULL, (VOID **)&uga); if (EFI_ERROR(status)) { sprintf(command_errbuf, "%s: UGA Protocol not present " - "(error=%lu)", argv[0], status & ~EFI_ERROR_MASK); + "(error=%lu)", argv[0], EFI_ERROR_CODE(status)); return (CMD_ERROR); } diff --git a/sys/boot/efi/loader/arch/arm/exec.c b/sys/boot/efi/loader/arch/arm/exec.c index 7c51e6e..716c7d3 100644 --- a/sys/boot/efi/loader/arch/arm/exec.c +++ b/sys/boot/efi/loader/arch/arm/exec.c @@ -44,8 +44,9 @@ __FBSDID("$FreeBSD$"); #include "loader_efi.h" extern vm_offset_t md_load(char *, vm_offset_t *); +extern int bi_load(char *, vm_offset_t *, vm_offset_t *); -int +static int __elfN(arm_load)(char *filename, u_int64_t dest, struct preloaded_file **result) { @@ -58,7 +59,7 @@ __elfN(arm_load)(char *filename, u_int64_t dest, return (0); } -int +static int __elfN(arm_exec)(struct preloaded_file *fp) { struct file_metadata *fmp; @@ -66,7 +67,6 @@ __elfN(arm_exec)(struct preloaded_file *fp) Elf_Ehdr *e; int error; void (*entry)(void *); - EFI_STATUS status; if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) return (EFTYPE); diff --git a/sys/boot/efi/loader/arch/arm64/exec.c b/sys/boot/efi/loader/arch/arm64/exec.c index 0746c05..a0f8b83 100644 --- a/sys/boot/efi/loader/arch/arm64/exec.c +++ b/sys/boot/efi/loader/arch/arm64/exec.c @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include "platform/acfreebsd.h" #include "acconfig.h" #define ACPI_SYSTEM_XFACE +#define ACPI_USE_SYSTEM_INTTYPES #include "actypes.h" #include "actbl.h" @@ -74,8 +75,6 @@ elf64_exec(struct preloaded_file *fp) size_t clean_size; struct file_metadata *md; ACPI_TABLE_RSDP *rsdp; - EFI_STATUS status; - EFI_PHYSICAL_ADDRESS addr; Elf_Ehdr *ehdr; char buf[24]; int err, revision; @@ -119,8 +118,8 @@ elf64_exec(struct preloaded_file *fp) return (err); /* Clean D-cache under kernel area and invalidate whole I-cache */ - clean_addr = efi_translate(fp->f_addr); - clean_size = efi_translate(kernendp) - clean_addr; + clean_addr = (vm_offset_t)efi_translate(fp->f_addr); + clean_size = (vm_offset_t)efi_translate(kernendp) - clean_addr; cpu_flush_dcache((void *)clean_addr, clean_size); cpu_inval_icache(NULL, 0); diff --git a/sys/boot/efi/loader/autoload.c b/sys/boot/efi/loader/autoload.c index 694a6da..c1eb849 100644 --- a/sys/boot/efi/loader/autoload.c +++ b/sys/boot/efi/loader/autoload.c @@ -27,6 +27,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "loader_efi.h" + int efi_autoload(void) { diff --git a/sys/boot/efi/loader/bootinfo.c b/sys/boot/efi/loader/bootinfo.c index 622f4c6..c6a76ab 100644 --- a/sys/boot/efi/loader/bootinfo.c +++ b/sys/boot/efi/loader/bootinfo.c @@ -55,6 +55,8 @@ __FBSDID("$FreeBSD$"); #include <fdt_platform.h> #endif +int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp); + extern EFI_SYSTEM_TABLE *ST; static const char howto_switches[] = "aCdrgDmphsv"; @@ -122,7 +124,7 @@ bi_copyenv(vm_offset_t start) /* Traverse the environment. */ for (ep = environ; ep != NULL; ep = ep->ev_next) { len = strlen(ep->ev_name); - if (archsw.arch_copyin(ep->ev_name, addr, len) != len) + if ((size_t)archsw.arch_copyin(ep->ev_name, addr, len) != len) break; addr += len; if (archsw.arch_copyin("=", addr, 1) != 1) @@ -130,7 +132,7 @@ bi_copyenv(vm_offset_t start) addr++; if (ep->ev_value != NULL) { len = strlen(ep->ev_value); - if (archsw.arch_copyin(ep->ev_value, addr, len) != len) + if ((size_t)archsw.arch_copyin(ep->ev_value, addr, len) != len) break; addr += len; } @@ -290,7 +292,7 @@ bi_load_efi_data(struct preloaded_file *kfp) pages, &addr); if (EFI_ERROR(status)) { printf("%s: AllocatePages error %lu\n", __func__, - (unsigned long)(status & ~EFI_ERROR_MASK)); + EFI_ERROR_CODE(status)); return (ENOMEM); } @@ -306,7 +308,7 @@ bi_load_efi_data(struct preloaded_file *kfp) status = BS->GetMemoryMap(&sz, mm, &efi_mapkey, &mmsz, &mmver); if (EFI_ERROR(status)) { printf("%s: GetMemoryMap error %lu\n", __func__, - (unsigned long)(status & ~EFI_ERROR_MASK)); + EFI_ERROR_CODE(status)); return (EINVAL); } status = BS->ExitBootServices(IH, efi_mapkey); @@ -320,8 +322,7 @@ bi_load_efi_data(struct preloaded_file *kfp) } BS->FreePages(addr, pages); } - printf("ExitBootServices error %lu\n", - (unsigned long)(status & ~EFI_ERROR_MASK)); + printf("ExitBootServices error %lu\n", EFI_ERROR_CODE(status)); return (EINVAL); } @@ -352,7 +353,7 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp) #endif #if defined(__arm__) vm_offset_t vaddr; - int i; + size_t i; /* * These metadata addreses must be converted for kernel after * relocation. diff --git a/sys/boot/efi/loader/copy.c b/sys/boot/efi/loader/copy.c index 716e9ea..128196e 100644 --- a/sys/boot/efi/loader/copy.c +++ b/sys/boot/efi/loader/copy.c @@ -37,6 +37,8 @@ __FBSDID("$FreeBSD$"); #include <efi.h> #include <efilib.h> +#include "loader_efi.h" + #ifndef EFI_STAGING_SIZE #define EFI_STAGING_SIZE 48 #endif @@ -56,7 +58,7 @@ efi_copy_init(void) STAGE_PAGES, &staging); if (EFI_ERROR(status)) { printf("failed to allocate staging area: %lu\n", - (unsigned long)(status & EFI_ERROR_MASK)); + EFI_ERROR_CODE(status)); return (status); } staging_end = staging + STAGE_PAGES * EFI_PAGE_SIZE; diff --git a/sys/boot/efi/loader/devicename.c b/sys/boot/efi/loader/devicename.c index 89f9941..45f9871 100644 --- a/sys/boot/efi/loader/devicename.c +++ b/sys/boot/efi/loader/devicename.c @@ -31,11 +31,13 @@ __FBSDID("$FreeBSD$"); #include <stand.h> #include <string.h> #include <sys/disklabel.h> -#include "bootstrap.h" +#include <bootstrap.h> #include <efi.h> #include <efilib.h> +#include "loader_efi.h" + static int efi_parsedev(struct devdesc **, const char *, const char **); /* @@ -147,7 +149,7 @@ efi_fmtdev(void *vdev) break; } - return(buf); + return (buf); } /* @@ -161,7 +163,7 @@ efi_setcurrdev(struct env_var *ev, int flags, const void *value) rv = efi_parsedev(&ncurr, value, NULL); if (rv != 0) - return(rv); + return (rv); free(ncurr); env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); diff --git a/sys/boot/efi/loader/loader_efi.h b/sys/boot/efi/loader/loader_efi.h index 5819d78..ee7c4bb 100644 --- a/sys/boot/efi/loader/loader_efi.h +++ b/sys/boot/efi/loader/loader_efi.h @@ -31,6 +31,8 @@ #ifndef _LOADER_EFI_COPY_H_ #define _LOADER_EFI_COPY_H_ +#include <stand.h> + int efi_autoload(void); int efi_getdev(void **vdev, const char *devspec, const char **path); diff --git a/sys/boot/efi/loader/main.c b/sys/boot/efi/loader/main.c index fc8949e..ddd96b4 100644 --- a/sys/boot/efi/loader/main.c +++ b/sys/boot/efi/loader/main.c @@ -68,6 +68,7 @@ main(int argc, CHAR16 *argv[]) EFI_LOADED_IMAGE *img; EFI_GUID *guid; int i, j, vargood; + UINTN k; /* * XXX Chicken-and-egg problem; we want to have console output @@ -155,10 +156,10 @@ main(int argc, CHAR16 *argv[]) archsw.arch_copyout = efi_copyout; archsw.arch_readin = efi_readin; - for (i = 0; i < ST->NumberOfTableEntries; i++) { - guid = &ST->ConfigurationTable[i].VendorGuid; + for (k = 0; k < ST->NumberOfTableEntries; k++) { + guid = &ST->ConfigurationTable[k].VendorGuid; if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) { - smbios_detect(ST->ConfigurationTable[i].VendorTable); + smbios_detect(ST->ConfigurationTable[k].VendorTable); break; } } @@ -227,50 +228,48 @@ command_memmap(int argc, char *argv[]) status = BS->GetMemoryMap(&sz, 0, &key, &dsz, &dver); if (status != EFI_BUFFER_TOO_SMALL) { printf("Can't determine memory map size\n"); - return CMD_ERROR; + return (CMD_ERROR); } map = malloc(sz); status = BS->GetMemoryMap(&sz, map, &key, &dsz, &dver); if (EFI_ERROR(status)) { printf("Can't read memory map\n"); - return CMD_ERROR; + return (CMD_ERROR); } ndesc = sz / dsz; printf("%23s %12s %12s %8s %4s\n", - "Type", "Physical", "Virtual", "#Pages", "Attr"); + "Type", "Physical", "Virtual", "#Pages", "Attr"); for (i = 0, p = map; i < ndesc; i++, p = NextMemoryDescriptor(p, dsz)) { - printf("%23s %012lx %012lx %08lx ", - types[p->Type], - p->PhysicalStart, - p->VirtualStart, - p->NumberOfPages); - if (p->Attribute & EFI_MEMORY_UC) - printf("UC "); - if (p->Attribute & EFI_MEMORY_WC) - printf("WC "); - if (p->Attribute & EFI_MEMORY_WT) - printf("WT "); - if (p->Attribute & EFI_MEMORY_WB) - printf("WB "); - if (p->Attribute & EFI_MEMORY_UCE) - printf("UCE "); - if (p->Attribute & EFI_MEMORY_WP) - printf("WP "); - if (p->Attribute & EFI_MEMORY_RP) - printf("RP "); - if (p->Attribute & EFI_MEMORY_XP) - printf("XP "); - printf("\n"); + printf("%23s %012jx %012jx %08jx ", types[p->Type], + (uintmax_t)p->PhysicalStart, (uintmax_t)p->VirtualStart, + (uintmax_t)p->NumberOfPages); + if (p->Attribute & EFI_MEMORY_UC) + printf("UC "); + if (p->Attribute & EFI_MEMORY_WC) + printf("WC "); + if (p->Attribute & EFI_MEMORY_WT) + printf("WT "); + if (p->Attribute & EFI_MEMORY_WB) + printf("WB "); + if (p->Attribute & EFI_MEMORY_UCE) + printf("UCE "); + if (p->Attribute & EFI_MEMORY_WP) + printf("WP "); + if (p->Attribute & EFI_MEMORY_RP) + printf("RP "); + if (p->Attribute & EFI_MEMORY_XP) + printf("XP "); + printf("\n"); } - return CMD_OK; + return (CMD_OK); } -COMMAND_SET(configuration, "configuration", - "print configuration tables", command_configuration); +COMMAND_SET(configuration, "configuration", "print configuration tables", + command_configuration); static const char * guid_to_string(EFI_GUID *guid) @@ -287,9 +286,10 @@ guid_to_string(EFI_GUID *guid) static int command_configuration(int argc, char *argv[]) { - int i; + UINTN i; - printf("NumberOfTableEntries=%ld\n", ST->NumberOfTableEntries); + printf("NumberOfTableEntries=%lu\n", + (unsigned long)ST->NumberOfTableEntries); for (i = 0; i < ST->NumberOfTableEntries; i++) { EFI_GUID *guid; @@ -318,7 +318,7 @@ command_configuration(int argc, char *argv[]) printf(" at %p\n", ST->ConfigurationTable[i].VendorTable); } - return CMD_OK; + return (CMD_OK); } @@ -334,6 +334,7 @@ command_mode(int argc, char *argv[]) char rowenv[8]; EFI_STATUS status; SIMPLE_TEXT_OUTPUT_INTERFACE *conout; + extern void HO(void); conout = ST->ConOut; @@ -355,14 +356,15 @@ command_mode(int argc, char *argv[]) } sprintf(rowenv, "%u", (unsigned)rows); setenv("LINES", rowenv, 1); - + HO(); /* set cursor */ return (CMD_OK); } - for (i = 0; ; i++) { + printf("Current mode: %d\n", conout->Mode->Mode); + for (i = 0; i <= conout->Mode->MaxMode; i++) { status = conout->QueryMode(conout, i, &cols, &rows); if (EFI_ERROR(status)) - break; + continue; printf("Mode %d: %u columns, %u rows\n", i, (unsigned)cols, (unsigned)rows); } @@ -383,9 +385,8 @@ command_nvram(int argc, char *argv[]) CHAR16 *data; EFI_STATUS status; EFI_GUID varguid = { 0,0,0,{0,0,0,0,0,0,0,0} }; - UINTN varsz, datasz; + UINTN varsz, datasz, i; SIMPLE_TEXT_OUTPUT_INTERFACE *conout; - int i; conout = ST->ConOut; @@ -393,20 +394,17 @@ command_nvram(int argc, char *argv[]) status = RS->GetNextVariableName(&varsz, NULL, NULL); for (; status != EFI_NOT_FOUND; ) { - status = RS->GetNextVariableName(&varsz, var, - &varguid); + status = RS->GetNextVariableName(&varsz, var, &varguid); //if (EFI_ERROR(status)) //break; conout->OutputString(conout, var); printf("="); datasz = 0; - status = RS->GetVariable(var, &varguid, NULL, &datasz, - NULL); + status = RS->GetVariable(var, &varguid, NULL, &datasz, NULL); /* XXX: check status */ data = malloc(datasz); - status = RS->GetVariable(var, &varguid, NULL, &datasz, - data); + status = RS->GetVariable(var, &varguid, NULL, &datasz, data); if (EFI_ERROR(status)) printf("<error retrieving variable>"); else { diff --git a/sys/boot/ficl/amd64/sysdep.c b/sys/boot/ficl/amd64/sysdep.c index ad38660..5957b71 100644 --- a/sys/boot/ficl/amd64/sysdep.c +++ b/sys/boot/ficl/amd64/sysdep.c @@ -55,7 +55,7 @@ void ficlTextOut(FICL_VM *pVM, char *msg, int fNewline) IGNORE(pVM); while(*msg != 0) - putchar(*(msg++)); + putchar((unsigned char)*(msg++)); if (fNewline) putchar('\n'); diff --git a/sys/boot/forth/beastie.4th b/sys/boot/forth/beastie.4th index 52c403f..752cce2 100644 --- a/sys/boot/forth/beastie.4th +++ b/sys/boot/forth/beastie.4th @@ -85,11 +85,6 @@ variable logoY also support-functions : beastie-start ( -- ) \ starts the menu - s" console" getenv dup -1 <> if - s" efi" 2swap contains? if - s" set beastie_disable=YES" evaluate - then - else drop then s" beastie_disable" getenv dup -1 <> if s" YES" compare-insensitive 0= if any_conf_read? if diff --git a/sys/boot/forth/beastie.4th.8 b/sys/boot/forth/beastie.4th.8 index 534a60c..9f77d5d 100644 --- a/sys/boot/forth/beastie.4th.8 +++ b/sys/boot/forth/beastie.4th.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 27, 2014 +.Dd January 6, 2016 .Dt BEASTIE.4TH 8 .Os .Sh NAME @@ -119,8 +119,7 @@ Sets the desired row position of the logo. Default is 4. If set to .Dq YES , the beastie boot menu will be skipped. -The beastie boot menu is always skipped if booting UEFI or running non-x86 -hardware. +The beastie boot menu is always skipped if running non-x86 hardware. .It Va loader_delay If set to a number higher than zero, introduces a delay before starting the beastie boot menu. During the delay the user can press either Ctrl-C to skip diff --git a/sys/boot/forth/loader.conf.5 b/sys/boot/forth/loader.conf.5 index 37f10bf..0320e98 100644 --- a/sys/boot/forth/loader.conf.5 +++ b/sys/boot/forth/loader.conf.5 @@ -23,7 +23,7 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd April 27, 2014 +.Dd January 6, 2016 .Dt LOADER.CONF 5 .Os .Sh NAME @@ -236,8 +236,7 @@ be displayed. If set to .Dq YES , the beastie boot menu will be skipped. -The beastie boot menu is always skipped if booting UEFI or running non-x86 -hardware. +The beastie boot menu is always skipped if running non-x86 hardware. .It Va loader_logo Pq Dq Li orbbw Selects a desired logo in the beastie boot menu. Possible values are: diff --git a/sys/boot/i386/libi386/smbios.c b/sys/boot/i386/libi386/smbios.c index 6e4fb84..7a7ce4b 100644 --- a/sys/boot/i386/libi386/smbios.c +++ b/sys/boot/i386/libi386/smbios.c @@ -332,7 +332,7 @@ static caddr_t smbios_find_struct(int type) { caddr_t dmi; - int i; + size_t i; if (smbios.addr == NULL) return (NULL); @@ -402,7 +402,7 @@ smbios_detect(const caddr_t addr) { char buf[16]; caddr_t dmi; - int i; + size_t i; smbios_probe(addr); if (smbios.addr == NULL) diff --git a/sys/boot/i386/loader/main.c b/sys/boot/i386/loader/main.c index d4073e7..644747e 100644 --- a/sys/boot/i386/loader/main.c +++ b/sys/boot/i386/loader/main.c @@ -296,7 +296,8 @@ extract_currdev(void) } #ifdef LOADER_ZFS_SUPPORT - init_zfs_bootenv(zfs_fmtdev(&new_currdev)); + if (new_currdev.d_type == DEVT_ZFS) + init_zfs_bootenv(zfs_fmtdev(&new_currdev)); #endif env_setenv("currdev", EV_VOLATILE, i386_fmtdev(&new_currdev), @@ -311,9 +312,14 @@ init_zfs_bootenv(char *currdev) { char *beroot; + if (strlen(currdev) == 0) + return; + if(strncmp(currdev, "zfs:", 4) != 0) + return; /* Remove the trailing : */ currdev[strlen(currdev) - 1] = '\0'; setenv("zfs_be_active", currdev, 1); + setenv("zfs_be_currpage", "1", 1); /* Do not overwrite if already set */ setenv("vfs.root.mountfrom", currdev, 0); /* Forward past zfs: */ @@ -321,10 +327,9 @@ init_zfs_bootenv(char *currdev) currdev++; /* Remove the last element (current bootenv) */ beroot = strrchr(currdev, '/'); - beroot[0] = '\0'; - + if (beroot != NULL) + beroot[0] = '\0'; beroot = currdev; - setenv("zfs_be_root", beroot, 1); } #endif @@ -393,6 +398,7 @@ static int command_reloadbe(int argc, char *argv[]) { int err; + char *root; if (argc > 2) { command_errmsg = "wrong number of arguments"; @@ -402,6 +408,11 @@ command_reloadbe(int argc, char *argv[]) if (argc == 2) { err = zfs_bootenv(argv[1]); } else { + root = getenv("zfs_be_root"); + if (root == NULL) { + /* There does not appear to be a ZFS pool here, exit without error */ + return (CMD_OK); + } err = zfs_bootenv(getenv("zfs_be_root")); } diff --git a/sys/boot/libstand32/Makefile b/sys/boot/libstand32/Makefile index 075a9ea..66798d7 100644 --- a/sys/boot/libstand32/Makefile +++ b/sys/boot/libstand32/Makefile @@ -1,151 +1,24 @@ # $FreeBSD$ -# Originally from $NetBSD: Makefile,v 1.21 1997/10/26 22:08:38 lukem Exp $ -# -# Notes: -# - We don't use the libc strerror/sys_errlist because the string table is -# quite large. -# - -MAN= .include <src.opts.mk> -MK_SSP= no LIBSTAND_SRC= ${.CURDIR}/../../../lib/libstand -LIBC_SRC= ${LIBSTAND_SRC}/../libc - -.PATH: ${LIBSTAND_SRC} -LIB= stand -INTERNALLIB= -MK_PROFILE= no -NO_PIC= -.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -m32 -I. -.endif - -WARNS?= 0 - -# standalone components and stuff we have modified locally -SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \ - globals.c pager.c printf.c strdup.c strerror.c strtol.c strtoul.c random.c \ - sbrk.c twiddle.c zalloc.c zalloc_malloc.c - -# private (pruned) versions of libc string functions -SRCS+= strcasecmp.c - -.PATH: ${LIBC_SRC}/net - -SRCS+= ntoh.c - -# string functions from libc -.PATH: ${LIBC_SRC}/string -SRCS+= bcmp.c bcopy.c bzero.c ffs.c memccpy.c memchr.c memcmp.c memcpy.c \ - memmove.c memset.c qdivrem.c strcat.c strchr.c strcmp.c strcpy.c \ - strcspn.c strlcat.c strlcpy.c strlen.c strncat.c strncmp.c strncpy.c \ - strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c -.if ${MACHINE_CPUARCH} == "arm" -.PATH: ${LIBC_SRC}/arm/gen - -# Compiler support functions -.PATH: ${LIBSTAND_SRC}/../../contrib/compiler-rt/lib/builtins/ -# __clzsi2 and ctzsi2 for various builtin functions -SRCS+= clzsi2.c ctzsi2.c -# Divide and modulus functions called by the compiler -SRCS+= divmoddi4.c divmodsi4.c divdi3.c divsi3.c moddi3.c modsi3.c -SRCS+= udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c - -.PATH: ${LIBSTAND_SRC}/../../contrib/compiler-rt/lib/builtins/arm/ -SRCS+= aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S -SRCS+= aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S - -.endif -.if ${MACHINE_CPUARCH} == "powerpc" -.PATH: ${LIBC_SRC}/quad -SRCS+= ashldi3.c ashrdi3.c -SRCS+= syncicache.c -.endif - -# uuid functions from libc -.PATH: ${LIBC_SRC}/uuid -SRCS+= uuid_equal.c uuid_is_nil.c - -# _setjmp/_longjmp .if ${MACHINE_CPUARCH} == "amd64" -.PATH: ${LIBSTAND_SRC}/i386 +LIBSTAND_CPUARCH=i386 .else -.PATH: ${LIBSTAND_SRC}/${MACHINE_CPUARCH} +LIBSTAND_CPUARCH=${MACHINE_CPUARCH} .endif -SRCS+= _setjmp.S - -# decompression functionality from libbz2 -# NOTE: to actually test this functionality after libbz2 upgrade compile -# loader(8) with LOADER_BZIP2_SUPPORT defined -.PATH: ${LIBSTAND_SRC}/../../contrib/bzip2 -CFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS -SRCS+= libstand_bzlib_private.h - -.for file in bzlib.c crctable.c decompress.c huffman.c randtable.c -SRCS+= _${file} -CLEANFILES+= _${file} - -_${file}: ${file} - sed "s|bzlib_private\.h|libstand_bzlib_private.h|" \ - ${.ALLSRC} > ${.TARGET} -.endfor - -CLEANFILES+= libstand_bzlib_private.h -libstand_bzlib_private.h: bzlib_private.h - sed -e 's|<stdlib.h>|"stand.h"|' \ - ${.ALLSRC} > ${.TARGET} - -# decompression functionality from libz -.PATH: ${LIBSTAND_SRC}/../libz -CFLAGS+=-DHAVE_MEMCPY -I${LIBSTAND_SRC}/../libz -SRCS+= adler32.c crc32.c libstand_zutil.h libstand_gzguts.h - -.for file in infback.c inffast.c inflate.c inftrees.c zutil.c -SRCS+= _${file} -CLEANFILES+= _${file} - -_${file}: ${file} - sed -e "s|zutil\.h|libstand_zutil.h|" \ - -e "s|gzguts\.h|libstand_gzguts.h|" \ - ${.ALLSRC} > ${.TARGET} -.endfor - -# depend on stand.h being able to be included multiple times -.for file in zutil.h gzguts.h -CLEANFILES+= libstand_${file} -libstand_${file}: ${file} - sed -e 's|<fcntl.h>|"stand.h"|' \ - -e 's|<stddef.h>|"stand.h"|' \ - -e 's|<string.h>|"stand.h"|' \ - -e 's|<stdio.h>|"stand.h"|' \ - -e 's|<stdlib.h>|"stand.h"|' \ - ${.ALLSRC} > ${.TARGET} -.endfor - -# io routines -SRCS+= closeall.c dev.c ioctl.c nullfs.c stat.c \ - fstat.c close.c lseek.c open.c read.c write.c readdir.c - -# network routines -SRCS+= arp.c ether.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c - -# network info services: -SRCS+= bootp.c rarp.c bootparam.c +LIBC_SRC= ${LIBSTAND_SRC}/../libc +INTERNALLIB= +INCS= +MAN= +.PATH: ${LIBSTAND_SRC} -# boot filesystems -SRCS+= ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c -SRCS+= dosfs.c ext2fs.c -SRCS+= splitfs.c -SRCS+= pkgfs.c -.if ${MK_NAND} != "no" -SRCS+= nandfs.c +.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "powerpc64" +CFLAGS+= -m32 -I. .endif -.include <bsd.stand.mk> -.include <bsd.lib.mk> +.include "${LIBSTAND_SRC}/Makefile" .if ${MACHINE_CPUARCH} == "amd64" CLEANFILES+= machine diff --git a/sys/boot/libstand32/Makefile.depend b/sys/boot/libstand32/Makefile.depend index dae5bcd..57cd80c 100644 --- a/sys/boot/libstand32/Makefile.depend +++ b/sys/boot/libstand32/Makefile.depend @@ -6,7 +6,6 @@ DIRDEPS = \ include/arpa \ include/xlocale \ lib/libbz2 \ - lib/libstand \ .include <dirdeps.mk> diff --git a/sys/boot/powerpc/boot1.chrp/boot1.c b/sys/boot/powerpc/boot1.chrp/boot1.c index 30e695b..af22488 100644 --- a/sys/boot/powerpc/boot1.chrp/boot1.c +++ b/sys/boot/powerpc/boot1.chrp/boot1.c @@ -564,10 +564,6 @@ printf(const char *fmt, ...) va_list ap; int ret; - /* Don't annoy the user as we probe for partitions */ - if (strcmp(fmt,"Not ufs\n") == 0) - return 0; - va_start(ap, fmt); ret = vprintf(fmt, ap); va_end(ap); diff --git a/sys/boot/uboot/lib/copy.c b/sys/boot/uboot/lib/copy.c index 51416ac..131b88d 100644 --- a/sys/boot/uboot/lib/copy.c +++ b/sys/boot/uboot/lib/copy.c @@ -69,11 +69,11 @@ uint64_t uboot_loadaddr(u_int type, void *data, uint64_t addr) { struct sys_info *si; - uintptr_t sblock, eblock, subldr, eubldr; - uintptr_t biggest_block, this_block; - size_t biggest_size, this_size; + uint64_t sblock, eblock, subldr, eubldr; + uint64_t biggest_block, this_block; + uint64_t biggest_size, this_size; int i; - char * envstr; + char *envstr; if (addr == 0) { /* @@ -101,13 +101,14 @@ uboot_loadaddr(u_int type, void *data, uint64_t addr) biggest_block = 0; biggest_size = 0; subldr = rounddown2((uintptr_t)_start, KERN_ALIGN); - eubldr = roundup2(uboot_heap_end, KERN_ALIGN); + eubldr = roundup2((uint64_t)uboot_heap_end, KERN_ALIGN); for (i = 0; i < si->mr_no; i++) { if (si->mr[i].flags != MR_ATTR_DRAM) continue; - sblock = roundup2(si->mr[i].start, KERN_ALIGN); - eblock = rounddown2(si->mr[i].start + si->mr[i].size, + sblock = roundup2((uint64_t)si->mr[i].start, KERN_ALIGN); + eblock = rounddown2((uint64_t)si->mr[i].start + + si->mr[i].size, KERN_ALIGN); if (biggest_size == 0) sblock += KERN_MINADDR; if (subldr >= sblock && subldr < eblock) { @@ -134,9 +135,10 @@ uboot_loadaddr(u_int type, void *data, uint64_t addr) if (biggest_size == 0) panic("Not enough DRAM to load kernel\n"); #if 0 - printf("Loading kernel into region 0x%08x-0x%08x (%u MiB)\n", - biggest_block, biggest_block + biggest_size - 1, - biggest_size / 1024 / 1024); + printf("Loading kernel into region 0x%08jx-0x%08jx (%ju MiB)\n", + (uintmax_t)biggest_block, + (uintmax_t)biggest_block + biggest_size - 1, + (uintmax_t)biggest_size / 1024 / 1024); #endif return (biggest_block); } diff --git a/sys/boot/userboot/libstand/Makefile b/sys/boot/userboot/libstand/Makefile index 401bbdac..d8a1100 100644 --- a/sys/boot/userboot/libstand/Makefile +++ b/sys/boot/userboot/libstand/Makefile @@ -1,136 +1,12 @@ # $FreeBSD$ -# Originally from $NetBSD: Makefile,v 1.21 1997/10/26 22:08:38 lukem Exp $ -# -# Notes: -# - We don't use the libc strerror/sys_errlist because the string table is -# quite large. -# -MAN= - -.include <bsd.own.mk> -MK_SSP= no +.include <src.opts.mk> LIBSTAND_SRC= ${.CURDIR}/../../../../lib/libstand -LIBC_SRC= ${LIBSTAND_SRC}/../libc -.PATH: ${LIBSTAND_SRC} -LIB= stand INTERNALLIB= -MK_PROFILE= no -NO_PIC= - -WARNS?= 0 - -# standalone components and stuff we have modified locally -SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \ - globals.c pager.c printf.c strdup.c strerror.c strtol.c strtoul.c random.c \ - sbrk.c twiddle.c zalloc.c zalloc_malloc.c - -# private (pruned) versions of libc string functions -SRCS+= strcasecmp.c - -.PATH: ${LIBC_SRC}/net - -SRCS+= ntoh.c - -# string functions from libc -.PATH: ${LIBC_SRC}/string -.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "powerpc" || \ - ${MACHINE_CPUARCH} == "sparc64" || ${MACHINE_CPUARCH} == "amd64" || \ - ${MACHINE_CPUARCH} == "arm" -SRCS+= bcmp.c bcopy.c bzero.c ffs.c memccpy.c memchr.c memcmp.c memcpy.c \ - memmove.c memset.c qdivrem.c strcat.c strchr.c strcmp.c strcpy.c \ - strcspn.c strlen.c strncat.c strncmp.c strncpy.c strpbrk.c \ - strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c -.endif -.if ${MACHINE_CPUARCH} == "arm" -.PATH: ${LIBC_SRC}/arm/gen -SRCS+= divsi3.S -.endif -.if ${MACHINE_CPUARCH} == "powerpc" -.PATH: ${LIBC_SRC}/quad -SRCS+= ashldi3.c ashrdi3.c -.PATH: ${LIBC_SRC}/powerpc/gen -SRCS+= syncicache.c -.endif - -# uuid functions from libc -.PATH: ${LIBC_SRC}/uuid -SRCS+= uuid_equal.c uuid_is_nil.c - -# _setjmp/_longjmp -.if ${MACHINE_CPUARCH} == "amd64" -.PATH: ${LIBSTAND_SRC}/amd64 -.elif ${MACHINE_ARCH} == "powerpc64" -.PATH: ${LIBSTAND_SRC}/powerpc -.else -.PATH: ${LIBSTAND_SRC}/${MACHINE_CPUARCH} -.endif -SRCS+= _setjmp.S - -# decompression functionality from libbz2 -# NOTE: to actually test this functionality after libbz2 upgrade compile -# loader(8) with LOADER_BZIP2_SUPPORT defined -.PATH: ${LIBSTAND_SRC}/../../contrib/bzip2 -CFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS -SRCS+= libstand_bzlib_private.h - -.for file in bzlib.c crctable.c decompress.c huffman.c randtable.c -SRCS+= _${file} -CLEANFILES+= _${file} - -_${file}: ${file} - sed "s|bzlib_private\.h|libstand_bzlib_private.h|" \ - ${.ALLSRC} > ${.TARGET} -.endfor - -CLEANFILES+= libstand_bzlib_private.h -libstand_bzlib_private.h: bzlib_private.h - sed -e 's|<stdlib.h>|"stand.h"|' \ - ${.ALLSRC} > ${.TARGET} - -# decompression functionality from libz -.PATH: ${LIBSTAND_SRC}/../libz -CFLAGS+=-DHAVE_MEMCPY -I${LIBSTAND_SRC}/../libz -SRCS+= adler32.c crc32.c libstand_zutil.h libstand_gzguts.h - -.for file in infback.c inffast.c inflate.c inftrees.c zutil.c -SRCS+= _${file} -CLEANFILES+= _${file} - -_${file}: ${file} - sed -e "s|zutil\.h|libstand_zutil.h|" \ - -e "s|gzguts\.h|libstand_gzguts.h|" \ - ${.ALLSRC} > ${.TARGET} -.endfor - -# depend on stand.h being able to be included multiple times -.for file in zutil.h gzguts.h -CLEANFILES+= libstand_${file} -libstand_${file}: ${file} - sed -e 's|<fcntl.h>|"stand.h"|' \ - -e 's|<stddef.h>|"stand.h"|' \ - -e 's|<string.h>|"stand.h"|' \ - -e 's|<stdio.h>|"stand.h"|' \ - -e 's|<stdlib.h>|"stand.h"|' \ - ${.ALLSRC} > ${.TARGET} -.endfor - -# io routines -SRCS+= closeall.c dev.c ioctl.c nullfs.c stat.c \ - fstat.c close.c lseek.c open.c read.c write.c readdir.c - -# network routines -SRCS+= arp.c ether.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c - -# network info services: -SRCS+= bootp.c rarp.c bootparam.c - -# boot filesystems -SRCS+= ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c -SRCS+= dosfs.c ext2fs.c -SRCS+= splitfs.c +INCS= +MAN= +.PATH: ${LIBSTAND_SRC} -.include <bsd.stand.mk> -.include <bsd.lib.mk> +.include "${LIBSTAND_SRC}/Makefile" diff --git a/sys/boot/userboot/libstand/Makefile.depend b/sys/boot/userboot/libstand/Makefile.depend index dae5bcd..57cd80c 100644 --- a/sys/boot/userboot/libstand/Makefile.depend +++ b/sys/boot/userboot/libstand/Makefile.depend @@ -6,7 +6,6 @@ DIRDEPS = \ include/arpa \ include/xlocale \ lib/libbz2 \ - lib/libstand \ .include <dirdeps.mk> diff --git a/sys/boot/userboot/test/Makefile.depend b/sys/boot/userboot/test/Makefile.depend index a5da8fd..3646e2e 100644 --- a/sys/boot/userboot/test/Makefile.depend +++ b/sys/boot/userboot/test/Makefile.depend @@ -8,7 +8,6 @@ DIRDEPS = \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ - lib/libc_nonshared \ lib/libcompiler_rt \ diff --git a/sys/boot/userboot/userboot/main.c b/sys/boot/userboot/userboot/main.c index d4cefff..a52550c 100644 --- a/sys/boot/userboot/userboot/main.c +++ b/sys/boot/userboot/userboot/main.c @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); static void userboot_zfs_probe(void); static int userboot_zfs_found; +static void init_zfs_bootenv(char *currdev); #endif #define USERBOOT_VERSION USERBOOT_VERSION_3 @@ -167,6 +168,7 @@ extract_currdev(void) zdev.d_type = zdev.d_dev->dv_type; dev = *(struct disk_devdesc *)&zdev; + init_zfs_bootenv(zfs_fmtdev(&dev)); } else #endif @@ -198,6 +200,32 @@ extract_currdev(void) #if defined(USERBOOT_ZFS_SUPPORT) static void +init_zfs_bootenv(char *currdev) +{ + char *beroot; + + if (strlen(currdev) == 0) + return; + if(strncmp(currdev, "zfs:", 4) != 0) + return; + /* Remove the trailing : */ + currdev[strlen(currdev) - 1] = '\0'; + setenv("zfs_be_active", currdev, 1); + setenv("zfs_be_currpage", "1", 1); + /* Do not overwrite if already set */ + setenv("vfs.root.mountfrom", currdev, 0); + /* Forward past zfs: */ + currdev = strchr(currdev, ':'); + currdev++; + /* Remove the last element (current bootenv) */ + beroot = strrchr(currdev, '/'); + if (beroot != NULL) + beroot[0] = '\0'; + beroot = currdev; + setenv("zfs_be_root", beroot, 1); +} + +static void userboot_zfs_probe(void) { char devname[32]; @@ -237,6 +265,38 @@ command_lszfs(int argc, char *argv[]) } return (CMD_OK); } + +COMMAND_SET(reloadbe, "reloadbe", "refresh the list of ZFS Boot Environments", + command_reloadbe); + +static int +command_reloadbe(int argc, char *argv[]) +{ + int err; + char *root; + + if (argc > 2) { + command_errmsg = "wrong number of arguments"; + return (CMD_ERROR); + } + + if (argc == 2) { + err = zfs_bootenv(argv[1]); + } else { + root = getenv("zfs_be_root"); + if (root == NULL) { + return (CMD_OK); + } + err = zfs_bootenv(root); + } + + if (err != 0) { + command_errmsg = strerror(err); + return (CMD_ERROR); + } + + return (CMD_OK); +} #endif /* USERBOOT_ZFS_SUPPORT */ COMMAND_SET(quit, "quit", "exit the loader", command_quit); diff --git a/sys/boot/zfs/zfs.c b/sys/boot/zfs/zfs.c index 0e15ac4..c8b1284 100644 --- a/sys/boot/zfs/zfs.c +++ b/sys/boot/zfs/zfs.c @@ -154,7 +154,7 @@ zfs_read(struct open_file *f, void *start, size_t size, size_t *resid /* out */) n = size; if (fp->f_seekp + n > sb.st_size) n = sb.st_size - fp->f_seekp; - + rc = dnode_read(spa, &fp->f_dnode, fp->f_seekp, start, n); if (rc) return (rc); @@ -413,7 +413,7 @@ struct zfs_probe_args { int fd; const char *devname; uint64_t *pool_guid; - uint16_t secsz; + u_int secsz; }; static int @@ -507,7 +507,7 @@ zfs_probe_dev(const char *devname, uint64_t *pool_guid) } } close(pa.fd); - return (0); + return (ret); } /* @@ -712,13 +712,18 @@ zfs_list(const char *name) int zfs_bootenv(const char *name) { - static char poolname[ZFS_MAXNAMELEN], *dsname; + static char poolname[ZFS_MAXNAMELEN], *dsname, *root; char becount[4]; uint64_t objid; spa_t *spa; int len, rv, pages, perpage, currpage; - if (strcmp(name, getenv("zfs_be_root")) != 0) { + if (name == NULL) + return (EINVAL); + if ((root = getenv("zfs_be_root")) == NULL) + return (EINVAL); + + if (strcmp(name, root) != 0) { if (setenv("zfs_be_root", name, 1) != 0) return (ENOMEM); } diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index ac886ca..4fdaa05 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -1778,6 +1778,7 @@ ctl_ha_role_sysctl(SYSCTL_HANDLER_ARGS) static int ctl_init(void) { + struct make_dev_args args; struct ctl_softc *softc; void *other_pool; int i, error; @@ -1785,9 +1786,17 @@ ctl_init(void) softc = control_softc = malloc(sizeof(*control_softc), M_DEVBUF, M_WAITOK | M_ZERO); - softc->dev = make_dev(&ctl_cdevsw, 0, UID_ROOT, GID_OPERATOR, 0600, - "cam/ctl"); - softc->dev->si_drv1 = softc; + make_dev_args_init(&args); + args.mda_devsw = &ctl_cdevsw; + args.mda_uid = UID_ROOT; + args.mda_gid = GID_OPERATOR; + args.mda_mode = 0600; + args.mda_si_drv1 = softc; + error = make_dev_s(&args, &softc->dev, "cam/ctl"); + if (error != 0) { + free(control_softc, M_DEVBUF); + return (error); + } sysctl_ctx_init(&softc->sysctl_ctx); softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx, diff --git a/sys/cam/scsi/scsi_ch.c b/sys/cam/scsi/scsi_ch.c index bc398e7..137128d 100644 --- a/sys/cam/scsi/scsi_ch.c +++ b/sys/cam/scsi/scsi_ch.c @@ -372,6 +372,8 @@ chregister(struct cam_periph *periph, void *arg) struct ch_softc *softc; struct ccb_getdev *cgd; struct ccb_pathinq cpi; + struct make_dev_args args; + int error; cgd = (struct ccb_getdev *)arg; if (cgd == NULL) { @@ -431,11 +433,20 @@ chregister(struct cam_periph *periph, void *arg) /* Register the device */ - softc->dev = make_dev(&ch_cdevsw, periph->unit_number, UID_ROOT, - GID_OPERATOR, 0600, "%s%d", periph->periph_name, - periph->unit_number); + make_dev_args_init(&args); + args.mda_devsw = &ch_cdevsw; + args.mda_unit = periph->unit_number; + args.mda_uid = UID_ROOT; + args.mda_gid = GID_OPERATOR; + args.mda_mode = 0600; + args.mda_si_drv1 = periph; + error = make_dev_s(&args, &softc->dev, "%s%d", periph->periph_name, + periph->unit_number); cam_periph_lock(periph); - softc->dev->si_drv1 = periph; + if (error != 0) { + cam_periph_release_locked(periph); + return (CAM_REQ_CMP_ERR); + } /* * Add an async callback so that we get @@ -507,8 +518,6 @@ chclose(struct cdev *dev, int flag, int fmt, struct thread *td) struct mtx *mtx; periph = (struct cam_periph *)dev->si_drv1; - if (periph == NULL) - return(ENXIO); mtx = cam_periph_mtx(periph); mtx_lock(mtx); @@ -754,9 +763,6 @@ chioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td) int error; periph = (struct cam_periph *)dev->si_drv1; - if (periph == NULL) - return(ENXIO); - cam_periph_lock(periph); CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("entering chioctl\n")); diff --git a/sys/cam/scsi/scsi_enc.c b/sys/cam/scsi/scsi_enc.c index 844f25a..a450cd0 100644 --- a/sys/cam/scsi/scsi_enc.c +++ b/sys/cam/scsi/scsi_enc.c @@ -264,10 +264,6 @@ enc_open(struct cdev *dev, int flags, int fmt, struct thread *td) int error = 0; periph = (struct cam_periph *)dev->si_drv1; - if (periph == NULL) { - return (ENXIO); - } - if (cam_periph_acquire(periph) != CAM_REQ_CMP) return (ENXIO); @@ -302,8 +298,6 @@ enc_close(struct cdev *dev, int flag, int fmt, struct thread *td) struct mtx *mtx; periph = (struct cam_periph *)dev->si_drv1; - if (periph == NULL) - return (ENXIO); mtx = cam_periph_mtx(periph); mtx_lock(mtx); @@ -364,9 +358,6 @@ enc_ioctl(struct cdev *dev, u_long cmd, caddr_t arg_addr, int flag, addr = NULL; periph = (struct cam_periph *)dev->si_drv1; - if (periph == NULL) - return (ENXIO); - CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("entering encioctl\n")); cam_periph_lock(periph); @@ -905,6 +896,7 @@ enc_ctor(struct cam_periph *periph, void *arg) enc_softc_t *enc; struct ccb_getdev *cgd; char *tname; + struct make_dev_args args; cgd = (struct ccb_getdev *)arg; if (cgd == NULL) { @@ -987,12 +979,20 @@ enc_ctor(struct cam_periph *periph, void *arg) return (CAM_REQ_CMP_ERR); } - enc->enc_dev = make_dev(&enc_cdevsw, periph->unit_number, - UID_ROOT, GID_OPERATOR, 0600, "%s%d", - periph->periph_name, periph->unit_number); - + make_dev_args_init(&args); + args.mda_devsw = &enc_cdevsw; + args.mda_unit = periph->unit_number; + args.mda_uid = UID_ROOT; + args.mda_gid = GID_OPERATOR; + args.mda_mode = 0600; + args.mda_si_drv1 = periph; + err = make_dev_s(&args, &enc->enc_dev, "%s%d", periph->periph_name, + periph->unit_number); cam_periph_lock(periph); - enc->enc_dev->si_drv1 = periph; + if (err != 0) { + cam_periph_release_locked(periph); + return (CAM_REQ_CMP_ERR); + } enc->enc_flags |= ENC_FLAG_INITIALIZED; diff --git a/sys/cam/scsi/scsi_pass.c b/sys/cam/scsi/scsi_pass.c index 09cda5b..c0c313e 100644 --- a/sys/cam/scsi/scsi_pass.c +++ b/sys/cam/scsi/scsi_pass.c @@ -548,7 +548,8 @@ passregister(struct cam_periph *periph, void *arg) struct pass_softc *softc; struct ccb_getdev *cgd; struct ccb_pathinq cpi; - int no_tags; + struct make_dev_args args; + int error, no_tags; cgd = (struct ccb_getdev *)arg; if (cgd == NULL) { @@ -648,9 +649,20 @@ passregister(struct cam_periph *periph, void *arg) } /* Register the device */ - softc->dev = make_dev(&pass_cdevsw, periph->unit_number, - UID_ROOT, GID_OPERATOR, 0600, "%s%d", - periph->periph_name, periph->unit_number); + make_dev_args_init(&args); + args.mda_devsw = &pass_cdevsw; + args.mda_unit = periph->unit_number; + args.mda_uid = UID_ROOT; + args.mda_gid = GID_OPERATOR; + args.mda_mode = 0600; + args.mda_si_drv1 = periph; + error = make_dev_s(&args, &softc->dev, "%s%d", periph->periph_name, + periph->unit_number); + if (error != 0) { + cam_periph_lock(periph); + cam_periph_release_locked(periph); + return (CAM_REQ_CMP_ERR); + } /* * Hold a reference to the periph before we create the physical @@ -664,7 +676,6 @@ passregister(struct cam_periph *periph, void *arg) } cam_periph_lock(periph); - softc->dev->si_drv1 = periph; TASK_INIT(&softc->add_physpath_task, /*priority*/0, pass_add_physpath, periph); @@ -754,8 +765,6 @@ passclose(struct cdev *dev, int flag, int fmt, struct thread *td) struct mtx *mtx; periph = (struct cam_periph *)dev->si_drv1; - if (periph == NULL) - return (ENXIO); mtx = cam_periph_mtx(periph); mtx_lock(mtx); @@ -1759,9 +1768,6 @@ passdoioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread uint32_t priority; periph = (struct cam_periph *)dev->si_drv1; - if (periph == NULL) - return(ENXIO); - cam_periph_lock(periph); softc = (struct pass_softc *)periph->softc; @@ -2068,9 +2074,6 @@ passpoll(struct cdev *dev, int poll_events, struct thread *td) int revents; periph = (struct cam_periph *)dev->si_drv1; - if (periph == NULL) - return (ENXIO); - softc = (struct pass_softc *)periph->softc; revents = poll_events & (POLLOUT | POLLWRNORM); @@ -2095,9 +2098,6 @@ passkqfilter(struct cdev *dev, struct knote *kn) struct pass_softc *softc; periph = (struct cam_periph *)dev->si_drv1; - if (periph == NULL) - return (ENXIO); - softc = (struct pass_softc *)periph->softc; kn->kn_hook = (caddr_t)periph; diff --git a/sys/cam/scsi/scsi_pt.c b/sys/cam/scsi/scsi_pt.c index 15240da..e9d2437 100644 --- a/sys/cam/scsi/scsi_pt.c +++ b/sys/cam/scsi/scsi_pt.c @@ -173,9 +173,6 @@ ptclose(struct cdev *dev, int flag, int fmt, struct thread *td) struct pt_softc *softc; periph = (struct cam_periph *)dev->si_drv1; - if (periph == NULL) - return (ENXIO); - softc = (struct pt_softc *)periph->softc; cam_periph_lock(periph); @@ -252,6 +249,8 @@ ptctor(struct cam_periph *periph, void *arg) struct pt_softc *softc; struct ccb_getdev *cgd; struct ccb_pathinq cpi; + struct make_dev_args args; + int error; cgd = (struct ccb_getdev *)arg; if (cgd == NULL) { @@ -282,6 +281,21 @@ ptctor(struct cam_periph *periph, void *arg) xpt_action((union ccb *)&cpi); cam_periph_unlock(periph); + + make_dev_args_init(&args); + args.mda_devsw = &pt_cdevsw; + args.mda_unit = periph->unit_number; + args.mda_uid = UID_ROOT; + args.mda_gid = GID_OPERATOR; + args.mda_mode = 0600; + args.mda_si_drv1 = periph; + error = make_dev_s(&args, &softc->dev, "%s%d", periph->periph_name, + periph->unit_number); + if (error != 0) { + cam_periph_lock(periph); + return (CAM_REQ_CMP_ERR); + } + softc->device_stats = devstat_new_entry("pt", periph->unit_number, 0, DEVSTAT_NO_BLOCKSIZE, @@ -289,11 +303,7 @@ ptctor(struct cam_periph *periph, void *arg) XPORT_DEVSTAT_TYPE(cpi.transport), DEVSTAT_PRIORITY_OTHER); - softc->dev = make_dev(&pt_cdevsw, periph->unit_number, UID_ROOT, - GID_OPERATOR, 0600, "%s%d", periph->periph_name, - periph->unit_number); cam_periph_lock(periph); - softc->dev->si_drv1 = periph; /* * Add async callbacks for bus reset and @@ -571,9 +581,6 @@ ptioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td) int error = 0; periph = (struct cam_periph *)dev->si_drv1; - if (periph == NULL) - return(ENXIO); - softc = (struct pt_softc *)periph->softc; cam_periph_lock(periph); diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c index 6110b3d..149d062 100644 --- a/sys/cam/scsi/scsi_sa.c +++ b/sys/cam/scsi/scsi_sa.c @@ -731,9 +731,6 @@ saclose(struct cdev *dev, int flag, int fmt, struct thread *td) mode = SAMODE(dev); periph = (struct cam_periph *)dev->si_drv1; - if (periph == NULL) - return (ENXIO); - cam_periph_lock(periph); softc = (struct sa_softc *)periph->softc; @@ -906,10 +903,6 @@ sastrategy(struct bio *bp) return; } periph = (struct cam_periph *)bp->bio_dev->si_drv1; - if (periph == NULL) { - biofinish(bp, NULL, ENXIO); - return; - } cam_periph_lock(periph); softc = (struct sa_softc *)periph->softc; @@ -1517,9 +1510,6 @@ saioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *td) spaceop = 0; /* shut up gcc */ periph = (struct cam_periph *)dev->si_drv1; - if (periph == NULL) - return (ENXIO); - cam_periph_lock(periph); softc = (struct sa_softc *)periph->softc; @@ -2285,7 +2275,7 @@ saasync(void *callback_arg, u_int32_t code, static void sasetupdev(struct sa_softc *softc, struct cdev *dev) { - dev->si_drv1 = softc->periph; + dev->si_iosize_max = softc->maxio; dev->si_flags |= softc->si_flags; /* @@ -2347,8 +2337,10 @@ saregister(struct cam_periph *periph, void *arg) struct sa_softc *softc; struct ccb_getdev *cgd; struct ccb_pathinq cpi; + struct make_dev_args args; caddr_t match; char tmpstr[80]; + int error; cgd = (struct ccb_getdev *)arg; if (cgd == NULL) { @@ -2506,25 +2498,48 @@ saregister(struct cam_periph *periph, void *arg) return (CAM_REQ_CMP_ERR); } - softc->devs.ctl_dev = make_dev(&sa_cdevsw, SAMINOR(SA_CTLDEV, - SA_ATYPE_R), UID_ROOT, GID_OPERATOR, - 0660, "%s%d.ctl", periph->periph_name, periph->unit_number); + make_dev_args_init(&args); + args.mda_devsw = &sa_cdevsw; + args.mda_si_drv1 = softc->periph; + args.mda_uid = UID_ROOT; + args.mda_gid = GID_OPERATOR; + args.mda_mode = 0660; + + args.mda_unit = SAMINOR(SA_CTLDEV, SA_ATYPE_R); + error = make_dev_s(&args, &softc->devs.ctl_dev, "%s%d.ctl", + periph->periph_name, periph->unit_number); + if (error != 0) { + cam_periph_lock(periph); + return (CAM_REQ_CMP_ERR); + } sasetupdev(softc, softc->devs.ctl_dev); - softc->devs.r_dev = make_dev(&sa_cdevsw, SAMINOR(SA_NOT_CTLDEV, - SA_ATYPE_R), UID_ROOT, GID_OPERATOR, - 0660, "%s%d", periph->periph_name, periph->unit_number); + args.mda_unit = SAMINOR(SA_NOT_CTLDEV, SA_ATYPE_R); + error = make_dev_s(&args, &softc->devs.r_dev, "%s%d", + periph->periph_name, periph->unit_number); + if (error != 0) { + cam_periph_lock(periph); + return (CAM_REQ_CMP_ERR); + } sasetupdev(softc, softc->devs.r_dev); - softc->devs.nr_dev = make_dev(&sa_cdevsw, SAMINOR(SA_NOT_CTLDEV, - SA_ATYPE_NR), UID_ROOT, GID_OPERATOR, - 0660, "n%s%d", periph->periph_name, periph->unit_number); + args.mda_unit = SAMINOR(SA_NOT_CTLDEV, SA_ATYPE_NR); + error = make_dev_s(&args, &softc->devs.nr_dev, "n%s%d", + periph->periph_name, periph->unit_number); + if (error != 0) { + cam_periph_lock(periph); + return (CAM_REQ_CMP_ERR); + } sasetupdev(softc, softc->devs.nr_dev); - softc->devs.er_dev = make_dev(&sa_cdevsw, SAMINOR(SA_NOT_CTLDEV, - SA_ATYPE_ER), UID_ROOT, GID_OPERATOR, - 0660, "e%s%d", periph->periph_name, periph->unit_number); - sasetupdev(softc, softc->devs.er_dev); + args.mda_unit = SAMINOR(SA_NOT_CTLDEV, SA_ATYPE_ER); + error = make_dev_s(&args, &softc->devs.er_dev, "e%s%d", + periph->periph_name, periph->unit_number); + if (error != 0) { + cam_periph_lock(periph); + return (CAM_REQ_CMP_ERR); + } + sasetupdev(softc, softc->devs.er_dev); cam_periph_lock(periph); diff --git a/sys/cam/scsi/scsi_sg.c b/sys/cam/scsi/scsi_sg.c index 3e13003..ef83fc7 100644 --- a/sys/cam/scsi/scsi_sg.c +++ b/sys/cam/scsi/scsi_sg.c @@ -300,7 +300,8 @@ sgregister(struct cam_periph *periph, void *arg) struct sg_softc *softc; struct ccb_getdev *cgd; struct ccb_pathinq cpi; - int no_tags; + struct make_dev_args args; + int no_tags, error; cgd = (struct ccb_getdev *)arg; if (cgd == NULL) { @@ -361,9 +362,20 @@ sgregister(struct cam_periph *periph, void *arg) } /* Register the device */ - softc->dev = make_dev(&sg_cdevsw, periph->unit_number, - UID_ROOT, GID_OPERATOR, 0600, "%s%d", - periph->periph_name, periph->unit_number); + make_dev_args_init(&args); + args.mda_devsw = &sg_cdevsw; + args.mda_unit = periph->unit_number; + args.mda_uid = UID_ROOT; + args.mda_gid = GID_OPERATOR; + args.mda_mode = 0600; + args.mda_si_drv1 = periph; + error = make_dev_s(&args, &softc->dev, "%s%d", + periph->periph_name, periph->unit_number); + if (error != 0) { + cam_periph_lock(periph); + cam_periph_release_locked(periph); + return (CAM_REQ_CMP_ERR); + } if (periph->unit_number < 26) { (void)make_dev_alias(softc->dev, "sg%c", periph->unit_number + 'a'); @@ -373,7 +385,6 @@ sgregister(struct cam_periph *periph, void *arg) (periph->unit_number % 26) + 'a'); } cam_periph_lock(periph); - softc->dev->si_drv1 = periph; /* * Add as async callback so that we get @@ -429,9 +440,6 @@ sgopen(struct cdev *dev, int flags, int fmt, struct thread *td) int error = 0; periph = (struct cam_periph *)dev->si_drv1; - if (periph == NULL) - return (ENXIO); - if (cam_periph_acquire(periph) != CAM_REQ_CMP) return (ENXIO); @@ -468,8 +476,6 @@ sgclose(struct cdev *dev, int flag, int fmt, struct thread *td) struct mtx *mtx; periph = (struct cam_periph *)dev->si_drv1; - if (periph == NULL) - return (ENXIO); mtx = cam_periph_mtx(periph); mtx_lock(mtx); @@ -506,9 +512,6 @@ sgioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *td) int dir, error; periph = (struct cam_periph *)dev->si_drv1; - if (periph == NULL) - return (ENXIO); - cam_periph_lock(periph); softc = (struct sg_softc *)periph->softc; diff --git a/sys/cddl/boot/zfs/lz4.c b/sys/cddl/boot/zfs/lz4.c index 055bd62..c29f861 100644 --- a/sys/cddl/boot/zfs/lz4.c +++ b/sys/cddl/boot/zfs/lz4.c @@ -52,7 +52,7 @@ lz4_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int dum * Returns 0 on success (decompression function returned non-negative) * and non-zero on failure (decompression function returned negative). */ - return (LZ4_uncompress_unknownOutputSize(s_start + 4, d_start, bufsiz, + return (LZ4_uncompress_unknownOutputSize((const char *)s_start + 4, d_start, bufsiz, d_len) < 0); } diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c index 5491442..99496c0 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c @@ -78,6 +78,9 @@ static void vdev_geom_attrchanged(struct g_consumer *cp, const char *attr) { vdev_t *vd; + spa_t *spa; + char *physpath; + int error, physpath_len; vd = cp->private; if (vd == NULL) @@ -87,6 +90,47 @@ vdev_geom_attrchanged(struct g_consumer *cp, const char *attr) vdev_geom_set_rotation_rate(vd, cp); return; } + + if (strcmp(attr, "GEOM::physpath") != 0) + return; + + if (g_access(cp, 1, 0, 0) != 0) + return; + + /* + * Record/Update physical path information for this device. + */ + spa = vd->vdev_spa; + physpath_len = MAXPATHLEN; + physpath = g_malloc(physpath_len, M_WAITOK|M_ZERO); + error = g_io_getattr("GEOM::physpath", cp, &physpath_len, physpath); + g_access(cp, -1, 0, 0); + if (error == 0) { + char *old_physpath; + + old_physpath = vd->vdev_physpath; + vd->vdev_physpath = spa_strdup(physpath); + spa_async_request(spa, SPA_ASYNC_CONFIG_UPDATE); + + if (old_physpath != NULL) { + int held_lock; + + held_lock = spa_config_held(spa, SCL_STATE, RW_WRITER); + if (held_lock == 0) { + g_topology_unlock(); + spa_config_enter(spa, SCL_STATE, FTAG, + RW_WRITER); + } + + spa_strfree(old_physpath); + + if (held_lock == 0) { + spa_config_exit(spa, SCL_STATE, FTAG); + g_topology_lock(); + } + } + } + g_free(physpath); } static void @@ -97,8 +141,10 @@ vdev_geom_orphan(struct g_consumer *cp) g_topology_assert(); vd = cp->private; - if (vd == NULL) + if (vd == NULL) { + /* Vdev close in progress. Ignore the event. */ return; + } /* * Orphan callbacks occur from the GEOM event thread. @@ -120,7 +166,7 @@ vdev_geom_orphan(struct g_consumer *cp) } static struct g_consumer * -vdev_geom_attach(struct g_provider *pp) +vdev_geom_attach(struct g_provider *pp, vdev_t *vd) { struct g_geom *gp; struct g_consumer *cp; @@ -139,6 +185,7 @@ vdev_geom_attach(struct g_provider *pp) if (gp == NULL) { gp = g_new_geomf(&zfs_vdev_class, "zfs::vdev"); gp->orphan = vdev_geom_orphan; + gp->attrchanged = vdev_geom_attrchanged; cp = g_new_consumer(gp); if (g_attach(cp, pp) != 0) { g_wither_geom(gp, ENXIO); @@ -175,28 +222,56 @@ vdev_geom_attach(struct g_provider *pp) ZFS_LOG(1, "Used existing consumer for %s.", pp->name); } } + + /* + * BUG: cp may already belong to a vdev. This could happen if: + * 1) That vdev is a shared spare, or + * 2) We are trying to reopen a missing vdev and we are scanning by + * guid. In that case, we'll ultimately fail to open this consumer, + * but not until after setting the private field. + * The solution is to: + * 1) Don't set the private field until after the open succeeds, and + * 2) Set it to a linked list of vdevs, not just a single vdev + */ + cp->private = vd; + vd->vdev_tsd = cp; + + /* Fetch initial physical path information for this device. */ + vdev_geom_attrchanged(cp, "GEOM::physpath"); + cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE; return (cp); } static void -vdev_geom_detach(void *arg, int flag __unused) +vdev_geom_close_locked(vdev_t *vd) { struct g_geom *gp; struct g_consumer *cp; g_topology_assert(); - cp = arg; - gp = cp->geom; + + cp = vd->vdev_tsd; + if (cp == NULL) + return; ZFS_LOG(1, "Closing access to %s.", cp->provider->name); + KASSERT(vd->vdev_tsd == cp, ("%s: vdev_tsd is not cp", __func__)); + vd->vdev_tsd = NULL; + vd->vdev_delayed_close = B_FALSE; + cp->private = NULL; + + gp = cp->geom; g_access(cp, -1, 0, -1); /* Destroy consumer on last close. */ if (cp->acr == 0 && cp->ace == 0) { - ZFS_LOG(1, "Destroyed consumer to %s.", cp->provider->name); if (cp->acw > 0) g_access(cp, 0, -cp->acw, 0); - g_detach(cp); + if (cp->provider != NULL) { + ZFS_LOG(1, "Destroyed consumer to %s.", + cp->provider->name); + g_detach(cp); + } g_destroy_consumer(cp); } /* Destroy geom if there are no consumers left. */ @@ -490,7 +565,7 @@ vdev_geom_read_guids(struct g_consumer *cp, uint64_t *pguid, uint64_t *vguid) } static struct g_consumer * -vdev_geom_attach_by_guids(uint64_t pool_guid, uint64_t vdev_guid) +vdev_geom_attach_by_guids(vdev_t *vd) { struct g_class *mp; struct g_geom *gp, *zgp; @@ -519,9 +594,18 @@ vdev_geom_attach_by_guids(uint64_t pool_guid, uint64_t vdev_guid) vdev_geom_read_guids(zcp, &pguid, &vguid); g_topology_lock(); vdev_geom_detach_taster(zcp); - if (pguid != pool_guid || vguid != vdev_guid) + /* + * Check that the label's vdev guid matches the + * desired guid. If the label has a pool guid, + * check that it matches too. (Inactive spares + * and L2ARCs do not have any pool guid in the + * label.) + */ + if ((pguid != 0 && + pguid != spa_guid(vd->vdev_spa)) || + vguid != vd->vdev_guid) continue; - cp = vdev_geom_attach(pp); + cp = vdev_geom_attach(pp, vd); if (cp == NULL) { printf("ZFS WARNING: Unable to " "attach to %s.\n", pp->name); @@ -551,7 +635,7 @@ vdev_geom_open_by_guids(vdev_t *vd) g_topology_assert(); ZFS_LOG(1, "Searching by guid [%ju].", (uintmax_t)vd->vdev_guid); - cp = vdev_geom_attach_by_guids(spa_guid(vd->vdev_spa), vd->vdev_guid); + cp = vdev_geom_attach_by_guids(vd); if (cp != NULL) { len = strlen(cp->provider->name) + strlen("/dev/") + 1; buf = kmem_alloc(len, KM_SLEEP); @@ -585,7 +669,7 @@ vdev_geom_open_by_path(vdev_t *vd, int check_guid) pp = g_provider_by_name(vd->vdev_path + sizeof("/dev/") - 1); if (pp != NULL) { ZFS_LOG(1, "Found provider by name %s.", vd->vdev_path); - cp = vdev_geom_attach(pp); + cp = vdev_geom_attach(pp, vd); if (cp != NULL && check_guid && ISP2(pp->sectorsize) && pp->sectorsize <= VDEV_PAD_SIZE) { g_topology_unlock(); @@ -593,7 +677,7 @@ vdev_geom_open_by_path(vdev_t *vd, int check_guid) g_topology_lock(); if (pguid != spa_guid(vd->vdev_spa) || vguid != vd->vdev_guid) { - vdev_geom_detach(cp, 0); + vdev_geom_close_locked(vd); cp = NULL; ZFS_LOG(1, "guid mismatch for provider %s: " "%ju:%ju != %ju:%ju.", vd->vdev_path, @@ -675,7 +759,8 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize, !ISP2(cp->provider->sectorsize)) { ZFS_LOG(1, "Provider %s has unsupported sectorsize.", vd->vdev_path); - vdev_geom_detach(cp, 0); + + vdev_geom_close_locked(vd); error = EINVAL; cp = NULL; } else if (cp->acw == 0 && (spa_mode(vd->vdev_spa) & FWRITE) != 0) { @@ -692,19 +777,17 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize, if (error != 0) { printf("ZFS WARNING: Unable to open %s for writing (error=%d).\n", vd->vdev_path, error); - vdev_geom_detach(cp, 0); + vdev_geom_close_locked(vd); cp = NULL; } } + g_topology_unlock(); PICKUP_GIANT(); if (cp == NULL) { vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED; return (error); } - - cp->private = vd; - vd->vdev_tsd = cp; pp = cp->provider; /* @@ -727,12 +810,6 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize, */ vd->vdev_nowritecache = B_FALSE; - if (vd->vdev_physpath != NULL) - spa_strfree(vd->vdev_physpath); - bufsize = sizeof("/dev/") + strlen(pp->name); - vd->vdev_physpath = kmem_alloc(bufsize, KM_SLEEP); - snprintf(vd->vdev_physpath, bufsize, "/dev/%s", pp->name); - /* * Determine the device's rotation rate. */ @@ -744,15 +821,12 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize, static void vdev_geom_close(vdev_t *vd) { - struct g_consumer *cp; - cp = vd->vdev_tsd; - if (cp == NULL) - return; - vd->vdev_tsd = NULL; - vd->vdev_delayed_close = B_FALSE; - cp->private = NULL; /* XXX locking */ - g_post_event(vdev_geom_detach, cp, M_WAITOK, NULL); + DROP_GIANT(); + g_topology_lock(); + vdev_geom_close_locked(vd); + g_topology_unlock(); + PICKUP_GIANT(); } static void diff --git a/sys/compat/ia32/ia32_sysvec.c b/sys/compat/ia32/ia32_sysvec.c index 1a6dd72..f201570 100644 --- a/sys/compat/ia32/ia32_sysvec.c +++ b/sys/compat/ia32/ia32_sysvec.c @@ -134,6 +134,7 @@ struct sysentvec ia32_freebsd_sysvec = { .sv_shared_page_len = PAGE_SIZE, .sv_schedtail = NULL, .sv_thread_detach = NULL, + .sv_trap = NULL, }; INIT_SYSENTVEC(elf_ia32_sysvec, &ia32_freebsd_sysvec); diff --git a/sys/compat/linux/linux_futex.c b/sys/compat/linux/linux_futex.c index e2aad79..db8ab2c 100644 --- a/sys/compat/linux/linux_futex.c +++ b/sys/compat/linux/linux_futex.c @@ -1099,8 +1099,12 @@ linux_get_robust_list(struct thread *td, struct linux_get_robust_list_args *args ESRCH); return (ESRCH); } - if (SV_PROC_ABI(td2->td_proc) != SV_ABI_LINUX) + if (SV_PROC_ABI(td2->td_proc) != SV_ABI_LINUX) { + LIN_SDT_PROBE1(futex, linux_get_robust_list, return, + EPERM); + PROC_UNLOCK(td2->td_proc); return (EPERM); + } em = em_find(td2); KASSERT(em != NULL, ("get_robust_list: emuldata notfound.\n")); diff --git a/sys/compat/linuxkpi/common/include/linux/gfp.h b/sys/compat/linuxkpi/common/include/linux/gfp.h index a82f30d..38a0222 100644 --- a/sys/compat/linuxkpi/common/include/linux/gfp.h +++ b/sys/compat/linuxkpi/common/include/linux/gfp.h @@ -66,15 +66,15 @@ page_address(struct page *page) } static inline unsigned long -_get_page(gfp_t mask) +linux_get_page(gfp_t mask) { return kmem_malloc(kmem_arena, PAGE_SIZE, mask); } -#define get_zeroed_page(mask) _get_page((mask) | M_ZERO) -#define alloc_page(mask) virt_to_page(_get_page((mask))) -#define __get_free_page(mask) _get_page((mask)) +#define get_zeroed_page(mask) linux_get_page((mask) | M_ZERO) +#define alloc_page(mask) virt_to_page(linux_get_page((mask))) +#define __get_free_page(mask) linux_get_page((mask)) static inline void free_page(unsigned long page) diff --git a/sys/compat/linuxkpi/common/include/linux/interrupt.h b/sys/compat/linuxkpi/common/include/linux/interrupt.h index d33a3b0..dd943e3 100644 --- a/sys/compat/linuxkpi/common/include/linux/interrupt.h +++ b/sys/compat/linuxkpi/common/include/linux/interrupt.h @@ -54,24 +54,17 @@ struct irq_ent { }; static inline int -_irq_rid(struct device *dev, int irq) +linux_irq_rid(struct device *dev, int irq) { if (irq == dev->irq) return (0); return irq - dev->msix + 1; } -static inline void -_irq_handler(void *ent) -{ - struct irq_ent *irqe; - - irqe = ent; - irqe->handler(irqe->irq, irqe->arg); -} +extern void linux_irq_handler(void *); static inline struct irq_ent * -_irq_ent(struct device *dev, int irq) +linux_irq_ent(struct device *dev, int irq) { struct irq_ent *irqe; @@ -95,7 +88,7 @@ request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, dev = _pci_find_irq_dev(irq); if (dev == NULL) return -ENXIO; - rid = _irq_rid(dev, irq); + rid = linux_irq_rid(dev, irq); res = bus_alloc_resource_any(dev->bsddev, SYS_RES_IRQ, &rid, flags | RF_ACTIVE); if (res == NULL) @@ -107,7 +100,7 @@ request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, irqe->handler = handler; irqe->irq = irq; error = bus_setup_intr(dev->bsddev, res, INTR_TYPE_NET | INTR_MPSAFE, - NULL, _irq_handler, irqe, &irqe->tag); + NULL, linux_irq_handler, irqe, &irqe->tag); if (error) { bus_release_resource(dev->bsddev, SYS_RES_IRQ, rid, irqe->res); kfree(irqe); @@ -128,7 +121,7 @@ bind_irq_to_cpu(unsigned int irq, int cpu_id) if (dev == NULL) return (-ENOENT); - irqe = _irq_ent(dev, irq); + irqe = linux_irq_ent(dev, irq); if (irqe == NULL) return (-ENOENT); @@ -145,8 +138,8 @@ free_irq(unsigned int irq, void *device) dev = _pci_find_irq_dev(irq); if (dev == NULL) return; - rid = _irq_rid(dev, irq); - irqe = _irq_ent(dev, irq); + rid = linux_irq_rid(dev, irq); + irqe = linux_irq_ent(dev, irq); if (irqe == NULL) return; bus_teardown_intr(dev->bsddev, irqe->res, irqe->tag); diff --git a/sys/compat/linuxkpi/common/include/linux/kthread.h b/sys/compat/linuxkpi/common/include/linux/kthread.h index fa8e9ba..f85a3f4 100644 --- a/sys/compat/linuxkpi/common/include/linux/kthread.h +++ b/sys/compat/linuxkpi/common/include/linux/kthread.h @@ -42,7 +42,7 @@ #include <linux/sched.h> static inline void -_kthread_fn(void *arg) +linux_kthread_fn(void *arg) { struct task_struct *task; @@ -58,7 +58,7 @@ _kthread_fn(void *arg) } static inline struct task_struct * -_kthread_create(int (*threadfn)(void *data), void *data) +linux_kthread_create(int (*threadfn)(void *data), void *data) { struct task_struct *task; @@ -69,17 +69,12 @@ _kthread_create(int (*threadfn)(void *data), void *data) return (task); } -struct task_struct *kthread_create(int (*threadfn)(void *data), - void *data, - const char namefmt[], ...) - __attribute__((format(printf, 3, 4))); - #define kthread_run(fn, data, fmt, ...) \ ({ \ struct task_struct *_task; \ \ - _task = _kthread_create((fn), (data)); \ - if (kthread_add(_kthread_fn, _task, NULL, &_task->task_thread, \ + _task = linux_kthread_create((fn), (data)); \ + if (kthread_add(linux_kthread_fn, _task, NULL, &_task->task_thread, \ 0, 0, fmt, ## __VA_ARGS__)) { \ kfree(_task); \ _task = NULL; \ diff --git a/sys/compat/linuxkpi/common/include/linux/netdevice.h b/sys/compat/linuxkpi/common/include/linux/netdevice.h index 1b1f8bf..1d50ac1 100644 --- a/sys/compat/linuxkpi/common/include/linux/netdevice.h +++ b/sys/compat/linuxkpi/common/include/linux/netdevice.h @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -69,103 +69,10 @@ netdev_priv(const struct net_device *dev) return (dev->if_softc); } -static inline void -_handle_ifnet_link_event(void *arg, struct ifnet *ifp, int linkstate) -{ - struct notifier_block *nb; - - nb = arg; - if (linkstate == LINK_STATE_UP) - nb->notifier_call(nb, NETDEV_UP, ifp); - else - nb->notifier_call(nb, NETDEV_DOWN, ifp); -} - -static inline void -_handle_ifnet_arrival_event(void *arg, struct ifnet *ifp) -{ - struct notifier_block *nb; - - nb = arg; - nb->notifier_call(nb, NETDEV_REGISTER, ifp); -} - -static inline void -_handle_ifnet_departure_event(void *arg, struct ifnet *ifp) -{ - struct notifier_block *nb; - - nb = arg; - nb->notifier_call(nb, NETDEV_UNREGISTER, ifp); -} - -static inline void -_handle_iflladdr_event(void *arg, struct ifnet *ifp) -{ - struct notifier_block *nb; - - nb = arg; - nb->notifier_call(nb, NETDEV_CHANGEADDR, ifp); -} - -static inline void -_handle_ifaddr_event(void *arg, struct ifnet *ifp) -{ - struct notifier_block *nb; - - nb = arg; - nb->notifier_call(nb, NETDEV_CHANGEIFADDR, ifp); -} - -static inline int -register_netdevice_notifier(struct notifier_block *nb) -{ - - nb->tags[NETDEV_UP] = EVENTHANDLER_REGISTER( - ifnet_link_event, _handle_ifnet_link_event, nb, 0); - nb->tags[NETDEV_REGISTER] = EVENTHANDLER_REGISTER( - ifnet_arrival_event, _handle_ifnet_arrival_event, nb, 0); - nb->tags[NETDEV_UNREGISTER] = EVENTHANDLER_REGISTER( - ifnet_departure_event, _handle_ifnet_departure_event, nb, 0); - nb->tags[NETDEV_CHANGEADDR] = EVENTHANDLER_REGISTER( - iflladdr_event, _handle_iflladdr_event, nb, 0); - - return (0); -} - -static inline int -register_inetaddr_notifier(struct notifier_block *nb) -{ - - nb->tags[NETDEV_CHANGEIFADDR] = EVENTHANDLER_REGISTER( - ifaddr_event, _handle_ifaddr_event, nb, 0); - return (0); -} - -static inline int -unregister_netdevice_notifier(struct notifier_block *nb) -{ - - EVENTHANDLER_DEREGISTER(ifnet_link_event, nb->tags[NETDEV_UP]); - EVENTHANDLER_DEREGISTER(ifnet_arrival_event, nb->tags[NETDEV_REGISTER]); - EVENTHANDLER_DEREGISTER(ifnet_departure_event, - nb->tags[NETDEV_UNREGISTER]); - EVENTHANDLER_DEREGISTER(iflladdr_event, - nb->tags[NETDEV_CHANGEADDR]); - - return (0); -} - -static inline int -unregister_inetaddr_notifier(struct notifier_block *nb) -{ - - EVENTHANDLER_DEREGISTER(ifaddr_event, - nb->tags[NETDEV_CHANGEIFADDR]); - - return (0); -} - +int register_netdevice_notifier(struct notifier_block *); +int register_inetaddr_notifier(struct notifier_block *); +int unregister_netdevice_notifier(struct notifier_block *); +int unregister_inetaddr_notifier(struct notifier_block *); #define rtnl_lock() #define rtnl_unlock() diff --git a/sys/compat/linuxkpi/common/include/linux/rcupdate.h b/sys/compat/linuxkpi/common/include/linux/rcupdate.h new file mode 100644 index 0000000..f8e2b04 --- /dev/null +++ b/sys/compat/linuxkpi/common/include/linux/rcupdate.h @@ -0,0 +1,76 @@ +/*- + * Copyright (c) 2016 Mellanox Technologies, Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ +#ifndef _LINUX_RCUPDATE_H_ +#define _LINUX_RCUPDATE_H_ + +#include <sys/param.h> +#include <sys/lock.h> +#include <sys/sx.h> + +extern struct sx linux_global_rcu_lock; + +struct rcu_head { +}; + +typedef void (*rcu_callback_t)(struct rcu_head *); + +static inline void +call_rcu(struct rcu_head *ptr, rcu_callback_t func) +{ + sx_xlock(&linux_global_rcu_lock); + func(ptr); + sx_xunlock(&linux_global_rcu_lock); +} + +static inline void +rcu_read_lock(void) +{ + sx_slock(&linux_global_rcu_lock); +} + +static inline void +rcu_read_unlock(void) +{ + sx_sunlock(&linux_global_rcu_lock); +} + +static inline void +rcu_barrier(void) +{ + sx_xlock(&linux_global_rcu_lock); + sx_xunlock(&linux_global_rcu_lock); +} + +static inline void +synchronize_rcu(void) +{ + sx_xlock(&linux_global_rcu_lock); + sx_xunlock(&linux_global_rcu_lock); +} + +#endif /* _LINUX_RCUPDATE_H_ */ diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 4d48519..56080a4 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013-2015 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -65,6 +65,8 @@ __FBSDID("$FreeBSD$"); #include <linux/netdevice.h> #include <linux/timer.h> #include <linux/workqueue.h> +#include <linux/rcupdate.h> +#include <linux/interrupt.h> #include <vm/vm_pager.h> @@ -84,6 +86,7 @@ struct list_head pci_drivers; struct list_head pci_devices; struct net init_net; spinlock_t pci_lock; +struct sx linux_global_rcu_lock; unsigned long linux_timer_hz_mask; @@ -1137,11 +1140,121 @@ const struct kobj_type linux_cdev_static_ktype = { }; static void +linux_handle_ifnet_link_event(void *arg, struct ifnet *ifp, int linkstate) +{ + struct notifier_block *nb; + + nb = arg; + if (linkstate == LINK_STATE_UP) + nb->notifier_call(nb, NETDEV_UP, ifp); + else + nb->notifier_call(nb, NETDEV_DOWN, ifp); +} + +static void +linux_handle_ifnet_arrival_event(void *arg, struct ifnet *ifp) +{ + struct notifier_block *nb; + + nb = arg; + nb->notifier_call(nb, NETDEV_REGISTER, ifp); +} + +static void +linux_handle_ifnet_departure_event(void *arg, struct ifnet *ifp) +{ + struct notifier_block *nb; + + nb = arg; + nb->notifier_call(nb, NETDEV_UNREGISTER, ifp); +} + +static void +linux_handle_iflladdr_event(void *arg, struct ifnet *ifp) +{ + struct notifier_block *nb; + + nb = arg; + nb->notifier_call(nb, NETDEV_CHANGEADDR, ifp); +} + +static void +linux_handle_ifaddr_event(void *arg, struct ifnet *ifp) +{ + struct notifier_block *nb; + + nb = arg; + nb->notifier_call(nb, NETDEV_CHANGEIFADDR, ifp); +} + +int +register_netdevice_notifier(struct notifier_block *nb) +{ + + nb->tags[NETDEV_UP] = EVENTHANDLER_REGISTER( + ifnet_link_event, linux_handle_ifnet_link_event, nb, 0); + nb->tags[NETDEV_REGISTER] = EVENTHANDLER_REGISTER( + ifnet_arrival_event, linux_handle_ifnet_arrival_event, nb, 0); + nb->tags[NETDEV_UNREGISTER] = EVENTHANDLER_REGISTER( + ifnet_departure_event, linux_handle_ifnet_departure_event, nb, 0); + nb->tags[NETDEV_CHANGEADDR] = EVENTHANDLER_REGISTER( + iflladdr_event, linux_handle_iflladdr_event, nb, 0); + + return (0); +} + +int +register_inetaddr_notifier(struct notifier_block *nb) +{ + + nb->tags[NETDEV_CHANGEIFADDR] = EVENTHANDLER_REGISTER( + ifaddr_event, linux_handle_ifaddr_event, nb, 0); + return (0); +} + +int +unregister_netdevice_notifier(struct notifier_block *nb) +{ + + EVENTHANDLER_DEREGISTER(ifnet_link_event, + nb->tags[NETDEV_UP]); + EVENTHANDLER_DEREGISTER(ifnet_arrival_event, + nb->tags[NETDEV_REGISTER]); + EVENTHANDLER_DEREGISTER(ifnet_departure_event, + nb->tags[NETDEV_UNREGISTER]); + EVENTHANDLER_DEREGISTER(iflladdr_event, + nb->tags[NETDEV_CHANGEADDR]); + + return (0); +} + +int +unregister_inetaddr_notifier(struct notifier_block *nb) +{ + + EVENTHANDLER_DEREGISTER(ifaddr_event, + nb->tags[NETDEV_CHANGEIFADDR]); + + return (0); +} + +void +linux_irq_handler(void *ent) +{ + struct irq_ent *irqe; + + irqe = ent; + irqe->handler(irqe->irq, irqe->arg); +} + +static void linux_compat_init(void *arg) { struct sysctl_oid *rootoid; int i; + sx_init(&linux_global_rcu_lock, "LinuxGlobalRCU"); + rootoid = SYSCTL_ADD_ROOT_NODE(NULL, OID_AUTO, "sys", CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, "sys"); kobject_init(&linux_class_root, &linux_class_ktype); @@ -1171,6 +1284,9 @@ linux_compat_uninit(void *arg) linux_kobject_kfree_name(&linux_class_root); linux_kobject_kfree_name(&linux_root_device.kobj); linux_kobject_kfree_name(&linux_class_misc.kobj); + + synchronize_rcu(); + sx_destroy(&linux_global_rcu_lock); } SYSUNINIT(linux_compat, SI_SUB_DRIVERS, SI_ORDER_SECOND, linux_compat_uninit, NULL); diff --git a/sys/compat/svr4/svr4_sysvec.c b/sys/compat/svr4/svr4_sysvec.c index f37d8cb..c9ceca7 100644 --- a/sys/compat/svr4/svr4_sysvec.c +++ b/sys/compat/svr4/svr4_sysvec.c @@ -194,6 +194,7 @@ struct sysentvec svr4_sysvec = { .sv_syscallnames = NULL, .sv_schedtail = NULL, .sv_thread_detach = NULL, + .sv_trap = NULL, }; const char svr4_emul_path[] = "/compat/svr4"; diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 3c64d5b..7d06fe3 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -2586,6 +2586,25 @@ device pps device lpbb device pcfclock +# +# Etherswitch framework and drivers +# +# etherswitch The etherswitch(4) framework +# miiproxy Proxy device for miibus(4) functionality +# +# Switch hardware support: +# arswitch Atheros switches +# ip17x IC+ 17x family switches +# rtl8366r Realtek RTL8366 switches +# ukswitch Multi-PHY switches +# +device etherswitch +device miiproxy +device arswitch +device ip17x +device rtl8366rb +device ukswitch + # Kernel BOOTP support options BOOTP # Use BOOTP to obtain IP address/hostname diff --git a/sys/conf/files b/sys/conf/files index feac6c0..3652b3b 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -2994,6 +2994,7 @@ geom/concat/g_concat.c optional geom_concat geom/eli/g_eli.c optional geom_eli geom/eli/g_eli_crypto.c optional geom_eli geom/eli/g_eli_ctl.c optional geom_eli +geom/eli/g_eli_hmac.c optional geom_eli geom/eli/g_eli_integrity.c optional geom_eli geom/eli/g_eli_key.c optional geom_eli geom/eli/g_eli_key_cache.c optional geom_eli diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index 6ecf36a..a128967 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -38,6 +38,7 @@ arm64/arm64/mem.c standard arm64/arm64/minidump_machdep.c standard arm64/arm64/mp_machdep.c optional smp arm64/arm64/nexus.c standard +arm64/arm64/ofw_machdep.c optional fdt arm64/arm64/pic_if.m standard arm64/arm64/pmap.c standard arm64/arm64/stack_machdep.c optional ddb | stack diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index 50000c5..819a955 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -28,6 +28,9 @@ # # KMODUNLOAD Command to unload a kernel module [/sbin/kldunload] # +# KMODISLOADED Command to check whether a kernel module is +# loaded [/sbin/kldstat -q -n] +# # PROG The name of the kernel module to build. # If not supplied, ${KMOD}.ko is used. # @@ -56,10 +59,14 @@ # unload: # Unload a module. # +# reload: +# Unload if loaded, then load. +# AWK?= awk KMODLOAD?= /sbin/kldload KMODUNLOAD?= /sbin/kldunload +KMODISLOADED?= /sbin/kldstat -q -n OBJCOPY?= objcopy .include <bsd.init.mk> @@ -325,7 +332,11 @@ load: ${PROG} .if !target(unload) unload: - ${KMODUNLOAD} -v ${PROG} + if ${KMODISLOADED} ${PROG} ; then ${KMODUNLOAD} -v ${PROG} ; fi +.endif + +.if !target(reload) +reload: unload load .endif .if defined(KERNBUILDDIR) diff --git a/sys/contrib/dev/rtwn/LICENSE b/sys/contrib/dev/rtwn/LICENSE new file mode 100644 index 0000000..d70921f --- /dev/null +++ b/sys/contrib/dev/rtwn/LICENSE @@ -0,0 +1,39 @@ +Copyright (c) 2010, Realtek Semiconductor Corporation +All rights reserved. + +Redistribution. Redistribution and use in binary form, without +modification, are permitted provided that the following conditions are +met: + +* Redistributions must reproduce the above copyright notice and the + following disclaimer in the documentation and/or other materials + provided with the distribution. +* Neither the name of Realtek Semiconductor Corporation nor the names of its + suppliers may be used to endorse or promote products derived from this + software without specific prior written permission. +* No reverse engineering, decompilation, or disassembly of this software + is permitted. + +Limited patent license. Realtek Semiconductor Corporation grants a world-wide, +royalty-free, non-exclusive license under patents it now or hereafter +owns or controls to make, have made, use, import, offer to sell and +sell ("Utilize") this software, but solely to the extent that any +such patent is necessary to Utilize the software alone, or in +combination with an operating system licensed under an approved Open +Source license as listed by the Open Source Initiative at +http://opensource.org/licenses. The patent license shall not apply to +any other combinations which include this software. No hardware per +se is licensed hereunder. + +DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. diff --git a/sys/contrib/dev/rtwn/rtwn-rtl8192cfwU.fw.uu b/sys/contrib/dev/rtwn/rtwn-rtl8192cfwU.fw.uu new file mode 100644 index 0000000..d542b2e --- /dev/null +++ b/sys/contrib/dev/rtwn/rtwn-rtl8192cfwU.fw.uu @@ -0,0 +1,333 @@ +begin 444 rtwn-rtl8192cfwU.fw.uu +MP8@"`$@````%$!!3PCD!`(%C`0`````````````````"0[H````````````` +M`````````E!$```````````````````````````````````````````````` +M`````````````E;@```````"2VH```4$`P(``P8%!`,`!`8%!`(`!`@'!@0` +M!@H)"`8`"`H)"`0`"`H)"`(`"`H)"```"!(1$`@`$!H9&!``&"(A(!@`("(A +M(!``("(A(`@`("(A'`@`("(A%`@`("(@&`@`(#$P(!``,#$P&```,#$O$!`` +M,#$L$!``,#$H$```,#$@$```,#$0$```,`0$!`4$!`0%!04&!@0$!`4%!08& +M!`0%!04%!@8$!`4%!04&!PH+#1`$!04&!@D,$0@("0D*#!`1!`0$!00$!0<' +M!P@*!`0$!`8*"PT%!0<'"`L-#P0$!`4'!PD)#`X0$@0$!04&"A$3"0D)"0P. +M$1,````````````D)BH8&AT?(2<I*@```!\C*"HL``0`!``(`!``&``D`#`` +M2`!@`)``P`#8`%``>`"@`,@!0`&0`>`",`$L`4`!X`+0`^@$L`9`!]```@`" +M``0`"``,`!(`&``D`#``2`!@`&P`*``\`%``9`"@`,@`\`$8`&0`H`#P`6@! +M]`)8`R`#Z`("`@("`@,#!`0%!P0$!PH*#`P2!0<'"`L2)#P!`0$!`0(#!`4& +M!P@!`@,$!08'"`4&!P@)"@L,(!X<&!`8````````````````NP$,Y8(I]8+E +M@SKU@^`B4`;I)8+XYB*[_@;I)8+XXB+E@BGU@N6#.O6#Y),BNP$&B8**@_`B +M4`+W(KO^`?,B^+L!#>6"*?6"Y8,Z]8/H\")0!NDE@LCV(KO^!>DE@LCR(L7P +M^*/@*/#%\/CE@A6"<`(5@^`X\"*[`0J)@HJ#X/7PH^`B4`:'\`GG&2*[_@?C +M]?`)XQDBB8**@^23]?!T`9,BNP$0Y8(I]8+E@SKU@^#U\*/@(E`)Z26"^(;P +M".8BN_X*Z26"^.+U\`CB(N6#*O6#Z9/U\*/IDR*[`0J)@HJ#\.7PH_`B4`;W +M":?P&2*[_@;SY?`)\QDB^+L!$>6"*?6"Y8,Z]8/H\.7PH_`B4`GI)8+(]@BF +M\"*[_@GI)8+(\N7P"/(B[TO_[DK^[4G][$C\(N#\H^#]H^#^H^#_(J0E@O6" +MY?`U@_6#(N#[H^#ZH^#Y(OC@^Z.CX/DE\/#E@A6"<`(5@^#Z./`BZ_"CZO"C +MZ?`BT(/0@OCDDW`2=`&3<`VCHY/X=`&3]8*(@^1S=`*3:&#OHZ.C@-\"0_@" +M2"_DDZ/XY).C0`/V@`'R"-_T@"GDDZ/X5`<D#,C#,\14#T0@R(-`!/16@`%& +M]M_D@`L!`@0($"!`@)!$/>1^`9-@O*/_5#\PY0E4'_[DDZ-@`0[/5,`EX&"H +M0+CDDZ/ZY).C^.23H\C%@LC*Q8/*\*/(Q8+(RL6#RM_IWN>`OD&7?P!!EZ$` +M09=K@$&7HP``CX*.@Z.CH^3P(N3U(W]@?@&`[=,0KP'#P-"0EUUQBY"777%K +MD``!4<+ZY?`D`/_D.OZ0EUUQ:Y```>Z/\'$9$B1B_V`HM2,4D)==<6N0``%1 +MPF4E<`3E)&7P8!^0EUUQ:Y```5'"_Z[PL5.`#I"777%K$B1B92-@`I%8T-"2 +MKR+T_Y``0^!?\-,0KP'#P-!_$-_^T-"2KR*0`<KE)O#O8`+QVR*0`@G@_WT! +MT6&0!!]T`?`B(@)7<@)7>=,0KP'#P-"+8(IAB6*0EXAQBZMCJF2I99"7BW&+ +MKV859N]@&Y"7B^1U\`%Q=!(D8O^0EXCD=?`!<73O44V`WJM@JF&I8M#0DJ\B +MD)=@[O"C[_!U(P&.)/4EY/U_"[&6Y/U_`K&6$FU;Y/^1YN3U)Y`!R>4G\)"7 +M8.#\H^#][/N-1.3U17T!?V!^`0(P8M,0KP'#P-"0EV/M\)"78N_PTY0'4$ZC +MX'`:D)=BX/]T`:@'"(`"PS/8_/3_D`!'X%_P@!>0EV+@_W0!J`<(@`+#,]C\ +M_Y``1^!/\)'6D)=BX/]T`:@'"(`"PS/8_/3_D`!&@%F0EV+@)/CPH^!P'9"7 +M8N#_=`&H!PB``L,SV/S$5/#T_Y``0^!?\(`:D)=BX/]T`:@'"(`"PS/8_,14 +M\/^0`$/@3_"1UI"78N#_=`&H!PB``L,SV/ST_Y``0^!?\)'6T-"2KR+@_WT! +MD)>4[_"C[?#DH_"C\.5J8`7D_Q).>9"7E.`PX`F0EY;D\*-T@/"0!!W@8!V0 +M!2+@D)>8\.#_5)!@[)`!R'3\\.]4;Y`%(O"`W9"7E.#_PQ.0_1#PD`0E[_"0 +MEY7@8!^CH^#_)`_U@N0T_/6#X$2`\'00+_6"Y#3\]8/@1(#PD)>6H^#__20( +M]8+D-/SU@^3P=`DM]8+D-/SU@^!4\/!T(2_U@N0T_/6#X%3W\)"7EN#^H^#_ +M(O"0`$7@5/[]?T73$*\!P\#0CX)U@P#M\)'6T-"2KR+O%&`P%&!E)`)@`N': +MD)<X=`+PD`!(X$0,_7](\2"0`$?@1`C]?T?Q()``1>!$$/U_18!OY)"7./"0 +MES1Q4Y"`EA(E"'^`?@@2*PB0`$7@1._]?T7Q()``1>!4[_U_1?$@D`!&X$00 +M_7]&@#>0ESAT`?"0ESYQ4Y"`EA(E"'^`?@@2*PB0`$7@1"#]?T7Q()``1>!$ +M$/U_1?$@D`!&X$00_7]&\2`BD`!)X)"7I/#@5`_P1/#]?TGQ()"7I.!$L/U_ +M2>$@=2@SY/4I=2H"]2N0`3#E*/"CY2GPH^4J\*/E*_`B=3`?=3$!Y/4RD`$X +MY3#PH^4Q\*/E,O`BY)"73_"C\'6.`A)LK9```N!4X)"7AF`%=`'P@`-T`O"0 +M`//@,.,(D)>'=`'P@`7DD)>'\)"7A^"T`1.0`/+@,.<,D)=]=/WPHW0S\(`* +MD)=]=/WPHW0O\.3U5Q)JZQ)O\A)?K!(N`1)M5Q)'^9``\^`PX@V0!4%T$/"0 +M!5KPH^3PD`%D=*#P=43_Y/5%^WT!?U!^`1(P8A$7$D4"$G=(D)=1Y=GP$E`5 +MPJ^0`(#@1$#P$D36=>@#0ZB%TJ^0ET_@9`'P)"^0`<3P=$BC\.57,.0*PJ]3 +M5^_2KQ)7@.57,.86PJ]35[_2KQ)A9)"7/.#_8`.T`0(Q8)"7/.!P`Q)WIC$S +M@+B0!C3@8"84<!M[`7H&>35_^7X!$FSUOP$)D`8UX%0/\(`%@``";)[DD`8T +M\"*0ES/@PY044`7@!/!!&)"7,^!D%&`"01B0ET+@<"60ET7@<!^0ET/@<!F0 +MET;@<!.0ET3@<`V0ET?@<`>0!/W@5/[PD)="X)`$1/"0ET/@D`1%\)"71."0 +M!$;PH^3PD)=%X)`$2/"0ET;@D`1)\)"71^"0!$KPH^3PD)<NX)`'`/"0ER_@ +MD`<!\)"7,."0!P+PD)<QX)`'`_#DD)<S\)"7+@3PY*/PH_"C\)"70O"C\*/P +MH_"C\*/PD`5@X)"74O"0!6'@D)=3\)`%8N"0EU3PD`5CX)"75?"0ETO@_Y"7 +M5>#^TY]0"Y"72^##GM.4`4`0D)<YX+0!`H`#D)<]X/]18B*0!6#@D)=(\)`% +M8>"0ETGPD`5BX)"72O"0!6/@D)=+\,-T_Y_^D)=)X-.>0![@+_"CX+3_#^3P +MH^"T_P/D\"*0ETN``Y"72N`$\"*0ETG@+_`BD)<ZX&0!8`)A:9``1N!$`?U_ +M1A)'()"73.!P,I"7,N!@%9"7/A)#4Y"`EA(E"'^`?@@2*PB`!I`%(G1_\)"7 +M.>#_46*0ETQT`1)'%H!`D)=,X&0!<#B0ESW@_U%BY)"73/"0`$7@1`']?T42 +M1R"0ES+@8!60ES020U.0@)82)0A_@'X($BL(@`60!2+D\)`%A^!D@/"0ETC@ +MD`6$\)"72>"0!87PD)=*X)`%AO"0ETO@D`6'\"+`X,#PP(/`@L#0==``P`#` +M`<`"P`/`!,`%P`;`!Y`!Q'1J\'1+H_!3D=^0`3S@53#U-*/@53'U-:/@53+U +M-J/@53/U-^4T,.`&D`$\=`'PY30PX0B0`3QT`O#QJ^4T,.(RD`$\=`3PD`:2 +MX##@'G5$%'5%`.3[_7]8?@$2,&*0`5MT!?"0!I)T`?"`!Y"7=N3PD8KE-##C +M,I`!/'0(\)`&DN`PX1YU1!1U10#D^_U_7'X!$C!BD`%?=`7PD`:2=`+P@`>0 +MEW7D\)&*Y30PY`F0`3QT$/`2;7?E-##E")`!/'0@\%&TY34PX!"0`3UT`?"0 +M`(/@D)=Y\)&*=&H$D`'$\'1+H_#0!]`&T`70!-`#T`+0`=``T-#0@M"#T/#0 +MX#*0EWG@_WT!@`1]`7\,CV>-:.5G5`__D)=WX%0/;V!QY6<PXBV0EW?@(.($ +M?P'1YY"7=^`PXPGE9R#C!+%.@%&0EW?@(.-*Y6<PXT6O:/$&@#^0EW?@5`__ +MOPP,Y6<@XP?Q)>]@*[%.D)=WX%0/_[\$#>5G(.(($E8Q[V`4T920EW?@5`__ +MOP(($F`)[V`"T<J0EW?@5`__D)=YX%0/;W`CX##F'Y"7=^!4#_^0EVO@_D^0 +M`2_P[F2`D)=K\)"7>>!4O_`BD`8$X$1`\.5IM`$$?P'Q2)"7=^!4\/#@1`3P +M(N]D`7`N?7U_`A(Q+'T"?P,2,2R0`5?D\)`!/'0"\)&3Y/_1>9`&!.!4?_"0 +M!@K@5/CP(I`!-G1]\*-T`O!]??\2,9U]`G\#$C&=D`8$X$2`\)`&"N!$!_"0 +MEW+@H^"0!5CPY6DPX!J0EV_@<!G@!/"0EW?@5`_#E`10"WT!?P2!E^20EV_P +M(HL1BA*)$Q)?^ZL1JA*I$Q(D8O5J%&`.%&`>%&`O)`-P0'\!@#JK$:H2J1.0 +M``(20B#]Y/_14X`GJQ&J$JD3D``"$D(@_7\!T5,?@!.K$:H2J1.0``(20B#] +M?P+14^3_L6HB[R3^8`L$<!V0EWAT`?"`$>V0EWAP!70%\(`"[?"0EWC@D)=M +M\"+O8`N0EX?@M`$0Y/^`"9"7A^"T`05_`1)O^R*0`3=T`O"0!2)T__`2;E_O +M<`:0`<AT_?!]`G\#$C&=Y6I@!'\!T7D2;Q^0EW?@5/#PX$0"\"*0EW?@5/#P +MX$0!\!)@1Q)@G9"7=^!4\/#@1`+P(I"7HN_P$FZ@D)>BX&`%D`4BY/"0EW?@ +M5/#PX$0$\"*0!@3@5+_P[V`)Y6FT`03D__%(D)=WX%3P\.!$#/`B$E/\OP$: +MD)=VX'`4D)=UX'`.D)=YX%0/TY0$4`-_`2)_`"*/:Y"7@A)&7>5K8!!T(2_U +M@N0T_/6#X$00\(`.="$O]8+D-/SU@^!4[_"0!!]T`?`B?0)_`Q(Q+.5J%"3] +M4`*`(9"7>N!@!GT!?PR`#Y"7=^!4#\.4!%`&?0%_!)&7Y/_1>2*0EWO@8`[D +M\*/@5/WPX%0'<">`(Y"7;N`$\)"7?.!4[_"0EV[@TY0!0`WE:;0!"J/@<`;@ +M!/`BD8HBD`$PY/"C\*/PH_"0`3CPH_"C\*/P_7]0$D<@Y/U_41)'(.3]?U(2 +M1R#D_7]3`D<@D`$\=/_PH_"C\)`!-/"C\*/PH_#]?U021R!]_W]5$D<@??]_ +M5A)'('W_?U<"1R#`X,#PP(/`@L#0==``P`#``<`"P`/`!,`%P`;`!Y`!Q'1$ +M\'10H_"0`33@52CU+)`!-N!5*O4NH^!5*_4OY2P@X`(AVY`!-'0!\(713872 +M3H733X744(7548764H774X795.545$##$__E4U0@;W`"(9+E5##E`B&2Y5)4 +M'_4(Y4U4/_4)Y5%4'__E""7@)./U@N0TE/6#Y(_P$D*!Y5-4'__E""7@),#U +M@N0TD?6#Y(_P$D*!Y0G3E`1``W4)!'7P"N4(D)``$D-?=?`"Y0D20U_@_J/@ +M_^535!\O_^0^_G7P"N4(D)``$D-?=?`"Y0D20U_N\*/O\.54(.8CY5-4'__E +M""7@)&/U@N0TE/6#Y(_P$D*!Y4\PYS2O"+'#@"[E4U0?_^4()>`DH_6"Y#24 +M]8/DC_`20H'E3S#G$>5/5'_]Y5-4'_4-JPFO")&PY6H4)/U0`H!`D)=ZX&`R +MD`%;Y/"0`3QT!/!Q_.]D`7`H=404]47[_7]8?@$2,&*0`5MT!?"0!I)T`?"0 +MEW;P@`AQ_+\!`Q),BN4L,.$FD`$T=`+PD/T0='_PA=%8A=)9A=-:A=1;A=5< +MA=9=A==>A=E?D0OE+##C!I`!-'0(\.4L,.0)D`$T=!#P0U<0Y2PPY2:0`<_@ +M,.4?X%3?\)`!-'0@\'6H`'7H`!)/Y9```^!4^_`21-:`_N4L,.8&D`$T=$#P +MY2XPX3R0`39T`O!#5T"0`0+@5`-D`7`ID`$WX##@"G0!\)"7?^3P@!B0EW_@ +M!/#@PY0*0`SD\)`$&>`PX`,21/+E+C#@")`!-G0!\-%EY2XPXG&0`39T!/#E +M:60!<&7E:F!AY6ID`F`&Y6ID!7`GD`:KX)"7;?"0!JK@D)=X\)"7;>!P!Y"7 +M>.#_@`60EVW@_Y"7;>_PD)=OX&`#X!3PD)=NY/"0`5?PD`$\=`+PD)=\X%3] +M\.!4[_#E:A0D_5`"@`*Q$.4N,.,QD`$V=`CPY6ED`7`EY6I@(9`!5^3PD`$\ +M=`+P=40#=44`Y/O]?U1^`1(P8I`!5W0%\.4N,.0OD`$V=!#PY6ED`7`CY6I@ +M'Y`!5^3PD`$\=`+PD)=[Y/"0EWS@5/WPX%0'<`,23(KE+C#E'9`!-G0@\.5I +MM`$2Y6I@#I"7>N!D`F`$L7B``K&)Y2XPYAZ0`39T0/#E:;0!$^5J8`^0EWS@ +M5/[PX%0'<`,23(KE+S#A"9`!-W0"\!)/>71$!)`!Q/!T4*/PT`?0!M`%T`30 +M`]`"T`'0`-#0T(+0@]#PT.`RD`0;X%1_9']_`6`"?P`BD)=-X%3P1`/P5`]$ +M@/![`'H`>5B0EY$20XL+>I=Y3=,0KP'#P-"0EXX20XN0EX;@9`)@;)`!K^!@ +M"9`!Q^`$\/"`\9"7H^#_!/"0EXX20VN0``'O$D)?D)>.$D-KBV.*9(EE=68" +M>P%Z`7F@$D4)D)>1$D-KBV.*9(EED)>.$D-K$B1B_\14#_5F>P%Z`7FB$D4) +MD`&O=/_PD`'+X&2`\-#0DJ\BJ07I5!_U#W0!+_6"Y#22]8/@]0Z0!/W@M`$% +M=1`#@`-U$`'KPY400`*AP^4.)0W^Y0^00=:3_>[3G70!0!<O]8+D-)+U@^3P +M=(0O]8+D-`3U@^GP(B_U@N0TDO6#[O`BD`:IX/4*5,!P#I"7?.!4_O#@5/WP +M$DR*Y0HPYA>0EWS@1`'PD)=ZX&0"8`2Q>(`+L8F`!Y"7?.!4_O#E"I"7?##G +M(.!$`O!U1`/D]47[_7]4?@$2,&*0`5=T!?"0EWMT`?`BX%3]\"*0EX'@_^3] +M$D9AD`0?=`'P(I`!7^3PD`$\=`CP=404Y/5%^_U_7'X!$C!BD`%?=`7PD`:2 +M=`+PD)=U%/"0EW?@5`_#E`Q0`Q),DR*M!W7P">V0DR<20U_@_W2E+?6"Y#26 +M]8/@5!_\TY]``JP'["7@))[U@N0T0?6#Y)/^=`&3_^PEX"1F]8+D-$'U@W0! +MDR__Y),^PQ/^[Q/_[27@).'U@N0TDO6#[O"C[_!TA"WU@N0T!/6#[/#_(G'\ +M[V0!<"J0EWS@5`-P(I"7>>!4#].4`E`7D)=\X"#B$)"7?.`@Y`F0EV_@<`-_ +M`2)_`"+DD)=-\.5J8''E:60!<&OE:A1@*23]8"4D`B3[4`*`(Y"7;>`4\.!@ +M!*/@8!:0EVW@<`J0EWC@D)=M\(``D)=-=`'PD)=-X&`QD)=\X$00\)"7=.#U +M1.3U1?O]?U1^`1(P8I`!5W0%\)"7=^!4#\.4!%`'?0%_!!),ER+`X,#PP(/` +M@L#0==``P`#``<`"P`/`!,`%P`;`!Y`!Q'3@\'16H_!3D>^0`%'@_Y``5>!? +M]3WE/3#F&'1`\)"7.^!4`_^_`PN0ESC@8`5_`1)'->4],.<5D`!5=(#PD)<[ +MX%0#_[\#!7\"$D<UD`'$=.#P=%:C\-`'T`;0!=`$T`/0`M`!T`#0T-""T(/0 +M\-#@,H\=C!Z-'R*/((PAC2(BD`',X%0/D)=2\)"74N#]<`,"6,>0EZ'@_W0! +M?@"H!PB`!<,SSC/.V/G_[UUP`P)8O9"7H>!U\`20`=`20U_@D)=3\'5C`75D +MEW5E4W5F`7L!>I=Y5!)%"9"75.#_Q!,3$U0!D)>A,.!9X'7P`I``B!)#7^"0 +MEU7PD)>AX'7P`I``B1)#7^"0EU;PD)>AX'7P!)`!T1)#7^"0EU?PD)>AX'7P +M!)`!TA)#7^"0EUCPD)>AX'7P!)`!TQ)#7^"0EUGP@#/@=?`$D`'1$D-?X)"7 +M5?"0EZ'@=?`$D`'2$D-?X)"75O"0EZ'@=?`$D`'3$D-?X)"75_#O5'__>P%Z +MEWE5$<B0EU+@_Y"7H>#^=`&H!@B``L,SV/ST7Y"74O"0EZ'@_W0!J`<(@`+# +M,]C\D`',\)"7H>`$\.!4`_`"5XJ0`<;@1`+P`E>*(I"76A)#B^\20Y18]`%8 +M_`)9!`-9#`59%`991@=9'`E9)0Q9+@U9-@X``%D_D)=:$D-KP=B0EUH20VO! +MTI"76A)#:^%DD)=:$D-KX0*0EUH20VN`*Y"76A)#:P)$89"76A)#:P)X?Y"7 +M6A)#:^$QD)=:$D-K`G9PD`'&X$0!\"*0``020B#_5!_^[U0@Q!-4!_VO!I"7 +M7>_PH^WPHQ)#BY"77Q)#:Y```Q)"(%3PQ%0/D)=B\)``!!)"(%1`Q!,35`.0 +MEV/PD)==X/]U\`F0DR420U^M@JR#D)=D[/"C[?#O=?`)I"0C^723-?#Z>P&C +M$D.+D)=?$D-KD``#$D(@5`__D)=F$D-K[Q)"39"77Q)#:Y```A)"(/^0EV82 +M0VN0``'O$D)?D)=?$D-KD``!$D(@_Y"79.#\H^#]]8*,@^_P$B1BC8*,@Z/P +MD)=BX/Z0EUW@_R3!]8+D-)+U@^[PD)=>X/YU\`GOD),I$D-?[O!U\`GOD),J +M$D-?=`'PD)=CX/YU\`GOD),K$D-?[O"/$>\EX"3D]8+D-)6O@O43CQ3E$77P +M`J0D@?ETDC7P=14!]1:)%W7P">41D),E$D-?KX*%@QB/&>41=?`)I"0C^723 +M-?!U&@'U&XD<=,$E$?6"Y#22]8/@$D.46M4`6NH!6O\"6Q0#6ST$6U(%6V<& +M6XT,6[H-6^<.7!0/``!<2.41)>`DY/6"Y#25]8-T\/"C=!6`/.41)>`DY/6" +MY#25]8-T\/"C=!"`)^41)>`DY/6"Y#25]8-T\/"C=`6`$N41)>`DY/6"Y#25 +M]8-T\/"CY/#E$27@)('U@N0TDO6#=`_PHW2/\(%(Y1$EX"3D]8+D-)7U@W0/ +M\*-T]8`GY1$EX"3D]8+D-)7U@W0/\*-T\(`2Y1$EX"3D]8+D-)7U@^3PHW0- +M\.41)>`D@?6"Y#22]8/D\*/P@4B0!$?@JQ6J%JD7$D)-D`1&X*L5JA:I%Y`` +M`1)"7Y`$1>"%%(*%$X/PD`1$@3^0!$O@JQ6J%JD7$D)-D`1*X*L5JA:I%Y`` +M`1)"7Y`$2>"%%(*%$X/PD`1(@%B0!$_@JQ6J%JD7$D)-D`1.X*L5JA:I%Y`` +M`1)"7Y`$3>"%%(*%$X/PD`1,@"N0!%/@JQ6J%JD7$D)-D`12X*L5JA:I%Y`` +M`1)"7Y`$4>"%%(*%$X/PD`10X(44@H43@Z/PJQ6J%JD7P`/``L`!$B1B_ZL: +MJANI'!(D8E_0`=`"T`,20DVK%>47)`'YY#46^L`#P`+``1(D8O^K&JH;J1R0 +M``$20B!?T`'0`M`#$D)-A12"A1.#P(/`@N#_A1F"A1B#X/[O7M""T(/PA12" +MA1.#H\"#P(+@_X49@H48@Z/@_N]>T(+0@_#E$27@)('U@N0TDO6#X/ZCX$Y@ +M.W42"W0!?@"H$@B`!<,SSC/.V/G_Y1$EX"2!]8+D-)+U@^!>_J/@7TY@!N42 +M)!"`7142Y1+#E`!0RH!6Y1$EX"3D]8+D-)7U@^#^H^!.8#UU$@]T`7X`J!(( +M@`7#,\XSSMCY_^41)>`DY/6"Y#25]8/@7OZCX%].8`B0EVGE$O"`$!42Y1+# +ME`!0R(`%Y)"7:?#E$27@).3U@N0TE?6#X/ZCX$Y@.^3U$G0!?@"H$@B`!<,S +MSC/.V/G_Y1$EX"3D]8+D-)7U@^!>_J/@7TY@")"7:N42\(!;!1+E$K00RH!2 +MY1$EX"2!]8+D-)+U@^#^H^!.8#GD]1)T`7X`J!((@`7#,\XSSMCY_^41)>`D +M@?6"Y#22]8/@7OZCX%].8`;E$B00@`H%$N42M`S,@`7DD)=J\)"7:>#_=?`) +MY1&0DR<20U_O\)"7:N#^=?`)Y1&0DR@20U_N\'2$)1'U@N0T!/6#X-.?0!^0 +MEVG@_W2$)1'U@N0TEO6#[_!TA"41]8+D-`3U@^_P=(0E$?6"Y#0$]8/@PYY0 +M'Y"7:N#_=(0E$?6"Y#26]8/O\'2$)1'U@N0T!/6#[_"0EVG@_].4$T`(D),B +M=`/P@"'OTY0+0`B0DR)T`O"`$^_3E`-`")"3(G0!\(`%Y)"3(O"0DR+@D`2Q +M\"(2)&+U:2+3$*\!P\#0D``!$D(@D)=Z\)```Q)"()"7;/`2)&)E:F`#$DWQ +MT-"2KR(2)&+U$<.4(%`5D``"$D(@_W0C)1'U@N0TE?6#[_`BY1&T(`J0``(2 +M0B"0DR'P(I```A)"()"7//#@8`3@]'`AHJ_D,_41PJ^0`$?@5/O]?T<21R!] +M0'\!$C%FY1$D_Y*O(I`"">#]$B1B_J\%[2Z0EX#PD``!$D(@_^TOD)>!\)`` +M`A)"(/_M+Y"7@O"0``,20B#_[2^0EX/PD``$$D(@_ZX%[2^0EX3P(N3U:9"7 +M?/#U:I"7>70,\)"7=_#DD)=Z\)"7=O"0EW7PD)=X!/"0EVWPY)"7>_"0EV_P +MD)=T=`?PY)"7;O"0EW+PHW0"\.20EW'PD)=L\"+DD)=[\)"7;O"0EWSP(N57 +M<#>0EWG@5`_3E`%0+)`"A^!P)I"7AN"T`A"0EWW@_J/@]8*.@^!@"(`/D`&O +MX'`)D)=QX&`#?P$B?P`BD``KX$0!\'_H?@,2,A60``C@1!#]?P@21R"0``G@ +M5/?]?PD21R"0`"C@5/[]?R@21R"0`"#@5/[]?R`21R"0`"7@1$#]?R421R"0 +M``G@5._]?PD"1R"0`"7@5+_]?R421R"0`"#@1`']?R`21R"0`"C@1`']?R@2 +M1R"0`/#@,.'YD``)X$0(_7\)$D<@D``(X%3O_7\($D<@D``KX%3^_7\K$D<@ +M?^A^`P(R%8]LD)>#$D9=Y6Q@$'0A+_6"Y#3\]8/@1!#P@`YT(2_U@N0T_/6# +MX%3O\)`$'W0!\"+OPY0@4#GO,.`7[<14\/WOPQ/^)*3U@N0T!/6#X%0/@!#O +MPQ/^)*3U@N0T!/6#X%3P\'2D+O6"Y#0$]8/@3?`BY/41=?`)Y1&0DRH20U_@ +M9`%@`N%AY1$EX"3`]8+D-)'U@^#^H^#3E`#NE`!0`N%AY1%U\`JD)`#Y=)`U +M\'46`?47B1CE$27@),#U@N0TD?6#X/^CX)"75L_PH^_PY1$EX"1C]8+D-)3U +M@^#_H^"0EUC/\*/O\'2$)1'U@N0T!/6#X%0_D)=2\.#^5!^C\'7P">41D),G +M$D-?X)"76_!T9"41]8+D-);U@^##E`5``H$[D)=;X/^0EU/@GT`3D)=;X)"7 +M4_#N5$#^D)=2\.].\)`$_>!D`7`ID)=3X/^004J3_G0C)1'U@N0TE?6#X,.> +M0`;OD$#:@#"0EU/@D$#V@">0EU/@_Y!!2I/^=",E$?6"Y#25]8/@PYY`!N^0 +M01*`!Y"74^"002Z3D)=:\)"76N!U\`:D)%#Y=$`U\'43__44B160EU+@D$'R +MD__3D)=9X)^0EUC@E`!`">3]KQ$2:5K!^.41)>`DX?6"Y#22]8/@]1FCX/4: +MJQ.J%*D5$B1B_WX`JQ:J%ZD8$D*7_:SP$B1[[R4:]1KN-1GU&:L3JA2I%9`` +M`1)"(/]^`*L6JA>I&)```A)"POVL\!(D>^\E&O4:[C49]1FK$ZH4J160``(2 +M0B#_?@"K%JH7J1B0``020L+]K/`2)'OO)1KU&NXU&?49JQ.J%*D5D``#$D(@ +M_WX`JQ:J%ZD8D``&$D+"_:SP$B1[[R4:]1KN-1GU&:L3JA2I%9``!!)"(/]^ +M`*L6JA>I&)``"!)"POVL\!(D>^\E&O4:[C49]1FK$ZH4J160``420B#_?@"0 +MEU;@_*/@_1(D>]/E&I_E&9Y`#.4:G_4:Y1F>]1F`!>3U&?4:Y1$EX"3A]8+D +M-)+U@^49\*/E&O"0EU+@)>`D9O6"Y#1!]8/#=`&3E1KDDY494`:O$?%MP<R0 +MEU+@)>`DGO6"Y#1!]8/3=`&3E1KDDY494`+!S'T!KQ$2:5K!S'1D)1'U@N0T +MEO6#X/QD!6`"H=:0DR+@_[0#"Y"74^##E!E`/8`N[[0""Y"74^##E!%`+H`? +MD),BX/^T`0N0EU/@PY0*0!N`#.]P$9"74^##E`-`#9"50W0!\(`%Y)"50_!T +M0R41]8+D-)3U@^#U&W0C)1'U@N0TE?6#X/_#E#!0`J&#D)5#X&0!8`*A@W1$ +M)1'U@N0TE?6#X&0*8%'O)`7_Y#/^="$E$?6"Y#22]8/@_=.?[F2`^'2`F%`R +M[20%_^0S_G0C)1'U@N0TE?6#X-.?[F2`^'2`F%`4=(0E$?6"Y#26]8/@_Y"7 +M4^!O8#UT(R41]8+D-)7U@^#_TY1"0`5U&P6`#N_3E#E`!74;`X`#=1L!="$E +M$?6"Y#22]8/O\'1$)1'U@N0TE8`I=&0E$?6"Y#26]8/D\'1$)1'U@N0TE?6# +MX`3P@!#D]1MT9"41]8+D-);U@^3PD)=3X/]TA"41]8+D-);U@^_P=$,E$?6" +MY#24]8/E&_!U\`GE$9"3*Q)#7^"T`1#D]1MT9"41]8+D-);U@^3PK1O!R.QD +M!F`"P<SU&?4:D$(3D_]^`)"75N#\H^#]$B1[D)=4[O"C[_!T0R41]8+D-)3U +M@^#U&^3U$JL6JA>I&'7P`N42I/6"A?"#$D+"_:SPY1*00@Z3_WX`$B1[[R4: +M]1KN-1GU&<.0EU7@E1J0EU3@E1E`!P42Y1*T!;WE$L,3]1+E&[0!!N42<$:` +M$^4;M`,5Y1)P!74;`X`YY1*T`05U&P&`+X`JY1NT!2CE$G`%=1L%@`WE$K0! +M!74;`X`#=1L!TY"76>"4`Y"76."4`$`#Y/4;TY"76>"4`Y"76."4`$`#Y/4; +M=$,E$?6"Y#24]8/E&_#]KQ$Q)'1D)1'U@N0TEO6#X-.4!71D4`XE$?6"Y#26 +M]8/@!/"`"R41]8+D-);U@^3PJQ:J%ZD8Y/7P$D+ZJQ:J%ZD8D``"Y/7P$D,9 +MD``$Y/7P$D,9D``&Y/7P$D,9D``(Y/7P$D,9Y1$EX"3`]8+D-)'U@^3PH_#E +M$27@)&/U@N0TE/6#Y/"C\.41)>`DH_6"Y#24]8/D\*/P!1'E$<.4(%`"(6<B +MJ0=TA"GU@N0T!/6#X%1_]1Q4'_UU\`GID),G$D-?X/^0EUSPZ27@)('U@N0T +MDO6#X/NCX)"77<OPH^OPZ27@).3U@N0TE?6#X/NCX)"77\OPH^OP[27@)&;U +M@N0T0?6#Y)/Z=`&3^^DEX"3A]8+D-)+U@^KPH^OP[<.?0`,":'!TI2GU@N0T +MEO6#[?`$_)"77.#_[-.?0`(!H>S#E!!`(>PD\/]T`7X`J`<(@`7#,\XSSMCY +M_Y"77>!>_J/@7TYP(^S#E!!0.70!?@"H!`B`!<,SSC/.V/G_D)=?X%[^H^!? +M3F`<[&038`CL9!)@`[P1"9"77>`PX`)\&*T$C1R`-`R`BY"77.#\;7!I=*4I +M]8+D-);U@^WP=?`)Z9"3*1)#7^"T`0SE'"#F!^U$0/4<@`.O'"+M)>`DGO6" +MY#1!]8/DD_YT`9/_[27@)&;U@N0T0?6#=`&3+__DDS[#$_[O$__I)>`DX?6" +MY#22]8/N\*/O\(!;[=.<0%:0EUS@_W2E*?6"Y#26]8/O\*T'CQSM)>`DGO6" +MY#1!]8/DD_YT`9/_[27@)&;U@N0T0?6#=`&3+__DDS[#$_[O$__I)>`DX?6" +MY#22]8/N\*/O\*\<(G0!*?6"Y#22]8/D\.4<1(#_=(0I]8+D-`3U@^_P(JH' +M=(0J]8+D-`3U@^!4?_M4'_F0EU[P=?`)ZI"3*!)#7^"0EV#P=?`)ZI"3)Q)# +M7^"0EV'P_.HEX"3D]8+D-)7U@^#_H^"0EV+/\*/O\.HEX"2!]8+D-)+U@^#_ +MH^"0EV3/\*/O\.G3G$`)D)=AX)"77O#[[7`"09V0EU_M\.LPY@F0EU[@^Z/@ +M%/"0EU_@<`)!G9"77N#_TY0`4`)!G>20EUWP[Q20EUSPD)=@X/F0EUS@_M.9 +M0'+NE!!`)>XD\/]T`7X`J`<(@`7#,\XSSMCY_Y"79.#\H^#][%[^[5].<"N0 +MEUS@_\.4$%`V=`%^`*@'"(`%PS/.,\[8^?^0EV+@_*/@_>Q>_NU?3F`5D)=< +MX/NCX`3PD)=?X/^0EUW@;V`(D)=<X!3P@("0EU_@_Y"77>##GU`,D)=<X+4! +M!9"78.#[ZR7@))[U@N0T0?6#Y)/^=`&3_^LEX"1F]8+D-$'U@^23_'0!DR__ +M[#[#$_[O$__J)>`DX?6"Y#22]8/N\*/O\'2$*O6"Y#0$]8/K\/\BD`1$=!'P +MHW3P\*-T#_"CY/#]=*0M]8+D-`3U@^3P#;T0\.3]=?`*[9"0`!)#7^3PH_!U +M\`KMD)`"$D-?Y/"C\'7P"NV0D`020U_D\*/P=?`*[9"0!A)#7^3PH_!U\`KM +MD)`($D-?Y/"C\'2$+?6"Y#26]8-T$_!T1"WU@N0TE?6#Y/!T0RWU@N0TE/6# +MY/#M)>`DP/6"Y#21]8/D\*/P[27@)&/U@N0TE/6#Y/"C\.TEX"3C]8+D-)3U +M@^3PH_#M)>`DH_6"Y#24]8/D\*/P[27@)&3U@N0TE?6#Y/"C\.TEX"2D]8+D +M-)7U@^3PH_!T1"WU@N0TEO6#Y/!T)"WU@N0TEO6#Y/!T9"WU@N0TEO6#Y/"0 +M0<23_G0!D_^008QT`9,O_^23/L,3_N\3_^TEX"3A]8+D-)+U@^[PH^_P=?`) +M[9"3*A)#7W0!\'7P">V0DRD20U]T`?!TP2WU@N0TDO6#=`SP=?`)[9"3)1)# +M7W3_\*/P=?`)[9"3(Q)#7^3PHW0/\'7P">V0DR<20U]T$_!U\`GMD),H$D-? +MY/!TA"WU@N0T!/6#=!/P#>UD(&`"80\BD`8T=/_PY*/PH_"C\"(BY)"7A?"B +MKS.0EU/PD`"`X"#A&A(R*Q(R*Y"74N!D`?#@)*V0`<3P=&RC\(#?D`8P=`'P +MPJ^0`(#@1(#P$D36D)=3X"3_DJ\BCA&/$HL3BA2)%>20EU+P[Y``,?`21-;E +M$50#_Y``,N!4_$_P$D36D``SX%1_\!)$UI``,^`@YPZ0EU+@PY1D4`7@!/"` +MZY"74N##E&10$)``,."K$ZH4J1420DU_`2)_`"+D]28B?PNQON]E)F`0Y2:T +M`07D]2:``W4F`7\!(G\`(N4C9`%P0+%;OP$%?P$21.:0`$;@1`3]?T821R"0 +M`$3@5/O]?T021R"0`$;@5/O]?T821R!_`K&^CR>0`<GE)_"T`0,21]LBTQ"O +M`</`T)"7I>_PTY0'4$?@_W0!J`<(@`+#,]C\]/^0`$;@7_`21-:0EZ7@_70! +M?@"H!0B`!<,SSC/.V/G_D`!$X/OD_N];J`4(@`;.HN<3SA/8^/^`1)"7I>`D +M^/#@_W0!J`<(@`+#,]C\$D3.D)>EX/UT`7X`J`4(@`7#,\XSSMCY_Y``0N#[ +MY/[O6Z@%"(`&SJ+G$\X3V/C_T-"2KR+DD)>=\*/PD`7XX'`/H^!P"Z/@<`>C +MX'`#?P$BTY"7GN"4Z)"7G>"4`T`#?P`B?S)^`!(R%9"7G>1U\`$20H&`QI`` +M$>!$"?`21-:0EQT20U.0@)82)0A_>'X($BL(D)<A$D-3D("6$B4(?P1^#!(K +M")"7)1)#4Y"`EA(E"'\`?@@2*PB0ERD20U.0@)82)0A_<'X.$BL(D(!H$B44 +M``,ME>3]_Q(P+)"7A^"T`1&0@&@2)10``RV5Y/U_`1(P+")_>'X($B)ED)<= +M$B4(?P1^#!(B99"7(1(E"'\`?@@2(F60ER42)0B0EX?@D)<=M`$-$D-3[U3' +M_^U4Q_V`!Q)#4^]4Q__LD("6$B4(?WA^"!(K")"7(1)#4^]4#__LD("6$B4( +M?P1^#!(K")"7)1)#4^]$`O_LD("6$B4(?P!^"!(K"']P?@X2(F60ERD2)0B0 +M@)82)10`&R6@?W!^#A(K")"`:!(E%`````#D_?\2,"R0EX?@M`$1D(!H$B44 +M`````.3]?P$2,"R0`!'@5/;P`D36D)>'X)"7+?`B[W`"(;&0ERW@8`*A?)"7 +M&1)#4Y"`EA(E"'^,?@@2*PB0EL420U.0@)82)0A_1'X($BL(D);)$D-3D("6 +M$B4(?UQ^"!(K")"6S1)#4Y"`EA(E"']L?@X2*PB0EM$20U.0@)82)0A_<'X. +M$BL(D);5$D-3D("6$B4(?W1^#A(K")"6V1)#4Y"`EA(E"']X?@X2*PB0EMT2 +M0U.0@)82)0A_?'X.$BL(D);A$D-3D("6$B4(?X!^#A(K")"6Y1)#4Y"`EA(E +M"'^$?@X2*PB0END20U.0@)82)0A_B'X.$BL(D);M$D-3D("6$B4(?XQ^#A(K +M")"6\1)#4Y"`EA(E"'_0?@X2*PB0EO420U.0@)82)0A_U'X.$BL(D);Y$D-3 +MD("6$B4(?]A^#A(K")"6_1)#4Y"`EA(E"'_<?@X2*PB0EP$20U.0@)82)0A_ +MX'X.$BL(D)<%$D-3D("6$B4(?^Q^#A(K")"7"1)#4Y"`EA(E"'\$?@P2*PB0 +MEPT20U.0@)82)0A_!'X-$BL(D)<1$D-3D("6$B4(?PQ^"1(K")"7%1)#4Y"` +MEA(E"'\$?@@2*PB0ERUT`?`BD)<MX&0!8`*A?'^,?@@2(F60EQD2)0A_1'X( +M$B)ED);%$B4(?UQ^"!(B99"6R1(E"']L?@X2(F60ELT2)0A_<'X.$B)ED);1 +M$B4(?W1^#A(B99"6U1(E"']X?@X2(F60EMD2)0A_?'X.$B)ED);=$B4(?X!^ +M#A(B99"6X1(E"'^$?@X2(F60EN42)0A_B'X.$B)ED);I$B4(?XQ^#A(B99"6 +M[1(E"'_0?@X2(F60EO$2)0A_U'X.$B)ED);U$B4(?]A^#A(B99"6^1(E"'_< +M?@X2(F60EOT2)0A_X'X.$B)ED)<!$B4(?^Q^#A(B99"7!1(E"'\$?@P2(F60 +MEPD2)0A_!'X-$B)ED)<-$B4(?PQ^"1(B99"7$1(E"'\$?@@2(F60EQ42)0A_ +MC'X($B)ED)>9$B4(D)>9$D-3[43`_>R0EYD2)0B0EYD20U.0@)82)0A_C'X( +M$BL(D("6$B44``$``']$?@@2*PB0@)82)10`VR6D?UQ^"!(K")"`EA(E%"#; +M):1_;'X.$BL(D("6$B44(-LEI']P?@X2*PB0@)82)10$&R6D?W1^#A(K")"` +MEA(E%`0;):1_>'X.$BL(D("6$B44!!LEI']\?@X2*PB0@)82)10$&R6D?X!^ +M#A(K")"`EA(E%&/;):1_A'X.$BL(D("6$B44!!LEI'^(?@X2*PB0@)82)10@ +MVR6D?XQ^#A(K")"`EA(E%"#;):1_T'X.$BL(D("6$B44(-LEI'_4?@X2*PB0 +M@)82)10@VR6D?]A^#A(K")"`EA(E%``;):1_W'X.$BL(D("6$B44`!LEI'_@ +M?@X2*PB0@)82)10DVR6D?^Q^#A(K"'\$?@P2(F60EYD2)0B0EYD20U/D_^R0 +MEYD2)0B0EYD20U/O1!'_[)"7F1(E")"7F1)#4Y"`EA(E"'\$?@P2*PA_!'X- +M$B)ED)>9$B4(D)>9$D-3[U3P_^R0EYD2)0B0EYD20U/O1`'_[)"7F1(E")"7 +MF1)#4Y"`EA(E"'\$?@T2*PA_#'X)$B)ED)>9$B4(D)>9$D-3Y/_LD)>9$B4( +MD)>9$D-3[T01_^R0EYD2)0B0EYD20U.0@)82)0A_#'X)$BL(?PQ^"1(B99"7 +MF1(E")"7F1)#4^U4#_WL5/#\D)>9$B4(D)>9$D-3[400_>Q$`?R0EYD2)0B0 +MEYD20U.0@)82)0A_#'X)$BL(?P1^"!(B99"7F1(E")"7F1)#4^]4\/_LD)>9 +M$B4(D)>9$D-3[T0!_^R0EYD2)0B0EYD20U.0@)82)0A_!'X($BL(Y)"7+?`B +MTQ"O`</`T)"7H.WPD)>?[_#3E`=09>#_=`&H!PB``L,SV/ST_Y``1^!?\!)$ +MUI"7G^#_=`&H!PB``L,SV/S_D`!&X$_P$D36D)>@X&`6D)>?X/]T`:@'"(`" +MPS/8_/^0`$6`:)"7G^#_=`&H!PB``L,SV/ST_Y``18!MD)>?X"3X\.#_=`&H +M!PB``L,SV/S$5/`21,Z0EY_@_W0!J`<(@`+#,]C\_Y``0^!/\!)$UI"7H.!@ +M&Y"7G^#_=`&H!PB``L,SV/S$5/#_D`!"X$^`&I"7G^#_=`&H!PB``L,SV/S$ +M5/#T_Y``0N!?\!)$UM#0DJ\BBQ&*$HD3D``"$D(@D)<[\.`PX$N0ES)T`?!_ +M@'X($B)ED)<T$B4(JQ&J$JD3D``!$D(@_^3\_?YX&A(D]:@$J06J!JL'D)<T +M$D-3[%0#_!)#1I"7/A(E")`%(N3P@"WDD)<R\'^`?@@2(F7L5`/\[$3`_)"7 +M-!(E")"7-!)#4Y"`EA(E"'^`?@@2*PB0ESO@,.$;?0Q_1Q)'()``2.!$#/U_ +M2!)'()``1N!$$(`>D`!'X%3S_7]'$D<@D`!(X%3S_7]($D<@D`!&X%3O_7]& +M$D<@Y)"7./`BY/U_11)'()`$_>3PH_"0ESSPD)="\)"71?"0ET/PD)=&\)"7 +M1/"0ET?PD)<N!/#DH_"C\*/PD)<S\)"7./"0ESKPD)=,\)"7/?"0ESGPD)<R +M\)``4>!$P/U_40)'()"73.!D`6`)D)<ZX&`#`GA^D)<NX,.4_U`%X`3P@#N0 +MER_@PY3_4`;@!/#D@"B0ES#@PY3_4`K@!/#DD)<O\(`5D)<QX,.4_U`0X`3P +MY)"7,/"0ER_PD)<N\)``1.!4#&!VX##B,I"70N##E/]0!>`$\(`DD)=#X,.4 +M_U`&X`3PY(`1D)=$X,.4_U`,X`3PY)"70_"0ET+PD`!$X##C,I"71>##E/]0 +M!>`$\(`DD)=&X,.4_U`&X`3PY(`1D)='X,.4_U`,X`3PY)"71O"0ET7PD`3] +MX$0!\"*0``(20B"0ESKPD``!$D(@)>`EX)"7.?`2)&(EX"7@D)<]\)`%8."0 +METCPD`5AX)"72?"0!6+@D)=*\)`%8^"0ETOPHJ_D,Y"77?#"KY"7.>#_$DIB +MD)==X"3_DJ^0ESK@<`(AB9"7.>!P`B&)D)<]X'`"(8FBK^0SD)==\,*OD)=, +M=`'PD)==X"3_DJ\21Q>0`$;@1`']?T821R"0ES+@8!60ESX20U.0@)82)0A_ +M@'X($BL(@`:0!2)T?_"0`$7@5._]?T421R"0!8?@9(#PD)=(X)`%A/"0ETG@ +MD`6%\)"72N"0!8;PD)=+X)`%A_"BK^0SD)==\,*OD`$\X$0@\'T@Y/\2,;>` +M+9"7.N!P+Y"73!)'%I``1N!4_OU_1A)'()`%(N3PHJ\SD)==\,*O?2#D_Q(Q +-29"77>`D_Y*O(@"'%P`` +` +end diff --git a/sys/contrib/dev/rtwn/rtwn-rtl8192cfwU_B.fw.uu b/sys/contrib/dev/rtwn/rtwn-rtl8192cfwU_B.fw.uu new file mode 100644 index 0000000..f104224 --- /dev/null +++ b/sys/contrib/dev/rtwn/rtwn-rtl8192cfwU_B.fw.uu @@ -0,0 +1,366 @@ +begin 444 rtwn-rtl8192cfwU_B.fw.uu +MPH@"`%@``@`'%11$K#\!`,S,S,P````````````````"19L````````````` +M`````````EE4```````````````````````````````````````````````` +M`````````````F2,```````"2[(```4$`P(``P8%!`,`!`8%!`(`!`@'!@0` +M!@H)"`8`"`H)"`0`"`H)"`(`"`H)"```"!(1$`@`$!H9&!``&"(A(!@`("(A +M(!``("(A(`@`("(A'`@`("(A%`@`("(@&`@`(#$P(!``,#$P&```,#$O$!`` +M,#$L$!``,#$H$```,#$@$```,#$0$```,`0$!`4$!`0%!04&!@0$!`4%!08& +M!`0%!04%!@8$!`4%!04&!PH+#1`$!04&!@D,$0@("0D*#!`1!`0$!00$!0<' +M!P@*!`0$!`8*"PT%!0<'"`L-#P0$!`4'!PD)#`X0$@8'"0H,#A$3"0D)"0P. +M$1,````````````D)BH8&AT?(2<I*@```!\C*"HL``0`!``(`!``&``D`#`` +M2`!@`)``P`#8`%``>`"@`,@!0`&0`>`",`$L`4`!X`+0`^@$L`9`!]```@`" +M``0`"``,`!(`&``D`#``2`!@`&P`*``\`%``9`"@`,@`\`$8`&0`H`#P`6@! +M]`)8`R`#Z`("`@("`@,#!`0%!P(#!`H,#A`2!0<'"`L2)#P!`0$!`0(#!`4& +M!P@!`@,$!08'"`4&!P@)"@L,(!X<&!`8````````````````NP$,Y8(I]8+E +M@SKU@^`B4`;I)8+XYB*[_@;I)8+XXB+E@BGU@N6#.O6#Y),BNP$&B8**@_`B +M4`+W(KO^`?,B^+L!#>6"*?6"Y8,Z]8/H\")0!NDE@LCV(KO^!>DE@LCR(L7P +M^*/@*/#%\/CE@A6"<`(5@^`X\"*[`0J)@HJ#X/7PH^`B4`:'\`GG&2*[_@?C +M]?`)XQDBB8**@^23]?!T`9,BNP$0Y8(I]8+E@SKU@^#U\*/@(E`)Z26"^(;P +M".8BN_X*Z26"^.+U\`CB(N6#*O6#Z9/U\*/IDR*[`0J)@HJ#\.7PH_`B4`;W +M":?P&2*[_@;SY?`)\QDB^+L!$>6"*?6"Y8,Z]8/H\.7PH_`B4`GI)8+(]@BF +M\"*[_@GI)8+(\N7P"/(B[TO_[DK^[4G][$C\(N#\H^#]H^#^H^#_(J0E@O6" +MY?`U@_6#(N#[H^#ZH^#Y(OC@^Z.CX/DE\/#E@A6"<`(5@^#Z./`BZ_"CZO"C +MZ?`BT(/0@OCDDW`2=`&3<`VCHY/X=`&3]8*(@^1S=`*3:&#OHZ.C@-_0@]"" +M^.23<!)T`9-P#:.CD_AT`9/U@HB#Y'-T`I.U\`9T`Y-H8.FCHZ.C@-B.9(]E +MK66L9*]C$DJ0KV6N9)`$@.!4#_VL!W01+/6"Y#3\]8/@1`'P=!$L]8+D-/SU +M@^!4^_"L!W06+/6"Y#3\]8/@1/KP=!4L]8+D-/SU@^!$'_"L!W0&+/6"Y#3\ +M]8/@1`_PD`13Y/"0!%+PD`11=/_PD`10=/WP=!0L]8+D-/SU@^!4P$W]=!0O +M]8+D-/SU@^WP(A)+5>]D`6`(D`&Y=`'P@&[E)50#8`B0`;ET`O"`8.4C5`_3 +ME`)`")`!N70$\(!/Y24PX@B0`;ET"/"`0N4E,.0(D`&Y=!#P@#60DE?@8`B0 +M`;ET(/"`)Y"27.!@")`!N72`\(`9Y29@!Y`!N>3P@`Z0`;GD\)`!N'0$\'\! +M(I`!N'0$\'\`(@)%`P)%!GT!?PS3$*\!P\#0CV>-:.5G5`__Y2)4#V]@<N5G +M,.(PY2(@X@5_`1)*Y^4B,.,0Y6<@XPL22*3O8%,22P&`3N4B(.-)Y6<PXT2O +M:!)*L8`]Y2)4#_^_#`[E9R#C"1)(I.]@*A)+`>4B5`__OP0.Y6<@X@D21'SO +M8!022C/E(E0/_[\""1)+@N]@`Q)+,=#0DJ\B`D79`E%WY).C^.23HT`#]H`! +M\@C?](`IY).C^%0')`S(PS/$5`]$(,B#0`3T5H`!1O;?Y(`+`0($"!`@0("0 +M2T3D?@&38+RC_U0_,.4)5!_^Y).C8`$.SU3`)>!@J$"XY).C^N23H_CDDZ/( +MQ8+(RL6#RO"CR,6"R,K%@\K?Z=[G@+[D_^4D8'7E(60!<&_E)!1@*R3]8"<D +M`B3[4`*`(9"25>`4\.!@!*/@8!20DE7@<`B0DF/@D))5\'\!@`)_`>]@.D,E +M$.20DH/PD))6X'7P`Z3_D))?X"^0DH3PY/O]?U1^`1)+EY`!5W0%\.4B5`_# +ME`10!WT!?P0210TBY2%D`7!GY21@8^4D9`)@!N4D9`5P)Y`&J^"0DE7PD`:J +MX)"28_"0DE7@<`>0DF/@_X`%D))5X/^0DE7O\)"25^!@`N3PY)"25O"0!5AT +M`_"0`5?D\)`!/'0"\%,E_5,E[^4D%"3]4`*``Q)'""+DD)(0\)`&J>"0DA#P +MX%3`<`E3)?Y3)?T22WN0DA#@,.850R4!D))DX&0"8`422LR`"!))\X`#4R7^ +MD)(0X##G)T,E`N20DH/PD));X)"2A/#D^_U_5'X!$DN7D`%7=`7PD))E=`'P +M(E,E_2+O9`%P,'UX?P(2-G5]`G\#$C9UD`%7Y/"0`3QT`O`210GD_Q)8II`& +M!.!4?_"0!@K@5/CP(I`!-G1[\*-T`O!]>_\2-N9]`G\#$C;FD`8$X$2`\)`& +M"N!$!_`22W#E(2#@!>20DE?P(I"2*1)#BQ)+9)"2*1)#:Q(IV?4D%&`.%&`? +M%&`Q)`-P1'\!@#V0DBD20VN0``(20B#]Y/\22F6`*9"2*1)#:Y```A)"(/U_ +M`1)*91^`%)"2*1)#:Y```A)"(/U_`A)*9>3_$D=T(N3U)?4D=2,,=2(,D))D +M\)"28O"0DF'PD))C!/"0DE7PY)"29?"0DE?PD))?=`7PY)"25O"0DEWPHW0# +M\)"26O"C=`7PD))9=!3PD))@=`7PY)"26/"0DE3PD))]\)"27/`B$DM5[V0! +M8`B0`;ET`?"`1Y"28N!@")`!N70"\(`YD))AX&`(D`&Y=`3P@"OE(U0/TY0$ +M0`B0`;ET"/"`&N4F8`B0`;ET(/"`#I`!N>3PD`&X=`CP?P$BD`&X=`CP?P`B +MY)"2%O#E)&!)D))EX&`-Y/!3)?WE)50'<#B`,Y"25N`$\%,E[Y"2%N#_D)): +MX"__Y#/^D))6X-.?[F2`^'2`F$`-Y2&T`0NCX'`'X`3P(A)+>R+E)!0D_5`" +M@$>0DF3@8"P210GDD)*#\)"26>"0DH3PY/O]?UA^`1)+EY`!6W0%\)`&DG0! +M\)"28O"`$.4B5`_#E`10!WT!?P0210WD_Q)8IB+3$*\!P\#0CV.0!!W@8"20 +M!2+@]69T__`2=F6_`0V0DGC@_WT!$E@*$D/GD`4BY6;P@`V0DGC@_WT!$E@* +M$D/GD`0?="#PT-"2KR*0`5_D\)`!/'0(\.20DH/PD))9X)"2A/#D^_U_7'X! +M$DN7D`%?=`7PD`:2=`+PD))A%/#E(E0/PY0,4`,210DBD`$W=`+PD`4B=/_P +M$G9E[W`&D`'(=/WP?0)_`Q(VYN4D8`5_`1)8IA)W&U,B\$,B`B+O)/Y@"P1P +M(I"28W0!\(`6[7`*D))@X)"28_"`!9"28^WPD))CX)"25?`B[V`/="$M]8+D +M-/SU@^!$$/`B="$M]8+D-/SU@^!4[_`BD`8$X%2_\.]@"N4AM`$%Y/\22:A3 +M(O!#(@PBD`0=X'`4D))WX/_D_1)8"HYICVJ0!!]T(/`BD)*I[_`2=J:0DJG@ +M8`60!2+D\%,B\$,B!"*0!@3@1$#PY2&T`05_`1))J%,B\$,B!"+E(S#F$N4C +M5`__D`$OX%2`3V2`\%,COR)3(O!#(@$22X422X93(O!#(@(B09)U`$&2J`!! +MDJH`09*B``"0!!O@5']D?W\!8`)_`"+DD))E\)"25O#U)2*0DEW@H^"0!5CP +M(GT!KR,"10U_`"(B(O"0DEG@D)*$\.3[_7]8?@'3$*\!P\#0D)*#X/NCX/5$ +MY/5%$C6KT-"2KR+`X,#PP(/`@L#0==``P`#``<`"P`/`!,`%P`;`!W4.`%.1 +MWY`!/.!5,/4TH^!5,?4UH^!5,O4VH^!5,_4WY30PX`:0`3QT`?#E-##A")`! +M/'0"\#$$Y30PXBR0`3QT!/#E)&`BD`:2X##@%)"2@^1QAY`!6W0%\)`&DG0! +M\(`'D))BY/!Q>^4T,.,\D`$\=`CPY21@,I`&DN`PX220DH/D\)"26>"0DH3P +MY/O]?UQ^`7&7D`%?=`7PD`:2=`+P@`>0DF'D\'%[Y30PY`B0`3QT$/"1]N4T +M,.4)D`$\="#P$E._Y34PX!:0`3UT`?"0`(/@]2.0`;OE(_!Q&7%[Y34PX@:0 +M`3UT!/#E-3#D!I`!/700\.4V,.`&D`$^=`'PY38PX0:0`3YT`O#0!]`&T`70 +M!-`#T`+0`=``T-#0@M"#T/#0X#+E7F0!<#OQN[\!!'\!\:^0`$;@1`3]?T:Q +M0I``1.!4^_U_1+%"D`!&X%3[_7]&L4)_`O'ZCV*0`<GE8O"T`0+QD2+PD`!% +MX%3^_7]%TQ"O`</`T(^"=8,`[?#QZM#0DJ\B[Q1@,!1@9B0"8`*A_I"2/W0" +M\)``2.!$#/U_2+%"D`!'X$0(_7]'L4*0`$7@1!#]?T6`<>20DC_PD)([$D-3 +MD("%$BI_?X!^"!(OV9``1>!$[_U_1;%"D`!%X%3O_7]%L4*0`$;@1!#]?T:` +M.)"2/W0!\)"211)#4Y"`A1(J?W^`?@@2+]F0`$7@1"#]?T6Q0I``1>!$$/U_ +M1;%"D`!&X$00_7]&L4(BD``"$D(@D))!\)```1)"("7@)>"0DD#P$BG9)>`E +MX)"21/"0!6#@D))/\)`%8>"0DE#PD`5BX)"24?"0!6/@D))2\**OY#.0DB7P +MPJ^0DD#@_Q)3;9"2)>`D_Y*OD))!X'`"X0:0DD#@<`+A!I"21.!P`N$&HJ_D +M,Y"2)?#"KY"24W0!\)"2)>`D_Y*OL3F0`$;@1`']?T:Q0I"2.>!@%9"211)# +M4Y"`A1(J?W^`?@@2+]F`!I`%(G1_\)``1>!4[_U_1;%"D`6'X&2`\)"23^"0 +M!83PD))0X)`%A?"0DE'@D`6&\)"24N"0!8?PHJ_D,Y"2)?#"KY`!/.!$(/!] +M(.3_$C<`@"N0DD'@<"V0DE.Q.)``1N!4_OU_1K%"D`4BY/"BKS.0DB7PPJ]] +M(.3_$C:2D)(EX"3_DJ\BD`$\=/_PH_"C\)`!-/"C\*/PH_#]?U2Q0GW_?U6Q +M0GW_?U:Q0GW_?U>A0I`!,.3PH_"C\*/PD`$X\*/PH_"C\/U_4+%"Y/U_4;%" +MY/U_4K%"Y/U_4Z%"D`!)X)"2J_#@5`_P1/#]?TFQ0I"2J^!$L/U_2:%"D`'* +MY6'P[V`"\9$B?POQ^N]E86`0Y6&T`07D]6&``W5A`7\!(G\`(N20DGOPD`"` +MX$2`_7^`H4+@7_#3$*\!P\#0?Q#?_M#0DJ\BTQ"O`</`T)"2K._PTY0'4$3@ +M_W0!J`<(@`+#,]C\]/^0`$823^>0DJS@_70!?@"H!0B`!<,SSC/.V/G_D`!$ +MX/OD_N];J`4(@`;.HN<3SA/8^/^`3)"2K.`D^/#@_W0!J`<(@`+#,]C\]/^0 +M`$/@7_`23^J0DJS@_70!?@"H!0B`!<,SSC/.V/G_D`!"X/OD_N];J`4(@`;. +MHN<3SA/8^/_0T)*O(I`"A._PH^[PHW0%\"+OCO`20[I0RP!`4/,`@%$>`0!1 +M,@(`44H$````46?M5#]P!/[_@`1^`']`[RW_[CS^[W@&SL,3SA/8^7@&PS/. +M,\[8^8`F[51_<`3^_X`$?@!_@.\M_^X\_N]X!\[#$\X3V/EX!\,SSC/.V/G] +MK`:`2>UP!/[_@`1^`7\`[RWN/'T`_(`U[%0!37`$_O^`!'X"?P#O+>X\PQ-] +M`(`:[%0#37`$_O^`!'X$?P#O+>X\$Q-4/WT`)>`EX/RN!*\%(I`!Y'18\*-T +M`O`BY)"2%_"C\'6.`A)/U]&ED))\[_#1F9"2?N_PT>V0DG/N\*/O\.3U5?4A +M$G#6T9`22$(2,CW1A1)/.O$%T<#1B='5T811)Q)^=)"2&>79\,*OD`"`X$1` +M\!)/ZG7H`T.HA=*O,6R0DA?@9`'PY54PY`G"KU-5[]*OD77E53#F%L*O4U6_ +MTJ\2:;R0DD/@_V`#M`$"46N0DD/@<`,2?M)1/Y`!O>4B\)"29."0`;SP@+60 +MDJ/@5/[PY)"2I?"0DJ/@5'_PHW0*\"*0!C3@8"44<!M[`7H&>35_^7X!$G8# +MOP$)D`8UX%0/\(`$@`#!LN20!C3P(I"2.N##E!10!>`$\&$CD)(ZX&048`)A +M(Y"22>!P)9"23.!P'Y"22N!P&9"23>!P$Y"22^!P#9"23N!P!Y`$_>!4_O"0 +MDDG@D`1$\)"22N"0!$7PD))+X)`$1O"CY/"0DDS@D`1(\)"23>"0!$GPD)). +MX)`$2O"CY/"0DC7@D`1,\)"2-N"0!$WPD)(WX)`$3O"0DCC@D`1/\.20DCKP +MD)(U!/#DH_"C\*/PD)))\*/PH_"C\*/PH_"0!6#@D)(:\)`%8>"0DAOPD`5B +MX)"2'/"0!6/@D)(=\)"24N#_D)(=X/[3GU`+D))2X,.>TY0!0!"0DD#@M`$" +M@`.0DD3@_W%M(I`%8."0DD_PD`5AX)"24/"0!6+@D))1\)`%8^"0DE+PPW3_ +MG_Z0DE#@TYY`'N`O\*/@M/\/Y/"CX+3_`^3P(I"24H`#D))1X`3P(I"24.`O +M\"*0DD'@9`%@`H%TD`!&X$0!_7]&$DU"D))3X'`RD)(YX&`5D))%$D-3D("% +M$BI_?X!^"!(OV8`&D`4B='_PD))`X/]Q;9"24W0!$DTX@$"0DE/@9`%P.)"2 +M1.#_<6WDD))3\)``1>!$`?U_11)-0I"2.>!@%9"2.Q)#4Y"`A1(J?W^`?@@2 +M+]F`!9`%(N3PD`6'X&2`\)"23^"0!83PD))0X)`%A?"0DE'@D`6&\)"24N"0 +M!8?P(M,0KP'#P-"0`<S@5`^0DAKPD)(:X/UP`J&]D)*HX/]T`7X`J`<(@`7# +M,\XSSMCY_^]=<`*AMI"2J.!U\`20`=`20U_@D)(;\'4=`74>DG4?&W4@`7L! +M>I)Y'+'"D)(<X/_$$Q,35`&0DJ@PX%G@=?`"D`"($D-?X)"2'?"0DJC@=?`" +MD`")$D-?X)"2'O"0DJC@=?`$D`'1$D-?X)"2'_"0DJC@=?`$D`'2$D-?X)"2 +M(/"0DJC@=?`$D`'3$D-?X)"2(?"`,^!U\`20`=$20U_@D)(=\)"2J.!U\`20 +M`=(20U_@D)(>\)"2J.!U\`20`=,20U_@D)(?\.]4?_][`7J2>1T27<F0DAK@ +M_Y"2J.#^=`&H!@B``L,SV/ST7Y"2&O"0DJC@_W0!J`<(@`+#,]C\D`',\)"2 +MJ.`$\.!4`_"!AI`!QN!$`O#0T)*O(M,0KP'#P-"+&HH;B1R0DH420XNK':H> +MJ1^0DH@20XNO(!4@[V`>D)*(Y'7P`1)#=!(IV?^0DH7D=?`!$D-T[Q)"38#; +MJQJJ&ZD<T-"2KR+3$*\!P\#0D)*+$D.+D)*JX)```1)"7W^O?@$2<QGO8$V0 +MDHL20VN+'8H>B1]U(`)[`7H!>:"QPI"2CA)#:XL=BAZ)'Y"2BQ)#:Q(IV?_$ +M5`_U('L!>@%YHK'"D`&O=/_PD)*JX`3PD`'+X&2`\-#0DJ\B(N3U82*0`61T +MH/`BD))^X)"2#_`BD`#SX'\`,.,"?P$BD``"X%3@?P%@`G\`(I`&-'3_\.2C +M\*/PH_`BD`#SX##B#9`%0700\)`%6O"CY/`B=3`?=3$!Y/4RD`$XY3#PH^4Q +M\*/E,O`BD))^X+0!#)``\N`PYP5^_7\S(G[]?R\B=2@SY/4I=2H']2N0`3#E +M*/"CY2GPH^4J\*/E*_`BD)(0X%3P1`/P5`]$@/![`'H`>5:0DHX20XL+>I)Y +M$,$1TQ"O`</`T)"2D1)#BY"2E.!4\$0&__#M5`_$5/#^[U0/3O"0DI$20VN0 +MDHX20XM[`7J2>931$=#0DJ\BTQ"O`</`T._#E"!0#G2$+_6"Y#0$]8/M\(`I +M=*8O]8+D-)#U@^WPD))F[_`DIO6"Y#20]8/@D))G\'L!>I)Y9GT"\430T)*O +M(H^"CH.CHZ/D\"+D]5Y_8'X!@.W3$*\!P\#0D`0=X&`:D`4BX%208`>0`<;@ +M1$#PD`''X##AY'\`@`)_`=#0DJ\BTQ"O`</`T)"2EN_PH^WPY*/PH_#E)&`$ +MY/\1II"2EN`PX`F0DICD\*-T@/"0DI;@_\,3D/T0\)`$)>_PD)*7X&`?HZ/@ +M_R0/]8+D-/SU@^!$@/!T$"_U@N0T_/6#X$2`\)"2F*/@__TD"/6"Y#3\]8/D +M\'0)+?6"Y#3\]8/@5/#P="$O]8+D-/SU@^!4]_"0DIC@_J/@_]#0DJ\B[V`+ +MD))^X+0!$.3_@`F0DG[@M`$%?P$2=^4B$E?<OP$/D`()X/]]`1$*D`0?="#P +M(I`!`N!4`__@5`P3$U0__N]D`6`$[[0#$)"2$'0!\*-T-_"C=`'P@!KN9`%@ +M!Z\&[F0#<$B0DA!T`?"C=#WPHW1`\)"2$.#^H^#_]8*.@^#]D)(2X/SM7&`, +MCX*.@^SPY)"2=?`BD))UX`3PX,.4"D`+Y/"0!!G@,.`"$<$BP.#`\,"#P(+` +MT'70`,``P`'``L`#P`3`!<`&P`>0`33@52CU+*/@52GU+:/@52KU+J/@52OU +M+^4L(.`"0=^0`31T`?"%T4V%TDZ%TT^%U%"%U5&%UE*%UU.%V53E5%1`PQ/_ +MY5-4(&]P`D&<Y50PY0)!G.525#_U".5-5#_U">515!__Y0@EX"3$]8+D-(WU +M@^2/\!)"@>535!__Y0@EX"2`]8+D-(?U@^2/\!)"@>4)TY0$0`-U"01U\`KE +M")"$`!)#7W7P`N4)$D-?X/ZCX/_E4U0?+__D/OYU\`KE")"$`!)#7W7P`N4) +M$D-?[O"C[_#E5"#F(^535!__Y0@EX"3$]8+D-(SU@^2/\!)"@>5/,.<TKPBQ +M$H`NY5-4'__E""7@)$3U@N0TC?6#Y(_P$D*!Y4\PYQ'E3U1__>535!_U#:L) +MKPB1F^4D%"3]4`*`.I"29.!@*Y`!6^3PD`$\=`3P$DM5[V0!<"&0DH,22X>0 +M`5MT!?"0!I)T`?"0DF+P@`D22U6_`0,22WOE+##A(9`!-'0"\(715H725X73 +M6(7468756H766X777(7971)7(^4L,.,&D`$T=`CPY2PPY`F0`31T$/!#51#E +M+##E)I`!S^`PY1_@5-_PD`$T="#P=:@`=>@`$D]ED``#X%3[\!)/ZH#^Y2PP +MY@:0`31T0/#E+C#@%)"2?70!\)`!-O`21AZ199"2?>3PY2XPX0N0`39T`O!# +M54`1U^4N,.()D`$V=`3P$D::Y2XPXSB0`39T"/#E(60!<"SE)&`HD`%7Y/"0 +M`3QT`O"0DH/D\)"26^"0DH3PY/O]?U1^`1)+EY`!5W0%\.4N,.0KD`$V=!#P +MY2&T`2#E)&`<D`%7Y/"0`3QT`O"0DF7D\%,E_>4E5`=P`Q)+>^4N,.4?D`$V +M="#PY2&T`13E)&`0D))DX&0"8`422LR``Q))\^4N,.8;D`$V=$#PY2&T`1#E +M)&`,4R7^Y254!W`#$DM[Y2\PX0F0`3=T`O`225?0!]`&T`70!-`#T`+0`=`` +MT-#0@M"#T/#0X#*0DJ/@,.`NY2&T`2F0DJ+@!/#@M`H+D)*EX`3PY)"2HO"0 +MDJ7@_Y"2I.#3GU`'L9'DD)*E\"*/"HT+Y0M4'Y"2$O!T`2_U@N0TB/6#X)"2 +M$/"0!/W@D)(3M`$%=`/P@`-T`?"0DA/@_^O#GT`$KPJ`/)"2$.`E#?^C\*/@ +MD$'6D_[OTYY`%'0!)0KU@N0TB/6#Y/"M"Z\*`E>`D)(1X/]T`24*]8+D-(CU +M@^_P(JT'=?`)[9"*2!)#7^#_D)(5\'1G+?6"Y#21]8/@5!^0DA3PTY]`!J/@ +MD)(4\)"2%.#_)>`DGO6"Y#1!]8/DD_IT`9/[[R7@)&;U@N0T0?6#=`&3*__D +MDSK#$_[O$__M)>`DPO6"Y#2)]8/N\*/O\*\%D)(4X/T25X"0DA3@_R+D_P)) +MJ)"2)1)#BQ(IV50!_Y"2H^!4_D_PX##@`K&1D)(E$D-K$BG9PQ,PX`J0``$2 +M0B"0DJ3P(I"2(A)#B^\20Y1>$`%>!P)>-`->/05>1@9>DP=>3@E>5PQ>8`U> +M:0Y><AM>>QQ>&2U>(BY>A#!>*SL``%Z,D)(B$D-K`G-CD)(B$D-K`G-ID)(B +M$D-K`G.>D)(B$D-K`G/FD)(B$D-K`G0?D)(B$D-K`G0XD)(B$D-K`G+,D)(B +M$D-K@$:0DB(20VL"=("0DB(20VL"3?^0DB(20VL"?D&0DB(20VL"?6F0DB(2 +M0VL"<Q&0DB(20VL"<OB0DB(20VNAEI`!QN!$`?`BD``$$D(@_U0?_N]4(,03 +M5`?]KP:0DB7O\*/M\*,20XN0DB<20VN0``,20B!4\,14#Y"2*O"0``020B!4 +M0,03$U0#D)(K\)"2)>#_=?`)D(I&$D-?K8*L@Y"2+.SPH^WP[W7P":0D1/ET +MBC7P^GL!HQ)#BY"2)Q)#:Y```Q)"(%0/_Y"2+A)#:^\20DV0DB<20VN0``(2 +M0B#_D)(N$D-KD``![Q)"7Y"2)Q)#:Y```1)"(/^0DBS@_*/@_?6"C(/O\!(I +MV8V"C(.C\)"2*N#^D)(EX/\D@O6"Y#2)]8/N\)"2)N#^=?`)[Y"*2A)#7^[P +M=?`)[Y"*2Q)#7W0!\)"2*^#^=?`)[Y"*3!)#7^[PCP_O)>`DQO6"Y#2/KX+U +M$(\1Y0]U\`*D)`+Y=(DU\'42`?43B11U\`GE#Y"*1A)#7Z^"A8,5CQ;E#W7P +M":0D1/ETBC7P=1<!]1B)&72")0_U@N0TB?6#X!)#E&`B`&`W`6!,`F!A`V"* +M!&"?!6"T!F#:#&$'#6$T#F%A#P``897E#R7@),;U@N0TC_6#=/#PHW05@#SE +M#R7@),;U@N0TC_6#=/#PHW00@"?E#R7@),;U@N0TC_6#=/#PHW0%@!+E#R7@ +M),;U@N0TC_6#=/#PH^3PY0\EX"0"]8+D-(GU@W0/\*-TC_`AE>4/)>`DQO6" +MY#2/]8-T#_"C=/6`)^4/)>`DQO6"Y#2/]8-T#_"C=/"`$N4/)>`DQO6"Y#2/ +M]8/D\*-T#?#E#R7@)`+U@N0TB?6#Y/"C\"&5D`1'X*L2JA.I%!)"39`$1N"K +M$JH3J120``$20E^0!$7@A1&"A1"#\)`$1"&,D`1+X*L2JA.I%!)"39`$2N"K +M$JH3J120``$20E^0!$G@A1&"A1"#\)`$2(!8D`1/X*L2JA.I%!)"39`$3N"K +M$JH3J120``$20E^0!$W@A1&"A1"#\)`$3(`KD`13X*L2JA.I%!)"39`$4N"K +M$JH3J120``$20E^0!%'@A1&"A1"#\)`$4."%$8*%$(.C\*L2JA.I%,`#P`+` +M`1(IV?^K%ZH8J1D2*=E?T`'0`M`#$D)-JQ+E%"0!^>0U$_K``\`"P`$2*=G_ +MJQ>J&*D9D``!$D(@7]`!T`+0`Q)"3841@H40@\"#P(+@_X46@H45@^#^[U[0 +M@M"#\(41@H40@Z/`@\""X/^%%H*%%8.CX/[O7M""T(/PY0\EX"0"]8+D-(GU +M@^#^H^!.8$N0DC%T"_"0DC'@_\.4`%`"0=IT`7X`J`<(@`7#,\XSSMCY_^4/ +M)>`D`O6"Y#2)]8/@7OZCX%].8`J0DC'@)!"C\(!HD)(QX!3P@+OE#R7@),;U +M@N0TC_6#X/ZCX$Y@1Y"2,70/\)"2,>#_PY0`0#QT`7X`J`<(@`7#,\XSSMCY +M_^4/)>`DQO6"Y#2/]8/@7OZCX%].8`B0DC'@H_"`#9"2,>`4\("_Y)"2,O#E +M#R7@),;U@N0TC_6#X/ZCX$Y@1N20DC'PD)(QX/_#E!!``F&3=`%^`*@'"(`% +MPS/.,\[8^?_E#R7@),;U@N0TC_6#X%[^H^!?3F`&D)(QX(!CD)(QX`3P@+_E +M#R7@)`+U@N0TB?6#X/ZCX$Y@1N20DC'PD)(QX/_#E`Q0/'0!?@"H!PB`!<,S +MSC/.V/G_Y0\EX"0"]8+D-(GU@^!>_J/@7TY@")"2,>`D$(`)D)(QX`3P@+_D +MD)(S\)"2,N#_=?`)Y0^0BD@20U_O\)"2,^#^=?`)Y0^0BDD20U_N\.4/PY0@ +M4"QTA"4/]8+D-`3U@^#3GT`"@$=TA"4/]8+D-`3U@^##GE`(D)(SX*/P@#>` +M+72F)0_U@N0TD/6#X/^0DC+@_N_3GD`'D)(T[O"`%Y"2,^#^[\.>4`6C[O"` +M")"2,N"0DC3PD)(TX/VO#Q)7@)"2-.#_="8E#_6"Y#21]8/O\)"2,N#_TY03 +M0`>0BD-T`_`B[].4"T`'D(I#=`+P(N_3E`-`!Y"*0W0!\"+DD(I#\"+3$*\! +MP\#0Y/W\[S#@`GV`[\,3D/T0\*X$KP70T)*O(L#@P/#`@\""P-!UT`#``,`! +MP`+``\`$P`7`!L`'4Y'OD`!1X/^0`%7@7_4]D`!2X/^0`%;@7_4^Y3TPY`:0 +M`%5T$/#E/3#E!I``570@\.4],.8;D`!5=$#PD))"X%0#_[\#"Y"2/^!@!7\! +M$DU7Y3TPYQ60`%5T@/"0DD+@5`/_OP,%?P(235?E/C#@!I``5G0!\.4^,.$& +MD`!6=`+PY3XPX@:0`%9T!/#E/C#C!I``5G0(\-`'T`;0!=`$T`/0`M`!T`#0 +MT-""T(/0\-#@,N_#E"!0.>\PX!?MQ%3P_>_#$_XDI/6"Y#0$]8/@5`^`$._# +M$_XDI/6"Y#0$]8/@5/#P=*0N]8+D-`3U@^!-\"*M!^W#E"!0$W2$+?6"Y#0$ +M]8/@5'^0DBGP@!%TIBWU@N0TD/6#X%1_D)(I\)"2*>#Y5!^C\'7P">V0BD@2 +M0U_@_Y"2+/#M)>`D`O6"Y#2)]8/@^Z/@D)(MR_"CZ_#M)>`DQO6"Y#2/]8/@ +M^Z/@D)(OR_"CZ_"0DBK@_B7@)&;U@N0T0?6#Y)/Z=`&3^^TEX"3"]8+D-(GU +M@^KPH^OP[L.?0`+!^)"2*N#_=&<M]8+D-)'U@^_P[P20DBOPD)(LX/^0DBO@ +M_M.?0`+A,N[#E!!`(>XD\/]T`7X`J`<(@`7#,\XSSMCY_Y"2+>!>_J/@7TYP +M)Y"2*^#_PY004%ET`7X`J`<(@`7#,\XSSMCY_Y"2+^!>_J/@7TY@/)"2*^"T +M$0V0DB[@,.<&D)(K=!?PD)(KX/]D$V`$[[02#9"2+>`PX`:0DBMT&/"0DBO@ +MD)(J\)"2*?"`0I"2*^`$\,%6D)(LX/R0DBK@_VQP<71G+?6"Y#21]8/O\'7P +M">V0BDH20U_@M`$0Z2#F#)"2*N!$0)"2*?"``Z\!(I"2*N#_)>`DGO6"Y#1! +M]8/DD_IT`9/[[R7@)&;U@N0T0?6#=`&3*__DDSK#$_[O$__M)>`DPO6"Y#2) +M]8/N\*/O\(!FD)(JX-.<0%Z0DBS@_W1G+?6"Y#21]8/O\)"2*N_PD)(I\/RC +MX/\EX"2>]8+D-$'U@^23^G0!D_OO)>`D9O6"Y#1!]8-T`9,K_^23.L,3_N\3 +M_^TEX"3"]8+D-(GU@^[PH^_PKP0B=`$M]8+D-(CU@^3PKP60DBG@1(#]$E>` +MD)(IX$2`_R*L!^S#E"!0$W2$+/6"Y#0$]8/@5'^0DBGP@!%TIBSU@N0TD/6# +MX%1_D)(I\)"2*>!4'_^0DBSP=?`)[)"*21)#7^"0DB[P=?`)[)"*2!)#7^#^ +MD)(O\.PEX"3&]8+D-(_U@^#[H^"0DC#+\*/K\.PEX"0"]8+D-(GU@^#[H^"0 +MDC++\*/K\._3GD`,D)(OX)"2+/"0DBGP[7`"(6J0DBWM\)"2*>`PY@Z0DBS@ +MD)(I\)"2+>`4\)"2+>!P`B%JD)(LX/_3E`!0`B%JY)"2*_#O%)"2*O"0DB[@ +M_9"2*N#_TYU`;^^4$$`A[R3P_W0!?@"H!PB`!<,SSC/.V/G_D)(RX%[^H^!? +M3G`GD)(JX/_#E!!0-W0!?@"H!PB`!<,SSC/.V/G_D)(PX%[^H^!?3F`:D)(J +MX)"2*?"0DBO@!/"0DBW@_Y"2*^!O8`B0DBK@%/"`@Y"2+>#_D)(KX,.?4`^0 +MDBK@M04(D)(NX)"2*?"0DBG@_R7@))[U@N0T0?6#Y)/Z=`&3^^\EX"1F]8+D +M-$'U@W0!DRO_Y),ZPQ/^[Q/_["7@),+U@N0TB?6#[O"C[_"O!)"2*>#]$E>` +MD)(IX/\BY)"2&O"0DAK@_\.40$`#`G#5[[0@%)".Q>`$\)")`>#_D([%X+4' +M`N3PD)(:X/]U\`F0BDL20U_@9`%@`P)PS.\EX"2`]8+D-(?U@^#^H^#3E`#N +ME`!0`P)PS)"2&N"4($`)D([%X&`#`G#5D)(:X'7P"J0D`/ETA#7P=1(!]1.) +M%.#_)>`D@/6"Y#2']8/@_:/@D)(?S?"C[?#O)>`DQ/6"Y#2,]8/@_Z/@D)(A +MS_"C[_"0DAK@_\.4(%`3=(0O]8+D-`3U@^!4/Y"2&_"`%)"2&N`DIO6"Y#20 +M]8/@5#^0DAOPD)(;X/Y4'Z/PD)(:X/]U\`F0BD@20U_@D)(D\'3F+_6"Y#20 +M]8/@PY0%0`*A'I"2).#_D)(<X)]`$Y"2)."0DASP[E1`_I"2&_#O3O"0!/W@ +M5`5D`7`KD)(<X/^004J3_I"2&N`D1/6"Y#2.]8/@PYY`!N^00-J`,I"2'."0 +M0/:`*9"2'.#_D$%*D_Z0DAK@)$3U@N0TCO6#X,.>0`;OD$$2@`>0DAS@D$$N +MDY"2(_"0DB/@=?`&I"10^71`-?!U#__U$(D1D)(;X)!!\I/_TY"2(N"?D)(A +MX)0`0`V0DAK@_^3]$F?\`G!BD)(:X"7@),+U@N0TB?6#X/^CX)"2'<_PH^_P +MJP^J$*D1$BG9_WX`JQ*J$ZD4$D*7_:SP$BGRD)(=[H_P$D*!JP^J$*D1D``! +M$D(@_WX`JQ*J$ZD4D``"$D+"_:SP$BGRD)(=[H_P$D*!JP^J$*D1D``"$D(@ +M_WX`JQ*J$ZD4D``$$D+"_:SP$BGRD)(=[H_P$D*!JP^J$*D1D``#$D(@_WX` +MJQ*J$ZD4D``&$D+"_:SP$BGRD)(=[H_P$D*!JP^J$*D1D``$$D(@_WX`JQ*J +M$ZD4D``($D+"_:SP$BGRD)(=[H_P$D*!JP^J$*D1D``%$D(@_WX`D)(?X/RC +MX/T2*?+3D)(>X)^0DAW@GD`,H^"?\)"2'>">\(`'Y)"2'?"C\)"2'>#\H^#] +MD)(:X/\EX"3"]8+D-(GU@^SPH^WPD)(;X"7@)&;U@N0T0?6#Y)/Z=`&3^]/M +MF^R:0`8299L"<#"0DAO@)>`DGO6"Y#1!]8/DD_YT`9/_PY"2'N"?D)(=X)Y` +M`P)P,)"2&N#_?0$29_P"<#"0DAK@_R3F]8+D-)#U@^#\9`5@`L']D(I#X/ZT +M`PN0DAS@PY090#V`+NZT`@N0DAS@PY010"Z`'Y"*0^#^M`$+D)(<X,.4"D`; +M@`SN<!&0DAS@PY0#0`V0CH1T`?"`!>20CH3PD)(:X/XDA/6"Y#2,]8/@D)(H +M\'1$+O6"Y#2.]8/@_L.4,%`*Y)"2*/!TYB_!IY".A.!D`6`"P9R0DAK@)(7U +M@N0TCO6#X&0*8%N0DAK@_^XD!?OD,_IT02_U@N0TB/6#X/_3F^ID@/AT@)A0 +M.)"2&N#^[R0%^^0S^G1$+O6"Y#2.]8/@TYOJ9(#X=("84!:0DAK@)";U@N0T +MD?6#X/^0DAS@;V!6D)(:X"1$]8+D-([U@^#_TY1"0`B0DBAT!?"`$>_3E#F0 +MDBA`!70#\(`#=`'PD)(:X/\D1/6"Y#2.]8/@_G1!+_6"Y#2(]8/N\)"2&N`D +MA?6"Y#2.@"^0DAK@_R3F]8+D-)#U@^3P=(4O]8+D-([U@^`$\(`4Y)"2*/"0 +MDAK@).;U@N0TD/6#Y/"0DAS@_I"2&N#_)";U@N0TD?6#[O"0DBC@_G2$+_6" +MY#2,]8/N\'7P">^0BDP20U_@M`$1Y)"2*/!TYB_U@N0TD/6#Y/"0DBC@_0)P +M+>QD!F`#`G`PD)(=\*/PD$(3D_]^`)"2'^#\H^#]$BGRD)(F[O"C[_"0DAK@ +M)(3U@N0TC/6#X)"2*/#DD)(E\)"2)>#_TY0$4$>K$JH3J11U\`+OI/6"A?"# +M$D+"_:SP[Y!"#I/_?@`2*?*0DAWNC_`20H&0DB;@_J/@_].0DA[@GY"2'>"> +M4`B0DB7@!/"`KY"2)>##$_"0DBC@_[0!#9"2)>!P79"2*`3P@%OOM`,=D)(E +MX/]P")"2*'0#\(!([[0!")"2*'0!\(`\@#60DBC@9`5P,I"2)>#_<`B0DBAT +M!?"`#^^0DBBT`05T`_"``W0!\-.0DB+@E`.0DB'@E`!`!>20DBCPTY"2(N"4 +M`Y"2(>"4`$`%Y)"2*/"0DBC@_9"2&N#_)(3U@N0TC/6#[?`295N0DAK@_R3F +M]8+D-)#U@^#3E`50#W3F+_6"Y#20]8/@!/"`#Y"2&N`DYO6"Y#20]8/D\*L2 +MJA.I%.3U\!)"^JL2JA.I%)```N3U\!)#&9``!.3U\!)#&9``!N3U\!)#&9`` +M".3U\!)#&9"2&N#_)>`D@/6"Y#2']8/D\*/P[R7@),3U@N0TC/6#Y/"C\.\E +MX"1$]8+D-(WU@^3PH_"0DAK@!/`":<$BD`1$=!'PHW3P\*-T#_"CY/"0DAKP +MD)(:X/_#E!!0%'2D+_6"Y#0$]8/D\)"2&N`$\(#BY)".Q?"0B0$$\.20DAKP +MD)(:X/_#E$!``D'+=?`*[Y"$`!)#7^3PH_!U\`KOD(0"$D-?Y/"C\'7P"N^0 +MA`020U_D\*/P=?`*[Y"$!A)#7^3PH_!U\`KOD(0($D-?Y/"C\'0F+_6"Y#21 +M]8-T$_!TA2_U@N0TCO6#Y/!TA"_U@N0TC/6#Y/#O)>`D@/6"Y#2']8/D\*/P +M[R7@),3U@N0TC/6#Y/"C\.\EX"3$]8+D-(WU@^3PH_#O)>`D1/6"Y#2-]8/D +M\*/P[R7@),;U@N0TCO6#Y/"C\.\EX"1&]8+D-(_U@^3PH_!TAB_U@N0TD/6# +MY/!T1B_U@N0TD/6#Y/!TYB_U@N0TD/6#Y/"00<23_G0!D_^008QT`9,O_^23 +M/L,3_N\3_Y"2&N#])>`DPO6"Y#2)]8/N\*/O\'7P">V0BDL20U]T`?!U\`GM +MD(I*$D-?=`'P=((M]8+D-(GU@W0,\'7P">V0BD820U]T__"C\'7P">V0BD02 +M0U_D\*-T#_!U\`GMD(I($D-?=!/P=?`)[9"*21)#7^3P[<.4(%`/=(0M]8+D +M-`3U@W03\(`-=*8M]8+D-)#U@W03\)"2&N`$\"$8(A(IV?_#E$!0%)```A)" +M(/YT1"_U@N0TCO6#[O`B[[1`"I```A)"()"*0O`BD``$$D(@_U0__N]4@,03 +M$Q-4`?VO!@)>J!(IV9")`?`BD)*:[O"C[_#DH_"C\)"2FN#^H^#U@HZ#X&`L +MPY"2G>"4Z)"2G."4`T`*D`'&X$00\'\`(I"2G.1U\`$20H%_"GX`$C=4@,9_ +M`2(2*=GU(2+3$*\!P\#0D)(E$BJ+`````)```1)"()"29/"0``,20B"0DE3P +M$D?<D))DX)`!YO#0T)*O(I```A)"(/\PX"42*=F0DEKPD``!$D(@D));\._# +M$U1_D))9\)```Q)"()"28/`BD)):=`/PD));=`7PD))9=!3PD))@=`7P(A(I +MV3#@&<,35'^0DE_PD``!$D(@_Y"27>3PH^_P@`^0DE]T!?"0DEWD\*-T`_"0 +MDEW@H^"0!5CP(A(IV9"27/!@!^3]?P0210V0DES@D`'G\"*0`@G@_1(IV?ZO +M!>TND))V\)```1)"(/_M+Y"2=_"0``(20B#_[2^0DGCPD``#$D(@_^TOD))Y +M\)``!!)"(/^N!>TOD))Z\"+3$*\!P\#0D)(E$D.+D)(E$D-KD``!$D+"^N7P +M)`#_Y#K^D)(E$D-KD``![H_P$D,9$BG9_V`LM5X6D)(E$D-KD``!$D+"96!P +M!.5?9?!@(Y"2)1)#:Y```1)"PO^N\)'X@!"0DB420VL2*=EE7F`#$E?3T-"2 +MKR*0DBCN\*/O\'5>`8Y?]6#D_7\+L3SD_7\"L3P23[OD_Q)/K^3U8I`!R>5B +M\)"2*.#\H^#][/N-1.3U17T!?V!^`0(UJ],0KP'#P-"0DBOM\)"2*N_PTY0' +M4$^CX'`:D)(JX/]T`:@'"(`"PS/8_/3_D`!'X%_P@!>0DBK@_W0!J`<(@`+# +M,]C\_Y``1^!/\!)/ZI"2*N#_=`&H!PB``L,SV/ST_Y``1H!:D)(JX"3X\*/@ +M<!V0DBK@_W0!J`<(@`+#,]C\Q%3P]/^0`$/@7_"`&I"2*N#_=`&H!PB``L,S +MV/S$5/#_D`!#X$_P$D_JD)(JX/]T`:@'"(`"PS/8_/3_D`!#$D_GT-"2KR*. +M#X\0BQ&*$HD3Y)"2&O#OD``Q\!)/ZN4/5`/_D``RX%3\3_`23^J0`#/@5'_P +M$D_JD``SX"#G#I"2&N##E&10!>`$\(#KD)(:X,.49%`0D``PX*L1JA*I$Q)" +M37\!(G\`(N20DJ;PH_"0!?C@<`^CX'`+H^!P!Z/@<`-_`2+3D)*GX)3HD)*F +MX)0#0`-_`")_,GX`$C=4D)*FY'7P`1)"@8#&D)'_$D-3D("%$BI_?WA^"!(O +MV9"2`Q)#4Y"`A1(J?W\$?@P2+]F0D@<20U.0@(42*G]_`'X($B_9D)(+$D-3 +MD("%$BI_?W!^#A(OV9"`61(JBP`#+97D_?\2-(&0DG[@M`$1D(!9$BJ+``,M +ME>3]?P$2-($B?WA^"!(GWI"1_Q(J?W\$?@P2)]Z0D@,2*G]_`'X($B?>D)(' +M$BI_D))^X)"1_[0!#1)#4^]4Q__M5,?]@`<20U/O5,?_[)"`A1(J?W]X?@@2 +M+]F0D@,20U/O5`__[)"`A1(J?W\$?@P2+]F0D@<20U/O1`+_[)"`A1(J?W\` +M?@@2+]E_<'X.$B?>D)(+$BI_D("%$BJ+`!LEH']P?@X2+]F0@%D2*HL````` +MY/W_$C2!D))^X+0!$9"`61(JBP````#D_7\!$C2!(N]P`P)YG9"2#^!@`P)] +M:)"1^Q)#4Y"`A1(J?W^,?@@2+]F0D:<20U.0@(42*G]_1'X($B_9D)&K$D-3 +MD("%$BI_?UQ^"!(OV9"1KQ)#4Y"`A1(J?W]L?@X2+]F0D;,20U.0@(42*G]_ +M<'X.$B_9D)&W$D-3D("%$BI_?W1^#A(OV9"1NQ)#4Y"`A1(J?W]X?@X2+]F0 +MD;\20U.0@(42*G]_?'X.$B_9D)'#$D-3D("%$BI_?X!^#A(OV9"1QQ)#4Y"` +MA1(J?W^$?@X2+]F0D<L20U.0@(42*G]_B'X.$B_9D)'/$D-3D("%$BI_?XQ^ +M#A(OV9"1TQ)#4Y"`A1(J?W_0?@X2+]F0D=<20U.0@(42*G]_U'X.$B_9D)'; +M$D-3D("%$BI_?]A^#A(OV9"1WQ)#4Y"`A1(J?W_<?@X2+]F0D>,20U.0@(42 +M*G]_X'X.$B_9D)'G$D-3D("%$BI_?^Q^#A(OV9"1ZQ)#4Y"`A1(J?W\$?@P2 +M+]F0D>\20U.0@(42*G]_!'X-$B_9D)'S$D-3D("%$BI_?PQ^"1(OV9"1]Q)# +M4Y"`A1(J?W\$?@@2+]F0D@]T`?`BD)(/X&0!8`*A:'^,?@@2)]Z0D?L2*G]_ +M1'X($B?>D)&G$BI_?UQ^"!(GWI"1JQ(J?W]L?@X2)]Z0D:\2*G]_<'X.$B?> +MD)&S$BI_?W1^#A(GWI"1MQ(J?W]X?@X2)]Z0D;L2*G]_?'X.$B?>D)&_$BI_ +M?X!^#A(GWI"1PQ(J?W^$?@X2)]Z0D<<2*G]_B'X.$B?>D)'+$BI_?XQ^#A(G +MWI"1SQ(J?W_0?@X2)]Z0D=,2*G]_U'X.$B?>D)'7$BI_?]A^#A(GWI"1VQ(J +M?W_<?@X2)]Z0D=\2*G]_X'X.$B?>D)'C$BI_?^Q^#A(GWI"1YQ(J?W\$?@P2 +M)]Z0D>L2*G]_!'X-$B?>D)'O$BI_?PQ^"1(GWI"1\Q(J?W\$?@@2)]Z0D?<2 +M*G]_C'X($B?>D)*>$BI_D)*>$D-3[43`_>R0DIX2*G^0DIX20U.0@(42*G]_ +MC'X($B_9D("%$BJ+``$``']$?@@2+]F0@(42*HL`VR6D?UQ^"!(OV9"`A1(J +MBR#;):1_;'X.$B_9D("%$BJ+(-LEI']P?@X2+]F0@(42*HL$&R6D?W1^#A(O +MV9"`A1(JBP0;):1_>'X.$B_9D("%$BJ+!!LEI']\?@X2+]F0@(42*HL$&R6D +M?X!^#A(OV9"`A1(JBV/;):1_A'X.$B_9D("%$BJ+!!LEI'^(?@X2+]F0@(42 +M*HL@VR6D?XQ^#A(OV9"`A1(JBR#;):1_T'X.$B_9D("%$BJ+(-LEI'_4?@X2 +M+]F0@(42*HL@VR6D?]A^#A(OV9"`A1(JBP`;):1_W'X.$B_9D("%$BJ+`!LE +MI'_@?@X2+]F0@(42*HLDVR6D?^Q^#A(OV7\$?@P2)]Z0DIX2*G^0DIX20U/D +M_^R0DIX2*G^0DIX20U/O1!'_[)"2GA(J?Y"2GA)#4Y"`A1(J?W\$?@P2+]E_ +M!'X-$B?>D)*>$BI_D)*>$D-3[U3P_^R0DIX2*G^0DIX20U/O1`'_[)"2GA(J +M?Y"2GA)#4Y"`A1(J?W\$?@T2+]E_#'X)$B?>D)*>$BI_D)*>$D-3Y/_LD)*> +M$BI_D)*>$D-3[T01_^R0DIX2*G^0DIX20U.0@(42*G]_#'X)$B_9?PQ^"1(G +MWI"2GA(J?Y"2GA)#4^U4#_WL5/#\D)*>$BI_D)*>$D-3[400_>Q$`?R0DIX2 +M*G^0DIX20U.0@(42*G]_#'X)$B_9?P1^"!(GWI"2GA(J?Y"2GA)#4^]4\/_L +MD)*>$BI_D)*>$D-3[T0!_^R0DIX2*G^0DIX20U.0@(42*G]_!'X($B_9Y)"2 +M#_`BBP^*$(D1D``"$D(@D))"\.`PX$N0DCET`?!_@'X($B?>D)([$BI_JP^J +M$*D1D``!$D(@_^3\_?YX&A(J;*@$J06J!JL'D)([$D-3[%0#_!)#1I"211(J +M?Y`%(N3P@"WDD)(Y\'^`?@@2)][L5`/\[$3`_)"2.Q(J?Y"2.Q)#4Y"`A1(J +M?W^`?@@2+]F0DD+@,.$;?0Q_1Q)-0I``2.!$#/U_2!)-0I``1N!$$(`>D`!' +MX%3S_7]'$DU"D`!(X%3S_7]($DU"D`!&X%3O_7]&$DU"Y)"2/_`BD``"$D(@ +MD))#\.!@!.#T<"&BK^0S]0_"KY``1^!4^_U_1Q)-0GU`?P$2-J_E#R3_DJ\B +MY/U_11)-0I`$_>3PH_"0DD/PD)))\)"23/"0DDKPD))-\)"22_"0DD[PD)(U +M!/#DH_"C\*/PD)(Z\)"2/_"0DD'PD))3\)"21/"0DD#PD)(Y\)``4>!$P/U_ +M40)-0I"24^!D`6`(D))!X&`"X:F0DC7@PY3_4`7@!/"`.Y"2-N##E/]0!N`$ +M\.2`*)"2-^##E/]0"N`$\.20DC;P@!60DCC@PY3_4!#@!/#DD)(W\)"2-O"0 +MDC7PD`!$X%0,8';@,.(RD)))X,.4_U`%X`3P@"20DDK@PY3_4`;@!/#D@!&0 +MDDO@PY3_4`S@!/#DD))*\)"22?"0`$3@,.,RD)),X,.4_U`%X`3P@"20DDW@ +JPY3_4`;@!/#D@!&0DD[@PY3_4`S@!/#DD))-\)"23/"0!/W@1`'P(GP. +` +end diff --git a/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c b/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c index a5d3f44..30ec46c 100644 --- a/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c +++ b/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c @@ -50,6 +50,7 @@ static const char rcsid[] = "@(#)$Id$"; # include <net/netisr.h> #include <net/route.h> #include <netinet/in.h> +#include <netinet/in_fib.h> #include <netinet/in_var.h> #include <netinet/in_systm.h> #include <netinet/ip.h> @@ -712,17 +713,16 @@ ipf_fastroute(m0, mpp, fin, fdp) { register struct ip *ip, *mhip; register struct mbuf *m = *mpp; - register struct route *ro; int len, off, error = 0, hlen, code; struct ifnet *ifp, *sifp; - struct sockaddr_in *dst; - struct route iproute; + struct sockaddr_in dst; + struct nhop4_extended nh4; + int has_nhop = 0; + u_long fibnum = 0; u_short ip_off; frdest_t node; frentry_t *fr; - ro = NULL; - #ifdef M_WRITABLE /* * HOT FIX/KLUDGE: @@ -766,11 +766,10 @@ ipf_fastroute(m0, mpp, fin, fdp) /* * Route packet. */ - ro = &iproute; - bzero(ro, sizeof (*ro)); - dst = (struct sockaddr_in *)&ro->ro_dst; - dst->sin_family = AF_INET; - dst->sin_addr = ip->ip_dst; + bzero(&dst, sizeof (dst)); + dst.sin_family = AF_INET; + dst.sin_addr = ip->ip_dst; + dst.sin_len = sizeof(dst); fr = fin->fin_fr; if ((fr != NULL) && !(fr->fr_flags & FR_KEEPSTATE) && (fdp != NULL) && @@ -790,25 +789,22 @@ ipf_fastroute(m0, mpp, fin, fdp) } if ((fdp != NULL) && (fdp->fd_ip.s_addr != 0)) - dst->sin_addr = fdp->fd_ip; - - dst->sin_len = sizeof(*dst); - in_rtalloc(ro, M_GETFIB(m0)); + dst.sin_addr = fdp->fd_ip; - if ((ifp == NULL) && (ro->ro_rt != NULL)) - ifp = ro->ro_rt->rt_ifp; - - if ((ro->ro_rt == NULL) || (ifp == NULL)) { + fibnum = M_GETFIB(m0); + if (fib4_lookup_nh_ext(fibnum, dst.sin_addr, NHR_REF, 0, &nh4) != 0) { if (in_localaddr(ip->ip_dst)) error = EHOSTUNREACH; else error = ENETUNREACH; goto bad; } - if (ro->ro_rt->rt_flags & RTF_GATEWAY) - dst = (struct sockaddr_in *)ro->ro_rt->rt_gateway; - if (ro->ro_rt) - counter_u64_add(ro->ro_rt->rt_pksent, 1); + + has_nhop = 1; + if (ifp == NULL) + ifp = nh4.nh_ifp; + if (nh4.nh_flags & NHF_GATEWAY) + dst.sin_addr = nh4.nh_addr; /* * For input packets which are being "fastrouted", they won't @@ -852,8 +848,8 @@ ipf_fastroute(m0, mpp, fin, fdp) if (ntohs(ip->ip_len) <= ifp->if_mtu) { if (!ip->ip_sum) ip->ip_sum = in_cksum(m, hlen); - error = (*ifp->if_output)(ifp, m, (struct sockaddr *)dst, - ro + error = (*ifp->if_output)(ifp, m, (struct sockaddr *)&dst, + NULL ); goto done; } @@ -935,8 +931,8 @@ sendorfree: m->m_act = 0; if (error == 0) error = (*ifp->if_output)(ifp, m, - (struct sockaddr *)dst, - ro + (struct sockaddr *)&dst, + NULL ); else FREE_MB_T(m); @@ -948,9 +944,9 @@ done: else ipfmain.ipf_frouteok[1]++; - if ((ro != NULL) && (ro->ro_rt != NULL)) { - RTFREE(ro->ro_rt); - } + if (has_nhop) + fib4_free_nh_ext(fibnum, &nh4); + return 0; bad: if (error == EMSGSIZE) { @@ -971,18 +967,11 @@ int ipf_verifysrc(fin) fr_info_t *fin; { - struct sockaddr_in *dst; - struct route iproute; - - bzero((char *)&iproute, sizeof(iproute)); - dst = (struct sockaddr_in *)&iproute.ro_dst; - dst->sin_len = sizeof(*dst); - dst->sin_family = AF_INET; - dst->sin_addr = fin->fin_src; - in_rtalloc(&iproute, 0); - if (iproute.ro_rt == NULL) - return 0; - return (fin->fin_ifp == iproute.ro_rt->rt_ifp); + struct nhop4_basic nh4; + + if (fib4_lookup_nh_basic(0, fin->fin_src, 0, 0, &nh4) != 0) + return (0); + return (fin->fin_ifp == nh4.nh_ifp); } diff --git a/sys/contrib/rdma/krping/krping.c b/sys/contrib/rdma/krping/krping.c index 6ffaa38..667af40 100644 --- a/sys/contrib/rdma/krping/krping.c +++ b/sys/contrib/rdma/krping/krping.c @@ -640,6 +640,7 @@ static int krping_setup_buffers(struct krping_cb *cb) buf.size = cb->size; iovbase = cb->rdma_dma_addr; cb->rdma_mr = ib_reg_phys_mr(cb->pd, &buf, 1, + IB_ACCESS_LOCAL_WRITE| IB_ACCESS_REMOTE_READ| IB_ACCESS_REMOTE_WRITE, &iovbase); @@ -675,8 +676,10 @@ static int krping_setup_buffers(struct krping_cb *cb) if (cb->mem == MR || cb->mem == MW) { unsigned flags = IB_ACCESS_REMOTE_READ; - if (cb->wlat || cb->rlat || cb->bw) - flags |= IB_ACCESS_REMOTE_WRITE; + if (cb->wlat || cb->rlat || cb->bw) { + flags |= IB_ACCESS_LOCAL_WRITE | + IB_ACCESS_REMOTE_WRITE; + } buf.addr = cb->start_dma_addr; buf.size = cb->size; diff --git a/sys/dev/asmc/asmc.c b/sys/dev/asmc/asmc.c index 2c8f6af..9c8c89a 100644 --- a/sys/dev/asmc/asmc.c +++ b/sys/dev/asmc/asmc.c @@ -963,14 +963,13 @@ asmc_fan_getvalue(device_t dev, const char *key, int fan) } static char* -asmc_fan_getstring(device_t dev, const char *key, int fan) +asmc_fan_getstring(device_t dev, const char *key, int fan, uint8_t *buf, uint8_t buflen) { - uint8_t buf[16]; char fankey[5]; char* desc; snprintf(fankey, sizeof(fankey), key, fan); - if (asmc_key_read(dev, fankey, buf, sizeof buf) < 0) + if (asmc_key_read(dev, fankey, buf, buflen) < 0) return (NULL); desc = buf+4; @@ -1012,12 +1011,13 @@ asmc_mb_sysctl_fanspeed(SYSCTL_HANDLER_ARGS) static int asmc_mb_sysctl_fanid(SYSCTL_HANDLER_ARGS) { + uint8_t buf[16]; device_t dev = (device_t) arg1; int fan = arg2; int error = true; char* desc; - desc = asmc_fan_getstring(dev, ASMC_KEY_FANID, fan); + desc = asmc_fan_getstring(dev, ASMC_KEY_FANID, fan, buf, sizeof(buf)); if (desc != NULL) error = sysctl_handle_string(oidp, desc, 0, req); diff --git a/sys/dev/ath/ah_osdep.c b/sys/dev/ath/ah_osdep.c index fe4a657..3d633a4 100644 --- a/sys/dev/ath/ah_osdep.c +++ b/sys/dev/ath/ah_osdep.c @@ -270,12 +270,14 @@ ath_hal_reg_write(struct ath_hal *ah, u_int32_t reg, u_int32_t val) bus_space_tag_t tag = BUSTAG(ah); bus_space_handle_t h = ah->ah_sh; +#ifdef AH_DEBUG /* Debug - complain if we haven't fully waken things up */ if (! ath_hal_reg_whilst_asleep(ah, reg) && ah->ah_powerMode != HAL_PM_AWAKE) { ath_hal_printf(ah, "%s: reg=0x%08x, val=0x%08x, pm=%d\n", __func__, reg, val, ah->ah_powerMode); } +#endif if (ath_hal_alq) { struct ale *ale = ath_hal_alq_get(ah); @@ -291,6 +293,7 @@ ath_hal_reg_write(struct ath_hal *ah, u_int32_t reg, u_int32_t val) if (ah->ah_config.ah_serialise_reg_war) mtx_lock_spin(&ah_regser_mtx); bus_space_write_4(tag, h, reg, val); + OS_BUS_BARRIER_REG(ah, reg, OS_BUS_BARRIER_WRITE); if (ah->ah_config.ah_serialise_reg_war) mtx_unlock_spin(&ah_regser_mtx); } @@ -302,15 +305,18 @@ ath_hal_reg_read(struct ath_hal *ah, u_int32_t reg) bus_space_handle_t h = ah->ah_sh; u_int32_t val; +#ifdef AH_DEBUG /* Debug - complain if we haven't fully waken things up */ if (! ath_hal_reg_whilst_asleep(ah, reg) && ah->ah_powerMode != HAL_PM_AWAKE) { ath_hal_printf(ah, "%s: reg=0x%08x, pm=%d\n", __func__, reg, ah->ah_powerMode); } +#endif if (ah->ah_config.ah_serialise_reg_war) mtx_lock_spin(&ah_regser_mtx); + OS_BUS_BARRIER_REG(ah, reg, OS_BUS_BARRIER_READ); val = bus_space_read_4(tag, h, reg); if (ah->ah_config.ah_serialise_reg_war) mtx_unlock_spin(&ah_regser_mtx); @@ -343,7 +349,8 @@ OS_MARK(struct ath_hal *ah, u_int id, u_int32_t v) } } } -#elif defined(AH_DEBUG) || defined(AH_REGOPS_FUNC) +#else /* AH_DEBUG_ALQ */ + /* * Memory-mapped device register read/write. These are here * as routines when debugging support is enabled and/or when @@ -361,16 +368,19 @@ ath_hal_reg_write(struct ath_hal *ah, u_int32_t reg, u_int32_t val) bus_space_tag_t tag = BUSTAG(ah); bus_space_handle_t h = ah->ah_sh; +#ifdef AH_DEBUG /* Debug - complain if we haven't fully waken things up */ if (! ath_hal_reg_whilst_asleep(ah, reg) && ah->ah_powerMode != HAL_PM_AWAKE) { ath_hal_printf(ah, "%s: reg=0x%08x, val=0x%08x, pm=%d\n", __func__, reg, val, ah->ah_powerMode); } +#endif if (ah->ah_config.ah_serialise_reg_war) mtx_lock_spin(&ah_regser_mtx); bus_space_write_4(tag, h, reg, val); + OS_BUS_BARRIER_REG(ah, reg, OS_BUS_BARRIER_WRITE); if (ah->ah_config.ah_serialise_reg_war) mtx_unlock_spin(&ah_regser_mtx); } @@ -382,21 +392,24 @@ ath_hal_reg_read(struct ath_hal *ah, u_int32_t reg) bus_space_handle_t h = ah->ah_sh; u_int32_t val; +#ifdef AH_DEBUG /* Debug - complain if we haven't fully waken things up */ if (! ath_hal_reg_whilst_asleep(ah, reg) && ah->ah_powerMode != HAL_PM_AWAKE) { ath_hal_printf(ah, "%s: reg=0x%08x, pm=%d\n", __func__, reg, ah->ah_powerMode); } +#endif if (ah->ah_config.ah_serialise_reg_war) mtx_lock_spin(&ah_regser_mtx); + OS_BUS_BARRIER_REG(ah, reg, OS_BUS_BARRIER_READ); val = bus_space_read_4(tag, h, reg); if (ah->ah_config.ah_serialise_reg_war) mtx_unlock_spin(&ah_regser_mtx); return val; } -#endif /* AH_DEBUG || AH_REGOPS_FUNC */ +#endif /* AH_DEBUG_ALQ */ #ifdef AH_ASSERT void diff --git a/sys/dev/ath/ah_osdep.h b/sys/dev/ath/ah_osdep.h index 50778f2..9460192 100644 --- a/sys/dev/ath/ah_osdep.h +++ b/sys/dev/ath/ah_osdep.h @@ -110,25 +110,35 @@ struct ath_hal; do { } while (0) /* - * Register read/write operations are either handled through - * platform-dependent routines (or when debugging is enabled - * with AH_DEBUG); or they are inline expanded using the macros - * defined below. + * Read and write barriers. Some platforms require more strongly ordered + * operations and unfortunately most of the HAL is written assuming everything + * is either an x86 or the bus layer will do the barriers for you. + * + * Read barriers should occur before each read, and write barriers + * occur after each write. + * + * Later on for SDIO/USB parts we will methodize this and make them no-ops; + * register accesses will go via USB commands. + */ +#define OS_BUS_BARRIER_READ BUS_SPACE_BARRIER_READ +#define OS_BUS_BARRIER_WRITE BUS_SPACE_BARRIER_WRITE +#define OS_BUS_BARRIER_RW \ + (BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE) +#define OS_BUS_BARRIER(_ah, _start, _len, _t) \ + bus_space_barrier((bus_space_tag_t)(_ah)->ah_st, \ + (bus_space_handle_t)(_ah)->ah_sh, (_start), (_len), (_t)) +#define OS_BUS_BARRIER_REG(_ah, _reg, _t) \ + OS_BUS_BARRIER((_ah), (_reg), 4, (_t)) + +/* + * Register read/write operations are handled through + * platform-dependent routines. */ -#if defined(AH_DEBUG) || defined(AH_REGOPS_FUNC) || defined(AH_DEBUG_ALQ) #define OS_REG_WRITE(_ah, _reg, _val) ath_hal_reg_write(_ah, _reg, _val) #define OS_REG_READ(_ah, _reg) ath_hal_reg_read(_ah, _reg) extern void ath_hal_reg_write(struct ath_hal *ah, u_int reg, u_int32_t val); extern u_int32_t ath_hal_reg_read(struct ath_hal *ah, u_int reg); -#else -#define OS_REG_WRITE(_ah, _reg, _val) \ - bus_space_write_4((bus_space_tag_t)(_ah)->ah_st, \ - (bus_space_handle_t)(_ah)->ah_sh, (_reg), (_val)) -#define OS_REG_READ(_ah, _reg) \ - bus_space_read_4((bus_space_tag_t)(_ah)->ah_st, \ - (bus_space_handle_t)(_ah)->ah_sh, (_reg)) -#endif #ifdef AH_DEBUG_ALQ extern void OS_MARK(struct ath_hal *, u_int id, u_int32_t value); diff --git a/sys/dev/bwi/if_bwi.c b/sys/dev/bwi/if_bwi.c index ebed09c..00e89f3 100644 --- a/sys/dev/bwi/if_bwi.c +++ b/sys/dev/bwi/if_bwi.c @@ -356,8 +356,8 @@ bwi_attach(struct bwi_softc *sc) device_t dev = sc->sc_dev; struct bwi_mac *mac; struct bwi_phy *phy; + uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)]; int i, error; - uint8_t bands; BWI_LOCK_INIT(sc); @@ -453,15 +453,15 @@ bwi_attach(struct bwi_softc *sc) /* * Setup ratesets, phytype, channels and get MAC address */ - bands = 0; + memset(bands, 0, sizeof(bands)); if (phy->phy_mode == IEEE80211_MODE_11B || phy->phy_mode == IEEE80211_MODE_11G) { - setbit(&bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11B); if (phy->phy_mode == IEEE80211_MODE_11B) { ic->ic_phytype = IEEE80211_T_DS; } else { ic->ic_phytype = IEEE80211_T_OFDM; - setbit(&bands, IEEE80211_MODE_11G); + setbit(bands, IEEE80211_MODE_11G); } bwi_get_eaddr(sc, BWI_SPROM_11BG_EADDR, ic->ic_macaddr); @@ -475,7 +475,7 @@ bwi_attach(struct bwi_softc *sc) } } else if (phy->phy_mode == IEEE80211_MODE_11A) { /* TODO:11A */ - setbit(&bands, IEEE80211_MODE_11A); + setbit(bands, IEEE80211_MODE_11A); error = ENXIO; goto fail; } else { @@ -487,7 +487,7 @@ bwi_attach(struct bwi_softc *sc) BWI_SPROM_CARD_INFO_LOCALE); DPRINTF(sc, BWI_DBG_ATTACH, "locale: %d\n", sc->sc_locale); /* XXX use locale */ - ieee80211_init_channels(ic, NULL, &bands); + ieee80211_init_channels(ic, NULL, bands); ic->ic_softc = sc; ic->ic_name = device_get_nameunit(dev); diff --git a/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c b/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c index 7b43560..b98caae 100644 --- a/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c +++ b/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include <net/route.h> #include <netinet/in_systm.h> #include <netinet/in.h> +#include <netinet/in_fib.h> #include <netinet/in_pcb.h> #include <netinet/ip.h> #include <netinet/ip_var.h> @@ -264,20 +265,14 @@ void __free_ep(struct iwch_ep_common *epc) free(epc, M_DEVBUF); } -static struct rtentry * +static int find_route(__be32 local_ip, __be32 peer_ip, __be16 local_port, - __be16 peer_port, u8 tos) + __be16 peer_port, u8 tos, struct nhop4_extended *pnh4) { - struct route iproute; - struct sockaddr_in *dst = (struct sockaddr_in *)&iproute.ro_dst; - - bzero(&iproute, sizeof iproute); - dst->sin_family = AF_INET; - dst->sin_len = sizeof *dst; - dst->sin_addr.s_addr = peer_ip; - - rtalloc(&iproute); - return iproute.ro_rt; + struct in_addr addr; + + addr.s_addr = peer_ip; + return (fib4_lookup_nh_ext(RT_DEFAULT_FIB, addr, NHR_REF, 0, pnh4)); } static void @@ -1293,7 +1288,7 @@ iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) int err = 0; struct iwch_dev *h = to_iwch_dev(cm_id->device); struct iwch_ep *ep; - struct rtentry *rt; + struct nhop4_extended nh4; struct toedev *tdev; if (is_loopback_dst(cm_id)) { @@ -1329,28 +1324,28 @@ iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) goto fail2; /* find a route */ - rt = find_route(cm_id->local_addr.sin_addr.s_addr, + err = find_route(cm_id->local_addr.sin_addr.s_addr, cm_id->remote_addr.sin_addr.s_addr, cm_id->local_addr.sin_port, - cm_id->remote_addr.sin_port, IPTOS_LOWDELAY); - if (!rt) { + cm_id->remote_addr.sin_port, IPTOS_LOWDELAY, &nh4); + if (err) { printf("%s - cannot find route.\n", __FUNCTION__); err = EHOSTUNREACH; goto fail2; } - if (!(rt->rt_ifp->if_flags & IFCAP_TOE)) { + if (!(nh4.nh_ifp->if_flags & IFCAP_TOE)) { printf("%s - interface not TOE capable.\n", __FUNCTION__); - RTFREE(rt); + fib4_free_nh_ext(RT_DEFAULT_FIB, &nh4); goto fail2; } - tdev = TOEDEV(rt->rt_ifp); + tdev = TOEDEV(nh4.nh_ifp); if (tdev == NULL) { printf("%s - No toedev for interface.\n", __FUNCTION__); - RTFREE(rt); + fib4_free_nh_ext(RT_DEFAULT_FIB, &nh4); goto fail2; } - RTFREE(rt); + fib4_free_nh_ext(RT_DEFAULT_FIB, &nh4); state_set(&ep->com, CONNECTING); ep->com.local_addr = cm_id->local_addr; diff --git a/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c b/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c index 985306c..d896020 100644 --- a/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c +++ b/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c @@ -1536,14 +1536,13 @@ assign_rxopt(struct tcpcb *tp, uint16_t tcpopt) struct toepcb *toep = tp->t_toe; struct adapter *sc = toep->tp_tod->tod_softc; - tp->t_maxseg = tp->t_maxopd = sc->params.mtus[G_TCPOPT_MSS(tcpopt)] - 40; + tp->t_maxseg = sc->params.mtus[G_TCPOPT_MSS(tcpopt)] - 40; if (G_TCPOPT_TSTAMP(tcpopt)) { tp->t_flags |= TF_RCVD_TSTMP; tp->t_flags |= TF_REQ_TSTMP; /* forcibly set */ tp->ts_recent = 0; /* XXX */ tp->ts_recent_age = tcp_ts_getticks(); - tp->t_maxseg -= TCPOLEN_TSTAMP_APPA; } if (G_TCPOPT_SACK(tcpopt)) diff --git a/sys/dev/cxgb/ulp/tom/cxgb_listen.c b/sys/dev/cxgb/ulp/tom/cxgb_listen.c index 933a83c..b7d69df 100644 --- a/sys/dev/cxgb/ulp/tom/cxgb_listen.c +++ b/sys/dev/cxgb/ulp/tom/cxgb_listen.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include <net/route.h> #include <netinet/in.h> #include <netinet/ip.h> +#include <netinet/in_fib.h> #include <netinet/in_pcb.h> #include <netinet/in_var.h> #include <netinet/tcp_timer.h> @@ -480,8 +481,8 @@ do_pass_accept_req(struct sge_qset *qs, struct rsp_desc *r, struct mbuf *m) unsigned int tid = GET_TID(req); struct listen_ctx *lctx = lookup_stid(&td->tid_maps, stid); struct l2t_entry *e = NULL; + struct nhop4_basic nh4; struct sockaddr_in nam; - struct rtentry *rt; struct inpcb *inp; struct socket *so; struct port_info *pi; @@ -525,18 +526,12 @@ do_pass_accept_req(struct sge_qset *qs, struct rsp_desc *r, struct mbuf *m) nam.sin_len = sizeof(nam); nam.sin_family = AF_INET; nam.sin_addr = inc.inc_faddr; - rt = rtalloc1((struct sockaddr *)&nam, 0, 0); - if (rt == NULL) + if (fib4_lookup_nh_basic(RT_DEFAULT_FIB, nam.sin_addr, 0, 0, &nh4) != 0) REJECT_PASS_ACCEPT(); else { - struct sockaddr *nexthop; - - RT_UNLOCK(rt); - nexthop = rt->rt_flags & RTF_GATEWAY ? rt->rt_gateway : - (struct sockaddr *)&nam; - if (rt->rt_ifp == ifp) - e = t3_l2t_get(pi, rt->rt_ifp, nexthop); - RTFREE(rt); + nam.sin_addr = nh4.nh_addr; + if (nh4.nh_ifp == ifp) + e = t3_l2t_get(pi, ifp, (struct sockaddr *)&nam); if (e == NULL) REJECT_PASS_ACCEPT(); /* no l2te, or ifp mismatch */ } diff --git a/sys/dev/cxgbe/iw_cxgbe/cm.c b/sys/dev/cxgbe/iw_cxgbe/cm.c index b5dede7..8af7df5 100644 --- a/sys/dev/cxgbe/iw_cxgbe/cm.c +++ b/sys/dev/cxgbe/iw_cxgbe/cm.c @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include <netinet/in_systm.h> #include <netinet/in_pcb.h> #include <netinet/ip.h> +#include <netinet/in_fib.h> #include <netinet/ip_var.h> #include <netinet/tcp_var.h> #include <netinet/tcp.h> @@ -86,8 +87,8 @@ static void __state_set(struct c4iw_ep_common *epc, enum c4iw_ep_state tostate); static void state_set(struct c4iw_ep_common *epc, enum c4iw_ep_state tostate); static void *alloc_ep(int size, gfp_t flags); void __free_ep(struct c4iw_ep_common *epc); -static struct rtentry * find_route(__be32 local_ip, __be32 peer_ip, __be16 local_port, - __be16 peer_port, u8 tos); +static int find_route(__be32 local_ip, __be32 peer_ip, __be16 local_port, + __be16 peer_port, u8 tos, struct nhop4_extended *pnh4); static int close_socket(struct c4iw_ep_common *epc, int close); static int shutdown_socket(struct c4iw_ep_common *epc); static void abort_socket(struct c4iw_ep *ep); @@ -201,23 +202,21 @@ done: } -static struct rtentry * +static int find_route(__be32 local_ip, __be32 peer_ip, __be16 local_port, - __be16 peer_port, u8 tos) + __be16 peer_port, u8 tos, struct nhop4_extended *pnh4) { - struct route iproute; - struct sockaddr_in *dst = (struct sockaddr_in *)&iproute.ro_dst; + struct in_addr addr; + int err; CTR5(KTR_IW_CXGBE, "%s:frtB %x, %x, %d, %d", __func__, local_ip, peer_ip, ntohs(local_port), ntohs(peer_port)); - bzero(&iproute, sizeof iproute); - dst->sin_family = AF_INET; - dst->sin_len = sizeof *dst; - dst->sin_addr.s_addr = peer_ip; - - rtalloc(&iproute); - CTR2(KTR_IW_CXGBE, "%s:frtE %p", __func__, (uint64_t)iproute.ro_rt); - return iproute.ro_rt; + + addr.s_addr = peer_ip; + err = fib4_lookup_nh_ext(RT_DEFAULT_FIB, addr, NHR_REF, 0, pnh4); + + CTR2(KTR_IW_CXGBE, "%s:frtE %d", __func__, err); + return err; } static int @@ -474,7 +473,7 @@ process_conn_error(struct c4iw_ep *ep) if (state != ABORTING) { CTR2(KTR_IW_CXGBE, "%s:pce1 %p", __func__, ep); - close_socket(&ep->com, 1); + close_socket(&ep->com, 0); state_set(&ep->com, DEAD); c4iw_put_ep(&ep->com); } @@ -2012,7 +2011,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) int err = 0; struct c4iw_dev *dev = to_c4iw_dev(cm_id->device); struct c4iw_ep *ep = NULL; - struct rtentry *rt; + struct nhop4_extended nh4; struct toedev *tdev; CTR2(KTR_IW_CXGBE, "%s:ccB %p", __func__, cm_id); @@ -2068,13 +2067,13 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) init_sock(&ep->com); /* find a route */ - rt = find_route( + err = find_route( cm_id->local_addr.sin_addr.s_addr, cm_id->remote_addr.sin_addr.s_addr, cm_id->local_addr.sin_port, - cm_id->remote_addr.sin_port, 0); + cm_id->remote_addr.sin_port, 0, &nh4); - if (!rt) { + if (err) { CTR2(KTR_IW_CXGBE, "%s:cc7 %p", __func__, ep); printk(KERN_ERR MOD "%s - cannot find route.\n", __func__); @@ -2082,7 +2081,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) goto fail2; } - if (!(rt->rt_ifp->if_capenable & IFCAP_TOE)) { + if (!(nh4.nh_ifp->if_capenable & IFCAP_TOE)) { CTR2(KTR_IW_CXGBE, "%s:cc8 %p", __func__, ep); printf("%s - interface not TOE capable.\n", __func__); @@ -2090,7 +2089,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) err = -ENOPROTOOPT; goto fail3; } - tdev = TOEDEV(rt->rt_ifp); + tdev = TOEDEV(nh4.nh_ifp); if (tdev == NULL) { @@ -2098,7 +2097,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) printf("%s - No toedev for interface.\n", __func__); goto fail3; } - RTFREE(rt); + fib4_free_nh_ext(RT_DEFAULT_FIB, &nh4); state_set(&ep->com, CONNECTING); ep->tos = 0; @@ -2117,7 +2116,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) fail3: CTR2(KTR_IW_CXGBE, "%s:ccb %p", __func__, ep); - RTFREE(rt); + fib4_free_nh_ext(RT_DEFAULT_FIB, &nh4); fail2: cm_id->rem_ref(cm_id); c4iw_put_ep(&ep->com); diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 0d00a77..21d0cb8 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -3642,6 +3642,9 @@ setup_intr_handlers(struct adapter *sc) #ifdef DEV_NETMAP struct sge_nm_rxq *nm_rxq; #endif +#ifdef RSS + int nbuckets = rss_getnumbuckets(); +#endif /* * Setup interrupts. @@ -3700,6 +3703,10 @@ setup_intr_handlers(struct adapter *sc) t4_intr, rxq, s); if (rc != 0) return (rc); +#ifdef RSS + bus_bind_intr(sc->dev, irq->res, + rss_getcpu(q % nbuckets)); +#endif irq++; rid++; vi->nintr++; diff --git a/sys/dev/cxgbe/tom/t4_cpl_io.c b/sys/dev/cxgbe/tom/t4_cpl_io.c index d58592e..f18f115 100644 --- a/sys/dev/cxgbe/tom/t4_cpl_io.c +++ b/sys/dev/cxgbe/tom/t4_cpl_io.c @@ -221,7 +221,7 @@ assign_rxopt(struct tcpcb *tp, unsigned int opt) n = sizeof(struct ip6_hdr) + sizeof(struct tcphdr); else n = sizeof(struct ip) + sizeof(struct tcphdr); - tp->t_maxseg = tp->t_maxopd = sc->params.mtus[G_TCPOPT_MSS(opt)] - n; + tp->t_maxseg = sc->params.mtus[G_TCPOPT_MSS(opt)] - n; CTR4(KTR_CXGBE, "%s: tid %d, mtu_idx %u (%u)", __func__, toep->tid, G_TCPOPT_MSS(opt), sc->params.mtus[G_TCPOPT_MSS(opt)]); @@ -230,7 +230,6 @@ assign_rxopt(struct tcpcb *tp, unsigned int opt) tp->t_flags |= TF_RCVD_TSTMP; /* timestamps ok */ tp->ts_recent = 0; /* hmmm */ tp->ts_recent_age = tcp_ts_getticks(); - tp->t_maxseg -= TCPOLEN_TSTAMP_APPA; } if (G_TCPOPT_SACK(opt)) diff --git a/sys/dev/cxgbe/tom/t4_listen.c b/sys/dev/cxgbe/tom/t4_listen.c index 187a9f8..5af9260 100644 --- a/sys/dev/cxgbe/tom/t4_listen.c +++ b/sys/dev/cxgbe/tom/t4_listen.c @@ -49,9 +49,11 @@ __FBSDID("$FreeBSD$"); #include <net/if_vlan_var.h> #include <net/route.h> #include <netinet/in.h> +#include <netinet/in_fib.h> #include <netinet/in_pcb.h> #include <netinet/ip.h> #include <netinet/ip6.h> +#include <netinet6/in6_fib.h> #include <netinet6/scope6_var.h> #include <netinet/tcp_timer.h> #include <netinet/tcp_var.h> @@ -1095,46 +1097,44 @@ static struct l2t_entry * get_l2te_for_nexthop(struct port_info *pi, struct ifnet *ifp, struct in_conninfo *inc) { - struct rtentry *rt; struct l2t_entry *e; struct sockaddr_in6 sin6; struct sockaddr *dst = (void *)&sin6; if (inc->inc_flags & INC_ISIPV6) { + struct nhop6_basic nh6; + + bzero(dst, sizeof(struct sockaddr_in6)); dst->sa_len = sizeof(struct sockaddr_in6); dst->sa_family = AF_INET6; - ((struct sockaddr_in6 *)dst)->sin6_addr = inc->inc6_faddr; if (IN6_IS_ADDR_LINKLOCAL(&inc->inc6_laddr)) { /* no need for route lookup */ e = t4_l2t_get(pi, ifp, dst); return (e); } + + if (fib6_lookup_nh_basic(RT_DEFAULT_FIB, &inc->inc6_faddr, + 0, 0, 0, &nh6) != 0) + return (NULL); + if (nh6.nh_ifp != ifp) + return (NULL); + ((struct sockaddr_in6 *)dst)->sin6_addr = nh6.nh_addr; } else { + struct nhop4_basic nh4; + dst->sa_len = sizeof(struct sockaddr_in); dst->sa_family = AF_INET; - ((struct sockaddr_in *)dst)->sin_addr = inc->inc_faddr; - } - rt = rtalloc1(dst, 0, 0); - if (rt == NULL) - return (NULL); - else { - struct sockaddr *nexthop; - - RT_UNLOCK(rt); - if (rt->rt_ifp != ifp) - e = NULL; - else { - if (rt->rt_flags & RTF_GATEWAY) - nexthop = rt->rt_gateway; - else - nexthop = dst; - e = t4_l2t_get(pi, ifp, nexthop); - } - RTFREE(rt); + if (fib4_lookup_nh_basic(RT_DEFAULT_FIB, inc->inc_faddr, 0, 0, + &nh4) != 0) + return (NULL); + if (nh4.nh_ifp != ifp) + return (NULL); + ((struct sockaddr_in *)dst)->sin_addr = nh4.nh_addr; } + e = t4_l2t_get(pi, ifp, dst); return (e); } diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index d9b3ca5..f586d39 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -260,7 +260,9 @@ static bool em_rxeof(struct rx_ring *, int, int *); #ifndef __NO_STRICT_ALIGNMENT static int em_fixup_rx(struct rx_ring *); #endif -static void em_receive_checksum(struct e1000_rx_desc *, struct mbuf *); +static void em_setup_rxdesc(union e1000_rx_desc_extended *, + const struct em_rxbuffer *rxbuf); +static void em_receive_checksum(uint32_t status, struct mbuf *); static void em_transmit_checksum_setup(struct tx_ring *, struct mbuf *, int, struct ip *, u32 *, u32 *); static void em_tso_setup(struct tx_ring *, struct mbuf *, int, struct ip *, @@ -631,7 +633,7 @@ em_attach(device_t dev) } else adapter->num_tx_desc = em_txd; - if (((em_rxd * sizeof(struct e1000_rx_desc)) % EM_DBA_ALIGN) != 0 || + if (((em_rxd * sizeof(union e1000_rx_desc_extended)) % EM_DBA_ALIGN) != 0 || (em_rxd > EM_MAX_RXD) || (em_rxd < EM_MIN_RXD)) { device_printf(dev, "Using %d RX descriptors instead of %d!\n", EM_DEFAULT_RXD, em_rxd); @@ -1872,7 +1874,7 @@ em_xmit(struct tx_ring *txr, struct mbuf **m_headp) struct adapter *adapter = txr->adapter; bus_dma_segment_t segs[EM_MAX_SCATTER]; bus_dmamap_t map; - struct em_buffer *tx_buffer, *tx_buffer_mapped; + struct em_txbuffer *tx_buffer, *tx_buffer_mapped; struct e1000_tx_desc *ctxd = NULL; struct mbuf *m_head; struct ether_header *eh; @@ -3296,7 +3298,7 @@ em_allocate_queues(struct adapter *adapter) * Next the RX queues... */ rsize = roundup2(adapter->num_rx_desc * - sizeof(struct e1000_rx_desc), EM_DBA_ALIGN); + sizeof(union e1000_rx_desc_extended), EM_DBA_ALIGN); for (int i = 0; i < adapter->num_queues; i++, rxconf++) { rxr = &adapter->rx_rings[i]; rxr->adapter = adapter; @@ -3314,7 +3316,7 @@ em_allocate_queues(struct adapter *adapter) error = ENOMEM; goto err_rx_desc; } - rxr->rx_base = (struct e1000_rx_desc *)rxr->rxdma.dma_vaddr; + rxr->rx_base = (union e1000_rx_desc_extended *)rxr->rxdma.dma_vaddr; bzero((void *)rxr->rx_base, rsize); /* Allocate receive buffers for the ring*/ @@ -3357,7 +3359,7 @@ em_allocate_transmit_buffers(struct tx_ring *txr) { struct adapter *adapter = txr->adapter; device_t dev = adapter->dev; - struct em_buffer *txbuf; + struct em_txbuffer *txbuf; int error, i; /* @@ -3380,7 +3382,7 @@ em_allocate_transmit_buffers(struct tx_ring *txr) } if (!(txr->tx_buffers = - (struct em_buffer *) malloc(sizeof(struct em_buffer) * + (struct em_txbuffer *) malloc(sizeof(struct em_txbuffer) * adapter->num_tx_desc, M_DEVBUF, M_NOWAIT | M_ZERO))) { device_printf(dev, "Unable to allocate tx_buffer memory\n"); error = ENOMEM; @@ -3413,7 +3415,7 @@ static void em_setup_transmit_ring(struct tx_ring *txr) { struct adapter *adapter = txr->adapter; - struct em_buffer *txbuf; + struct em_txbuffer *txbuf; int i; #ifdef DEV_NETMAP struct netmap_slot *slot; @@ -3632,7 +3634,7 @@ static void em_free_transmit_buffers(struct tx_ring *txr) { struct adapter *adapter = txr->adapter; - struct em_buffer *txbuf; + struct em_txbuffer *txbuf; INIT_DEBUGOUT("free_transmit_ring: begin"); @@ -3699,7 +3701,7 @@ em_transmit_checksum_setup(struct tx_ring *txr, struct mbuf *mp, int ip_off, { struct adapter *adapter = txr->adapter; struct e1000_context_desc *TXD = NULL; - struct em_buffer *tx_buffer; + struct em_txbuffer *tx_buffer; int cur, hdr_len; u32 cmd = 0; u16 offload = 0; @@ -3733,29 +3735,38 @@ em_transmit_checksum_setup(struct tx_ring *txr, struct mbuf *mp, int ip_off, offload |= CSUM_TCP; tucss = hdr_len; tucso = hdr_len + offsetof(struct tcphdr, th_sum); - /* - * Setting up new checksum offload context for every frames - * takes a lot of processing time for hardware. This also - * reduces performance a lot for small sized frames so avoid - * it if driver can use previously configured checksum - * offload context. - */ - if (txr->last_hw_offload == offload) { - if (offload & CSUM_IP) { - if (txr->last_hw_ipcss == ipcss && - txr->last_hw_ipcso == ipcso && - txr->last_hw_tucss == tucss && - txr->last_hw_tucso == tucso) - return; - } else { - if (txr->last_hw_tucss == tucss && - txr->last_hw_tucso == tucso) - return; - } - } - txr->last_hw_offload = offload; - txr->last_hw_tucss = tucss; - txr->last_hw_tucso = tucso; + /* + * The 82574L can only remember the *last* context used + * regardless of queue that it was use for. We cannot reuse + * contexts on this hardware platform and must generate a new + * context every time. 82574L hardware spec, section 7.2.6, + * second note. + */ + if (adapter->num_queues < 2) { + /* + * Setting up new checksum offload context for every + * frames takes a lot of processing time for hardware. + * This also reduces performance a lot for small sized + * frames so avoid it if driver can use previously + * configured checksum offload context. + */ + if (txr->last_hw_offload == offload) { + if (offload & CSUM_IP) { + if (txr->last_hw_ipcss == ipcss && + txr->last_hw_ipcso == ipcso && + txr->last_hw_tucss == tucss && + txr->last_hw_tucso == tucso) + return; + } else { + if (txr->last_hw_tucss == tucss && + txr->last_hw_tucso == tucso) + return; + } + } + txr->last_hw_offload = offload; + txr->last_hw_tucss = tucss; + txr->last_hw_tucso = tucso; + } /* * Start offset for payload checksum calculation. * End offset for payload checksum calculation. @@ -3771,29 +3782,38 @@ em_transmit_checksum_setup(struct tx_ring *txr, struct mbuf *mp, int ip_off, *txd_upper |= E1000_TXD_POPTS_TXSM << 8; tucss = hdr_len; tucso = hdr_len + offsetof(struct udphdr, uh_sum); - /* - * Setting up new checksum offload context for every frames - * takes a lot of processing time for hardware. This also - * reduces performance a lot for small sized frames so avoid - * it if driver can use previously configured checksum - * offload context. - */ - if (txr->last_hw_offload == offload) { - if (offload & CSUM_IP) { - if (txr->last_hw_ipcss == ipcss && - txr->last_hw_ipcso == ipcso && - txr->last_hw_tucss == tucss && - txr->last_hw_tucso == tucso) - return; - } else { - if (txr->last_hw_tucss == tucss && - txr->last_hw_tucso == tucso) - return; + /* + * The 82574L can only remember the *last* context used + * regardless of queue that it was use for. We cannot reuse + * contexts on this hardware platform and must generate a new + * context every time. 82574L hardware spec, section 7.2.6, + * second note. + */ + if (adapter->num_queues < 2) { + /* + * Setting up new checksum offload context for every + * frames takes a lot of processing time for hardware. + * This also reduces performance a lot for small sized + * frames so avoid it if driver can use previously + * configured checksum offload context. + */ + if (txr->last_hw_offload == offload) { + if (offload & CSUM_IP) { + if (txr->last_hw_ipcss == ipcss && + txr->last_hw_ipcso == ipcso && + txr->last_hw_tucss == tucss && + txr->last_hw_tucso == tucso) + return; + } else { + if (txr->last_hw_tucss == tucss && + txr->last_hw_tucso == tucso) + return; + } } - } - txr->last_hw_offload = offload; - txr->last_hw_tucss = tucss; - txr->last_hw_tucso = tucso; + txr->last_hw_offload = offload; + txr->last_hw_tucss = tucss; + txr->last_hw_tucso = tucso; + } /* * Start offset for header checksum calculation. * End offset for header checksum calculation. @@ -3836,7 +3856,7 @@ em_tso_setup(struct tx_ring *txr, struct mbuf *mp, int ip_off, { struct adapter *adapter = txr->adapter; struct e1000_context_desc *TXD; - struct em_buffer *tx_buffer; + struct em_txbuffer *tx_buffer; int cur, hdr_len; /* @@ -3914,7 +3934,7 @@ em_txeof(struct tx_ring *txr) { struct adapter *adapter = txr->adapter; int first, last, done, processed; - struct em_buffer *tx_buffer; + struct em_txbuffer *tx_buffer; struct e1000_tx_desc *tx_desc, *eop_desc; if_t ifp = adapter->ifp; @@ -4020,7 +4040,6 @@ em_txeof(struct tx_ring *txr) txr->busy = EM_TX_IDLE; } - /********************************************************************* * * Refresh RX descriptor mbufs from system mbuf buffer pool. @@ -4031,8 +4050,8 @@ em_refresh_mbufs(struct rx_ring *rxr, int limit) { struct adapter *adapter = rxr->adapter; struct mbuf *m; - bus_dma_segment_t segs[1]; - struct em_buffer *rxbuf; + bus_dma_segment_t segs; + struct em_rxbuffer *rxbuf; int i, j, error, nsegs; bool cleaned = FALSE; @@ -4067,7 +4086,7 @@ em_refresh_mbufs(struct rx_ring *rxr, int limit) /* Use bus_dma machinery to setup the memory mapping */ error = bus_dmamap_load_mbuf_sg(rxr->rxtag, rxbuf->map, - m, segs, &nsegs, BUS_DMA_NOWAIT); + m, &segs, &nsegs, BUS_DMA_NOWAIT); if (error != 0) { printf("Refresh mbufs: hdr dmamap load" " failure - %d\n", error); @@ -4076,9 +4095,10 @@ em_refresh_mbufs(struct rx_ring *rxr, int limit) goto update; } rxbuf->m_head = m; + rxbuf->paddr = segs.ds_addr; bus_dmamap_sync(rxr->rxtag, rxbuf->map, BUS_DMASYNC_PREREAD); - rxr->rx_base[i].buffer_addr = htole64(segs[0].ds_addr); + em_setup_rxdesc(&rxr->rx_base[i], rxbuf); cleaned = TRUE; i = j; /* Next is precalulated for us */ @@ -4113,10 +4133,10 @@ em_allocate_receive_buffers(struct rx_ring *rxr) { struct adapter *adapter = rxr->adapter; device_t dev = adapter->dev; - struct em_buffer *rxbuf; + struct em_rxbuffer *rxbuf; int error; - rxr->rx_buffers = malloc(sizeof(struct em_buffer) * + rxr->rx_buffers = malloc(sizeof(struct em_rxbuffer) * adapter->num_rx_desc, M_DEVBUF, M_NOWAIT | M_ZERO); if (rxr->rx_buffers == NULL) { device_printf(dev, "Unable to allocate rx_buffer memory\n"); @@ -4169,7 +4189,7 @@ static int em_setup_receive_ring(struct rx_ring *rxr) { struct adapter *adapter = rxr->adapter; - struct em_buffer *rxbuf; + struct em_rxbuffer *rxbuf; bus_dma_segment_t seg[1]; int rsize, nsegs, error = 0; #ifdef DEV_NETMAP @@ -4181,7 +4201,7 @@ em_setup_receive_ring(struct rx_ring *rxr) /* Clear the ring contents */ EM_RX_LOCK(rxr); rsize = roundup2(adapter->num_rx_desc * - sizeof(struct e1000_rx_desc), EM_DBA_ALIGN); + sizeof(union e1000_rx_desc_extended), EM_DBA_ALIGN); bzero((void *)rxr->rx_base, rsize); #ifdef DEV_NETMAP slot = netmap_reset(na, NR_RX, rxr->me, 0); @@ -4212,8 +4232,7 @@ em_setup_receive_ring(struct rx_ring *rxr) addr = PNMB(na, slot + si, &paddr); netmap_load_map(na, rxr->rxtag, rxbuf->map, addr); - /* Update descriptor */ - rxr->rx_base[j].buffer_addr = htole64(paddr); + em_setup_rxdesc(&rxr->rx_base[j], rxbuf); continue; } #endif /* DEV_NETMAP */ @@ -4239,8 +4258,8 @@ em_setup_receive_ring(struct rx_ring *rxr) bus_dmamap_sync(rxr->rxtag, rxbuf->map, BUS_DMASYNC_PREREAD); - /* Update descriptor */ - rxr->rx_base[j].buffer_addr = htole64(seg[0].ds_addr); + rxbuf->paddr = seg[0].ds_addr; + em_setup_rxdesc(&rxr->rx_base[j], rxbuf); } rxr->next_to_check = 0; rxr->next_to_refresh = 0; @@ -4277,7 +4296,7 @@ fail: for (int i = 0; i < q; ++i) { rxr = &adapter->rx_rings[i]; for (int n = 0; n < adapter->num_rx_desc; n++) { - struct em_buffer *rxbuf; + struct em_rxbuffer *rxbuf; rxbuf = &rxr->rx_buffers[n]; if (rxbuf->m_head != NULL) { bus_dmamap_sync(rxr->rxtag, rxbuf->map, @@ -4324,7 +4343,7 @@ static void em_free_receive_buffers(struct rx_ring *rxr) { struct adapter *adapter = rxr->adapter; - struct em_buffer *rxbuf = NULL; + struct em_rxbuffer *rxbuf = NULL; INIT_DEBUGOUT("free_receive_buffers: begin"); @@ -4366,11 +4385,10 @@ em_free_receive_buffers(struct rx_ring *rxr) static void em_initialize_receive_unit(struct adapter *adapter) { - struct rx_ring *rxr = adapter->rx_rings; + struct rx_ring *rxr = adapter->rx_rings; if_t ifp = adapter->ifp; struct e1000_hw *hw = &adapter->hw; - u64 bus_addr; - u32 rctl, rxcsum; + u32 rctl, rxcsum, rfctl; INIT_DEBUGOUT("em_initialize_receive_units: begin"); @@ -4383,6 +4401,25 @@ em_initialize_receive_unit(struct adapter *adapter) if ((hw->mac.type != e1000_82574) && (hw->mac.type != e1000_82583)) E1000_WRITE_REG(hw, E1000_RCTL, rctl & ~E1000_RCTL_EN); + /* Setup the Receive Control Register */ + rctl &= ~(3 << E1000_RCTL_MO_SHIFT); + rctl |= E1000_RCTL_EN | E1000_RCTL_BAM | + E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF | + (hw->mac.mc_filter_type << E1000_RCTL_MO_SHIFT); + + /* Do not store bad packets */ + rctl &= ~E1000_RCTL_SBP; + + /* Enable Long Packet receive */ + if (if_getmtu(ifp) > ETHERMTU) + rctl |= E1000_RCTL_LPE; + else + rctl &= ~E1000_RCTL_LPE; + + /* Strip the CRC */ + if (!em_disable_crc_stripping) + rctl |= E1000_RCTL_SECRC; + E1000_WRITE_REG(&adapter->hw, E1000_RADV, adapter->rx_abs_int_delay.value); @@ -4394,20 +4431,21 @@ em_initialize_receive_unit(struct adapter *adapter) */ E1000_WRITE_REG(hw, E1000_ITR, DEFAULT_ITR); + /* Use extended rx descriptor formats */ + rfctl = E1000_READ_REG(hw, E1000_RFCTL); + rfctl |= E1000_RFCTL_EXTEN; /* ** When using MSIX interrupts we need to throttle ** using the EITR register (82574 only) */ if (hw->mac.type == e1000_82574) { - u32 rfctl; for (int i = 0; i < 4; i++) E1000_WRITE_REG(hw, E1000_EITR_82574(i), DEFAULT_ITR); /* Disable accelerated acknowledge */ - rfctl = E1000_READ_REG(hw, E1000_RFCTL); rfctl |= E1000_RFCTL_ACK_DIS; - E1000_WRITE_REG(hw, E1000_RFCTL, rfctl); } + E1000_WRITE_REG(hw, E1000_RFCTL, rfctl); rxcsum = E1000_READ_REG(hw, E1000_RXCSUM); if (if_getcapenable(ifp) & IFCAP_RXCSUM) { @@ -4424,38 +4462,44 @@ em_initialize_receive_unit(struct adapter *adapter) E1000_WRITE_REG(hw, E1000_RXCSUM, rxcsum); #ifdef EM_MULTIQUEUE +#define RSSKEYLEN 10 if (adapter->num_queues > 1) { - uint32_t rss_key[10]; - uint32_t reta; + uint8_t rss_key[4 * RSSKEYLEN]; + uint32_t reta = 0; int i; /* * Configure RSS key */ arc4rand(rss_key, sizeof(rss_key), 0); - for (i = 0; i < 10; ++i) - E1000_WRITE_REG_ARRAY(hw,E1000_RSSRK(0), i, rss_key[i]); + for (i = 0; i < RSSKEYLEN; ++i) { + uint32_t rssrk = 0; + + rssrk = EM_RSSRK_VAL(rss_key, i); + E1000_WRITE_REG(hw,E1000_RSSRK(i), rssrk); + } /* * Configure RSS redirect table in following fashion: * (hash & ring_cnt_mask) == rdr_table[(hash & rdr_table_mask)] */ - reta = 0; - for (i = 0; i < 4; ++i) { + for (i = 0; i < sizeof(reta); ++i) { uint32_t q; + q = (i % adapter->num_queues) << 7; reta |= q << (8 * i); } - for (i = 0; i < 32; ++i) + + for (i = 0; i < 32; ++i) { E1000_WRITE_REG(hw, E1000_RETA(i), reta); + } E1000_WRITE_REG(hw, E1000_MRQC, E1000_MRQC_RSS_ENABLE_2Q | E1000_MRQC_RSS_FIELD_IPV4_TCP | E1000_MRQC_RSS_FIELD_IPV4 | E1000_MRQC_RSS_FIELD_IPV6_TCP_EX | E1000_MRQC_RSS_FIELD_IPV6_EX | - E1000_MRQC_RSS_FIELD_IPV6 | - E1000_MRQC_RSS_FIELD_IPV6_TCP); + E1000_MRQC_RSS_FIELD_IPV6); } #endif /* @@ -4470,11 +4514,11 @@ em_initialize_receive_unit(struct adapter *adapter) for (int i = 0; i < adapter->num_queues; i++, rxr++) { /* Setup the Base and Length of the Rx Descriptor Ring */ + u64 bus_addr = rxr->rxdma.dma_paddr; u32 rdt = adapter->num_rx_desc - 1; /* default */ - bus_addr = rxr->rxdma.dma_paddr; E1000_WRITE_REG(hw, E1000_RDLEN(i), - adapter->num_rx_desc * sizeof(struct e1000_rx_desc)); + adapter->num_rx_desc * sizeof(union e1000_rx_desc_extended)); E1000_WRITE_REG(hw, E1000_RDBAH(i), (u32)(bus_addr >> 32)); E1000_WRITE_REG(hw, E1000_RDBAL(i), (u32)bus_addr); /* Setup the Head and Tail Descriptor Pointers */ @@ -4505,14 +4549,13 @@ em_initialize_receive_unit(struct adapter *adapter) (if_getmtu(ifp) > ETHERMTU)) { u32 rxdctl = E1000_READ_REG(hw, E1000_RXDCTL(0)); E1000_WRITE_REG(hw, E1000_RXDCTL(0), rxdctl | 3); - } else if ((adapter->hw.mac.type == e1000_82574) && - (if_getmtu(ifp) > ETHERMTU)) { + } else if (adapter->hw.mac.type == e1000_82574) { for (int i = 0; i < adapter->num_queues; i++) { u32 rxdctl = E1000_READ_REG(hw, E1000_RXDCTL(i)); - rxdctl |= 0x20; /* PTHRESH */ - rxdctl |= 4 << 8; /* HTHRESH */ - rxdctl |= 4 << 16;/* WTHRESH */ + rxdctl |= 0x20; /* PTHRESH */ + rxdctl |= 4 << 8; /* HTHRESH */ + rxdctl |= 4 << 16;/* WTHRESH */ rxdctl |= 1 << 24; /* Switch to granularity */ E1000_WRITE_REG(hw, E1000_RXDCTL(i), rxdctl); } @@ -4525,19 +4568,8 @@ em_initialize_receive_unit(struct adapter *adapter) e1000_lv_jumbo_workaround_ich8lan(hw, FALSE); } - /* Setup the Receive Control Register */ - rctl &= ~(3 << E1000_RCTL_MO_SHIFT); - rctl |= E1000_RCTL_EN | E1000_RCTL_BAM | - E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF | - (hw->mac.mc_filter_type << E1000_RCTL_MO_SHIFT); - - /* Strip the CRC */ - if (!em_disable_crc_stripping) - rctl |= E1000_RCTL_SECRC; - /* Make sure VLAN Filters are off */ rctl &= ~E1000_RCTL_VFE; - rctl &= ~E1000_RCTL_SBP; if (adapter->rx_mbuf_sz == MCLBYTES) rctl |= E1000_RCTL_SZ_2048; @@ -4546,11 +4578,8 @@ em_initialize_receive_unit(struct adapter *adapter) else if (adapter->rx_mbuf_sz > MJUMPAGESIZE) rctl |= E1000_RCTL_SZ_8192 | E1000_RCTL_BSEX; - if (if_getmtu(ifp) > ETHERMTU) - rctl |= E1000_RCTL_LPE; - else - rctl &= ~E1000_RCTL_LPE; - + /* ensure we clear use DTYPE of 00 here */ + rctl &= ~0x00000C00; /* Write out the settings */ E1000_WRITE_REG(hw, E1000_RCTL, rctl); @@ -4575,11 +4604,11 @@ em_rxeof(struct rx_ring *rxr, int count, int *done) struct adapter *adapter = rxr->adapter; if_t ifp = adapter->ifp; struct mbuf *mp, *sendmp; - u8 status = 0; + u32 status = 0; u16 len; int i, processed, rxdone = 0; bool eop; - struct e1000_rx_desc *cur; + union e1000_rx_desc_extended *cur; EM_RX_LOCK(rxr); @@ -4596,21 +4625,20 @@ em_rxeof(struct rx_ring *rxr, int count, int *done) #endif /* DEV_NETMAP */ for (i = rxr->next_to_check, processed = 0; count != 0;) { - if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) break; cur = &rxr->rx_base[i]; - status = cur->status; + status = le32toh(cur->wb.upper.status_error); mp = sendmp = NULL; if ((status & E1000_RXD_STAT_DD) == 0) break; - len = le16toh(cur->length); + len = le16toh(cur->wb.upper.length); eop = (status & E1000_RXD_STAT_EOP) != 0; - if ((cur->errors & E1000_RXD_ERR_FRAME_ERR_MASK) || + if ((status & E1000_RXDEXT_ERR_FRAME_ERR_MASK) || (rxr->discard == TRUE)) { adapter->dropped_pkts++; ++rxr->rx_discarded; @@ -4647,7 +4675,7 @@ em_rxeof(struct rx_ring *rxr, int count, int *done) sendmp = rxr->fmp; if_setrcvif(sendmp, ifp); if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); - em_receive_checksum(cur, sendmp); + em_receive_checksum(status, sendmp); #ifndef __NO_STRICT_ALIGNMENT if (adapter->hw.mac.max_frame_size > (MCLBYTES - ETHER_ALIGN) && @@ -4656,7 +4684,7 @@ em_rxeof(struct rx_ring *rxr, int count, int *done) #endif if (status & E1000_RXD_STAT_VP) { if_setvtag(sendmp, - le16toh(cur->special)); + le16toh(cur->wb.upper.vlan)); sendmp->m_flags |= M_VLANTAG; } #ifndef __NO_STRICT_ALIGNMENT @@ -4670,7 +4698,7 @@ next_desc: BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); /* Zero out the receive descriptors status. */ - cur->status = 0; + cur->wb.upper.status_error &= htole32(~0xFF); ++rxdone; /* cumulative for POLL */ ++processed; @@ -4709,7 +4737,7 @@ next_desc: static __inline void em_rx_discard(struct rx_ring *rxr, int i) { - struct em_buffer *rbuf; + struct em_rxbuffer *rbuf; rbuf = &rxr->rx_buffers[i]; bus_dmamap_unload(rxr->rxtag, rbuf->map); @@ -4781,6 +4809,14 @@ em_fixup_rx(struct rx_ring *rxr) } #endif +static void +em_setup_rxdesc(union e1000_rx_desc_extended *rxd, const struct em_rxbuffer *rxbuf) +{ + rxd->read.buffer_addr = htole64(rxbuf->paddr); + /* DD bits must be cleared */ + rxd->wb.upper.status_error= 0; +} + /********************************************************************* * * Verify that the hardware indicated that the checksum is valid. @@ -4789,23 +4825,27 @@ em_fixup_rx(struct rx_ring *rxr) * *********************************************************************/ static void -em_receive_checksum(struct e1000_rx_desc *rx_desc, struct mbuf *mp) +em_receive_checksum(uint32_t status, struct mbuf *mp) { mp->m_pkthdr.csum_flags = 0; /* Ignore Checksum bit is set */ - if (rx_desc->status & E1000_RXD_STAT_IXSM) - return; - - if (rx_desc->errors & (E1000_RXD_ERR_TCPE | E1000_RXD_ERR_IPE)) + if (status & E1000_RXD_STAT_IXSM) return; - /* IP Checksum Good? */ - if (rx_desc->status & E1000_RXD_STAT_IPCS) + /* If the IP checksum exists and there is no IP Checksum error */ + if ((status & (E1000_RXD_STAT_IPCS | E1000_RXDEXT_STATERR_IPE)) == + E1000_RXD_STAT_IPCS) { mp->m_pkthdr.csum_flags = (CSUM_IP_CHECKED | CSUM_IP_VALID); + } /* TCP or UDP checksum */ - if (rx_desc->status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS)) { + if ((status & (E1000_RXD_STAT_TCPCS | E1000_RXDEXT_STATERR_TCPE)) == + E1000_RXD_STAT_TCPCS) { + mp->m_pkthdr.csum_flags |= (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); + mp->m_pkthdr.csum_data = htons(0xffff); + } + if (status & E1000_RXD_STAT_UDPCS) { mp->m_pkthdr.csum_flags |= (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); mp->m_pkthdr.csum_data = htons(0xffff); } diff --git a/sys/dev/e1000/if_em.h b/sys/dev/e1000/if_em.h index 8725de3..be9fdc9 100644 --- a/sys/dev/e1000/if_em.h +++ b/sys/dev/e1000/if_em.h @@ -330,7 +330,7 @@ struct tx_ring { struct taskqueue *tq; u32 next_avail_desc; u32 next_to_clean; - struct em_buffer *tx_buffers; + struct em_txbuffer *tx_buffers; volatile u16 tx_avail; u32 tx_tso; /* last tx was tso */ u16 last_hw_offload; @@ -362,11 +362,11 @@ struct rx_ring { u32 payload; struct task rx_task; struct taskqueue *tq; - struct e1000_rx_desc *rx_base; + union e1000_rx_desc_extended *rx_base; struct em_dma_alloc rxdma; u32 next_to_refresh; u32 next_to_check; - struct em_buffer *rx_buffers; + struct em_rxbuffer *rx_buffers; struct mbuf *fmp; struct mbuf *lmp; @@ -499,12 +499,19 @@ typedef struct _em_vendor_info_t { unsigned int index; } em_vendor_info_t; -struct em_buffer { +struct em_txbuffer { int next_eop; /* Index of the desc to watch */ struct mbuf *m_head; bus_dmamap_t map; /* bus_dma map for packet */ }; +struct em_rxbuffer { + int next_eop; /* Index of the desc to watch */ + struct mbuf *m_head; + bus_dmamap_t map; /* bus_dma map for packet */ + bus_addr_t paddr; +}; + /* ** Find the number of unrefreshed RX descriptors @@ -541,4 +548,9 @@ e1000_rx_unrefreshed(struct rx_ring *rxr) #define EM_TX_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->tx_mtx, MA_OWNED) #define EM_RX_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->rx_mtx, MA_OWNED) +#define EM_RSSRK_SIZE 4 +#define EM_RSSRK_VAL(key, i) (key[(i) * EM_RSSRK_SIZE] | \ + key[(i) * EM_RSSRK_SIZE + 1] << 8 | \ + key[(i) * EM_RSSRK_SIZE + 2] << 16 | \ + key[(i) * EM_RSSRK_SIZE + 3] << 24) #endif /* _EM_H_DEFINED_ */ diff --git a/sys/dev/hyperv/netvsc/hv_net_vsc.c b/sys/dev/hyperv/netvsc/hv_net_vsc.c index a32f1ee..99e500c 100644 --- a/sys/dev/hyperv/netvsc/hv_net_vsc.c +++ b/sys/dev/hyperv/netvsc/hv_net_vsc.c @@ -919,6 +919,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, struct hv_device *device, */ hv_nv_on_receive_completion(device, vm_xfer_page_pkt->d.transaction_id, status); + hv_rf_receive_rollup(net_dev); } /* diff --git a/sys/dev/hyperv/netvsc/hv_net_vsc.h b/sys/dev/hyperv/netvsc/hv_net_vsc.h index 0796f22..b1d1e37 100644 --- a/sys/dev/hyperv/netvsc/hv_net_vsc.h +++ b/sys/dev/hyperv/netvsc/hv_net_vsc.h @@ -44,6 +44,12 @@ #include <sys/malloc.h> #include <sys/sx.h> +#include <netinet/in.h> +#include <netinet/tcp_lro.h> + +#include <net/if.h> +#include <net/if_media.h> + #include <dev/hyperv/include/hyperv.h> MALLOC_DECLARE(M_NETVSC); @@ -983,6 +989,7 @@ typedef struct { */ typedef struct hn_softc { struct ifnet *hn_ifp; + struct ifmedia hn_media; device_t hn_dev; uint8_t hn_unit; int hn_carrier; @@ -993,6 +1000,18 @@ typedef struct hn_softc { int temp_unusable; struct hv_device *hn_dev_obj; netvsc_dev *net_dev; + + struct lro_ctrl hn_lro; + int hn_lro_hiwat; + + /* Trust tcp segments verification on host side */ + int hn_trust_hosttcp; + + u_long hn_csum_ip; + u_long hn_csum_tcp; + u_long hn_csum_trusted; + u_long hn_lro_tried; + u_long hn_small_pkts; } hn_softc_t; diff --git a/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c index 2f2b07b..68f822a 100644 --- a/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c +++ b/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c @@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$"); #include <sys/queue.h> #include <sys/lock.h> #include <sys/sx.h> +#include <sys/sysctl.h> #include <net/if.h> #include <net/if_arp.h> @@ -138,13 +139,14 @@ __FBSDID("$FreeBSD$"); CSUM_IP_ISCSI|CSUM_IP6_UDP|CSUM_IP6_TCP|CSUM_IP6_SCTP| \ CSUM_IP6_TSO|CSUM_IP6_ISCSI) -/* - * Data types - */ - -struct hv_netvsc_driver_context { - uint32_t drv_inited; -}; +/* XXX move to netinet/tcp_lro.h */ +#define HN_LRO_HIWAT_MAX 65535 +#define HN_LRO_HIWAT_DEF HN_LRO_HIWAT_MAX +/* YYY 2*MTU is a bit rough, but should be good enough. */ +#define HN_LRO_HIWAT_MTULIM(ifp) (2 * (ifp)->if_mtu) +#define HN_LRO_HIWAT_ISVALID(sc, hiwat) \ + ((hiwat) >= HN_LRO_HIWAT_MTULIM((sc)->hn_ifp) || \ + (hiwat) <= HN_LRO_HIWAT_MAX) /* * Be aware that this sleepable mutex will exhibit WITNESS errors when @@ -168,9 +170,9 @@ struct hv_netvsc_driver_context { int hv_promisc_mode = 0; /* normal mode by default */ -/* The one and only one */ -static struct hv_netvsc_driver_context g_netvsc_drv; - +/* Trust tcp segements verification on host side. */ +static int hn_trust_hosttcp = 0; +TUNABLE_INT("dev.hn.trust_hosttcp", &hn_trust_hosttcp); /* * Forward declarations @@ -181,6 +183,21 @@ static void hn_ifinit(void *xsc); static int hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data); static int hn_start_locked(struct ifnet *ifp); static void hn_start(struct ifnet *ifp); +static int hn_ifmedia_upd(struct ifnet *ifp); +static void hn_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr); +#ifdef HN_LRO_HIWAT +static int hn_lro_hiwat_sysctl(SYSCTL_HANDLER_ARGS); +#endif +static int hn_check_iplen(const struct mbuf *, int); + +static __inline void +hn_set_lro_hiwat(struct hn_softc *sc, int hiwat) +{ + sc->hn_lro_hiwat = hiwat; +#ifdef HN_LRO_HIWAT + sc->hn_lro.lro_hiwat = sc->hn_lro_hiwat; +#endif +} /* * NetVsc get message transport protocol type @@ -238,35 +255,27 @@ static uint32_t get_transport_proto_type(struct mbuf *m_head) return (ret_val); } -/* - * NetVsc driver initialization - * Note: Filter init is no longer required - */ static int -netvsc_drv_init(void) +hn_ifmedia_upd(struct ifnet *ifp __unused) { - return (0); + + return EOPNOTSUPP; } -/* - * NetVsc global initialization entry point - */ static void -netvsc_init(void) +hn_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) { - if (bootverbose) - printf("Netvsc initializing... "); + struct hn_softc *sc = ifp->if_softc; - /* - * XXXKYS: cleanup initialization - */ - if (!cold && !g_netvsc_drv.drv_inited) { - g_netvsc_drv.drv_inited = 1; - netvsc_drv_init(); - if (bootverbose) - printf("done!\n"); - } else if (bootverbose) - printf("Already initialized!\n"); + ifmr->ifm_status = IFM_AVALID; + ifmr->ifm_active = IFM_ETHER; + + if (!sc->hn_carrier) { + ifmr->ifm_active |= IFM_NONE; + return; + } + ifmr->ifm_status |= IFM_ACTIVE; + ifmr->ifm_active |= IFM_10G_T | IFM_FDX; } /* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */ @@ -310,10 +319,10 @@ netvsc_attach(device_t dev) hn_softc_t *sc; int unit = device_get_unit(dev); struct ifnet *ifp; + struct sysctl_oid_list *child; + struct sysctl_ctx_list *ctx; int ret; - netvsc_init(); - sc = device_get_softc(dev); if (sc == NULL) { return (ENOMEM); @@ -322,6 +331,8 @@ netvsc_attach(device_t dev) bzero(sc, sizeof(hn_softc_t)); sc->hn_unit = unit; sc->hn_dev = dev; + sc->hn_lro_hiwat = HN_LRO_HIWAT_DEF; + sc->hn_trust_hosttcp = hn_trust_hosttcp; NV_LOCK_INIT(sc, "NetVSCLock"); @@ -344,14 +355,22 @@ netvsc_attach(device_t dev) ifp->if_snd.ifq_drv_maxlen = 511; IFQ_SET_READY(&ifp->if_snd); + ifmedia_init(&sc->hn_media, 0, hn_ifmedia_upd, hn_ifmedia_sts); + ifmedia_add(&sc->hn_media, IFM_ETHER | IFM_AUTO, 0, NULL); + ifmedia_set(&sc->hn_media, IFM_ETHER | IFM_AUTO); + /* XXX ifmedia_set really should do this for us */ + sc->hn_media.ifm_media = sc->hn_media.ifm_cur->ifm_media; + /* * Tell upper layers that we support full VLAN capability. */ ifp->if_hdrlen = sizeof(struct ether_vlan_header); ifp->if_capabilities |= - IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_TSO; + IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_TSO | + IFCAP_LRO; ifp->if_capenable |= - IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_TSO; + IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_TSO | + IFCAP_LRO; /* * Only enable UDP checksum offloading when it is on 2012R2 or * later. UDP checksum offloading doesn't work on earlier @@ -372,8 +391,61 @@ netvsc_attach(device_t dev) sc->hn_carrier = 1; } + tcp_lro_init(&sc->hn_lro); + /* Driver private LRO settings */ + sc->hn_lro.ifp = ifp; +#ifdef HN_LRO_HIWAT + sc->hn_lro.lro_hiwat = sc->hn_lro_hiwat; +#endif + ether_ifattach(ifp, device_info.mac_addr); + ctx = device_get_sysctl_ctx(dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); + + SYSCTL_ADD_INT(ctx, child, OID_AUTO, "lro_queued", + CTLFLAG_RW, &sc->hn_lro.lro_queued, 0, "LRO queued"); + SYSCTL_ADD_INT(ctx, child, OID_AUTO, "lro_flushed", + CTLFLAG_RW, &sc->hn_lro.lro_flushed, 0, "LRO flushed"); + SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "lro_tried", + CTLFLAG_RW, &sc->hn_lro_tried, "# of LRO tries"); +#ifdef HN_LRO_HIWAT + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_hiwat", + CTLTYPE_INT | CTLFLAG_RW, sc, 0, hn_lro_hiwat_sysctl, + "I", "LRO high watermark"); +#endif + SYSCTL_ADD_INT(ctx, child, OID_AUTO, "trust_hosttcp", + CTLFLAG_RW, &sc->hn_trust_hosttcp, 0, + "Trust tcp segement verification on host side, " + "when csum info is missing"); + SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "csum_ip", + CTLFLAG_RW, &sc->hn_csum_ip, "RXCSUM IP"); + SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "csum_tcp", + CTLFLAG_RW, &sc->hn_csum_tcp, "RXCSUM TCP"); + SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "csum_trusted", + CTLFLAG_RW, &sc->hn_csum_trusted, + "# of TCP segements that we trust host's csum verification"); + SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "small_pkts", + CTLFLAG_RW, &sc->hn_small_pkts, "# of small packets received"); + + if (unit == 0) { + struct sysctl_ctx_list *dc_ctx; + struct sysctl_oid_list *dc_child; + devclass_t dc; + + /* + * Add sysctl nodes for devclass + */ + dc = device_get_devclass(dev); + dc_ctx = devclass_get_sysctl_ctx(dc); + dc_child = SYSCTL_CHILDREN(devclass_get_sysctl_tree(dc)); + + SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "trust_hosttcp", + CTLFLAG_RD, &hn_trust_hosttcp, 0, + "Trust tcp segement verification on host side, " + "when csum info is missing (global setting)"); + } + return (0); } @@ -383,6 +455,7 @@ netvsc_attach(device_t dev) static int netvsc_detach(device_t dev) { + struct hn_softc *sc = device_get_softc(dev); struct hv_device *hv_device = vmbus_get_devctx(dev); if (bootverbose) @@ -401,6 +474,9 @@ netvsc_detach(device_t dev) hv_rf_on_device_remove(hv_device, HV_RF_NV_DESTROY_CHANNEL); + ifmedia_removeall(&sc->hn_media); + tcp_lro_free(&sc->hn_lro); + return (0); } @@ -887,7 +963,7 @@ netvsc_recv(struct hv_device *device_ctx, netvsc_packet *packet, struct mbuf *m_new; struct ifnet *ifp; device_t dev = device_ctx->device; - int size; + int size, do_lro = 0; if (sc == NULL) { return (0); /* TODO: KYS how can this be! */ @@ -904,40 +980,44 @@ netvsc_recv(struct hv_device *device_ctx, netvsc_packet *packet, */ if (packet->tot_data_buf_len > (ifp->if_mtu + ETHER_HDR_LEN)) { return (0); - } - - /* - * Get an mbuf with a cluster. For packets 2K or less, - * get a standard 2K cluster. For anything larger, get a - * 4K cluster. Any buffers larger than 4K can cause problems - * if looped around to the Hyper-V TX channel, so avoid them. - */ - size = MCLBYTES; - - if (packet->tot_data_buf_len > MCLBYTES) { - /* 4096 */ - size = MJUMPAGESIZE; - } + } else if (packet->tot_data_buf_len <= MHLEN) { + m_new = m_gethdr(M_NOWAIT, MT_DATA); + if (m_new == NULL) + return (0); + memcpy(mtod(m_new, void *), packet->data, + packet->tot_data_buf_len); + m_new->m_pkthdr.len = m_new->m_len = packet->tot_data_buf_len; + sc->hn_small_pkts++; + } else { + /* + * Get an mbuf with a cluster. For packets 2K or less, + * get a standard 2K cluster. For anything larger, get a + * 4K cluster. Any buffers larger than 4K can cause problems + * if looped around to the Hyper-V TX channel, so avoid them. + */ + size = MCLBYTES; + if (packet->tot_data_buf_len > MCLBYTES) { + /* 4096 */ + size = MJUMPAGESIZE; + } - m_new = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, size); + m_new = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, size); + if (m_new == NULL) { + device_printf(dev, "alloc mbuf failed.\n"); + return (0); + } - if (m_new == NULL) { - device_printf(dev, "alloc mbuf failed.\n"); - return (0); + hv_m_append(m_new, packet->tot_data_buf_len, packet->data); } - - hv_m_append(m_new, packet->tot_data_buf_len, - packet->data); - m_new->m_pkthdr.rcvif = ifp; /* receive side checksum offload */ - m_new->m_pkthdr.csum_flags = 0; if (NULL != csum_info) { /* IP csum offload */ if (csum_info->receive.ip_csum_succeeded) { m_new->m_pkthdr.csum_flags |= (CSUM_IP_CHECKED | CSUM_IP_VALID); + sc->hn_csum_ip++; } /* TCP csum offload */ @@ -945,9 +1025,50 @@ netvsc_recv(struct hv_device *device_ctx, netvsc_packet *packet, m_new->m_pkthdr.csum_flags |= (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); m_new->m_pkthdr.csum_data = 0xffff; + sc->hn_csum_tcp++; + } + + if (csum_info->receive.ip_csum_succeeded && + csum_info->receive.tcp_csum_succeeded) + do_lro = 1; + } else { + const struct ether_header *eh; + uint16_t etype; + int hoff; + + hoff = sizeof(*eh); + if (m_new->m_len < hoff) + goto skip; + eh = mtod(m_new, struct ether_header *); + etype = ntohs(eh->ether_type); + if (etype == ETHERTYPE_VLAN) { + const struct ether_vlan_header *evl; + + hoff = sizeof(*evl); + if (m_new->m_len < hoff) + goto skip; + evl = mtod(m_new, struct ether_vlan_header *); + etype = ntohs(evl->evl_proto); } - } + if (etype == ETHERTYPE_IP) { + int pr; + + pr = hn_check_iplen(m_new, hoff); + if (pr == IPPROTO_TCP) { + if (sc->hn_trust_hosttcp) { + sc->hn_csum_trusted++; + m_new->m_pkthdr.csum_flags |= + (CSUM_IP_CHECKED | CSUM_IP_VALID | + CSUM_DATA_VALID | CSUM_PSEUDO_HDR); + m_new->m_pkthdr.csum_data = 0xffff; + } + /* Rely on SW csum verification though... */ + do_lro = 1; + } + } + } +skip: if ((packet->vlan_tci != 0) && (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0) { m_new->m_pkthdr.ether_vtag = packet->vlan_tci; @@ -961,12 +1082,37 @@ netvsc_recv(struct hv_device *device_ctx, netvsc_packet *packet, if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + if ((ifp->if_capenable & IFCAP_LRO) && do_lro) { + struct lro_ctrl *lro = &sc->hn_lro; + + if (lro->lro_cnt) { + sc->hn_lro_tried++; + if (tcp_lro_rx(lro, m_new, 0) == 0) { + /* DONE! */ + return 0; + } + } + } + /* We're not holding the lock here, so don't release it */ (*ifp->if_input)(ifp, m_new); return (0); } +void +netvsc_recv_rollup(struct hv_device *device_ctx) +{ + hn_softc_t *sc = device_get_softc(device_ctx->device); + struct lro_ctrl *lro = &sc->hn_lro; + struct lro_entry *queued; + + while ((queued = SLIST_FIRST(&lro->lro_active)) != NULL) { + SLIST_REMOVE_HEAD(&lro->lro_active, next); + tcp_lro_flush(lro, queued); + } +} + /* * Rules for using sc->temp_unusable: * 1. sc->temp_unusable can only be read or written while holding NV_LOCK() @@ -1022,7 +1168,13 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) /* Obtain and record requested MTU */ ifp->if_mtu = ifr->ifr_mtu; - + /* + * Make sure that LRO high watermark is still valid, + * after MTU change (the 2*MTU limit). + */ + if (!HN_LRO_HIWAT_ISVALID(sc, sc->hn_lro_hiwat)) + hn_set_lro_hiwat(sc, HN_LRO_HIWAT_MTULIM(ifp)); + do { NV_LOCK(sc); if (!sc->temp_unusable) { @@ -1147,6 +1299,8 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) ifp->if_capenable |= IFCAP_RXCSUM; } } + if (mask & IFCAP_LRO) + ifp->if_capenable ^= IFCAP_LRO; if (mask & IFCAP_TSO4) { ifp->if_capenable ^= IFCAP_TSO4; @@ -1171,10 +1325,11 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) error = 0; } #endif - /* FALLTHROUGH */ + error = EINVAL; + break; case SIOCSIFMEDIA: case SIOCGIFMEDIA: - error = EINVAL; + error = ifmedia_ioctl(ifp, ifr, &sc->hn_media, cmd); break; default: error = ether_ioctl(ifp, cmd, data); @@ -1292,6 +1447,102 @@ hn_watchdog(struct ifnet *ifp) } #endif +#ifdef HN_LRO_HIWAT +static int +hn_lro_hiwat_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int hiwat, error; + + hiwat = sc->hn_lro_hiwat; + error = sysctl_handle_int(oidp, &hiwat, 0, req); + if (error || req->newptr == NULL) + return error; + + if (!HN_LRO_HIWAT_ISVALID(sc, hiwat)) + return EINVAL; + + if (sc->hn_lro_hiwat != hiwat) + hn_set_lro_hiwat(sc, hiwat); + return 0; +} +#endif /* HN_LRO_HIWAT */ + +static int +hn_check_iplen(const struct mbuf *m, int hoff) +{ + const struct ip *ip; + int len, iphlen, iplen; + const struct tcphdr *th; + int thoff; /* TCP data offset */ + + len = hoff + sizeof(struct ip); + + /* The packet must be at least the size of an IP header. */ + if (m->m_pkthdr.len < len) + return IPPROTO_DONE; + + /* The fixed IP header must reside completely in the first mbuf. */ + if (m->m_len < len) + return IPPROTO_DONE; + + ip = mtodo(m, hoff); + + /* Bound check the packet's stated IP header length. */ + iphlen = ip->ip_hl << 2; + if (iphlen < sizeof(struct ip)) /* minimum header length */ + return IPPROTO_DONE; + + /* The full IP header must reside completely in the one mbuf. */ + if (m->m_len < hoff + iphlen) + return IPPROTO_DONE; + + iplen = ntohs(ip->ip_len); + + /* + * Check that the amount of data in the buffers is as + * at least much as the IP header would have us expect. + */ + if (m->m_pkthdr.len < hoff + iplen) + return IPPROTO_DONE; + + /* + * Ignore IP fragments. + */ + if (ntohs(ip->ip_off) & (IP_OFFMASK | IP_MF)) + return IPPROTO_DONE; + + /* + * The TCP/IP or UDP/IP header must be entirely contained within + * the first fragment of a packet. + */ + switch (ip->ip_p) { + case IPPROTO_TCP: + if (iplen < iphlen + sizeof(struct tcphdr)) + return IPPROTO_DONE; + if (m->m_len < hoff + iphlen + sizeof(struct tcphdr)) + return IPPROTO_DONE; + th = (const struct tcphdr *)((const uint8_t *)ip + iphlen); + thoff = th->th_off << 2; + if (thoff < sizeof(struct tcphdr) || thoff + iphlen > iplen) + return IPPROTO_DONE; + if (m->m_len < hoff + iphlen + thoff) + return IPPROTO_DONE; + break; + case IPPROTO_UDP: + if (iplen < iphlen + sizeof(struct udphdr)) + return IPPROTO_DONE; + if (m->m_len < hoff + iphlen + sizeof(struct udphdr)) + return IPPROTO_DONE; + break; + default: + if (iplen < iphlen) + return IPPROTO_DONE; + break; + } + return ip->ip_p; +} + static device_method_t netvsc_methods[] = { /* Device interface */ DEVMETHOD(device_probe, netvsc_probe), @@ -1313,6 +1564,3 @@ static devclass_t netvsc_devclass; DRIVER_MODULE(hn, vmbus, netvsc_driver, netvsc_devclass, 0, 0); MODULE_VERSION(hn, 1); MODULE_DEPEND(hn, vmbus, 1, 1, 1); -SYSINIT(netvsc_initx, SI_SUB_KTHREAD_IDLE, SI_ORDER_MIDDLE + 1, netvsc_init, - NULL); - diff --git a/sys/dev/hyperv/netvsc/hv_rndis.h b/sys/dev/hyperv/netvsc/hv_rndis.h index 64fd578..fd032de 100644 --- a/sys/dev/hyperv/netvsc/hv_rndis.h +++ b/sys/dev/hyperv/netvsc/hv_rndis.h @@ -1049,6 +1049,7 @@ typedef struct rndismp_rx_bufs_info_ { int netvsc_recv(struct hv_device *device_ctx, netvsc_packet *packet, rndis_tcp_ip_csum_info *csum_info); +void netvsc_recv_rollup(struct hv_device *device_ctx); void* hv_set_rppi_data(rndis_msg *rndis_mesg, uint32_t rppi_size, diff --git a/sys/dev/hyperv/netvsc/hv_rndis_filter.c b/sys/dev/hyperv/netvsc/hv_rndis_filter.c index 691badd..3e95024 100644 --- a/sys/dev/hyperv/netvsc/hv_rndis_filter.c +++ b/sys/dev/hyperv/netvsc/hv_rndis_filter.c @@ -963,3 +963,14 @@ hv_rf_on_send_request_halt_completion(void *context) request->halt_complete_flag = 1; } +/* + * RNDIS filter when "all" reception is done + */ +void +hv_rf_receive_rollup(netvsc_dev *net_dev) +{ + rndis_device *rndis_dev; + + rndis_dev = (rndis_device *)net_dev->extension; + netvsc_recv_rollup(rndis_dev->net_dev->dev); +} diff --git a/sys/dev/hyperv/netvsc/hv_rndis_filter.h b/sys/dev/hyperv/netvsc/hv_rndis_filter.h index 8355c6a..2f3ebd8 100644 --- a/sys/dev/hyperv/netvsc/hv_rndis_filter.h +++ b/sys/dev/hyperv/netvsc/hv_rndis_filter.h @@ -98,6 +98,7 @@ typedef struct rndis_device_ { int hv_rf_on_receive(netvsc_dev *net_dev, struct hv_device *device, netvsc_packet *pkt); +void hv_rf_receive_rollup(netvsc_dev *net_dev); int hv_rf_on_device_add(struct hv_device *device, void *additl_info); int hv_rf_on_device_remove(struct hv_device *device, boolean_t destroy_channel); int hv_rf_on_open(struct hv_device *device); diff --git a/sys/dev/ic/ns16550.h b/sys/dev/ic/ns16550.h index 33a7dd1..e4c714f 100644 --- a/sys/dev/ic/ns16550.h +++ b/sys/dev/ic/ns16550.h @@ -205,6 +205,7 @@ * requires ACR[6]. */ #define com_icr 5 /* index control register (R/W) */ +#define REG_ICR com_icr /* * 16950 register #7. It is the same as com_scr except it has a different @@ -220,6 +221,7 @@ */ #define com_acr 0 /* additional control register (R/W) */ +#define REG_ACR com_acr #define ACR_ASE 0x80 /* ASR/RFL/TFL enable */ #define ACR_ICRE 0x40 /* ICR enable */ #define ACR_TLE 0x20 /* TTL/RTL enable */ diff --git a/sys/dev/if_ndis/if_ndis.c b/sys/dev/if_ndis/if_ndis.c index bb1f19e..47594fc 100644 --- a/sys/dev/if_ndis/if_ndis.c +++ b/sys/dev/if_ndis/if_ndis.c @@ -724,8 +724,8 @@ ndis_80211attach(struct ndis_softc *sc) ndis_80211_rates_ex rates; struct ndis_80211_nettype_list *ntl; uint32_t arg; - int mode, i, r, len; - uint8_t bands = 0; + int mode, i, r, len, nonettypes = 1; + uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)] = { 0 }; callout_init(&sc->ndis_scan_callout, 1); @@ -751,8 +751,9 @@ ndis_80211attach(struct ndis_softc *sc) for (i = 0; i < ntl->ntl_items; i++) { mode = ndis_nettype_mode(ntl->ntl_type[i]); if (mode) { + nonettypes = 0; setbit(ic->ic_modecaps, mode); - setbit(&bands, mode); + setbit(bands, mode); } else device_printf(sc->ndis_dev, "Unknown nettype %d\n", ntl->ntl_type[i]); @@ -760,9 +761,9 @@ ndis_80211attach(struct ndis_softc *sc) free(ntl, M_DEVBUF); nonettypes: /* Default to 11b channels if the card did not supply any */ - if (bands == 0) { + if (nonettypes) { setbit(ic->ic_modecaps, IEEE80211_MODE_11B); - setbit(&bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11B); } len = sizeof(rates); bzero((char *)&rates, len); @@ -859,7 +860,7 @@ nonettypes: #undef INCRATE #undef TESTSETRATE - ieee80211_init_channels(ic, NULL, &bands); + ieee80211_init_channels(ic, NULL, bands); /* * To test for WPA support, we need to see if we can diff --git a/sys/dev/ioat/ioat.c b/sys/dev/ioat/ioat.c index 4b6d7df..7f14c3f 100644 --- a/sys/dev/ioat/ioat.c +++ b/sys/dev/ioat/ioat.c @@ -744,6 +744,15 @@ ioat_get_hwversion(bus_dmaengine_t dmaengine) return (ioat->version); } +size_t +ioat_get_max_io_size(bus_dmaengine_t dmaengine) +{ + struct ioat_softc *ioat; + + ioat = to_ioat_softc(dmaengine); + return (ioat->max_xfer_size); +} + int ioat_set_interrupt_coalesce(bus_dmaengine_t dmaengine, uint16_t delay) { @@ -780,6 +789,21 @@ ioat_acquire(bus_dmaengine_t dmaengine) CTR0(KTR_IOAT, __func__); } +int +ioat_acquire_reserve(bus_dmaengine_t dmaengine, unsigned n, int mflags) +{ + struct ioat_softc *ioat; + int error; + + ioat = to_ioat_softc(dmaengine); + ioat_acquire(dmaengine); + + error = ioat_reserve_space(ioat, n, mflags); + if (error != 0) + ioat_release(dmaengine); + return (error); +} + void ioat_release(bus_dmaengine_t dmaengine) { diff --git a/sys/dev/ioat/ioat.h b/sys/dev/ioat/ioat.h index e8f47ae..64f9783 100644 --- a/sys/dev/ioat/ioat.h +++ b/sys/dev/ioat/ioat.h @@ -70,6 +70,7 @@ void ioat_put_dmaengine(bus_dmaengine_t dmaengine); /* Check the DMA engine's HW version */ int ioat_get_hwversion(bus_dmaengine_t dmaengine); +size_t ioat_get_max_io_size(bus_dmaengine_t dmaengine); /* * Set interrupt coalescing on a DMA channel. @@ -95,13 +96,26 @@ uint16_t ioat_get_max_coalesce_period(bus_dmaengine_t dmaengine); /* * Acquire must be called before issuing an operation to perform. Release is - * called after. Multiple operations can be issued within the context of one + * called after. Multiple operations can be issued within the context of one * acquire and release */ void ioat_acquire(bus_dmaengine_t dmaengine); void ioat_release(bus_dmaengine_t dmaengine); /* + * Acquire_reserve can be called to ensure there is room for N descriptors. If + * it succeeds, the next N valid operations will successfully enqueue. + * + * It may fail with: + * - ENXIO if the channel is in an errored state, or the driver is being + * unloaded + * - EAGAIN if mflags included M_NOWAIT + * + * On failure, the caller does not hold the dmaengine. + */ +int ioat_acquire_reserve(bus_dmaengine_t dmaengine, unsigned n, int mflags); + +/* * Issue a blockfill operation. The 64-bit pattern 'fillpattern' is written to * 'len' physically contiguous bytes at 'dst'. * diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index d792746..a9bdaf7 100644 --- a/sys/dev/iscsi/iscsi.c +++ b/sys/dev/iscsi/iscsi.c @@ -98,6 +98,9 @@ SYSCTL_INT(_kern_iscsi, OID_AUTO, maxtags, CTLFLAG_RWTUN, &maxtags, static int fail_on_disconnection = 0; SYSCTL_INT(_kern_iscsi, OID_AUTO, fail_on_disconnection, CTLFLAG_RWTUN, &fail_on_disconnection, 0, "Destroy CAM SIM on connection failure"); +static int fail_on_shutdown = 1; +SYSCTL_INT(_kern_iscsi, OID_AUTO, fail_on_shutdown, CTLFLAG_RWTUN, + &fail_on_shutdown, 0, "Fail disconnected sessions on shutdown"); static MALLOC_DEFINE(M_ISCSI, "iSCSI", "iSCSI initiator"); static uma_zone_t iscsi_outstanding_zone; @@ -417,8 +420,6 @@ iscsi_maintenance_thread_terminate(struct iscsi_session *is) sc = is->is_softc; sx_xlock(&sc->sc_lock); - TAILQ_REMOVE(&sc->sc_sessions, is, is_next); - sx_xunlock(&sc->sc_lock); icl_conn_close(is->is_conn); callout_drain(&is->is_callout); @@ -450,6 +451,9 @@ iscsi_maintenance_thread_terminate(struct iscsi_session *is) #ifdef ICL_KERNEL_PROXY cv_destroy(&is->is_login_cv); #endif + TAILQ_REMOVE(&sc->sc_sessions, is, is_next); + sx_xunlock(&sc->sc_lock); + ISCSI_SESSION_DEBUG(is, "terminated"); free(is, M_ISCSI); @@ -473,12 +477,7 @@ iscsi_maintenance_thread(void *arg) STAILQ_EMPTY(&is->is_postponed)) cv_wait(&is->is_maintenance_cv, &is->is_lock); - if (is->is_reconnecting) { - ISCSI_SESSION_UNLOCK(is); - iscsi_maintenance_thread_reconnect(is); - continue; - } - + /* Terminate supersedes reconnect. */ if (is->is_terminating) { ISCSI_SESSION_UNLOCK(is); iscsi_maintenance_thread_terminate(is); @@ -486,6 +485,12 @@ iscsi_maintenance_thread(void *arg) return; } + if (is->is_reconnecting) { + ISCSI_SESSION_UNLOCK(is); + iscsi_maintenance_thread_reconnect(is); + continue; + } + iscsi_session_send_postponed(is); ISCSI_SESSION_UNLOCK(is); } @@ -605,6 +610,11 @@ iscsi_callout(void *context) return; out: + if (is->is_terminating) { + ISCSI_SESSION_UNLOCK(is); + return; + } + ISCSI_SESSION_UNLOCK(is); if (reconnect_needed) @@ -2326,30 +2336,62 @@ iscsi_poll(struct cam_sim *sim) } static void -iscsi_shutdown(struct iscsi_softc *sc) +iscsi_terminate_sessions(struct iscsi_softc *sc) { struct iscsi_session *is; - /* - * Trying to reconnect during system shutdown would lead to hang. - */ - fail_on_disconnection = 1; + sx_slock(&sc->sc_lock); + TAILQ_FOREACH(is, &sc->sc_sessions, is_next) + iscsi_session_terminate(is); + while(!TAILQ_EMPTY(&sc->sc_sessions)) { + ISCSI_DEBUG("waiting for sessions to terminate"); + cv_wait(&sc->sc_cv, &sc->sc_lock); + } + ISCSI_DEBUG("all sessions terminated"); + sx_sunlock(&sc->sc_lock); +} + +static void +iscsi_shutdown_pre(struct iscsi_softc *sc) +{ + struct iscsi_session *is; + + if (!fail_on_shutdown) + return; /* * If we have any sessions waiting for reconnection, request * maintenance thread to fail them immediately instead of waiting * for reconnect timeout. + * + * This prevents LUNs with mounted filesystems that are supported + * by disconnected iSCSI sessions from hanging, however it will + * fail all queued BIOs. */ + ISCSI_DEBUG("forcing failing all disconnected sessions due to shutdown"); + + fail_on_disconnection = 1; + sx_slock(&sc->sc_lock); TAILQ_FOREACH(is, &sc->sc_sessions, is_next) { ISCSI_SESSION_LOCK(is); - if (is->is_waiting_for_iscsid) + if (!is->is_connected) { + ISCSI_SESSION_DEBUG(is, "force failing disconnected session early"); iscsi_session_reconnect(is); + } ISCSI_SESSION_UNLOCK(is); } sx_sunlock(&sc->sc_lock); } +static void +iscsi_shutdown_post(struct iscsi_softc *sc) +{ + + ISCSI_DEBUG("removing all sessions due to shutdown"); + iscsi_terminate_sessions(sc); +} + static int iscsi_load(void) { @@ -2372,8 +2414,16 @@ iscsi_load(void) } sc->sc_cdev->si_drv1 = sc; - sc->sc_shutdown_eh = EVENTHANDLER_REGISTER(shutdown_pre_sync, - iscsi_shutdown, sc, SHUTDOWN_PRI_DEFAULT-1); + sc->sc_shutdown_pre_eh = EVENTHANDLER_REGISTER(shutdown_pre_sync, + iscsi_shutdown_pre, sc, SHUTDOWN_PRI_FIRST); + /* + * shutdown_post_sync needs to run after filesystem shutdown and before + * CAM shutdown - otherwise when rebooting with an iSCSI session that is + * disconnected but has outstanding requests, dashutdown() will hang on + * cam_periph_runccb(). + */ + sc->sc_shutdown_post_eh = EVENTHANDLER_REGISTER(shutdown_post_sync, + iscsi_shutdown_post, sc, SHUTDOWN_PRI_DEFAULT - 1); return (0); } @@ -2381,7 +2431,6 @@ iscsi_load(void) static int iscsi_unload(void) { - struct iscsi_session *is, *tmp; if (sc->sc_cdev != NULL) { ISCSI_DEBUG("removing device node"); @@ -2389,18 +2438,12 @@ iscsi_unload(void) ISCSI_DEBUG("device node removed"); } - if (sc->sc_shutdown_eh != NULL) - EVENTHANDLER_DEREGISTER(shutdown_pre_sync, sc->sc_shutdown_eh); + if (sc->sc_shutdown_pre_eh != NULL) + EVENTHANDLER_DEREGISTER(shutdown_pre_sync, sc->sc_shutdown_pre_eh); + if (sc->sc_shutdown_post_eh != NULL) + EVENTHANDLER_DEREGISTER(shutdown_post_sync, sc->sc_shutdown_post_eh); - sx_slock(&sc->sc_lock); - TAILQ_FOREACH_SAFE(is, &sc->sc_sessions, is_next, tmp) - iscsi_session_terminate(is); - while(!TAILQ_EMPTY(&sc->sc_sessions)) { - ISCSI_DEBUG("waiting for sessions to terminate"); - cv_wait(&sc->sc_cv, &sc->sc_lock); - } - ISCSI_DEBUG("all sessions terminated"); - sx_sunlock(&sc->sc_lock); + iscsi_terminate_sessions(sc); uma_zdestroy(iscsi_outstanding_zone); sx_destroy(&sc->sc_lock); diff --git a/sys/dev/iscsi/iscsi.h b/sys/dev/iscsi/iscsi.h index fd52fa8..a2475f4 100644 --- a/sys/dev/iscsi/iscsi.h +++ b/sys/dev/iscsi/iscsi.h @@ -131,7 +131,8 @@ struct iscsi_softc { TAILQ_HEAD(, iscsi_session) sc_sessions; struct cv sc_cv; unsigned int sc_last_session_id; - eventhandler_tag sc_shutdown_eh; + eventhandler_tag sc_shutdown_pre_eh; + eventhandler_tag sc_shutdown_post_eh; }; #endif /* !ISCSI_H */ diff --git a/sys/dev/ismt/ismt.c b/sys/dev/ismt/ismt.c index dc90e3f..3fbcfed 100644 --- a/sys/dev/ismt/ismt.c +++ b/sys/dev/ismt/ismt.c @@ -72,7 +72,7 @@ __FBSDID("$FreeBSD$"); #define ISMT_DESC_LPR 0x80 /* Large Packet Received */ /* Macros */ -#define ISMT_DESC_ADDR_RW(addr, is_read) ((addr) | (is_read)) +#define ISMT_DESC_ADDR_RW(addr, is_read) ((addr << 1) | (is_read)) /* iSMT General Register address offsets (SMBBAR + <addr>) */ #define ISMT_GR_GCTRL 0x000 /* General Control */ diff --git a/sys/dev/iwi/if_iwi.c b/sys/dev/iwi/if_iwi.c index 53141e1..55004f6 100644 --- a/sys/dev/iwi/if_iwi.c +++ b/sys/dev/iwi/if_iwi.c @@ -271,8 +271,8 @@ iwi_attach(device_t dev) struct iwi_softc *sc = device_get_softc(dev); struct ieee80211com *ic = &sc->sc_ic; uint16_t val; + uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)]; int i, error; - uint8_t bands; sc->sc_dev = dev; @@ -373,13 +373,13 @@ iwi_attach(device_t dev) val = iwi_read_prom_word(sc, IWI_EEPROM_MAC + 2); ic->ic_macaddr[4] = val & 0xff; ic->ic_macaddr[5] = val >> 8; - - bands = 0; - setbit(&bands, IEEE80211_MODE_11B); - setbit(&bands, IEEE80211_MODE_11G); + + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); if (pci_get_device(dev) >= 0x4223) - setbit(&bands, IEEE80211_MODE_11A); - ieee80211_init_channels(ic, NULL, &bands); + setbit(bands, IEEE80211_MODE_11A); + ieee80211_init_channels(ic, NULL, bands); ieee80211_ifattach(ic); /* override default methods */ diff --git a/sys/dev/iwm/if_iwm.c b/sys/dev/iwm/if_iwm.c index ce3b603..510491e 100644 --- a/sys/dev/iwm/if_iwm.c +++ b/sys/dev/iwm/if_iwm.c @@ -270,7 +270,7 @@ static void iwm_mvm_rx_rx_phy_cmd(struct iwm_softc *, static int iwm_get_noise(const struct iwm_mvm_statistics_rx_non_phy *); static void iwm_mvm_rx_rx_mpdu(struct iwm_softc *, struct iwm_rx_packet *, struct iwm_rx_data *); -static void iwm_mvm_rx_tx_cmd_single(struct iwm_softc *, +static int iwm_mvm_rx_tx_cmd_single(struct iwm_softc *, struct iwm_rx_packet *, struct iwm_node *); static void iwm_mvm_rx_tx_cmd(struct iwm_softc *, struct iwm_rx_packet *, @@ -423,9 +423,8 @@ iwm_set_default_calib(struct iwm_softc *sc, const void *data) static void iwm_fw_info_free(struct iwm_fw_info *fw) { - firmware_put(fw->fw_rawdata, FIRMWARE_UNLOAD); - fw->fw_rawdata = NULL; - fw->fw_rawsize = 0; + firmware_put(fw->fw_fp, FIRMWARE_UNLOAD); + fw->fw_fp = NULL; /* don't touch fw->fw_status */ memset(fw->fw_sects, 0, sizeof(fw->fw_sects)); } @@ -450,32 +449,30 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode_type ucode_type) msleep(&sc->sc_fw, &sc->sc_mtx, 0, "iwmfwp", 0); fw->fw_status = IWM_FW_STATUS_INPROGRESS; - if (fw->fw_rawdata != NULL) + if (fw->fw_fp != NULL) iwm_fw_info_free(fw); /* * Load firmware into driver memory. - * fw_rawdata and fw_rawsize will be set. + * fw_fp will be set. */ IWM_UNLOCK(sc); fwp = firmware_get(sc->sc_fwname); + IWM_LOCK(sc); if (fwp == NULL) { device_printf(sc->sc_dev, "could not read firmware %s (error %d)\n", sc->sc_fwname, error); - IWM_LOCK(sc); goto out; } - IWM_LOCK(sc); - fw->fw_rawdata = fwp->data; - fw->fw_rawsize = fwp->datasize; + fw->fw_fp = fwp; /* * Parse firmware contents */ - uhdr = (const void *)fw->fw_rawdata; - if (*(const uint32_t *)fw->fw_rawdata != 0 + uhdr = (const void *)fw->fw_fp->data; + if (*(const uint32_t *)fw->fw_fp->data != 0 || le32toh(uhdr->magic) != IWM_TLV_UCODE_MAGIC) { device_printf(sc->sc_dev, "invalid firmware %s\n", sc->sc_fwname); @@ -485,7 +482,7 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode_type ucode_type) sc->sc_fwver = le32toh(uhdr->ver); data = uhdr->data; - len = fw->fw_rawsize - sizeof(*uhdr); + len = fw->fw_fp->datasize - sizeof(*uhdr); while (len >= sizeof(tlv)) { size_t tlv_len; @@ -684,7 +681,7 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode_type ucode_type) out: if (error) { fw->fw_status = IWM_FW_STATUS_NONE; - if (fw->fw_rawdata != NULL) + if (fw->fw_fp != NULL) iwm_fw_info_free(fw); } else fw->fw_status = IWM_FW_STATUS_DONE; @@ -956,7 +953,7 @@ iwm_alloc_tx_ring(struct iwm_softc *sc, struct iwm_tx_ring *ring, int qid) error = bus_dma_tag_create(sc->sc_dmat, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, - IWM_MAX_SCATTER - 1, MCLBYTES, 0, NULL, NULL, &ring->data_dmat); + IWM_MAX_SCATTER - 2, MCLBYTES, 0, NULL, NULL, &ring->data_dmat); if (error != 0) { device_printf(sc->sc_dev, "could not create TX buf DMA tag\n"); goto fail; @@ -2400,12 +2397,13 @@ iwm_mvm_rx_rx_mpdu(struct iwm_softc *sc, IWM_LOCK(sc); } -static void +static int iwm_mvm_rx_tx_cmd_single(struct iwm_softc *sc, struct iwm_rx_packet *pkt, struct iwm_node *in) { struct iwm_mvm_tx_resp *tx_resp = (void *)pkt->data; - struct ieee80211vap *vap = in->in_ni.ni_vap; + struct ieee80211_node *ni = &in->in_ni; + struct ieee80211vap *vap = ni->ni_vap; int status = le16toh(tx_resp->status.status) & IWM_TX_STATUS_MSK; int failack = tx_resp->failure_frame; @@ -2414,14 +2412,13 @@ iwm_mvm_rx_tx_cmd_single(struct iwm_softc *sc, struct iwm_rx_packet *pkt, /* Update rate control statistics. */ if (status != IWM_TX_STATUS_SUCCESS && status != IWM_TX_STATUS_DIRECT_DONE) { - if_inc_counter(vap->iv_ifp, IFCOUNTER_OERRORS, 1); - ieee80211_ratectl_tx_complete(vap, &in->in_ni, + ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_FAILURE, &failack, NULL); + return (1); } else { - if_inc_counter(vap->iv_ifp, IFCOUNTER_OPACKETS, 1); - ieee80211_ratectl_tx_complete(vap, &in->in_ni, + ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_SUCCESS, &failack, NULL); - + return (0); } } @@ -2435,33 +2432,30 @@ iwm_mvm_rx_tx_cmd(struct iwm_softc *sc, struct iwm_tx_ring *ring = &sc->txq[qid]; struct iwm_tx_data *txd = &ring->data[idx]; struct iwm_node *in = txd->in; + struct mbuf *m = txd->m; + int status; + + KASSERT(txd->done == 0, ("txd not done")); + KASSERT(txd->in != NULL, ("txd without node")); + KASSERT(txd->m != NULL, ("txd without mbuf")); - if (txd->done) { - device_printf(sc->sc_dev, - "%s: got tx interrupt that's already been handled!\n", - __func__); - return; - } bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_POSTREAD); sc->sc_tx_timer = 0; - iwm_mvm_rx_tx_cmd_single(sc, pkt, in); + status = iwm_mvm_rx_tx_cmd_single(sc, pkt, in); /* Unmap and free mbuf. */ bus_dmamap_sync(ring->data_dmat, txd->map, BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(ring->data_dmat, txd->map); - m_freem(txd->m); IWM_DPRINTF(sc, IWM_DEBUG_XMIT, "free txd %p, in %p\n", txd, txd->in); - KASSERT(txd->done == 0, ("txd not done")); txd->done = 1; - KASSERT(txd->in, ("txd without node")); - txd->m = NULL; txd->in = NULL; - ieee80211_free_node((struct ieee80211_node *)in); + + ieee80211_tx_complete(&in->in_ni, m, status); if (--ring->queued < IWM_TX_RING_LOMARK) { sc->qfullmsk &= ~(1 << ring->qid); @@ -2649,7 +2643,7 @@ iwm_tx(struct iwm_softc *sc, struct mbuf *m, struct ieee80211_node *ni, int ac) { struct ieee80211com *ic = &sc->sc_ic; struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); - struct iwm_node *in = (struct iwm_node *)ni; + struct iwm_node *in = IWM_NODE(ni); struct iwm_tx_ring *ring; struct iwm_tx_data *data; struct iwm_tfd *desc; @@ -2706,7 +2700,6 @@ iwm_tx(struct iwm_softc *sc, struct mbuf *m, struct ieee80211_node *ni, int ac) tap->wt_chan_freq = htole16(ni->ni_chan->ic_freq); tap->wt_chan_flags = htole16(ni->ni_chan->ic_flags); tap->wt_rate = rinfo->rate; - tap->wt_hwqueue = ac; if (k != NULL) tap->wt_flags |= IEEE80211_RADIOTAP_F_WEP; ieee80211_radiotap_tx(vap, m); @@ -2782,23 +2775,15 @@ iwm_tx(struct iwm_softc *sc, struct mbuf *m, struct ieee80211_node *ni, int ac) return error; } /* Too many DMA segments, linearize mbuf. */ - MGETHDR(m1, M_NOWAIT, MT_DATA); + m1 = m_collapse(m, M_NOWAIT, IWM_MAX_SCATTER - 2); if (m1 == NULL) { + device_printf(sc->sc_dev, + "%s: could not defrag mbuf\n", __func__); m_freem(m); - return ENOBUFS; - } - if (m->m_pkthdr.len > MHLEN) { - MCLGET(m1, M_NOWAIT); - if (!(m1->m_flags & M_EXT)) { - m_freem(m); - m_freem(m1); - return ENOBUFS; - } + return (ENOBUFS); } - m_copydata(m, 0, m->m_pkthdr.len, mtod(m1, void *)); - m1->m_pkthdr.len = m1->m_len = m->m_pkthdr.len; - m_freem(m); m = m1; + error = bus_dmamap_load_mbuf_sg(ring->data_dmat, data->map, m, segs, &nsegs, BUS_DMA_NOWAIT); if (error != 0) { @@ -3182,7 +3167,7 @@ iwm_auth(struct ieee80211vap *vap, struct iwm_softc *sc) * freed from underneath us. Grr. */ ni = ieee80211_ref_node(vap->iv_bss); - in = (struct iwm_node *) ni; + in = IWM_NODE(ni); IWM_DPRINTF(sc, IWM_DEBUG_RESET | IWM_DEBUG_STATE, "%s: called; vap=%p, bss ni=%p\n", __func__, @@ -3289,7 +3274,7 @@ out: static int iwm_assoc(struct ieee80211vap *vap, struct iwm_softc *sc) { - struct iwm_node *in = (struct iwm_node *)vap->iv_bss; + struct iwm_node *in = IWM_NODE(vap->iv_bss); int error; if ((error = iwm_mvm_update_sta(sc, in)) != 0) { @@ -3515,7 +3500,7 @@ iwm_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) if (vap->iv_state == IEEE80211_S_RUN && nstate != vap->iv_state) { iwm_mvm_disable_beacon_filter(sc); - if (((in = (void *)vap->iv_bss) != NULL)) + if (((in = IWM_NODE(vap->iv_bss)) != NULL)) in->in_assoc = 0; iwm_release(sc, NULL); @@ -3591,7 +3576,7 @@ iwm_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) break; } - in = (struct iwm_node *)vap->iv_bss; + in = IWM_NODE(vap->iv_bss); iwm_mvm_power_mac_update_mode(sc, in); iwm_mvm_enable_beacon_filter(sc, in); iwm_mvm_update_quotas(sc, in); @@ -4596,7 +4581,7 @@ iwm_attach(device_t dev) int txq_i, i; sc->sc_dev = dev; - mtx_init(&sc->sc_mtx, "iwm_mtx", MTX_DEF, 0); + IWM_LOCK_INIT(sc); mbufq_init(&sc->sc_snd, ifqmaxlen); callout_init_mtx(&sc->sc_watchdog_to, &sc->sc_mtx, 0); TASK_INIT(&sc->sc_es_task, 0, iwm_endscan_cb, sc); @@ -4969,10 +4954,10 @@ iwm_detach_local(struct iwm_softc *sc, int do_net80211) iwm_free_tx_ring(sc, &sc->txq[i]); /* Free firmware */ - if (fw->fw_rawdata != NULL) + if (fw->fw_fp != NULL) iwm_fw_info_free(fw); - /* free scheduler */ + /* Free scheduler */ iwm_free_sched(sc); if (sc->ict_dma.vaddr != NULL) iwm_free_ict(sc); @@ -4985,7 +4970,7 @@ iwm_detach_local(struct iwm_softc *sc, int do_net80211) iwm_pci_detach(dev); mbufq_drain(&sc->sc_snd); - mtx_destroy(&sc->sc_mtx); + IWM_LOCK_DESTROY(sc); return (0); } diff --git a/sys/dev/iwm/if_iwm_mac_ctxt.c b/sys/dev/iwm/if_iwm_mac_ctxt.c index edaacc9..50b1b13 100644 --- a/sys/dev/iwm/if_iwm_mac_ctxt.c +++ b/sys/dev/iwm/if_iwm_mac_ctxt.c @@ -426,7 +426,7 @@ iwm_mvm_mac_ctxt_cmd_station(struct iwm_softc *sc, struct ieee80211vap *vap, uint32_t action) { struct ieee80211_node *ni = vap->iv_bss; - struct iwm_node *in = (struct iwm_node *) ni; + struct iwm_node *in = IWM_NODE(ni); struct iwm_mac_ctx_cmd cmd; IWM_DPRINTF(sc, IWM_DEBUG_RESET, diff --git a/sys/dev/iwm/if_iwmvar.h b/sys/dev/iwm/if_iwmvar.h index 9434b83..7ab0ea7 100644 --- a/sys/dev/iwm/if_iwmvar.h +++ b/sys/dev/iwm/if_iwmvar.h @@ -129,7 +129,6 @@ struct iwm_tx_radiotap_header { uint8_t wt_rate; uint16_t wt_chan_freq; uint16_t wt_chan_flags; - uint8_t wt_hwqueue; } __packed; #define IWM_TX_RADIOTAP_PRESENT \ @@ -152,9 +151,6 @@ struct iwm_tx_radiotap_header { #define IWM_FW_STATUS_INPROGRESS 1 #define IWM_FW_STATUS_DONE 2 -#define IWM_LOCK(_sc) mtx_lock(&sc->sc_mtx) -#define IWM_UNLOCK(_sc) mtx_unlock(&sc->sc_mtx) - enum iwm_ucode_type { IWM_UCODE_TYPE_INIT, IWM_UCODE_TYPE_REGULAR, @@ -163,8 +159,7 @@ enum iwm_ucode_type { }; struct iwm_fw_info { - const void *fw_rawdata; - size_t fw_rawsize; + const struct firmware *fw_fp; int fw_status; struct iwm_fw_sects { @@ -244,12 +239,12 @@ struct iwm_dma_info { #define IWM_TX_RING_HIMARK 224 struct iwm_tx_data { - bus_dmamap_t map; - bus_addr_t cmd_paddr; - bus_addr_t scratch_paddr; - struct mbuf *m; - struct iwm_node *in; - int done; + bus_dmamap_t map; + bus_addr_t cmd_paddr; + bus_addr_t scratch_paddr; + struct mbuf *m; + struct iwm_node *in; + int done; }; struct iwm_tx_ring { @@ -295,12 +290,6 @@ struct iwm_rx_ring { int cur; }; -#define IWM_FLAG_USE_ICT 0x01 -#define IWM_FLAG_HW_INITED 0x02 -#define IWM_FLAG_STOPPED 0x04 -#define IWM_FLAG_RFKILL 0x08 -#define IWM_FLAG_BUSY 0x10 - struct iwm_ucode_status { uint32_t uc_error_event_table; uint32_t uc_log_event_table; @@ -371,68 +360,97 @@ struct iwm_bf_data { }; struct iwm_vap { - struct ieee80211vap iv_vap; - uint8_t macaddr[IEEE80211_ADDR_LEN]; - int is_uploaded; + struct ieee80211vap iv_vap; + int is_uploaded; - int (*iv_newstate)(struct ieee80211vap *, enum ieee80211_state, int); + int (*iv_newstate)(struct ieee80211vap *, + enum ieee80211_state, int); }; +#define IWM_VAP(_vap) ((struct iwm_vap *)(_vap)) -#define IWM_VAP(_vap) ((struct iwm_vap *)(_vap)) +struct iwm_node { + struct ieee80211_node in_ni; + struct iwm_mvm_phy_ctxt *in_phyctxt; + + /* status "bits" */ + int in_assoc; + + struct iwm_lq_cmd in_lq; + + uint8_t in_ridx[IEEE80211_RATE_MAXSIZE]; +}; +#define IWM_NODE(_ni) ((struct iwm_node *)(_ni)) + +#define IWM_STATION_ID 0 + +#define IWM_DEFAULT_MACID 0 +#define IWM_DEFAULT_COLOR 0 +#define IWM_DEFAULT_TSFID 0 + +#define IWM_ICT_SIZE 4096 +#define IWM_ICT_COUNT (IWM_ICT_SIZE / sizeof (uint32_t)) +#define IWM_ICT_PADDR_SHIFT 12 struct iwm_softc { + device_t sc_dev; + uint32_t sc_debug; + struct mtx sc_mtx; struct mbufq sc_snd; struct ieee80211com sc_ic; - device_t sc_dev; + + int sc_flags; +#define IWM_FLAG_USE_ICT (1 << 0) +#define IWM_FLAG_HW_INITED (1 << 1) +#define IWM_FLAG_STOPPED (1 << 2) +#define IWM_FLAG_RFKILL (1 << 3) +#define IWM_FLAG_BUSY (1 << 4) struct intr_config_hook sc_preinit_hook; - struct callout sc_watchdog_to; + struct callout sc_watchdog_to; struct task init_task; - struct resource *sc_irq; - struct resource *sc_mem; - bus_space_tag_t sc_st; - bus_space_handle_t sc_sh; - bus_size_t sc_sz; - bus_dma_tag_t sc_dmat; - void *sc_ih; + struct resource *sc_irq; + struct resource *sc_mem; + bus_space_tag_t sc_st; + bus_space_handle_t sc_sh; + bus_size_t sc_sz; + bus_dma_tag_t sc_dmat; + void *sc_ih; /* TX scheduler rings. */ - struct iwm_dma_info sched_dma; - uint32_t sched_base; + struct iwm_dma_info sched_dma; + uint32_t sched_base; /* TX/RX rings. */ - struct iwm_tx_ring txq[IWM_MVM_MAX_QUEUES]; - struct iwm_rx_ring rxq; - int qfullmsk; + struct iwm_tx_ring txq[IWM_MVM_MAX_QUEUES]; + struct iwm_rx_ring rxq; + int qfullmsk; - int sc_sf_state; + int sc_sf_state; /* ICT table. */ struct iwm_dma_info ict_dma; int ict_cur; - int sc_hw_rev; - int sc_hw_id; + int sc_hw_rev; + int sc_hw_id; - struct iwm_dma_info kw_dma; - struct iwm_dma_info fw_dma; + struct iwm_dma_info kw_dma; + struct iwm_dma_info fw_dma; - int sc_fw_chunk_done; - int sc_init_complete; + int sc_fw_chunk_done; + int sc_init_complete; - struct iwm_ucode_status sc_uc; - enum iwm_ucode_type sc_uc_current; - int sc_fwver; + struct iwm_ucode_status sc_uc; + enum iwm_ucode_type sc_uc_current; + int sc_fwver; - int sc_capaflags; - int sc_capa_max_probe_len; + int sc_capaflags; + int sc_capa_max_probe_len; - int sc_intmask; - int sc_flags; - uint32_t sc_debug; + int sc_intmask; /* * So why do we need a separate stopped flag and a generation? @@ -443,86 +461,63 @@ struct iwm_softc { * the device from interrupt context when it craps out, so we * don't have the luxury of waiting for quiescense. */ - int sc_generation; + int sc_generation; - const char *sc_fwname; - bus_size_t sc_fwdmasegsz; - struct iwm_fw_info sc_fw; - int sc_fw_phy_config; + const char *sc_fwname; + bus_size_t sc_fwdmasegsz; + struct iwm_fw_info sc_fw; + int sc_fw_phy_config; struct iwm_tlv_calib_ctrl sc_default_calib[IWM_UCODE_TYPE_MAX]; - struct iwm_nvm_data sc_nvm; - struct iwm_phy_db sc_phy_db; + struct iwm_nvm_data sc_nvm; + struct iwm_phy_db sc_phy_db; - struct iwm_bf_data sc_bf; + struct iwm_bf_data sc_bf; - int sc_tx_timer; + int sc_tx_timer; - struct iwm_scan_cmd *sc_scan_cmd; - size_t sc_scan_cmd_len; - int sc_scan_last_antenna; - int sc_scanband; + struct iwm_scan_cmd *sc_scan_cmd; + size_t sc_scan_cmd_len; + int sc_scan_last_antenna; + int sc_scanband; - int sc_auth_prot; + int sc_auth_prot; - int sc_fixed_ridx; + int sc_fixed_ridx; - int sc_staid; - int sc_nodecolor; + int sc_staid; + int sc_nodecolor; - uint8_t sc_cmd_resp[IWM_CMD_RESP_MAX]; - int sc_wantresp; + uint8_t sc_cmd_resp[IWM_CMD_RESP_MAX]; + int sc_wantresp; - struct taskqueue *sc_tq; - struct task sc_es_task; + struct taskqueue *sc_tq; + struct task sc_es_task; - struct iwm_rx_phy_info sc_last_phy_info; - int sc_ampdu_ref; + struct iwm_rx_phy_info sc_last_phy_info; + int sc_ampdu_ref; - struct iwm_int_sta sc_aux_sta; + struct iwm_int_sta sc_aux_sta; /* phy contexts. we only use the first one */ - struct iwm_mvm_phy_ctxt sc_phyctxt[IWM_NUM_PHY_CTX]; + struct iwm_mvm_phy_ctxt sc_phyctxt[IWM_NUM_PHY_CTX]; struct iwm_notif_statistics sc_stats; - int sc_noise; + int sc_noise; - int host_interrupt_operation_mode; + int host_interrupt_operation_mode; caddr_t sc_drvbpf; - union { - struct iwm_rx_radiotap_header th; - uint8_t pad[IEEE80211_RADIOTAP_HDRLEN]; - } sc_rxtapu; -#define sc_rxtap sc_rxtapu.th - - union { - struct iwm_tx_radiotap_header th; - uint8_t pad[IEEE80211_RADIOTAP_HDRLEN]; - } sc_txtapu; -#define sc_txtap sc_txtapu.th - - int sc_max_rssi; -}; - -#define IWM_DEFAULT_MACID 0 -#define IWM_DEFAULT_COLOR 0 -#define IWM_DEFAULT_TSFID 0 - -struct iwm_node { - struct ieee80211_node in_ni; - struct iwm_mvm_phy_ctxt *in_phyctxt; - - /* status "bits" */ - int in_assoc; - - struct iwm_lq_cmd in_lq; + struct iwm_rx_radiotap_header sc_rxtap; + struct iwm_tx_radiotap_header sc_txtap; - uint8_t in_ridx[IEEE80211_RATE_MAXSIZE]; + int sc_max_rssi; }; -#define IWM_STATION_ID 0 -#define IWM_ICT_SIZE 4096 -#define IWM_ICT_COUNT (IWM_ICT_SIZE / sizeof (uint32_t)) -#define IWM_ICT_PADDR_SHIFT 12 +#define IWM_LOCK_INIT(_sc) \ + mtx_init(&(_sc)->sc_mtx, device_get_nameunit((_sc)->sc_dev), \ + MTX_NETWORK_LOCK, MTX_DEF); +#define IWM_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) +#define IWM_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) +#define IWM_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_mtx) diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c index 2947db5..c361fe3 100644 --- a/sys/dev/iwn/if_iwn.c +++ b/sys/dev/iwn/if_iwn.c @@ -177,11 +177,15 @@ static void iwn4965_print_power_group(struct iwn_softc *, int); #endif static void iwn5000_read_eeprom(struct iwn_softc *); static uint32_t iwn_eeprom_channel_flags(struct iwn_eeprom_chan *); -static void iwn_read_eeprom_band(struct iwn_softc *, int); -static void iwn_read_eeprom_ht40(struct iwn_softc *, int); +static void iwn_read_eeprom_band(struct iwn_softc *, int, int, int *, + struct ieee80211_channel[]); +static void iwn_read_eeprom_ht40(struct iwn_softc *, int, int, int *, + struct ieee80211_channel[]); static void iwn_read_eeprom_channels(struct iwn_softc *, int, uint32_t); static struct iwn_eeprom_chan *iwn_find_eeprom_channel(struct iwn_softc *, struct ieee80211_channel *); +static void iwn_getradiocaps(struct ieee80211com *, int, int *, + struct ieee80211_channel[]); static int iwn_setregdomain(struct ieee80211com *, struct ieee80211_regdomain *, int, struct ieee80211_channel[]); @@ -318,6 +322,7 @@ static int iwn_read_firmware_leg(struct iwn_softc *, static int iwn_read_firmware_tlv(struct iwn_softc *, struct iwn_fw_info *, uint16_t); static int iwn_read_firmware(struct iwn_softc *); +static void iwn_unload_firmware(struct iwn_softc *); static int iwn_clock_wait(struct iwn_softc *); static int iwn_apm_init(struct iwn_softc *); static void iwn_apm_stop_master(struct iwn_softc *); @@ -665,6 +670,7 @@ iwn_attach(device_t dev) ic->ic_set_channel = iwn_set_channel; ic->ic_scan_curchan = iwn_scan_curchan; ic->ic_scan_mindwell = iwn_scan_mindwell; + ic->ic_getradiocaps = iwn_getradiocaps; ic->ic_setregdomain = iwn_setregdomain; iwn_radiotap_attach(sc); @@ -2370,9 +2376,9 @@ iwn_eeprom_channel_flags(struct iwn_eeprom_chan *channel) } static void -iwn_read_eeprom_band(struct iwn_softc *sc, int n) +iwn_read_eeprom_band(struct iwn_softc *sc, int n, int maxchans, int *nchans, + struct ieee80211_channel chans[]) { - struct ieee80211com *ic = &sc->sc_ic; struct iwn_eeprom_chan *channels = sc->eeprom_channels[n]; const struct iwn_chan_band *band = &iwn_bands[n]; struct ieee80211_channel *c; @@ -2389,10 +2395,14 @@ iwn_read_eeprom_band(struct iwn_softc *sc, int n) channels[i].maxpwr); continue; } + + if (*nchans >= maxchans) + break; + chan = band->chan[i]; nflags = iwn_eeprom_channel_flags(&channels[i]); - c = &ic->ic_channels[ic->ic_nchans++]; + c = &chans[(*nchans)++]; c->ic_ieee = chan; c->ic_maxregpower = channels[i].maxpwr; c->ic_maxpower = 2*c->ic_maxregpower; @@ -2401,7 +2411,11 @@ iwn_read_eeprom_band(struct iwn_softc *sc, int n) c->ic_freq = ieee80211_ieee2mhz(chan, IEEE80211_CHAN_G); /* G =>'s B is supported */ c->ic_flags = IEEE80211_CHAN_B | nflags; - c = &ic->ic_channels[ic->ic_nchans++]; + + if (*nchans >= maxchans) + break; + + c = &chans[(*nchans)++]; c[0] = c[-1]; c->ic_flags = IEEE80211_CHAN_G | nflags; } else { /* 5GHz band */ @@ -2417,8 +2431,11 @@ iwn_read_eeprom_band(struct iwn_softc *sc, int n) channels[i].flags, channels[i].maxpwr); if (sc->sc_flags & IWN_FLAG_HAS_11N) { + if (*nchans >= maxchans) + break; + /* add HT20, HT40 added separately */ - c = &ic->ic_channels[ic->ic_nchans++]; + c = &chans[(*nchans)++]; c[0] = c[-1]; c->ic_flags |= IEEE80211_CHAN_HT20; } @@ -2429,7 +2446,8 @@ iwn_read_eeprom_band(struct iwn_softc *sc, int n) } static void -iwn_read_eeprom_ht40(struct iwn_softc *sc, int n) +iwn_read_eeprom_ht40(struct iwn_softc *sc, int n, int maxchans, int *nchans, + struct ieee80211_channel chans[]) { struct ieee80211com *ic = &sc->sc_ic; struct iwn_eeprom_chan *channels = sc->eeprom_channels[n]; @@ -2453,6 +2471,10 @@ iwn_read_eeprom_ht40(struct iwn_softc *sc, int n) channels[i].maxpwr); continue; } + + if (*nchans + 1 >= maxchans) + break; + chan = band->chan[i]; nflags = iwn_eeprom_channel_flags(&channels[i]); @@ -2480,12 +2502,12 @@ iwn_read_eeprom_ht40(struct iwn_softc *sc, int n) "add ht40 chan %d flags 0x%x maxpwr %d\n", chan, channels[i].flags, channels[i].maxpwr); - c = &ic->ic_channels[ic->ic_nchans++]; + c = &chans[(*nchans)++]; c[0] = cent[0]; c->ic_extieee = extc->ic_ieee; c->ic_flags &= ~IEEE80211_CHAN_HT; c->ic_flags |= IEEE80211_CHAN_HT40U | nflags; - c = &ic->ic_channels[ic->ic_nchans++]; + c = &chans[(*nchans)++]; c[0] = extc[0]; c->ic_extieee = cent->ic_ieee; c->ic_flags &= ~IEEE80211_CHAN_HT; @@ -2504,10 +2526,13 @@ iwn_read_eeprom_channels(struct iwn_softc *sc, int n, uint32_t addr) iwn_read_prom_data(sc, addr, &sc->eeprom_channels[n], iwn_bands[n].nchan * sizeof (struct iwn_eeprom_chan)); - if (n < 5) - iwn_read_eeprom_band(sc, n); - else - iwn_read_eeprom_ht40(sc, n); + if (n < 5) { + iwn_read_eeprom_band(sc, n, IEEE80211_CHAN_MAX, &ic->ic_nchans, + ic->ic_channels); + } else { + iwn_read_eeprom_ht40(sc, n, IEEE80211_CHAN_MAX, &ic->ic_nchans, + ic->ic_channels); + } ieee80211_sort_channels(ic->ic_channels, ic->ic_nchans); } @@ -2537,6 +2562,20 @@ iwn_find_eeprom_channel(struct iwn_softc *sc, struct ieee80211_channel *c) return NULL; } +static void +iwn_getradiocaps(struct ieee80211com *ic, + int maxchans, int *nchans, struct ieee80211_channel chans[]) +{ + struct iwn_softc *sc = ic->ic_softc; + int i; + + /* Parse the list of authorized channels. */ + for (i = 0; i < 5 && *nchans < maxchans; i++) + iwn_read_eeprom_band(sc, i, maxchans, nchans, chans); + for (i = 5; i < IWN_NBANDS - 1 && *nchans < maxchans; i++) + iwn_read_eeprom_ht40(sc, i, maxchans, nchans, chans); +} + /* * Enforce flags read from EEPROM. */ @@ -8200,9 +8239,8 @@ iwn_read_firmware(struct iwn_softc *sc) if (fw->size < sizeof (uint32_t)) { device_printf(sc->sc_dev, "%s: firmware too short: %zu bytes\n", __func__, fw->size); - firmware_put(sc->fw_fp, FIRMWARE_UNLOAD); - sc->fw_fp = NULL; - return EINVAL; + error = EINVAL; + goto fail; } /* Retrieve text and data sections. */ @@ -8214,9 +8252,7 @@ iwn_read_firmware(struct iwn_softc *sc) device_printf(sc->sc_dev, "%s: could not read firmware sections, error %d\n", __func__, error); - firmware_put(sc->fw_fp, FIRMWARE_UNLOAD); - sc->fw_fp = NULL; - return error; + goto fail; } device_printf(sc->sc_dev, "%s: ucode rev=0x%08x\n", __func__, sc->ucode_rev); @@ -8230,13 +8266,22 @@ iwn_read_firmware(struct iwn_softc *sc) (fw->boot.textsz & 3) != 0) { device_printf(sc->sc_dev, "%s: firmware sections too large\n", __func__); - firmware_put(sc->fw_fp, FIRMWARE_UNLOAD); - sc->fw_fp = NULL; - return EINVAL; + error = EINVAL; + goto fail; } /* We can proceed with loading the firmware. */ return 0; + +fail: iwn_unload_firmware(sc); + return error; +} + +static void +iwn_unload_firmware(struct iwn_softc *sc) +{ + firmware_put(sc->fw_fp, FIRMWARE_UNLOAD); + sc->fw_fp = NULL; } static int @@ -8724,8 +8769,7 @@ iwn_init_locked(struct iwn_softc *sc) /* Initialize hardware and upload firmware. */ error = iwn_hw_init(sc); - firmware_put(sc->fw_fp, FIRMWARE_UNLOAD); - sc->fw_fp = NULL; + iwn_unload_firmware(sc); if (error != 0) { device_printf(sc->sc_dev, "%s: could not initialize hardware, error %d\n", __func__, diff --git a/sys/dev/ixgbe/if_ix.c b/sys/dev/ixgbe/if_ix.c index c7ac593..90d70d9 100644 --- a/sys/dev/ixgbe/if_ix.c +++ b/sys/dev/ixgbe/if_ix.c @@ -2947,12 +2947,7 @@ ixgbe_config_link(struct adapter *adapter) sfp = ixgbe_is_sfp(hw); if (sfp) { - if (hw->phy.multispeed_fiber) { - hw->mac.ops.setup_sfp(hw); - ixgbe_enable_tx_laser(hw); - taskqueue_enqueue(adapter->tq, &adapter->msf_task); - } else - taskqueue_enqueue(adapter->tq, &adapter->mod_task); + taskqueue_enqueue(adapter->tq, &adapter->mod_task); } else { if (hw->mac.ops.check_link) err = ixgbe_check_link(hw, &adapter->link_speed, @@ -3758,23 +3753,66 @@ ixgbe_handle_mod(void *context, int pending) { struct adapter *adapter = context; struct ixgbe_hw *hw = &adapter->hw; + enum ixgbe_phy_type orig_type = hw->phy.type; device_t dev = adapter->dev; u32 err; + IXGBE_CORE_LOCK(adapter); + + /* Check to see if the PHY type changed */ + if (hw->phy.ops.identify) { + hw->phy.type = ixgbe_phy_unknown; + hw->phy.ops.identify(hw); + } + + if (hw->phy.type != orig_type) { + device_printf(dev, "Detected phy_type %d\n", hw->phy.type); + + if (hw->phy.type == ixgbe_phy_none) { + hw->phy.sfp_type = ixgbe_sfp_type_unknown; + goto out; + } + + /* Try to do the initialization that was skipped before */ + if (hw->phy.ops.init) + hw->phy.ops.init(hw); + if (hw->phy.ops.reset) + hw->phy.ops.reset(hw); + } + err = hw->phy.ops.identify_sfp(hw); if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) { device_printf(dev, "Unsupported SFP+ module type was detected.\n"); - return; + goto out; } err = hw->mac.ops.setup_sfp(hw); if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) { device_printf(dev, "Setup failure - unsupported SFP+ module type.\n"); - return; + goto out; } - taskqueue_enqueue(adapter->tq, &adapter->msf_task); + if (hw->phy.multispeed_fiber) + taskqueue_enqueue(adapter->tq, &adapter->msf_task); +out: + /* Update media type */ + switch (hw->mac.ops.get_media_type(hw)) { + case ixgbe_media_type_fiber: + adapter->optics = IFM_10G_SR; + break; + case ixgbe_media_type_copper: + adapter->optics = IFM_10G_TWINAX; + break; + case ixgbe_media_type_cx4: + adapter->optics = IFM_10G_CX4; + break; + default: + adapter->optics = 0; + break; + } + + IXGBE_CORE_UNLOCK(adapter); return; } @@ -3790,6 +3828,7 @@ ixgbe_handle_msf(void *context, int pending) u32 autoneg; bool negotiate; + IXGBE_CORE_LOCK(adapter); /* get_supported_phy_layer will call hw->phy.ops.identify_sfp() */ adapter->phy_layer = ixgbe_get_supported_physical_layer(hw); @@ -3802,6 +3841,7 @@ ixgbe_handle_msf(void *context, int pending) /* Adjust media types shown in ifconfig */ ifmedia_removeall(&adapter->media); ixgbe_add_media_types(adapter); + IXGBE_CORE_UNLOCK(adapter); return; } diff --git a/sys/dev/ixgbe/if_ixv.c b/sys/dev/ixgbe/if_ixv.c index 0b147d4..20358ad 100644 --- a/sys/dev/ixgbe/if_ixv.c +++ b/sys/dev/ixgbe/if_ixv.c @@ -1664,7 +1664,7 @@ ixv_initialize_receive_units(struct adapter *adapter) /* Disable the queue */ rxdctl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(i)); - rxdctl &= ~(IXGBE_RXDCTL_ENABLE | IXGBE_RXDCTL_VME); + rxdctl &= ~IXGBE_RXDCTL_ENABLE; IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(i), rxdctl); for (int j = 0; j < 10; j++) { if (IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(i)) & @@ -1698,8 +1698,7 @@ ixv_initialize_receive_units(struct adapter *adapter) rxr->tail = IXGBE_VFRDT(rxr->me); /* Do the queue enabling last */ - rxdctl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(i)); - rxdctl |= IXGBE_RXDCTL_ENABLE; + rxdctl |= IXGBE_RXDCTL_ENABLE | IXGBE_RXDCTL_VME; IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(i), rxdctl); for (int k = 0; k < 10; k++) { if (IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(i)) & diff --git a/sys/dev/ixl/if_ixl.c b/sys/dev/ixl/if_ixl.c index 0428140..505d4b4 100644 --- a/sys/dev/ixl/if_ixl.c +++ b/sys/dev/ixl/if_ixl.c @@ -6606,7 +6606,11 @@ ixl_iov_uninit(device_t dev) pf->veb_seid = 0; } +#if __FreeBSD_version > 1100022 if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) +#else + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) +#endif ixl_disable_intr(vsi); vfs = pf->vfs; diff --git a/sys/dev/malo/if_malo.c b/sys/dev/malo/if_malo.c index d02b6d5..ff48708 100644 --- a/sys/dev/malo/if_malo.c +++ b/sys/dev/malo/if_malo.c @@ -173,7 +173,7 @@ malo_attach(uint16_t devid, struct malo_softc *sc) struct ieee80211com *ic = &sc->malo_ic; struct malo_hal *mh; int error; - uint8_t bands; + uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)]; MALO_LOCK_INIT(sc); callout_init_mtx(&sc->malo_watchdog_timer, &sc->malo_mtx, 0); @@ -222,10 +222,10 @@ malo_attach(uint16_t devid, struct malo_softc *sc) sc->malo_hwspecs.wcbbase[2], sc->malo_hwspecs.wcbbase[3]); /* NB: firmware looks that it does not export regdomain info API. */ - bands = 0; - setbit(&bands, IEEE80211_MODE_11B); - setbit(&bands, IEEE80211_MODE_11G); - ieee80211_init_channels(ic, NULL, &bands); + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); + ieee80211_init_channels(ic, NULL, bands); sc->malo_txantenna = 0x2; /* h/w default */ sc->malo_rxantenna = 0xffff; /* h/w default */ diff --git a/sys/dev/netmap/if_em_netmap.h b/sys/dev/netmap/if_em_netmap.h index eae4f8c..28f2dd4 100644 --- a/sys/dev/netmap/if_em_netmap.h +++ b/sys/dev/netmap/if_em_netmap.h @@ -148,7 +148,7 @@ em_netmap_txsync(struct netmap_kring *kring, int flags) /* device-specific */ struct e1000_tx_desc *curr = &txr->tx_base[nic_i]; - struct em_buffer *txbuf = &txr->tx_buffers[nic_i]; + struct em_txbuffer *txbuf = &txr->tx_buffers[nic_i]; int flags = (slot->flags & NS_REPORT || nic_i == 0 || nic_i == report_frequency) ? E1000_TXD_CMD_RS : 0; @@ -239,12 +239,12 @@ em_netmap_rxsync(struct netmap_kring *kring, int flags) nm_i = netmap_idx_n2k(kring, nic_i); for (n = 0; ; n++) { // XXX no need to count - struct e1000_rx_desc *curr = &rxr->rx_base[nic_i]; - uint32_t staterr = le32toh(curr->status); + union e1000_rx_desc_extended *curr = &rxr->rx_base[nic_i]; + uint32_t staterr = le32toh(curr->wb.upper.status_error); if ((staterr & E1000_RXD_STAT_DD) == 0) break; - ring->slot[nm_i].len = le16toh(curr->length); + ring->slot[nm_i].len = le16toh(curr->wb.upper.length); ring->slot[nm_i].flags = slot_flags; bus_dmamap_sync(rxr->rxtag, rxr->rx_buffers[nic_i].map, BUS_DMASYNC_POSTREAD); @@ -271,19 +271,19 @@ em_netmap_rxsync(struct netmap_kring *kring, int flags) uint64_t paddr; void *addr = PNMB(na, slot, &paddr); - struct e1000_rx_desc *curr = &rxr->rx_base[nic_i]; - struct em_buffer *rxbuf = &rxr->rx_buffers[nic_i]; + union e1000_rx_desc_extended *curr = &rxr->rx_base[nic_i]; + struct em_rxbuffer *rxbuf = &rxr->rx_buffers[nic_i]; if (addr == NETMAP_BUF_BASE(na)) /* bad buf */ goto ring_reset; if (slot->flags & NS_BUF_CHANGED) { /* buffer has changed, reload map */ - curr->buffer_addr = htole64(paddr); + curr->read.buffer_addr = htole64(paddr); netmap_reload_map(na, rxr->rxtag, rxbuf->map, addr); slot->flags &= ~NS_BUF_CHANGED; } - curr->status = 0; + curr->wb.upper.status_error = 0; bus_dmamap_sync(rxr->rxtag, rxbuf->map, BUS_DMASYNC_PREREAD); nm_i = nm_next(nm_i, lim); diff --git a/sys/dev/nvd/nvd.c b/sys/dev/nvd/nvd.c index f459e06..24ee075 100644 --- a/sys/dev/nvd/nvd.c +++ b/sys/dev/nvd/nvd.c @@ -47,6 +47,8 @@ struct nvd_disk; static disk_ioctl_t nvd_ioctl; static disk_strategy_t nvd_strategy; +static void nvd_done(void *arg, const struct nvme_completion *cpl); + static void *nvd_new_disk(struct nvme_namespace *ns, void *ctrlr); static void destroy_geom_disk(struct nvd_disk *ndisk); @@ -71,6 +73,7 @@ struct nvd_disk { struct nvme_namespace *ns; uint32_t cur_depth; + uint32_t ordered_in_flight; TAILQ_ENTRY(nvd_disk) global_tailq; TAILQ_ENTRY(nvd_disk) ctrlr_tailq; @@ -148,6 +151,28 @@ nvd_unload() nvme_unregister_consumer(consumer_handle); } +static int +nvd_bio_submit(struct nvd_disk *ndisk, struct bio *bp) +{ + int err; + + bp->bio_driver1 = NULL; + atomic_add_int(&ndisk->cur_depth, 1); + err = nvme_ns_bio_process(ndisk->ns, bp, nvd_done); + if (err) { + atomic_add_int(&ndisk->cur_depth, -1); + if (__predict_false(bp->bio_flags & BIO_ORDERED)) + atomic_add_int(&ndisk->ordered_in_flight, -1); + bp->bio_error = err; + bp->bio_flags |= BIO_ERROR; + bp->bio_resid = bp->bio_bcount; + biodone(bp); + return (-1); + } + + return (0); +} + static void nvd_strategy(struct bio *bp) { @@ -155,6 +180,18 @@ nvd_strategy(struct bio *bp) ndisk = (struct nvd_disk *)bp->bio_disk->d_drv1; + if (__predict_false(bp->bio_flags & BIO_ORDERED)) + atomic_add_int(&ndisk->ordered_in_flight, 1); + + if (__predict_true(ndisk->ordered_in_flight == 0)) { + nvd_bio_submit(ndisk, bp); + return; + } + + /* + * There are ordered bios in flight, so we need to submit + * bios through the task queue to enforce ordering. + */ mtx_lock(&ndisk->bioqlock); bioq_insert_tail(&ndisk->bioq, bp); mtx_unlock(&ndisk->bioqlock); @@ -186,6 +223,8 @@ nvd_done(void *arg, const struct nvme_completion *cpl) ndisk = bp->bio_disk->d_drv1; atomic_add_int(&ndisk->cur_depth, -1); + if (__predict_false(bp->bio_flags & BIO_ORDERED)) + atomic_add_int(&ndisk->ordered_in_flight, -1); biodone(bp); } @@ -195,7 +234,6 @@ nvd_bioq_process(void *arg, int pending) { struct nvd_disk *ndisk = arg; struct bio *bp; - int err; for (;;) { mtx_lock(&ndisk->bioqlock); @@ -204,30 +242,8 @@ nvd_bioq_process(void *arg, int pending) if (bp == NULL) break; -#ifdef BIO_ORDERED - /* - * BIO_ORDERED flag dictates that all outstanding bios - * must be completed before processing the bio with - * BIO_ORDERED flag set. - */ - if (bp->bio_flags & BIO_ORDERED) { - while (ndisk->cur_depth > 0) { - pause("nvd flush", 1); - } - } -#endif - - bp->bio_driver1 = NULL; - atomic_add_int(&ndisk->cur_depth, 1); - - err = nvme_ns_bio_process(ndisk->ns, bp, nvd_done); - - if (err) { - atomic_add_int(&ndisk->cur_depth, -1); - bp->bio_error = err; - bp->bio_flags |= BIO_ERROR; - bp->bio_resid = bp->bio_bcount; - biodone(bp); + if (nvd_bio_submit(ndisk, bp) != 0) { + continue; } #ifdef BIO_ORDERED @@ -287,7 +303,7 @@ nvd_new_disk(struct nvme_namespace *ns, void *ctrlr_arg) disk->d_unit = TAILQ_LAST(&disk_head, disk_list)->disk->d_unit + 1; - disk->d_flags = 0; + disk->d_flags = DISKFLAG_DIRECT_COMPLETION; if (nvme_ns_get_flags(ns) & NVME_NS_DEALLOCATE_SUPPORTED) disk->d_flags |= DISKFLAG_CANDELETE; @@ -317,6 +333,7 @@ nvd_new_disk(struct nvme_namespace *ns, void *ctrlr_arg) ndisk->ns = ns; ndisk->disk = disk; ndisk->cur_depth = 0; + ndisk->ordered_in_flight = 0; mtx_init(&ndisk->bioqlock, "NVD bioq lock", NULL, MTX_DEF); bioq_init(&ndisk->bioq); diff --git a/sys/dev/nvme/nvme.c b/sys/dev/nvme/nvme.c index cc14d34..9db2b14 100644 --- a/sys/dev/nvme/nvme.c +++ b/sys/dev/nvme/nvme.c @@ -270,8 +270,6 @@ nvme_attach(device_t dev) return (status); } - nvme_sysctl_initialize_ctrlr(ctrlr); - pci_enable_busmaster(dev); ctrlr->config_hook.ich_func = nvme_ctrlr_start_config_hook; diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c index ee4b901..e400f52 100644 --- a/sys/dev/nvme/nvme_ctrlr.c +++ b/sys/dev/nvme/nvme_ctrlr.c @@ -1,5 +1,5 @@ /*- - * Copyright (C) 2012-2015 Intel Corporation + * Copyright (C) 2012-2016 Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); static void nvme_ctrlr_construct_and_submit_aer(struct nvme_controller *ctrlr, struct nvme_async_event_request *aer); +static void nvme_ctrlr_setup_interrupts(struct nvme_controller *ctrlr); static int nvme_ctrlr_allocate_bar(struct nvme_controller *ctrlr) @@ -140,6 +141,13 @@ nvme_ctrlr_construct_io_qpairs(struct nvme_controller *ctrlr) */ num_trackers = min(num_trackers, (num_entries-1)); + /* + * This was calculated previously when setting up interrupts, but + * a controller could theoretically support fewer I/O queues than + * MSI-X vectors. So calculate again here just to be safe. + */ + ctrlr->num_cpus_per_ioq = howmany(mp_ncpus, ctrlr->num_io_queues); + ctrlr->ioq = malloc(ctrlr->num_io_queues * sizeof(struct nvme_qpair), M_NVME, M_ZERO | M_WAITOK); @@ -160,8 +168,13 @@ nvme_ctrlr_construct_io_qpairs(struct nvme_controller *ctrlr) num_trackers, ctrlr); - if (ctrlr->per_cpu_io_queues) - bus_bind_intr(ctrlr->dev, qpair->res, i); + /* + * Do not bother binding interrupts if we only have one I/O + * interrupt thread for this controller. + */ + if (ctrlr->num_io_queues > 1) + bus_bind_intr(ctrlr->dev, qpair->res, + i * ctrlr->num_cpus_per_ioq); } return (0); @@ -306,8 +319,15 @@ nvme_ctrlr_hw_reset(struct nvme_controller *ctrlr) int i; nvme_admin_qpair_disable(&ctrlr->adminq); - for (i = 0; i < ctrlr->num_io_queues; i++) - nvme_io_qpair_disable(&ctrlr->ioq[i]); + /* + * I/O queues are not allocated before the initial HW + * reset, so do not try to disable them. Use is_initialized + * to determine if this is the initial HW reset. + */ + if (ctrlr->is_initialized) { + for (i = 0; i < ctrlr->num_io_queues; i++) + nvme_io_qpair_disable(&ctrlr->ioq[i]); + } DELAY(100*1000); @@ -363,7 +383,7 @@ static int nvme_ctrlr_set_num_qpairs(struct nvme_controller *ctrlr) { struct nvme_completion_poll_status status; - int cq_allocated, i, sq_allocated; + int cq_allocated, sq_allocated; status.done = FALSE; nvme_ctrlr_cmd_set_num_queues(ctrlr, ctrlr->num_io_queues, @@ -384,26 +404,12 @@ nvme_ctrlr_set_num_qpairs(struct nvme_controller *ctrlr) cq_allocated = (status.cpl.cdw0 >> 16) + 1; /* - * Check that the controller was able to allocate the number of - * queues we requested. If not, revert to one IO queue pair. + * Controller may allocate more queues than we requested, + * so use the minimum of the number requested and what was + * actually allocated. */ - if (sq_allocated < ctrlr->num_io_queues || - cq_allocated < ctrlr->num_io_queues) { - - /* - * Destroy extra IO queue pairs that were created at - * controller construction time but are no longer - * needed. This will only happen when a controller - * supports fewer queues than MSI-X vectors. This - * is not the normal case, but does occur with the - * Chatham prototype board. - */ - for (i = 1; i < ctrlr->num_io_queues; i++) - nvme_io_qpair_destroy(&ctrlr->ioq[i]); - - ctrlr->num_io_queues = 1; - ctrlr->per_cpu_io_queues = 0; - } + ctrlr->num_io_queues = min(ctrlr->num_io_queues, sq_allocated); + ctrlr->num_io_queues = min(ctrlr->num_io_queues, cq_allocated); return (0); } @@ -687,9 +693,20 @@ static void nvme_ctrlr_start(void *ctrlr_arg) { struct nvme_controller *ctrlr = ctrlr_arg; + uint32_t old_num_io_queues; int i; - nvme_qpair_reset(&ctrlr->adminq); + /* + * Only reset adminq here when we are restarting the + * controller after a reset. During initialization, + * we have already submitted admin commands to get + * the number of I/O queues supported, so cannot reset + * the adminq again here. + */ + if (ctrlr->is_resetting) { + nvme_qpair_reset(&ctrlr->adminq); + } + for (i = 0; i < ctrlr->num_io_queues; i++) nvme_qpair_reset(&ctrlr->ioq[i]); @@ -700,11 +717,25 @@ nvme_ctrlr_start(void *ctrlr_arg) return; } + /* + * The number of qpairs are determined during controller initialization, + * including using NVMe SET_FEATURES/NUMBER_OF_QUEUES to determine the + * HW limit. We call SET_FEATURES again here so that it gets called + * after any reset for controllers that depend on the driver to + * explicit specify how many queues it will use. This value should + * never change between resets, so panic if somehow that does happen. + */ + old_num_io_queues = ctrlr->num_io_queues; if (nvme_ctrlr_set_num_qpairs(ctrlr) != 0) { nvme_ctrlr_fail(ctrlr); return; } + if (old_num_io_queues != ctrlr->num_io_queues) { + panic("num_io_queues changed from %u to %u", old_num_io_queues, + ctrlr->num_io_queues); + } + if (nvme_ctrlr_create_qpairs(ctrlr) != 0) { nvme_ctrlr_fail(ctrlr); return; @@ -727,7 +758,16 @@ nvme_ctrlr_start_config_hook(void *arg) { struct nvme_controller *ctrlr = arg; - nvme_ctrlr_start(ctrlr); + nvme_qpair_reset(&ctrlr->adminq); + nvme_admin_qpair_enable(&ctrlr->adminq); + + if (nvme_ctrlr_set_num_qpairs(ctrlr) == 0 && + nvme_ctrlr_construct_io_qpairs(ctrlr) == 0) + nvme_ctrlr_start(ctrlr); + else + nvme_ctrlr_fail(ctrlr); + + nvme_sysctl_initialize_ctrlr(ctrlr); config_intrhook_disestablish(&ctrlr->config_hook); ctrlr->is_initialized = 1; @@ -778,8 +818,9 @@ static int nvme_ctrlr_configure_intx(struct nvme_controller *ctrlr) { + ctrlr->msix_enabled = 0; ctrlr->num_io_queues = 1; - ctrlr->per_cpu_io_queues = 0; + ctrlr->num_cpus_per_ioq = mp_ncpus; ctrlr->rid = 0; ctrlr->res = bus_alloc_resource_any(ctrlr->dev, SYS_RES_IRQ, &ctrlr->rid, RF_SHAREABLE | RF_ACTIVE); @@ -926,13 +967,93 @@ static struct cdevsw nvme_ctrlr_cdevsw = { .d_ioctl = nvme_ctrlr_ioctl }; +static void +nvme_ctrlr_setup_interrupts(struct nvme_controller *ctrlr) +{ + device_t dev; + int per_cpu_io_queues; + int min_cpus_per_ioq; + int num_vectors_requested, num_vectors_allocated; + int num_vectors_available; + + dev = ctrlr->dev; + min_cpus_per_ioq = 1; + TUNABLE_INT_FETCH("hw.nvme.min_cpus_per_ioq", &min_cpus_per_ioq); + + if (min_cpus_per_ioq < 1) { + min_cpus_per_ioq = 1; + } else if (min_cpus_per_ioq > mp_ncpus) { + min_cpus_per_ioq = mp_ncpus; + } + + per_cpu_io_queues = 1; + TUNABLE_INT_FETCH("hw.nvme.per_cpu_io_queues", &per_cpu_io_queues); + + if (per_cpu_io_queues == 0) { + min_cpus_per_ioq = mp_ncpus; + } + + ctrlr->force_intx = 0; + TUNABLE_INT_FETCH("hw.nvme.force_intx", &ctrlr->force_intx); + + /* + * FreeBSD currently cannot allocate more than about 190 vectors at + * boot, meaning that systems with high core count and many devices + * requesting per-CPU interrupt vectors will not get their full + * allotment. So first, try to allocate as many as we may need to + * understand what is available, then immediately release them. + * Then figure out how many of those we will actually use, based on + * assigning an equal number of cores to each I/O queue. + */ + + /* One vector for per core I/O queue, plus one vector for admin queue. */ + num_vectors_available = min(pci_msix_count(dev), mp_ncpus + 1); + if (pci_alloc_msix(dev, &num_vectors_available) != 0) { + num_vectors_available = 0; + } + pci_release_msi(dev); + + if (ctrlr->force_intx || num_vectors_available < 2) { + nvme_ctrlr_configure_intx(ctrlr); + return; + } + + /* + * Do not use all vectors for I/O queues - one must be saved for the + * admin queue. + */ + ctrlr->num_cpus_per_ioq = max(min_cpus_per_ioq, + howmany(mp_ncpus, num_vectors_available - 1)); + + ctrlr->num_io_queues = howmany(mp_ncpus, ctrlr->num_cpus_per_ioq); + num_vectors_requested = ctrlr->num_io_queues + 1; + num_vectors_allocated = num_vectors_requested; + + /* + * Now just allocate the number of vectors we need. This should + * succeed, since we previously called pci_alloc_msix() + * successfully returning at least this many vectors, but just to + * be safe, if something goes wrong just revert to INTx. + */ + if (pci_alloc_msix(dev, &num_vectors_allocated) != 0) { + nvme_ctrlr_configure_intx(ctrlr); + return; + } + + if (num_vectors_allocated < num_vectors_requested) { + pci_release_msi(dev); + nvme_ctrlr_configure_intx(ctrlr); + return; + } + + ctrlr->msix_enabled = 1; +} + int nvme_ctrlr_construct(struct nvme_controller *ctrlr, device_t dev) { union cap_lo_register cap_lo; union cap_hi_register cap_hi; - int i, per_cpu_io_queues, rid; - int num_vectors_requested, num_vectors_allocated; int status, timeout_period; ctrlr->dev = dev; @@ -967,116 +1088,13 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, device_t dev) nvme_retry_count = NVME_DEFAULT_RETRY_COUNT; TUNABLE_INT_FETCH("hw.nvme.retry_count", &nvme_retry_count); - per_cpu_io_queues = 1; - TUNABLE_INT_FETCH("hw.nvme.per_cpu_io_queues", &per_cpu_io_queues); - ctrlr->per_cpu_io_queues = per_cpu_io_queues ? TRUE : FALSE; - - if (ctrlr->per_cpu_io_queues) - ctrlr->num_io_queues = mp_ncpus; - else - ctrlr->num_io_queues = 1; - - ctrlr->force_intx = 0; - TUNABLE_INT_FETCH("hw.nvme.force_intx", &ctrlr->force_intx); - ctrlr->enable_aborts = 0; TUNABLE_INT_FETCH("hw.nvme.enable_aborts", &ctrlr->enable_aborts); - ctrlr->msix_enabled = 1; - - if (ctrlr->force_intx) { - ctrlr->msix_enabled = 0; - goto intx; - } - - /* One vector per IO queue, plus one vector for admin queue. */ - num_vectors_requested = ctrlr->num_io_queues + 1; - - /* - * If we cannot even allocate 2 vectors (one for admin, one for - * I/O), then revert to INTx. - */ - if (pci_msix_count(dev) < 2) { - ctrlr->msix_enabled = 0; - goto intx; - } else if (pci_msix_count(dev) < num_vectors_requested) { - ctrlr->per_cpu_io_queues = FALSE; - ctrlr->num_io_queues = 1; - num_vectors_requested = 2; /* one for admin, one for I/O */ - } - - num_vectors_allocated = num_vectors_requested; - if (pci_alloc_msix(dev, &num_vectors_allocated) != 0) { - ctrlr->msix_enabled = 0; - goto intx; - } else if (num_vectors_allocated < num_vectors_requested) { - if (num_vectors_allocated < 2) { - pci_release_msi(dev); - ctrlr->msix_enabled = 0; - goto intx; - } else { - ctrlr->per_cpu_io_queues = FALSE; - ctrlr->num_io_queues = 1; - /* - * Release whatever vectors were allocated, and just - * reallocate the two needed for the admin and single - * I/O qpair. - */ - num_vectors_allocated = 2; - pci_release_msi(dev); - if (pci_alloc_msix(dev, &num_vectors_allocated) != 0) - panic("could not reallocate any vectors\n"); - if (num_vectors_allocated != 2) - panic("could not reallocate 2 vectors\n"); - } - } - - /* - * On earlier FreeBSD releases, there are reports that - * pci_alloc_msix() can return successfully with all vectors - * requested, but a subsequent bus_alloc_resource_any() - * for one of those vectors fails. This issue occurs more - * readily with multiple devices using per-CPU vectors. - * To workaround this issue, try to allocate the resources now, - * and fall back to INTx if we cannot allocate all of them. - * This issue cannot be reproduced on more recent versions of - * FreeBSD which have increased the maximum number of MSI-X - * vectors, but adding the workaround makes it easier for - * vendors wishing to import this driver into kernels based on - * older versions of FreeBSD. - */ - for (i = 0; i < num_vectors_allocated; i++) { - rid = i + 1; - ctrlr->msi_res[i] = bus_alloc_resource_any(ctrlr->dev, - SYS_RES_IRQ, &rid, RF_ACTIVE); - - if (ctrlr->msi_res[i] == NULL) { - ctrlr->msix_enabled = 0; - while (i > 0) { - i--; - bus_release_resource(ctrlr->dev, - SYS_RES_IRQ, - rman_get_rid(ctrlr->msi_res[i]), - ctrlr->msi_res[i]); - } - pci_release_msi(dev); - nvme_printf(ctrlr, "could not obtain all MSI-X " - "resources, reverting to intx\n"); - break; - } - } - -intx: - - if (!ctrlr->msix_enabled) - nvme_ctrlr_configure_intx(ctrlr); + nvme_ctrlr_setup_interrupts(ctrlr); ctrlr->max_xfer_size = NVME_MAX_XFER_SIZE; nvme_ctrlr_construct_admin_qpair(ctrlr); - status = nvme_ctrlr_construct_io_qpairs(ctrlr); - - if (status != 0) - return (status); ctrlr->cdev = make_dev(&nvme_ctrlr_cdevsw, device_get_unit(dev), UID_ROOT, GID_WHEEL, 0600, "nvme%d", device_get_unit(dev)); @@ -1188,11 +1206,7 @@ nvme_ctrlr_submit_io_request(struct nvme_controller *ctrlr, { struct nvme_qpair *qpair; - if (ctrlr->per_cpu_io_queues) - qpair = &ctrlr->ioq[curcpu]; - else - qpair = &ctrlr->ioq[0]; - + qpair = &ctrlr->ioq[curcpu / ctrlr->num_cpus_per_ioq]; nvme_qpair_submit_request(qpair, req); } diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h index 6137b41..3330711 100644 --- a/sys/dev/nvme/nvme_private.h +++ b/sys/dev/nvme/nvme_private.h @@ -265,7 +265,7 @@ struct nvme_controller { uint32_t enable_aborts; uint32_t num_io_queues; - boolean_t per_cpu_io_queues; + uint32_t num_cpus_per_ioq; /* Fields for tracking progress during controller initialization. */ struct intr_config_hook config_hook; @@ -276,8 +276,6 @@ struct nvme_controller { struct task fail_req_task; struct taskqueue *taskqueue; - struct resource *msi_res[MAXCPU + 1]; - /* For shared legacy interrupt. */ int rid; struct resource *res; diff --git a/sys/dev/nvme/nvme_qpair.c b/sys/dev/nvme/nvme_qpair.c index d0cb8c6..92fe672 100644 --- a/sys/dev/nvme/nvme_qpair.c +++ b/sys/dev/nvme/nvme_qpair.c @@ -479,8 +479,9 @@ nvme_qpair_construct(struct nvme_qpair *qpair, uint32_t id, * the queue's vector to get the corresponding rid to use. */ qpair->rid = vector + 1; - qpair->res = ctrlr->msi_res[vector]; + qpair->res = bus_alloc_resource_any(ctrlr->dev, SYS_RES_IRQ, + &qpair->rid, RF_ACTIVE); bus_setup_intr(ctrlr->dev, qpair->res, INTR_TYPE_MISC | INTR_MPSAFE, NULL, nvme_qpair_msix_handler, qpair, &qpair->tag); diff --git a/sys/dev/nvme/nvme_sysctl.c b/sys/dev/nvme/nvme_sysctl.c index 8b99111..08cd15e 100644 --- a/sys/dev/nvme/nvme_sysctl.c +++ b/sys/dev/nvme/nvme_sysctl.c @@ -1,5 +1,5 @@ /*- - * Copyright (C) 2012-2013 Intel Corporation + * Copyright (C) 2012-2016 Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -267,6 +267,10 @@ nvme_sysctl_initialize_ctrlr(struct nvme_controller *ctrlr) ctrlr_tree = device_get_sysctl_tree(ctrlr->dev); ctrlr_list = SYSCTL_CHILDREN(ctrlr_tree); + SYSCTL_ADD_UINT(ctrlr_ctx, ctrlr_list, OID_AUTO, "num_cpus_per_ioq", + CTLFLAG_RD, &ctrlr->num_cpus_per_ioq, 0, + "Number of CPUs assigned per I/O queue pair"); + SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, "int_coal_time", CTLTYPE_UINT | CTLFLAG_RW, ctrlr, 0, nvme_sysctl_int_coal_time, "IU", diff --git a/sys/dev/ofw/ofw_bus_subr.c b/sys/dev/ofw/ofw_bus_subr.c index c286373..60a341c 100644 --- a/sys/dev/ofw/ofw_bus_subr.c +++ b/sys/dev/ofw/ofw_bus_subr.c @@ -361,10 +361,11 @@ ofw_bus_search_intrmap(void *intr, int intrsz, void *regs, int physsz, paddrsz = 0; while (i > 0) { bcopy(mptr + physsz + intrsz, &parent, sizeof(parent)); -#ifdef OFW_EPAPR +#ifndef OFW_IMAP_NO_IPARENT_ADDR_CELLS /* - * Find if we need to read the parent address data. Sparc64 - * uses a different encoding that doesn't include this data. + * Find if we need to read the parent address data. + * CHRP-derived OF bindings, including ePAPR-compliant FDTs, + * use this as an optional part of the specifier. */ if (OF_getencprop(OF_node_from_xref(parent), "#address-cells", &paddrsz, sizeof(paddrsz)) == -1) diff --git a/sys/dev/otus/if_otus.c b/sys/dev/otus/if_otus.c index 160b05e..daa9626 100644 --- a/sys/dev/otus/if_otus.c +++ b/sys/dev/otus/if_otus.c @@ -624,8 +624,8 @@ otus_attachhook(struct otus_softc *sc) struct ieee80211com *ic = &sc->sc_ic; usb_device_request_t req; uint32_t in, out; + uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)]; int error; - uint8_t bands; /* Not locked */ error = otus_load_firmware(sc, "otusfw_init", AR_FW_INIT_ADDR); @@ -743,19 +743,19 @@ otus_attachhook(struct otus_softc *sc) otus_get_chanlist(sc); #else /* Set supported .11b and .11g rates. */ - bands = 0; + memset(bands, 0, sizeof(bands)); if (sc->eeprom.baseEepHeader.opCapFlags & AR5416_OPFLAGS_11G) { - setbit(&bands, IEEE80211_MODE_11B); - setbit(&bands, IEEE80211_MODE_11G); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); } if (sc->eeprom.baseEepHeader.opCapFlags & AR5416_OPFLAGS_11A) { - setbit(&bands, IEEE80211_MODE_11A); + setbit(bands, IEEE80211_MODE_11A); } #if 0 if (sc->sc_ht) - setbit(&bands, IEEE80211_MODE_11NG); + setbit(bands, IEEE80211_MODE_11NG); #endif - ieee80211_init_channels(ic, NULL, &bands); + ieee80211_init_channels(ic, NULL, bands); #endif ieee80211_ifattach(ic); diff --git a/sys/dev/puc/pucdata.c b/sys/dev/puc/pucdata.c index b953146..d8ca258 100644 --- a/sys/dev/puc/pucdata.c +++ b/sys/dev/puc/pucdata.c @@ -42,12 +42,16 @@ __FBSDID("$FreeBSD$"); #include <machine/bus.h> #include <sys/rman.h> +#include <dev/ic/ns16550.h> + +#include <dev/pci/pcireg.h> #include <dev/pci/pcivar.h> #include <dev/puc/puc_bus.h> #include <dev/puc/puc_cfg.h> #include <dev/puc/puc_bfe.h> +static puc_config_f puc_config_advantech; static puc_config_f puc_config_amc; static puc_config_f puc_config_diva; static puc_config_f puc_config_exar; @@ -691,10 +695,25 @@ const struct puc_cfg puc_pci_devices[] = { .config_function = puc_config_exar_pcie }, + /* + * The Advantech PCI-1602 Rev. A use the first two ports of an Oxford + * Semiconductor OXuPCI954. Note these boards have a hardware bug in + * that they drive the RS-422/485 transmitters after power-on until a + * driver initalizes the UARTs. + */ { 0x13fe, 0x1600, 0x1602, 0x0002, - "Advantech PCI-1602", + "Advantech PCI-1602 Rev. A", DEFAULT_RCLK * 8, PUC_PORT_2S, 0x10, 0, 8, + .config_function = puc_config_advantech + }, + + /* Advantech PCI-1602 Rev. B1/PCI-1603 are also based on OXuPCI952. */ + { 0x13fe, 0xa102, 0x13fe, 0xa102, + "Advantech 2-port PCI (PCI-1602 Rev. B1/PCI-1603)", + DEFAULT_RCLK * 8, + PUC_PORT_2S, 0x10, 4, 0, + .config_function = puc_config_advantech }, { 0x1407, 0x0100, 0xffff, 0, @@ -1256,6 +1275,92 @@ const struct puc_cfg puc_pci_devices[] = { }; static int +puc_config_advantech(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port, + intptr_t *res __unused) +{ + const struct puc_cfg *cfg; + struct resource *cres; + struct puc_bar *bar; + device_t cdev, dev; + bus_size_t off; + int base, crtype, fixed, high, i, oxpcie; + uint8_t acr, func, mask; + + if (cmd != PUC_CFG_SETUP) + return (ENXIO); + + base = fixed = oxpcie = 0; + crtype = SYS_RES_IOPORT; + acr = mask = 0x0; + func = high = 1; + off = 0x60; + + cfg = sc->sc_cfg; + switch (cfg->subvendor) { + case 0x13fe: + switch (cfg->device) { + case 0xa102: + high = 0; + break; + default: + break; + } + default: + break; + } + if (fixed == 1) + goto setup; + + dev = sc->sc_dev; + cdev = pci_find_dbsf(pci_get_domain(dev), pci_get_bus(dev), + pci_get_slot(dev), func); + if (cdev == NULL) { + device_printf(dev, "could not find config function\n"); + return (ENXIO); + } + + i = PCIR_BAR(0); + cres = bus_alloc_resource_any(cdev, crtype, &i, RF_ACTIVE); + if (cres == NULL) { + device_printf(dev, "could not allocate config resource\n"); + return (ENXIO); + } + + if (oxpcie == 0) { + mask = bus_read_1(cres, off); + if (pci_get_function(dev) == 1) + base = 4; + } + + setup: + for (i = 0; i < sc->sc_nports; ++i) { + device_printf(dev, "port %d: ", i); + bar = puc_get_bar(sc, cfg->rid + i * cfg->d_rid); + if (bar == NULL) { + printf("could not get BAR\n"); + continue; + } + + if (fixed == 0) { + if ((mask & (1 << (base + i))) == 0) { + acr = 0; + printf("RS-232\n"); + } else { + acr = (high == 1 ? 0x18 : 0x10); + printf("RS-422/RS-485, active-%s auto-DTR\n", + high == 1 ? "high" : "low"); + } + } + + bus_write_1(bar->b_res, REG_SPR, REG_ACR); + bus_write_1(bar->b_res, REG_ICR, acr); + } + + bus_release_resource(cdev, crtype, rman_get_rid(cres), cres); + return (0); +} + +static int puc_config_amc(struct puc_softc *sc __unused, enum puc_cfg_cmd cmd, int port, intptr_t *res) { @@ -1360,24 +1465,17 @@ puc_config_quatech(struct puc_softc *sc, enum puc_cfg_cmd cmd, bar = puc_get_bar(sc, cfg->rid); if (bar == NULL) return (ENXIO); - /* Set DLAB in the LCR register of UART 0. */ - bus_write_1(bar->b_res, 3, 0x80); - /* Write 0 to the SPR register of UART 0. */ - bus_write_1(bar->b_res, 7, 0); - /* Read back the contents of the SPR register of UART 0. */ - v0 = bus_read_1(bar->b_res, 7); - /* Write a specific value to the SPR register of UART 0. */ - bus_write_1(bar->b_res, 7, 0x80 + -cfg->clock); - /* Read back the contents of the SPR register of UART 0. */ - v1 = bus_read_1(bar->b_res, 7); - /* Clear DLAB in the LCR register of UART 0. */ - bus_write_1(bar->b_res, 3, 0); - /* Save the two values read-back from the SPR register. */ + bus_write_1(bar->b_res, REG_LCR, LCR_DLAB); + bus_write_1(bar->b_res, REG_SPR, 0); + v0 = bus_read_1(bar->b_res, REG_SPR); + bus_write_1(bar->b_res, REG_SPR, 0x80 + -cfg->clock); + v1 = bus_read_1(bar->b_res, REG_SPR); + bus_write_1(bar->b_res, REG_LCR, 0); sc->sc_cfg_data = (v0 << 8) | v1; if (v0 == 0 && v1 == 0x80 + -cfg->clock) { /* * The SPR register echoed the two values written - * by us. This means that the SPAD jumper is set. + * by us. This means that the SPAD jumper is set. */ device_printf(sc->sc_dev, "warning: extra features " "not usable -- SPAD compatibility enabled\n"); @@ -1385,7 +1483,7 @@ puc_config_quatech(struct puc_softc *sc, enum puc_cfg_cmd cmd, } if (v0 != 0) { /* - * The first value doesn't match. This can only mean + * The first value doesn't match. This can only mean * that the SPAD jumper is not set and that a non- * standard fixed clock multiplier jumper is set. */ @@ -1399,8 +1497,8 @@ puc_config_quatech(struct puc_softc *sc, enum puc_cfg_cmd cmd, return (0); } /* - * The first value matched, but the second didn't. We know - * that the SPAD jumper is not set. We also know that the + * The first value matched, but the second didn't. We know + * that the SPAD jumper is not set. We also know that the * clock rate multiplier is software controlled *and* that * we just programmed it to the maximum allowed. */ @@ -1415,8 +1513,8 @@ puc_config_quatech(struct puc_softc *sc, enum puc_cfg_cmd cmd, /* * XXX With the SPAD jumper applied, there's no * easy way of knowing if there's also a clock - * rate multiplier jumper installed. Let's hope - * not... + * rate multiplier jumper installed. Let's hope + * not ... */ *res = DEFAULT_RCLK; } else if (v0 == 0) { @@ -1678,15 +1776,15 @@ puc_config_oxford_pcie(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port, case PUC_CFG_GET_NPORTS: /* * Check if we are being called from puc_bfe_attach() - * or puc_bfe_probe(). If puc_bfe_probe(), we cannot - * puc_get_bar(), so we return a value of 16. This has cosmetic - * side-effects at worst; in PUC_CFG_GET_DESC, - * (int)sc->sc_cfg_data will not contain the true number of - * ports in PUC_CFG_GET_DESC, but we are not implementing that - * call for this device family anyway. + * or puc_bfe_probe(). If puc_bfe_probe(), we cannot + * puc_get_bar(), so we return a value of 16. This has + * cosmetic side-effects at worst; in PUC_CFG_GET_DESC, + * sc->sc_cfg_data will not contain the true number of + * ports in PUC_CFG_GET_DESC, but we are not implementing + * that call for this device family anyway. * - * The check is for initialisation of sc->sc_bar[idx], which is - * only done in puc_bfe_attach(). + * The check is for initialization of sc->sc_bar[idx], + * which is only done in puc_bfe_attach(). */ idx = 0; do { diff --git a/sys/dev/ral/rt2560.c b/sys/dev/ral/rt2560.c index d62c470..1ba2791 100644 --- a/sys/dev/ral/rt2560.c +++ b/sys/dev/ral/rt2560.c @@ -199,7 +199,7 @@ rt2560_attach(device_t dev, int id) { struct rt2560_softc *sc = device_get_softc(dev); struct ieee80211com *ic = &sc->sc_ic; - uint8_t bands; + uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)]; int error; sc->sc_dev = dev; @@ -278,12 +278,12 @@ rt2560_attach(device_t dev, int id) #endif ; - bands = 0; - setbit(&bands, IEEE80211_MODE_11B); - setbit(&bands, IEEE80211_MODE_11G); + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); if (sc->rf_rev == RT2560_RF_5222) - setbit(&bands, IEEE80211_MODE_11A); - ieee80211_init_channels(ic, NULL, &bands); + setbit(bands, IEEE80211_MODE_11A); + ieee80211_init_channels(ic, NULL, bands); ieee80211_ifattach(ic); ic->ic_raw_xmit = rt2560_raw_xmit; diff --git a/sys/dev/ral/rt2661.c b/sys/dev/ral/rt2661.c index a2e955c..a53d509 100644 --- a/sys/dev/ral/rt2661.c +++ b/sys/dev/ral/rt2661.c @@ -199,8 +199,8 @@ rt2661_attach(device_t dev, int id) struct rt2661_softc *sc = device_get_softc(dev); struct ieee80211com *ic = &sc->sc_ic; uint32_t val; + uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)]; int error, ac, ntries; - uint8_t bands; sc->sc_id = id; sc->sc_dev = dev; @@ -279,12 +279,12 @@ rt2661_attach(device_t dev, int id) #endif ; - bands = 0; - setbit(&bands, IEEE80211_MODE_11B); - setbit(&bands, IEEE80211_MODE_11G); + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); if (sc->rf_rev == RT2661_RF_5225 || sc->rf_rev == RT2661_RF_5325) - setbit(&bands, IEEE80211_MODE_11A); - ieee80211_init_channels(ic, NULL, &bands); + setbit(bands, IEEE80211_MODE_11A); + ieee80211_init_channels(ic, NULL, bands); ieee80211_ifattach(ic); #if 0 diff --git a/sys/dev/ral/rt2860.c b/sys/dev/ral/rt2860.c index 9447976..8bfb00d 100644 --- a/sys/dev/ral/rt2860.c +++ b/sys/dev/ral/rt2860.c @@ -232,8 +232,8 @@ rt2860_attach(device_t dev, int id) struct rt2860_softc *sc = device_get_softc(dev); struct ieee80211com *ic = &sc->sc_ic; uint32_t tmp; + uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)]; int error, ntries, qid; - uint8_t bands; sc->sc_dev = dev; sc->sc_debug = 0; @@ -319,12 +319,12 @@ rt2860_attach(device_t dev, int id) | IEEE80211_C_WME /* 802.11e */ ; - bands = 0; - setbit(&bands, IEEE80211_MODE_11B); - setbit(&bands, IEEE80211_MODE_11G); + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); if (sc->rf_rev == RT2860_RF_2750 || sc->rf_rev == RT2860_RF_2850) - setbit(&bands, IEEE80211_MODE_11A); - ieee80211_init_channels(ic, NULL, &bands); + setbit(bands, IEEE80211_MODE_11A); + ieee80211_init_channels(ic, NULL, bands); ieee80211_ifattach(ic); diff --git a/sys/dev/rt/if_rt.c b/sys/dev/rt/if_rt.c index 4deb8de..3d3a3f3 100644 --- a/sys/dev/rt/if_rt.c +++ b/sys/dev/rt/if_rt.c @@ -227,20 +227,6 @@ macaddr_atoi(const char *str, uint8_t *mac) } #ifdef USE_GENERATED_MAC_ADDRESS -static char * -kernenv_next(char *cp) -{ - - if (cp != NULL) { - while (*cp != 0) - cp++; - cp++; - if (*cp == 0) - cp = NULL; - } - return (cp); -} - /* * generate_mac(uin8_t *mac) * This is MAC address generator for cases when real device MAC address @@ -259,14 +245,8 @@ generate_mac(uint8_t *mac) uint32_t crc = 0xffffffff; /* Generate CRC32 on kenv */ - if (dynamic_kenv) { - for (cp = kenvp[0]; cp != NULL; cp = kenvp[++i]) { - crc = calculate_crc32c(crc, cp, strlen(cp) + 1); - } - } else { - for (cp = kern_envp; cp != NULL; cp = kernenv_next(cp)) { - crc = calculate_crc32c(crc, cp, strlen(cp) + 1); - } + for (cp = kenvp[0]; cp != NULL; cp = kenvp[++i]) { + crc = calculate_crc32c(crc, cp, strlen(cp) + 1); } crc = ~crc; diff --git a/sys/dev/rtwn/if_rtwn.c b/sys/dev/rtwn/if_rtwn.c new file mode 100644 index 0000000..886b281 --- /dev/null +++ b/sys/dev/rtwn/if_rtwn.c @@ -0,0 +1,3494 @@ +/* $OpenBSD: if_rtwn.c,v 1.6 2015/08/28 00:03:53 deraadt Exp $ */ + +/*- + * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> + * Copyright (c) 2015 Stefan Sperling <stsp@openbsd.org> + * + * Permission to use, copy, modify, and 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. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +/* + * Driver for Realtek RTL8188CE + */ + +#include <sys/param.h> +#include <sys/sysctl.h> +#include <sys/sockio.h> +#include <sys/mbuf.h> +#include <sys/kernel.h> +#include <sys/socket.h> +#include <sys/systm.h> +#include <sys/malloc.h> +#include <sys/lock.h> +#include <sys/mutex.h> +#include <sys/module.h> +#include <sys/bus.h> +#include <sys/endian.h> +#include <sys/firmware.h> + +#include <machine/bus.h> +#include <machine/resource.h> +#include <sys/rman.h> + +#include <dev/pci/pcireg.h> +#include <dev/pci/pcivar.h> + +#include <net/bpf.h> +#include <net/if.h> +#include <net/if_var.h> +#include <net/if_arp.h> +#include <net/ethernet.h> +#include <net/if_dl.h> +#include <net/if_media.h> +#include <net/if_types.h> + +#include <net80211/ieee80211_var.h> +#include <net80211/ieee80211_radiotap.h> +#include <net80211/ieee80211_regdomain.h> +#include <net80211/ieee80211_ratectl.h> + +#include <netinet/in.h> +#include <netinet/in_systm.h> +#include <netinet/in_var.h> +#include <netinet/ip.h> +#include <netinet/if_ether.h> + +#include <dev/rtwn/if_rtwnreg.h> + +#define RTWN_DEBUG +#ifdef RTWN_DEBUG +#define DPRINTF(x) do { if (sc->sc_debug > 0) printf x; } while (0) +#define DPRINTFN(n, x) do { if (sc->sc_debug >= (n)) printf x; } while (0) +#else +#define DPRINTF(x) +#define DPRINTFN(n, x) +#endif + +/* + * PCI configuration space registers. + */ +#define RTWN_PCI_IOBA 0x10 /* i/o mapped base */ +#define RTWN_PCI_MMBA 0x18 /* memory mapped base */ + +#define RTWN_INT_ENABLE (R92C_IMR_ROK | R92C_IMR_VODOK | R92C_IMR_VIDOK | \ + R92C_IMR_BEDOK | R92C_IMR_BKDOK | R92C_IMR_MGNTDOK | \ + R92C_IMR_HIGHDOK | R92C_IMR_BDOK | R92C_IMR_RDU | \ + R92C_IMR_RXFOVW) + +struct rtwn_ident { + uint16_t vendor; + uint16_t device; + const char *name; +}; + + +static const struct rtwn_ident rtwn_ident_table[] = { + { 0x10ec, 0x8176, "Realtek RTL8188CE" }, + { 0, 0, NULL } +}; + + +static void rtwn_dma_map_addr(void *, bus_dma_segment_t *, int, int); +static void rtwn_setup_rx_desc(struct rtwn_softc *, struct r92c_rx_desc *, + bus_addr_t, size_t, int); +static int rtwn_alloc_rx_list(struct rtwn_softc *); +static void rtwn_reset_rx_list(struct rtwn_softc *); +static void rtwn_free_rx_list(struct rtwn_softc *); +static int rtwn_alloc_tx_list(struct rtwn_softc *, int); +static void rtwn_reset_tx_list(struct rtwn_softc *, int); +static void rtwn_free_tx_list(struct rtwn_softc *, int); +static struct ieee80211vap *rtwn_vap_create(struct ieee80211com *, + const char [IFNAMSIZ], int, enum ieee80211_opmode, int, + const uint8_t [IEEE80211_ADDR_LEN], + const uint8_t [IEEE80211_ADDR_LEN]); +static void rtwn_vap_delete(struct ieee80211vap *); +static void rtwn_write_1(struct rtwn_softc *, uint16_t, uint8_t); +static void rtwn_write_2(struct rtwn_softc *, uint16_t, uint16_t); +static void rtwn_write_4(struct rtwn_softc *, uint16_t, uint32_t); +static uint8_t rtwn_read_1(struct rtwn_softc *, uint16_t); +static uint16_t rtwn_read_2(struct rtwn_softc *, uint16_t); +static uint32_t rtwn_read_4(struct rtwn_softc *, uint16_t); +static int rtwn_fw_cmd(struct rtwn_softc *, uint8_t, const void *, int); +static void rtwn_rf_write(struct rtwn_softc *, int, uint8_t, uint32_t); +static uint32_t rtwn_rf_read(struct rtwn_softc *, int, uint8_t); +static int rtwn_llt_write(struct rtwn_softc *, uint32_t, uint32_t); +static uint8_t rtwn_efuse_read_1(struct rtwn_softc *, uint16_t); +static void rtwn_efuse_read(struct rtwn_softc *); +static int rtwn_read_chipid(struct rtwn_softc *); +static void rtwn_read_rom(struct rtwn_softc *); +static int rtwn_ra_init(struct rtwn_softc *); +static void rtwn_tsf_sync_enable(struct rtwn_softc *); +static void rtwn_set_led(struct rtwn_softc *, int, int); +static void rtwn_calib_to(void *); +static int rtwn_newstate(struct ieee80211vap *, enum ieee80211_state, int); +static int rtwn_updateedca(struct ieee80211com *); +static void rtwn_update_avgrssi(struct rtwn_softc *, int, int8_t); +static int8_t rtwn_get_rssi(struct rtwn_softc *, int, void *); +static void rtwn_rx_frame(struct rtwn_softc *, struct r92c_rx_desc *, + struct rtwn_rx_data *, int); +static int rtwn_tx(struct rtwn_softc *, struct mbuf *, + struct ieee80211_node *); +static void rtwn_tx_done(struct rtwn_softc *, int); +static int rtwn_raw_xmit(struct ieee80211_node *, struct mbuf *, + const struct ieee80211_bpf_params *); +static int rtwn_transmit(struct ieee80211com *, struct mbuf *); +static void rtwn_parent(struct ieee80211com *); +static void rtwn_start(struct rtwn_softc *sc); +static void rtwn_watchdog(void *); +static int rtwn_power_on(struct rtwn_softc *); +static int rtwn_llt_init(struct rtwn_softc *); +static void rtwn_fw_reset(struct rtwn_softc *); +static void rtwn_fw_loadpage(struct rtwn_softc *, int, const uint8_t *, + int); +static int rtwn_load_firmware(struct rtwn_softc *); +static int rtwn_dma_init(struct rtwn_softc *); +static void rtwn_mac_init(struct rtwn_softc *); +static void rtwn_bb_init(struct rtwn_softc *); +static void rtwn_rf_init(struct rtwn_softc *); +static void rtwn_cam_init(struct rtwn_softc *); +static void rtwn_pa_bias_init(struct rtwn_softc *); +static void rtwn_rxfilter_init(struct rtwn_softc *); +static void rtwn_edca_init(struct rtwn_softc *); +static void rtwn_write_txpower(struct rtwn_softc *, int, uint16_t[]); +static void rtwn_get_txpower(struct rtwn_softc *, int, + struct ieee80211_channel *, struct ieee80211_channel *, + uint16_t[]); +static void rtwn_set_txpower(struct rtwn_softc *, + struct ieee80211_channel *, struct ieee80211_channel *); +static void rtwn_scan_start(struct ieee80211com *); +static void rtwn_scan_end(struct ieee80211com *); +static void rtwn_set_channel(struct ieee80211com *); +static void rtwn_update_mcast(struct ieee80211com *); +static void rtwn_set_chan(struct rtwn_softc *, + struct ieee80211_channel *, struct ieee80211_channel *); +static int rtwn_iq_calib_chain(struct rtwn_softc *, int, uint16_t[2], + uint16_t[2]); +static void rtwn_iq_calib_run(struct rtwn_softc *, int, uint16_t[2][2], + uint16_t[2][2]); +static int rtwn_iq_calib_compare_results(uint16_t[2][2], uint16_t[2][2], + uint16_t[2][2], uint16_t[2][2], int); +static void rtwn_iq_calib_write_results(struct rtwn_softc *, uint16_t[2], + uint16_t[2], int); +static void rtwn_iq_calib(struct rtwn_softc *); +static void rtwn_lc_calib(struct rtwn_softc *); +static void rtwn_temp_calib(struct rtwn_softc *); +static void rtwn_init_locked(struct rtwn_softc *); +static void rtwn_init(struct rtwn_softc *); +static void rtwn_stop_locked(struct rtwn_softc *); +static void rtwn_stop(struct rtwn_softc *); +static void rtwn_intr(void *); +static void rtwn_hw_reset(void *, int); + +/* Aliases. */ +#define rtwn_bb_write rtwn_write_4 +#define rtwn_bb_read rtwn_read_4 + +static int rtwn_probe(device_t); +static int rtwn_attach(device_t); +static int rtwn_detach(device_t); +static int rtwn_shutdown(device_t); +static int rtwn_suspend(device_t); +static int rtwn_resume(device_t); + +static device_method_t rtwn_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, rtwn_probe), + DEVMETHOD(device_attach, rtwn_attach), + DEVMETHOD(device_detach, rtwn_detach), + DEVMETHOD(device_shutdown, rtwn_shutdown), + DEVMETHOD(device_suspend, rtwn_suspend), + DEVMETHOD(device_resume, rtwn_resume), + + DEVMETHOD_END +}; + +static driver_t rtwn_driver = { + "rtwn", + rtwn_methods, + sizeof (struct rtwn_softc) +}; +static devclass_t rtwn_devclass; + +DRIVER_MODULE(rtwn, pci, rtwn_driver, rtwn_devclass, NULL, NULL); + +MODULE_VERSION(rtwn, 1); + +MODULE_DEPEND(rtwn, pci, 1, 1, 1); +MODULE_DEPEND(rtwn, wlan, 1, 1, 1); +MODULE_DEPEND(rtwn, firmware, 1, 1, 1); + +static int +rtwn_probe(device_t dev) +{ + const struct rtwn_ident *ident; + + for (ident = rtwn_ident_table; ident->name != NULL; ident++) { + if (pci_get_vendor(dev) == ident->vendor && + pci_get_device(dev) == ident->device) { + device_set_desc(dev, ident->name); + return (BUS_PROBE_DEFAULT); + } + } + return (ENXIO); +} + +static int +rtwn_attach(device_t dev) +{ + struct rtwn_softc *sc = device_get_softc(dev); + struct ieee80211com *ic = &sc->sc_ic; + uint32_t lcsr; + uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)]; + int i, count, error, rid; + + sc->sc_dev = dev; + sc->sc_debug = 0; + + /* + * Get the offset of the PCI Express Capability Structure in PCI + * Configuration Space. + */ + error = pci_find_cap(dev, PCIY_EXPRESS, &sc->sc_cap_off); + if (error != 0) { + device_printf(dev, "PCIe capability structure not found!\n"); + return (error); + } + + /* Enable bus-mastering. */ + pci_enable_busmaster(dev); + + rid = PCIR_BAR(2); + sc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, + RF_ACTIVE); + if (sc->mem == NULL) { + device_printf(dev, "can't map mem space\n"); + return (ENOMEM); + } + sc->sc_st = rman_get_bustag(sc->mem); + sc->sc_sh = rman_get_bushandle(sc->mem); + + /* Install interrupt handler. */ + count = 1; + rid = 0; + if (pci_alloc_msi(dev, &count) == 0) + rid = 1; + sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE | + (rid != 0 ? 0 : RF_SHAREABLE)); + if (sc->irq == NULL) { + device_printf(dev, "can't map interrupt\n"); + return (ENXIO); + } + + RTWN_LOCK_INIT(sc); + callout_init_mtx(&sc->calib_to, &sc->sc_mtx, 0); + callout_init_mtx(&sc->watchdog_to, &sc->sc_mtx, 0); + TASK_INIT(&sc->sc_reinit_task, 0, rtwn_hw_reset, sc); + mbufq_init(&sc->sc_snd, ifqmaxlen); + + error = rtwn_read_chipid(sc); + if (error != 0) { + device_printf(dev, "unsupported test chip\n"); + goto fail; + } + + /* Disable PCIe Active State Power Management (ASPM). */ + lcsr = pci_read_config(sc->sc_dev, sc->sc_cap_off + PCIER_LINK_CTL, 4); + lcsr &= ~PCIEM_LINK_CTL_ASPMC; + pci_write_config(sc->sc_dev, sc->sc_cap_off + PCIER_LINK_CTL, lcsr, 4); + + /* Allocate Tx/Rx buffers. */ + error = rtwn_alloc_rx_list(sc); + if (error != 0) { + device_printf(dev, "could not allocate Rx buffers\n"); + goto fail; + } + for (i = 0; i < RTWN_NTXQUEUES; i++) { + error = rtwn_alloc_tx_list(sc, i); + if (error != 0) { + device_printf(dev, "could not allocate Tx buffers\n"); + goto fail; + } + } + + /* Determine number of Tx/Rx chains. */ + if (sc->chip & RTWN_CHIP_92C) { + sc->ntxchains = (sc->chip & RTWN_CHIP_92C_1T2R) ? 1 : 2; + sc->nrxchains = 2; + } else { + sc->ntxchains = 1; + sc->nrxchains = 1; + } + rtwn_read_rom(sc); + + device_printf(sc->sc_dev, "MAC/BB RTL%s, RF 6052 %dT%dR\n", + (sc->chip & RTWN_CHIP_92C) ? "8192CE" : "8188CE", + sc->ntxchains, sc->nrxchains); + + ic->ic_softc = sc; + ic->ic_name = device_get_nameunit(dev); + ic->ic_opmode = IEEE80211_M_STA; + ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */ + + /* set device capabilities */ + ic->ic_caps = + IEEE80211_C_STA /* station mode */ + | IEEE80211_C_MONITOR /* monitor mode */ + | IEEE80211_C_SHPREAMBLE /* short preamble supported */ + | IEEE80211_C_SHSLOT /* short slot time supported */ + | IEEE80211_C_WPA /* capable of WPA1+WPA2 */ + | IEEE80211_C_BGSCAN /* capable of bg scanning */ + | IEEE80211_C_WME /* 802.11e */ + ; + + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); + ieee80211_init_channels(ic, NULL, bands); + + ieee80211_ifattach(ic); + + ic->ic_wme.wme_update = rtwn_updateedca; + ic->ic_update_mcast = rtwn_update_mcast; + ic->ic_scan_start =rtwn_scan_start; + ic->ic_scan_end = rtwn_scan_end; + ic->ic_set_channel = rtwn_set_channel; + ic->ic_raw_xmit = rtwn_raw_xmit; + ic->ic_transmit = rtwn_transmit; + ic->ic_parent = rtwn_parent; + ic->ic_vap_create = rtwn_vap_create; + ic->ic_vap_delete = rtwn_vap_delete; + + ieee80211_radiotap_attach(ic, + &sc->sc_txtap.wt_ihdr, sizeof(sc->sc_txtap), + RTWN_TX_RADIOTAP_PRESENT, + &sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap), + RTWN_RX_RADIOTAP_PRESENT); + + /* + * Hook our interrupt after all initialization is complete. + */ + error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET | INTR_MPSAFE, + NULL, rtwn_intr, sc, &sc->sc_ih); + if (error != 0) { + device_printf(dev, "can't establish interrupt, error %d\n", + error); + goto fail; + } + + if (bootverbose) + ieee80211_announce(ic); + + return (0); + +fail: + rtwn_detach(dev); + return (error); +} + + +static int +rtwn_detach(device_t dev) +{ + struct rtwn_softc *sc = device_get_softc(dev); + int i; + + if (sc->sc_ic.ic_softc != NULL) { + ieee80211_draintask(&sc->sc_ic, &sc->sc_reinit_task); + rtwn_stop(sc); + + callout_drain(&sc->calib_to); + callout_drain(&sc->watchdog_to); + ieee80211_ifdetach(&sc->sc_ic); + mbufq_drain(&sc->sc_snd); + } + + /* Uninstall interrupt handler. */ + if (sc->irq != NULL) { + bus_teardown_intr(dev, sc->irq, sc->sc_ih); + bus_release_resource(dev, SYS_RES_IRQ, rman_get_rid(sc->irq), + sc->irq); + pci_release_msi(dev); + } + + /* Free Tx/Rx buffers. */ + for (i = 0; i < RTWN_NTXQUEUES; i++) + rtwn_free_tx_list(sc, i); + rtwn_free_rx_list(sc); + + if (sc->mem != NULL) + bus_release_resource(dev, SYS_RES_MEMORY, + rman_get_rid(sc->mem), sc->mem); + + RTWN_LOCK_DESTROY(sc); + return (0); +} + +static int +rtwn_shutdown(device_t dev) +{ + + return (0); +} + +static int +rtwn_suspend(device_t dev) +{ + return (0); +} + +static int +rtwn_resume(device_t dev) +{ + + return (0); +} + +static void +rtwn_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nsegs, int error) +{ + + if (error != 0) + return; + KASSERT(nsegs == 1, ("too many DMA segments, %d should be 1", nsegs)); + *(bus_addr_t *)arg = segs[0].ds_addr; +} + +static void +rtwn_setup_rx_desc(struct rtwn_softc *sc, struct r92c_rx_desc *desc, + bus_addr_t addr, size_t len, int idx) +{ + + memset(desc, 0, sizeof(*desc)); + desc->rxdw0 = htole32(SM(R92C_RXDW0_PKTLEN, len) | + ((idx == RTWN_RX_LIST_COUNT - 1) ? R92C_RXDW0_EOR : 0)); + desc->rxbufaddr = htole32(addr); + bus_space_barrier(sc->sc_st, sc->sc_sh, 0, sc->sc_mapsize, + BUS_SPACE_BARRIER_WRITE); + desc->rxdw0 |= htole32(R92C_RXDW0_OWN); +} + +static int +rtwn_alloc_rx_list(struct rtwn_softc *sc) +{ + struct rtwn_rx_ring *rx_ring = &sc->rx_ring; + struct rtwn_rx_data *rx_data; + bus_size_t size; + int i, error; + + /* Allocate Rx descriptors. */ + size = sizeof(struct r92c_rx_desc) * RTWN_RX_LIST_COUNT; + error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + size, 1, size, 0, NULL, NULL, &rx_ring->desc_dmat); + if (error != 0) { + device_printf(sc->sc_dev, "could not create rx desc DMA tag\n"); + goto fail; + } + + error = bus_dmamem_alloc(rx_ring->desc_dmat, (void **)&rx_ring->desc, + BUS_DMA_NOWAIT | BUS_DMA_ZERO | BUS_DMA_COHERENT, + &rx_ring->desc_map); + if (error != 0) { + device_printf(sc->sc_dev, "could not allocate rx desc\n"); + goto fail; + } + error = bus_dmamap_load(rx_ring->desc_dmat, rx_ring->desc_map, + rx_ring->desc, size, rtwn_dma_map_addr, &rx_ring->paddr, 0); + if (error != 0) { + device_printf(sc->sc_dev, "could not load rx desc DMA map\n"); + goto fail; + } + bus_dmamap_sync(rx_ring->desc_dmat, rx_ring->desc_map, + BUS_DMASYNC_PREWRITE); + + /* Create RX buffer DMA tag. */ + error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, + 1, MCLBYTES, 0, NULL, NULL, &rx_ring->data_dmat); + if (error != 0) { + device_printf(sc->sc_dev, "could not create rx buf DMA tag\n"); + goto fail; + } + + /* Allocate Rx buffers. */ + for (i = 0; i < RTWN_RX_LIST_COUNT; i++) { + rx_data = &rx_ring->rx_data[i]; + error = bus_dmamap_create(rx_ring->data_dmat, 0, &rx_data->map); + if (error != 0) { + device_printf(sc->sc_dev, + "could not create rx buf DMA map\n"); + goto fail; + } + + rx_data->m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); + if (rx_data->m == NULL) { + device_printf(sc->sc_dev, + "could not allocate rx mbuf\n"); + error = ENOMEM; + goto fail; + } + + error = bus_dmamap_load(rx_ring->data_dmat, rx_data->map, + mtod(rx_data->m, void *), MCLBYTES, rtwn_dma_map_addr, + &rx_data->paddr, BUS_DMA_NOWAIT); + if (error != 0) { + device_printf(sc->sc_dev, + "could not load rx buf DMA map"); + goto fail; + } + + rtwn_setup_rx_desc(sc, &rx_ring->desc[i], rx_data->paddr, + MCLBYTES, i); + } + return (0); + +fail: + rtwn_free_rx_list(sc); + return (error); +} + +static void +rtwn_reset_rx_list(struct rtwn_softc *sc) +{ + struct rtwn_rx_ring *rx_ring = &sc->rx_ring; + struct rtwn_rx_data *rx_data; + int i; + + for (i = 0; i < RTWN_RX_LIST_COUNT; i++) { + rx_data = &rx_ring->rx_data[i]; + rtwn_setup_rx_desc(sc, &rx_ring->desc[i], rx_data->paddr, + MCLBYTES, i); + } +} + +static void +rtwn_free_rx_list(struct rtwn_softc *sc) +{ + struct rtwn_rx_ring *rx_ring = &sc->rx_ring; + struct rtwn_rx_data *rx_data; + int i; + + if (rx_ring->desc_dmat != NULL) { + if (rx_ring->desc != NULL) { + bus_dmamap_unload(rx_ring->desc_dmat, + rx_ring->desc_map); + bus_dmamem_free(rx_ring->desc_dmat, rx_ring->desc, + rx_ring->desc_map); + rx_ring->desc = NULL; + } + bus_dma_tag_destroy(rx_ring->desc_dmat); + rx_ring->desc_dmat = NULL; + } + + for (i = 0; i < RTWN_RX_LIST_COUNT; i++) { + rx_data = &rx_ring->rx_data[i]; + + if (rx_data->m != NULL) { + bus_dmamap_unload(rx_ring->data_dmat, rx_data->map); + m_freem(rx_data->m); + rx_data->m = NULL; + } + bus_dmamap_destroy(rx_ring->data_dmat, rx_data->map); + rx_data->map = NULL; + } + if (rx_ring->data_dmat != NULL) { + bus_dma_tag_destroy(rx_ring->data_dmat); + rx_ring->data_dmat = NULL; + } +} + +static int +rtwn_alloc_tx_list(struct rtwn_softc *sc, int qid) +{ + struct rtwn_tx_ring *tx_ring = &sc->tx_ring[qid]; + struct rtwn_tx_data *tx_data; + bus_size_t size; + int i, error; + + size = sizeof(struct r92c_tx_desc) * RTWN_TX_LIST_COUNT; + error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), PAGE_SIZE, 0, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + size, 1, size, 0, NULL, NULL, &tx_ring->desc_dmat); + if (error != 0) { + device_printf(sc->sc_dev, "could not create tx ring DMA tag\n"); + goto fail; + } + + error = bus_dmamem_alloc(tx_ring->desc_dmat, (void **)&tx_ring->desc, + BUS_DMA_NOWAIT | BUS_DMA_ZERO, &tx_ring->desc_map); + if (error != 0) { + device_printf(sc->sc_dev, "can't map tx ring DMA memory\n"); + goto fail; + } + error = bus_dmamap_load(tx_ring->desc_dmat, tx_ring->desc_map, + tx_ring->desc, size, rtwn_dma_map_addr, &tx_ring->paddr, + BUS_DMA_NOWAIT); + if (error != 0) { + device_printf(sc->sc_dev, "could not load desc DMA map\n"); + goto fail; + } + + error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, + 1, MCLBYTES, 0, NULL, NULL, &tx_ring->data_dmat); + if (error != 0) { + device_printf(sc->sc_dev, "could not create tx buf DMA tag\n"); + goto fail; + } + + for (i = 0; i < RTWN_TX_LIST_COUNT; i++) { + struct r92c_tx_desc *desc = &tx_ring->desc[i]; + + /* setup tx desc */ + desc->nextdescaddr = htole32(tx_ring->paddr + + + sizeof(struct r92c_tx_desc) + * ((i + 1) % RTWN_TX_LIST_COUNT)); + tx_data = &tx_ring->tx_data[i]; + error = bus_dmamap_create(tx_ring->data_dmat, 0, &tx_data->map); + if (error != 0) { + device_printf(sc->sc_dev, + "could not create tx buf DMA map\n"); + goto fail; + } + tx_data->m = NULL; + tx_data->ni = NULL; + } + return (0); + +fail: + rtwn_free_tx_list(sc, qid); + return (error); +} + +static void +rtwn_reset_tx_list(struct rtwn_softc *sc, int qid) +{ + struct rtwn_tx_ring *tx_ring = &sc->tx_ring[qid]; + int i; + + for (i = 0; i < RTWN_TX_LIST_COUNT; i++) { + struct r92c_tx_desc *desc = &tx_ring->desc[i]; + struct rtwn_tx_data *tx_data = &tx_ring->tx_data[i]; + + memset(desc, 0, sizeof(*desc) - + (sizeof(desc->reserved) + sizeof(desc->nextdescaddr64) + + sizeof(desc->nextdescaddr))); + + if (tx_data->m != NULL) { + bus_dmamap_unload(tx_ring->data_dmat, tx_data->map); + m_freem(tx_data->m); + tx_data->m = NULL; + } + if (tx_data->ni != NULL) { + ieee80211_free_node(tx_data->ni); + tx_data->ni = NULL; + } + } + + bus_dmamap_sync(tx_ring->desc_dmat, tx_ring->desc_map, + BUS_DMASYNC_POSTWRITE); + + sc->qfullmsk &= ~(1 << qid); + tx_ring->queued = 0; + tx_ring->cur = 0; +} + +static void +rtwn_free_tx_list(struct rtwn_softc *sc, int qid) +{ + struct rtwn_tx_ring *tx_ring = &sc->tx_ring[qid]; + struct rtwn_tx_data *tx_data; + int i; + + if (tx_ring->desc_dmat != NULL) { + if (tx_ring->desc != NULL) { + bus_dmamap_unload(tx_ring->desc_dmat, + tx_ring->desc_map); + bus_dmamem_free(tx_ring->desc_dmat, tx_ring->desc, + tx_ring->desc_map); + } + bus_dma_tag_destroy(tx_ring->desc_dmat); + } + + for (i = 0; i < RTWN_TX_LIST_COUNT; i++) { + tx_data = &tx_ring->tx_data[i]; + + if (tx_data->m != NULL) { + bus_dmamap_unload(tx_ring->data_dmat, tx_data->map); + m_freem(tx_data->m); + tx_data->m = NULL; + } + } + if (tx_ring->data_dmat != NULL) { + bus_dma_tag_destroy(tx_ring->data_dmat); + tx_ring->data_dmat = NULL; + } + + sc->qfullmsk &= ~(1 << qid); + tx_ring->queued = 0; + tx_ring->cur = 0; +} + + +static struct ieee80211vap * +rtwn_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit, + enum ieee80211_opmode opmode, int flags, + const uint8_t bssid[IEEE80211_ADDR_LEN], + const uint8_t mac[IEEE80211_ADDR_LEN]) +{ + struct rtwn_vap *rvp; + struct ieee80211vap *vap; + + if (!TAILQ_EMPTY(&ic->ic_vaps)) + return (NULL); + + rvp = malloc(sizeof(struct rtwn_vap), M_80211_VAP, M_WAITOK | M_ZERO); + vap = &rvp->vap; + if (ieee80211_vap_setup(ic, vap, name, unit, opmode, + flags | IEEE80211_CLONE_NOBEACONS, bssid) != 0) { + /* out of memory */ + free(rvp, M_80211_VAP); + return (NULL); + } + + /* Override state transition machine. */ + rvp->newstate = vap->iv_newstate; + vap->iv_newstate = rtwn_newstate; + + /* Complete setup. */ + ieee80211_vap_attach(vap, ieee80211_media_change, + ieee80211_media_status, mac); + ic->ic_opmode = opmode; + return (vap); +} + +static void +rtwn_vap_delete(struct ieee80211vap *vap) +{ + struct rtwn_vap *rvp = RTWN_VAP(vap); + + ieee80211_vap_detach(vap); + free(rvp, M_80211_VAP); +} + +static void +rtwn_write_1(struct rtwn_softc *sc, uint16_t addr, uint8_t val) +{ + + bus_space_write_1(sc->sc_st, sc->sc_sh, addr, val); +} + +static void +rtwn_write_2(struct rtwn_softc *sc, uint16_t addr, uint16_t val) +{ + + val = htole16(val); + bus_space_write_2(sc->sc_st, sc->sc_sh, addr, val); +} + +static void +rtwn_write_4(struct rtwn_softc *sc, uint16_t addr, uint32_t val) +{ + + val = htole32(val); + bus_space_write_4(sc->sc_st, sc->sc_sh, addr, val); +} + +static uint8_t +rtwn_read_1(struct rtwn_softc *sc, uint16_t addr) +{ + + return (bus_space_read_1(sc->sc_st, sc->sc_sh, addr)); +} + +static uint16_t +rtwn_read_2(struct rtwn_softc *sc, uint16_t addr) +{ + + return (bus_space_read_2(sc->sc_st, sc->sc_sh, addr)); +} + +static uint32_t +rtwn_read_4(struct rtwn_softc *sc, uint16_t addr) +{ + + return (bus_space_read_4(sc->sc_st, sc->sc_sh, addr)); +} + +static int +rtwn_fw_cmd(struct rtwn_softc *sc, uint8_t id, const void *buf, int len) +{ + struct r92c_fw_cmd cmd; + int ntries; + + /* Wait for current FW box to be empty. */ + for (ntries = 0; ntries < 100; ntries++) { + if (!(rtwn_read_1(sc, R92C_HMETFR) & (1 << sc->fwcur))) + break; + DELAY(1); + } + if (ntries == 100) { + device_printf(sc->sc_dev, + "could not send firmware command %d\n", id); + return (ETIMEDOUT); + } + memset(&cmd, 0, sizeof(cmd)); + cmd.id = id; + if (len > 3) + cmd.id |= R92C_CMD_FLAG_EXT; + KASSERT(len <= sizeof(cmd.msg), ("rtwn_fw_cmd\n")); + memcpy(cmd.msg, buf, len); + + /* Write the first word last since that will trigger the FW. */ + rtwn_write_2(sc, R92C_HMEBOX_EXT(sc->fwcur), *((uint8_t *)&cmd + 4)); + rtwn_write_4(sc, R92C_HMEBOX(sc->fwcur), *((uint8_t *)&cmd + 0)); + + sc->fwcur = (sc->fwcur + 1) % R92C_H2C_NBOX; + + /* Give firmware some time for processing. */ + DELAY(2000); + + return (0); +} + +static void +rtwn_rf_write(struct rtwn_softc *sc, int chain, uint8_t addr, uint32_t val) +{ + rtwn_bb_write(sc, R92C_LSSI_PARAM(chain), + SM(R92C_LSSI_PARAM_ADDR, addr) | + SM(R92C_LSSI_PARAM_DATA, val)); +} + +static uint32_t +rtwn_rf_read(struct rtwn_softc *sc, int chain, uint8_t addr) +{ + uint32_t reg[R92C_MAX_CHAINS], val; + + reg[0] = rtwn_bb_read(sc, R92C_HSSI_PARAM2(0)); + if (chain != 0) + reg[chain] = rtwn_bb_read(sc, R92C_HSSI_PARAM2(chain)); + + rtwn_bb_write(sc, R92C_HSSI_PARAM2(0), + reg[0] & ~R92C_HSSI_PARAM2_READ_EDGE); + DELAY(1000); + + rtwn_bb_write(sc, R92C_HSSI_PARAM2(chain), + RW(reg[chain], R92C_HSSI_PARAM2_READ_ADDR, addr) | + R92C_HSSI_PARAM2_READ_EDGE); + DELAY(1000); + + rtwn_bb_write(sc, R92C_HSSI_PARAM2(0), + reg[0] | R92C_HSSI_PARAM2_READ_EDGE); + DELAY(1000); + + if (rtwn_bb_read(sc, R92C_HSSI_PARAM1(chain)) & R92C_HSSI_PARAM1_PI) + val = rtwn_bb_read(sc, R92C_HSPI_READBACK(chain)); + else + val = rtwn_bb_read(sc, R92C_LSSI_READBACK(chain)); + return (MS(val, R92C_LSSI_READBACK_DATA)); +} + +static int +rtwn_llt_write(struct rtwn_softc *sc, uint32_t addr, uint32_t data) +{ + int ntries; + + rtwn_write_4(sc, R92C_LLT_INIT, + SM(R92C_LLT_INIT_OP, R92C_LLT_INIT_OP_WRITE) | + SM(R92C_LLT_INIT_ADDR, addr) | + SM(R92C_LLT_INIT_DATA, data)); + /* Wait for write operation to complete. */ + for (ntries = 0; ntries < 20; ntries++) { + if (MS(rtwn_read_4(sc, R92C_LLT_INIT), R92C_LLT_INIT_OP) == + R92C_LLT_INIT_OP_NO_ACTIVE) + return (0); + DELAY(5); + } + return (ETIMEDOUT); +} + +static uint8_t +rtwn_efuse_read_1(struct rtwn_softc *sc, uint16_t addr) +{ + uint32_t reg; + int ntries; + + reg = rtwn_read_4(sc, R92C_EFUSE_CTRL); + reg = RW(reg, R92C_EFUSE_CTRL_ADDR, addr); + reg &= ~R92C_EFUSE_CTRL_VALID; + rtwn_write_4(sc, R92C_EFUSE_CTRL, reg); + /* Wait for read operation to complete. */ + for (ntries = 0; ntries < 100; ntries++) { + reg = rtwn_read_4(sc, R92C_EFUSE_CTRL); + if (reg & R92C_EFUSE_CTRL_VALID) + return (MS(reg, R92C_EFUSE_CTRL_DATA)); + DELAY(5); + } + device_printf(sc->sc_dev, + "could not read efuse byte at address 0x%x\n", addr); + return (0xff); +} + +static void +rtwn_efuse_read(struct rtwn_softc *sc) +{ + uint8_t *rom = (uint8_t *)&sc->rom; + uint16_t addr = 0; + uint32_t reg; + uint8_t off, msk; + int i; + + reg = rtwn_read_2(sc, R92C_SYS_ISO_CTRL); + if (!(reg & R92C_SYS_ISO_CTRL_PWC_EV12V)) { + rtwn_write_2(sc, R92C_SYS_ISO_CTRL, + reg | R92C_SYS_ISO_CTRL_PWC_EV12V); + } + reg = rtwn_read_2(sc, R92C_SYS_FUNC_EN); + if (!(reg & R92C_SYS_FUNC_EN_ELDR)) { + rtwn_write_2(sc, R92C_SYS_FUNC_EN, + reg | R92C_SYS_FUNC_EN_ELDR); + } + reg = rtwn_read_2(sc, R92C_SYS_CLKR); + if ((reg & (R92C_SYS_CLKR_LOADER_EN | R92C_SYS_CLKR_ANA8M)) != + (R92C_SYS_CLKR_LOADER_EN | R92C_SYS_CLKR_ANA8M)) { + rtwn_write_2(sc, R92C_SYS_CLKR, + reg | R92C_SYS_CLKR_LOADER_EN | R92C_SYS_CLKR_ANA8M); + } + memset(&sc->rom, 0xff, sizeof(sc->rom)); + while (addr < 512) { + reg = rtwn_efuse_read_1(sc, addr); + if (reg == 0xff) + break; + addr++; + off = reg >> 4; + msk = reg & 0xf; + for (i = 0; i < 4; i++) { + if (msk & (1 << i)) + continue; + rom[off * 8 + i * 2 + 0] = + rtwn_efuse_read_1(sc, addr); + addr++; + rom[off * 8 + i * 2 + 1] = + rtwn_efuse_read_1(sc, addr); + addr++; + } + } +#ifdef RTWN_DEBUG + if (sc->sc_debug >= 2) { + /* Dump ROM content. */ + printf("\n"); + for (i = 0; i < sizeof(sc->rom); i++) + printf("%02x:", rom[i]); + printf("\n"); + } +#endif +} + +static int +rtwn_read_chipid(struct rtwn_softc *sc) +{ + uint32_t reg; + + reg = rtwn_read_4(sc, R92C_SYS_CFG); + if (reg & R92C_SYS_CFG_TRP_VAUX_EN) + /* Unsupported test chip. */ + return (EIO); + + if (reg & R92C_SYS_CFG_TYPE_92C) { + sc->chip |= RTWN_CHIP_92C; + /* Check if it is a castrated 8192C. */ + if (MS(rtwn_read_4(sc, R92C_HPON_FSM), + R92C_HPON_FSM_CHIP_BONDING_ID) == + R92C_HPON_FSM_CHIP_BONDING_ID_92C_1T2R) + sc->chip |= RTWN_CHIP_92C_1T2R; + } + if (reg & R92C_SYS_CFG_VENDOR_UMC) { + sc->chip |= RTWN_CHIP_UMC; + if (MS(reg, R92C_SYS_CFG_CHIP_VER_RTL) == 0) + sc->chip |= RTWN_CHIP_UMC_A_CUT; + } + return (0); +} + +static void +rtwn_read_rom(struct rtwn_softc *sc) +{ + struct r92c_rom *rom = &sc->rom; + + /* Read full ROM image. */ + rtwn_efuse_read(sc); + + if (rom->id != 0x8129) + device_printf(sc->sc_dev, "invalid EEPROM ID 0x%x\n", rom->id); + + /* XXX Weird but this is what the vendor driver does. */ + sc->pa_setting = rtwn_efuse_read_1(sc, 0x1fa); + DPRINTF(("PA setting=0x%x\n", sc->pa_setting)); + + sc->board_type = MS(rom->rf_opt1, R92C_ROM_RF1_BOARD_TYPE); + + sc->regulatory = MS(rom->rf_opt1, R92C_ROM_RF1_REGULATORY); + DPRINTF(("regulatory type=%d\n", sc->regulatory)); + + IEEE80211_ADDR_COPY(sc->sc_ic.ic_macaddr, rom->macaddr); +} + +/* + * Initialize rate adaptation in firmware. + */ +static int +rtwn_ra_init(struct rtwn_softc *sc) +{ + static const uint8_t map[] = + { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 }; + struct ieee80211com *ic = &sc->sc_ic; + struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); + struct ieee80211_node *ni = ieee80211_ref_node(vap->iv_bss); + struct ieee80211_rateset *rs = &ni->ni_rates; + struct r92c_fw_cmd_macid_cfg cmd; + uint32_t rates, basicrates; + uint8_t mode; + int maxrate, maxbasicrate, error, i, j; + + /* Get normal and basic rates mask. */ + rates = basicrates = 0; + maxrate = maxbasicrate = 0; + for (i = 0; i < rs->rs_nrates; i++) { + /* Convert 802.11 rate to HW rate index. */ + for (j = 0; j < nitems(map); j++) + if ((rs->rs_rates[i] & IEEE80211_RATE_VAL) == map[j]) + break; + if (j == nitems(map)) /* Unknown rate, skip. */ + continue; + rates |= 1 << j; + if (j > maxrate) + maxrate = j; + if (rs->rs_rates[i] & IEEE80211_RATE_BASIC) { + basicrates |= 1 << j; + if (j > maxbasicrate) + maxbasicrate = j; + } + } + if (ic->ic_curmode == IEEE80211_MODE_11B) + mode = R92C_RAID_11B; + else + mode = R92C_RAID_11BG; + DPRINTF(("mode=0x%x rates=0x%08x, basicrates=0x%08x\n", + mode, rates, basicrates)); + + /* Set rates mask for group addressed frames. */ + cmd.macid = RTWN_MACID_BC | RTWN_MACID_VALID; + cmd.mask = htole32(mode << 28 | basicrates); + error = rtwn_fw_cmd(sc, R92C_CMD_MACID_CONFIG, &cmd, sizeof(cmd)); + if (error != 0) { + device_printf(sc->sc_dev, + "could not add broadcast station\n"); + return (error); + } + /* Set initial MRR rate. */ + DPRINTF(("maxbasicrate=%d\n", maxbasicrate)); + rtwn_write_1(sc, R92C_INIDATA_RATE_SEL(RTWN_MACID_BC), + maxbasicrate); + + /* Set rates mask for unicast frames. */ + cmd.macid = RTWN_MACID_BSS | RTWN_MACID_VALID; + cmd.mask = htole32(mode << 28 | rates); + error = rtwn_fw_cmd(sc, R92C_CMD_MACID_CONFIG, &cmd, sizeof(cmd)); + if (error != 0) { + device_printf(sc->sc_dev, "could not add BSS station\n"); + return (error); + } + /* Set initial MRR rate. */ + DPRINTF(("maxrate=%d\n", maxrate)); + rtwn_write_1(sc, R92C_INIDATA_RATE_SEL(RTWN_MACID_BSS), + maxrate); + + /* Configure Automatic Rate Fallback Register. */ + if (ic->ic_curmode == IEEE80211_MODE_11B) { + if (rates & 0x0c) + rtwn_write_4(sc, R92C_ARFR(0), htole32(rates & 0x0d)); + else + rtwn_write_4(sc, R92C_ARFR(0), htole32(rates & 0x0f)); + } else + rtwn_write_4(sc, R92C_ARFR(0), htole32(rates & 0x0ff5)); + + /* Indicate highest supported rate. */ + ni->ni_txrate = rs->rs_rates[rs->rs_nrates - 1]; + return (0); +} + +static void +rtwn_tsf_sync_enable(struct rtwn_softc *sc) +{ + struct ieee80211com *ic = &sc->sc_ic; + struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); + struct ieee80211_node *ni = vap->iv_bss; + uint64_t tsf; + + /* Enable TSF synchronization. */ + rtwn_write_1(sc, R92C_BCN_CTRL, + rtwn_read_1(sc, R92C_BCN_CTRL) & ~R92C_BCN_CTRL_DIS_TSF_UDT0); + + rtwn_write_1(sc, R92C_BCN_CTRL, + rtwn_read_1(sc, R92C_BCN_CTRL) & ~R92C_BCN_CTRL_EN_BCN); + + /* Set initial TSF. */ + memcpy(&tsf, ni->ni_tstamp.data, 8); + tsf = le64toh(tsf); + tsf = tsf - (tsf % (vap->iv_bss->ni_intval * IEEE80211_DUR_TU)); + tsf -= IEEE80211_DUR_TU; + rtwn_write_4(sc, R92C_TSFTR + 0, tsf); + rtwn_write_4(sc, R92C_TSFTR + 4, tsf >> 32); + + rtwn_write_1(sc, R92C_BCN_CTRL, + rtwn_read_1(sc, R92C_BCN_CTRL) | R92C_BCN_CTRL_EN_BCN); +} + +static void +rtwn_set_led(struct rtwn_softc *sc, int led, int on) +{ + uint8_t reg; + + if (led == RTWN_LED_LINK) { + reg = rtwn_read_1(sc, R92C_LEDCFG2) & 0xf0; + if (!on) + reg |= R92C_LEDCFG2_DIS; + else + reg |= R92C_LEDCFG2_EN; + rtwn_write_1(sc, R92C_LEDCFG2, reg); + sc->ledlink = on; /* Save LED state. */ + } +} + +static void +rtwn_calib_to(void *arg) +{ + struct rtwn_softc *sc = arg; + struct r92c_fw_cmd_rssi cmd; + + if (sc->avg_pwdb != -1) { + /* Indicate Rx signal strength to FW for rate adaptation. */ + memset(&cmd, 0, sizeof(cmd)); + cmd.macid = 0; /* BSS. */ + cmd.pwdb = sc->avg_pwdb; + DPRINTFN(3, ("sending RSSI command avg=%d\n", sc->avg_pwdb)); + rtwn_fw_cmd(sc, R92C_CMD_RSSI_SETTING, &cmd, sizeof(cmd)); + } + + /* Do temperature compensation. */ + rtwn_temp_calib(sc); + + callout_reset(&sc->calib_to, hz * 2, rtwn_calib_to, sc); +} + +static int +rtwn_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) +{ + struct rtwn_vap *rvp = RTWN_VAP(vap); + struct ieee80211com *ic = vap->iv_ic; + struct ieee80211_node *ni = vap->iv_bss; + struct rtwn_softc *sc = ic->ic_softc; + uint32_t reg; + + IEEE80211_UNLOCK(ic); + RTWN_LOCK(sc); + + if (vap->iv_state == IEEE80211_S_RUN) { + /* Stop calibration. */ + callout_stop(&sc->calib_to); + + /* Turn link LED off. */ + rtwn_set_led(sc, RTWN_LED_LINK, 0); + + /* Set media status to 'No Link'. */ + reg = rtwn_read_4(sc, R92C_CR); + reg = RW(reg, R92C_CR_NETTYPE, R92C_CR_NETTYPE_NOLINK); + rtwn_write_4(sc, R92C_CR, reg); + + /* Stop Rx of data frames. */ + rtwn_write_2(sc, R92C_RXFLTMAP2, 0); + + /* Rest TSF. */ + rtwn_write_1(sc, R92C_DUAL_TSF_RST, 0x03); + + /* Disable TSF synchronization. */ + rtwn_write_1(sc, R92C_BCN_CTRL, + rtwn_read_1(sc, R92C_BCN_CTRL) | + R92C_BCN_CTRL_DIS_TSF_UDT0); + + /* Reset EDCA parameters. */ + rtwn_write_4(sc, R92C_EDCA_VO_PARAM, 0x002f3217); + rtwn_write_4(sc, R92C_EDCA_VI_PARAM, 0x005e4317); + rtwn_write_4(sc, R92C_EDCA_BE_PARAM, 0x00105320); + rtwn_write_4(sc, R92C_EDCA_BK_PARAM, 0x0000a444); + } + switch (nstate) { + case IEEE80211_S_INIT: + /* Turn link LED off. */ + rtwn_set_led(sc, RTWN_LED_LINK, 0); + break; + case IEEE80211_S_SCAN: + if (vap->iv_state != IEEE80211_S_SCAN) { + /* Allow Rx from any BSSID. */ + rtwn_write_4(sc, R92C_RCR, + rtwn_read_4(sc, R92C_RCR) & + ~(R92C_RCR_CBSSID_DATA | R92C_RCR_CBSSID_BCN)); + + /* Set gain for scanning. */ + reg = rtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(0)); + reg = RW(reg, R92C_OFDM0_AGCCORE1_GAIN, 0x20); + rtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(0), reg); + + reg = rtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(1)); + reg = RW(reg, R92C_OFDM0_AGCCORE1_GAIN, 0x20); + rtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(1), reg); + } + + /* Make link LED blink during scan. */ + rtwn_set_led(sc, RTWN_LED_LINK, !sc->ledlink); + + /* Pause AC Tx queues. */ + rtwn_write_1(sc, R92C_TXPAUSE, + rtwn_read_1(sc, R92C_TXPAUSE) | 0x0f); + break; + case IEEE80211_S_AUTH: + /* Set initial gain under link. */ + reg = rtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(0)); + reg = RW(reg, R92C_OFDM0_AGCCORE1_GAIN, 0x32); + rtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(0), reg); + + reg = rtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(1)); + reg = RW(reg, R92C_OFDM0_AGCCORE1_GAIN, 0x32); + rtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(1), reg); + rtwn_set_chan(sc, ic->ic_curchan, NULL); + break; + case IEEE80211_S_RUN: + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + /* Enable Rx of data frames. */ + rtwn_write_2(sc, R92C_RXFLTMAP2, 0xffff); + + /* Turn link LED on. */ + rtwn_set_led(sc, RTWN_LED_LINK, 1); + break; + } + + /* Set media status to 'Associated'. */ + reg = rtwn_read_4(sc, R92C_CR); + reg = RW(reg, R92C_CR_NETTYPE, R92C_CR_NETTYPE_INFRA); + rtwn_write_4(sc, R92C_CR, reg); + + /* Set BSSID. */ + rtwn_write_4(sc, R92C_BSSID + 0, LE_READ_4(&ni->ni_bssid[0])); + rtwn_write_4(sc, R92C_BSSID + 4, LE_READ_2(&ni->ni_bssid[4])); + + if (ic->ic_curmode == IEEE80211_MODE_11B) + rtwn_write_1(sc, R92C_INIRTS_RATE_SEL, 0); + else /* 802.11b/g */ + rtwn_write_1(sc, R92C_INIRTS_RATE_SEL, 3); + + /* Enable Rx of data frames. */ + rtwn_write_2(sc, R92C_RXFLTMAP2, 0xffff); + + /* Flush all AC queues. */ + rtwn_write_1(sc, R92C_TXPAUSE, 0); + + /* Set beacon interval. */ + rtwn_write_2(sc, R92C_BCN_INTERVAL, ni->ni_intval); + + /* Allow Rx from our BSSID only. */ + rtwn_write_4(sc, R92C_RCR, + rtwn_read_4(sc, R92C_RCR) | + R92C_RCR_CBSSID_DATA | R92C_RCR_CBSSID_BCN); + + /* Enable TSF synchronization. */ + rtwn_tsf_sync_enable(sc); + + rtwn_write_1(sc, R92C_SIFS_CCK + 1, 10); + rtwn_write_1(sc, R92C_SIFS_OFDM + 1, 10); + rtwn_write_1(sc, R92C_SPEC_SIFS + 1, 10); + rtwn_write_1(sc, R92C_MAC_SPEC_SIFS + 1, 10); + rtwn_write_1(sc, R92C_R2T_SIFS + 1, 10); + rtwn_write_1(sc, R92C_T2T_SIFS + 1, 10); + + /* Intialize rate adaptation. */ + rtwn_ra_init(sc); + /* Turn link LED on. */ + rtwn_set_led(sc, RTWN_LED_LINK, 1); + + sc->avg_pwdb = -1; /* Reset average RSSI. */ + /* Reset temperature calibration state machine. */ + sc->thcal_state = 0; + sc->thcal_lctemp = 0; + /* Start periodic calibration. */ + callout_reset(&sc->calib_to, hz * 2, rtwn_calib_to, sc); + break; + default: + break; + } + RTWN_UNLOCK(sc); + IEEE80211_LOCK(ic); + return (rvp->newstate(vap, nstate, arg)); +} + +static int +rtwn_updateedca(struct ieee80211com *ic) +{ + struct rtwn_softc *sc = ic->ic_softc; + const uint16_t aci2reg[WME_NUM_AC] = { + R92C_EDCA_BE_PARAM, + R92C_EDCA_BK_PARAM, + R92C_EDCA_VI_PARAM, + R92C_EDCA_VO_PARAM + }; + int aci, aifs, slottime; + + IEEE80211_LOCK(ic); + slottime = (ic->ic_flags & IEEE80211_F_SHSLOT) ? 9 : 20; + for (aci = 0; aci < WME_NUM_AC; aci++) { + const struct wmeParams *ac = + &ic->ic_wme.wme_chanParams.cap_wmeParams[aci]; + /* AIFS[AC] = AIFSN[AC] * aSlotTime + aSIFSTime. */ + aifs = ac->wmep_aifsn * slottime + 10; + rtwn_write_4(sc, aci2reg[aci], + SM(R92C_EDCA_PARAM_TXOP, ac->wmep_txopLimit) | + SM(R92C_EDCA_PARAM_ECWMIN, ac->wmep_logcwmin) | + SM(R92C_EDCA_PARAM_ECWMAX, ac->wmep_logcwmax) | + SM(R92C_EDCA_PARAM_AIFS, aifs)); + } + IEEE80211_UNLOCK(ic); + return (0); +} + +static void +rtwn_update_avgrssi(struct rtwn_softc *sc, int rate, int8_t rssi) +{ + int pwdb; + + /* Convert antenna signal to percentage. */ + if (rssi <= -100 || rssi >= 20) + pwdb = 0; + else if (rssi >= 0) + pwdb = 100; + else + pwdb = 100 + rssi; + if (rate <= 3) { + /* CCK gain is smaller than OFDM/MCS gain. */ + pwdb += 6; + if (pwdb > 100) + pwdb = 100; + if (pwdb <= 14) + pwdb -= 4; + else if (pwdb <= 26) + pwdb -= 8; + else if (pwdb <= 34) + pwdb -= 6; + else if (pwdb <= 42) + pwdb -= 2; + } + if (sc->avg_pwdb == -1) /* Init. */ + sc->avg_pwdb = pwdb; + else if (sc->avg_pwdb < pwdb) + sc->avg_pwdb = ((sc->avg_pwdb * 19 + pwdb) / 20) + 1; + else + sc->avg_pwdb = ((sc->avg_pwdb * 19 + pwdb) / 20); + DPRINTFN(4, ("PWDB=%d EMA=%d\n", pwdb, sc->avg_pwdb)); +} + +static int8_t +rtwn_get_rssi(struct rtwn_softc *sc, int rate, void *physt) +{ + static const int8_t cckoff[] = { 16, -12, -26, -46 }; + struct r92c_rx_phystat *phy; + struct r92c_rx_cck *cck; + uint8_t rpt; + int8_t rssi; + + if (rate <= 3) { + cck = (struct r92c_rx_cck *)physt; + if (sc->sc_flags & RTWN_FLAG_CCK_HIPWR) { + rpt = (cck->agc_rpt >> 5) & 0x3; + rssi = (cck->agc_rpt & 0x1f) << 1; + } else { + rpt = (cck->agc_rpt >> 6) & 0x3; + rssi = cck->agc_rpt & 0x3e; + } + rssi = cckoff[rpt] - rssi; + } else { /* OFDM/HT. */ + phy = (struct r92c_rx_phystat *)physt; + rssi = ((le32toh(phy->phydw1) >> 1) & 0x7f) - 110; + } + return (rssi); +} + +static void +rtwn_rx_frame(struct rtwn_softc *sc, struct r92c_rx_desc *rx_desc, + struct rtwn_rx_data *rx_data, int desc_idx) +{ + struct ieee80211com *ic = &sc->sc_ic; + struct ieee80211_frame_min *wh; + struct ieee80211_node *ni; + struct r92c_rx_phystat *phy = NULL; + uint32_t rxdw0, rxdw3; + struct mbuf *m, *m1; + bus_dma_segment_t segs[1]; + bus_addr_t physaddr; + uint8_t rate; + int8_t rssi = 0, nf; + int infosz, nsegs, pktlen, shift, error; + + rxdw0 = le32toh(rx_desc->rxdw0); + rxdw3 = le32toh(rx_desc->rxdw3); + + if (__predict_false(rxdw0 & (R92C_RXDW0_CRCERR | R92C_RXDW0_ICVERR))) { + /* + * This should not happen since we setup our Rx filter + * to not receive these frames. + */ + counter_u64_add(ic->ic_ierrors, 1); + return; + } + + pktlen = MS(rxdw0, R92C_RXDW0_PKTLEN); + if (__predict_false(pktlen < sizeof(struct ieee80211_frame_ack) || + pktlen > MCLBYTES)) { + counter_u64_add(ic->ic_ierrors, 1); + return; + } + + rate = MS(rxdw3, R92C_RXDW3_RATE); + infosz = MS(rxdw0, R92C_RXDW0_INFOSZ) * 8; + if (infosz > sizeof(struct r92c_rx_phystat)) + infosz = sizeof(struct r92c_rx_phystat); + shift = MS(rxdw0, R92C_RXDW0_SHIFT); + + /* Get RSSI from PHY status descriptor if present. */ + if (infosz != 0 && (rxdw0 & R92C_RXDW0_PHYST)) { + phy = mtod(rx_data->m, struct r92c_rx_phystat *); + rssi = rtwn_get_rssi(sc, rate, phy); + /* Update our average RSSI. */ + rtwn_update_avgrssi(sc, rate, rssi); + } + + DPRINTFN(5, ("Rx frame len=%d rate=%d infosz=%d shift=%d rssi=%d\n", + pktlen, rate, infosz, shift, rssi)); + + m1 = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); + if (m1 == NULL) { + counter_u64_add(ic->ic_ierrors, 1); + return; + } + bus_dmamap_unload(sc->rx_ring.data_dmat, rx_data->map); + + error = bus_dmamap_load(sc->rx_ring.data_dmat, rx_data->map, + mtod(m1, void *), MCLBYTES, rtwn_dma_map_addr, + &physaddr, 0); + if (error != 0) { + m_freem(m1); + + if (bus_dmamap_load_mbuf_sg(sc->rx_ring.data_dmat, + rx_data->map, rx_data->m, segs, &nsegs, 0)) + panic("%s: could not load old RX mbuf", + device_get_name(sc->sc_dev)); + + /* Physical address may have changed. */ + rtwn_setup_rx_desc(sc, rx_desc, physaddr, MCLBYTES, desc_idx); + counter_u64_add(ic->ic_ierrors, 1); + return; + } + + /* Finalize mbuf. */ + m = rx_data->m; + rx_data->m = m1; + m->m_pkthdr.len = m->m_len = pktlen + infosz + shift; + + /* Update RX descriptor. */ + rtwn_setup_rx_desc(sc, rx_desc, physaddr, MCLBYTES, desc_idx); + + /* Get ieee80211 frame header. */ + if (rxdw0 & R92C_RXDW0_PHYST) + m_adj(m, infosz + shift); + else + m_adj(m, shift); + + nf = -95; + if (ieee80211_radiotap_active(ic)) { + struct rtwn_rx_radiotap_header *tap = &sc->sc_rxtap; + + tap->wr_flags = 0; + if (!(rxdw3 & R92C_RXDW3_HT)) { + switch (rate) { + /* CCK. */ + case 0: tap->wr_rate = 2; break; + case 1: tap->wr_rate = 4; break; + case 2: tap->wr_rate = 11; break; + case 3: tap->wr_rate = 22; break; + /* OFDM. */ + case 4: tap->wr_rate = 12; break; + case 5: tap->wr_rate = 18; break; + case 6: tap->wr_rate = 24; break; + case 7: tap->wr_rate = 36; break; + case 8: tap->wr_rate = 48; break; + case 9: tap->wr_rate = 72; break; + case 10: tap->wr_rate = 96; break; + case 11: tap->wr_rate = 108; break; + } + } else if (rate >= 12) { /* MCS0~15. */ + /* Bit 7 set means HT MCS instead of rate. */ + tap->wr_rate = 0x80 | (rate - 12); + } + tap->wr_dbm_antsignal = rssi; + tap->wr_chan_freq = htole16(ic->ic_curchan->ic_freq); + tap->wr_chan_flags = htole16(ic->ic_curchan->ic_flags); + } + + RTWN_UNLOCK(sc); + wh = mtod(m, struct ieee80211_frame_min *); + if (m->m_len >= sizeof(*wh)) + ni = ieee80211_find_rxnode(ic, wh); + else + ni = NULL; + + /* Send the frame to the 802.11 layer. */ + if (ni != NULL) { + (void)ieee80211_input(ni, m, rssi - nf, nf); + /* Node is no longer needed. */ + ieee80211_free_node(ni); + } else + (void)ieee80211_input_all(ic, m, rssi - nf, nf); + + RTWN_LOCK(sc); +} + +static int +rtwn_tx(struct rtwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni) +{ + struct ieee80211com *ic = &sc->sc_ic; + struct ieee80211vap *vap = ni->ni_vap; + struct ieee80211_frame *wh; + struct ieee80211_key *k = NULL; + struct rtwn_tx_ring *tx_ring; + struct rtwn_tx_data *data; + struct r92c_tx_desc *txd; + bus_dma_segment_t segs[1]; + uint16_t qos; + uint8_t raid, type, tid, qid; + int nsegs, error; + + wh = mtod(m, struct ieee80211_frame *); + type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; + + /* Encrypt the frame if need be. */ + if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { + k = ieee80211_crypto_encap(ni, m); + if (k == NULL) { + m_freem(m); + return (ENOBUFS); + } + /* 802.11 header may have moved. */ + wh = mtod(m, struct ieee80211_frame *); + } + + if (IEEE80211_QOS_HAS_SEQ(wh)) { + qos = ((const struct ieee80211_qosframe *)wh)->i_qos[0]; + tid = qos & IEEE80211_QOS_TID; + } else { + qos = 0; + tid = 0; + } + + switch (type) { + case IEEE80211_FC0_TYPE_CTL: + case IEEE80211_FC0_TYPE_MGT: + qid = RTWN_VO_QUEUE; + break; + default: + qid = M_WME_GETAC(m); + break; + } + + /* Grab a Tx buffer from the ring. */ + tx_ring = &sc->tx_ring[qid]; + data = &tx_ring->tx_data[tx_ring->cur]; + if (data->m != NULL) { + m_freem(m); + return (ENOBUFS); + } + + /* Fill Tx descriptor. */ + txd = &tx_ring->desc[tx_ring->cur]; + if (htole32(txd->txdw0) & R92C_RXDW0_OWN) { + m_freem(m); + return (ENOBUFS); + } + txd->txdw0 = htole32( + SM(R92C_TXDW0_PKTLEN, m->m_pkthdr.len) | + SM(R92C_TXDW0_OFFSET, sizeof(*txd)) | + R92C_TXDW0_FSG | R92C_TXDW0_LSG); + if (IEEE80211_IS_MULTICAST(wh->i_addr1)) + txd->txdw0 |= htole32(R92C_TXDW0_BMCAST); + + txd->txdw1 = 0; + txd->txdw4 = 0; + txd->txdw5 = 0; + + /* XXX TODO: rate control; implement low-rate for EAPOL */ + if (!IEEE80211_IS_MULTICAST(wh->i_addr1) && + type == IEEE80211_FC0_TYPE_DATA) { + if (ic->ic_curmode == IEEE80211_MODE_11B) + raid = R92C_RAID_11B; + else + raid = R92C_RAID_11BG; + txd->txdw1 |= htole32( + SM(R92C_TXDW1_MACID, RTWN_MACID_BSS) | + SM(R92C_TXDW1_QSEL, R92C_TXDW1_QSEL_BE) | + SM(R92C_TXDW1_RAID, raid) | + R92C_TXDW1_AGGBK); + + if (ic->ic_flags & IEEE80211_F_USEPROT) { + if (ic->ic_protmode == IEEE80211_PROT_CTSONLY) { + txd->txdw4 |= htole32(R92C_TXDW4_CTS2SELF | + R92C_TXDW4_HWRTSEN); + } else if (ic->ic_protmode == IEEE80211_PROT_RTSCTS) { + txd->txdw4 |= htole32(R92C_TXDW4_RTSEN | + R92C_TXDW4_HWRTSEN); + } + } + + /* XXX TODO: implement rate control */ + + /* Send RTS at OFDM24. */ + txd->txdw4 |= htole32(SM(R92C_TXDW4_RTSRATE, 8)); + txd->txdw5 |= htole32(SM(R92C_TXDW5_RTSRATE_FBLIMIT, 0xf)); + /* Send data at OFDM54. */ + txd->txdw5 |= htole32(SM(R92C_TXDW5_DATARATE, 11)); + txd->txdw5 |= htole32(SM(R92C_TXDW5_DATARATE_FBLIMIT, 0x1f)); + + } else { + txd->txdw1 |= htole32( + SM(R92C_TXDW1_MACID, 0) | + SM(R92C_TXDW1_QSEL, R92C_TXDW1_QSEL_MGNT) | + SM(R92C_TXDW1_RAID, R92C_RAID_11B)); + + /* Force CCK1. */ + txd->txdw4 |= htole32(R92C_TXDW4_DRVRATE); + txd->txdw5 |= htole32(SM(R92C_TXDW5_DATARATE, 0)); + } + /* Set sequence number (already little endian). */ + txd->txdseq = htole16(M_SEQNO_GET(m) % IEEE80211_SEQ_RANGE); + + if (!qos) { + /* Use HW sequence numbering for non-QoS frames. */ + txd->txdw4 |= htole32(R92C_TXDW4_HWSEQ); + txd->txdseq |= htole16(0x8000); + } else + txd->txdw4 |= htole32(R92C_TXDW4_QOS); + + error = bus_dmamap_load_mbuf_sg(tx_ring->data_dmat, data->map, m, segs, + &nsegs, BUS_DMA_NOWAIT); + if (error != 0 && error != EFBIG) { + device_printf(sc->sc_dev, "can't map mbuf (error %d)\n", error); + m_freem(m); + return (error); + } + if (error != 0) { + struct mbuf *mnew; + + mnew = m_defrag(m, M_NOWAIT); + if (mnew == NULL) { + device_printf(sc->sc_dev, + "can't defragment mbuf\n"); + m_freem(m); + return (ENOBUFS); + } + m = mnew; + + error = bus_dmamap_load_mbuf_sg(tx_ring->data_dmat, data->map, + m, segs, &nsegs, BUS_DMA_NOWAIT); + if (error != 0) { + device_printf(sc->sc_dev, + "can't map mbuf (error %d)\n", error); + m_freem(m); + return (error); + } + } + + txd->txbufaddr = htole32(segs[0].ds_addr); + txd->txbufsize = htole16(m->m_pkthdr.len); + bus_space_barrier(sc->sc_st, sc->sc_sh, 0, sc->sc_mapsize, + BUS_SPACE_BARRIER_WRITE); + txd->txdw0 |= htole32(R92C_TXDW0_OWN); + + bus_dmamap_sync(tx_ring->desc_dmat, tx_ring->desc_map, + BUS_DMASYNC_POSTWRITE); + bus_dmamap_sync(tx_ring->data_dmat, data->map, BUS_DMASYNC_POSTWRITE); + + data->m = m; + data->ni = ni; + + if (ieee80211_radiotap_active_vap(vap)) { + struct rtwn_tx_radiotap_header *tap = &sc->sc_txtap; + + tap->wt_flags = 0; + tap->wt_chan_freq = htole16(ic->ic_curchan->ic_freq); + tap->wt_chan_flags = htole16(ic->ic_curchan->ic_flags); + + ieee80211_radiotap_tx(vap, m); + } + + tx_ring->cur = (tx_ring->cur + 1) % RTWN_TX_LIST_COUNT; + tx_ring->queued++; + + if (tx_ring->queued >= (RTWN_TX_LIST_COUNT - 1)) + sc->qfullmsk |= (1 << qid); + + /* Kick TX. */ + rtwn_write_2(sc, R92C_PCIE_CTRL_REG, (1 << qid)); + return (0); +} + +static void +rtwn_tx_done(struct rtwn_softc *sc, int qid) +{ + struct rtwn_tx_ring *tx_ring = &sc->tx_ring[qid]; + struct rtwn_tx_data *tx_data; + struct r92c_tx_desc *tx_desc; + int i; + + bus_dmamap_sync(tx_ring->desc_dmat, tx_ring->desc_map, + BUS_DMASYNC_POSTREAD); + + for (i = 0; i < RTWN_TX_LIST_COUNT; i++) { + tx_data = &tx_ring->tx_data[i]; + if (tx_data->m == NULL) + continue; + + tx_desc = &tx_ring->desc[i]; + if (le32toh(tx_desc->txdw0) & R92C_TXDW0_OWN) + continue; + + bus_dmamap_unload(tx_ring->desc_dmat, tx_ring->desc_map); + + /* + * XXX TODO: figure out whether the transmit succeeded or not. + * .. and then notify rate control. + */ + ieee80211_tx_complete(tx_data->ni, tx_data->m, 0); + tx_data->ni = NULL; + tx_data->m = NULL; + + sc->sc_tx_timer = 0; + tx_ring->queued--; + } + + if (tx_ring->queued < (RTWN_TX_LIST_COUNT - 1)) + sc->qfullmsk &= ~(1 << qid); + rtwn_start(sc); +} + +static int +rtwn_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, + const struct ieee80211_bpf_params *params) +{ + struct ieee80211com *ic = ni->ni_ic; + struct rtwn_softc *sc = ic->ic_softc; + + RTWN_LOCK(sc); + + /* Prevent management frames from being sent if we're not ready. */ + if (!(sc->sc_flags & RTWN_RUNNING)) { + RTWN_UNLOCK(sc); + m_freem(m); + return (ENETDOWN); + } + + if (rtwn_tx(sc, m, ni) != 0) { + m_freem(m); + RTWN_UNLOCK(sc); + return (EIO); + } + sc->sc_tx_timer = 5; + RTWN_UNLOCK(sc); + return (0); +} + +static int +rtwn_transmit(struct ieee80211com *ic, struct mbuf *m) +{ + struct rtwn_softc *sc = ic->ic_softc; + int error; + + RTWN_LOCK(sc); + if ((sc->sc_flags & RTWN_RUNNING) == 0) { + RTWN_UNLOCK(sc); + return (ENXIO); + } + error = mbufq_enqueue(&sc->sc_snd, m); + if (error) { + RTWN_UNLOCK(sc); + return (error); + } + rtwn_start(sc); + RTWN_UNLOCK(sc); + return (0); +} + +static void +rtwn_parent(struct ieee80211com *ic) +{ + struct rtwn_softc *sc = ic->ic_softc; + int startall = 0; + + RTWN_LOCK(sc); + if (ic->ic_nrunning> 0) { + if (!(sc->sc_flags & RTWN_RUNNING)) { + rtwn_init_locked(sc); + startall = 1; + } + } else if (sc->sc_flags & RTWN_RUNNING) + rtwn_stop_locked(sc); + RTWN_UNLOCK(sc); + if (startall) + ieee80211_start_all(ic); +} + +static void +rtwn_start(struct rtwn_softc *sc) +{ + struct ieee80211_node *ni; + struct mbuf *m; + + RTWN_LOCK_ASSERT(sc); + + if ((sc->sc_flags & RTWN_RUNNING) == 0) + return; + + while (sc->qfullmsk == 0 && (m = mbufq_dequeue(&sc->sc_snd)) != NULL) { + ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; + if (rtwn_tx(sc, m, ni) != 0) { + if_inc_counter(ni->ni_vap->iv_ifp, + IFCOUNTER_OERRORS, 1); + ieee80211_free_node(ni); + continue; + } + sc->sc_tx_timer = 5; + } +} + +static void +rtwn_watchdog(void *arg) +{ + struct rtwn_softc *sc = arg; + struct ieee80211com *ic = &sc->sc_ic; + + RTWN_LOCK_ASSERT(sc); + + KASSERT(sc->sc_flags & RTWN_RUNNING, ("not running")); + + if (sc->sc_tx_timer != 0 && --sc->sc_tx_timer == 0) { + ic_printf(ic, "device timeout\n"); + ieee80211_runtask(ic, &sc->sc_reinit_task); + return; + } + callout_reset(&sc->watchdog_to, hz, rtwn_watchdog, sc); +} + +static int +rtwn_power_on(struct rtwn_softc *sc) +{ + uint32_t reg; + int ntries; + + /* Wait for autoload done bit. */ + for (ntries = 0; ntries < 1000; ntries++) { + if (rtwn_read_1(sc, R92C_APS_FSMCO) & R92C_APS_FSMCO_PFM_ALDN) + break; + DELAY(5); + } + if (ntries == 1000) { + device_printf(sc->sc_dev, + "timeout waiting for chip autoload\n"); + return (ETIMEDOUT); + } + + /* Unlock ISO/CLK/Power control register. */ + rtwn_write_1(sc, R92C_RSV_CTRL, 0); + + /* TODO: check if we need this for 8188CE */ + if (sc->board_type != R92C_BOARD_TYPE_DONGLE) { + /* bt coex */ + reg = rtwn_read_4(sc, R92C_APS_FSMCO); + reg |= (R92C_APS_FSMCO_SOP_ABG | + R92C_APS_FSMCO_SOP_AMB | + R92C_APS_FSMCO_XOP_BTCK); + rtwn_write_4(sc, R92C_APS_FSMCO, reg); + } + + /* Move SPS into PWM mode. */ + rtwn_write_1(sc, R92C_SPS0_CTRL, 0x2b); + + /* Set low byte to 0x0f, leave others unchanged. */ + rtwn_write_4(sc, R92C_AFE_XTAL_CTRL, + (rtwn_read_4(sc, R92C_AFE_XTAL_CTRL) & 0xffffff00) | 0x0f); + + /* TODO: check if we need this for 8188CE */ + if (sc->board_type != R92C_BOARD_TYPE_DONGLE) { + /* bt coex */ + reg = rtwn_read_4(sc, R92C_AFE_XTAL_CTRL); + reg &= (~0x00024800); /* XXX magic from linux */ + rtwn_write_4(sc, R92C_AFE_XTAL_CTRL, reg); + } + + rtwn_write_2(sc, R92C_SYS_ISO_CTRL, + (rtwn_read_2(sc, R92C_SYS_ISO_CTRL) & 0xff) | + R92C_SYS_ISO_CTRL_PWC_EV12V | R92C_SYS_ISO_CTRL_DIOR); + DELAY(200); + + /* TODO: linux does additional btcoex stuff here */ + + /* Auto enable WLAN. */ + rtwn_write_2(sc, R92C_APS_FSMCO, + rtwn_read_2(sc, R92C_APS_FSMCO) | R92C_APS_FSMCO_APFM_ONMAC); + for (ntries = 0; ntries < 1000; ntries++) { + if (!(rtwn_read_2(sc, R92C_APS_FSMCO) & + R92C_APS_FSMCO_APFM_ONMAC)) + break; + DELAY(5); + } + if (ntries == 1000) { + device_printf(sc->sc_dev, "timeout waiting for MAC auto ON\n"); + return (ETIMEDOUT); + } + + /* Enable radio, GPIO and LED functions. */ + rtwn_write_2(sc, R92C_APS_FSMCO, + R92C_APS_FSMCO_AFSM_PCIE | + R92C_APS_FSMCO_PDN_EN | + R92C_APS_FSMCO_PFM_ALDN); + /* Release RF digital isolation. */ + rtwn_write_2(sc, R92C_SYS_ISO_CTRL, + rtwn_read_2(sc, R92C_SYS_ISO_CTRL) & ~R92C_SYS_ISO_CTRL_DIOR); + + if (sc->chip & RTWN_CHIP_92C) + rtwn_write_1(sc, R92C_PCIE_CTRL_REG + 3, 0x77); + else + rtwn_write_1(sc, R92C_PCIE_CTRL_REG + 3, 0x22); + + rtwn_write_4(sc, R92C_INT_MIG, 0); + + if (sc->board_type != R92C_BOARD_TYPE_DONGLE) { + /* bt coex */ + reg = rtwn_read_4(sc, R92C_AFE_XTAL_CTRL + 2); + reg &= 0xfd; /* XXX magic from linux */ + rtwn_write_4(sc, R92C_AFE_XTAL_CTRL + 2, reg); + } + + rtwn_write_1(sc, R92C_GPIO_MUXCFG, + rtwn_read_1(sc, R92C_GPIO_MUXCFG) & ~R92C_GPIO_MUXCFG_RFKILL); + + reg = rtwn_read_1(sc, R92C_GPIO_IO_SEL); + if (!(reg & R92C_GPIO_IO_SEL_RFKILL)) { + device_printf(sc->sc_dev, + "radio is disabled by hardware switch\n"); + return (EPERM); + } + + /* Initialize MAC. */ + reg = rtwn_read_1(sc, R92C_APSD_CTRL); + rtwn_write_1(sc, R92C_APSD_CTRL, + rtwn_read_1(sc, R92C_APSD_CTRL) & ~R92C_APSD_CTRL_OFF); + for (ntries = 0; ntries < 200; ntries++) { + if (!(rtwn_read_1(sc, R92C_APSD_CTRL) & + R92C_APSD_CTRL_OFF_STATUS)) + break; + DELAY(500); + } + if (ntries == 200) { + device_printf(sc->sc_dev, + "timeout waiting for MAC initialization\n"); + return (ETIMEDOUT); + } + + /* Enable MAC DMA/WMAC/SCHEDULE/SEC blocks. */ + reg = rtwn_read_2(sc, R92C_CR); + reg |= R92C_CR_HCI_TXDMA_EN | R92C_CR_HCI_RXDMA_EN | + R92C_CR_TXDMA_EN | R92C_CR_RXDMA_EN | R92C_CR_PROTOCOL_EN | + R92C_CR_SCHEDULE_EN | R92C_CR_MACTXEN | R92C_CR_MACRXEN | + R92C_CR_ENSEC; + rtwn_write_2(sc, R92C_CR, reg); + + rtwn_write_1(sc, 0xfe10, 0x19); + + return (0); +} + +static int +rtwn_llt_init(struct rtwn_softc *sc) +{ + int i, error; + + /* Reserve pages [0; R92C_TX_PAGE_COUNT]. */ + for (i = 0; i < R92C_TX_PAGE_COUNT; i++) { + if ((error = rtwn_llt_write(sc, i, i + 1)) != 0) + return (error); + } + /* NB: 0xff indicates end-of-list. */ + if ((error = rtwn_llt_write(sc, i, 0xff)) != 0) + return (error); + /* + * Use pages [R92C_TX_PAGE_COUNT + 1; R92C_TXPKTBUF_COUNT - 1] + * as ring buffer. + */ + for (++i; i < R92C_TXPKTBUF_COUNT - 1; i++) { + if ((error = rtwn_llt_write(sc, i, i + 1)) != 0) + return (error); + } + /* Make the last page point to the beginning of the ring buffer. */ + error = rtwn_llt_write(sc, i, R92C_TX_PAGE_COUNT + 1); + return (error); +} + +static void +rtwn_fw_reset(struct rtwn_softc *sc) +{ + uint16_t reg; + int ntries; + + /* Tell 8051 to reset itself. */ + rtwn_write_1(sc, R92C_HMETFR + 3, 0x20); + + /* Wait until 8051 resets by itself. */ + for (ntries = 0; ntries < 100; ntries++) { + reg = rtwn_read_2(sc, R92C_SYS_FUNC_EN); + if (!(reg & R92C_SYS_FUNC_EN_CPUEN)) + goto sleep; + DELAY(50); + } + /* Force 8051 reset. */ + rtwn_write_2(sc, R92C_SYS_FUNC_EN, reg & ~R92C_SYS_FUNC_EN_CPUEN); +sleep: + /* + * We must sleep for one second to let the firmware settle. + * Accessing registers too early will hang the whole system. + */ + if (msleep(®, &sc->sc_mtx, 0, "rtwnrst", hz)) { + device_printf(sc->sc_dev, "timeout waiting for firmware " + "initialization to complete\n"); + } +} + +static void +rtwn_fw_loadpage(struct rtwn_softc *sc, int page, const uint8_t *buf, int len) +{ + uint32_t reg; + int off, mlen, i; + + reg = rtwn_read_4(sc, R92C_MCUFWDL); + reg = RW(reg, R92C_MCUFWDL_PAGE, page); + rtwn_write_4(sc, R92C_MCUFWDL, reg); + + DELAY(5); + + off = R92C_FW_START_ADDR; + while (len > 0) { + if (len > 196) + mlen = 196; + else if (len > 4) + mlen = 4; + else + mlen = 1; + for (i = 0; i < mlen; i++) + rtwn_write_1(sc, off++, buf[i]); + buf += mlen; + len -= mlen; + } +} + +static int +rtwn_load_firmware(struct rtwn_softc *sc) +{ + const struct firmware *fw; + const struct r92c_fw_hdr *hdr; + const char *name; + const u_char *ptr; + size_t len; + uint32_t reg; + int mlen, ntries, page, error = 0; + + /* Read firmware image from the filesystem. */ + if ((sc->chip & (RTWN_CHIP_UMC_A_CUT | RTWN_CHIP_92C)) == + RTWN_CHIP_UMC_A_CUT) + name = "rtwn-rtl8192cfwU"; + else + name = "rtwn-rtl8192cfwU_B"; + RTWN_UNLOCK(sc); + fw = firmware_get(name); + RTWN_LOCK(sc); + if (fw == NULL) { + device_printf(sc->sc_dev, + "could not read firmware %s\n", name); + return (ENOENT); + } + len = fw->datasize; + if (len < sizeof(*hdr)) { + device_printf(sc->sc_dev, "firmware too short\n"); + error = EINVAL; + goto fail; + } + ptr = fw->data; + hdr = (const struct r92c_fw_hdr *)ptr; + /* Check if there is a valid FW header and skip it. */ + if ((le16toh(hdr->signature) >> 4) == 0x88c || + (le16toh(hdr->signature) >> 4) == 0x92c) { + DPRINTF(("FW V%d.%d %02d-%02d %02d:%02d\n", + le16toh(hdr->version), le16toh(hdr->subversion), + hdr->month, hdr->date, hdr->hour, hdr->minute)); + ptr += sizeof(*hdr); + len -= sizeof(*hdr); + } + + if (rtwn_read_1(sc, R92C_MCUFWDL) & R92C_MCUFWDL_RAM_DL_SEL) + rtwn_fw_reset(sc); + + /* Enable FW download. */ + rtwn_write_2(sc, R92C_SYS_FUNC_EN, + rtwn_read_2(sc, R92C_SYS_FUNC_EN) | + R92C_SYS_FUNC_EN_CPUEN); + rtwn_write_1(sc, R92C_MCUFWDL, + rtwn_read_1(sc, R92C_MCUFWDL) | R92C_MCUFWDL_EN); + rtwn_write_1(sc, R92C_MCUFWDL + 2, + rtwn_read_1(sc, R92C_MCUFWDL + 2) & ~0x08); + + /* Reset the FWDL checksum. */ + rtwn_write_1(sc, R92C_MCUFWDL, + rtwn_read_1(sc, R92C_MCUFWDL) | R92C_MCUFWDL_CHKSUM_RPT); + + for (page = 0; len > 0; page++) { + mlen = MIN(len, R92C_FW_PAGE_SIZE); + rtwn_fw_loadpage(sc, page, ptr, mlen); + ptr += mlen; + len -= mlen; + } + + /* Disable FW download. */ + rtwn_write_1(sc, R92C_MCUFWDL, + rtwn_read_1(sc, R92C_MCUFWDL) & ~R92C_MCUFWDL_EN); + rtwn_write_1(sc, R92C_MCUFWDL + 1, 0); + + /* Wait for checksum report. */ + for (ntries = 0; ntries < 1000; ntries++) { + if (rtwn_read_4(sc, R92C_MCUFWDL) & R92C_MCUFWDL_CHKSUM_RPT) + break; + DELAY(5); + } + if (ntries == 1000) { + device_printf(sc->sc_dev, + "timeout waiting for checksum report\n"); + error = ETIMEDOUT; + goto fail; + } + + reg = rtwn_read_4(sc, R92C_MCUFWDL); + reg = (reg & ~R92C_MCUFWDL_WINTINI_RDY) | R92C_MCUFWDL_RDY; + rtwn_write_4(sc, R92C_MCUFWDL, reg); + /* Wait for firmware readiness. */ + for (ntries = 0; ntries < 2000; ntries++) { + if (rtwn_read_4(sc, R92C_MCUFWDL) & R92C_MCUFWDL_WINTINI_RDY) + break; + DELAY(50); + } + if (ntries == 1000) { + device_printf(sc->sc_dev, + "timeout waiting for firmware readiness\n"); + error = ETIMEDOUT; + goto fail; + } +fail: + firmware_put(fw, FIRMWARE_UNLOAD); + return (error); +} + +static int +rtwn_dma_init(struct rtwn_softc *sc) +{ + uint32_t reg; + int error; + + /* Initialize LLT table. */ + error = rtwn_llt_init(sc); + if (error != 0) + return error; + + /* Set number of pages for normal priority queue. */ + rtwn_write_2(sc, R92C_RQPN_NPQ, 0); + rtwn_write_4(sc, R92C_RQPN, + /* Set number of pages for public queue. */ + SM(R92C_RQPN_PUBQ, R92C_PUBQ_NPAGES) | + /* Set number of pages for high priority queue. */ + SM(R92C_RQPN_HPQ, R92C_HPQ_NPAGES) | + /* Set number of pages for low priority queue. */ + SM(R92C_RQPN_LPQ, R92C_LPQ_NPAGES) | + /* Load values. */ + R92C_RQPN_LD); + + rtwn_write_1(sc, R92C_TXPKTBUF_BCNQ_BDNY, R92C_TX_PAGE_BOUNDARY); + rtwn_write_1(sc, R92C_TXPKTBUF_MGQ_BDNY, R92C_TX_PAGE_BOUNDARY); + rtwn_write_1(sc, R92C_TXPKTBUF_WMAC_LBK_BF_HD, R92C_TX_PAGE_BOUNDARY); + rtwn_write_1(sc, R92C_TRXFF_BNDY, R92C_TX_PAGE_BOUNDARY); + rtwn_write_1(sc, R92C_TDECTRL + 1, R92C_TX_PAGE_BOUNDARY); + + reg = rtwn_read_2(sc, R92C_TRXDMA_CTRL); + reg &= ~R92C_TRXDMA_CTRL_QMAP_M; + reg |= 0xF771; + rtwn_write_2(sc, R92C_TRXDMA_CTRL, reg); + + rtwn_write_4(sc, R92C_TCR, R92C_TCR_CFENDFORM | (1 << 12) | (1 << 13)); + + /* Configure Tx DMA. */ + rtwn_write_4(sc, R92C_BKQ_DESA, sc->tx_ring[RTWN_BK_QUEUE].paddr); + rtwn_write_4(sc, R92C_BEQ_DESA, sc->tx_ring[RTWN_BE_QUEUE].paddr); + rtwn_write_4(sc, R92C_VIQ_DESA, sc->tx_ring[RTWN_VI_QUEUE].paddr); + rtwn_write_4(sc, R92C_VOQ_DESA, sc->tx_ring[RTWN_VO_QUEUE].paddr); + rtwn_write_4(sc, R92C_BCNQ_DESA, sc->tx_ring[RTWN_BEACON_QUEUE].paddr); + rtwn_write_4(sc, R92C_MGQ_DESA, sc->tx_ring[RTWN_MGNT_QUEUE].paddr); + rtwn_write_4(sc, R92C_HQ_DESA, sc->tx_ring[RTWN_HIGH_QUEUE].paddr); + + /* Configure Rx DMA. */ + rtwn_write_4(sc, R92C_RX_DESA, sc->rx_ring.paddr); + + /* Set Tx/Rx transfer page boundary. */ + rtwn_write_2(sc, R92C_TRXFF_BNDY + 2, 0x27ff); + + /* Set Tx/Rx transfer page size. */ + rtwn_write_1(sc, R92C_PBP, + SM(R92C_PBP_PSRX, R92C_PBP_128) | + SM(R92C_PBP_PSTX, R92C_PBP_128)); + return (0); +} + +static void +rtwn_mac_init(struct rtwn_softc *sc) +{ + int i; + + /* Write MAC initialization values. */ + for (i = 0; i < nitems(rtl8192ce_mac); i++) + rtwn_write_1(sc, rtl8192ce_mac[i].reg, rtl8192ce_mac[i].val); +} + +static void +rtwn_bb_init(struct rtwn_softc *sc) +{ + const struct rtwn_bb_prog *prog; + uint32_t reg; + int i; + + /* Enable BB and RF. */ + rtwn_write_2(sc, R92C_SYS_FUNC_EN, + rtwn_read_2(sc, R92C_SYS_FUNC_EN) | + R92C_SYS_FUNC_EN_BBRSTB | R92C_SYS_FUNC_EN_BB_GLB_RST | + R92C_SYS_FUNC_EN_DIO_RF); + + rtwn_write_2(sc, R92C_AFE_PLL_CTRL, 0xdb83); + + rtwn_write_1(sc, R92C_RF_CTRL, + R92C_RF_CTRL_EN | R92C_RF_CTRL_RSTB | R92C_RF_CTRL_SDMRSTB); + + rtwn_write_1(sc, R92C_SYS_FUNC_EN, + R92C_SYS_FUNC_EN_DIO_PCIE | R92C_SYS_FUNC_EN_PCIEA | + R92C_SYS_FUNC_EN_PPLL | R92C_SYS_FUNC_EN_BB_GLB_RST | + R92C_SYS_FUNC_EN_BBRSTB); + + rtwn_write_1(sc, R92C_AFE_XTAL_CTRL + 1, 0x80); + + rtwn_write_4(sc, R92C_LEDCFG0, + rtwn_read_4(sc, R92C_LEDCFG0) | 0x00800000); + + /* Select BB programming. */ + prog = (sc->chip & RTWN_CHIP_92C) ? + &rtl8192ce_bb_prog_2t : &rtl8192ce_bb_prog_1t; + + /* Write BB initialization values. */ + for (i = 0; i < prog->count; i++) { + rtwn_bb_write(sc, prog->regs[i], prog->vals[i]); + DELAY(1); + } + + if (sc->chip & RTWN_CHIP_92C_1T2R) { + /* 8192C 1T only configuration. */ + reg = rtwn_bb_read(sc, R92C_FPGA0_TXINFO); + reg = (reg & ~0x00000003) | 0x2; + rtwn_bb_write(sc, R92C_FPGA0_TXINFO, reg); + + reg = rtwn_bb_read(sc, R92C_FPGA1_TXINFO); + reg = (reg & ~0x00300033) | 0x00200022; + rtwn_bb_write(sc, R92C_FPGA1_TXINFO, reg); + + reg = rtwn_bb_read(sc, R92C_CCK0_AFESETTING); + reg = (reg & ~0xff000000) | 0x45 << 24; + rtwn_bb_write(sc, R92C_CCK0_AFESETTING, reg); + + reg = rtwn_bb_read(sc, R92C_OFDM0_TRXPATHENA); + reg = (reg & ~0x000000ff) | 0x23; + rtwn_bb_write(sc, R92C_OFDM0_TRXPATHENA, reg); + + reg = rtwn_bb_read(sc, R92C_OFDM0_AGCPARAM1); + reg = (reg & ~0x00000030) | 1 << 4; + rtwn_bb_write(sc, R92C_OFDM0_AGCPARAM1, reg); + + reg = rtwn_bb_read(sc, 0xe74); + reg = (reg & ~0x0c000000) | 2 << 26; + rtwn_bb_write(sc, 0xe74, reg); + reg = rtwn_bb_read(sc, 0xe78); + reg = (reg & ~0x0c000000) | 2 << 26; + rtwn_bb_write(sc, 0xe78, reg); + reg = rtwn_bb_read(sc, 0xe7c); + reg = (reg & ~0x0c000000) | 2 << 26; + rtwn_bb_write(sc, 0xe7c, reg); + reg = rtwn_bb_read(sc, 0xe80); + reg = (reg & ~0x0c000000) | 2 << 26; + rtwn_bb_write(sc, 0xe80, reg); + reg = rtwn_bb_read(sc, 0xe88); + reg = (reg & ~0x0c000000) | 2 << 26; + rtwn_bb_write(sc, 0xe88, reg); + } + + /* Write AGC values. */ + for (i = 0; i < prog->agccount; i++) { + rtwn_bb_write(sc, R92C_OFDM0_AGCRSSITABLE, + prog->agcvals[i]); + DELAY(1); + } + + if (rtwn_bb_read(sc, R92C_HSSI_PARAM2(0)) & + R92C_HSSI_PARAM2_CCK_HIPWR) + sc->sc_flags |= RTWN_FLAG_CCK_HIPWR; +} + +static void +rtwn_rf_init(struct rtwn_softc *sc) +{ + const struct rtwn_rf_prog *prog; + uint32_t reg, type; + int i, j, idx, off; + + /* Select RF programming based on board type. */ + if (!(sc->chip & RTWN_CHIP_92C)) { + if (sc->board_type == R92C_BOARD_TYPE_MINICARD) + prog = rtl8188ce_rf_prog; + else if (sc->board_type == R92C_BOARD_TYPE_HIGHPA) + prog = rtl8188ru_rf_prog; + else + prog = rtl8188cu_rf_prog; + } else + prog = rtl8192ce_rf_prog; + + for (i = 0; i < sc->nrxchains; i++) { + /* Save RF_ENV control type. */ + idx = i / 2; + off = (i % 2) * 16; + reg = rtwn_bb_read(sc, R92C_FPGA0_RFIFACESW(idx)); + type = (reg >> off) & 0x10; + + /* Set RF_ENV enable. */ + reg = rtwn_bb_read(sc, R92C_FPGA0_RFIFACEOE(i)); + reg |= 0x100000; + rtwn_bb_write(sc, R92C_FPGA0_RFIFACEOE(i), reg); + DELAY(1); + /* Set RF_ENV output high. */ + reg = rtwn_bb_read(sc, R92C_FPGA0_RFIFACEOE(i)); + reg |= 0x10; + rtwn_bb_write(sc, R92C_FPGA0_RFIFACEOE(i), reg); + DELAY(1); + /* Set address and data lengths of RF registers. */ + reg = rtwn_bb_read(sc, R92C_HSSI_PARAM2(i)); + reg &= ~R92C_HSSI_PARAM2_ADDR_LENGTH; + rtwn_bb_write(sc, R92C_HSSI_PARAM2(i), reg); + DELAY(1); + reg = rtwn_bb_read(sc, R92C_HSSI_PARAM2(i)); + reg &= ~R92C_HSSI_PARAM2_DATA_LENGTH; + rtwn_bb_write(sc, R92C_HSSI_PARAM2(i), reg); + DELAY(1); + + /* Write RF initialization values for this chain. */ + for (j = 0; j < prog[i].count; j++) { + if (prog[i].regs[j] >= 0xf9 && + prog[i].regs[j] <= 0xfe) { + /* + * These are fake RF registers offsets that + * indicate a delay is required. + */ + DELAY(50); + continue; + } + rtwn_rf_write(sc, i, prog[i].regs[j], + prog[i].vals[j]); + DELAY(1); + } + + /* Restore RF_ENV control type. */ + reg = rtwn_bb_read(sc, R92C_FPGA0_RFIFACESW(idx)); + reg &= ~(0x10 << off) | (type << off); + rtwn_bb_write(sc, R92C_FPGA0_RFIFACESW(idx), reg); + + /* Cache RF register CHNLBW. */ + sc->rf_chnlbw[i] = rtwn_rf_read(sc, i, R92C_RF_CHNLBW); + } + + if ((sc->chip & (RTWN_CHIP_UMC_A_CUT | RTWN_CHIP_92C)) == + RTWN_CHIP_UMC_A_CUT) { + rtwn_rf_write(sc, 0, R92C_RF_RX_G1, 0x30255); + rtwn_rf_write(sc, 0, R92C_RF_RX_G2, 0x50a00); + } +} + +static void +rtwn_cam_init(struct rtwn_softc *sc) +{ + /* Invalidate all CAM entries. */ + rtwn_write_4(sc, R92C_CAMCMD, + R92C_CAMCMD_POLLING | R92C_CAMCMD_CLR); +} + +static void +rtwn_pa_bias_init(struct rtwn_softc *sc) +{ + uint8_t reg; + int i; + + for (i = 0; i < sc->nrxchains; i++) { + if (sc->pa_setting & (1 << i)) + continue; + rtwn_rf_write(sc, i, R92C_RF_IPA, 0x0f406); + rtwn_rf_write(sc, i, R92C_RF_IPA, 0x4f406); + rtwn_rf_write(sc, i, R92C_RF_IPA, 0x8f406); + rtwn_rf_write(sc, i, R92C_RF_IPA, 0xcf406); + } + if (!(sc->pa_setting & 0x10)) { + reg = rtwn_read_1(sc, 0x16); + reg = (reg & ~0xf0) | 0x90; + rtwn_write_1(sc, 0x16, reg); + } +} + +static void +rtwn_rxfilter_init(struct rtwn_softc *sc) +{ + /* Initialize Rx filter. */ + /* TODO: use better filter for monitor mode. */ + rtwn_write_4(sc, R92C_RCR, + R92C_RCR_AAP | R92C_RCR_APM | R92C_RCR_AM | R92C_RCR_AB | + R92C_RCR_APP_ICV | R92C_RCR_AMF | R92C_RCR_HTC_LOC_CTRL | + R92C_RCR_APP_MIC | R92C_RCR_APP_PHYSTS); + /* Accept all multicast frames. */ + rtwn_write_4(sc, R92C_MAR + 0, 0xffffffff); + rtwn_write_4(sc, R92C_MAR + 4, 0xffffffff); + /* Accept all management frames. */ + rtwn_write_2(sc, R92C_RXFLTMAP0, 0xffff); + /* Reject all control frames. */ + rtwn_write_2(sc, R92C_RXFLTMAP1, 0x0000); + /* Accept all data frames. */ + rtwn_write_2(sc, R92C_RXFLTMAP2, 0xffff); +} + +static void +rtwn_edca_init(struct rtwn_softc *sc) +{ + + rtwn_write_2(sc, R92C_SPEC_SIFS, 0x1010); + rtwn_write_2(sc, R92C_MAC_SPEC_SIFS, 0x1010); + rtwn_write_2(sc, R92C_SIFS_CCK, 0x1010); + rtwn_write_2(sc, R92C_SIFS_OFDM, 0x0e0e); + rtwn_write_4(sc, R92C_EDCA_BE_PARAM, 0x005ea42b); + rtwn_write_4(sc, R92C_EDCA_BK_PARAM, 0x0000a44f); + rtwn_write_4(sc, R92C_EDCA_VI_PARAM, 0x005e4322); + rtwn_write_4(sc, R92C_EDCA_VO_PARAM, 0x002f3222); +} + +static void +rtwn_write_txpower(struct rtwn_softc *sc, int chain, + uint16_t power[RTWN_RIDX_COUNT]) +{ + uint32_t reg; + + /* Write per-CCK rate Tx power. */ + if (chain == 0) { + reg = rtwn_bb_read(sc, R92C_TXAGC_A_CCK1_MCS32); + reg = RW(reg, R92C_TXAGC_A_CCK1, power[0]); + rtwn_bb_write(sc, R92C_TXAGC_A_CCK1_MCS32, reg); + reg = rtwn_bb_read(sc, R92C_TXAGC_B_CCK11_A_CCK2_11); + reg = RW(reg, R92C_TXAGC_A_CCK2, power[1]); + reg = RW(reg, R92C_TXAGC_A_CCK55, power[2]); + reg = RW(reg, R92C_TXAGC_A_CCK11, power[3]); + rtwn_bb_write(sc, R92C_TXAGC_B_CCK11_A_CCK2_11, reg); + } else { + reg = rtwn_bb_read(sc, R92C_TXAGC_B_CCK1_55_MCS32); + reg = RW(reg, R92C_TXAGC_B_CCK1, power[0]); + reg = RW(reg, R92C_TXAGC_B_CCK2, power[1]); + reg = RW(reg, R92C_TXAGC_B_CCK55, power[2]); + rtwn_bb_write(sc, R92C_TXAGC_B_CCK1_55_MCS32, reg); + reg = rtwn_bb_read(sc, R92C_TXAGC_B_CCK11_A_CCK2_11); + reg = RW(reg, R92C_TXAGC_B_CCK11, power[3]); + rtwn_bb_write(sc, R92C_TXAGC_B_CCK11_A_CCK2_11, reg); + } + /* Write per-OFDM rate Tx power. */ + rtwn_bb_write(sc, R92C_TXAGC_RATE18_06(chain), + SM(R92C_TXAGC_RATE06, power[ 4]) | + SM(R92C_TXAGC_RATE09, power[ 5]) | + SM(R92C_TXAGC_RATE12, power[ 6]) | + SM(R92C_TXAGC_RATE18, power[ 7])); + rtwn_bb_write(sc, R92C_TXAGC_RATE54_24(chain), + SM(R92C_TXAGC_RATE24, power[ 8]) | + SM(R92C_TXAGC_RATE36, power[ 9]) | + SM(R92C_TXAGC_RATE48, power[10]) | + SM(R92C_TXAGC_RATE54, power[11])); + /* Write per-MCS Tx power. */ + rtwn_bb_write(sc, R92C_TXAGC_MCS03_MCS00(chain), + SM(R92C_TXAGC_MCS00, power[12]) | + SM(R92C_TXAGC_MCS01, power[13]) | + SM(R92C_TXAGC_MCS02, power[14]) | + SM(R92C_TXAGC_MCS03, power[15])); + rtwn_bb_write(sc, R92C_TXAGC_MCS07_MCS04(chain), + SM(R92C_TXAGC_MCS04, power[16]) | + SM(R92C_TXAGC_MCS05, power[17]) | + SM(R92C_TXAGC_MCS06, power[18]) | + SM(R92C_TXAGC_MCS07, power[19])); + rtwn_bb_write(sc, R92C_TXAGC_MCS11_MCS08(chain), + SM(R92C_TXAGC_MCS08, power[20]) | + SM(R92C_TXAGC_MCS09, power[21]) | + SM(R92C_TXAGC_MCS10, power[22]) | + SM(R92C_TXAGC_MCS11, power[23])); + rtwn_bb_write(sc, R92C_TXAGC_MCS15_MCS12(chain), + SM(R92C_TXAGC_MCS12, power[24]) | + SM(R92C_TXAGC_MCS13, power[25]) | + SM(R92C_TXAGC_MCS14, power[26]) | + SM(R92C_TXAGC_MCS15, power[27])); +} + +static void +rtwn_get_txpower(struct rtwn_softc *sc, int chain, + struct ieee80211_channel *c, struct ieee80211_channel *extc, + uint16_t power[RTWN_RIDX_COUNT]) +{ + struct ieee80211com *ic = &sc->sc_ic; + struct r92c_rom *rom = &sc->rom; + uint16_t cckpow, ofdmpow, htpow, diff, max; + const struct rtwn_txpwr *base; + int ridx, chan, group; + + /* Determine channel group. */ + chan = ieee80211_chan2ieee(ic, c); /* XXX center freq! */ + if (chan <= 3) + group = 0; + else if (chan <= 9) + group = 1; + else + group = 2; + + /* Get original Tx power based on board type and RF chain. */ + if (!(sc->chip & RTWN_CHIP_92C)) { + if (sc->board_type == R92C_BOARD_TYPE_HIGHPA) + base = &rtl8188ru_txagc[chain]; + else + base = &rtl8192cu_txagc[chain]; + } else + base = &rtl8192cu_txagc[chain]; + + memset(power, 0, RTWN_RIDX_COUNT * sizeof(power[0])); + if (sc->regulatory == 0) { + for (ridx = 0; ridx <= 3; ridx++) + power[ridx] = base->pwr[0][ridx]; + } + for (ridx = 4; ridx < RTWN_RIDX_COUNT; ridx++) { + if (sc->regulatory == 3) { + power[ridx] = base->pwr[0][ridx]; + /* Apply vendor limits. */ + if (extc != NULL) + max = rom->ht40_max_pwr[group]; + else + max = rom->ht20_max_pwr[group]; + max = (max >> (chain * 4)) & 0xf; + if (power[ridx] > max) + power[ridx] = max; + } else if (sc->regulatory == 1) { + if (extc == NULL) + power[ridx] = base->pwr[group][ridx]; + } else if (sc->regulatory != 2) + power[ridx] = base->pwr[0][ridx]; + } + + /* Compute per-CCK rate Tx power. */ + cckpow = rom->cck_tx_pwr[chain][group]; + for (ridx = 0; ridx <= 3; ridx++) { + power[ridx] += cckpow; + if (power[ridx] > R92C_MAX_TX_PWR) + power[ridx] = R92C_MAX_TX_PWR; + } + + htpow = rom->ht40_1s_tx_pwr[chain][group]; + if (sc->ntxchains > 1) { + /* Apply reduction for 2 spatial streams. */ + diff = rom->ht40_2s_tx_pwr_diff[group]; + diff = (diff >> (chain * 4)) & 0xf; + htpow = (htpow > diff) ? htpow - diff : 0; + } + + /* Compute per-OFDM rate Tx power. */ + diff = rom->ofdm_tx_pwr_diff[group]; + diff = (diff >> (chain * 4)) & 0xf; + ofdmpow = htpow + diff; /* HT->OFDM correction. */ + for (ridx = 4; ridx <= 11; ridx++) { + power[ridx] += ofdmpow; + if (power[ridx] > R92C_MAX_TX_PWR) + power[ridx] = R92C_MAX_TX_PWR; + } + + /* Compute per-MCS Tx power. */ + if (extc == NULL) { + diff = rom->ht20_tx_pwr_diff[group]; + diff = (diff >> (chain * 4)) & 0xf; + htpow += diff; /* HT40->HT20 correction. */ + } + for (ridx = 12; ridx <= 27; ridx++) { + power[ridx] += htpow; + if (power[ridx] > R92C_MAX_TX_PWR) + power[ridx] = R92C_MAX_TX_PWR; + } +#ifdef RTWN_DEBUG + if (sc->sc_debug >= 4) { + /* Dump per-rate Tx power values. */ + printf("Tx power for chain %d:\n", chain); + for (ridx = 0; ridx < RTWN_RIDX_COUNT; ridx++) + printf("Rate %d = %u\n", ridx, power[ridx]); + } +#endif +} + +static void +rtwn_set_txpower(struct rtwn_softc *sc, struct ieee80211_channel *c, + struct ieee80211_channel *extc) +{ + uint16_t power[RTWN_RIDX_COUNT]; + int i; + + for (i = 0; i < sc->ntxchains; i++) { + /* Compute per-rate Tx power values. */ + rtwn_get_txpower(sc, i, c, extc, power); + /* Write per-rate Tx power values to hardware. */ + rtwn_write_txpower(sc, i, power); + } +} + +static void +rtwn_scan_start(struct ieee80211com *ic) +{ + + /* XXX do nothing? */ +} + +static void +rtwn_scan_end(struct ieee80211com *ic) +{ + + /* XXX do nothing? */ +} + +static void +rtwn_set_channel(struct ieee80211com *ic) +{ + struct rtwn_softc *sc = ic->ic_softc; + struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); + + RTWN_LOCK(sc); + if (vap->iv_state == IEEE80211_S_SCAN) { + /* Make link LED blink during scan. */ + rtwn_set_led(sc, RTWN_LED_LINK, !sc->ledlink); + } + rtwn_set_chan(sc, ic->ic_curchan, NULL); + RTWN_UNLOCK(sc); +} + +static void +rtwn_update_mcast(struct ieee80211com *ic) +{ + + /* XXX do nothing? */ +} + +static void +rtwn_set_chan(struct rtwn_softc *sc, struct ieee80211_channel *c, + struct ieee80211_channel *extc) +{ + struct ieee80211com *ic = &sc->sc_ic; + u_int chan; + int i; + + chan = ieee80211_chan2ieee(ic, c); /* XXX center freq! */ + if (chan == 0 || chan == IEEE80211_CHAN_ANY) { + device_printf(sc->sc_dev, + "%s: invalid channel %x\n", __func__, chan); + return; + } + + /* Set Tx power for this new channel. */ + rtwn_set_txpower(sc, c, extc); + + for (i = 0; i < sc->nrxchains; i++) { + rtwn_rf_write(sc, i, R92C_RF_CHNLBW, + RW(sc->rf_chnlbw[i], R92C_RF_CHNLBW_CHNL, chan)); + } +#ifndef IEEE80211_NO_HT + if (extc != NULL) { + uint32_t reg; + + /* Is secondary channel below or above primary? */ + int prichlo = c->ic_freq < extc->ic_freq; + + rtwn_write_1(sc, R92C_BWOPMODE, + rtwn_read_1(sc, R92C_BWOPMODE) & ~R92C_BWOPMODE_20MHZ); + + reg = rtwn_read_1(sc, R92C_RRSR + 2); + reg = (reg & ~0x6f) | (prichlo ? 1 : 2) << 5; + rtwn_write_1(sc, R92C_RRSR + 2, reg); + + rtwn_bb_write(sc, R92C_FPGA0_RFMOD, + rtwn_bb_read(sc, R92C_FPGA0_RFMOD) | R92C_RFMOD_40MHZ); + rtwn_bb_write(sc, R92C_FPGA1_RFMOD, + rtwn_bb_read(sc, R92C_FPGA1_RFMOD) | R92C_RFMOD_40MHZ); + + /* Set CCK side band. */ + reg = rtwn_bb_read(sc, R92C_CCK0_SYSTEM); + reg = (reg & ~0x00000010) | (prichlo ? 0 : 1) << 4; + rtwn_bb_write(sc, R92C_CCK0_SYSTEM, reg); + + reg = rtwn_bb_read(sc, R92C_OFDM1_LSTF); + reg = (reg & ~0x00000c00) | (prichlo ? 1 : 2) << 10; + rtwn_bb_write(sc, R92C_OFDM1_LSTF, reg); + + rtwn_bb_write(sc, R92C_FPGA0_ANAPARAM2, + rtwn_bb_read(sc, R92C_FPGA0_ANAPARAM2) & + ~R92C_FPGA0_ANAPARAM2_CBW20); + + reg = rtwn_bb_read(sc, 0x818); + reg = (reg & ~0x0c000000) | (prichlo ? 2 : 1) << 26; + rtwn_bb_write(sc, 0x818, reg); + + /* Select 40MHz bandwidth. */ + rtwn_rf_write(sc, 0, R92C_RF_CHNLBW, + (sc->rf_chnlbw[0] & ~0xfff) | chan); + } else +#endif + { + rtwn_write_1(sc, R92C_BWOPMODE, + rtwn_read_1(sc, R92C_BWOPMODE) | R92C_BWOPMODE_20MHZ); + + rtwn_bb_write(sc, R92C_FPGA0_RFMOD, + rtwn_bb_read(sc, R92C_FPGA0_RFMOD) & ~R92C_RFMOD_40MHZ); + rtwn_bb_write(sc, R92C_FPGA1_RFMOD, + rtwn_bb_read(sc, R92C_FPGA1_RFMOD) & ~R92C_RFMOD_40MHZ); + + rtwn_bb_write(sc, R92C_FPGA0_ANAPARAM2, + rtwn_bb_read(sc, R92C_FPGA0_ANAPARAM2) | + R92C_FPGA0_ANAPARAM2_CBW20); + + /* Select 20MHz bandwidth. */ + rtwn_rf_write(sc, 0, R92C_RF_CHNLBW, + (sc->rf_chnlbw[0] & ~0xfff) | R92C_RF_CHNLBW_BW20 | chan); + } +} + +static int +rtwn_iq_calib_chain(struct rtwn_softc *sc, int chain, uint16_t tx[2], + uint16_t rx[2]) +{ + uint32_t status; + int offset = chain * 0x20; + + if (chain == 0) { /* IQ calibration for chain 0. */ + /* IQ calibration settings for chain 0. */ + rtwn_bb_write(sc, 0xe30, 0x10008c1f); + rtwn_bb_write(sc, 0xe34, 0x10008c1f); + rtwn_bb_write(sc, 0xe38, 0x82140102); + + if (sc->ntxchains > 1) { + rtwn_bb_write(sc, 0xe3c, 0x28160202); /* 2T */ + /* IQ calibration settings for chain 1. */ + rtwn_bb_write(sc, 0xe50, 0x10008c22); + rtwn_bb_write(sc, 0xe54, 0x10008c22); + rtwn_bb_write(sc, 0xe58, 0x82140102); + rtwn_bb_write(sc, 0xe5c, 0x28160202); + } else + rtwn_bb_write(sc, 0xe3c, 0x28160502); /* 1T */ + + /* LO calibration settings. */ + rtwn_bb_write(sc, 0xe4c, 0x001028d1); + /* We're doing LO and IQ calibration in one shot. */ + rtwn_bb_write(sc, 0xe48, 0xf9000000); + rtwn_bb_write(sc, 0xe48, 0xf8000000); + + } else { /* IQ calibration for chain 1. */ + /* We're doing LO and IQ calibration in one shot. */ + rtwn_bb_write(sc, 0xe60, 0x00000002); + rtwn_bb_write(sc, 0xe60, 0x00000000); + } + + /* Give LO and IQ calibrations the time to complete. */ + DELAY(1000); + + /* Read IQ calibration status. */ + status = rtwn_bb_read(sc, 0xeac); + + if (status & (1 << (28 + chain * 3))) + return (0); /* Tx failed. */ + /* Read Tx IQ calibration results. */ + tx[0] = (rtwn_bb_read(sc, 0xe94 + offset) >> 16) & 0x3ff; + tx[1] = (rtwn_bb_read(sc, 0xe9c + offset) >> 16) & 0x3ff; + if (tx[0] == 0x142 || tx[1] == 0x042) + return (0); /* Tx failed. */ + + if (status & (1 << (27 + chain * 3))) + return (1); /* Rx failed. */ + /* Read Rx IQ calibration results. */ + rx[0] = (rtwn_bb_read(sc, 0xea4 + offset) >> 16) & 0x3ff; + rx[1] = (rtwn_bb_read(sc, 0xeac + offset) >> 16) & 0x3ff; + if (rx[0] == 0x132 || rx[1] == 0x036) + return (1); /* Rx failed. */ + + return (3); /* Both Tx and Rx succeeded. */ +} + +static void +rtwn_iq_calib_run(struct rtwn_softc *sc, int n, uint16_t tx[2][2], + uint16_t rx[2][2]) +{ + /* Registers to save and restore during IQ calibration. */ + struct iq_cal_regs { + uint32_t adda[16]; + uint8_t txpause; + uint8_t bcn_ctrl; + uint8_t ustime_tsf; + uint32_t gpio_muxcfg; + uint32_t ofdm0_trxpathena; + uint32_t ofdm0_trmuxpar; + uint32_t fpga0_rfifacesw1; + } iq_cal_regs; + static const uint16_t reg_adda[16] = { + 0x85c, 0xe6c, 0xe70, 0xe74, + 0xe78, 0xe7c, 0xe80, 0xe84, + 0xe88, 0xe8c, 0xed0, 0xed4, + 0xed8, 0xedc, 0xee0, 0xeec + }; + int i, chain; + uint32_t hssi_param1; + + if (n == 0) { + for (i = 0; i < nitems(reg_adda); i++) + iq_cal_regs.adda[i] = rtwn_bb_read(sc, reg_adda[i]); + + iq_cal_regs.txpause = rtwn_read_1(sc, R92C_TXPAUSE); + iq_cal_regs.bcn_ctrl = rtwn_read_1(sc, R92C_BCN_CTRL); + iq_cal_regs.ustime_tsf = rtwn_read_1(sc, R92C_USTIME_TSF); + iq_cal_regs.gpio_muxcfg = rtwn_read_4(sc, R92C_GPIO_MUXCFG); + } + + if (sc->ntxchains == 1) { + rtwn_bb_write(sc, reg_adda[0], 0x0b1b25a0); + for (i = 1; i < nitems(reg_adda); i++) + rtwn_bb_write(sc, reg_adda[i], 0x0bdb25a0); + } else { + for (i = 0; i < nitems(reg_adda); i++) + rtwn_bb_write(sc, reg_adda[i], 0x04db25a4); + } + + hssi_param1 = rtwn_bb_read(sc, R92C_HSSI_PARAM1(0)); + if (!(hssi_param1 & R92C_HSSI_PARAM1_PI)) { + rtwn_bb_write(sc, R92C_HSSI_PARAM1(0), + hssi_param1 | R92C_HSSI_PARAM1_PI); + rtwn_bb_write(sc, R92C_HSSI_PARAM1(1), + hssi_param1 | R92C_HSSI_PARAM1_PI); + } + + if (n == 0) { + iq_cal_regs.ofdm0_trxpathena = + rtwn_bb_read(sc, R92C_OFDM0_TRXPATHENA); + iq_cal_regs.ofdm0_trmuxpar = + rtwn_bb_read(sc, R92C_OFDM0_TRMUXPAR); + iq_cal_regs.fpga0_rfifacesw1 = + rtwn_bb_read(sc, R92C_FPGA0_RFIFACESW(1)); + } + + rtwn_bb_write(sc, R92C_OFDM0_TRXPATHENA, 0x03a05600); + rtwn_bb_write(sc, R92C_OFDM0_TRMUXPAR, 0x000800e4); + rtwn_bb_write(sc, R92C_FPGA0_RFIFACESW(1), 0x22204000); + if (sc->ntxchains > 1) { + rtwn_bb_write(sc, R92C_LSSI_PARAM(0), 0x00010000); + rtwn_bb_write(sc, R92C_LSSI_PARAM(1), 0x00010000); + } + + rtwn_write_1(sc, R92C_TXPAUSE, 0x3f); + rtwn_write_1(sc, R92C_BCN_CTRL, iq_cal_regs.bcn_ctrl & ~(0x08)); + rtwn_write_1(sc, R92C_USTIME_TSF, iq_cal_regs.ustime_tsf & ~(0x08)); + rtwn_write_1(sc, R92C_GPIO_MUXCFG, + iq_cal_regs.gpio_muxcfg & ~(0x20)); + + rtwn_bb_write(sc, 0x0b68, 0x00080000); + if (sc->ntxchains > 1) + rtwn_bb_write(sc, 0x0b6c, 0x00080000); + + rtwn_bb_write(sc, 0x0e28, 0x80800000); + rtwn_bb_write(sc, 0x0e40, 0x01007c00); + rtwn_bb_write(sc, 0x0e44, 0x01004800); + + rtwn_bb_write(sc, 0x0b68, 0x00080000); + + for (chain = 0; chain < sc->ntxchains; chain++) { + if (chain > 0) { + /* Put chain 0 on standby. */ + rtwn_bb_write(sc, 0x0e28, 0x00); + rtwn_bb_write(sc, R92C_LSSI_PARAM(0), 0x00010000); + rtwn_bb_write(sc, 0x0e28, 0x80800000); + + /* Enable chain 1. */ + for (i = 0; i < nitems(reg_adda); i++) + rtwn_bb_write(sc, reg_adda[i], 0x0b1b25a4); + } + + /* Run IQ calibration twice. */ + for (i = 0; i < 2; i++) { + int ret; + + ret = rtwn_iq_calib_chain(sc, chain, + tx[chain], rx[chain]); + if (ret == 0) { + DPRINTF(("%s: chain %d: Tx failed.\n", + __func__, chain)); + tx[chain][0] = 0xff; + tx[chain][1] = 0xff; + rx[chain][0] = 0xff; + rx[chain][1] = 0xff; + } else if (ret == 1) { + DPRINTF(("%s: chain %d: Rx failed.\n", + __func__, chain)); + rx[chain][0] = 0xff; + rx[chain][1] = 0xff; + } else if (ret == 3) { + DPRINTF(("%s: chain %d: Both Tx and Rx " + "succeeded.\n", __func__, chain)); + } + } + + DPRINTF(("%s: results for run %d chain %d: tx[0]=0x%x, " + "tx[1]=0x%x rx[0]=0x%x rx[1]=0x%x\n", __func__, n, chain, + tx[chain][0], tx[chain][1], rx[chain][0], rx[chain][1])); + } + + rtwn_bb_write(sc, R92C_OFDM0_TRXPATHENA, + iq_cal_regs.ofdm0_trxpathena); + rtwn_bb_write(sc, R92C_FPGA0_RFIFACESW(1), + iq_cal_regs.fpga0_rfifacesw1); + rtwn_bb_write(sc, R92C_OFDM0_TRMUXPAR, iq_cal_regs.ofdm0_trmuxpar); + + rtwn_bb_write(sc, 0x0e28, 0x00); + rtwn_bb_write(sc, R92C_LSSI_PARAM(0), 0x00032ed3); + if (sc->ntxchains > 1) + rtwn_bb_write(sc, R92C_LSSI_PARAM(1), 0x00032ed3); + + if (n != 0) { + if (!(hssi_param1 & R92C_HSSI_PARAM1_PI)) { + rtwn_bb_write(sc, R92C_HSSI_PARAM1(0), hssi_param1); + rtwn_bb_write(sc, R92C_HSSI_PARAM1(1), hssi_param1); + } + + for (i = 0; i < nitems(reg_adda); i++) + rtwn_bb_write(sc, reg_adda[i], iq_cal_regs.adda[i]); + + rtwn_write_1(sc, R92C_TXPAUSE, iq_cal_regs.txpause); + rtwn_write_1(sc, R92C_BCN_CTRL, iq_cal_regs.bcn_ctrl); + rtwn_write_1(sc, R92C_USTIME_TSF, iq_cal_regs.ustime_tsf); + rtwn_write_4(sc, R92C_GPIO_MUXCFG, iq_cal_regs.gpio_muxcfg); + } +} + +#define RTWN_IQ_CAL_MAX_TOLERANCE 5 +static int +rtwn_iq_calib_compare_results(uint16_t tx1[2][2], uint16_t rx1[2][2], + uint16_t tx2[2][2], uint16_t rx2[2][2], int ntxchains) +{ + int chain, i, tx_ok[2], rx_ok[2]; + + tx_ok[0] = tx_ok[1] = rx_ok[0] = rx_ok[1] = 0; + for (chain = 0; chain < ntxchains; chain++) { + for (i = 0; i < 2; i++) { + if (tx1[chain][i] == 0xff || tx2[chain][i] == 0xff || + rx1[chain][i] == 0xff || rx2[chain][i] == 0xff) + continue; + + tx_ok[chain] = (abs(tx1[chain][i] - tx2[chain][i]) <= + RTWN_IQ_CAL_MAX_TOLERANCE); + + rx_ok[chain] = (abs(rx1[chain][i] - rx2[chain][i]) <= + RTWN_IQ_CAL_MAX_TOLERANCE); + } + } + + if (ntxchains > 1) + return (tx_ok[0] && tx_ok[1] && rx_ok[0] && rx_ok[1]); + else + return (tx_ok[0] && rx_ok[0]); +} +#undef RTWN_IQ_CAL_MAX_TOLERANCE + +static void +rtwn_iq_calib_write_results(struct rtwn_softc *sc, uint16_t tx[2], + uint16_t rx[2], int chain) +{ + uint32_t reg, val, x; + long y, tx_c; + + if (tx[0] == 0xff || tx[1] == 0xff) + return; + + reg = rtwn_bb_read(sc, R92C_OFDM0_TXIQIMBALANCE(chain)); + val = ((reg >> 22) & 0x3ff); + x = tx[0]; + if (x & 0x0200) + x |= 0xfc00; + reg = (((x * val) >> 8) & 0x3ff); + rtwn_bb_write(sc, R92C_OFDM0_TXIQIMBALANCE(chain), reg); + + reg = rtwn_bb_read(sc, R92C_OFDM0_ECCATHRESHOLD); + if (((x * val) >> 7) & 0x01) + reg |= 0x80000000; + else + reg &= ~0x80000000; + rtwn_bb_write(sc, R92C_OFDM0_ECCATHRESHOLD, reg); + + y = tx[1]; + if (y & 0x00000200) + y |= 0xfffffc00; + tx_c = (y * val) >> 8; + reg = rtwn_bb_read(sc, R92C_OFDM0_TXAFE(chain)); + reg |= ((((tx_c & 0x3c0) >> 6) << 24) & 0xf0000000); + rtwn_bb_write(sc, R92C_OFDM0_TXAFE(chain), reg); + + reg = rtwn_bb_read(sc, R92C_OFDM0_TXIQIMBALANCE(chain)); + reg |= (((tx_c & 0x3f) << 16) & 0x003F0000); + rtwn_bb_write(sc, R92C_OFDM0_TXIQIMBALANCE(chain), reg); + + reg = rtwn_bb_read(sc, R92C_OFDM0_ECCATHRESHOLD); + if (((y * val) >> 7) & 0x01) + reg |= 0x20000000; + else + reg &= ~0x20000000; + rtwn_bb_write(sc, R92C_OFDM0_ECCATHRESHOLD, reg); + + if (rx[0] == 0xff || rx[1] == 0xff) + return; + + reg = rtwn_bb_read(sc, R92C_OFDM0_RXIQIMBALANCE(chain)); + reg |= (rx[0] & 0x3ff); + rtwn_bb_write(sc, R92C_OFDM0_RXIQIMBALANCE(chain), reg); + reg |= (((rx[1] & 0x03f) << 8) & 0xFC00); + rtwn_bb_write(sc, R92C_OFDM0_RXIQIMBALANCE(chain), reg); + + if (chain == 0) { + reg = rtwn_bb_read(sc, R92C_OFDM0_RXIQEXTANTA); + reg |= (((rx[1] & 0xf) >> 6) & 0x000f); + rtwn_bb_write(sc, R92C_OFDM0_RXIQEXTANTA, reg); + } else { + reg = rtwn_bb_read(sc, R92C_OFDM0_AGCRSSITABLE); + reg |= ((((rx[1] & 0xf) >> 6) << 12) & 0xf000); + rtwn_bb_write(sc, R92C_OFDM0_AGCRSSITABLE, reg); + } +} + +#define RTWN_IQ_CAL_NRUN 3 +static void +rtwn_iq_calib(struct rtwn_softc *sc) +{ + uint16_t tx[RTWN_IQ_CAL_NRUN][2][2], rx[RTWN_IQ_CAL_NRUN][2][2]; + int n, valid; + + valid = 0; + for (n = 0; n < RTWN_IQ_CAL_NRUN; n++) { + rtwn_iq_calib_run(sc, n, tx[n], rx[n]); + + if (n == 0) + continue; + + /* Valid results remain stable after consecutive runs. */ + valid = rtwn_iq_calib_compare_results(tx[n - 1], rx[n - 1], + tx[n], rx[n], sc->ntxchains); + if (valid) + break; + } + + if (valid) { + rtwn_iq_calib_write_results(sc, tx[n][0], rx[n][0], 0); + if (sc->ntxchains > 1) + rtwn_iq_calib_write_results(sc, tx[n][1], rx[n][1], 1); + } +} +#undef RTWN_IQ_CAL_NRUN + +static void +rtwn_lc_calib(struct rtwn_softc *sc) +{ + uint32_t rf_ac[2]; + uint8_t txmode; + int i; + + txmode = rtwn_read_1(sc, R92C_OFDM1_LSTF + 3); + if ((txmode & 0x70) != 0) { + /* Disable all continuous Tx. */ + rtwn_write_1(sc, R92C_OFDM1_LSTF + 3, txmode & ~0x70); + + /* Set RF mode to standby mode. */ + for (i = 0; i < sc->nrxchains; i++) { + rf_ac[i] = rtwn_rf_read(sc, i, R92C_RF_AC); + rtwn_rf_write(sc, i, R92C_RF_AC, + RW(rf_ac[i], R92C_RF_AC_MODE, + R92C_RF_AC_MODE_STANDBY)); + } + } else { + /* Block all Tx queues. */ + rtwn_write_1(sc, R92C_TXPAUSE, 0xff); + } + /* Start calibration. */ + rtwn_rf_write(sc, 0, R92C_RF_CHNLBW, + rtwn_rf_read(sc, 0, R92C_RF_CHNLBW) | R92C_RF_CHNLBW_LCSTART); + + /* Give calibration the time to complete. */ + DELAY(100); + + /* Restore configuration. */ + if ((txmode & 0x70) != 0) { + /* Restore Tx mode. */ + rtwn_write_1(sc, R92C_OFDM1_LSTF + 3, txmode); + /* Restore RF mode. */ + for (i = 0; i < sc->nrxchains; i++) + rtwn_rf_write(sc, i, R92C_RF_AC, rf_ac[i]); + } else { + /* Unblock all Tx queues. */ + rtwn_write_1(sc, R92C_TXPAUSE, 0x00); + } +} + +static void +rtwn_temp_calib(struct rtwn_softc *sc) +{ + int temp; + + if (sc->thcal_state == 0) { + /* Start measuring temperature. */ + rtwn_rf_write(sc, 0, R92C_RF_T_METER, 0x60); + sc->thcal_state = 1; + return; + } + sc->thcal_state = 0; + + /* Read measured temperature. */ + temp = rtwn_rf_read(sc, 0, R92C_RF_T_METER) & 0x1f; + if (temp == 0) /* Read failed, skip. */ + return; + DPRINTFN(2, ("temperature=%d\n", temp)); + + /* + * Redo IQ and LC calibration if temperature changed significantly + * since last calibration. + */ + if (sc->thcal_lctemp == 0) { + /* First calibration is performed in rtwn_init(). */ + sc->thcal_lctemp = temp; + } else if (abs(temp - sc->thcal_lctemp) > 1) { + DPRINTF(("IQ/LC calib triggered by temp: %d -> %d\n", + sc->thcal_lctemp, temp)); + rtwn_iq_calib(sc); + rtwn_lc_calib(sc); + /* Record temperature of last calibration. */ + sc->thcal_lctemp = temp; + } +} + +static void +rtwn_init_locked(struct rtwn_softc *sc) +{ + struct ieee80211com *ic = &sc->sc_ic; + struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); + uint32_t reg; + uint8_t macaddr[IEEE80211_ADDR_LEN]; + int i, error; + + RTWN_LOCK_ASSERT(sc); + + /* Init firmware commands ring. */ + sc->fwcur = 0; + + /* Power on adapter. */ + error = rtwn_power_on(sc); + if (error != 0) { + device_printf(sc->sc_dev, "could not power on adapter\n"); + goto fail; + } + + /* Initialize DMA. */ + error = rtwn_dma_init(sc); + if (error != 0) { + device_printf(sc->sc_dev, "could not initialize DMA\n"); + goto fail; + } + + /* Set info size in Rx descriptors (in 64-bit words). */ + rtwn_write_1(sc, R92C_RX_DRVINFO_SZ, 4); + + /* Disable interrupts. */ + rtwn_write_4(sc, R92C_HISR, 0x00000000); + rtwn_write_4(sc, R92C_HIMR, 0x00000000); + + /* Set MAC address. */ + IEEE80211_ADDR_COPY(macaddr, vap ? vap->iv_myaddr : ic->ic_macaddr); + for (i = 0; i < IEEE80211_ADDR_LEN; i++) + rtwn_write_1(sc, R92C_MACID + i, macaddr[i]); + + /* Set initial network type. */ + reg = rtwn_read_4(sc, R92C_CR); + reg = RW(reg, R92C_CR_NETTYPE, R92C_CR_NETTYPE_INFRA); + rtwn_write_4(sc, R92C_CR, reg); + + rtwn_rxfilter_init(sc); + + reg = rtwn_read_4(sc, R92C_RRSR); + reg = RW(reg, R92C_RRSR_RATE_BITMAP, R92C_RRSR_RATE_ALL); + rtwn_write_4(sc, R92C_RRSR, reg); + + /* Set short/long retry limits. */ + rtwn_write_2(sc, R92C_RL, + SM(R92C_RL_SRL, 0x07) | SM(R92C_RL_LRL, 0x07)); + + /* Initialize EDCA parameters. */ + rtwn_edca_init(sc); + + /* Set data and response automatic rate fallback retry counts. */ + rtwn_write_4(sc, R92C_DARFRC + 0, 0x01000000); + rtwn_write_4(sc, R92C_DARFRC + 4, 0x07060504); + rtwn_write_4(sc, R92C_RARFRC + 0, 0x01000000); + rtwn_write_4(sc, R92C_RARFRC + 4, 0x07060504); + + rtwn_write_2(sc, R92C_FWHW_TXQ_CTRL, 0x1f80); + + /* Set ACK timeout. */ + rtwn_write_1(sc, R92C_ACKTO, 0x40); + + /* Initialize beacon parameters. */ + rtwn_write_2(sc, R92C_TBTT_PROHIBIT, 0x6404); + rtwn_write_1(sc, R92C_DRVERLYINT, 0x05); + rtwn_write_1(sc, R92C_BCNDMATIM, 0x02); + rtwn_write_2(sc, R92C_BCNTCFG, 0x660f); + + /* Setup AMPDU aggregation. */ + rtwn_write_4(sc, R92C_AGGLEN_LMT, 0x99997631); /* MCS7~0 */ + rtwn_write_1(sc, R92C_AGGR_BREAK_TIME, 0x16); + + rtwn_write_1(sc, R92C_BCN_MAX_ERR, 0xff); + rtwn_write_1(sc, R92C_BCN_CTRL, R92C_BCN_CTRL_DIS_TSF_UDT0); + + rtwn_write_4(sc, R92C_PIFS, 0x1c); + rtwn_write_4(sc, R92C_MCUTST_1, 0x0); + + /* Load 8051 microcode. */ + error = rtwn_load_firmware(sc); + if (error != 0) + goto fail; + + /* Initialize MAC/BB/RF blocks. */ + rtwn_mac_init(sc); + rtwn_bb_init(sc); + rtwn_rf_init(sc); + + /* Turn CCK and OFDM blocks on. */ + reg = rtwn_bb_read(sc, R92C_FPGA0_RFMOD); + reg |= R92C_RFMOD_CCK_EN; + rtwn_bb_write(sc, R92C_FPGA0_RFMOD, reg); + reg = rtwn_bb_read(sc, R92C_FPGA0_RFMOD); + reg |= R92C_RFMOD_OFDM_EN; + rtwn_bb_write(sc, R92C_FPGA0_RFMOD, reg); + + /* Clear per-station keys table. */ + rtwn_cam_init(sc); + + /* Enable hardware sequence numbering. */ + rtwn_write_1(sc, R92C_HWSEQ_CTRL, 0xff); + + /* Perform LO and IQ calibrations. */ + rtwn_iq_calib(sc); + /* Perform LC calibration. */ + rtwn_lc_calib(sc); + + rtwn_pa_bias_init(sc); + + /* Initialize GPIO setting. */ + rtwn_write_1(sc, R92C_GPIO_MUXCFG, + rtwn_read_1(sc, R92C_GPIO_MUXCFG) & ~R92C_GPIO_MUXCFG_ENBT); + + /* Fix for lower temperature. */ + rtwn_write_1(sc, 0x15, 0xe9); + + /* CLear pending interrupts. */ + rtwn_write_4(sc, R92C_HISR, 0xffffffff); + + /* Enable interrupts. */ + rtwn_write_4(sc, R92C_HIMR, RTWN_INT_ENABLE); + + sc->sc_flags |= RTWN_RUNNING; + + callout_reset(&sc->watchdog_to, hz, rtwn_watchdog, sc); + return; + +fail: + rtwn_stop_locked(sc); +} + +static void +rtwn_init(struct rtwn_softc *sc) +{ + + RTWN_LOCK(sc); + rtwn_init_locked(sc); + RTWN_UNLOCK(sc); + + if (sc->sc_flags & RTWN_RUNNING) + ieee80211_start_all(&sc->sc_ic); +} + +static void +rtwn_stop_locked(struct rtwn_softc *sc) +{ + uint16_t reg; + int i; + + RTWN_LOCK_ASSERT(sc); + + sc->sc_tx_timer = 0; + callout_stop(&sc->watchdog_to); + callout_stop(&sc->calib_to); + sc->sc_flags &= ~RTWN_RUNNING; + + /* Disable interrupts. */ + rtwn_write_4(sc, R92C_HISR, 0x00000000); + rtwn_write_4(sc, R92C_HIMR, 0x00000000); + + /* Stop hardware. */ + rtwn_write_1(sc, R92C_TXPAUSE, 0xff); + rtwn_write_1(sc, R92C_RF_CTRL, 0x00); + reg = rtwn_read_1(sc, R92C_SYS_FUNC_EN); + reg |= R92C_SYS_FUNC_EN_BB_GLB_RST; + rtwn_write_1(sc, R92C_SYS_FUNC_EN, reg); + reg &= ~R92C_SYS_FUNC_EN_BB_GLB_RST; + rtwn_write_1(sc, R92C_SYS_FUNC_EN, reg); + reg = rtwn_read_2(sc, R92C_CR); + reg &= ~(R92C_CR_HCI_TXDMA_EN | R92C_CR_HCI_RXDMA_EN | + R92C_CR_TXDMA_EN | R92C_CR_RXDMA_EN | R92C_CR_PROTOCOL_EN | + R92C_CR_SCHEDULE_EN | R92C_CR_MACTXEN | R92C_CR_MACRXEN | + R92C_CR_ENSEC); + rtwn_write_2(sc, R92C_CR, reg); + if (rtwn_read_1(sc, R92C_MCUFWDL) & R92C_MCUFWDL_RAM_DL_SEL) + rtwn_fw_reset(sc); + /* TODO: linux does additional btcoex stuff here */ + rtwn_write_2(sc, R92C_AFE_PLL_CTRL, 0x80); /* linux magic number */ + rtwn_write_1(sc, R92C_SPS0_CTRL, 0x23); /* ditto */ + rtwn_write_1(sc, R92C_AFE_XTAL_CTRL, 0x0e); /* different with btcoex */ + rtwn_write_1(sc, R92C_RSV_CTRL, 0x0e); + rtwn_write_1(sc, R92C_APS_FSMCO, R92C_APS_FSMCO_PDN_EN); + + for (i = 0; i < RTWN_NTXQUEUES; i++) + rtwn_reset_tx_list(sc, i); + rtwn_reset_rx_list(sc); +} + +static void +rtwn_stop(struct rtwn_softc *sc) +{ + RTWN_LOCK(sc); + rtwn_stop_locked(sc); + RTWN_UNLOCK(sc); +} + +static void +rtwn_intr(void *arg) +{ + struct rtwn_softc *sc = arg; + uint32_t status; + int i; + + RTWN_LOCK(sc); + status = rtwn_read_4(sc, R92C_HISR); + if (status == 0 || status == 0xffffffff) { + RTWN_UNLOCK(sc); + return; + } + + /* Disable interrupts. */ + rtwn_write_4(sc, R92C_HIMR, 0x00000000); + + /* Ack interrupts. */ + rtwn_write_4(sc, R92C_HISR, status); + + /* Vendor driver treats RX errors like ROK... */ + if (status & (R92C_IMR_ROK | R92C_IMR_RXFOVW | R92C_IMR_RDU)) { + bus_dmamap_sync(sc->rx_ring.desc_dmat, sc->rx_ring.desc_map, + BUS_DMASYNC_POSTREAD); + + for (i = 0; i < RTWN_RX_LIST_COUNT; i++) { + struct r92c_rx_desc *rx_desc = &sc->rx_ring.desc[i]; + struct rtwn_rx_data *rx_data = &sc->rx_ring.rx_data[i]; + + if (le32toh(rx_desc->rxdw0) & R92C_RXDW0_OWN) + continue; + + rtwn_rx_frame(sc, rx_desc, rx_data, i); + } + } + + if (status & R92C_IMR_BDOK) + rtwn_tx_done(sc, RTWN_BEACON_QUEUE); + if (status & R92C_IMR_HIGHDOK) + rtwn_tx_done(sc, RTWN_HIGH_QUEUE); + if (status & R92C_IMR_MGNTDOK) + rtwn_tx_done(sc, RTWN_MGNT_QUEUE); + if (status & R92C_IMR_BKDOK) + rtwn_tx_done(sc, RTWN_BK_QUEUE); + if (status & R92C_IMR_BEDOK) + rtwn_tx_done(sc, RTWN_BE_QUEUE); + if (status & R92C_IMR_VIDOK) + rtwn_tx_done(sc, RTWN_VI_QUEUE); + if (status & R92C_IMR_VODOK) + rtwn_tx_done(sc, RTWN_VO_QUEUE); + + /* Enable interrupts. */ + rtwn_write_4(sc, R92C_HIMR, RTWN_INT_ENABLE); + + RTWN_UNLOCK(sc); +} + +static void +rtwn_hw_reset(void *arg0, int pending) +{ + struct rtwn_softc *sc = arg0; + struct ieee80211com *ic = &sc->sc_ic; + + rtwn_stop(sc); + rtwn_init(sc); + ieee80211_notify_radio(ic, 1); +} diff --git a/sys/dev/rtwn/if_rtwnreg.h b/sys/dev/rtwn/if_rtwnreg.h new file mode 100644 index 0000000..a5f1cc2 --- /dev/null +++ b/sys/dev/rtwn/if_rtwnreg.h @@ -0,0 +1,2106 @@ +/* $OpenBSD: if_rtwnreg.h,v 1.3 2015/06/14 08:02:47 stsp Exp $ */ + +/*- + * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> + * Copyright (c) 2015 Stefan Sperling <stsp@openbsd.org> + * + * Permission to use, copy, modify, and 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$ + */ + +#define R92C_MAX_CHAINS 2 + +/* Maximum number of output pipes is 3. */ +#define R92C_MAX_EPOUT 3 + +#define R92C_MAX_TX_PWR 0x3f + +#define R92C_PUBQ_NPAGES 176 +#define R92C_HPQ_NPAGES 41 +#define R92C_LPQ_NPAGES 28 +#define R92C_TXPKTBUF_COUNT 256 +#define R92C_TX_PAGE_COUNT \ + (R92C_PUBQ_NPAGES + R92C_HPQ_NPAGES + R92C_LPQ_NPAGES) +#define R92C_TX_PAGE_BOUNDARY (R92C_TX_PAGE_COUNT + 1) + +#define R92C_H2C_NBOX 4 + +/* USB Requests. */ +#define R92C_REQ_REGS 0x05 + +/* + * MAC registers. + */ +/* System Configuration. */ +#define R92C_SYS_ISO_CTRL 0x000 +#define R92C_SYS_FUNC_EN 0x002 +#define R92C_APS_FSMCO 0x004 +#define R92C_SYS_CLKR 0x008 +#define R92C_AFE_MISC 0x010 +#define R92C_SPS0_CTRL 0x011 +#define R92C_SPS_OCP_CFG 0x018 +#define R92C_RSV_CTRL 0x01c +#define R92C_RF_CTRL 0x01f +#define R92C_LDOA15_CTRL 0x020 +#define R92C_LDOV12D_CTRL 0x021 +#define R92C_LDOHCI12_CTRL 0x022 +#define R92C_LPLDO_CTRL 0x023 +#define R92C_AFE_XTAL_CTRL 0x024 +#define R92C_AFE_PLL_CTRL 0x028 +#define R92C_EFUSE_CTRL 0x030 +#define R92C_EFUSE_TEST 0x034 +#define R92C_PWR_DATA 0x038 +#define R92C_CAL_TIMER 0x03c +#define R92C_ACLK_MON 0x03e +#define R92C_GPIO_MUXCFG 0x040 +#define R92C_GPIO_IO_SEL 0x042 +#define R92C_MAC_PINMUX_CFG 0x043 +#define R92C_GPIO_PIN_CTRL 0x044 +#define R92C_GPIO_INTM 0x048 +#define R92C_LEDCFG0 0x04c +#define R92C_LEDCFG1 0x04d +#define R92C_LEDCFG2 0x04e +#define R92C_LEDCFG3 0x04f +#define R92C_FSIMR 0x050 +#define R92C_FSISR 0x054 +#define R92C_HSIMR 0x058 +#define R92C_HSISR 0x05c +#define R92C_MCUFWDL 0x080 +#define R92C_HMEBOX_EXT(idx) (0x088 + (idx) * 2) +#define R92C_BIST_SCAN 0x0d0 +#define R92C_BIST_RPT 0x0d4 +#define R92C_BIST_ROM_RPT 0x0d8 +#define R92C_USB_SIE_INTF 0x0e0 +#define R92C_PCIE_MIO_INTF 0x0e4 +#define R92C_PCIE_MIO_INTD 0x0e8 +#define R92C_HPON_FSM 0x0ec +#define R92C_SYS_CFG 0x0f0 +/* MAC General Configuration. */ +#define R92C_CR 0x100 +#define R92C_PBP 0x104 +#define R92C_TRXDMA_CTRL 0x10c +#define R92C_TRXFF_BNDY 0x114 +#define R92C_TRXFF_STATUS 0x118 +#define R92C_RXFF_PTR 0x11c +#define R92C_HIMR 0x120 +#define R92C_HISR 0x124 +#define R92C_HIMRE 0x128 +#define R92C_HISRE 0x12c +#define R92C_CPWM 0x12f +#define R92C_FWIMR 0x130 +#define R92C_FWISR 0x134 +#define R92C_PKTBUF_DBG_CTRL 0x140 +#define R92C_PKTBUF_DBG_DATA_L 0x144 +#define R92C_PKTBUF_DBG_DATA_H 0x148 +#define R92C_TC0_CTRL(i) (0x150 + (i) * 4) +#define R92C_TCUNIT_BASE 0x164 +#define R92C_MBIST_START 0x174 +#define R92C_MBIST_DONE 0x178 +#define R92C_MBIST_FAIL 0x17c +#define R92C_C2HEVT_MSG_NORMAL 0x1a0 +#define R92C_C2HEVT_MSG_TEST 0x1b8 +#define R92C_C2HEVT_CLEAR 0x1bf +#define R92C_MCUTST_1 0x1c0 +#define R92C_FMETHR 0x1c8 +#define R92C_HMETFR 0x1cc +#define R92C_HMEBOX(idx) (0x1d0 + (idx) * 4) +#define R92C_LLT_INIT 0x1e0 +#define R92C_BB_ACCESS_CTRL 0x1e8 +#define R92C_BB_ACCESS_DATA 0x1ec +/* Tx DMA Configuration. */ +#define R92C_RQPN 0x200 +#define R92C_FIFOPAGE 0x204 +#define R92C_TDECTRL 0x208 +#define R92C_TXDMA_OFFSET_CHK 0x20c +#define R92C_TXDMA_STATUS 0x210 +#define R92C_RQPN_NPQ 0x214 +/* Rx DMA Configuration. */ +#define R92C_RXDMA_AGG_PG_TH 0x280 +#define R92C_RXPKT_NUM 0x284 +#define R92C_RXDMA_STATUS 0x288 + +#define R92C_PCIE_CTRL_REG 0x300 +#define R92C_INT_MIG 0x304 +#define R92C_BCNQ_DESA 0x308 +#define R92C_HQ_DESA 0x310 +#define R92C_MGQ_DESA 0x318 +#define R92C_VOQ_DESA 0x320 +#define R92C_VIQ_DESA 0x328 +#define R92C_BEQ_DESA 0x330 +#define R92C_BKQ_DESA 0x338 +#define R92C_RX_DESA 0x340 +#define R92C_DBI 0x348 +#define R92C_MDIO 0x354 +#define R92C_DBG_SEL 0x360 +#define R92C_PCIE_HRPWM 0x361 +#define R92C_PCIE_HCPWM 0x363 +#define R92C_UART_CTRL 0x364 +#define R92C_UART_TX_DES 0x370 +#define R92C_UART_RX_DES 0x378 + +#define R92C_VOQ_INFORMATION 0x0400 +#define R92C_VIQ_INFORMATION 0x0404 +#define R92C_BEQ_INFORMATION 0x0408 +#define R92C_BKQ_INFORMATION 0x040C +#define R92C_MGQ_INFORMATION 0x0410 +#define R92C_HGQ_INFORMATION 0x0414 +#define R92C_BCNQ_INFORMATION 0x0418 +#define R92C_CPU_MGQ_INFORMATION 0x041C + +/* Protocol Configuration. */ +#define R92C_FWHW_TXQ_CTRL 0x420 +#define R92C_HWSEQ_CTRL 0x423 +#define R92C_TXPKTBUF_BCNQ_BDNY 0x424 +#define R92C_TXPKTBUF_MGQ_BDNY 0x425 +#define R92C_SPEC_SIFS 0x428 +#define R92C_RL 0x42a +#define R92C_DARFRC 0x430 +#define R92C_RARFRC 0x438 +#define R92C_RRSR 0x440 +#define R92C_ARFR(i) (0x444 + (i) * 4) +#define R92C_AGGLEN_LMT 0x458 +#define R92C_AMPDU_MIN_SPACE 0x45c +#define R92C_TXPKTBUF_WMAC_LBK_BF_HD 0x45d +#define R92C_FAST_EDCA_CTRL 0x460 +#define R92C_RD_RESP_PKT_TH 0x463 +#define R92C_INIRTS_RATE_SEL 0x480 +#define R92C_INIDATA_RATE_SEL(macid) (0x484 + (macid)) +/* EDCA Configuration. */ +#define R92C_EDCA_VO_PARAM 0x500 +#define R92C_EDCA_VI_PARAM 0x504 +#define R92C_EDCA_BE_PARAM 0x508 +#define R92C_EDCA_BK_PARAM 0x50c +#define R92C_BCNTCFG 0x510 +#define R92C_PIFS 0x512 +#define R92C_RDG_PIFS 0x513 +#define R92C_SIFS_CCK 0x514 +#define R92C_SIFS_OFDM 0x516 +#define R92C_AGGR_BREAK_TIME 0x51a +#define R92C_SLOT 0x51b +#define R92C_TX_PTCL_CTRL 0x520 +#define R92C_TXPAUSE 0x522 +#define R92C_DIS_TXREQ_CLR 0x523 +#define R92C_RD_CTRL 0x524 +#define R92C_TBTT_PROHIBIT 0x540 +#define R92C_RD_NAV_NXT 0x544 +#define R92C_NAV_PROT_LEN 0x546 +#define R92C_BCN_CTRL 0x550 +#define R92C_USTIME_TSF 0x551 +#define R92C_MBID_NUM 0x552 +#define R92C_DUAL_TSF_RST 0x553 +#define R92C_BCN_INTERVAL 0x554 +#define R92C_DRVERLYINT 0x558 +#define R92C_BCNDMATIM 0x559 +#define R92C_ATIMWND 0x55a +#define R92C_BCN_MAX_ERR 0x55d +#define R92C_RXTSF_OFFSET_CCK 0x55e +#define R92C_RXTSF_OFFSET_OFDM 0x55f +#define R92C_TSFTR 0x560 +#define R92C_INIT_TSFTR 0x564 +#define R92C_PSTIMER 0x580 +#define R92C_TIMER0 0x584 +#define R92C_TIMER1 0x588 +#define R92C_ACMHWCTRL 0x5c0 +#define R92C_ACMRSTCTRL 0x5c1 +#define R92C_ACMAVG 0x5c2 +#define R92C_VO_ADMTIME 0x5c4 +#define R92C_VI_ADMTIME 0x5c6 +#define R92C_BE_ADMTIME 0x5c8 +#define R92C_EDCA_RANDOM_GEN 0x5cc +#define R92C_SCH_TXCMD 0x5d0 +/* WMAC Configuration. */ +#define R92C_APSD_CTRL 0x600 +#define R92C_BWOPMODE 0x603 +#define R92C_TCR 0x604 +#define R92C_RCR 0x608 +#define R92C_RX_DRVINFO_SZ 0x60f +#define R92C_MACID 0x610 +#define R92C_BSSID 0x618 +#define R92C_MAR 0x620 +#define R92C_MAC_SPEC_SIFS 0x63a +#define R92C_R2T_SIFS 0x63c +#define R92C_T2T_SIFS 0x63e +#define R92C_ACKTO 0x640 +#define R92C_CAMCMD 0x670 +#define R92C_CAMWRITE 0x674 +#define R92C_CAMREAD 0x678 +#define R92C_CAMDBG 0x67c +#define R92C_SECCFG 0x680 +#define R92C_RXFLTMAP0 0x6a0 +#define R92C_RXFLTMAP1 0x6a2 +#define R92C_RXFLTMAP2 0x6a4 + +/* Bits for R92C_SYS_ISO_CTRL. */ +#define R92C_SYS_ISO_CTRL_MD2PP 0x0001 +#define R92C_SYS_ISO_CTRL_UA2USB 0x0002 +#define R92C_SYS_ISO_CTRL_UD2CORE 0x0004 +#define R92C_SYS_ISO_CTRL_PA2PCIE 0x0008 +#define R92C_SYS_ISO_CTRL_PD2CORE 0x0010 +#define R92C_SYS_ISO_CTRL_IP2MAC 0x0020 +#define R92C_SYS_ISO_CTRL_DIOP 0x0040 +#define R92C_SYS_ISO_CTRL_DIOE 0x0080 +#define R92C_SYS_ISO_CTRL_EB2CORE 0x0100 +#define R92C_SYS_ISO_CTRL_DIOR 0x0200 +#define R92C_SYS_ISO_CTRL_PWC_EV25V 0x4000 +#define R92C_SYS_ISO_CTRL_PWC_EV12V 0x8000 + +/* Bits for R92C_SYS_FUNC_EN. */ +#define R92C_SYS_FUNC_EN_BBRSTB 0x0001 +#define R92C_SYS_FUNC_EN_BB_GLB_RST 0x0002 +#define R92C_SYS_FUNC_EN_USBA 0x0004 +#define R92C_SYS_FUNC_EN_UPLL 0x0008 +#define R92C_SYS_FUNC_EN_USBD 0x0010 +#define R92C_SYS_FUNC_EN_DIO_PCIE 0x0020 +#define R92C_SYS_FUNC_EN_PCIEA 0x0040 +#define R92C_SYS_FUNC_EN_PPLL 0x0080 +#define R92C_SYS_FUNC_EN_PCIED 0x0100 +#define R92C_SYS_FUNC_EN_DIOE 0x0200 +#define R92C_SYS_FUNC_EN_CPUEN 0x0400 +#define R92C_SYS_FUNC_EN_DCORE 0x0800 +#define R92C_SYS_FUNC_EN_ELDR 0x1000 +#define R92C_SYS_FUNC_EN_DIO_RF 0x2000 +#define R92C_SYS_FUNC_EN_HWPDN 0x4000 +#define R92C_SYS_FUNC_EN_MREGEN 0x8000 + +/* Bits for R92C_APS_FSMCO. */ +#define R92C_APS_FSMCO_PFM_LDALL 0x00000001 +#define R92C_APS_FSMCO_PFM_ALDN 0x00000002 +#define R92C_APS_FSMCO_PFM_LDKP 0x00000004 +#define R92C_APS_FSMCO_PFM_WOWL 0x00000008 +#define R92C_APS_FSMCO_PDN_EN 0x00000010 +#define R92C_APS_FSMCO_PDN_PL 0x00000020 +#define R92C_APS_FSMCO_APFM_ONMAC 0x00000100 +#define R92C_APS_FSMCO_APFM_OFF 0x00000200 +#define R92C_APS_FSMCO_APFM_RSM 0x00000400 +#define R92C_APS_FSMCO_AFSM_HSUS 0x00000800 +#define R92C_APS_FSMCO_AFSM_PCIE 0x00001000 +#define R92C_APS_FSMCO_APDM_MAC 0x00002000 +#define R92C_APS_FSMCO_APDM_HOST 0x00004000 +#define R92C_APS_FSMCO_APDM_HPDN 0x00008000 +#define R92C_APS_FSMCO_RDY_MACON 0x00010000 +#define R92C_APS_FSMCO_SUS_HOST 0x00020000 +#define R92C_APS_FSMCO_ROP_ALD 0x00100000 +#define R92C_APS_FSMCO_ROP_PWR 0x00200000 +#define R92C_APS_FSMCO_ROP_SPS 0x00400000 +#define R92C_APS_FSMCO_SOP_MRST 0x02000000 +#define R92C_APS_FSMCO_SOP_FUSE 0x04000000 +#define R92C_APS_FSMCO_SOP_ABG 0x08000000 +#define R92C_APS_FSMCO_SOP_AMB 0x10000000 +#define R92C_APS_FSMCO_SOP_RCK 0x20000000 +#define R92C_APS_FSMCO_SOP_A8M 0x40000000 +#define R92C_APS_FSMCO_XOP_BTCK 0x80000000 + +/* Bits for R92C_SYS_CLKR. */ +#define R92C_SYS_CLKR_ANAD16V_EN 0x00000001 +#define R92C_SYS_CLKR_ANA8M 0x00000002 +#define R92C_SYS_CLKR_MACSLP 0x00000010 +#define R92C_SYS_CLKR_LOADER_EN 0x00000020 +#define R92C_SYS_CLKR_80M_SSC_DIS 0x00000080 +#define R92C_SYS_CLKR_80M_SSC_EN_HO 0x00000100 +#define R92C_SYS_CLKR_PHY_SSC_RSTB 0x00000200 +#define R92C_SYS_CLKR_SEC_EN 0x00000400 +#define R92C_SYS_CLKR_MAC_EN 0x00000800 +#define R92C_SYS_CLKR_SYS_EN 0x00001000 +#define R92C_SYS_CLKR_RING_EN 0x00002000 + +/* Bits for R92C_RF_CTRL. */ +#define R92C_RF_CTRL_EN 0x01 +#define R92C_RF_CTRL_RSTB 0x02 +#define R92C_RF_CTRL_SDMRSTB 0x04 + +/* Bits for R92C_LDOV12D_CTRL. */ +#define R92C_LDOV12D_CTRL_LDV12_EN 0x01 + +/* Bits for R92C_EFUSE_CTRL. */ +#define R92C_EFUSE_CTRL_DATA_M 0x000000ff +#define R92C_EFUSE_CTRL_DATA_S 0 +#define R92C_EFUSE_CTRL_ADDR_M 0x0003ff00 +#define R92C_EFUSE_CTRL_ADDR_S 8 +#define R92C_EFUSE_CTRL_VALID 0x80000000 + +/* Bits for R92C_GPIO_MUXCFG. */ +#define R92C_GPIO_MUXCFG_RFKILL 0x0008 +#define R92C_GPIO_MUXCFG_ENBT 0x0020 + +/* Bits for R92C_GPIO_IO_SEL. */ +#define R92C_GPIO_IO_SEL_RFKILL 0x0008 + +/* Bits for R92C_LEDCFG0. */ +#define R92C_LEDCFG0_DIS 0x08 + +/* Bits for R92C_LEDCFG2. */ +#define R92C_LEDCFG2_EN 0x60 +#define R92C_LEDCFG2_DIS 0x68 + +/* Bits for R92C_MCUFWDL. */ +#define R92C_MCUFWDL_EN 0x00000001 +#define R92C_MCUFWDL_RDY 0x00000002 +#define R92C_MCUFWDL_CHKSUM_RPT 0x00000004 +#define R92C_MCUFWDL_MACINI_RDY 0x00000008 +#define R92C_MCUFWDL_BBINI_RDY 0x00000010 +#define R92C_MCUFWDL_RFINI_RDY 0x00000020 +#define R92C_MCUFWDL_WINTINI_RDY 0x00000040 +#define R92C_MCUFWDL_RAM_DL_SEL 0x00000080 /* 1: RAM, 0: ROM */ +#define R92C_MCUFWDL_PAGE_M 0x00070000 +#define R92C_MCUFWDL_PAGE_S 16 +#define R92C_MCUFWDL_CPRST 0x00800000 + +/* Bits for R92C_HPON_FSM. */ +#define R92C_HPON_FSM_CHIP_BONDING_ID_S 22 +#define R92C_HPON_FSM_CHIP_BONDING_ID_M 0x00c00000 +#define R92C_HPON_FSM_CHIP_BONDING_ID_92C_1T2R 1 + +/* Bits for R92C_SYS_CFG. */ +#define R92C_SYS_CFG_XCLK_VLD 0x00000001 +#define R92C_SYS_CFG_ACLK_VLD 0x00000002 +#define R92C_SYS_CFG_UCLK_VLD 0x00000004 +#define R92C_SYS_CFG_PCLK_VLD 0x00000008 +#define R92C_SYS_CFG_PCIRSTB 0x00000010 +#define R92C_SYS_CFG_V15_VLD 0x00000020 +#define R92C_SYS_CFG_TRP_B15V_EN 0x00000080 +#define R92C_SYS_CFG_SIC_IDLE 0x00000100 +#define R92C_SYS_CFG_BD_MAC2 0x00000200 +#define R92C_SYS_CFG_BD_MAC1 0x00000400 +#define R92C_SYS_CFG_IC_MACPHY_MODE 0x00000800 +#define R92C_SYS_CFG_CHIP_VER_RTL_M 0x0000f000 +#define R92C_SYS_CFG_CHIP_VER_RTL_S 12 +#define R92C_SYS_CFG_BT_FUNC 0x00010000 +#define R92C_SYS_CFG_VENDOR_UMC 0x00080000 +#define R92C_SYS_CFG_PAD_HWPD_IDN 0x00400000 +#define R92C_SYS_CFG_TRP_VAUX_EN 0x00800000 +#define R92C_SYS_CFG_TRP_BT_EN 0x01000000 +#define R92C_SYS_CFG_BD_PKG_SEL 0x02000000 +#define R92C_SYS_CFG_BD_HCI_SEL 0x04000000 +#define R92C_SYS_CFG_TYPE_92C 0x08000000 + +/* Bits for R92C_CR. */ +#define R92C_CR_HCI_TXDMA_EN 0x00000001 +#define R92C_CR_HCI_RXDMA_EN 0x00000002 +#define R92C_CR_TXDMA_EN 0x00000004 +#define R92C_CR_RXDMA_EN 0x00000008 +#define R92C_CR_PROTOCOL_EN 0x00000010 +#define R92C_CR_SCHEDULE_EN 0x00000020 +#define R92C_CR_MACTXEN 0x00000040 +#define R92C_CR_MACRXEN 0x00000080 +#define R92C_CR_ENSEC 0x00000200 +#define R92C_CR_NETTYPE_S 16 +#define R92C_CR_NETTYPE_M 0x00030000 +#define R92C_CR_NETTYPE_NOLINK 0 +#define R92C_CR_NETTYPE_ADHOC 1 +#define R92C_CR_NETTYPE_INFRA 2 +#define R92C_CR_NETTYPE_AP 3 + +/* Bits for R92C_PBP. */ +#define R92C_PBP_PSRX_M 0x0f +#define R92C_PBP_PSRX_S 0 +#define R92C_PBP_PSTX_M 0xf0 +#define R92C_PBP_PSTX_S 4 +#define R92C_PBP_64 0 +#define R92C_PBP_128 1 +#define R92C_PBP_256 2 +#define R92C_PBP_512 3 +#define R92C_PBP_1024 4 + +/* Bits for R92C_TRXDMA_CTRL. */ +#define R92C_TRXDMA_CTRL_RXDMA_AGG_EN 0x0004 +#define R92C_TRXDMA_CTRL_TXDMA_VOQ_MAP_M 0x0030 +#define R92C_TRXDMA_CTRL_TXDMA_VOQ_MAP_S 4 +#define R92C_TRXDMA_CTRL_TXDMA_VIQ_MAP_M 0x00c0 +#define R92C_TRXDMA_CTRL_TXDMA_VIQ_MAP_S 6 +#define R92C_TRXDMA_CTRL_TXDMA_BEQ_MAP_M 0x0300 +#define R92C_TRXDMA_CTRL_TXDMA_BEQ_MAP_S 8 +#define R92C_TRXDMA_CTRL_TXDMA_BKQ_MAP_M 0x0c00 +#define R92C_TRXDMA_CTRL_TXDMA_BKQ_MAP_S 10 +#define R92C_TRXDMA_CTRL_TXDMA_MGQ_MAP_M 0x3000 +#define R92C_TRXDMA_CTRL_TXDMA_MGQ_MAP_S 12 +#define R92C_TRXDMA_CTRL_TXDMA_HIQ_MAP_M 0xc000 +#define R92C_TRXDMA_CTRL_TXDMA_HIQ_MAP_S 14 +#define R92C_TRXDMA_CTRL_QUEUE_LOW 1 +#define R92C_TRXDMA_CTRL_QUEUE_NORMAL 2 +#define R92C_TRXDMA_CTRL_QUEUE_HIGH 3 +#define R92C_TRXDMA_CTRL_QMAP_M 0xfff0 +#define R92C_TRXDMA_CTRL_QMAP_S 4 +/* Shortcuts. */ +#define R92C_TRXDMA_CTRL_QMAP_3EP 0xf5b0 +#define R92C_TRXDMA_CTRL_QMAP_HQ_LQ 0xf5f0 +#define R92C_TRXDMA_CTRL_QMAP_HQ_NQ 0xfaf0 +#define R92C_TRXDMA_CTRL_QMAP_LQ 0x5550 +#define R92C_TRXDMA_CTRL_QMAP_NQ 0xaaa0 +#define R92C_TRXDMA_CTRL_QMAP_HQ 0xfff0 + +/* Bits for R92C_LLT_INIT. */ +#define R92C_LLT_INIT_DATA_M 0x000000ff +#define R92C_LLT_INIT_DATA_S 0 +#define R92C_LLT_INIT_ADDR_M 0x0000ff00 +#define R92C_LLT_INIT_ADDR_S 8 +#define R92C_LLT_INIT_OP_M 0xc0000000 +#define R92C_LLT_INIT_OP_S 30 +#define R92C_LLT_INIT_OP_NO_ACTIVE 0 +#define R92C_LLT_INIT_OP_WRITE 1 + +/* Bits for R92C_RQPN. */ +#define R92C_RQPN_HPQ_M 0x000000ff +#define R92C_RQPN_HPQ_S 0 +#define R92C_RQPN_LPQ_M 0x0000ff00 +#define R92C_RQPN_LPQ_S 8 +#define R92C_RQPN_PUBQ_M 0x00ff0000 +#define R92C_RQPN_PUBQ_S 16 +#define R92C_RQPN_LD 0x80000000 + +/* Bits for R92C_TDECTRL. */ +#define R92C_TDECTRL_BLK_DESC_NUM_M 0x0000000f +#define R92C_TDECTRL_BLK_DESC_NUM_S 4 + +/* Bits for R92C_FWHW_TXQ_CTRL. */ +#define R92C_FWHW_TXQ_CTRL_AMPDU_RTY_NEW 0x80 + +/* Bits for R92C_SPEC_SIFS. */ +#define R92C_SPEC_SIFS_CCK_M 0x00ff +#define R92C_SPEC_SIFS_CCK_S 0 +#define R92C_SPEC_SIFS_OFDM_M 0xff00 +#define R92C_SPEC_SIFS_OFDM_S 8 + +/* Bits for R92C_RL. */ +#define R92C_RL_LRL_M 0x003f +#define R92C_RL_LRL_S 0 +#define R92C_RL_SRL_M 0x3f00 +#define R92C_RL_SRL_S 8 + +/* Bits for R92C_RRSR. */ +#define R92C_RRSR_RATE_BITMAP_M 0x000fffff +#define R92C_RRSR_RATE_BITMAP_S 0 +#define R92C_RRSR_RATE_CCK_ONLY_1M 0xffff1 +#define R92C_RRSR_RATE_ALL 0xfffff +#define R92C_RRSR_RSC_LOWSUBCHNL 0x00200000 +#define R92C_RRSR_RSC_UPSUBCHNL 0x00400000 +#define R92C_RRSR_SHORT 0x00800000 + +/* Bits for R92C_EDCA_XX_PARAM. */ +#define R92C_EDCA_PARAM_AIFS_M 0x000000ff +#define R92C_EDCA_PARAM_AIFS_S 0 +#define R92C_EDCA_PARAM_ECWMIN_M 0x00000f00 +#define R92C_EDCA_PARAM_ECWMIN_S 8 +#define R92C_EDCA_PARAM_ECWMAX_M 0x0000f000 +#define R92C_EDCA_PARAM_ECWMAX_S 12 +#define R92C_EDCA_PARAM_TXOP_M 0xffff0000 +#define R92C_EDCA_PARAM_TXOP_S 16 + +/* Bits for R92C_TXPAUSE. */ +#define R92C_TXPAUSE_AC_VO 0x01 +#define R92C_TXPAUSE_AC_VI 0x02 +#define R92C_TXPAUSE_AC_BE 0x04 +#define R92C_TXPAUSE_AC_BK 0x08 + +/* Bits for R92C_BCN_CTRL. */ +#define R92C_BCN_CTRL_EN_MBSSID 0x02 +#define R92C_BCN_CTRL_TXBCN_RPT 0x04 +#define R92C_BCN_CTRL_EN_BCN 0x08 +#define R92C_BCN_CTRL_DIS_TSF_UDT0 0x10 + +/* Bits for R92C_APSD_CTRL. */ +#define R92C_APSD_CTRL_OFF 0x40 +#define R92C_APSD_CTRL_OFF_STATUS 0x80 + +/* Bits for R92C_BWOPMODE. */ +#define R92C_BWOPMODE_11J 0x01 +#define R92C_BWOPMODE_5G 0x02 +#define R92C_BWOPMODE_20MHZ 0x04 + +/* Bits for R92C_TCR. */ +#define R92C_TCR_TSFRST 0x00000001 +#define R92C_TCR_DIS_GCLK 0x00000002 +#define R92C_TCR_PAD_SEL 0x00000004 +#define R92C_TCR_PWR_ST 0x00000040 +#define R92C_TCR_PWRBIT_OW_EN 0x00000080 +#define R92C_TCR_ACRC 0x00000100 +#define R92C_TCR_CFENDFORM 0x00000200 +#define R92C_TCR_ICV 0x00000400 + +/* Bits for R92C_RCR. */ +#define R92C_RCR_AAP 0x00000001 +#define R92C_RCR_APM 0x00000002 +#define R92C_RCR_AM 0x00000004 +#define R92C_RCR_AB 0x00000008 +#define R92C_RCR_ADD3 0x00000010 +#define R92C_RCR_APWRMGT 0x00000020 +#define R92C_RCR_CBSSID_DATA 0x00000040 +#define R92C_RCR_CBSSID_BCN 0x00000080 +#define R92C_RCR_ACRC32 0x00000100 +#define R92C_RCR_AICV 0x00000200 +#define R92C_RCR_ADF 0x00000800 +#define R92C_RCR_ACF 0x00001000 +#define R92C_RCR_AMF 0x00002000 +#define R92C_RCR_HTC_LOC_CTRL 0x00004000 +#define R92C_RCR_MFBEN 0x00400000 +#define R92C_RCR_LSIGEN 0x00800000 +#define R92C_RCR_ENMBID 0x01000000 +#define R92C_RCR_APP_BA_SSN 0x08000000 +#define R92C_RCR_APP_PHYSTS 0x10000000 +#define R92C_RCR_APP_ICV 0x20000000 +#define R92C_RCR_APP_MIC 0x40000000 +#define R92C_RCR_APPFCS 0x80000000 + +/* Bits for R92C_CAMCMD. */ +#define R92C_CAMCMD_ADDR_M 0x0000ffff +#define R92C_CAMCMD_ADDR_S 0 +#define R92C_CAMCMD_WRITE 0x00010000 +#define R92C_CAMCMD_CLR 0x40000000 +#define R92C_CAMCMD_POLLING 0x80000000 + +/* IMR */ + +/*Beacon DMA interrupt 6 */ +#define R92C_IMR_BCNDMAINT6 0x80000000 +/*Beacon DMA interrupt 5 */ +#define R92C_IMR_BCNDMAINT5 0x40000000 +/*Beacon DMA interrupt 4 */ +#define R92C_IMR_BCNDMAINT4 0x20000000 +/*Beacon DMA interrupt 3 */ +#define R92C_IMR_BCNDMAINT3 0x10000000 +/*Beacon DMA interrupt 2 */ +#define R92C_IMR_BCNDMAINT2 0x08000000 +/*Beacon DMA interrupt 1 */ +#define R92C_IMR_BCNDMAINT1 0x04000000 +/*Beacon Queue DMA OK interrupt 8 */ +#define R92C_IMR_BCNDOK8 0x02000000 +/*Beacon Queue DMA OK interrupt 7 */ +#define R92C_IMR_BCNDOK7 0x01000000 +/*Beacon Queue DMA OK interrupt 6 */ +#define R92C_IMR_BCNDOK6 0x00800000 +/*Beacon Queue DMA OK interrupt 5 */ +#define R92C_IMR_BCNDOK5 0x00400000 +/*Beacon Queue DMA OK interrupt 4 */ +#define R92C_IMR_BCNDOK4 0x00200000 +/*Beacon Queue DMA OK interrupt 3 */ +#define R92C_IMR_BCNDOK3 0x00100000 +/*Beacon Queue DMA OK interrupt 2 */ +#define R92C_IMR_BCNDOK2 0x00080000 +/*Beacon Queue DMA OK interrupt 1 */ +#define R92C_IMR_BCNDOK1 0x00040000 +/*Timeout interrupt 2 */ +#define R92C_IMR_TIMEOUT2 0x00020000 +/*Timeout interrupt 1 */ +#define R92C_IMR_TIMEOUT1 0x00010000 +/*Transmit FIFO Overflow */ +#define R92C_IMR_TXFOVW 0x00008000 +/*Power save time out interrupt */ +#define R92C_IMR_PSTIMEOUT 0x00004000 +/*Beacon DMA interrupt 0 */ +#define R92C_IMR_BCNINT 0x00002000 +/*Receive FIFO Overflow */ +#define R92C_IMR_RXFOVW 0x00001000 +/*Receive Descriptor Unavailable */ +#define R92C_IMR_RDU 0x00000800 +/*For 92C,ATIM Window End interrupt */ +#define R92C_IMR_ATIMEND 0x00000400 +/*Beacon Queue DMA OK interrupt */ +#define R92C_IMR_BDOK 0x00000200 +/*High Queue DMA OK interrupt */ +#define R92C_IMR_HIGHDOK 0x00000100 +/*Transmit Beacon OK interrupt */ +#define R92C_IMR_TBDOK 0x00000080 +/*Management Queue DMA OK interrupt */ +#define R92C_IMR_MGNTDOK 0x00000040 +/*For 92C,Transmit Beacon Error interrupt */ +#define R92C_IMR_TBDER 0x00000020 +/*AC_BK DMA OK interrupt */ +#define R92C_IMR_BKDOK 0x00000010 +/*AC_BE DMA OK interrupt */ +#define R92C_IMR_BEDOK 0x00000008 +/*AC_VI DMA OK interrupt */ +#define R92C_IMR_VIDOK 0x00000004 +/*AC_VO DMA interrupt */ +#define R92C_IMR_VODOK 0x00000002 +/*Receive DMA OK interrupt */ +#define R92C_IMR_ROK 0x00000001 + +#define R92C_IBSS_INT_MASK (R92C_IMR_BCNINT | R92C_IMR_TBDOK | R92C_IMR_TBDER) + +/* + * Baseband registers. + */ +#define R92C_FPGA0_RFMOD 0x800 +#define R92C_FPGA0_TXINFO 0x804 +#define R92C_HSSI_PARAM1(chain) (0x820 + (chain) * 8) +#define R92C_HSSI_PARAM2(chain) (0x824 + (chain) * 8) +#define R92C_TXAGC_RATE18_06(i) (((i) == 0) ? 0xe00 : 0x830) +#define R92C_TXAGC_RATE54_24(i) (((i) == 0) ? 0xe04 : 0x834) +#define R92C_TXAGC_A_CCK1_MCS32 0xe08 +#define R92C_TXAGC_B_CCK1_55_MCS32 0x838 +#define R92C_TXAGC_B_CCK11_A_CCK2_11 0x86c +#define R92C_TXAGC_MCS03_MCS00(i) (((i) == 0) ? 0xe10 : 0x83c) +#define R92C_TXAGC_MCS07_MCS04(i) (((i) == 0) ? 0xe14 : 0x848) +#define R92C_TXAGC_MCS11_MCS08(i) (((i) == 0) ? 0xe18 : 0x84c) +#define R92C_TXAGC_MCS15_MCS12(i) (((i) == 0) ? 0xe1c : 0x868) +#define R92C_LSSI_PARAM(chain) (0x840 + (chain) * 4) +#define R92C_FPGA0_RFIFACEOE(chain) (0x860 + (chain) * 4) +#define R92C_FPGA0_RFIFACESW(idx) (0x870 + (idx) * 4) +#define R92C_FPGA0_RFPARAM(idx) (0x878 + (idx) * 4) +#define R92C_FPGA0_ANAPARAM2 0x884 +#define R92C_LSSI_READBACK(chain) (0x8a0 + (chain) * 4) +#define R92C_HSPI_READBACK(chain) (0x8b8 + (chain) * 4) +#define R92C_FPGA1_RFMOD 0x900 +#define R92C_FPGA1_TXINFO 0x90c +#define R92C_CCK0_SYSTEM 0xa00 +#define R92C_CCK0_AFESETTING 0xa04 +#define R92C_OFDM0_TRXPATHENA 0xc04 +#define R92C_OFDM0_TRMUXPAR 0xc08 +#define R92C_OFDM0_RXIQIMBALANCE(chain) (0xc14 + (chain) * 8) +#define R92C_OFDM0_ECCATHRESHOLD 0xc4c +#define R92C_OFDM0_AGCCORE1(chain) (0xc50 + (chain) * 8) +#define R92C_OFDM0_AGCPARAM1 0xc70 +#define R92C_OFDM0_AGCRSSITABLE 0xc78 +#define R92C_OFDM0_TXIQIMBALANCE(chain) (0xc80 + (chain) * 8) +#define R92C_OFDM0_TXAFE(chain) (0xc94 + (chain) * 8) +#define R92C_OFDM0_RXIQEXTANTA 0xca0 +#define R92C_OFDM1_LSTF 0xd00 + +/* Bits for R92C_FPGA[01]_RFMOD. */ +#define R92C_RFMOD_40MHZ 0x00000001 +#define R92C_RFMOD_JAPAN 0x00000002 +#define R92C_RFMOD_CCK_TXSC 0x00000030 +#define R92C_RFMOD_CCK_EN 0x01000000 +#define R92C_RFMOD_OFDM_EN 0x02000000 + +/* Bits for R92C_HSSI_PARAM1(i). */ +#define R92C_HSSI_PARAM1_PI 0x00000100 + +/* Bits for R92C_HSSI_PARAM2(i). */ +#define R92C_HSSI_PARAM2_CCK_HIPWR 0x00000200 +#define R92C_HSSI_PARAM2_ADDR_LENGTH 0x00000400 +#define R92C_HSSI_PARAM2_DATA_LENGTH 0x00000800 +#define R92C_HSSI_PARAM2_READ_ADDR_M 0x7f800000 +#define R92C_HSSI_PARAM2_READ_ADDR_S 23 +#define R92C_HSSI_PARAM2_READ_EDGE 0x80000000 + +/* Bits for R92C_TXAGC_A_CCK1_MCS32. */ +#define R92C_TXAGC_A_CCK1_M 0x0000ff00 +#define R92C_TXAGC_A_CCK1_S 8 + +/* Bits for R92C_TXAGC_B_CCK11_A_CCK2_11. */ +#define R92C_TXAGC_B_CCK11_M 0x000000ff +#define R92C_TXAGC_B_CCK11_S 0 +#define R92C_TXAGC_A_CCK2_M 0x0000ff00 +#define R92C_TXAGC_A_CCK2_S 8 +#define R92C_TXAGC_A_CCK55_M 0x00ff0000 +#define R92C_TXAGC_A_CCK55_S 16 +#define R92C_TXAGC_A_CCK11_M 0xff000000 +#define R92C_TXAGC_A_CCK11_S 24 + +/* Bits for R92C_TXAGC_B_CCK1_55_MCS32. */ +#define R92C_TXAGC_B_CCK1_M 0x0000ff00 +#define R92C_TXAGC_B_CCK1_S 8 +#define R92C_TXAGC_B_CCK2_M 0x00ff0000 +#define R92C_TXAGC_B_CCK2_S 16 +#define R92C_TXAGC_B_CCK55_M 0xff000000 +#define R92C_TXAGC_B_CCK55_S 24 + +/* Bits for R92C_TXAGC_RATE18_06(x). */ +#define R92C_TXAGC_RATE06_M 0x000000ff +#define R92C_TXAGC_RATE06_S 0 +#define R92C_TXAGC_RATE09_M 0x0000ff00 +#define R92C_TXAGC_RATE09_S 8 +#define R92C_TXAGC_RATE12_M 0x00ff0000 +#define R92C_TXAGC_RATE12_S 16 +#define R92C_TXAGC_RATE18_M 0xff000000 +#define R92C_TXAGC_RATE18_S 24 + +/* Bits for R92C_TXAGC_RATE54_24(x). */ +#define R92C_TXAGC_RATE24_M 0x000000ff +#define R92C_TXAGC_RATE24_S 0 +#define R92C_TXAGC_RATE36_M 0x0000ff00 +#define R92C_TXAGC_RATE36_S 8 +#define R92C_TXAGC_RATE48_M 0x00ff0000 +#define R92C_TXAGC_RATE48_S 16 +#define R92C_TXAGC_RATE54_M 0xff000000 +#define R92C_TXAGC_RATE54_S 24 + +/* Bits for R92C_TXAGC_MCS03_MCS00(x). */ +#define R92C_TXAGC_MCS00_M 0x000000ff +#define R92C_TXAGC_MCS00_S 0 +#define R92C_TXAGC_MCS01_M 0x0000ff00 +#define R92C_TXAGC_MCS01_S 8 +#define R92C_TXAGC_MCS02_M 0x00ff0000 +#define R92C_TXAGC_MCS02_S 16 +#define R92C_TXAGC_MCS03_M 0xff000000 +#define R92C_TXAGC_MCS03_S 24 + +/* Bits for R92C_TXAGC_MCS07_MCS04(x). */ +#define R92C_TXAGC_MCS04_M 0x000000ff +#define R92C_TXAGC_MCS04_S 0 +#define R92C_TXAGC_MCS05_M 0x0000ff00 +#define R92C_TXAGC_MCS05_S 8 +#define R92C_TXAGC_MCS06_M 0x00ff0000 +#define R92C_TXAGC_MCS06_S 16 +#define R92C_TXAGC_MCS07_M 0xff000000 +#define R92C_TXAGC_MCS07_S 24 + +/* Bits for R92C_TXAGC_MCS11_MCS08(x). */ +#define R92C_TXAGC_MCS08_M 0x000000ff +#define R92C_TXAGC_MCS08_S 0 +#define R92C_TXAGC_MCS09_M 0x0000ff00 +#define R92C_TXAGC_MCS09_S 8 +#define R92C_TXAGC_MCS10_M 0x00ff0000 +#define R92C_TXAGC_MCS10_S 16 +#define R92C_TXAGC_MCS11_M 0xff000000 +#define R92C_TXAGC_MCS11_S 24 + +/* Bits for R92C_TXAGC_MCS15_MCS12(x). */ +#define R92C_TXAGC_MCS12_M 0x000000ff +#define R92C_TXAGC_MCS12_S 0 +#define R92C_TXAGC_MCS13_M 0x0000ff00 +#define R92C_TXAGC_MCS13_S 8 +#define R92C_TXAGC_MCS14_M 0x00ff0000 +#define R92C_TXAGC_MCS14_S 16 +#define R92C_TXAGC_MCS15_M 0xff000000 +#define R92C_TXAGC_MCS15_S 24 + +/* Bits for R92C_LSSI_PARAM(i). */ +#define R92C_LSSI_PARAM_DATA_M 0x000fffff +#define R92C_LSSI_PARAM_DATA_S 0 +#define R92C_LSSI_PARAM_ADDR_M 0x03f00000 +#define R92C_LSSI_PARAM_ADDR_S 20 + +/* Bits for R92C_FPGA0_ANAPARAM2. */ +#define R92C_FPGA0_ANAPARAM2_CBW20 0x00000400 + +/* Bits for R92C_LSSI_READBACK(i). */ +#define R92C_LSSI_READBACK_DATA_M 0x000fffff +#define R92C_LSSI_READBACK_DATA_S 0 + +/* Bits for R92C_OFDM0_AGCCORE1(i). */ +#define R92C_OFDM0_AGCCORE1_GAIN_M 0x0000007f +#define R92C_OFDM0_AGCCORE1_GAIN_S 0 + + +/* + * USB registers. + */ +#define R92C_USB_INFO 0xfe17 +#define R92C_USB_SPECIAL_OPTION 0xfe55 +#define R92C_USB_HCPWM 0xfe57 +#define R92C_USB_HRPWM 0xfe58 +#define R92C_USB_DMA_AGG_TO 0xfe5b +#define R92C_USB_AGG_TO 0xfe5c +#define R92C_USB_AGG_TH 0xfe5d +#define R92C_USB_VID 0xfe60 +#define R92C_USB_PID 0xfe62 +#define R92C_USB_OPTIONAL 0xfe64 +#define R92C_USB_EP 0xfe65 +#define R92C_USB_PHY 0xfe68 +#define R92C_USB_MAC_ADDR 0xfe70 +#define R92C_USB_STRING 0xfe80 + +/* Bits for R92C_USB_SPECIAL_OPTION. */ +#define R92C_USB_SPECIAL_OPTION_AGG_EN 0x08 + +/* Bits for R92C_USB_EP. */ +#define R92C_USB_EP_HQ_M 0x000f +#define R92C_USB_EP_HQ_S 0 +#define R92C_USB_EP_NQ_M 0x00f0 +#define R92C_USB_EP_NQ_S 4 +#define R92C_USB_EP_LQ_M 0x0f00 +#define R92C_USB_EP_LQ_S 8 + + +/* + * Firmware base address. + */ +#define R92C_FW_START_ADDR 0x1000 +#define R92C_FW_PAGE_SIZE 4096 + + +/* + * RF (6052) registers. + */ +#define R92C_RF_AC 0x00 +#define R92C_RF_IQADJ_G(i) (0x01 + (i)) +#define R92C_RF_POW_TRSW 0x05 +#define R92C_RF_GAIN_RX 0x06 +#define R92C_RF_GAIN_TX 0x07 +#define R92C_RF_TXM_IDAC 0x08 +#define R92C_RF_BS_IQGEN 0x0f +#define R92C_RF_MODE1 0x10 +#define R92C_RF_MODE2 0x11 +#define R92C_RF_RX_AGC_HP 0x12 +#define R92C_RF_TX_AGC 0x13 +#define R92C_RF_BIAS 0x14 +#define R92C_RF_IPA 0x15 +#define R92C_RF_POW_ABILITY 0x17 +#define R92C_RF_CHNLBW 0x18 +#define R92C_RF_RX_G1 0x1a +#define R92C_RF_RX_G2 0x1b +#define R92C_RF_RX_BB2 0x1c +#define R92C_RF_RX_BB1 0x1d +#define R92C_RF_RCK1 0x1e +#define R92C_RF_RCK2 0x1f +#define R92C_RF_TX_G(i) (0x20 + (i)) +#define R92C_RF_TX_BB1 0x23 +#define R92C_RF_T_METER 0x24 +#define R92C_RF_SYN_G(i) (0x25 + (i)) +#define R92C_RF_RCK_OS 0x30 +#define R92C_RF_TXPA_G(i) (0x31 + (i)) + +/* Bits for R92C_RF_AC. */ +#define R92C_RF_AC_MODE_M 0x70000 +#define R92C_RF_AC_MODE_S 16 +#define R92C_RF_AC_MODE_STANDBY 1 + +/* Bits for R92C_RF_CHNLBW. */ +#define R92C_RF_CHNLBW_CHNL_M 0x003ff +#define R92C_RF_CHNLBW_CHNL_S 0 +#define R92C_RF_CHNLBW_BW20 0x00400 +#define R92C_RF_CHNLBW_LCSTART 0x08000 + + +/* + * CAM entries. + */ +#define R92C_CAM_ENTRY_COUNT 32 + +#define R92C_CAM_CTL0(entry) ((entry) * 8 + 0) +#define R92C_CAM_CTL1(entry) ((entry) * 8 + 1) +#define R92C_CAM_KEY(entry, i) ((entry) * 8 + 2 + (i)) + +/* Bits for R92C_CAM_CTL0(i). */ +#define R92C_CAM_KEYID_M 0x00000003 +#define R92C_CAM_KEYID_S 0 +#define R92C_CAM_ALGO_M 0x0000001c +#define R92C_CAM_ALGO_S 2 +#define R92C_CAM_ALGO_NONE 0 +#define R92C_CAM_ALGO_WEP40 1 +#define R92C_CAM_ALGO_TKIP 2 +#define R92C_CAM_ALGO_AES 4 +#define R92C_CAM_ALGO_WEP104 5 +#define R92C_CAM_VALID 0x00008000 +#define R92C_CAM_MACLO_M 0xffff0000 +#define R92C_CAM_MACLO_S 16 + +/* Rate adaptation modes. */ +#define R92C_RAID_11GN 1 +#define R92C_RAID_11N 3 +#define R92C_RAID_11BG 4 +#define R92C_RAID_11G 5 /* "pure" 11g */ +#define R92C_RAID_11B 6 + + +/* Macros to access unaligned little-endian memory. */ +#define LE_READ_2(x) ((x)[0] | (x)[1] << 8) +#define LE_READ_4(x) ((x)[0] | (x)[1] << 8 | (x)[2] << 16 | (x)[3] << 24) + +/* + * Macros to access subfields in registers. + */ +/* Mask and Shift (getter). */ +#define MS(val, field) \ + (((val) & field##_M) >> field##_S) + +/* Shift and Mask (setter). */ +#define SM(field, val) \ + (((val) << field##_S) & field##_M) + +/* Rewrite. */ +#define RW(var, field, val) \ + (((var) & ~field##_M) | SM(field, val)) + +/* + * Firmware image header. + */ +struct r92c_fw_hdr { + /* QWORD0 */ + uint16_t signature; + uint8_t category; + uint8_t function; + uint16_t version; + uint16_t subversion; + /* QWORD1 */ + uint8_t month; + uint8_t date; + uint8_t hour; + uint8_t minute; + uint16_t ramcodesize; + uint16_t reserved2; + /* QWORD2 */ + uint32_t svnidx; + uint32_t reserved3; + /* QWORD3 */ + uint32_t reserved4; + uint32_t reserved5; +} __packed; + +/* + * Host to firmware commands. + */ +struct r92c_fw_cmd { + uint8_t id; +#define R92C_CMD_AP_OFFLOAD 0 +#define R92C_CMD_SET_PWRMODE 1 +#define R92C_CMD_JOINBSS_RPT 2 +#define R92C_CMD_RSVD_PAGE 3 +#define R92C_CMD_RSSI 4 +#define R92C_CMD_RSSI_SETTING 5 +#define R92C_CMD_MACID_CONFIG 6 +#define R92C_CMD_MACID_PS_MODE 7 +#define R92C_CMD_P2P_PS_OFFLOAD 8 +#define R92C_CMD_SELECTIVE_SUSPEND 9 +#define R92C_CMD_FLAG_EXT 0x80 + + uint8_t msg[5]; +} __packed; + +/* Structure for R92C_CMD_RSSI_SETTING. */ +struct r92c_fw_cmd_rssi { + uint8_t macid; + uint8_t reserved; + uint8_t pwdb; +} __packed; + +/* Structure for R92C_CMD_MACID_CONFIG. */ +struct r92c_fw_cmd_macid_cfg { + uint32_t mask; + uint8_t macid; +#define RTWN_MACID_BSS 0 +#define RTWN_MACID_BC 4 /* Broadcast. */ +#define RTWN_MACID_VALID 0x80 +} __packed; + +/* + * RTL8192CU ROM image. + */ +struct r92c_rom { + uint16_t id; /* 0x8129 */ + uint8_t reserved1[5]; + uint8_t dbg_sel; + uint16_t reserved2; + uint16_t vid; + uint16_t pid; + uint8_t usb_opt; + uint8_t ep_setting; + uint16_t reserved3; + uint8_t usb_phy; + uint8_t reserved4[3]; + uint8_t macaddr[6]; + uint8_t string[61]; /* "Realtek" */ + uint8_t subcustomer_id; + uint8_t cck_tx_pwr[R92C_MAX_CHAINS][3]; + uint8_t ht40_1s_tx_pwr[R92C_MAX_CHAINS][3]; + uint8_t ht40_2s_tx_pwr_diff[3]; + uint8_t ht20_tx_pwr_diff[3]; + uint8_t ofdm_tx_pwr_diff[3]; + uint8_t ht40_max_pwr[3]; + uint8_t ht20_max_pwr[3]; + uint8_t xtal_calib; + uint8_t tssi[R92C_MAX_CHAINS]; + uint8_t thermal_meter; + uint8_t rf_opt1; +#define R92C_ROM_RF1_REGULATORY_M 0x07 +#define R92C_ROM_RF1_REGULATORY_S 0 +#define R92C_ROM_RF1_BOARD_TYPE_M 0xe0 +#define R92C_ROM_RF1_BOARD_TYPE_S 5 +#define R92C_BOARD_TYPE_DONGLE 0 +#define R92C_BOARD_TYPE_HIGHPA 1 +#define R92C_BOARD_TYPE_MINICARD 2 +#define R92C_BOARD_TYPE_SOLO 3 +#define R92C_BOARD_TYPE_COMBO 4 + + uint8_t rf_opt2; + uint8_t rf_opt3; + uint8_t rf_opt4; + uint8_t channel_plan; + uint8_t version; + uint8_t curstomer_id; +} __packed; + +/* Rx MAC descriptor. */ +struct r92c_rx_desc { + uint32_t rxdw0; +#define R92C_RXDW0_PKTLEN_M 0x00003fff +#define R92C_RXDW0_PKTLEN_S 0 +#define R92C_RXDW0_CRCERR 0x00004000 +#define R92C_RXDW0_ICVERR 0x00008000 +#define R92C_RXDW0_INFOSZ_M 0x000f0000 +#define R92C_RXDW0_INFOSZ_S 16 +#define R92C_RXDW0_QOS 0x00800000 +#define R92C_RXDW0_SHIFT_M 0x03000000 +#define R92C_RXDW0_SHIFT_S 24 +#define R92C_RXDW0_PHYST 0x04000000 +#define R92C_RXDW0_DECRYPTED 0x08000000 +#define R92C_RXDW0_LS 0x10000000 +#define R92C_RXDW0_FS 0x20000000 +#define R92C_RXDW0_EOR 0x40000000 +#define R92C_RXDW0_OWN 0x80000000 + + uint32_t rxdw1; + uint32_t rxdw2; +#define R92C_RXDW2_PKTCNT_M 0x00ff0000 +#define R92C_RXDW2_PKTCNT_S 16 + + uint32_t rxdw3; +#define R92C_RXDW3_RATE_M 0x0000003f +#define R92C_RXDW3_RATE_S 0 +#define R92C_RXDW3_HT 0x00000040 +#define R92C_RXDW3_HTC 0x00000400 + + uint32_t rxdw4; + uint32_t rxdw5; + + uint32_t rxbufaddr; + uint32_t rxbufaddr64; +} __packed __attribute__((aligned(4))); + +/* Rx PHY descriptor. */ +struct r92c_rx_phystat { + uint32_t phydw0; + uint32_t phydw1; + uint32_t phydw2; + uint32_t phydw3; + uint32_t phydw4; + uint32_t phydw5; + uint32_t phydw6; + uint32_t phydw7; +} __packed __attribute__((aligned(4))); + +/* Rx PHY CCK descriptor. */ +struct r92c_rx_cck { + uint8_t adc_pwdb[4]; + uint8_t sq_rpt; + uint8_t agc_rpt; +} __packed; + +/* Tx MAC descriptor. */ +struct r92c_tx_desc { + uint32_t txdw0; +#define R92C_TXDW0_PKTLEN_M 0x0000ffff +#define R92C_TXDW0_PKTLEN_S 0 +#define R92C_TXDW0_OFFSET_M 0x00ff0000 +#define R92C_TXDW0_OFFSET_S 16 +#define R92C_TXDW0_BMCAST 0x01000000 +#define R92C_TXDW0_LSG 0x04000000 +#define R92C_TXDW0_FSG 0x08000000 +#define R92C_TXDW0_OWN 0x80000000 + + uint32_t txdw1; +#define R92C_TXDW1_MACID_M 0x0000001f +#define R92C_TXDW1_MACID_S 0 +#define R92C_TXDW1_AGGEN 0x00000020 +#define R92C_TXDW1_AGGBK 0x00000040 +#define R92C_TXDW1_QSEL_M 0x00001f00 +#define R92C_TXDW1_QSEL_S 8 +#define R92C_TXDW1_QSEL_BE 0x00 +#define R92C_TXDW1_QSEL_BK 0x02 +#define R92C_TXDW1_QSEL_VI 0x05 +#define R92C_TXDW1_QSEL_VO 0x07 +#define R92C_TXDW1_QSEL_BEACON 0x10 +#define R92C_TXDW1_QSEL_HIGH 0x11 +#define R92C_TXDW1_QSEL_MGNT 0x12 +#define R92C_TXDW1_QSEL_CMD 0x13 +#define R92C_TXDW1_RAID_M 0x000f0000 +#define R92C_TXDW1_RAID_S 16 +#define R92C_TXDW1_CIPHER_M 0x00c00000 +#define R92C_TXDW1_CIPHER_S 22 +#define R92C_TXDW1_CIPHER_NONE 0 +#define R92C_TXDW1_CIPHER_RC4 1 +#define R92C_TXDW1_CIPHER_AES 3 +#define R92C_TXDW1_PKTOFF_M 0x7c000000 +#define R92C_TXDW1_PKTOFF_S 26 + + uint32_t txdw2; + uint16_t txdw3; + uint16_t txdseq; + + uint32_t txdw4; +#define R92C_TXDW4_RTSRATE_M 0x0000003f +#define R92C_TXDW4_RTSRATE_S 0 +#define R92C_TXDW4_QOS 0x00000040 +#define R92C_TXDW4_HWSEQ 0x00000080 +#define R92C_TXDW4_DRVRATE 0x00000100 +#define R92C_TXDW4_CTS2SELF 0x00000800 +#define R92C_TXDW4_RTSEN 0x00001000 +#define R92C_TXDW4_HWRTSEN 0x00002000 +#define R92C_TXDW4_SCO_M 0x003f0000 +#define R92C_TXDW4_SCO_S 20 +#define R92C_TXDW4_SCO_SCA 1 +#define R92C_TXDW4_SCO_SCB 2 +#define R92C_TXDW4_40MHZ 0x02000000 + + uint32_t txdw5; +#define R92C_TXDW5_DATARATE_M 0x0000003f +#define R92C_TXDW5_DATARATE_S 0 +#define R92C_TXDW5_SGI 0x00000040 +#define R92C_TXDW5_DATARATE_FBLIMIT_M 0x00001f00 +#define R92C_TXDW5_DATARATE_FBLIMIT_S 8 +#define R92C_TXDW5_RTSRATE_FBLIMIT_M 0x0001e000 +#define R92C_TXDW5_RTSRATE_FBLIMIT_S 13 +#define R92C_TXDW5_RETRY_LIMIT_ENABLE 0x00020000 +#define R92C_TXDW5_DATA_RETRY_LIMIT_M 0x00fc0000 +#define R92C_TXDW5_DATA_RETRY_LIMIT_S 18 +#define R92C_TXDW5_AGGNUM_M 0xff000000 +#define R92C_TXDW5_AGGNUM_S 24 + + uint32_t txdw6; + + uint16_t txbufsize; + uint16_t pad; + + uint32_t txbufaddr; + uint32_t txbufaddr64; + + uint32_t nextdescaddr; + uint32_t nextdescaddr64; + + uint32_t reserved[4]; +} __packed __attribute__((aligned(4))); + + +/* + * Driver definitions. + */ +#define RTWN_NTXQUEUES 9 +#define RTWN_RX_LIST_COUNT 256 +#define RTWN_TX_LIST_COUNT 256 +#define RTWN_HOST_CMD_RING_COUNT 32 + +/* TX queue indices. */ +#define RTWN_BK_QUEUE 0 +#define RTWN_BE_QUEUE 1 +#define RTWN_VI_QUEUE 2 +#define RTWN_VO_QUEUE 3 +#define RTWN_BEACON_QUEUE 4 +#define RTWN_TXCMD_QUEUE 5 +#define RTWN_MGNT_QUEUE 6 +#define RTWN_HIGH_QUEUE 7 +#define RTWN_HCCA_QUEUE 8 + +/* RX queue indices. */ +#define RTWN_RX_QUEUE 0 + +#define RTWN_RXBUFSZ (16 * 1024) +#define RTWN_TXBUFSZ (sizeof(struct r92c_tx_desc) + IEEE80211_MAX_LEN) + +#define RTWN_RIDX_COUNT 28 + +#define RTWN_TX_TIMEOUT 5000 /* ms */ + +#define RTWN_LED_LINK 0 +#define RTWN_LED_DATA 1 + +struct rtwn_rx_radiotap_header { + struct ieee80211_radiotap_header wr_ihdr; + uint8_t wr_flags; + uint8_t wr_rate; + uint16_t wr_chan_freq; + uint16_t wr_chan_flags; + uint8_t wr_dbm_antsignal; +} __packed; + +#define RTWN_RX_RADIOTAP_PRESENT \ + (1 << IEEE80211_RADIOTAP_FLAGS | \ + 1 << IEEE80211_RADIOTAP_RATE | \ + 1 << IEEE80211_RADIOTAP_CHANNEL | \ + 1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) + +struct rtwn_tx_radiotap_header { + struct ieee80211_radiotap_header wt_ihdr; + uint8_t wt_flags; + uint16_t wt_chan_freq; + uint16_t wt_chan_flags; +} __packed; + +#define RTWN_TX_RADIOTAP_PRESENT \ + (1 << IEEE80211_RADIOTAP_FLAGS | \ + 1 << IEEE80211_RADIOTAP_CHANNEL) + +struct rtwn_softc; + +struct rtwn_rx_data { + bus_dmamap_t map; + struct mbuf *m; + bus_addr_t paddr; +}; + +struct rtwn_rx_ring { + struct r92c_rx_desc *desc; + bus_addr_t paddr; + bus_dma_tag_t desc_dmat; + bus_dmamap_t desc_map; + bus_dma_tag_t data_dmat; + bus_dma_segment_t seg; + struct rtwn_rx_data rx_data[RTWN_RX_LIST_COUNT]; + +}; +struct rtwn_tx_data { + bus_dmamap_t map; + struct mbuf *m; + struct ieee80211_node *ni; +}; + +struct rtwn_tx_ring { + bus_addr_t paddr; + bus_dma_tag_t desc_dmat; + bus_dmamap_t desc_map; + bus_dma_tag_t data_dmat; + bus_dma_segment_t seg; + struct r92c_tx_desc *desc; + struct rtwn_tx_data tx_data[RTWN_TX_LIST_COUNT]; + int queued; + int cur; +}; + +struct rtwn_host_cmd { + void (*cb)(struct rtwn_softc *, void *); + uint8_t data[256]; +}; + +struct rtwn_cmd_key { + struct ieee80211_key key; + uint16_t associd; +}; + +struct rtwn_host_cmd_ring { + struct rtwn_host_cmd cmd[RTWN_HOST_CMD_RING_COUNT]; + int cur; + int next; + int queued; +}; + +struct rtwn_vap { + struct ieee80211vap vap; + int (*newstate)(struct ieee80211vap *, + enum ieee80211_state, int); +}; +#define RTWN_VAP(vap) ((struct rtwn_vap *)(vap)) + +struct rtwn_softc { + device_t sc_dev; + struct mtx sc_mtx; + struct ieee80211com sc_ic; + struct mbufq sc_snd; + + struct resource *irq; + struct resource *mem; + bus_space_tag_t sc_st; + bus_space_handle_t sc_sh; + void *sc_ih; + bus_size_t sc_mapsize; + int sc_cap_off; + + struct task sc_reinit_task; + struct callout calib_to; + struct callout watchdog_to; + + int sc_debug; + + u_int sc_flags; +#define RTWN_FLAG_CCK_HIPWR 0x01 +#define RTWN_FLAG_BUSY 0x02 +#define RTWN_RUNNING 0x04 + + u_int chip; +#define RTWN_CHIP_88C 0x00 +#define RTWN_CHIP_92C 0x01 +#define RTWN_CHIP_92C_1T2R 0x02 +#define RTWN_CHIP_UMC 0x04 +#define RTWN_CHIP_UMC_A_CUT 0x08 + + uint8_t board_type; + uint8_t regulatory; + uint8_t pa_setting; + int avg_pwdb; + int thcal_state; + int thcal_lctemp; + int ntxchains; + int nrxchains; + int ledlink; + + int sc_tx_timer; + int fwcur; + struct rtwn_rx_ring rx_ring; + struct rtwn_tx_ring tx_ring[RTWN_NTXQUEUES]; + uint32_t qfullmsk; + struct r92c_rom rom; + + uint32_t rf_chnlbw[R92C_MAX_CHAINS]; + + struct rtwn_rx_radiotap_header sc_rxtap; + struct rtwn_tx_radiotap_header sc_txtap; +}; + +/* + * MAC initialization values. + */ +static const struct { + uint16_t reg; + uint8_t val; +} rtl8192ce_mac[] = { + { 0x420, 0x80 }, { 0x423, 0x00 }, { 0x430, 0x00 }, { 0x431, 0x00 }, + { 0x432, 0x00 }, { 0x433, 0x01 }, { 0x434, 0x04 }, { 0x435, 0x05 }, + { 0x436, 0x06 }, { 0x437, 0x07 }, { 0x438, 0x00 }, { 0x439, 0x00 }, + { 0x43a, 0x00 }, { 0x43b, 0x01 }, { 0x43c, 0x04 }, { 0x43d, 0x05 }, + { 0x43e, 0x06 }, { 0x43f, 0x07 }, { 0x440, 0x5d }, { 0x441, 0x01 }, + { 0x442, 0x00 }, { 0x444, 0x15 }, { 0x445, 0xf0 }, { 0x446, 0x0f }, + { 0x447, 0x00 }, { 0x458, 0x41 }, { 0x459, 0xa8 }, { 0x45a, 0x72 }, + { 0x45b, 0xb9 }, { 0x460, 0x88 }, { 0x461, 0x88 }, { 0x462, 0x06 }, + { 0x463, 0x03 }, { 0x4c8, 0x04 }, { 0x4c9, 0x08 }, { 0x4cc, 0x02 }, + { 0x4cd, 0x28 }, { 0x4ce, 0x01 }, { 0x500, 0x26 }, { 0x501, 0xa2 }, + { 0x502, 0x2f }, { 0x503, 0x00 }, { 0x504, 0x28 }, { 0x505, 0xa3 }, + { 0x506, 0x5e }, { 0x507, 0x00 }, { 0x508, 0x2b }, { 0x509, 0xa4 }, + { 0x50a, 0x5e }, { 0x50b, 0x00 }, { 0x50c, 0x4f }, { 0x50d, 0xa4 }, + { 0x50e, 0x00 }, { 0x50f, 0x00 }, { 0x512, 0x1c }, { 0x514, 0x0a }, + { 0x515, 0x10 }, { 0x516, 0x0a }, { 0x517, 0x10 }, { 0x51a, 0x16 }, + { 0x524, 0x0f }, { 0x525, 0x4f }, { 0x546, 0x20 }, { 0x547, 0x00 }, + { 0x559, 0x02 }, { 0x55a, 0x02 }, { 0x55d, 0xff }, { 0x605, 0x30 }, + { 0x608, 0x0e }, { 0x609, 0x2a }, { 0x652, 0x20 }, { 0x63c, 0x0a }, + { 0x63d, 0x0e }, { 0x700, 0x21 }, { 0x701, 0x43 }, { 0x702, 0x65 }, + { 0x703, 0x87 }, { 0x708, 0x21 }, { 0x709, 0x43 }, { 0x70a, 0x65 }, + { 0x70b, 0x87 } +}; + +/* + * Baseband initialization values. + */ +struct rtwn_bb_prog { + int count; + const uint16_t *regs; + const uint32_t *vals; + int agccount; + const uint32_t *agcvals; +}; + +/* + * RTL8192CU and RTL8192CE-VAU. + */ +static const uint16_t rtl8192ce_bb_regs[] = { + 0x024, 0x028, 0x800, 0x804, 0x808, 0x80c, 0x810, 0x814, 0x818, + 0x81c, 0x820, 0x824, 0x828, 0x82c, 0x830, 0x834, 0x838, 0x83c, + 0x840, 0x844, 0x848, 0x84c, 0x850, 0x854, 0x858, 0x85c, 0x860, + 0x864, 0x868, 0x86c, 0x870, 0x874, 0x878, 0x87c, 0x880, 0x884, + 0x888, 0x88c, 0x890, 0x894, 0x898, 0x89c, 0x900, 0x904, 0x908, + 0x90c, 0xa00, 0xa04, 0xa08, 0xa0c, 0xa10, 0xa14, 0xa18, 0xa1c, + 0xa20, 0xa24, 0xa28, 0xa2c, 0xa70, 0xa74, 0xc00, 0xc04, 0xc08, + 0xc0c, 0xc10, 0xc14, 0xc18, 0xc1c, 0xc20, 0xc24, 0xc28, 0xc2c, + 0xc30, 0xc34, 0xc38, 0xc3c, 0xc40, 0xc44, 0xc48, 0xc4c, 0xc50, + 0xc54, 0xc58, 0xc5c, 0xc60, 0xc64, 0xc68, 0xc6c, 0xc70, 0xc74, + 0xc78, 0xc7c, 0xc80, 0xc84, 0xc88, 0xc8c, 0xc90, 0xc94, 0xc98, + 0xc9c, 0xca0, 0xca4, 0xca8, 0xcac, 0xcb0, 0xcb4, 0xcb8, 0xcbc, + 0xcc0, 0xcc4, 0xcc8, 0xccc, 0xcd0, 0xcd4, 0xcd8, 0xcdc, 0xce0, + 0xce4, 0xce8, 0xcec, 0xd00, 0xd04, 0xd08, 0xd0c, 0xd10, 0xd14, + 0xd18, 0xd2c, 0xd30, 0xd34, 0xd38, 0xd3c, 0xd40, 0xd44, 0xd48, + 0xd4c, 0xd50, 0xd54, 0xd58, 0xd5c, 0xd60, 0xd64, 0xd68, 0xd6c, + 0xd70, 0xd74, 0xd78, 0xe00, 0xe04, 0xe08, 0xe10, 0xe14, 0xe18, + 0xe1c, 0xe28, 0xe30, 0xe34, 0xe38, 0xe3c, 0xe40, 0xe44, 0xe48, + 0xe4c, 0xe50, 0xe54, 0xe58, 0xe5c, 0xe60, 0xe68, 0xe6c, 0xe70, + 0xe74, 0xe78, 0xe7c, 0xe80, 0xe84, 0xe88, 0xe8c, 0xed0, 0xed4, + 0xed8, 0xedc, 0xee0, 0xeec, 0xf14, 0xf4c, 0xf00 +}; + +static const uint32_t rtl8192ce_bb_vals_2t[] = { + 0x0011800f, 0x00ffdb83, 0x80040002, 0x00000003, 0x0000fc00, + 0x0000000a, 0x10005388, 0x020c3d10, 0x02200385, 0x00000000, + 0x01000100, 0x00390004, 0x01000100, 0x00390004, 0x27272727, + 0x27272727, 0x27272727, 0x27272727, 0x00010000, 0x00010000, + 0x27272727, 0x27272727, 0x00000000, 0x00000000, 0x569a569a, + 0x0c1b25a4, 0x66e60230, 0x061f0130, 0x27272727, 0x2b2b2b27, + 0x07000700, 0x22184000, 0x08080808, 0x00000000, 0xc0083070, + 0x000004d5, 0x00000000, 0xcc0000c0, 0x00000800, 0xfffffffe, + 0x40302010, 0x00706050, 0x00000000, 0x00000023, 0x00000000, + 0x81121313, 0x00d047c8, 0x80ff000c, 0x8c838300, 0x2e68120f, + 0x9500bb78, 0x11144028, 0x00881117, 0x89140f00, 0x1a1b0000, + 0x090e1317, 0x00000204, 0x00d30000, 0x101fbf00, 0x00000007, + 0x48071d40, 0x03a05633, 0x000000e4, 0x6c6c6c6c, 0x08800000, + 0x40000100, 0x08800000, 0x40000100, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x69e9ac44, 0x469652cf, 0x49795994, + 0x0a97971c, 0x1f7c403f, 0x000100b7, 0xec020107, 0x007f037f, + 0x69543420, 0x43bc0094, 0x69543420, 0x433c0094, 0x00000000, + 0x5116848b, 0x47c00bff, 0x00000036, 0x2c7f000d, 0x018610db, + 0x0000001f, 0x00b91612, 0x40000100, 0x20f60000, 0x40000100, + 0x20200000, 0x00121820, 0x00000000, 0x00121820, 0x00007f7f, + 0x00000000, 0x00000080, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x28000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x64b22427, + 0x00766932, 0x00222222, 0x00000000, 0x37644302, 0x2f97d40c, + 0x00080740, 0x00020403, 0x0000907f, 0x20010201, 0xa0633333, + 0x3333bc43, 0x7a8f5b6b, 0xcc979975, 0x00000000, 0x80608000, + 0x00000000, 0x00027293, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x6437140a, 0x00000000, 0x00000000, 0x30032064, + 0x4653de68, 0x04518a3c, 0x00002101, 0x2a201c16, 0x1812362e, + 0x322c2220, 0x000e3c24, 0x2a2a2a2a, 0x2a2a2a2a, 0x03902a2a, + 0x2a2a2a2a, 0x2a2a2a2a, 0x2a2a2a2a, 0x2a2a2a2a, 0x00000000, + 0x1000dc1f, 0x10008c1f, 0x02140102, 0x681604c2, 0x01007c00, + 0x01004800, 0xfb000000, 0x000028d1, 0x1000dc1f, 0x10008c1f, + 0x02140102, 0x28160d05, 0x00000010, 0x001b25a4, 0x63db25a4, + 0x63db25a4, 0x0c1b25a4, 0x0c1b25a4, 0x0c1b25a4, 0x0c1b25a4, + 0x63db25a4, 0x0c1b25a4, 0x63db25a4, 0x63db25a4, 0x63db25a4, + 0x63db25a4, 0x001b25a4, 0x001b25a4, 0x6fdb25a4, 0x00000003, + 0x00000000, 0x00000300 +}; + +static const uint32_t rtl8192ce_bb_vals_1t[] = { + 0x0011800f, 0x00ffdb83, 0x80040000, 0x00000001, 0x0000fc00, + 0x0000000a, 0x10005388, 0x020c3d10, 0x02200385, 0x00000000, + 0x01000100, 0x00390004, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00010000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x569a569a, + 0x001b25a4, 0x66e60230, 0x061f0130, 0x00000000, 0x32323200, + 0x07000700, 0x22004000, 0x00000808, 0x00000000, 0xc0083070, + 0x000004d5, 0x00000000, 0xccc000c0, 0x00000800, 0xfffffffe, + 0x40302010, 0x00706050, 0x00000000, 0x00000023, 0x00000000, + 0x81121111, 0x00d047c8, 0x80ff000c, 0x8c838300, 0x2e68120f, + 0x9500bb78, 0x11144028, 0x00881117, 0x89140f00, 0x1a1b0000, + 0x090e1317, 0x00000204, 0x00d30000, 0x101fbf00, 0x00000007, + 0x48071d40, 0x03a05611, 0x000000e4, 0x6c6c6c6c, 0x08800000, + 0x40000100, 0x08800000, 0x40000100, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x69e9ac44, 0x469652cf, 0x49795994, + 0x0a97971c, 0x1f7c403f, 0x000100b7, 0xec020107, 0x007f037f, + 0x69543420, 0x43bc0094, 0x69543420, 0x433c0094, 0x00000000, + 0x5116848b, 0x47c00bff, 0x00000036, 0x2c7f000d, 0x018610db, + 0x0000001f, 0x00b91612, 0x40000100, 0x20f60000, 0x40000100, + 0x20200000, 0x00121820, 0x00000000, 0x00121820, 0x00007f7f, + 0x00000000, 0x00000080, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x28000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x64b22427, + 0x00766932, 0x00222222, 0x00000000, 0x37644302, 0x2f97d40c, + 0x00080740, 0x00020401, 0x0000907f, 0x20010201, 0xa0633333, + 0x3333bc43, 0x7a8f5b6b, 0xcc979975, 0x00000000, 0x80608000, + 0x00000000, 0x00027293, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x6437140a, 0x00000000, 0x00000000, 0x30032064, + 0x4653de68, 0x04518a3c, 0x00002101, 0x2a201c16, 0x1812362e, + 0x322c2220, 0x000e3c24, 0x2a2a2a2a, 0x2a2a2a2a, 0x03902a2a, + 0x2a2a2a2a, 0x2a2a2a2a, 0x2a2a2a2a, 0x2a2a2a2a, 0x00000000, + 0x1000dc1f, 0x10008c1f, 0x02140102, 0x681604c2, 0x01007c00, + 0x01004800, 0xfb000000, 0x000028d1, 0x1000dc1f, 0x10008c1f, + 0x02140102, 0x28160d05, 0x00000010, 0x001b25a4, 0x631b25a0, + 0x631b25a0, 0x081b25a0, 0x081b25a0, 0x081b25a0, 0x081b25a0, + 0x631b25a0, 0x081b25a0, 0x631b25a0, 0x631b25a0, 0x631b25a0, + 0x631b25a0, 0x001b25a0, 0x001b25a0, 0x6b1b25a0, 0x00000003, + 0x00000000, 0x00000300, +}; + +static const uint32_t rtl8192ce_agc_vals[] = { + 0x7b000001, 0x7b010001, 0x7b020001, 0x7b030001, 0x7b040001, + 0x7b050001, 0x7a060001, 0x79070001, 0x78080001, 0x77090001, + 0x760a0001, 0x750b0001, 0x740c0001, 0x730d0001, 0x720e0001, + 0x710f0001, 0x70100001, 0x6f110001, 0x6e120001, 0x6d130001, + 0x6c140001, 0x6b150001, 0x6a160001, 0x69170001, 0x68180001, + 0x67190001, 0x661a0001, 0x651b0001, 0x641c0001, 0x631d0001, + 0x621e0001, 0x611f0001, 0x60200001, 0x49210001, 0x48220001, + 0x47230001, 0x46240001, 0x45250001, 0x44260001, 0x43270001, + 0x42280001, 0x41290001, 0x402a0001, 0x262b0001, 0x252c0001, + 0x242d0001, 0x232e0001, 0x222f0001, 0x21300001, 0x20310001, + 0x06320001, 0x05330001, 0x04340001, 0x03350001, 0x02360001, + 0x01370001, 0x00380001, 0x00390001, 0x003a0001, 0x003b0001, + 0x003c0001, 0x003d0001, 0x003e0001, 0x003f0001, 0x7b400001, + 0x7b410001, 0x7b420001, 0x7b430001, 0x7b440001, 0x7b450001, + 0x7a460001, 0x79470001, 0x78480001, 0x77490001, 0x764a0001, + 0x754b0001, 0x744c0001, 0x734d0001, 0x724e0001, 0x714f0001, + 0x70500001, 0x6f510001, 0x6e520001, 0x6d530001, 0x6c540001, + 0x6b550001, 0x6a560001, 0x69570001, 0x68580001, 0x67590001, + 0x665a0001, 0x655b0001, 0x645c0001, 0x635d0001, 0x625e0001, + 0x615f0001, 0x60600001, 0x49610001, 0x48620001, 0x47630001, + 0x46640001, 0x45650001, 0x44660001, 0x43670001, 0x42680001, + 0x41690001, 0x406a0001, 0x266b0001, 0x256c0001, 0x246d0001, + 0x236e0001, 0x226f0001, 0x21700001, 0x20710001, 0x06720001, + 0x05730001, 0x04740001, 0x03750001, 0x02760001, 0x01770001, + 0x00780001, 0x00790001, 0x007a0001, 0x007b0001, 0x007c0001, + 0x007d0001, 0x007e0001, 0x007f0001, 0x3800001e, 0x3801001e, + 0x3802001e, 0x3803001e, 0x3804001e, 0x3805001e, 0x3806001e, + 0x3807001e, 0x3808001e, 0x3c09001e, 0x3e0a001e, 0x400b001e, + 0x440c001e, 0x480d001e, 0x4c0e001e, 0x500f001e, 0x5210001e, + 0x5611001e, 0x5a12001e, 0x5e13001e, 0x6014001e, 0x6015001e, + 0x6016001e, 0x6217001e, 0x6218001e, 0x6219001e, 0x621a001e, + 0x621b001e, 0x621c001e, 0x621d001e, 0x621e001e, 0x621f001e +}; + +static const struct rtwn_bb_prog rtl8192ce_bb_prog_2t = { + nitems(rtl8192ce_bb_regs), + rtl8192ce_bb_regs, + rtl8192ce_bb_vals_2t, + nitems(rtl8192ce_agc_vals), + rtl8192ce_agc_vals +}; + +static const struct rtwn_bb_prog rtl8192ce_bb_prog_1t = { + nitems(rtl8192ce_bb_regs), + rtl8192ce_bb_regs, + rtl8192ce_bb_vals_1t, + nitems(rtl8192ce_agc_vals), + rtl8192ce_agc_vals +}; + +/* + * RTL8188CU. + */ +static const uint32_t rtl8192cu_bb_vals[] = { + 0x0011800d, 0x00ffdb83, 0x80040002, 0x00000003, 0x0000fc00, + 0x0000000a, 0x10005388, 0x020c3d10, 0x02200385, 0x00000000, + 0x01000100, 0x00390004, 0x01000100, 0x00390004, 0x27272727, + 0x27272727, 0x27272727, 0x27272727, 0x00010000, 0x00010000, + 0x27272727, 0x27272727, 0x00000000, 0x00000000, 0x569a569a, + 0x0c1b25a4, 0x66e60230, 0x061f0130, 0x27272727, 0x2b2b2b27, + 0x07000700, 0x22184000, 0x08080808, 0x00000000, 0xc0083070, + 0x000004d5, 0x00000000, 0xcc0000c0, 0x00000800, 0xfffffffe, + 0x40302010, 0x00706050, 0x00000000, 0x00000023, 0x00000000, + 0x81121313, 0x00d047c8, 0x80ff000c, 0x8c838300, 0x2e68120f, + 0x9500bb78, 0x11144028, 0x00881117, 0x89140f00, 0x1a1b0000, + 0x090e1317, 0x00000204, 0x00d30000, 0x101fbf00, 0x00000007, + 0x48071d40, 0x03a05633, 0x000000e4, 0x6c6c6c6c, 0x08800000, + 0x40000100, 0x08800000, 0x40000100, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x69e9ac44, 0x469652cf, 0x49795994, + 0x0a97971c, 0x1f7c403f, 0x000100b7, 0xec020107, 0x007f037f, + 0x6954341e, 0x43bc0094, 0x6954341e, 0x433c0094, 0x00000000, + 0x5116848b, 0x47c00bff, 0x00000036, 0x2c7f000d, 0x0186115b, + 0x0000001f, 0x00b99612, 0x40000100, 0x20f60000, 0x40000100, + 0x20200000, 0x00121820, 0x00000000, 0x00121820, 0x00007f7f, + 0x00000000, 0x00000080, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x28000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x64b22427, + 0x00766932, 0x00222222, 0x00000000, 0x37644302, 0x2f97d40c, + 0x00080740, 0x00020403, 0x0000907f, 0x20010201, 0xa0633333, + 0x3333bc43, 0x7a8f5b6b, 0xcc979975, 0x00000000, 0x80608000, + 0x00000000, 0x00027293, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x6437140a, 0x00000000, 0x00000000, 0x30032064, + 0x4653de68, 0x04518a3c, 0x00002101, 0x2a201c16, 0x1812362e, + 0x322c2220, 0x000e3c24, 0x2a2a2a2a, 0x2a2a2a2a, 0x03902a2a, + 0x2a2a2a2a, 0x2a2a2a2a, 0x2a2a2a2a, 0x2a2a2a2a, 0x00000000, + 0x1000dc1f, 0x10008c1f, 0x02140102, 0x681604c2, 0x01007c00, + 0x01004800, 0xfb000000, 0x000028d1, 0x1000dc1f, 0x10008c1f, + 0x02140102, 0x28160d05, 0x00000010, 0x001b25a4, 0x63db25a4, + 0x63db25a4, 0x0c1b25a4, 0x0c1b25a4, 0x0c1b25a4, 0x0c1b25a4, + 0x63db25a4, 0x0c1b25a4, 0x63db25a4, 0x63db25a4, 0x63db25a4, + 0x63db25a4, 0x001b25a4, 0x001b25a4, 0x6fdb25a4, 0x00000003, + 0x00000000, 0x00000300 +}; + +static const struct rtwn_bb_prog rtl8192cu_bb_prog = { + nitems(rtl8192ce_bb_regs), + rtl8192ce_bb_regs, + rtl8192cu_bb_vals, + nitems(rtl8192ce_agc_vals), + rtl8192ce_agc_vals +}; + +/* + * RTL8188CE-VAU. + */ +static const uint32_t rtl8188ce_bb_vals[] = { + 0x0011800d, 0x00ffdb83, 0x80040000, 0x00000001, 0x0000fc00, + 0x0000000a, 0x10005388, 0x020c3d10, 0x02200385, 0x00000000, + 0x01000100, 0x00390004, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00010000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x569a569a, + 0x001b25a4, 0x66e60230, 0x061f0130, 0x00000000, 0x32323200, + 0x07000700, 0x22004000, 0x00000808, 0x00000000, 0xc0083070, + 0x000004d5, 0x00000000, 0xccc000c0, 0x00000800, 0xfffffffe, + 0x40302010, 0x00706050, 0x00000000, 0x00000023, 0x00000000, + 0x81121111, 0x00d047c8, 0x80ff000c, 0x8c838300, 0x2e68120f, + 0x9500bb78, 0x11144028, 0x00881117, 0x89140f00, 0x1a1b0000, + 0x090e1317, 0x00000204, 0x00d30000, 0x101fbf00, 0x00000007, + 0x48071d40, 0x03a05611, 0x000000e4, 0x6c6c6c6c, 0x08800000, + 0x40000100, 0x08800000, 0x40000100, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x69e9ac44, 0x469652cf, 0x49795994, + 0x0a97971c, 0x1f7c403f, 0x000100b7, 0xec020107, 0x007f037f, + 0x6954341e, 0x43bc0094, 0x6954341e, 0x433c0094, 0x00000000, + 0x5116848b, 0x47c00bff, 0x00000036, 0x2c7f000d, 0x018610db, + 0x0000001f, 0x00b91612, 0x40000100, 0x20f60000, 0x40000100, + 0x20200000, 0x00121820, 0x00000000, 0x00121820, 0x00007f7f, + 0x00000000, 0x00000080, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x28000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x64b22427, + 0x00766932, 0x00222222, 0x00000000, 0x37644302, 0x2f97d40c, + 0x00080740, 0x00020401, 0x0000907f, 0x20010201, 0xa0633333, + 0x3333bc43, 0x7a8f5b6b, 0xcc979975, 0x00000000, 0x80608000, + 0x00000000, 0x00027293, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x6437140a, 0x00000000, 0x00000000, 0x30032064, + 0x4653de68, 0x04518a3c, 0x00002101, 0x2a201c16, 0x1812362e, + 0x322c2220, 0x000e3c24, 0x2a2a2a2a, 0x2a2a2a2a, 0x03902a2a, + 0x2a2a2a2a, 0x2a2a2a2a, 0x2a2a2a2a, 0x2a2a2a2a, 0x00000000, + 0x1000dc1f, 0x10008c1f, 0x02140102, 0x681604c2, 0x01007c00, + 0x01004800, 0xfb000000, 0x000028d1, 0x1000dc1f, 0x10008c1f, + 0x02140102, 0x28160d05, 0x00000008, 0x001b25a4, 0x631b25a0, + 0x631b25a0, 0x081b25a0, 0x081b25a0, 0x081b25a0, 0x081b25a0, + 0x631b25a0, 0x081b25a0, 0x631b25a0, 0x631b25a0, 0x631b25a0, + 0x631b25a0, 0x001b25a0, 0x001b25a0, 0x6b1b25a0, 0x00000003, + 0x00000000, 0x00000300 +}; + +static const uint32_t rtl8188ce_agc_vals[] = { + 0x7b000001, 0x7b010001, 0x7b020001, 0x7b030001, 0x7b040001, + 0x7b050001, 0x7a060001, 0x79070001, 0x78080001, 0x77090001, + 0x760a0001, 0x750b0001, 0x740c0001, 0x730d0001, 0x720e0001, + 0x710f0001, 0x70100001, 0x6f110001, 0x6e120001, 0x6d130001, + 0x6c140001, 0x6b150001, 0x6a160001, 0x69170001, 0x68180001, + 0x67190001, 0x661a0001, 0x651b0001, 0x641c0001, 0x631d0001, + 0x621e0001, 0x611f0001, 0x60200001, 0x49210001, 0x48220001, + 0x47230001, 0x46240001, 0x45250001, 0x44260001, 0x43270001, + 0x42280001, 0x41290001, 0x402a0001, 0x262b0001, 0x252c0001, + 0x242d0001, 0x232e0001, 0x222f0001, 0x21300001, 0x20310001, + 0x06320001, 0x05330001, 0x04340001, 0x03350001, 0x02360001, + 0x01370001, 0x00380001, 0x00390001, 0x003a0001, 0x003b0001, + 0x003c0001, 0x003d0001, 0x003e0001, 0x003f0001, 0x7b400001, + 0x7b410001, 0x7b420001, 0x7b430001, 0x7b440001, 0x7b450001, + 0x7a460001, 0x79470001, 0x78480001, 0x77490001, 0x764a0001, + 0x754b0001, 0x744c0001, 0x734d0001, 0x724e0001, 0x714f0001, + 0x70500001, 0x6f510001, 0x6e520001, 0x6d530001, 0x6c540001, + 0x6b550001, 0x6a560001, 0x69570001, 0x68580001, 0x67590001, + 0x665a0001, 0x655b0001, 0x645c0001, 0x635d0001, 0x625e0001, + 0x615f0001, 0x60600001, 0x49610001, 0x48620001, 0x47630001, + 0x46640001, 0x45650001, 0x44660001, 0x43670001, 0x42680001, + 0x41690001, 0x406a0001, 0x266b0001, 0x256c0001, 0x246d0001, + 0x236e0001, 0x226f0001, 0x21700001, 0x20710001, 0x06720001, + 0x05730001, 0x04740001, 0x03750001, 0x02760001, 0x01770001, + 0x00780001, 0x00790001, 0x007a0001, 0x007b0001, 0x007c0001, + 0x007d0001, 0x007e0001, 0x007f0001, 0x3800001e, 0x3801001e, + 0x3802001e, 0x3803001e, 0x3804001e, 0x3805001e, 0x3806001e, + 0x3807001e, 0x3808001e, 0x3c09001e, 0x3e0a001e, 0x400b001e, + 0x440c001e, 0x480d001e, 0x4c0e001e, 0x500f001e, 0x5210001e, + 0x5611001e, 0x5a12001e, 0x5e13001e, 0x6014001e, 0x6015001e, + 0x6016001e, 0x6217001e, 0x6218001e, 0x6219001e, 0x621a001e, + 0x621b001e, 0x621c001e, 0x621d001e, 0x621e001e, 0x621f001e +}; + +static const struct rtwn_bb_prog rtl8188ce_bb_prog = { + nitems(rtl8192ce_bb_regs), + rtl8192ce_bb_regs, + rtl8188ce_bb_vals, + nitems(rtl8188ce_agc_vals), + rtl8188ce_agc_vals +}; + +static const uint32_t rtl8188cu_bb_vals[] = { + 0x0011800d, 0x00ffdb83, 0x80040000, 0x00000001, 0x0000fc00, + 0x0000000a, 0x10005388, 0x020c3d10, 0x02200385, 0x00000000, + 0x01000100, 0x00390004, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00010000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x569a569a, + 0x001b25a4, 0x66e60230, 0x061f0130, 0x00000000, 0x32323200, + 0x07000700, 0x22004000, 0x00000808, 0x00000000, 0xc0083070, + 0x000004d5, 0x00000000, 0xccc000c0, 0x00000800, 0xfffffffe, + 0x40302010, 0x00706050, 0x00000000, 0x00000023, 0x00000000, + 0x81121111, 0x00d047c8, 0x80ff000c, 0x8c838300, 0x2e68120f, + 0x9500bb78, 0x11144028, 0x00881117, 0x89140f00, 0x1a1b0000, + 0x090e1317, 0x00000204, 0x00d30000, 0x101fbf00, 0x00000007, + 0x48071d40, 0x03a05611, 0x000000e4, 0x6c6c6c6c, 0x08800000, + 0x40000100, 0x08800000, 0x40000100, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x69e9ac44, 0x469652cf, 0x49795994, + 0x0a97971c, 0x1f7c403f, 0x000100b7, 0xec020107, 0x007f037f, + 0x6954341e, 0x43bc0094, 0x6954341e, 0x433c0094, 0x00000000, + 0x5116848b, 0x47c00bff, 0x00000036, 0x2c7f000d, 0x018610db, + 0x0000001f, 0x00b91612, 0x40000100, 0x20f60000, 0x40000100, + 0x20200000, 0x00121820, 0x00000000, 0x00121820, 0x00007f7f, + 0x00000000, 0x00000080, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x28000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x64b22427, + 0x00766932, 0x00222222, 0x00000000, 0x37644302, 0x2f97d40c, + 0x00080740, 0x00020401, 0x0000907f, 0x20010201, 0xa0633333, + 0x3333bc43, 0x7a8f5b6b, 0xcc979975, 0x00000000, 0x80608000, + 0x00000000, 0x00027293, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x6437140a, 0x00000000, 0x00000000, 0x30032064, + 0x4653de68, 0x04518a3c, 0x00002101, 0x2a201c16, 0x1812362e, + 0x322c2220, 0x000e3c24, 0x2a2a2a2a, 0x2a2a2a2a, 0x03902a2a, + 0x2a2a2a2a, 0x2a2a2a2a, 0x2a2a2a2a, 0x2a2a2a2a, 0x00000000, + 0x1000dc1f, 0x10008c1f, 0x02140102, 0x681604c2, 0x01007c00, + 0x01004800, 0xfb000000, 0x000028d1, 0x1000dc1f, 0x10008c1f, + 0x02140102, 0x28160d05, 0x00000008, 0x001b25a4, 0x631b25a0, + 0x631b25a0, 0x081b25a0, 0x081b25a0, 0x081b25a0, 0x081b25a0, + 0x631b25a0, 0x081b25a0, 0x631b25a0, 0x631b25a0, 0x631b25a0, + 0x631b25a0, 0x001b25a0, 0x001b25a0, 0x6b1b25a0, 0x00000003, + 0x00000000, 0x00000300 +}; + +static const struct rtwn_bb_prog rtl8188cu_bb_prog = { + nitems(rtl8192ce_bb_regs), + rtl8192ce_bb_regs, + rtl8188cu_bb_vals, + nitems(rtl8188ce_agc_vals), + rtl8188ce_agc_vals +}; + +/* + * RTL8188RU. + */ +static const uint16_t rtl8188ru_bb_regs[] = { + 0x024, 0x028, 0x040, 0x800, 0x804, 0x808, 0x80c, 0x810, 0x814, + 0x818, 0x81c, 0x820, 0x824, 0x828, 0x82c, 0x830, 0x834, 0x838, + 0x83c, 0x840, 0x844, 0x848, 0x84c, 0x850, 0x854, 0x858, 0x85c, + 0x860, 0x864, 0x868, 0x86c, 0x870, 0x874, 0x878, 0x87c, 0x880, + 0x884, 0x888, 0x88c, 0x890, 0x894, 0x898, 0x89c, 0x900, 0x904, + 0x908, 0x90c, 0xa00, 0xa04, 0xa08, 0xa0c, 0xa10, 0xa14, 0xa18, + 0xa1c, 0xa20, 0xa24, 0xa28, 0xa2c, 0xa70, 0xa74, 0xc00, 0xc04, + 0xc08, 0xc0c, 0xc10, 0xc14, 0xc18, 0xc1c, 0xc20, 0xc24, 0xc28, + 0xc2c, 0xc30, 0xc34, 0xc38, 0xc3c, 0xc40, 0xc44, 0xc48, 0xc4c, + 0xc50, 0xc54, 0xc58, 0xc5c, 0xc60, 0xc64, 0xc68, 0xc6c, 0xc70, + 0xc74, 0xc78, 0xc7c, 0xc80, 0xc84, 0xc88, 0xc8c, 0xc90, 0xc94, + 0xc98, 0xc9c, 0xca0, 0xca4, 0xca8, 0xcac, 0xcb0, 0xcb4, 0xcb8, + 0xcbc, 0xcc0, 0xcc4, 0xcc8, 0xccc, 0xcd0, 0xcd4, 0xcd8, 0xcdc, + 0xce0, 0xce4, 0xce8, 0xcec, 0xd00, 0xd04, 0xd08, 0xd0c, 0xd10, + 0xd14, 0xd18, 0xd2c, 0xd30, 0xd34, 0xd38, 0xd3c, 0xd40, 0xd44, + 0xd48, 0xd4c, 0xd50, 0xd54, 0xd58, 0xd5c, 0xd60, 0xd64, 0xd68, + 0xd6c, 0xd70, 0xd74, 0xd78, 0xe00, 0xe04, 0xe08, 0xe10, 0xe14, + 0xe18, 0xe1c, 0xe28, 0xe30, 0xe34, 0xe38, 0xe3c, 0xe40, 0xe44, + 0xe48, 0xe4c, 0xe50, 0xe54, 0xe58, 0xe5c, 0xe60, 0xe68, 0xe6c, + 0xe70, 0xe74, 0xe78, 0xe7c, 0xe80, 0xe84, 0xe88, 0xe8c, 0xed0, + 0xed4, 0xed8, 0xedc, 0xee0, 0xeec, 0xee8, 0xf14, 0xf4c, 0xf00 +}; + +static const uint32_t rtl8188ru_bb_vals[] = { + 0x0011800d, 0x00ffdb83, 0x000c0004, 0x80040000, 0x00000001, + 0x0000fc00, 0x0000000a, 0x10005388, 0x020c3d10, 0x02200385, + 0x00000000, 0x01000100, 0x00390204, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00010000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x569a569a, 0x001b25a4, 0x66e60230, 0x061f0130, 0x00000000, + 0x32323200, 0x03000300, 0x22004000, 0x00000808, 0x00ffc3f1, + 0xc0083070, 0x000004d5, 0x00000000, 0xccc000c0, 0x00000800, + 0xfffffffe, 0x40302010, 0x00706050, 0x00000000, 0x00000023, + 0x00000000, 0x81121111, 0x00d047c8, 0x80ff000c, 0x8c838300, + 0x2e68120f, 0x9500bb78, 0x11144028, 0x00881117, 0x89140f00, + 0x15160000, 0x070b0f12, 0x00000104, 0x00d30000, 0x101fbf00, + 0x00000007, 0x48071d40, 0x03a05611, 0x000000e4, 0x6c6c6c6c, + 0x08800000, 0x40000100, 0x08800000, 0x40000100, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x69e9ac44, 0x469652cf, + 0x49795994, 0x0a97971c, 0x1f7c403f, 0x000100b7, 0xec020107, + 0x007f037f, 0x6954342e, 0x43bc0094, 0x6954342f, 0x433c0094, + 0x00000000, 0x5116848b, 0x47c00bff, 0x00000036, 0x2c56000d, + 0x018610db, 0x0000001f, 0x00b91612, 0x24000090, 0x20f60000, + 0x24000090, 0x20200000, 0x00121820, 0x00000000, 0x00121820, + 0x00007f7f, 0x00000000, 0x00000080, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x28000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x64b22427, 0x00766932, 0x00222222, 0x00000000, 0x37644302, + 0x2f97d40c, 0x00080740, 0x00020401, 0x0000907f, 0x20010201, + 0xa0633333, 0x3333bc43, 0x7a8f5b6b, 0xcc979975, 0x00000000, + 0x80608000, 0x00000000, 0x00027293, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x6437140a, 0x00000000, 0x00000000, + 0x30032064, 0x4653de68, 0x04518a3c, 0x00002101, 0x2a201c16, + 0x1812362e, 0x322c2220, 0x000e3c24, 0x2a2a2a2a, 0x2a2a2a2a, + 0x03902a2a, 0x2a2a2a2a, 0x2a2a2a2a, 0x2a2a2a2a, 0x2a2a2a2a, + 0x00000000, 0x1000dc1f, 0x10008c1f, 0x02140102, 0x681604c2, + 0x01007c00, 0x01004800, 0xfb000000, 0x000028d1, 0x1000dc1f, + 0x10008c1f, 0x02140102, 0x28160d05, 0x00000010, 0x001b25a4, + 0x631b25a0, 0x631b25a0, 0x081b25a0, 0x081b25a0, 0x081b25a0, + 0x081b25a0, 0x631b25a0, 0x081b25a0, 0x631b25a0, 0x631b25a0, + 0x631b25a0, 0x631b25a0, 0x001b25a0, 0x001b25a0, 0x6b1b25a0, + 0x31555448, 0x00000003, 0x00000000, 0x00000300 +}; + +static const uint32_t rtl8188ru_agc_vals[] = { + 0x7b000001, 0x7b010001, 0x7b020001, 0x7b030001, 0x7b040001, + 0x7b050001, 0x7b060001, 0x7b070001, 0x7b080001, 0x7a090001, + 0x790a0001, 0x780b0001, 0x770c0001, 0x760d0001, 0x750e0001, + 0x740f0001, 0x73100001, 0x72110001, 0x71120001, 0x70130001, + 0x6f140001, 0x6e150001, 0x6d160001, 0x6c170001, 0x6b180001, + 0x6a190001, 0x691a0001, 0x681b0001, 0x671c0001, 0x661d0001, + 0x651e0001, 0x641f0001, 0x63200001, 0x62210001, 0x61220001, + 0x60230001, 0x46240001, 0x45250001, 0x44260001, 0x43270001, + 0x42280001, 0x41290001, 0x402a0001, 0x262b0001, 0x252c0001, + 0x242d0001, 0x232e0001, 0x222f0001, 0x21300001, 0x20310001, + 0x06320001, 0x05330001, 0x04340001, 0x03350001, 0x02360001, + 0x01370001, 0x00380001, 0x00390001, 0x003a0001, 0x003b0001, + 0x003c0001, 0x003d0001, 0x003e0001, 0x003f0001, 0x7b400001, + 0x7b410001, 0x7b420001, 0x7b430001, 0x7b440001, 0x7b450001, + 0x7b460001, 0x7b470001, 0x7b480001, 0x7a490001, 0x794a0001, + 0x784b0001, 0x774c0001, 0x764d0001, 0x754e0001, 0x744f0001, + 0x73500001, 0x72510001, 0x71520001, 0x70530001, 0x6f540001, + 0x6e550001, 0x6d560001, 0x6c570001, 0x6b580001, 0x6a590001, + 0x695a0001, 0x685b0001, 0x675c0001, 0x665d0001, 0x655e0001, + 0x645f0001, 0x63600001, 0x62610001, 0x61620001, 0x60630001, + 0x46640001, 0x45650001, 0x44660001, 0x43670001, 0x42680001, + 0x41690001, 0x406a0001, 0x266b0001, 0x256c0001, 0x246d0001, + 0x236e0001, 0x226f0001, 0x21700001, 0x20710001, 0x06720001, + 0x05730001, 0x04740001, 0x03750001, 0x02760001, 0x01770001, + 0x00780001, 0x00790001, 0x007a0001, 0x007b0001, 0x007c0001, + 0x007d0001, 0x007e0001, 0x007f0001, 0x3800001e, 0x3801001e, + 0x3802001e, 0x3803001e, 0x3804001e, 0x3805001e, 0x3806001e, + 0x3807001e, 0x3808001e, 0x3c09001e, 0x3e0a001e, 0x400b001e, + 0x440c001e, 0x480d001e, 0x4c0e001e, 0x500f001e, 0x5210001e, + 0x5611001e, 0x5a12001e, 0x5e13001e, 0x6014001e, 0x6015001e, + 0x6016001e, 0x6217001e, 0x6218001e, 0x6219001e, 0x621a001e, + 0x621b001e, 0x621c001e, 0x621d001e, 0x621e001e, 0x621f001e +}; + +static const struct rtwn_bb_prog rtl8188ru_bb_prog = { + nitems(rtl8188ru_bb_regs), + rtl8188ru_bb_regs, + rtl8188ru_bb_vals, + nitems(rtl8188ru_agc_vals), + rtl8188ru_agc_vals +}; + +/* + * RF initialization values. + */ +struct rtwn_rf_prog { + int count; + const uint8_t *regs; + const uint32_t *vals; +}; + +/* + * RTL8192CU and RTL8192CE-VAU. + */ +static const uint8_t rtl8192ce_rf1_regs[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, + 0x0f, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, + 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2a, 0x2b, + 0x2a, 0x2b, 0x2b, 0x2c, 0x2a, 0x2b, 0x2b, 0x2c, 0x2a, 0x2b, 0x2b, + 0x2c, 0x2a, 0x2b, 0x2b, 0x2c, 0x2a, 0x2b, 0x2b, 0x2c, 0x2a, 0x2b, + 0x2b, 0x2c, 0x2a, 0x2b, 0x2b, 0x2c, 0x2a, 0x2b, 0x2b, 0x2c, 0x2a, + 0x2b, 0x2b, 0x2c, 0x2a, 0x2b, 0x2b, 0x2c, 0x2a, 0x2b, 0x2b, 0x2c, + 0x2a, 0x2b, 0x2b, 0x2c, 0x2a, 0x2b, 0x2b, 0x2c, 0x2a, 0x2b, 0x2b, + 0x2c, 0x2a, 0x10, 0x11, 0x10, 0x11, 0x10, 0x11, 0x10, 0x11, 0x10, + 0x11, 0x10, 0x11, 0x10, 0x11, 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x14, 0x14, + 0x14, 0x14, 0x15, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x16, 0x00, + 0x18, 0xfe, 0xfe, 0x1f, 0xfe, 0xfe, 0x1e, 0x1f, 0x00 +}; + +static const uint32_t rtl8192ce_rf1_vals[] = { + 0x30159, 0x31284, 0x98000, 0x18c63, 0x210e7, 0x2044f, 0x1adb1, + 0x54867, 0x8992e, 0x0e52c, 0x39ce7, 0x00451, 0x00000, 0x10255, + 0x60a00, 0xfc378, 0xa1250, 0x4445f, 0x80001, 0x0b614, 0x6c000, + 0x00000, 0x01558, 0x00060, 0x00483, 0x4f000, 0xec7d9, 0x577c0, + 0x04783, 0x00001, 0x21334, 0x00000, 0x00054, 0x00001, 0x00808, + 0x53333, 0x0000c, 0x00002, 0x00808, 0x5b333, 0x0000d, 0x00003, + 0x00808, 0x63333, 0x0000d, 0x00004, 0x00808, 0x6b333, 0x0000d, + 0x00005, 0x00808, 0x73333, 0x0000d, 0x00006, 0x00709, 0x5b333, + 0x0000d, 0x00007, 0x00709, 0x63333, 0x0000d, 0x00008, 0x0060a, + 0x4b333, 0x0000d, 0x00009, 0x0060a, 0x53333, 0x0000d, 0x0000a, + 0x0060a, 0x5b333, 0x0000d, 0x0000b, 0x0060a, 0x63333, 0x0000d, + 0x0000c, 0x0060a, 0x6b333, 0x0000d, 0x0000d, 0x0060a, 0x73333, + 0x0000d, 0x0000e, 0x0050b, 0x66666, 0x0001a, 0xe0000, 0x4000f, + 0xe31fc, 0x6000f, 0xff9f8, 0x2000f, 0x203f9, 0x3000f, 0xff500, + 0x00000, 0x00000, 0x8000f, 0x3f100, 0x9000f, 0x23100, 0x32000, + 0x71000, 0xb0000, 0xfc000, 0x287af, 0x244b7, 0x204ab, 0x1c49f, + 0x18493, 0x14297, 0x10295, 0x0c298, 0x0819c, 0x040a8, 0x0001c, + 0x1944c, 0x59444, 0x9944c, 0xd9444, 0x0f424, 0x4f424, 0x8f424, + 0xcf424, 0xe0330, 0xa0330, 0x60330, 0x20330, 0x10159, 0x0f401, + 0x00000, 0x00000, 0x80003, 0x00000, 0x00000, 0x44457, 0x80000, + 0x30159 +}; + +static const uint8_t rtl8192ce_rf2_regs[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, + 0x0f, 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14, 0x14, 0x15, 0x15, + 0x15, 0x15, 0x16, 0x16, 0x16, 0x16 +}; + +static const uint32_t rtl8192ce_rf2_vals[] = { + 0x30159, 0x31284, 0x98000, 0x18c63, 0x210e7, 0x2044f, 0x1adb1, + 0x54867, 0x8992e, 0x0e52c, 0x39ce7, 0x00451, 0x32000, 0x71000, + 0xb0000, 0xfc000, 0x287af, 0x244b7, 0x204ab, 0x1c49f, 0x18493, + 0x14297, 0x10295, 0x0c298, 0x0819c, 0x040a8, 0x0001c, 0x1944c, + 0x59444, 0x9944c, 0xd9444, 0x0f424, 0x4f424, 0x8f424, 0xcf424, + 0xe0330, 0xa0330, 0x60330, 0x20330 +}; + +static const struct rtwn_rf_prog rtl8192ce_rf_prog[] = { + { + nitems(rtl8192ce_rf1_regs), + rtl8192ce_rf1_regs, + rtl8192ce_rf1_vals + }, + { + nitems(rtl8192ce_rf2_regs), + rtl8192ce_rf2_regs, + rtl8192ce_rf2_vals + } +}; + +/* + * RTL8188CE-VAU. + */ +static const uint32_t rtl8188ce_rf_vals[] = { + 0x30159, 0x31284, 0x98000, 0x18c63, 0x210e7, 0x2044f, 0x1adb1, + 0x54867, 0x8992e, 0x0e52c, 0x39ce7, 0x00451, 0x00000, 0x10255, + 0x60a00, 0xfc378, 0xa1250, 0x4445f, 0x80001, 0x0b614, 0x6c000, + 0x00000, 0x01558, 0x00060, 0x00483, 0x4f200, 0xec7d9, 0x577c0, + 0x04783, 0x00001, 0x21334, 0x00000, 0x00054, 0x00001, 0x00808, + 0x53333, 0x0000c, 0x00002, 0x00808, 0x5b333, 0x0000d, 0x00003, + 0x00808, 0x63333, 0x0000d, 0x00004, 0x00808, 0x6b333, 0x0000d, + 0x00005, 0x00808, 0x73333, 0x0000d, 0x00006, 0x00709, 0x5b333, + 0x0000d, 0x00007, 0x00709, 0x63333, 0x0000d, 0x00008, 0x0060a, + 0x4b333, 0x0000d, 0x00009, 0x0060a, 0x53333, 0x0000d, 0x0000a, + 0x0060a, 0x5b333, 0x0000d, 0x0000b, 0x0060a, 0x63333, 0x0000d, + 0x0000c, 0x0060a, 0x6b333, 0x0000d, 0x0000d, 0x0060a, 0x73333, + 0x0000d, 0x0000e, 0x0050b, 0x66666, 0x0001a, 0xe0000, 0x4000f, + 0xe31fc, 0x6000f, 0xff9f8, 0x2000f, 0x203f9, 0x3000f, 0xff500, + 0x00000, 0x00000, 0x8000f, 0x3f100, 0x9000f, 0x23100, 0x32000, + 0x71000, 0xb0000, 0xfc000, 0x287b3, 0x244b7, 0x204ab, 0x1c49f, + 0x18493, 0x1429b, 0x10299, 0x0c29c, 0x081a0, 0x040ac, 0x00020, + 0x1944c, 0x59444, 0x9944c, 0xd9444, 0x0f424, 0x4f424, 0x8f424, + 0xcf424, 0xe0330, 0xa0330, 0x60330, 0x20330, 0x10159, 0x0f401, + 0x00000, 0x00000, 0x80003, 0x00000, 0x00000, 0x44457, 0x80000, + 0x30159 +}; + +static const struct rtwn_rf_prog rtl8188ce_rf_prog[] = { + { + nitems(rtl8192ce_rf1_regs), + rtl8192ce_rf1_regs, + rtl8188ce_rf_vals + } +}; + + +/* + * RTL8188CU. + */ +static const uint32_t rtl8188cu_rf_vals[] = { + 0x30159, 0x31284, 0x98000, 0x18c63, 0x210e7, 0x2044f, 0x1adb1, + 0x54867, 0x8992e, 0x0e52c, 0x39ce7, 0x00451, 0x00000, 0x10255, + 0x60a00, 0xfc378, 0xa1250, 0x4445f, 0x80001, 0x0b614, 0x6c000, + 0x00000, 0x01558, 0x00060, 0x00483, 0x4f000, 0xec7d9, 0x577c0, + 0x04783, 0x00001, 0x21334, 0x00000, 0x00054, 0x00001, 0x00808, + 0x53333, 0x0000c, 0x00002, 0x00808, 0x5b333, 0x0000d, 0x00003, + 0x00808, 0x63333, 0x0000d, 0x00004, 0x00808, 0x6b333, 0x0000d, + 0x00005, 0x00808, 0x73333, 0x0000d, 0x00006, 0x00709, 0x5b333, + 0x0000d, 0x00007, 0x00709, 0x63333, 0x0000d, 0x00008, 0x0060a, + 0x4b333, 0x0000d, 0x00009, 0x0060a, 0x53333, 0x0000d, 0x0000a, + 0x0060a, 0x5b333, 0x0000d, 0x0000b, 0x0060a, 0x63333, 0x0000d, + 0x0000c, 0x0060a, 0x6b333, 0x0000d, 0x0000d, 0x0060a, 0x73333, + 0x0000d, 0x0000e, 0x0050b, 0x66666, 0x0001a, 0xe0000, 0x4000f, + 0xe31fc, 0x6000f, 0xff9f8, 0x2000f, 0x203f9, 0x3000f, 0xff500, + 0x00000, 0x00000, 0x8000f, 0x3f100, 0x9000f, 0x23100, 0x32000, + 0x71000, 0xb0000, 0xfc000, 0x287b3, 0x244b7, 0x204ab, 0x1c49f, + 0x18493, 0x1429b, 0x10299, 0x0c29c, 0x081a0, 0x040ac, 0x00020, + 0x1944c, 0x59444, 0x9944c, 0xd9444, 0x0f405, 0x4f405, 0x8f405, + 0xcf405, 0xe0330, 0xa0330, 0x60330, 0x20330, 0x10159, 0x0f401, + 0x00000, 0x00000, 0x80003, 0x00000, 0x00000, 0x44457, 0x80000, + 0x30159 +}; + +static const struct rtwn_rf_prog rtl8188cu_rf_prog[] = { + { + nitems(rtl8192ce_rf1_regs), + rtl8192ce_rf1_regs, + rtl8188cu_rf_vals + } +}; + +/* + * RTL8188RU. + */ +static const uint32_t rtl8188ru_rf_vals[] = { + 0x30159, 0x31284, 0x98000, 0x18c63, 0x210e7, 0x2044f, 0x1adb0, + 0x54867, 0x8992e, 0x0e529, 0x39ce7, 0x00451, 0x00000, 0x00255, + 0x60a00, 0xfc378, 0xa1250, 0x4445f, 0x80001, 0x0b614, 0x6c000, + 0x0083c, 0x01558, 0x00060, 0x00483, 0x4f000, 0xec7d9, 0x977c0, + 0x04783, 0x00001, 0x21334, 0x00000, 0x00054, 0x00001, 0x00808, + 0x53333, 0x0000c, 0x00002, 0x00808, 0x5b333, 0x0000d, 0x00003, + 0x00808, 0x63333, 0x0000d, 0x00004, 0x00808, 0x6b333, 0x0000d, + 0x00005, 0x00808, 0x73333, 0x0000d, 0x00006, 0x00709, 0x5b333, + 0x0000d, 0x00007, 0x00709, 0x63333, 0x0000d, 0x00008, 0x0060a, + 0x4b333, 0x0000d, 0x00009, 0x0060a, 0x53333, 0x0000d, 0x0000a, + 0x0060a, 0x5b333, 0x0000d, 0x0000b, 0x0060a, 0x63333, 0x0000d, + 0x0000c, 0x0060a, 0x6b333, 0x0000d, 0x0000d, 0x0060a, 0x73333, + 0x0000d, 0x0000e, 0x0050b, 0x66666, 0x0001a, 0xe0000, 0x4000f, + 0xe31fc, 0x6000f, 0xff9f8, 0x2000f, 0x203f9, 0x3000f, 0xff500, + 0x00000, 0x00000, 0x8000f, 0x3f100, 0x9000f, 0x23100, 0xd8000, + 0x90000, 0x51000, 0x12000, 0x28fb4, 0x24fa8, 0x207a4, 0x1c798, + 0x183a4, 0x14398, 0x101a4, 0x0c198, 0x080a4, 0x04098, 0x00014, + 0x1944c, 0x59444, 0x9944c, 0xd9444, 0x0f405, 0x4f405, 0x8f405, + 0xcf405, 0xe0330, 0xa0330, 0x60330, 0x20330, 0x10159, 0x0f401, + 0x00000, 0x00000, 0x80003, 0x00000, 0x00000, 0x44457, 0x80000, + 0x30159 +}; + +static const struct rtwn_rf_prog rtl8188ru_rf_prog[] = { + { + nitems(rtl8192ce_rf1_regs), + rtl8192ce_rf1_regs, + rtl8188ru_rf_vals + } +}; + +struct rtwn_txpwr { + uint8_t pwr[3][28]; +}; + +/* + * Per RF chain/group/rate Tx gain values. + */ +static const struct rtwn_txpwr rtl8192cu_txagc[] = { + { { /* Chain 0. */ + { /* Group 0. */ + 0x00, 0x00, 0x00, 0x00, /* CCK1~11. */ + 0x0c, 0x0c, 0x0c, 0x0a, 0x08, 0x06, 0x04, 0x02, /* OFDM6~54. */ + 0x0e, 0x0d, 0x0c, 0x0a, 0x08, 0x06, 0x04, 0x02, /* MCS0~7. */ + 0x0e, 0x0d, 0x0c, 0x0a, 0x08, 0x06, 0x04, 0x02 /* MCS8~15. */ + }, + { /* Group 1. */ + 0x00, 0x00, 0x00, 0x00, /* CCK1~11. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* OFDM6~54. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* MCS0~7. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* MCS8~15. */ + }, + { /* Group 2. */ + 0x00, 0x00, 0x00, 0x00, /* CCK1~11. */ + 0x04, 0x04, 0x04, 0x04, 0x04, 0x02, 0x02, 0x00, /* OFDM6~54. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* MCS0~7. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* MCS8~15. */ + } + } }, + { { /* Chain 1. */ + { /* Group 0. */ + 0x00, 0x00, 0x00, 0x00, /* CCK1~11. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* OFDM6~54. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* MCS0~7. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* MCS8~15. */ + }, + { /* Group 1. */ + 0x00, 0x00, 0x00, 0x00, /* CCK1~11. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* OFDM6~54. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* MCS0~7. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* MCS8~15. */ + }, + { /* Group 2. */ + 0x00, 0x00, 0x00, 0x00, /* CCK1~11. */ + 0x04, 0x04, 0x04, 0x04, 0x04, 0x02, 0x02, 0x00, /* OFDM6~54. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* MCS0~7. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* MCS8~15. */ + } + } } +}; + +static const struct rtwn_txpwr rtl8188ru_txagc[] = { + { { /* Chain 0. */ + { /* Group 0. */ + 0x00, 0x00, 0x00, 0x00, /* CCK1~11. */ + 0x08, 0x08, 0x08, 0x06, 0x06, 0x04, 0x04, 0x00, /* OFDM6~54. */ + 0x08, 0x06, 0x06, 0x04, 0x04, 0x02, 0x02, 0x00, /* MCS0~7. */ + 0x08, 0x06, 0x06, 0x04, 0x04, 0x02, 0x02, 0x00 /* MCS8~15. */ + }, + { /* Group 1. */ + 0x00, 0x00, 0x00, 0x00, /* CCK1~11. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* OFDM6~54. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* MCS0~7. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* MCS8~15. */ + }, + { /* Group 2. */ + 0x00, 0x00, 0x00, 0x00, /* CCK1~11. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* OFDM6~54. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* MCS0~7. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* MCS8~15. */ + } + } } +}; + +#define RTWN_LOCK_INIT(_sc) \ + mtx_init(&(_sc)->sc_mtx, device_get_nameunit((_sc)->sc_dev), \ + MTX_NETWORK_LOCK, MTX_DEF) +#define RTWN_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) +#define RTWN_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_mtx, MA_OWNED) +#define RTWN_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) +#define RTWN_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_mtx) + diff --git a/sys/dev/sec/sec.c b/sys/dev/sec/sec.c index 3b99a3e..b83e7eb 100644 --- a/sys/dev/sec/sec.c +++ b/sys/dev/sec/sec.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include <sys/random.h> #include <sys/rman.h> +#include <machine/_inttypes.h> #include <machine/bus.h> #include <machine/resource.h> @@ -235,7 +236,7 @@ sec_probe(device_t dev) sc->sc_version = 3; break; default: - device_printf(dev, "unknown SEC ID 0x%016llx!\n", id); + device_printf(dev, "unknown SEC ID 0x%016"PRIx64"!\n", id); return (ENXIO); } diff --git a/sys/dev/sfxge/common/ef10_impl.h b/sys/dev/sfxge/common/ef10_impl.h new file mode 100644 index 0000000..9b9f0aa --- /dev/null +++ b/sys/dev/sfxge/common/ef10_impl.h @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 2015 Solarflare Communications Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are + * those of the authors and should not be interpreted as representing official + * policies, either expressed or implied, of the FreeBSD Project. + * + * $FreeBSD$ + */ + +#ifndef _SYS_EF10_IMPL_H +#define _SYS_EF10_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if (EFSYS_OPT_HUNTINGTON && EFSYS_OPT_MEDFORD) +#define EF10_MAX_PIOBUF_NBUFS MAX(HUNT_PIOBUF_NBUFS, MEDFORD_PIOBUF_NBUFS) +#elif EFSYS_OPT_HUNTINGTON +#define EF10_MAX_PIOBUF_NBUFS HUNT_PIOBUF_NBUFS +#elif EFSYS_OPT_MEDFORD +#define EF10_MAX_PIOBUF_NBUFS MEDFORD_PIOBUF_NBUFS +#endif + + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_EF10_IMPL_H */ diff --git a/sys/dev/sfxge/common/ef10_tlv_layout.h b/sys/dev/sfxge/common/ef10_tlv_layout.h index e2c7082..4063165 100644 --- a/sys/dev/sfxge/common/ef10_tlv_layout.h +++ b/sys/dev/sfxge/common/ef10_tlv_layout.h @@ -764,4 +764,20 @@ struct tlv_rx_event_merging_config { #define TLV_RX_EVENT_MERGING_MAX_EVENTS_DEFAULT 7 #define TLV_RX_EVENT_MERGING_TIMEOUT_NS_DEFAULT 8740 +#define TLV_TAG_PCIE_LINK_SETTINGS (0x101f0000) +struct tlv_pcie_link_settings { + uint32_t tag; + uint32_t length; + uint16_t gen; /* Target PCIe generation: 1, 2, 3 */ + uint16_t width; /* Number of lanes */ +}; + +#define TLV_TAG_LICENSE (0x20800000) + +typedef struct tlv_license { + uint32_t tag; + uint32_t length; + uint8_t data[]; +} tlv_license_t; + #endif /* CI_MGMT_TLV_LAYOUT_H */ diff --git a/sys/dev/sfxge/common/efsys.h b/sys/dev/sfxge/common/efsys.h index 10dc04d..4d72e28 100644 --- a/sys/dev/sfxge/common/efsys.h +++ b/sys/dev/sfxge/common/efsys.h @@ -238,6 +238,7 @@ sfxge_map_mbuf_fast(bus_dma_tag_t tag, bus_dmamap_t map, #define EFSYS_OPT_FALCON_NIC_CFG_OVERRIDE 0 #define EFSYS_OPT_SIENA 1 #define EFSYS_OPT_HUNTINGTON 1 +#define EFSYS_OPT_MEDFORD 0 #ifdef DEBUG #define EFSYS_OPT_CHECK_REG 1 #else @@ -286,9 +287,7 @@ sfxge_map_mbuf_fast(bus_dma_tag_t tag, bus_dmamap_t map, #define EFSYS_OPT_RX_SCALE 1 #define EFSYS_OPT_QSTATS 1 #define EFSYS_OPT_FILTER 1 -#define EFSYS_OPT_MCAST_FILTER_LIST 1 #define EFSYS_OPT_RX_SCATTER 0 -#define EFSYS_OPT_RX_HDR_SPLIT 0 #define EFSYS_OPT_EV_PREFETCH 0 diff --git a/sys/dev/sfxge/common/efx.h b/sys/dev/sfxge/common/efx.h index a84454d..b9d2061 100644 --- a/sys/dev/sfxge/common/efx.h +++ b/sys/dev/sfxge/common/efx.h @@ -61,6 +61,7 @@ typedef enum efx_family_e { EFX_FAMILY_FALCON, EFX_FAMILY_SIENA, EFX_FAMILY_HUNTINGTON, + EFX_FAMILY_MEDFORD, EFX_FAMILY_NTYPES } efx_family_t; @@ -90,6 +91,9 @@ efx_infer_family( #define EFX_PCI_DEVID_FARMINGDALE_VF 0x1903 /* SFC9120 VF */ #define EFX_PCI_DEVID_GREENPORT_VF 0x1923 /* SFC9140 VF */ +#define EFX_PCI_DEVID_MEDFORD_PF_UNINIT 0x0913 +#define EFX_PCI_DEVID_MEDFORD 0x0A03 /* SFC9240 PF */ +#define EFX_PCI_DEVID_MEDFORD_VF 0x1A03 /* SFC9240 VF */ #define EFX_MEM_BAR 2 @@ -187,8 +191,8 @@ efx_nic_destroy( #if EFSYS_OPT_MCDI -#if EFSYS_OPT_HUNTINGTON -/* Huntington requires MCDIv2 commands */ +#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD +/* Huntington and Medford require MCDIv2 commands */ #define WITH_MCDI_V2 1 #endif @@ -501,38 +505,6 @@ efx_mac_fcntl_get( __out unsigned int *fcntl_wantedp, __out unsigned int *fcntl_linkp); -#define EFX_MAC_HASH_BITS (1 << 8) - -extern __checkReturn efx_rc_t -efx_pktfilter_init( - __in efx_nic_t *enp); - -extern void -efx_pktfilter_fini( - __in efx_nic_t *enp); - -extern __checkReturn efx_rc_t -efx_pktfilter_set( - __in efx_nic_t *enp, - __in boolean_t unicst, - __in boolean_t brdcst); - -extern __checkReturn efx_rc_t -efx_mac_hash_set( - __in efx_nic_t *enp, - __in_ecount(EFX_MAC_HASH_BITS) unsigned int const *bucket); - -#if EFSYS_OPT_MCAST_FILTER_LIST -extern __checkReturn efx_rc_t -efx_pktfilter_mcast_list_set( - __in efx_nic_t *enp, - __in uint8_t const *addrs, - __in int count); -#endif /* EFSYS_OPT_MCAST_FILTER_LIST */ - -extern __checkReturn efx_rc_t -efx_pktfilter_mcast_all( - __in efx_nic_t *enp); #if EFSYS_OPT_MAC_STATS @@ -590,6 +562,7 @@ typedef enum efx_mon_type_e { EFX_MON_MAX6647, EFX_MON_SFC90X0, EFX_MON_SFC91X0, + EFX_MON_SFC92X0, EFX_MON_NTYPES } efx_mon_type_t; @@ -610,7 +583,7 @@ efx_mon_init( #define EFX_MON_STATS_PAGE_SIZE 0x100 #define EFX_MON_MASK_ELEMENT_SIZE 32 -/* START MKCONFIG GENERATED MonitorHeaderStatsBlock c79c86b62a144846 */ +/* START MKCONFIG GENERATED MonitorHeaderStatsBlock c09b13f732431f23 */ typedef enum efx_mon_stat_e { EFX_MON_STAT_2_5V, EFX_MON_STAT_VCCP1, @@ -681,6 +654,12 @@ typedef enum efx_mon_stat_e { EFX_MON_STAT_CONTROLLER_SLAVE_INTERNAL_TEMP, EFX_MON_STAT_CONTROLLER_SLAVE_VPTAT_EXT_ADC, EFX_MON_STAT_CONTROLLER_SLAVE_INTERNAL_TEMP_EXT_ADC, + EFX_MON_STAT_SODIMM_VOUT, + EFX_MON_STAT_SODIMM_0_TEMP, + EFX_MON_STAT_SODIMM_1_TEMP, + EFX_MON_STAT_PHY0_VCC, + EFX_MON_STAT_PHY1_VCC, + EFX_MON_STAT_CONTROLLER_TDIODE_TEMP, EFX_MON_NSTATS } efx_mon_stat_t; @@ -1117,6 +1096,7 @@ typedef struct efx_nic_cfg_s { uint32_t enc_buftbl_limit; uint32_t enc_piobuf_limit; uint32_t enc_piobuf_size; + uint32_t enc_piobuf_min_alloc_size; uint32_t enc_evq_timer_quantum_ns; uint32_t enc_evq_timer_max_us; uint32_t enc_clk_mult; @@ -1144,20 +1124,20 @@ typedef struct efx_nic_cfg_s { uint32_t enc_mcdi_phy_stat_mask; #endif /* EFSYS_OPT_PHY_STATS */ #endif /* EFSYS_OPT_SIENA */ -#if (EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON) +#if (EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) #if EFSYS_OPT_MON_STATS uint32_t *enc_mcdi_sensor_maskp; uint32_t enc_mcdi_sensor_mask_size; #endif /* EFSYS_OPT_MON_STATS */ -#endif /* (EFSYS_OPT_SIENA | EFSYS_OPT_HUNTINGTON) */ +#endif /* (EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) */ #if EFSYS_OPT_BIST uint32_t enc_bist_mask; #endif /* EFSYS_OPT_BIST */ -#if EFSYS_OPT_HUNTINGTON +#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD uint32_t enc_pf; uint32_t enc_vf; uint32_t enc_privilege_mask; -#endif /* EFSYS_OPT_HUNTINGTON */ +#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ boolean_t enc_bug26807_workaround; boolean_t enc_bug35388_workaround; boolean_t enc_bug41750_workaround; @@ -1837,15 +1817,6 @@ extern void efx_rx_fini( __in efx_nic_t *enp); -#if EFSYS_OPT_RX_HDR_SPLIT - __checkReturn efx_rc_t -efx_rx_hdr_split_enable( - __in efx_nic_t *enp, - __in unsigned int hdr_buf_size, - __in unsigned int pld_buf_size); - -#endif /* EFSYS_OPT_RX_HDR_SPLIT */ - #if EFSYS_OPT_RX_SCATTER __checkReturn efx_rc_t efx_rx_scatter_enable( @@ -1912,7 +1883,7 @@ efx_rx_scale_key_set( __in_ecount(n) uint8_t *key, __in size_t n); -extern uint32_t +extern __checkReturn uint32_t efx_psuedo_hdr_hash_get( __in efx_nic_t *enp, __in efx_rx_hash_alg_t func, @@ -1936,8 +1907,6 @@ efx_psuedo_hdr_pkt_length_get( typedef enum efx_rxq_type_e { EFX_RXQ_TYPE_DEFAULT, - EFX_RXQ_TYPE_SPLIT_HEADER, - EFX_RXQ_TYPE_SPLIT_PAYLOAD, EFX_RXQ_TYPE_SCATTER, EFX_RXQ_NTYPES } efx_rxq_type_t; diff --git a/sys/dev/sfxge/common/efx_bootcfg.c b/sys/dev/sfxge/common/efx_bootcfg.c index 97e829d..16ee337 100644 --- a/sys/dev/sfxge/common/efx_bootcfg.c +++ b/sys/dev/sfxge/common/efx_bootcfg.c @@ -31,9 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" #include "efx_impl.h" #if EFSYS_OPT_BOOTCFG diff --git a/sys/dev/sfxge/common/efx_check.h b/sys/dev/sfxge/common/efx_check.h index 684cbbf..199fab0 100644 --- a/sys/dev/sfxge/common/efx_check.h +++ b/sys/dev/sfxge/common/efx_check.h @@ -52,32 +52,32 @@ /* Verify chip implements accessed registers */ #if EFSYS_OPT_CHECK_REG -# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON) -# error "CHECK_REG requires FALCON or SIENA or HUNTINGTON" +# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || \ + EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) +# error "CHECK_REG requires FALCON or SIENA or HUNTINGTON or MEDFORD" # endif #endif /* EFSYS_OPT_CHECK_REG */ /* Decode fatal errors */ #if EFSYS_OPT_DECODE_INTR_FATAL # if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA) -# if EFSYS_OPT_HUNTINGTON -# error "INTR_FATAL not supported on HUNTINGTON" -# endif # error "INTR_FATAL requires FALCON or SIENA" # endif #endif /* EFSYS_OPT_DECODE_INTR_FATAL */ /* Support diagnostic hardware tests */ #if EFSYS_OPT_DIAG -# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON) -# error "DIAG requires FALCON or SIENA or HUNTINGTON" +# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || \ + EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) +# error "DIAG requires FALCON or SIENA or HUNTINGTON or MEDFORD" # endif #endif /* EFSYS_OPT_DIAG */ /* Support optimized EVQ data access */ #if EFSYS_OPT_EV_PREFETCH -# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON) -# error "EV_PREFETCH requires FALCON or SIENA or HUNTINGTON" +# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || \ + EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) +# error "EV_PREFETCH requires FALCON or SIENA or HUNTINGTON or MEDFORD" # endif #endif /* EFSYS_OPT_EV_PREFETCH */ @@ -90,21 +90,23 @@ /* Support hardware packet filters */ #if EFSYS_OPT_FILTER -# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON) -# error "FILTER requires FALCON or SIENA or HUNTINGTON" +# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || \ + EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) +# error "FILTER requires FALCON or SIENA or HUNTINGTON or MEDFORD" # endif #endif /* EFSYS_OPT_FILTER */ -#if EFSYS_OPT_HUNTINGTON +#if (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) # if !EFSYS_OPT_FILTER -# error "HUNTINGTON requires FILTER" +# error "HUNTINGTON or MEDFORD requires FILTER" # endif #endif /* EFSYS_OPT_HUNTINGTON */ /* Support hardware loopback modes */ #if EFSYS_OPT_LOOPBACK -# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON) -# error "LOOPBACK requires FALCON or SIENA or HUNTINGTON" +# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || \ + EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) +# error "LOOPBACK requires FALCON or SIENA or HUNTINGTON or MEDFORD" # endif #endif /* EFSYS_OPT_LOOPBACK */ @@ -124,26 +126,23 @@ /* Support MAC statistics */ #if EFSYS_OPT_MAC_STATS -# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON) -# error "MAC_STATS requires FALCON or SIENA or HUNTINGTON" +# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || \ + EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) +# error "MAC_STATS requires FALCON or SIENA or HUNTINGTON or MEDFORD" # endif #endif /* EFSYS_OPT_MAC_STATS */ /* Support management controller messages */ #if EFSYS_OPT_MCDI -# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON) -# if EFSYS_OPT_FALCON -# error "MCDI not supported on FALCON" -# endif -# error "MCDI requires SIENA or HUNTINGTON" +# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) +# error "MCDI requires SIENA or HUNTINGTON or MEDFORD" # endif #endif /* EFSYS_OPT_MCDI */ -#if EFSYS_OPT_SIENA && !EFSYS_OPT_MCDI -# error "SIENA requires MCDI" -#endif -#if EFSYS_OPT_HUNTINGTON && !EFSYS_OPT_MCDI -# error "HUNTINGTON requires MCDI" +#if (EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) +# if !EFSYS_OPT_MCDI +# error "SIENA or HUNTINGTON or MEDFORD requires MCDI" +# endif #endif /* Support MCDI logging */ @@ -181,27 +180,28 @@ # endif #endif /* EFSYS_OPT_MON_NULL */ -/* Support Siena monitor */ +/* Obsolete option */ #ifdef EFSYS_OPT_MON_SIENA -# error "MON_SIENA is obsolete use MON_MCDI" +# error "MON_SIENA is obsolete (replaced by MON_MCDI)." #endif /* EFSYS_OPT_MON_SIENA*/ -/* Support Huntington monitor */ +/* Obsolete option */ #ifdef EFSYS_OPT_MON_HUNTINGTON -# error "MON_HUNTINGTON is obsolete use MON_MCDI" +# error "MON_HUNTINGTON is obsolete (replaced by MON_MCDI)." #endif /* EFSYS_OPT_MON_HUNTINGTON*/ /* Support monitor statistics (voltage/temperature) */ #if EFSYS_OPT_MON_STATS -# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON) -# error "MON_STATS requires FALCON or SIENA or HUNTINGTON" +# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || \ + EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) +# error "MON_STATS requires FALCON or SIENA or HUNTINGTON or MEDFORD" # endif #endif /* EFSYS_OPT_MON_STATS */ /* Support Monitor via mcdi */ #if EFSYS_OPT_MON_MCDI -# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON) -# error "MON_MCDI requires SIENA or HUNTINGTON" +# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) +# error "MON_MCDI requires SIENA or HUNTINGTON or MEDFORD" # endif #endif /* EFSYS_OPT_MON_MCDI*/ @@ -216,8 +216,9 @@ /* Support non volatile configuration */ #if EFSYS_OPT_NVRAM -# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON) -# error "NVRAM requires FALCON or SIENA or HUNTINGTON" +# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || \ + EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) +# error "NVRAM requires FALCON or SIENA or HUNTINGTON or MEDFORD" # endif #endif /* EFSYS_OPT_NVRAM */ @@ -258,9 +259,9 @@ # endif #endif /* EFSYS_OPT_PCIE_TUNE */ -/* Support PHY BIST diagnostics */ +/* Obsolete option */ #if EFSYS_OPT_PHY_BIST -# error "PHY_BIST is obsolete. It has been replaced by the BIST option." +# error "PHY_BIST is obsolete (replaced by BIST)." #endif /* EFSYS_OPT_PHY_BIST */ /* Support PHY flags */ @@ -340,41 +341,43 @@ /* Support EVQ/RXQ/TXQ statistics */ #if EFSYS_OPT_QSTATS -# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON) -# error "QSTATS requires FALCON or SIENA or HUNTINGTON" +# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || \ + EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) +# error "QSTATS requires FALCON or SIENA or HUNTINGTON or MEDFORD" # endif #endif /* EFSYS_OPT_QSTATS */ -/* Support receive header split */ -#if EFSYS_OPT_RX_HDR_SPLIT -# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON) -# error "RX_HDR_SPLIT requires FALCON or SIENA or HUNTINGTON" -# endif +/* Obsolete option */ +#ifdef EFSYS_OPT_RX_HDR_SPLIT +# error "RX_HDR_SPLIT is obsolete and is not supported" #endif /* EFSYS_OPT_RX_HDR_SPLIT */ /* Support receive scaling (RSS) */ #if EFSYS_OPT_RX_SCALE -# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON) -# error "RX_SCALE requires FALCON or SIENA or HUNTINGTON" +# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || \ + EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) +# error "RX_SCALE requires FALCON or SIENA or HUNTINGTON or MEDFORD" # endif #endif /* EFSYS_OPT_RX_SCALE */ /* Support receive scatter DMA */ #if EFSYS_OPT_RX_SCATTER -# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON) -# error "RX_SCATTER requires FALCON or SIENA or HUNTINGTON" +# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || \ + EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) +# error "RX_SCATTER requires FALCON or SIENA or HUNTINGTON or MEDFORD" # endif #endif /* EFSYS_OPT_RX_SCATTER */ /* Obsolete option */ #ifdef EFSYS_OPT_STAT_NAME -# error "EFSYS_OPT_STAT_NAME is obsolete (replaced by EFSYS_OPT_NAMES)." +# error "STAT_NAME is obsolete (replaced by NAMES)." #endif /* Support PCI Vital Product Data (VPD) */ #if EFSYS_OPT_VPD -# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON) -# error "VPD requires FALCON or SIENA or HUNTINGTON" +# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || \ + EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) +# error "VPD requires FALCON or SIENA or HUNTINGTON or MEDFORD" # endif #endif /* EFSYS_OPT_VPD */ @@ -385,17 +388,16 @@ # endif #endif /* EFSYS_OPT_WOL */ -/* Support calculating multicast pktfilter in common code */ -#if EFSYS_OPT_MCAST_FILTER_LIST -# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON) -# error "MCAST_FILTER_LIST requires FALCON or SIENA or HUNTINGTON" -# endif +/* Obsolete option */ +#ifdef EFSYS_OPT_MCAST_FILTER_LIST +# error "MCAST_FILTER_LIST is obsolete and is not supported" #endif /* EFSYS_OPT_MCAST_FILTER_LIST */ /* Support BIST */ #if EFSYS_OPT_BIST -# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON) -# error "BIST requires FALCON or SIENA or HUNTINGTON" +# if !(EFSYS_OPT_FALCON || EFSYS_OPT_SIENA || \ + EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) +# error "BIST requires FALCON or SIENA or HUNTINGTON or MEDFORD" # endif #endif /* EFSYS_OPT_BIST */ diff --git a/sys/dev/sfxge/common/efx_crc32.c b/sys/dev/sfxge/common/efx_crc32.c index 1fb8b02..23d77ae 100644 --- a/sys/dev/sfxge/common/efx_crc32.c +++ b/sys/dev/sfxge/common/efx_crc32.c @@ -31,9 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" #include "efx_impl.h" /* diff --git a/sys/dev/sfxge/common/efx_ev.c b/sys/dev/sfxge/common/efx_ev.c index ffbe8dc..037dbfa 100644 --- a/sys/dev/sfxge/common/efx_ev.c +++ b/sys/dev/sfxge/common/efx_ev.c @@ -31,12 +31,11 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" -#include "efx_regs.h" #include "efx_impl.h" +#if EFSYS_OPT_MON_MCDI #include "mcdi_mon.h" +#endif #if EFSYS_OPT_QSTATS #define EFX_EV_QSTAT_INCR(_eep, _stat) \ @@ -139,20 +138,20 @@ static efx_ev_ops_t __efx_ev_siena_ops = { }; #endif /* EFSYS_OPT_SIENA */ -#if EFSYS_OPT_HUNTINGTON -static efx_ev_ops_t __efx_ev_hunt_ops = { - hunt_ev_init, /* eevo_init */ - hunt_ev_fini, /* eevo_fini */ - hunt_ev_qcreate, /* eevo_qcreate */ - hunt_ev_qdestroy, /* eevo_qdestroy */ - hunt_ev_qprime, /* eevo_qprime */ - hunt_ev_qpost, /* eevo_qpost */ - hunt_ev_qmoderate, /* eevo_qmoderate */ +#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD +static efx_ev_ops_t __efx_ev_ef10_ops = { + ef10_ev_init, /* eevo_init */ + ef10_ev_fini, /* eevo_fini */ + ef10_ev_qcreate, /* eevo_qcreate */ + ef10_ev_qdestroy, /* eevo_qdestroy */ + ef10_ev_qprime, /* eevo_qprime */ + ef10_ev_qpost, /* eevo_qpost */ + ef10_ev_qmoderate, /* eevo_qmoderate */ #if EFSYS_OPT_QSTATS - hunt_ev_qstats_update, /* eevo_qstats_update */ + ef10_ev_qstats_update, /* eevo_qstats_update */ #endif }; -#endif /* EFSYS_OPT_HUNTINGTON */ +#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ __checkReturn efx_rc_t @@ -185,10 +184,16 @@ efx_ev_init( #if EFSYS_OPT_HUNTINGTON case EFX_FAMILY_HUNTINGTON: - eevop = (efx_ev_ops_t *)&__efx_ev_hunt_ops; + eevop = (efx_ev_ops_t *)&__efx_ev_ef10_ops; break; #endif /* EFSYS_OPT_HUNTINGTON */ +#if EFSYS_OPT_MEDFORD + case EFX_FAMILY_MEDFORD: + eevop = (efx_ev_ops_t *)&__efx_ev_ef10_ops; + break; +#endif /* EFSYS_OPT_MEDFORD */ + default: EFSYS_ASSERT(0); rc = ENOTSUP; @@ -492,7 +497,7 @@ falconsiena_ev_rx_not_ok( EFX_EV_QSTAT_INCR(eep, EV_RX_FRM_TRUNC); (*flagsp) |= EFX_DISCARD; -#if (EFSYS_OPT_RX_HDR_SPLIT || EFSYS_OPT_RX_SCATTER) +#if EFSYS_OPT_RX_SCATTER /* * Lookout for payload queue ran dry errors and ignore them. * @@ -507,7 +512,7 @@ falconsiena_ev_rx_not_ok( (EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_JUMBO_CONT) == 0) && (EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_BYTE_CNT) == 0)) ignore = B_TRUE; -#endif /* EFSYS_OPT_RX_HDR_SPLIT || EFSYS_OPT_RX_SCATTER */ +#endif /* EFSYS_OPT_RX_SCATTER */ } if (EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_ETH_CRC_ERR) != 0) { @@ -568,10 +573,10 @@ falconsiena_ev_rx( uint32_t size; uint32_t label; boolean_t ok; -#if (EFSYS_OPT_RX_HDR_SPLIT || EFSYS_OPT_RX_SCATTER) +#if EFSYS_OPT_RX_SCATTER boolean_t sop; boolean_t jumbo_cont; -#endif /* EFSYS_OPT_RX_HDR_SPLIT || EFSYS_OPT_RX_SCATTER */ +#endif /* EFSYS_OPT_RX_SCATTER */ uint32_t hdr_type; boolean_t is_v6; uint16_t flags; @@ -586,10 +591,10 @@ falconsiena_ev_rx( label = EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_Q_LABEL); ok = (EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_PKT_OK) != 0); -#if (EFSYS_OPT_RX_HDR_SPLIT || EFSYS_OPT_RX_SCATTER) +#if EFSYS_OPT_RX_SCATTER sop = (EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_SOP) != 0); jumbo_cont = (EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_JUMBO_CONT) != 0); -#endif /* EFSYS_OPT_RX_HDR_SPLIT || EFSYS_OPT_RX_SCATTER */ +#endif /* EFSYS_OPT_RX_SCATTER */ hdr_type = EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_HDR_TYPE); @@ -644,13 +649,13 @@ falconsiena_ev_rx( break; } -#if EFSYS_OPT_RX_SCATTER || EFSYS_OPT_RX_HDR_SPLIT +#if EFSYS_OPT_RX_SCATTER /* Report scatter and header/lookahead split buffer flags */ if (sop) flags |= EFX_PKT_START; if (jumbo_cont) flags |= EFX_PKT_CONT; -#endif /* EFSYS_OPT_RX_SCATTER || EFSYS_OPT_RX_HDR_SPLIT */ +#endif /* EFSYS_OPT_RX_SCATTER */ /* Detect errors included in the FSF_AZ_RX_EV_PKT_OK indication */ if (!ok) { diff --git a/sys/dev/sfxge/common/efx_filter.c b/sys/dev/sfxge/common/efx_filter.c index 9841715..e2763ae 100644 --- a/sys/dev/sfxge/common/efx_filter.c +++ b/sys/dev/sfxge/common/efx_filter.c @@ -31,10 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" -#include "efx_regs.h" #include "efx_impl.h" @@ -97,17 +94,17 @@ static efx_filter_ops_t __efx_filter_siena_ops = { }; #endif /* EFSYS_OPT_SIENA */ -#if EFSYS_OPT_HUNTINGTON -static efx_filter_ops_t __efx_filter_hunt_ops = { - hunt_filter_init, /* efo_init */ - hunt_filter_fini, /* efo_fini */ - hunt_filter_restore, /* efo_restore */ - hunt_filter_add, /* efo_add */ - hunt_filter_delete, /* efo_delete */ - hunt_filter_supported_filters, /* efo_supported_filters */ - hunt_filter_reconfigure, /* efo_reconfigure */ +#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD +static efx_filter_ops_t __efx_filter_ef10_ops = { + ef10_filter_init, /* efo_init */ + ef10_filter_fini, /* efo_fini */ + ef10_filter_restore, /* efo_restore */ + ef10_filter_add, /* efo_add */ + ef10_filter_delete, /* efo_delete */ + ef10_filter_supported_filters, /* efo_supported_filters */ + ef10_filter_reconfigure, /* efo_reconfigure */ }; -#endif /* EFSYS_OPT_HUNTINGTON */ +#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ __checkReturn efx_rc_t efx_filter_insert( @@ -189,10 +186,16 @@ efx_filter_init( #if EFSYS_OPT_HUNTINGTON case EFX_FAMILY_HUNTINGTON: - efop = (efx_filter_ops_t *)&__efx_filter_hunt_ops; + efop = (efx_filter_ops_t *)&__efx_filter_ef10_ops; break; #endif /* EFSYS_OPT_HUNTINGTON */ +#if EFSYS_OPT_MEDFORD + case EFX_FAMILY_MEDFORD: + efop = (efx_filter_ops_t *)&__efx_filter_ef10_ops; + break; +#endif /* EFSYS_OPT_MEDFORD */ + default: EFSYS_ASSERT(0); rc = ENOTSUP; diff --git a/sys/dev/sfxge/common/efx_hash.c b/sys/dev/sfxge/common/efx_hash.c index 3005c1b..db8b12c 100644 --- a/sys/dev/sfxge/common/efx_hash.c +++ b/sys/dev/sfxge/common/efx_hash.c @@ -42,9 +42,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" #include "efx_impl.h" /* Hash initial value */ diff --git a/sys/dev/sfxge/common/efx_impl.h b/sys/dev/sfxge/common/efx_impl.h index 502fc78..16c0898 100644 --- a/sys/dev/sfxge/common/efx_impl.h +++ b/sys/dev/sfxge/common/efx_impl.h @@ -58,6 +58,14 @@ #include "hunt_impl.h" #endif /* EFSYS_OPT_HUNTINGTON */ +#if EFSYS_OPT_MEDFORD +#include "medford_impl.h" +#endif /* EFSYS_OPT_MEDFORD */ + +#if (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) +#include "ef10_impl.h" +#endif /* (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) */ + #ifdef __cplusplus extern "C" { #endif @@ -149,10 +157,6 @@ typedef struct efx_tx_ops_s { typedef struct efx_rx_ops_s { efx_rc_t (*erxo_init)(efx_nic_t *); void (*erxo_fini)(efx_nic_t *); -#if EFSYS_OPT_RX_HDR_SPLIT - efx_rc_t (*erxo_hdr_split_enable)(efx_nic_t *, unsigned int, - unsigned int); -#endif #if EFSYS_OPT_RX_SCATTER efx_rc_t (*erxo_scatter_enable)(efx_nic_t *, unsigned int); #endif @@ -162,7 +166,11 @@ typedef struct efx_rx_ops_s { efx_rc_t (*erxo_scale_key_set)(efx_nic_t *, uint8_t *, size_t); efx_rc_t (*erxo_scale_tbl_set)(efx_nic_t *, unsigned int *, size_t); -#endif + uint32_t (*erxo_prefix_hash)(efx_nic_t *, efx_rx_hash_alg_t, + uint8_t *); +#endif /* EFSYS_OPT_RX_SCALE */ + efx_rc_t (*erxo_prefix_pktlen)(efx_nic_t *, uint8_t *, + uint16_t *); void (*erxo_qpost)(efx_rxq_t *, efsys_dma_addr_t *, size_t, unsigned int, unsigned int, unsigned int); @@ -258,16 +266,6 @@ efx_filter_reconfigure( #endif /* EFSYS_OPT_FILTER */ -typedef struct efx_pktfilter_ops_s { - efx_rc_t (*epfo_set)(efx_nic_t *, - boolean_t unicst, - boolean_t brdcast); -#if EFSYS_OPT_MCAST_FILTER_LIST - efx_rc_t (*epfo_mcast_list_set)(efx_nic_t *, - uint8_t const *addrs, int count); -#endif /* EFSYS_OPT_MCAST_FILTER_LIST */ - efx_rc_t (*epfo_mcast_all)(efx_nic_t *); -} efx_pktfilter_ops_t; typedef struct efx_port_s { efx_mac_type_t ep_mac_type; @@ -344,6 +342,10 @@ typedef struct efx_intr_ops_s { void (*eio_disable)(efx_nic_t *); void (*eio_disable_unlocked)(efx_nic_t *); efx_rc_t (*eio_trigger)(efx_nic_t *, unsigned int); + void (*eio_status_line)(efx_nic_t *, boolean_t *, uint32_t *); + void (*eio_status_message)(efx_nic_t *, unsigned int, + boolean_t *); + void (*eio_fatal)(efx_nic_t *); void (*eio_fini)(efx_nic_t *); } efx_intr_ops_t; @@ -438,9 +440,9 @@ typedef struct efx_filter_s { #if EFSYS_OPT_FALCON || EFSYS_OPT_SIENA falconsiena_filter_t *ef_falconsiena_filter; #endif /* EFSYS_OPT_FALCON || EFSYS_OPT_SIENA */ -#if EFSYS_OPT_HUNTINGTON - hunt_filter_table_t *ef_hunt_filter_table; -#endif /* EFSYS_OPT_HUNTINGTON */ +#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD + ef10_filter_table_t *ef_ef10_filter_table; +#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ } efx_filter_t; extern void @@ -490,6 +492,8 @@ typedef struct efx_nvram_ops_s { efx_rc_t (*envo_set_version)(efx_nic_t *, efx_nvram_type_t, uint16_t *); + efx_rc_t (*envo_type_to_partn)(efx_nic_t *, efx_nvram_type_t, + uint32_t *); } efx_nvram_ops_t; #endif /* EFSYS_OPT_NVRAM */ @@ -616,7 +620,6 @@ struct efx_nic_s { efx_filter_t en_filter; efx_filter_ops_t *en_efop; #endif /* EFSYS_OPT_FILTER */ - efx_pktfilter_ops_t *en_epfop; #if EFSYS_OPT_MCDI efx_mcdi_t en_mcdi; #endif /* EFSYS_OPT_MCDI */ @@ -664,26 +667,30 @@ struct efx_nic_s { int enu_unused; } siena; #endif /* EFSYS_OPT_SIENA */ -#if EFSYS_OPT_HUNTINGTON + int enu_unused; + } en_u; +#if (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) + union en_arch { struct { - int enu_vi_base; - int enu_vi_count; + int ena_vi_base; + int ena_vi_count; + int ena_vi_shift; #if EFSYS_OPT_VPD - caddr_t enu_svpd; - size_t enu_svpd_length; + caddr_t ena_svpd; + size_t ena_svpd_length; #endif /* EFSYS_OPT_VPD */ - efx_piobuf_handle_t enu_piobuf_handle[HUNT_PIOBUF_NBUFS]; - uint32_t enu_piobuf_count; - uint32_t enu_pio_alloc_map[HUNT_PIOBUF_NBUFS]; - uint32_t enu_pio_write_vi_base; + efx_piobuf_handle_t ena_piobuf_handle[EF10_MAX_PIOBUF_NBUFS]; + uint32_t ena_piobuf_count; + uint32_t ena_pio_alloc_map[EF10_MAX_PIOBUF_NBUFS]; + uint32_t ena_pio_write_vi_base; /* Memory BAR mapping regions */ - uint32_t enu_uc_mem_map_offset; - size_t enu_uc_mem_map_size; - uint32_t enu_wc_mem_map_offset; - size_t enu_wc_mem_map_size; - } hunt; -#endif /* EFSYS_OPT_HUNTINGTON */ - } en_u; + uint32_t ena_uc_mem_map_offset; + size_t ena_uc_mem_map_size; + uint32_t ena_wc_mem_map_offset; + size_t ena_wc_mem_map_size; + } ef10; + } en_arch; +#endif /* (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) */ }; @@ -797,6 +804,10 @@ struct efx_txq_s { rev = 'D'; \ break; \ \ + case EFX_FAMILY_MEDFORD: \ + rev = 'E'; \ + break; \ + \ default: \ rev = '?'; \ break; \ diff --git a/sys/dev/sfxge/common/efx_intr.c b/sys/dev/sfxge/common/efx_intr.c index 48ec3cb..eb570fc 100644 --- a/sys/dev/sfxge/common/efx_intr.c +++ b/sys/dev/sfxge/common/efx_intr.c @@ -31,10 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" -#include "efx_regs.h" #include "efx_impl.h" @@ -67,15 +64,27 @@ static void falconsiena_intr_fini( __in efx_nic_t *enp); +static void +falconsiena_intr_status_line( + __in efx_nic_t *enp, + __out boolean_t *fatalp, + __out uint32_t *qmaskp); -static __checkReturn boolean_t -falconsiena_intr_check_fatal( - __in efx_nic_t *enp); +static void +falconsiena_intr_status_message( + __in efx_nic_t *enp, + __in unsigned int message, + __out boolean_t *fatalp); static void falconsiena_intr_fatal( __in efx_nic_t *enp); +static __checkReturn boolean_t +falconsiena_intr_check_fatal( + __in efx_nic_t *enp); + + #endif /* EFSYS_OPT_FALCON || EFSYS_OPT_SIENA */ @@ -86,6 +95,9 @@ static efx_intr_ops_t __efx_intr_falcon_ops = { falconsiena_intr_disable, /* eio_disable */ falconsiena_intr_disable_unlocked, /* eio_disable_unlocked */ falconsiena_intr_trigger, /* eio_trigger */ + falconsiena_intr_status_line, /* eio_status_line */ + falconsiena_intr_status_message, /* eio_status_message */ + falconsiena_intr_fatal, /* eio_fatal */ falconsiena_intr_fini, /* eio_fini */ }; #endif /* EFSYS_OPT_FALCON */ @@ -97,21 +109,26 @@ static efx_intr_ops_t __efx_intr_siena_ops = { falconsiena_intr_disable, /* eio_disable */ falconsiena_intr_disable_unlocked, /* eio_disable_unlocked */ falconsiena_intr_trigger, /* eio_trigger */ + falconsiena_intr_status_line, /* eio_status_line */ + falconsiena_intr_status_message, /* eio_status_message */ + falconsiena_intr_fatal, /* eio_fatal */ falconsiena_intr_fini, /* eio_fini */ }; #endif /* EFSYS_OPT_SIENA */ -#if EFSYS_OPT_HUNTINGTON -static efx_intr_ops_t __efx_intr_hunt_ops = { - hunt_intr_init, /* eio_init */ - hunt_intr_enable, /* eio_enable */ - hunt_intr_disable, /* eio_disable */ - hunt_intr_disable_unlocked, /* eio_disable_unlocked */ - hunt_intr_trigger, /* eio_trigger */ - hunt_intr_fini, /* eio_fini */ +#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD +static efx_intr_ops_t __efx_intr_ef10_ops = { + ef10_intr_init, /* eio_init */ + ef10_intr_enable, /* eio_enable */ + ef10_intr_disable, /* eio_disable */ + ef10_intr_disable_unlocked, /* eio_disable_unlocked */ + ef10_intr_trigger, /* eio_trigger */ + ef10_intr_status_line, /* eio_status_line */ + ef10_intr_status_message, /* eio_status_message */ + ef10_intr_fatal, /* eio_fatal */ + ef10_intr_fini, /* eio_fini */ }; -#endif /* EFSYS_OPT_HUNTINGTON */ - +#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ __checkReturn efx_rc_t efx_intr_init( @@ -152,10 +169,16 @@ efx_intr_init( #if EFSYS_OPT_HUNTINGTON case EFX_FAMILY_HUNTINGTON: - eiop = (efx_intr_ops_t *)&__efx_intr_hunt_ops; + eiop = (efx_intr_ops_t *)&__efx_intr_ef10_ops; break; #endif /* EFSYS_OPT_HUNTINGTON */ +#if EFSYS_OPT_MEDFORD + case EFX_FAMILY_MEDFORD: + eiop = (efx_intr_ops_t *)&__efx_intr_ef10_ops; + break; +#endif /* EFSYS_OPT_MEDFORD */ + default: EFSYS_ASSERT(B_FALSE); rc = ENOTSUP; @@ -256,35 +279,12 @@ efx_intr_status_line( __out uint32_t *qmaskp) { efx_intr_t *eip = &(enp->en_intr); - efx_dword_t dword; + efx_intr_ops_t *eiop = eip->ei_eiop; EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_INTR); - /* Ensure Huntington and Falcon/Siena ISR at same location */ - EFX_STATIC_ASSERT(FR_BZ_INT_ISR0_REG_OFST == - ER_DZ_BIU_INT_ISR_REG_OFST); - - /* - * Read the queue mask and implicitly acknowledge the - * interrupt. - */ - EFX_BAR_READD(enp, FR_BZ_INT_ISR0_REG, &dword, B_FALSE); - *qmaskp = EFX_DWORD_FIELD(dword, EFX_DWORD_0); - - EFSYS_PROBE1(qmask, uint32_t, *qmaskp); - -#if EFSYS_OPT_HUNTINGTON - if (enp->en_family == EFX_FAMILY_HUNTINGTON) { - /* Huntington reports fatal errors via events */ - *fatalp = B_FALSE; - return; - } -#endif - if (*qmaskp & (1U << eip->ei_level)) - *fatalp = falconsiena_intr_check_fatal(enp); - else - *fatalp = B_FALSE; + eiop->eio_status_line(enp, fatalp, qmaskp); } void @@ -294,39 +294,25 @@ efx_intr_status_message( __out boolean_t *fatalp) { efx_intr_t *eip = &(enp->en_intr); + efx_intr_ops_t *eiop = eip->ei_eiop; EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_INTR); -#if EFSYS_OPT_HUNTINGTON - if (enp->en_family == EFX_FAMILY_HUNTINGTON) { - /* Huntington reports fatal errors via events */ - *fatalp = B_FALSE; - return; - } -#endif - if (message == eip->ei_level) - *fatalp = falconsiena_intr_check_fatal(enp); - else - *fatalp = B_FALSE; + eiop->eio_status_message(enp, message, fatalp); } void efx_intr_fatal( __in efx_nic_t *enp) { + efx_intr_t *eip = &(enp->en_intr); + efx_intr_ops_t *eiop = eip->ei_eiop; + EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_INTR); -#if EFSYS_OPT_HUNTINGTON - if (enp->en_family == EFX_FAMILY_HUNTINGTON) { - /* Huntington reports fatal errors via events */ - return; - } -#endif -#if EFSYS_OPT_FALCON || EFSYS_OPT_SIENA - falconsiena_intr_fatal(enp); -#endif + eiop->eio_fatal(enp); } @@ -509,6 +495,51 @@ falconsiena_intr_check_fatal( return (B_FALSE); } +static void +falconsiena_intr_status_line( + __in efx_nic_t *enp, + __out boolean_t *fatalp, + __out uint32_t *qmaskp) +{ + efx_intr_t *eip = &(enp->en_intr); + efx_dword_t dword; + + EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); + EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_INTR); + + /* + * Read the queue mask and implicitly acknowledge the + * interrupt. + */ + EFX_BAR_READD(enp, FR_BZ_INT_ISR0_REG, &dword, B_FALSE); + *qmaskp = EFX_DWORD_FIELD(dword, EFX_DWORD_0); + + EFSYS_PROBE1(qmask, uint32_t, *qmaskp); + + if (*qmaskp & (1U << eip->ei_level)) + *fatalp = falconsiena_intr_check_fatal(enp); + else + *fatalp = B_FALSE; +} + +static void +falconsiena_intr_status_message( + __in efx_nic_t *enp, + __in unsigned int message, + __out boolean_t *fatalp) +{ + efx_intr_t *eip = &(enp->en_intr); + + EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); + EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_INTR); + + if (message == eip->ei_level) + *fatalp = falconsiena_intr_check_fatal(enp); + else + *fatalp = B_FALSE; +} + + static void falconsiena_intr_fatal( __in efx_nic_t *enp) diff --git a/sys/dev/sfxge/common/efx_mac.c b/sys/dev/sfxge/common/efx_mac.c index 50f9333..c8794a6 100644 --- a/sys/dev/sfxge/common/efx_mac.c +++ b/sys/dev/sfxge/common/efx_mac.c @@ -31,9 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" #include "efx_impl.h" #if EFSYS_OPT_MAC_FALCON_GMAC @@ -462,55 +460,6 @@ efx_mac_fcntl_get( *fcntl_wantedp = wanted; } -/* - * FIXME: efx_mac_hash_set() should be deleted once all its callers have been - * updated to use efx_mac_multicast_list_set(). - * Then efx_port_t.ep_multicst_hash could be made Falcon/Siena specific as - * well. - */ - __checkReturn efx_rc_t -efx_mac_hash_set( - __in efx_nic_t *enp, - __in_ecount(EFX_MAC_HASH_BITS) unsigned int const *bucket) -{ - efx_port_t *epp = &(enp->en_port); - efx_mac_ops_t *emop = epp->ep_emop; - efx_oword_t old_hash[2]; - unsigned int index; - efx_rc_t rc; - - EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); - EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT); - - memcpy(old_hash, epp->ep_multicst_hash, sizeof (old_hash)); - - /* Set the lower 128 bits of the hash */ - EFX_ZERO_OWORD(epp->ep_multicst_hash[0]); - for (index = 0; index < 128; index++) { - if (bucket[index] != 0) - EFX_SET_OWORD_BIT(epp->ep_multicst_hash[0], index); - } - - /* Set the upper 128 bits of the hash */ - EFX_ZERO_OWORD(epp->ep_multicst_hash[1]); - for (index = 0; index < 128; index++) { - if (bucket[index + 128] != 0) - EFX_SET_OWORD_BIT(epp->ep_multicst_hash[1], index); - } - - if ((rc = emop->emo_reconfigure(enp)) != 0) - goto fail1; - - return (0); - -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - memcpy(epp->ep_multicst_hash, old_hash, sizeof (old_hash)); - - return (rc); -} - __checkReturn efx_rc_t efx_mac_multicast_list_set( __in efx_nic_t *enp, @@ -912,6 +861,8 @@ fail1: #if EFSYS_OPT_FALCON || EFSYS_OPT_SIENA +#define EFX_MAC_HASH_BITS (1 << 8) + /* Compute the multicast hash as used on Falcon and Siena. */ static void falconsiena_mac_multicast_hash_compute( diff --git a/sys/dev/sfxge/common/efx_mcdi.c b/sys/dev/sfxge/common/efx_mcdi.c index a5c4d52..07224c7 100644 --- a/sys/dev/sfxge/common/efx_mcdi.c +++ b/sys/dev/sfxge/common/efx_mcdi.c @@ -31,11 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" -#include "efx_regs.h" -#include "efx_regs_mcdi.h" #include "efx_impl.h" #if EFSYS_OPT_MCDI @@ -56,20 +52,20 @@ static efx_mcdi_ops_t __efx_mcdi_siena_ops = { #endif /* EFSYS_OPT_SIENA */ -#if EFSYS_OPT_HUNTINGTON - -static efx_mcdi_ops_t __efx_mcdi_hunt_ops = { - hunt_mcdi_init, /* emco_init */ - hunt_mcdi_request_copyin, /* emco_request_copyin */ - hunt_mcdi_request_copyout, /* emco_request_copyout */ - hunt_mcdi_poll_reboot, /* emco_poll_reboot */ - hunt_mcdi_poll_response, /* emco_poll_response */ - hunt_mcdi_read_response, /* emco_read_response */ - hunt_mcdi_fini, /* emco_fini */ - hunt_mcdi_feature_supported, /* emco_feature_supported */ +#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD + +static efx_mcdi_ops_t __efx_mcdi_ef10_ops = { + ef10_mcdi_init, /* emco_init */ + ef10_mcdi_request_copyin, /* emco_request_copyin */ + ef10_mcdi_request_copyout, /* emco_request_copyout */ + ef10_mcdi_poll_reboot, /* emco_poll_reboot */ + ef10_mcdi_poll_response, /* emco_poll_response */ + ef10_mcdi_read_response, /* emco_read_response */ + ef10_mcdi_fini, /* emco_fini */ + ef10_mcdi_feature_supported, /* emco_feature_supported */ }; -#endif /* EFSYS_OPT_HUNTINGTON */ +#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ @@ -100,10 +96,16 @@ efx_mcdi_init( #if EFSYS_OPT_HUNTINGTON case EFX_FAMILY_HUNTINGTON: - emcop = (efx_mcdi_ops_t *)&__efx_mcdi_hunt_ops; + emcop = (efx_mcdi_ops_t *)&__efx_mcdi_ef10_ops; break; #endif /* EFSYS_OPT_HUNTINGTON */ +#if EFSYS_OPT_MEDFORD + case EFX_FAMILY_MEDFORD: + emcop = (efx_mcdi_ops_t *)&__efx_mcdi_ef10_ops; + break; +#endif /* EFSYS_OPT_MEDFORD */ + default: EFSYS_ASSERT(0); rc = ENOTSUP; @@ -637,7 +639,6 @@ efx_mcdi_ev_cpl( efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp; efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop; - efx_nic_cfg_t *encp = &enp->en_nic_cfg; efx_mcdi_req_t *emrp; int state; @@ -662,7 +663,7 @@ efx_mcdi_ev_cpl( emip->emi_pending_req = NULL; EFSYS_UNLOCK(enp->en_eslp, state); - if (encp->enc_mcdi_max_payload_length > MCDI_CTL_SDU_LEN_MAX_V1) { + if (emip->emi_max_version >= 2) { /* MCDIv2 response details do not fit into an event. */ efx_mcdi_read_response_header(enp, emrp); } else { @@ -1491,7 +1492,7 @@ fail1: #if EFSYS_OPT_BIST -#if EFSYS_OPT_HUNTINGTON +#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD /* * Enter bist offline mode. This is a fw mode which puts the NIC into a state * where memory BIST tests can be run and not much else can interfere or happen. @@ -1527,7 +1528,7 @@ fail1: return (rc); } -#endif /* EFSYS_OPT_HUNTINGTON */ +#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ __checkReturn efx_rc_t efx_mcdi_bist_start( @@ -1788,7 +1789,7 @@ fail1: #endif /* EFSYS_OPT_MAC_STATS */ -#if EFSYS_OPT_HUNTINGTON +#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD /* * This function returns the pf and vf number of a function. If it is a pf the @@ -1887,7 +1888,7 @@ fail1: return (rc); } -#endif /* EFSYS_OPT_HUNTINGTON */ +#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ __checkReturn efx_rc_t efx_mcdi_set_workaround( diff --git a/sys/dev/sfxge/common/efx_mcdi.h b/sys/dev/sfxge/common/efx_mcdi.h index 18924a0..d100775 100644 --- a/sys/dev/sfxge/common/efx_mcdi.h +++ b/sys/dev/sfxge/common/efx_mcdi.h @@ -34,7 +34,6 @@ #define _SYS_EFX_MCDI_H #include "efx.h" -#include "efx_regs.h" #include "efx_regs_mcdi.h" #ifdef __cplusplus @@ -69,6 +68,7 @@ struct efx_mcdi_req_s { typedef struct efx_mcdi_iface_s { unsigned int emi_port; + unsigned int emi_max_version; unsigned int emi_seq; efx_mcdi_req_t *emi_pending_req; boolean_t emi_ev_cpl; @@ -188,11 +188,11 @@ efx_mcdi_mac_spoofing_supported( #if EFSYS_OPT_BIST -#if EFSYS_OPT_HUNTINGTON +#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD extern __checkReturn efx_rc_t efx_mcdi_bist_enable_offline( __in efx_nic_t *enp); -#endif /* EFSYS_OPT_HUNTINGTON */ +#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ extern __checkReturn efx_rc_t efx_mcdi_bist_start( __in efx_nic_t *enp, diff --git a/sys/dev/sfxge/common/efx_mon.c b/sys/dev/sfxge/common/efx_mon.c index 3574e8a..9803b43 100644 --- a/sys/dev/sfxge/common/efx_mon.c +++ b/sys/dev/sfxge/common/efx_mon.c @@ -31,10 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" -#include "efx_regs.h" #include "efx_impl.h" #if EFSYS_OPT_MON_NULL @@ -62,6 +59,7 @@ static const char *__efx_mon_name[] = { "max6647", "sfx90x0", "sfx91x0" + "sfx92x0" }; const char * @@ -119,34 +117,6 @@ static efx_mon_ops_t __efx_mon_mcdi_ops = { }; #endif -static efx_mon_ops_t *__efx_mon_ops[] = { - NULL, -#if EFSYS_OPT_MON_NULL - &__efx_mon_null_ops, -#else - NULL, -#endif -#if EFSYS_OPT_MON_LM87 - &__efx_mon_lm87_ops, -#else - NULL, -#endif -#if EFSYS_OPT_MON_MAX6647 - &__efx_mon_max6647_ops, -#else - NULL, -#endif -#if EFSYS_OPT_MON_MCDI - &__efx_mon_mcdi_ops, -#else - NULL, -#endif -#if EFSYS_OPT_MON_MCDI - &__efx_mon_mcdi_ops -#else - NULL -#endif -}; __checkReturn efx_rc_t efx_mon_init( @@ -170,8 +140,30 @@ efx_mon_init( emp->em_type = encp->enc_mon_type; EFSYS_ASSERT(encp->enc_mon_type != EFX_MON_INVALID); - EFSYS_ASSERT3U(emp->em_type, <, EFX_MON_NTYPES); - if ((emop = (efx_mon_ops_t *)__efx_mon_ops[emp->em_type]) == NULL) { + switch (emp->em_type) { +#if EFSYS_OPT_MON_NULL + case EFX_MON_NULL: + emop = &__efx_mon_null_ops; + break; +#endif +#if EFSYS_OPT_MON_LM87 + case EFX_MON_LM87: + emop = &__efx_mon_lm87_ops; + break; +#endif +#if EFSYS_OPT_MON_MAX6647 + case EFX_MON_MAX6647: + emop = &__efx_mon_max6647_ops; + break; +#endif +#if EFSYS_OPT_MON_MCDI + case EFX_MON_SFC90X0: + case EFX_MON_SFC91X0: + case EFX_MON_SFC92X0: + emop = &__efx_mon_mcdi_ops; + break; +#endif + default: rc = ENOTSUP; goto fail2; } @@ -214,7 +206,7 @@ fail1: #if EFSYS_OPT_NAMES -/* START MKCONFIG GENERATED MonitorStatNamesBlock b9328f15438c4d01 */ +/* START MKCONFIG GENERATED MonitorStatNamesBlock 01ee3ea01f23a0c4 */ static const char *__mon_stat_name[] = { "value_2_5v", "value_vccp1", @@ -285,6 +277,12 @@ static const char *__mon_stat_name[] = { "controller_slave_internal_temp", "controller_slave_vptat_ext_adc", "controller_slave_internal_temp_ext_adc", + "sodimm_vout", + "sodimm_0_temp", + "sodimm_1_temp", + "phy0_vcc", + "phy1_vcc", + "controller_tdiode_temp", }; /* END MKCONFIG GENERATED MonitorStatNamesBlock */ diff --git a/sys/dev/sfxge/common/efx_nic.c b/sys/dev/sfxge/common/efx_nic.c index 96d0649..07acc56 100644 --- a/sys/dev/sfxge/common/efx_nic.c +++ b/sys/dev/sfxge/common/efx_nic.c @@ -31,10 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" -#include "efx_regs.h" #include "efx_impl.h" __checkReturn efx_rc_t @@ -49,7 +46,8 @@ efx_family( case EFX_PCI_DEVID_FALCON: *efp = EFX_FAMILY_FALCON; return (0); -#endif +#endif /* EFSYS_OPT_FALCON */ + #if EFSYS_OPT_SIENA case EFX_PCI_DEVID_SIENA_F1_UNINIT: /* @@ -63,7 +61,7 @@ efx_family( case EFX_PCI_DEVID_SIENA: *efp = EFX_FAMILY_SIENA; return (0); -#endif +#endif /* EFSYS_OPT_SIENA */ #if EFSYS_OPT_HUNTINGTON case EFX_PCI_DEVID_HUNTINGTON_PF_UNINIT: @@ -83,7 +81,26 @@ efx_family( case EFX_PCI_DEVID_GREENPORT_VF: *efp = EFX_FAMILY_HUNTINGTON; return (0); -#endif +#endif /* EFSYS_OPT_HUNTINGTON */ + +#if EFSYS_OPT_MEDFORD + case EFX_PCI_DEVID_MEDFORD_PF_UNINIT: + /* + * Hardware default for PF0 of uninitialised Medford. + * manftest must be able to cope with this device id. + */ + *efp = EFX_FAMILY_MEDFORD; + return (0); + + case EFX_PCI_DEVID_MEDFORD: + *efp = EFX_FAMILY_MEDFORD; + return (0); + + case EFX_PCI_DEVID_MEDFORD_VF: + *efp = EFX_FAMILY_MEDFORD; + return (0); +#endif /* EFSYS_OPT_MEDFORD */ + default: break; } @@ -110,8 +127,12 @@ efx_infer_family( EFSYS_BAR_READO(esbp, FR_AZ_CS_DEBUG_REG_OFST, &oword, B_TRUE); portnum = EFX_OWORD_FIELD(oword, FRF_CZ_CS_PORT_NUM); - switch (portnum) { - case 0: { + if ((portnum == 1) || (portnum == 2)) { +#if EFSYS_OPT_SIENA + family = EFX_FAMILY_SIENA; + goto out; +#endif + } else if (portnum == 0) { efx_dword_t dword; uint32_t hw_rev; @@ -119,31 +140,25 @@ efx_infer_family( B_TRUE); hw_rev = EFX_DWORD_FIELD(dword, ERF_DZ_HW_REV_ID); if (hw_rev == ER_DZ_BIU_HW_REV_ID_REG_RESET) { -#if EFSYS_OPT_HUNTINGTON +#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD + /* + * BIU_HW_REV_ID is the same for Huntington and Medford. + * Assume Huntington, as Medford is very similar. + */ family = EFX_FAMILY_HUNTINGTON; - break; + goto out; #endif } else { #if EFSYS_OPT_FALCON family = EFX_FAMILY_FALCON; - break; + goto out; #endif } - rc = ENOTSUP; - goto fail1; - } - -#if EFSYS_OPT_SIENA - case 1: - case 2: - family = EFX_FAMILY_SIENA; - break; -#endif - default: - rc = ENOTSUP; - goto fail1; } + rc = ENOTSUP; + goto fail1; +out: if (efp != NULL) *efp = family; return (0); @@ -266,18 +281,18 @@ static efx_nic_ops_t __efx_nic_siena_ops = { #if EFSYS_OPT_HUNTINGTON static efx_nic_ops_t __efx_nic_hunt_ops = { - hunt_nic_probe, /* eno_probe */ - hunt_nic_set_drv_limits, /* eno_set_drv_limits */ - hunt_nic_reset, /* eno_reset */ - hunt_nic_init, /* eno_init */ - hunt_nic_get_vi_pool, /* eno_get_vi_pool */ - hunt_nic_get_bar_region, /* eno_get_bar_region */ + ef10_nic_probe, /* eno_probe */ + ef10_nic_set_drv_limits, /* eno_set_drv_limits */ + ef10_nic_reset, /* eno_reset */ + ef10_nic_init, /* eno_init */ + ef10_nic_get_vi_pool, /* eno_get_vi_pool */ + ef10_nic_get_bar_region, /* eno_get_bar_region */ #if EFSYS_OPT_DIAG - hunt_sram_test, /* eno_sram_test */ - hunt_nic_register_test, /* eno_register_test */ + ef10_sram_test, /* eno_sram_test */ + ef10_nic_register_test, /* eno_register_test */ #endif /* EFSYS_OPT_DIAG */ - hunt_nic_fini, /* eno_fini */ - hunt_nic_unprobe, /* eno_unprobe */ + ef10_nic_fini, /* eno_fini */ + ef10_nic_unprobe, /* eno_unprobe */ }; #endif /* EFSYS_OPT_HUNTINGTON */ diff --git a/sys/dev/sfxge/common/efx_nvram.c b/sys/dev/sfxge/common/efx_nvram.c index b7d29fd..7597636 100644 --- a/sys/dev/sfxge/common/efx_nvram.c +++ b/sys/dev/sfxge/common/efx_nvram.c @@ -31,10 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" -#include "efx_regs.h" #include "efx_impl.h" #if EFSYS_OPT_NVRAM @@ -53,6 +50,7 @@ static efx_nvram_ops_t __efx_nvram_falcon_ops = { falcon_nvram_write_chunk, /* envo_write_chunk */ falcon_nvram_rw_finish, /* envo_rw_finish */ falcon_nvram_set_version, /* envo_set_version */ + falcon_nvram_type_to_partn, /* envo_type_to_partn */ }; #endif /* EFSYS_OPT_FALCON */ @@ -71,27 +69,29 @@ static efx_nvram_ops_t __efx_nvram_siena_ops = { siena_nvram_write_chunk, /* envo_write_chunk */ siena_nvram_rw_finish, /* envo_rw_finish */ siena_nvram_set_version, /* envo_set_version */ + siena_nvram_type_to_partn, /* envo_type_to_partn */ }; #endif /* EFSYS_OPT_SIENA */ -#if EFSYS_OPT_HUNTINGTON +#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD -static efx_nvram_ops_t __efx_nvram_hunt_ops = { +static efx_nvram_ops_t __efx_nvram_ef10_ops = { #if EFSYS_OPT_DIAG - hunt_nvram_test, /* envo_test */ + ef10_nvram_test, /* envo_test */ #endif /* EFSYS_OPT_DIAG */ - hunt_nvram_size, /* envo_size */ - hunt_nvram_get_version, /* envo_get_version */ - hunt_nvram_rw_start, /* envo_rw_start */ - hunt_nvram_read_chunk, /* envo_read_chunk */ - hunt_nvram_erase, /* envo_erase */ - hunt_nvram_write_chunk, /* envo_write_chunk */ - hunt_nvram_rw_finish, /* envo_rw_finish */ - hunt_nvram_set_version, /* envo_set_version */ + ef10_nvram_size, /* envo_size */ + ef10_nvram_get_version, /* envo_get_version */ + ef10_nvram_rw_start, /* envo_rw_start */ + ef10_nvram_read_chunk, /* envo_read_chunk */ + ef10_nvram_erase, /* envo_erase */ + ef10_nvram_write_chunk, /* envo_write_chunk */ + ef10_nvram_rw_finish, /* envo_rw_finish */ + ef10_nvram_set_version, /* envo_set_version */ + ef10_nvram_type_to_partn, /* envo_type_to_partn */ }; -#endif /* EFSYS_OPT_HUNTINGTON */ +#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ __checkReturn efx_rc_t efx_nvram_init( @@ -119,10 +119,16 @@ efx_nvram_init( #if EFSYS_OPT_HUNTINGTON case EFX_FAMILY_HUNTINGTON: - envop = (efx_nvram_ops_t *)&__efx_nvram_hunt_ops; + envop = (efx_nvram_ops_t *)&__efx_nvram_ef10_ops; break; #endif /* EFSYS_OPT_HUNTINGTON */ +#if EFSYS_OPT_MEDFORD + case EFX_FAMILY_MEDFORD: + envop = (efx_nvram_ops_t *)&__efx_nvram_ef10_ops; + break; +#endif /* EFSYS_OPT_MEDFORD */ + default: EFSYS_ASSERT(0); rc = ENOTSUP; diff --git a/sys/dev/sfxge/common/efx_phy.c b/sys/dev/sfxge/common/efx_phy.c index 0742208..dd966be 100644 --- a/sys/dev/sfxge/common/efx_phy.c +++ b/sys/dev/sfxge/common/efx_phy.c @@ -31,10 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" -#include "efx_regs.h" #include "efx_impl.h" #if EFSYS_OPT_FALCON #include "falcon_nvram.h" diff --git a/sys/dev/sfxge/common/efx_port.c b/sys/dev/sfxge/common/efx_port.c index e74cfe6..ca2a69b 100644 --- a/sys/dev/sfxge/common/efx_port.c +++ b/sys/dev/sfxge/common/efx_port.c @@ -31,9 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" #include "efx_impl.h" __checkReturn efx_rc_t diff --git a/sys/dev/sfxge/common/efx_regs_ef10.h b/sys/dev/sfxge/common/efx_regs_ef10.h index c5ee15d..bd7619a 100644 --- a/sys/dev/sfxge/common/efx_regs_ef10.h +++ b/sys/dev/sfxge/common/efx_regs_ef10.h @@ -429,6 +429,48 @@ extern "C" { #define ESF_DZ_TX_TSO_TCP_SEQNO_WIDTH 32 +/* TX_TSO_FATSO2A_DESC */ +#define ESF_DZ_TX_DESC_IS_OPT_LBN 63 +#define ESF_DZ_TX_DESC_IS_OPT_WIDTH 1 +#define ESF_DZ_TX_OPTION_TYPE_LBN 60 +#define ESF_DZ_TX_OPTION_TYPE_WIDTH 3 +#define ESE_DZ_TX_OPTION_DESC_TSO 7 +#define ESE_DZ_TX_OPTION_DESC_VLAN 6 +#define ESE_DZ_TX_OPTION_DESC_CRC_CSUM 0 +#define ESF_DZ_TX_TSO_OPTION_TYPE_LBN 56 +#define ESF_DZ_TX_TSO_OPTION_TYPE_WIDTH 4 +#define ESE_DZ_TX_TSO_OPTION_DESC_FATSO2B 3 +#define ESE_DZ_TX_TSO_OPTION_DESC_FATSO2A 2 +#define ESE_DZ_TX_TSO_OPTION_DESC_ENCAP 1 +#define ESE_DZ_TX_TSO_OPTION_DESC_NORMAL 0 +#define ESF_DZ_TX_TSO_IP_ID_LBN 32 +#define ESF_DZ_TX_TSO_IP_ID_WIDTH 16 +#define ESF_DZ_TX_TSO_TCP_SEQNO_LBN 0 +#define ESF_DZ_TX_TSO_TCP_SEQNO_WIDTH 32 + + +/* TX_TSO_FATSO2B_DESC */ +#define ESF_DZ_TX_DESC_IS_OPT_LBN 63 +#define ESF_DZ_TX_DESC_IS_OPT_WIDTH 1 +#define ESF_DZ_TX_OPTION_TYPE_LBN 60 +#define ESF_DZ_TX_OPTION_TYPE_WIDTH 3 +#define ESE_DZ_TX_OPTION_DESC_TSO 7 +#define ESE_DZ_TX_OPTION_DESC_VLAN 6 +#define ESE_DZ_TX_OPTION_DESC_CRC_CSUM 0 +#define ESF_DZ_TX_TSO_OPTION_TYPE_LBN 56 +#define ESF_DZ_TX_TSO_OPTION_TYPE_WIDTH 4 +#define ESE_DZ_TX_TSO_OPTION_DESC_FATSO2B 3 +#define ESE_DZ_TX_TSO_OPTION_DESC_FATSO2A 2 +#define ESE_DZ_TX_TSO_OPTION_DESC_ENCAP 1 +#define ESE_DZ_TX_TSO_OPTION_DESC_NORMAL 0 +#define ESF_DZ_TX_TSO_OUTER_IP_ID_LBN 16 +#define ESF_DZ_TX_TSO_OUTER_IP_ID_WIDTH 16 +#define ESF_DZ_TX_TSO_TCP_MSS_LBN 32 +#define ESF_DZ_TX_TSO_TCP_MSS_WIDTH 16 +#define ESF_DZ_TX_TSO_INNER_PE_CSUM_LBN 0 +#define ESF_DZ_TX_TSO_INNER_PE_CSUM_WIDTH 16 + + /* ES_TX_VLAN_DESC */ #define ESF_DZ_TX_DESC_IS_OPT_LBN 63 #define ESF_DZ_TX_DESC_IS_OPT_WIDTH 1 diff --git a/sys/dev/sfxge/common/efx_regs_mcdi.h b/sys/dev/sfxge/common/efx_regs_mcdi.h index db8651e..a1d76ab 100644 --- a/sys/dev/sfxge/common/efx_regs_mcdi.h +++ b/sys/dev/sfxge/common/efx_regs_mcdi.h @@ -299,6 +299,9 @@ * have already installed filters. See the comment at * MC_CMD_WORKAROUND_BUG26807. */ #define MC_CMD_ERR_FILTERS_PRESENT 0x1014 +/* The clock whose frequency you've attempted to set set + * doesn't exist on this NIC */ +#define MC_CMD_ERR_NO_CLOCK 0x1015 #define MC_CMD_ERR_CODE_OFST 0 @@ -318,9 +321,11 @@ /* Point to the copycode entry point. */ #define SIENA_MC_BOOTROM_COPYCODE_VEC (0x800 - 3 * 0x4) #define HUNT_MC_BOOTROM_COPYCODE_VEC (0x8000 - 3 * 0x4) +#define MEDFORD_MC_BOOTROM_COPYCODE_VEC (0x10000 - 3 * 0x4) /* Points to the recovery mode entry point. */ #define SIENA_MC_BOOTROM_NOFLASH_VEC (0x800 - 2 * 0x4) #define HUNT_MC_BOOTROM_NOFLASH_VEC (0x8000 - 2 * 0x4) +#define MEDFORD_MC_BOOTROM_NOFLASH_VEC (0x10000 - 2 * 0x4) /* The command set exported by the boot ROM (MCDI v0) */ #define MC_CMD_GET_VERSION_V0_SUPPORTED_FUNCS { \ @@ -1456,9 +1461,11 @@ #define MC_CMD_FC_IN_DDR_TEST_START_B1_WIDTH 1 /* MC_CMD_FC_IN_DDR_TEST_POLL msgrequest */ -#define MC_CMD_FC_IN_DDR_TEST_POLL_LEN 8 +#define MC_CMD_FC_IN_DDR_TEST_POLL_LEN 12 #define MC_CMD_FC_IN_DDR_TEST_CMD_OFST 0 /* MC_CMD_FC_IN_DDR_TEST_HEADER_OFST 4 */ +/* Clear previous test result and prepare for restarting DDR test */ +#define MC_CMD_FC_IN_DDR_TEST_POLL_CLEAR_RESULT_FOR_DDR_TEST_OFST 8 /* MC_CMD_FC_IN_GET_ASSERT msgrequest */ #define MC_CMD_FC_IN_GET_ASSERT_LEN 4 @@ -1475,6 +1482,10 @@ #define MC_CMD_FC_IN_FPGA_BUILD_SERVICES 0x2 /* enum: Get the BSP version */ #define MC_CMD_FC_IN_FPGA_BUILD_BSP_VERSION 0x3 +/* enum: Get build register for V2 (SFA974X) */ +#define MC_CMD_FC_IN_FPGA_BUILD_BUILD_V2 0x4 +/* enum: GEt the services register for V2 (SFA974X) */ +#define MC_CMD_FC_IN_FPGA_BUILD_SERVICES_V2 0x5 /* MC_CMD_FC_IN_READ_MAP msgrequest */ #define MC_CMD_FC_IN_READ_MAP_LEN 8 @@ -1832,6 +1843,7 @@ #define MC_CMD_FC_IN_DDR_OP_OFST 4 #define MC_CMD_FC_IN_DDR_SET_SPD 0x0 /* enum */ #define MC_CMD_FC_IN_DDR_GET_STATUS 0x1 /* enum */ +#define MC_CMD_FC_IN_DDR_SET_INFO 0x2 /* enum */ #define MC_CMD_FC_IN_DDR_BANK_OFST 8 #define MC_CMD_FC_IN_DDR_BANK_B0 0x0 /* enum */ #define MC_CMD_FC_IN_DDR_BANK_B1 0x1 /* enum */ @@ -1855,6 +1867,15 @@ /* Page index of the spd data copied into MC_CMD_FC_IN_DDR_SPD */ #define MC_CMD_FC_IN_DDR_SPD_PAGE_ID_OFST 144 +/* MC_CMD_FC_IN_DDR_SET_INFO msgrequest */ +#define MC_CMD_FC_IN_DDR_SET_INFO_LEN 16 +/* MC_CMD_FC_IN_CMD_OFST 0 */ +/* MC_CMD_FC_IN_DDR_OP_OFST 4 */ +/* Affected bank */ +/* MC_CMD_FC_IN_DDR_BANK_OFST 8 */ +/* Size of DDR */ +#define MC_CMD_FC_IN_DDR_SIZE_OFST 12 + /* MC_CMD_FC_IN_DDR_GET_STATUS msgrequest */ #define MC_CMD_FC_IN_DDR_GET_STATUS_LEN 12 /* MC_CMD_FC_IN_CMD_OFST 0 */ @@ -2387,6 +2408,116 @@ #define MC_CMD_FC_OUT_FPGA_BUILD_REVISION_HIGH_LBN 0 #define MC_CMD_FC_OUT_FPGA_BUILD_REVISION_HIGH_WIDTH 16 +/* MC_CMD_FC_OUT_FPGA_BUILD_V2 msgresponse */ +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_LEN 32 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_COMPONENT_INFO_OFST 0 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_IS_APPLICATION_LBN 31 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_IS_APPLICATION_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_IS_LICENSED_LBN 30 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_IS_LICENSED_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_COMPONENT_ID_LBN 16 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_COMPONENT_ID_WIDTH 14 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_VERSION_MAJOR_LBN 12 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_VERSION_MAJOR_WIDTH 4 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_VERSION_MINOR_LBN 4 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_VERSION_MINOR_WIDTH 8 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_BUILD_NUM_LBN 0 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_BUILD_NUM_WIDTH 4 +/* Build timestamp (seconds since epoch) */ +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_TIMESTAMP_OFST 4 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_PARAMETERS_OFST 8 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_PMA_PASSTHROUGH_LBN 31 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_PMA_PASSTHROUGH_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SODIMM2_QDR_DEF_LBN 29 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SODIMM2_QDR_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SODIMM1_QDR_DEF_LBN 28 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SODIMM1_QDR_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_DDR3_ECC_ENABLED_LBN 27 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_DDR3_ECC_ENABLED_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_DISCRETE2_DDR3_DEF_LBN 26 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_DISCRETE2_DDR3_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_DISCRETE1_DDR3_DEF_LBN 25 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_DISCRETE1_DDR3_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SODIMM2_TO_DDR3_DEF_LBN 24 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SODIMM2_TO_DDR3_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SODIMM1_T0_DDR3_DEF_LBN 23 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SODIMM1_T0_DDR3_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_DISCRETE2_RLDRAM_DEF_LBN 22 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_DISCRETE2_RLDRAM_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_DISCRETE1_RLDRAM_DEF_LBN 21 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_DISCRETE1_RLDRAM_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SODIMM2_RLDRAM_DEF_LBN 20 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SODIMM2_RLDRAM_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SODIMM1_RLDRAM_DEF_LBN 19 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SODIMM1_RLDRAM_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_NIC0_3_SPEED_LBN 18 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_NIC0_3_SPEED_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_NIC0_3_SPEED_10G 0x0 /* enum */ +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_NIC0_3_SPEED_40G 0x1 /* enum */ +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP4_7_SPEED_LBN 17 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP4_7_SPEED_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP4_7_SPEED_10G 0x0 /* enum */ +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP4_7_SPEED_40G 0x1 /* enum */ +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP0_3_SPEED_LBN 16 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP0_3_SPEED_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP0_3_SPEED_10G 0x0 /* enum */ +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP0_3_SPEED_40G 0x1 /* enum */ +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP7_DEF_LBN 15 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP7_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP6_DEF_LBN 14 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP6_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP5_DEF_LBN 13 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP5_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP4_DEF_LBN 12 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP4_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP3_DEF_LBN 11 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP3_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP2_DEF_LBN 10 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP2_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP1_DEF_LBN 9 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP1_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP0_DEF_LBN 8 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_SFP0_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_NIC3_DEF_LBN 7 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_NIC3_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_NIC2_DEF_LBN 6 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_NIC2_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_NIC1_DEF_LBN 5 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_NIC1_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_NIC0_DEF_LBN 4 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_NIC0_DEF_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_FPGA_TYPE_LBN 0 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_FPGA_TYPE_WIDTH 4 +#define MC_CMD_FC_FPGA_V2_TYPE_A3 0x0 /* enum */ +#define MC_CMD_FC_FPGA_V2_TYPE_A4 0x1 /* enum */ +#define MC_CMD_FC_FPGA_V2_TYPE_A5 0x2 /* enum */ +#define MC_CMD_FC_FPGA_V2_TYPE_A7 0x3 /* enum */ +#define MC_CMD_FC_FPGA_V2_TYPE_D3 0x8 /* enum */ +#define MC_CMD_FC_FPGA_V2_TYPE_D4 0x9 /* enum */ +#define MC_CMD_FC_FPGA_V2_TYPE_D5 0xa /* enum */ +#define MC_CMD_FC_FPGA_V2_TYPE_D7 0xb /* enum */ +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_IDENTIFIER_OFST 12 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_CHANGESET_LBN 0 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_CHANGESET_WIDTH 16 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_BUILD_FLAG_LBN 16 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_BUILD_FLAG_WIDTH 1 +/* MC_CMD_FC_FPGA_BUILD_FLAG_INTERNAL 0x0 */ +/* MC_CMD_FC_FPGA_BUILD_FLAG_RELEASE 0x1 */ +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_VERSION_HI_OFST 16 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_DEPLOYMENT_VERSION_MINOR_LBN 0 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_DEPLOYMENT_VERSION_MINOR_WIDTH 16 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_DEPLOYMENT_VERSION_MAJOR_LBN 16 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_DEPLOYMENT_VERSION_MAJOR_WIDTH 16 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_VERSION_LO_OFST 20 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_DEPLOYMENT_VERSION_BUILD_LBN 0 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_DEPLOYMENT_VERSION_BUILD_WIDTH 16 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_DEPLOYMENT_VERSION_MICRO_LBN 16 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_DEPLOYMENT_VERSION_MICRO_WIDTH 16 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_REVISION_LO_OFST 24 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_REVISION_HI_OFST 28 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_REVISION_HIGH_LBN 0 +#define MC_CMD_FC_OUT_FPGA_BUILD_V2_REVISION_HIGH_WIDTH 16 + /* MC_CMD_FC_OUT_FPGA_SERVICES msgresponse */ #define MC_CMD_FC_OUT_FPGA_SERVICES_LEN 32 #define MC_CMD_FC_OUT_FPGA_SERVICES_COMPONENT_INFO_OFST 0 @@ -2437,6 +2568,40 @@ #define MC_CMD_FC_OUT_FPGA_SERVICES_REVISION_HIGH_LBN 0 #define MC_CMD_FC_OUT_FPGA_SERVICES_REVISION_HIGH_WIDTH 16 +/* MC_CMD_FC_OUT_FPGA_SERVICES_V2 msgresponse */ +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_LEN 32 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_COMPONENT_INFO_OFST 0 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_IS_APPLICATION_LBN 31 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_IS_APPLICATION_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_IS_LICENSED_LBN 30 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_IS_LICENSED_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_COMPONENT_ID_LBN 16 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_COMPONENT_ID_WIDTH 14 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_VERSION_MAJOR_LBN 12 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_VERSION_MAJOR_WIDTH 4 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_VERSION_MINOR_LBN 4 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_VERSION_MINOR_WIDTH 8 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_BUILD_NUM_LBN 0 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_BUILD_NUM_WIDTH 4 +/* Build timestamp (seconds since epoch) */ +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_TIMESTAMP_OFST 4 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_PARAMETERS_OFST 8 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_PTP_ENABLED_LBN 0 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_PTP_ENABLED_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_FC_FLASH_BOOTED_LBN 8 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_FC_FLASH_BOOTED_WIDTH 1 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_IDENTIFIER_OFST 12 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_CHANGESET_LBN 0 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_CHANGESET_WIDTH 16 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_BUILD_FLAG_LBN 16 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_BUILD_FLAG_WIDTH 1 +/* MC_CMD_FC_FPGA_BUILD_FLAG_INTERNAL 0x0 */ +/* MC_CMD_FC_FPGA_BUILD_FLAG_RELEASE 0x1 */ +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_REVISION_LO_OFST 24 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_REVISION_HI_OFST 28 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_REVISION_HIGH_LBN 0 +#define MC_CMD_FC_OUT_FPGA_SERVICES_V2_REVISION_HIGH_WIDTH 16 + /* MC_CMD_FC_OUT_BSP_VERSION msgresponse */ #define MC_CMD_FC_OUT_BSP_VERSION_LEN 4 /* Qsys system ID */ @@ -2718,6 +2883,9 @@ /* MC_CMD_FC_OUT_DDR_SET_SPD msgresponse */ #define MC_CMD_FC_OUT_DDR_SET_SPD_LEN 0 +/* MC_CMD_FC_OUT_DDR_SET_INFO msgresponse */ +#define MC_CMD_FC_OUT_DDR_SET_INFO_LEN 0 + /* MC_CMD_FC_OUT_DDR_GET_STATUS msgresponse */ #define MC_CMD_FC_OUT_DDR_GET_STATUS_LEN 4 #define MC_CMD_FC_OUT_DDR_GET_STATUS_FLAGS_OFST 0 @@ -3131,6 +3299,8 @@ #define MC_CMD_AOE_OUT_INFO_FPGA_VERSION_OFST 12 /* FPGA type - read from CPLD straps */ #define MC_CMD_AOE_OUT_INFO_FPGA_TYPE_OFST 16 +#define MC_CMD_AOE_OUT_INFO_FPGA_TYPE_A5_C2 0x1 /* enum */ +#define MC_CMD_AOE_OUT_INFO_FPGA_TYPE_A7_C2 0x2 /* enum */ /* FPGA state (debug) */ #define MC_CMD_AOE_OUT_INFO_FPGA_STATE_OFST 20 /* FPGA image - partition from which loaded */ @@ -3144,23 +3314,28 @@ /* Random pieces of information */ #define MC_CMD_AOE_OUT_INFO_FLAGS_OFST 32 /* enum: Power to FPGA supplied by PEG connector, not PCIe bus */ -#define MC_CMD_AOE_OUT_INFO_PEG_POWER 0x1 +#define MC_CMD_AOE_OUT_INFO_PEG_POWER 0x1 /* enum: CPLD apparently good */ -#define MC_CMD_AOE_OUT_INFO_CPLD_GOOD 0x2 +#define MC_CMD_AOE_OUT_INFO_CPLD_GOOD 0x2 /* enum: FPGA working normally */ -#define MC_CMD_AOE_OUT_INFO_FPGA_GOOD 0x4 +#define MC_CMD_AOE_OUT_INFO_FPGA_GOOD 0x4 /* enum: FPGA is powered */ -#define MC_CMD_AOE_OUT_INFO_FPGA_POWER 0x8 +#define MC_CMD_AOE_OUT_INFO_FPGA_POWER 0x8 /* enum: Board has incompatible SODIMMs fitted */ -#define MC_CMD_AOE_OUT_INFO_BAD_SODIMM 0x10 +#define MC_CMD_AOE_OUT_INFO_BAD_SODIMM 0x10 /* enum: Board has ByteBlaster connected */ -#define MC_CMD_AOE_OUT_INFO_HAS_BYTEBLASTER 0x20 -/* Revision of Modena board */ +#define MC_CMD_AOE_OUT_INFO_HAS_BYTEBLASTER 0x20 +/* enum: FPGA Boot flash has an invalid header. */ +#define MC_CMD_AOE_OUT_INFO_FPGA_BAD_BOOT_HDR 0x40 +/* enum: FPGA Application flash is accessible. */ +#define MC_CMD_AOE_OUT_INFO_FPGA_APP_FLASH_GOOD 0x80 +/* Revision of Modena and Sorrento boards. Sorrento can be R1_2 or R1_3. */ #define MC_CMD_AOE_OUT_INFO_BOARD_REVISION_OFST 36 #define MC_CMD_AOE_OUT_INFO_UNKNOWN 0x0 /* enum */ #define MC_CMD_AOE_OUT_INFO_R1_0 0x10 /* enum */ #define MC_CMD_AOE_OUT_INFO_R1_1 0x11 /* enum */ #define MC_CMD_AOE_OUT_INFO_R1_2 0x12 /* enum */ +#define MC_CMD_AOE_OUT_INFO_R1_3 0x13 /* enum */ /* Result of FC booting - not valid while a ByteBlaster is connected. */ #define MC_CMD_AOE_OUT_INFO_FC_BOOT_RESULT_OFST 40 /* enum: No error */ @@ -3931,15 +4106,30 @@ /* MC_CMD_PTP_OUT_GET_TIMESTAMP_CORRECTIONS msgresponse */ #define MC_CMD_PTP_OUT_GET_TIMESTAMP_CORRECTIONS_LEN 16 -/* Uncorrected error on transmit timestamps in NIC clock format */ +/* Uncorrected error on PTP transmit timestamps in NIC clock format */ #define MC_CMD_PTP_OUT_GET_TIMESTAMP_CORRECTIONS_TRANSMIT_OFST 0 -/* Uncorrected error on receive timestamps in NIC clock format */ +/* Uncorrected error on PTP receive timestamps in NIC clock format */ #define MC_CMD_PTP_OUT_GET_TIMESTAMP_CORRECTIONS_RECEIVE_OFST 4 /* Uncorrected error on PPS output in NIC clock format */ #define MC_CMD_PTP_OUT_GET_TIMESTAMP_CORRECTIONS_PPS_OUT_OFST 8 /* Uncorrected error on PPS input in NIC clock format */ #define MC_CMD_PTP_OUT_GET_TIMESTAMP_CORRECTIONS_PPS_IN_OFST 12 +/* MC_CMD_PTP_OUT_GET_TIMESTAMP_CORRECTIONS_V2 msgresponse */ +#define MC_CMD_PTP_OUT_GET_TIMESTAMP_CORRECTIONS_V2_LEN 24 +/* Uncorrected error on PTP transmit timestamps in NIC clock format */ +#define MC_CMD_PTP_OUT_GET_TIMESTAMP_CORRECTIONS_V2_PTP_TX_OFST 0 +/* Uncorrected error on PTP receive timestamps in NIC clock format */ +#define MC_CMD_PTP_OUT_GET_TIMESTAMP_CORRECTIONS_V2_PTP_RX_OFST 4 +/* Uncorrected error on PPS output in NIC clock format */ +#define MC_CMD_PTP_OUT_GET_TIMESTAMP_CORRECTIONS_V2_PPS_OUT_OFST 8 +/* Uncorrected error on PPS input in NIC clock format */ +#define MC_CMD_PTP_OUT_GET_TIMESTAMP_CORRECTIONS_V2_PPS_IN_OFST 12 +/* Uncorrected error on non-PTP transmit timestamps in NIC clock format */ +#define MC_CMD_PTP_OUT_GET_TIMESTAMP_CORRECTIONS_V2_GENERAL_TX_OFST 16 +/* Uncorrected error on non-PTP receive timestamps in NIC clock format */ +#define MC_CMD_PTP_OUT_GET_TIMESTAMP_CORRECTIONS_V2_GENERAL_RX_OFST 20 + /* MC_CMD_PTP_OUT_MANFTEST_PPS msgresponse */ #define MC_CMD_PTP_OUT_MANFTEST_PPS_LEN 4 /* Results of testing */ @@ -5203,7 +5393,7 @@ #define MC_CMD_SET_MAC 0x2c #undef MC_CMD_0x2c_PRIVILEGE_CTG -#define MC_CMD_0x2c_PRIVILEGE_CTG SRIOV_CTG_LINK +#define MC_CMD_0x2c_PRIVILEGE_CTG SRIOV_CTG_GENERAL /* MC_CMD_SET_MAC_IN msgrequest */ #define MC_CMD_SET_MAC_IN_LEN 28 @@ -5950,6 +6140,37 @@ /* amount to read in bytes */ #define MC_CMD_NVRAM_READ_IN_LENGTH_OFST 8 +/* MC_CMD_NVRAM_READ_IN_V2 msgrequest */ +#define MC_CMD_NVRAM_READ_IN_V2_LEN 16 +#define MC_CMD_NVRAM_READ_IN_V2_TYPE_OFST 0 +/* Enum values, see field(s): */ +/* MC_CMD_NVRAM_TYPES/MC_CMD_NVRAM_TYPES_OUT/TYPES */ +#define MC_CMD_NVRAM_READ_IN_V2_OFFSET_OFST 4 +/* amount to read in bytes */ +#define MC_CMD_NVRAM_READ_IN_V2_LENGTH_OFST 8 +/* Optional control info. If a partition is stored with an A/B versioning + * scheme (i.e. in more than one physical partition in NVRAM) the host can set + * this to control which underlying physical partition is used to read data + * from. This allows it to perform a read-modify-write-verify with the write + * lock continuously held by calling NVRAM_UPDATE_START, reading the old + * contents using MODE=TARGET_CURRENT, overwriting the old partition and then + * verifying by reading with MODE=TARGET_BACKUP. + */ +#define MC_CMD_NVRAM_READ_IN_V2_MODE_OFST 12 +/* enum: Same as omitting MODE: caller sees data in current partition unless it + * holds the write lock in which case it sees data in the partition it is + * updating. + */ +#define MC_CMD_NVRAM_READ_IN_V2_DEFAULT 0x0 +/* enum: Read from the current partition of an A/B pair, even if holding the + * write lock. + */ +#define MC_CMD_NVRAM_READ_IN_V2_TARGET_CURRENT 0x1 +/* enum: Read from the non-current (i.e. to be updated) partition of an A/B + * pair + */ +#define MC_CMD_NVRAM_READ_IN_V2_TARGET_BACKUP 0x2 + /* MC_CMD_NVRAM_READ_OUT msgresponse */ #define MC_CMD_NVRAM_READ_OUT_LENMIN 1 #define MC_CMD_NVRAM_READ_OUT_LENMAX 252 @@ -6329,6 +6550,8 @@ #define MC_CMD_SENSOR_PHY0_VCC 0x4c /* enum: Voltage supplied to the QSFP #1 from their power supply: mV */ #define MC_CMD_SENSOR_PHY1_VCC 0x4d +/* enum: Controller die temperature (TDIODE): degC */ +#define MC_CMD_SENSOR_CONTROLLER_TDIODE_TEMP 0x4e /* MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF */ #define MC_CMD_SENSOR_ENTRY_OFST 4 #define MC_CMD_SENSOR_ENTRY_LEN 8 @@ -6406,7 +6629,7 @@ /* MC_CMD_READ_SENSORS_EXT_IN msgrequest */ #define MC_CMD_READ_SENSORS_EXT_IN_LEN 12 -/* DMA address of host buffer for sensor readings */ +/* DMA address of host buffer for sensor readings (must be 4Kbyte aligned). */ #define MC_CMD_READ_SENSORS_EXT_IN_DMA_ADDR_OFST 0 #define MC_CMD_READ_SENSORS_EXT_IN_DMA_ADDR_LEN 8 #define MC_CMD_READ_SENSORS_EXT_IN_DMA_ADDR_LO_OFST 0 @@ -7656,6 +7879,88 @@ #define LICENSED_APP_ID_ID_LBN 0 #define LICENSED_APP_ID_ID_WIDTH 32 +/* LICENSED_FEATURES structuredef */ +#define LICENSED_FEATURES_LEN 8 +/* Bitmask of licensed firmware features */ +#define LICENSED_FEATURES_MASK_OFST 0 +#define LICENSED_FEATURES_MASK_LEN 8 +#define LICENSED_FEATURES_MASK_LO_OFST 0 +#define LICENSED_FEATURES_MASK_HI_OFST 4 +#define LICENSED_FEATURES_RX_CUT_THROUGH_LBN 0 +#define LICENSED_FEATURES_RX_CUT_THROUGH_WIDTH 1 +#define LICENSED_FEATURES_PIO_LBN 1 +#define LICENSED_FEATURES_PIO_WIDTH 1 +#define LICENSED_FEATURES_EVQ_TIMER_LBN 2 +#define LICENSED_FEATURES_EVQ_TIMER_WIDTH 1 +#define LICENSED_FEATURES_CLOCK_LBN 3 +#define LICENSED_FEATURES_CLOCK_WIDTH 1 +#define LICENSED_FEATURES_RX_TIMESTAMPS_LBN 4 +#define LICENSED_FEATURES_RX_TIMESTAMPS_WIDTH 1 +#define LICENSED_FEATURES_TX_TIMESTAMPS_LBN 5 +#define LICENSED_FEATURES_TX_TIMESTAMPS_WIDTH 1 +#define LICENSED_FEATURES_RX_SNIFF_LBN 6 +#define LICENSED_FEATURES_RX_SNIFF_WIDTH 1 +#define LICENSED_FEATURES_TX_SNIFF_LBN 7 +#define LICENSED_FEATURES_TX_SNIFF_WIDTH 1 +#define LICENSED_FEATURES_PROXY_FILTER_OPS_LBN 8 +#define LICENSED_FEATURES_PROXY_FILTER_OPS_WIDTH 1 +#define LICENSED_FEATURES_MASK_LBN 0 +#define LICENSED_FEATURES_MASK_WIDTH 64 + +/* LICENSED_V3_APPS structuredef */ +#define LICENSED_V3_APPS_LEN 8 +/* Bitmask of licensed applications */ +#define LICENSED_V3_APPS_MASK_OFST 0 +#define LICENSED_V3_APPS_MASK_LEN 8 +#define LICENSED_V3_APPS_MASK_LO_OFST 0 +#define LICENSED_V3_APPS_MASK_HI_OFST 4 +#define LICENSED_V3_APPS_ONLOAD_LBN 0 +#define LICENSED_V3_APPS_ONLOAD_WIDTH 1 +#define LICENSED_V3_APPS_PTP_LBN 1 +#define LICENSED_V3_APPS_PTP_WIDTH 1 +#define LICENSED_V3_APPS_SOLARCAPTURE_PRO_LBN 2 +#define LICENSED_V3_APPS_SOLARCAPTURE_PRO_WIDTH 1 +#define LICENSED_V3_APPS_SOLARSECURE_LBN 3 +#define LICENSED_V3_APPS_SOLARSECURE_WIDTH 1 +#define LICENSED_V3_APPS_PERF_MONITOR_LBN 4 +#define LICENSED_V3_APPS_PERF_MONITOR_WIDTH 1 +#define LICENSED_V3_APPS_SOLARCAPTURE_LIVE_LBN 5 +#define LICENSED_V3_APPS_SOLARCAPTURE_LIVE_WIDTH 1 +#define LICENSED_V3_APPS_CAPTURE_SOLARSYSTEM_LBN 6 +#define LICENSED_V3_APPS_CAPTURE_SOLARSYSTEM_WIDTH 1 +#define LICENSED_V3_APPS_NETWORK_ACCESS_CONTROL_LBN 7 +#define LICENSED_V3_APPS_NETWORK_ACCESS_CONTROL_WIDTH 1 +#define LICENSED_V3_APPS_MASK_LBN 0 +#define LICENSED_V3_APPS_MASK_WIDTH 64 + +/* LICENSED_V3_FEATURES structuredef */ +#define LICENSED_V3_FEATURES_LEN 8 +/* Bitmask of licensed firmware features */ +#define LICENSED_V3_FEATURES_MASK_OFST 0 +#define LICENSED_V3_FEATURES_MASK_LEN 8 +#define LICENSED_V3_FEATURES_MASK_LO_OFST 0 +#define LICENSED_V3_FEATURES_MASK_HI_OFST 4 +#define LICENSED_V3_FEATURES_RX_CUT_THROUGH_LBN 0 +#define LICENSED_V3_FEATURES_RX_CUT_THROUGH_WIDTH 1 +#define LICENSED_V3_FEATURES_PIO_LBN 1 +#define LICENSED_V3_FEATURES_PIO_WIDTH 1 +#define LICENSED_V3_FEATURES_EVQ_TIMER_LBN 2 +#define LICENSED_V3_FEATURES_EVQ_TIMER_WIDTH 1 +#define LICENSED_V3_FEATURES_CLOCK_LBN 3 +#define LICENSED_V3_FEATURES_CLOCK_WIDTH 1 +#define LICENSED_V3_FEATURES_RX_TIMESTAMPS_LBN 4 +#define LICENSED_V3_FEATURES_RX_TIMESTAMPS_WIDTH 1 +#define LICENSED_V3_FEATURES_TX_TIMESTAMPS_LBN 5 +#define LICENSED_V3_FEATURES_TX_TIMESTAMPS_WIDTH 1 +#define LICENSED_V3_FEATURES_RX_SNIFF_LBN 6 +#define LICENSED_V3_FEATURES_RX_SNIFF_WIDTH 1 +#define LICENSED_V3_FEATURES_TX_SNIFF_LBN 7 +#define LICENSED_V3_FEATURES_TX_SNIFF_WIDTH 1 +#define LICENSED_V3_FEATURES_PROXY_FILTER_OPS_LBN 8 +#define LICENSED_V3_FEATURES_PROXY_FILTER_OPS_WIDTH 1 +#define LICENSED_V3_FEATURES_MASK_LBN 0 +#define LICENSED_V3_FEATURES_MASK_WIDTH 64 + /* TX_TIMESTAMP_EVENT structuredef */ #define TX_TIMESTAMP_EVENT_LEN 6 /* lower 16 bits of timestamp data */ @@ -8050,6 +8355,8 @@ #define MC_CMD_INIT_TXQ_EXT_IN_FLAG_INNER_IP_CSUM_EN_WIDTH 1 #define MC_CMD_INIT_TXQ_EXT_IN_FLAG_INNER_TCP_CSUM_EN_LBN 11 #define MC_CMD_INIT_TXQ_EXT_IN_FLAG_INNER_TCP_CSUM_EN_WIDTH 1 +#define MC_CMD_INIT_TXQ_EXT_IN_FLAG_TSOV2_EN_LBN 12 +#define MC_CMD_INIT_TXQ_EXT_IN_FLAG_TSOV2_EN_WIDTH 1 /* Owner ID to use if in buffer mode (zero if physical) */ #define MC_CMD_INIT_TXQ_EXT_IN_OWNER_ID_OFST 20 /* The port ID associated with the v-adaptor which should contain this DMAQ. */ @@ -8923,7 +9230,10 @@ /***********************************/ /* MC_CMD_PARSER_DISP_RW - * Direct read/write of parser-dispatcher state (DICPUs and LUE) for debugging + * Direct read/write of parser-dispatcher state (DICPUs and LUE) for debugging. + * Please note that this interface is only of use to debug tools which have + * knowledge of firmware and hardware data structures; nothing here is intended + * for use by normal driver code. */ #define MC_CMD_PARSER_DISP_RW 0xe5 #undef MC_CMD_0xe5_PRIVILEGE_CTG @@ -8942,6 +9252,12 @@ #define MC_CMD_PARSER_DISP_RW_IN_LUE 0x2 /* enum: Lookup engine (with requested metadata format) */ #define MC_CMD_PARSER_DISP_RW_IN_LUE_VERSIONED_METADATA 0x3 +/* enum: RX0 dispatcher CPU (alias for RX_DICPU; Medford has 2 RX DICPUs) */ +#define MC_CMD_PARSER_DISP_RW_IN_RX0_DICPU 0x0 +/* enum: RX1 dispatcher CPU (only valid for Medford) */ +#define MC_CMD_PARSER_DISP_RW_IN_RX1_DICPU 0x4 +/* enum: Miscellaneous other state (only valid for Medford) */ +#define MC_CMD_PARSER_DISP_RW_IN_MISC_STATE 0x5 /* identifies the type of operation requested */ #define MC_CMD_PARSER_DISP_RW_IN_OP_OFST 4 /* enum: read a word of DICPU DMEM or a LUE entry */ @@ -8950,8 +9266,12 @@ #define MC_CMD_PARSER_DISP_RW_IN_WRITE 0x1 /* enum: read-modify-write a word of DICPU DMEM (not valid for LUE) */ #define MC_CMD_PARSER_DISP_RW_IN_RMW 0x2 -/* data memory address or LUE index */ +/* data memory address (DICPU targets) or LUE index (LUE targets) */ #define MC_CMD_PARSER_DISP_RW_IN_ADDRESS_OFST 8 +/* selector (for MISC_STATE target) */ +#define MC_CMD_PARSER_DISP_RW_IN_SELECTOR_OFST 8 +/* enum: Port to datapath mapping */ +#define MC_CMD_PARSER_DISP_RW_IN_PORT_DP_MAPPING 0x1 /* value to write (for DMEM writes) */ #define MC_CMD_PARSER_DISP_RW_IN_DMEM_WRITE_VALUE_OFST 12 /* XOR value (for DMEM read-modify-writes: new = (old & mask) ^ value) */ @@ -8976,6 +9296,12 @@ */ #define MC_CMD_PARSER_DISP_RW_OUT_LUE_MGR_STATE_OFST 20 #define MC_CMD_PARSER_DISP_RW_OUT_LUE_MGR_STATE_LEN 32 +/* datapath(s) used for each port (for MISC_STATE PORT_DP_MAPPING selector) */ +#define MC_CMD_PARSER_DISP_RW_OUT_PORT_DP_MAPPING_OFST 0 +#define MC_CMD_PARSER_DISP_RW_OUT_PORT_DP_MAPPING_LEN 4 +#define MC_CMD_PARSER_DISP_RW_OUT_PORT_DP_MAPPING_NUM 4 +#define MC_CMD_PARSER_DISP_RW_OUT_DP0 0x1 /* enum */ +#define MC_CMD_PARSER_DISP_RW_OUT_DP1 0x2 /* enum */ /***********************************/ @@ -9656,6 +9982,14 @@ #define MC_CMD_GET_CAPABILITIES_OUT_LEN 20 /* First word of flags. */ #define MC_CMD_GET_CAPABILITIES_OUT_FLAGS1_OFST 0 +#define MC_CMD_GET_CAPABILITIES_OUT_VPORT_RECONFIGURE_LBN 3 +#define MC_CMD_GET_CAPABILITIES_OUT_VPORT_RECONFIGURE_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_OUT_TX_STRIPING_LBN 4 +#define MC_CMD_GET_CAPABILITIES_OUT_TX_STRIPING_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_OUT_VADAPTOR_QUERY_LBN 5 +#define MC_CMD_GET_CAPABILITIES_OUT_VADAPTOR_QUERY_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_OUT_EVB_PORT_VLAN_RESTRICT_LBN 6 +#define MC_CMD_GET_CAPABILITIES_OUT_EVB_PORT_VLAN_RESTRICT_WIDTH 1 #define MC_CMD_GET_CAPABILITIES_OUT_DRV_ATTACH_PREBOOT_LBN 7 #define MC_CMD_GET_CAPABILITIES_OUT_DRV_ATTACH_PREBOOT_WIDTH 1 #define MC_CMD_GET_CAPABILITIES_OUT_RX_FORCE_EVENT_MERGING_LBN 8 @@ -9824,6 +10158,200 @@ /* Licensed capabilities */ #define MC_CMD_GET_CAPABILITIES_OUT_LICENSE_CAPABILITIES_OFST 16 +/* MC_CMD_GET_CAPABILITIES_V2_IN msgrequest */ +#define MC_CMD_GET_CAPABILITIES_V2_IN_LEN 0 + +/* MC_CMD_GET_CAPABILITIES_V2_OUT msgresponse */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_LEN 26 +/* First word of flags. */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_FLAGS1_OFST 0 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_VPORT_RECONFIGURE_LBN 3 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_VPORT_RECONFIGURE_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_STRIPING_LBN 4 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_STRIPING_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_VADAPTOR_QUERY_LBN 5 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_VADAPTOR_QUERY_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_EVB_PORT_VLAN_RESTRICT_LBN 6 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_EVB_PORT_VLAN_RESTRICT_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_DRV_ATTACH_PREBOOT_LBN 7 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_DRV_ATTACH_PREBOOT_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_FORCE_EVENT_MERGING_LBN 8 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_FORCE_EVENT_MERGING_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_SET_MAC_ENHANCED_LBN 9 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_SET_MAC_ENHANCED_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_UNKNOWN_UCAST_DST_FILTER_ALWAYS_MULTI_RECIPIENT_LBN 10 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_UNKNOWN_UCAST_DST_FILTER_ALWAYS_MULTI_RECIPIENT_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_VADAPTOR_PERMIT_SET_MAC_WHEN_FILTERS_INSTALLED_LBN 11 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_VADAPTOR_PERMIT_SET_MAC_WHEN_FILTERS_INSTALLED_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_MAC_SECURITY_FILTERING_LBN 12 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_MAC_SECURITY_FILTERING_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_ADDITIONAL_RSS_MODES_LBN 13 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_ADDITIONAL_RSS_MODES_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_QBB_LBN 14 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_QBB_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_PACKED_STREAM_VAR_BUFFERS_LBN 15 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_PACKED_STREAM_VAR_BUFFERS_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_RSS_LIMITED_LBN 16 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_RSS_LIMITED_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_PACKED_STREAM_LBN 17 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_PACKED_STREAM_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_INCLUDE_FCS_LBN 18 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_INCLUDE_FCS_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_VLAN_INSERTION_LBN 19 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_VLAN_INSERTION_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_VLAN_STRIPPING_LBN 20 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_VLAN_STRIPPING_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_TSO_LBN 21 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_TSO_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_PREFIX_LEN_0_LBN 22 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_PREFIX_LEN_0_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_PREFIX_LEN_14_LBN 23 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_PREFIX_LEN_14_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_TIMESTAMP_LBN 24 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_TIMESTAMP_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_BATCHING_LBN 25 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_BATCHING_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_MCAST_FILTER_CHAINING_LBN 26 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_MCAST_FILTER_CHAINING_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_PM_AND_RXDP_COUNTERS_LBN 27 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_PM_AND_RXDP_COUNTERS_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_DISABLE_SCATTER_LBN 28 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_DISABLE_SCATTER_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_MCAST_UDP_LOOPBACK_LBN 29 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_MCAST_UDP_LOOPBACK_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_EVB_LBN 30 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_EVB_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_VXLAN_NVGRE_LBN 31 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_VXLAN_NVGRE_WIDTH 1 +/* RxDPCPU firmware id. */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_DPCPU_FW_ID_OFST 4 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_DPCPU_FW_ID_LEN 2 +/* enum: Standard RXDP firmware */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXDP 0x0 +/* enum: Low latency RXDP firmware */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXDP_LOW_LATENCY 0x1 +/* enum: Packed stream RXDP firmware */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXDP_PACKED_STREAM 0x2 +/* enum: BIST RXDP firmware */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXDP_BIST 0x10a +/* enum: RXDP Test firmware image 1 */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXDP_TEST_FW_TO_MC_CUT_THROUGH 0x101 +/* enum: RXDP Test firmware image 2 */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXDP_TEST_FW_TO_MC_STORE_FORWARD 0x102 +/* enum: RXDP Test firmware image 3 */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXDP_TEST_FW_TO_MC_STORE_FORWARD_FIRST 0x103 +/* enum: RXDP Test firmware image 4 */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXDP_TEST_EVERY_EVENT_BATCHABLE 0x104 +/* enum: RXDP Test firmware image 5 */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXDP_TEST_BACKPRESSURE 0x105 +/* enum: RXDP Test firmware image 6 */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXDP_TEST_FW_PACKET_EDITS 0x106 +/* enum: RXDP Test firmware image 7 */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXDP_TEST_FW_RX_HDR_SPLIT 0x107 +/* enum: RXDP Test firmware image 8 */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXDP_TEST_FW_DISABLE_DL 0x108 +/* enum: RXDP Test firmware image 9 */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXDP_TEST_FW_DOORBELL_DELAY 0x10b +/* TxDPCPU firmware id. */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_DPCPU_FW_ID_OFST 6 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_DPCPU_FW_ID_LEN 2 +/* enum: Standard TXDP firmware */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXDP 0x0 +/* enum: Low latency TXDP firmware */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXDP_LOW_LATENCY 0x1 +/* enum: High packet rate TXDP firmware */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXDP_HIGH_PACKET_RATE 0x3 +/* enum: BIST TXDP firmware */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXDP_BIST 0x12d +/* enum: TXDP Test firmware image 1 */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXDP_TEST_FW_TSO_EDIT 0x101 +/* enum: TXDP Test firmware image 2 */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXDP_TEST_FW_PACKET_EDITS 0x102 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXPD_FW_VERSION_OFST 8 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXPD_FW_VERSION_LEN 2 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXPD_FW_VERSION_REV_LBN 0 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXPD_FW_VERSION_REV_WIDTH 12 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXPD_FW_VERSION_TYPE_LBN 12 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXPD_FW_VERSION_TYPE_WIDTH 4 +/* enum: reserved value - do not use (may indicate alternative interpretation + * of REV field in future) + */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXPD_FW_TYPE_RESERVED 0x0 +/* enum: Trivial RX PD firmware for early Huntington development (Huntington + * development only) + */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXPD_FW_TYPE_FIRST_PKT 0x1 +/* enum: RX PD firmware with approximately Siena-compatible behaviour + * (Huntington development only) + */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXPD_FW_TYPE_SIENA_COMPAT 0x2 +/* enum: Virtual switching (full feature) RX PD production firmware */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXPD_FW_TYPE_VSWITCH 0x3 +/* enum: siena_compat variant RX PD firmware using PM rather than MAC + * (Huntington development only) + */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXPD_FW_TYPE_SIENA_COMPAT_PM 0x4 +/* enum: Low latency RX PD production firmware */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXPD_FW_TYPE_LOW_LATENCY 0x5 +/* enum: Packed stream RX PD production firmware */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXPD_FW_TYPE_PACKED_STREAM 0x6 +/* enum: RX PD firmware handling layer 2 only for high packet rate performance + * tests (Medford development only) + */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXPD_FW_TYPE_LAYER2_PERF 0x7 +/* enum: RX PD firmware for GUE parsing prototype (Medford development only) */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXPD_FW_TYPE_TESTFW_GUE_PROTOTYPE 0xe +/* enum: RX PD firmware parsing but not filtering network overlay tunnel + * encapsulations (Medford development only) + */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_RXPD_FW_TYPE_TESTFW_ENCAP_PARSING_ONLY 0xf +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXPD_FW_VERSION_OFST 10 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXPD_FW_VERSION_LEN 2 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXPD_FW_VERSION_REV_LBN 0 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXPD_FW_VERSION_REV_WIDTH 12 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXPD_FW_VERSION_TYPE_LBN 12 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXPD_FW_VERSION_TYPE_WIDTH 4 +/* enum: reserved value - do not use (may indicate alternative interpretation + * of REV field in future) + */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXPD_FW_TYPE_RESERVED 0x0 +/* enum: Trivial TX PD firmware for early Huntington development (Huntington + * development only) + */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXPD_FW_TYPE_FIRST_PKT 0x1 +/* enum: TX PD firmware with approximately Siena-compatible behaviour + * (Huntington development only) + */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXPD_FW_TYPE_SIENA_COMPAT 0x2 +/* enum: Virtual switching (full feature) TX PD production firmware */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXPD_FW_TYPE_VSWITCH 0x3 +/* enum: siena_compat variant TX PD firmware using PM rather than MAC + * (Huntington development only) + */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXPD_FW_TYPE_SIENA_COMPAT_PM 0x4 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXPD_FW_TYPE_LOW_LATENCY 0x5 /* enum */ +/* enum: TX PD firmware handling layer 2 only for high packet rate performance + * tests (Medford development only) + */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXPD_FW_TYPE_LAYER2_PERF 0x7 +/* enum: RX PD firmware for GUE parsing prototype (Medford development only) */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TXPD_FW_TYPE_TESTFW_GUE_PROTOTYPE 0xe +/* Hardware capabilities of NIC */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_HW_CAPABILITIES_OFST 12 +/* Licensed capabilities */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_LICENSE_CAPABILITIES_OFST 16 +/* Second word of flags. Not present on older firmware (check the length). */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_FLAGS2_OFST 20 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_TSO_V2_LBN 0 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_TSO_V2_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_TSO_V2_ENCAP_LBN 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_TSO_V2_ENCAP_WIDTH 1 +/* Number of FATSOv2 contexts per datapath supported by this NIC. Not present + * on older firmware (check the length). + */ +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_TSO_V2_N_CONTEXTS_OFST 24 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_TSO_V2_N_CONTEXTS_LEN 2 + /***********************************/ /* MC_CMD_V2_EXTN @@ -10545,10 +11073,17 @@ #define MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_LEN 8 /* The handle of the RSS context */ #define MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_RSS_CONTEXT_ID_OFST 0 -/* Hash control flags. The _EN bits are always supported. The _MODE bits only - * work when the firmware reports ADDITIONAL_RSS_MODES in - * MC_CMD_GET_CAPABILITIES and override the _EN bits if any of them are not 0. - * See the RSS_MODE structure for the meaning of the mode bits. +/* Hash control flags. The _EN bits are always supported, but new modes are + * available when ADDITIONAL_RSS_MODES is reported by MC_CMD_GET_CAPABILITIES: + * in this case, the MODE fields may be set to non-zero values, and will take + * effect regardless of the settings of the _EN flags. See the RSS_MODE + * structure for the meaning of the mode bits. Drivers must check the + * capability before trying to set any _MODE fields, as older firmware will + * reject any attempt to set the FLAGS field to a value > 0xff with EINVAL. In + * the case where all the _MODE flags are zero, the _EN flags take effect, + * providing backward compatibility for existing drivers. (Setting all _MODE + * *and* all _EN flags to zero is valid, to disable RSS spreading for that + * particular packet type.) */ #define MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_FLAGS_OFST 4 #define MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_TOEPLITZ_IPV4_EN_LBN 0 @@ -10594,11 +11129,18 @@ /* MC_CMD_RSS_CONTEXT_GET_FLAGS_OUT msgresponse */ #define MC_CMD_RSS_CONTEXT_GET_FLAGS_OUT_LEN 8 -/* Hash control flags. If any _MODE bits are non-zero (which will only be true - * when the firmware reports ADDITIONAL_RSS_MODES) then the _EN bits should be - * disregarded (but are guaranteed to be consistent with the _MODE bits if - * RSS_CONTEXT_SET_FLAGS has never been called for this context since it was - * allocated). +/* Hash control flags. If all _MODE bits are zero (which will always be true + * for older firmware which does not report the ADDITIONAL_RSS_MODES + * capability), the _EN bits report the state. If any _MODE bits are non-zero + * (which will only be true when the firmware reports ADDITIONAL_RSS_MODES) + * then the _EN bits should be disregarded, although the _MODE flags are + * guaranteed to be consistent with the _EN flags for a freshly-allocated RSS + * context and in the case where the _EN flags were used in the SET. This + * provides backward compatibility: old drivers will not be attempting to + * derive any meaning from the _MODE bits (and can never set them to any value + * not representable by the _EN bits); new drivers can always determine the + * mode by looking only at the _MODE bits; the value returned by a GET can + * always be used for a SET regardless of old/new driver vs. old/new firmware. */ #define MC_CMD_RSS_CONTEXT_GET_FLAGS_OUT_FLAGS_OFST 4 #define MC_CMD_RSS_CONTEXT_GET_FLAGS_OUT_TOEPLITZ_IPV4_EN_LBN 0 @@ -11568,32 +12110,38 @@ #define MC_CMD_KR_TUNE_RXEQ_GET_OUT_PARAM_MAXNUM 63 #define MC_CMD_KR_TUNE_RXEQ_GET_OUT_PARAM_ID_LBN 0 #define MC_CMD_KR_TUNE_RXEQ_GET_OUT_PARAM_ID_WIDTH 8 -/* enum: Attenuation (0-15, TBD for Medford) */ +/* enum: Attenuation (0-15, Huntington) */ #define MC_CMD_KR_TUNE_RXEQ_GET_OUT_ATT 0x0 -/* enum: CTLE Boost (0-15, TBD for Medford) */ +/* enum: CTLE Boost (0-15, Huntington) */ #define MC_CMD_KR_TUNE_RXEQ_GET_OUT_BOOST 0x1 -/* enum: Edge DFE Tap1 (0 - max negative, 64 - zero, 127 - max positive, TBD - * for Medford) +/* enum: Edge DFE Tap1 (Huntington - 0 - max negative, 64 - zero, 127 - max + * positive, Medford - 0-31) */ #define MC_CMD_KR_TUNE_RXEQ_GET_OUT_EDFE_TAP1 0x2 -/* enum: Edge DFE Tap2 (0 - max negative, 32 - zero, 63 - max positive, TBD for - * Medford) +/* enum: Edge DFE Tap2 (Huntington - 0 - max negative, 32 - zero, 63 - max + * positive, Medford - 0-31) */ #define MC_CMD_KR_TUNE_RXEQ_GET_OUT_EDFE_TAP2 0x3 -/* enum: Edge DFE Tap3 (0 - max negative, 32 - zero, 63 - max positive, TBD for - * Medford) +/* enum: Edge DFE Tap3 (Huntington - 0 - max negative, 32 - zero, 63 - max + * positive, Medford - 0-16) */ #define MC_CMD_KR_TUNE_RXEQ_GET_OUT_EDFE_TAP3 0x4 -/* enum: Edge DFE Tap4 (0 - max negative, 32 - zero, 63 - max positive, TBD for - * Medford) +/* enum: Edge DFE Tap4 (Huntington - 0 - max negative, 32 - zero, 63 - max + * positive, Medford - 0-16) */ #define MC_CMD_KR_TUNE_RXEQ_GET_OUT_EDFE_TAP4 0x5 -/* enum: Edge DFE Tap5 (0 - max negative, 32 - zero, 63 - max positive, TBD for - * Medford) +/* enum: Edge DFE Tap5 (Huntington - 0 - max negative, 32 - zero, 63 - max + * positive, Medford - 0-16) */ #define MC_CMD_KR_TUNE_RXEQ_GET_OUT_EDFE_TAP5 0x6 -/* enum: Edge DFE DLEV (TBD for Medford) */ +/* enum: Edge DFE DLEV (0-128 for Medford) */ #define MC_CMD_KR_TUNE_RXEQ_GET_OUT_EDFE_DLEV 0x7 +/* enum: Variable Gain Amplifier (0-15, Medford) */ +#define MC_CMD_KR_TUNE_RXEQ_GET_OUT_VGA 0x8 +/* enum: CTLE EQ Capacitor (0-15, Medford) */ +#define MC_CMD_KR_TUNE_RXEQ_GET_OUT_CTLE_EQC 0x9 +/* enum: CTLE EQ Resistor (0-7, Medford) */ +#define MC_CMD_KR_TUNE_RXEQ_GET_OUT_CTLE_EQRES 0xa #define MC_CMD_KR_TUNE_RXEQ_GET_OUT_PARAM_LANE_LBN 8 #define MC_CMD_KR_TUNE_RXEQ_GET_OUT_PARAM_LANE_WIDTH 3 #define MC_CMD_KR_TUNE_RXEQ_GET_OUT_LANE_0 0x0 /* enum */ @@ -11665,26 +12213,32 @@ #define MC_CMD_KR_TUNE_TXEQ_GET_OUT_PARAM_MAXNUM 63 #define MC_CMD_KR_TUNE_TXEQ_GET_OUT_PARAM_ID_LBN 0 #define MC_CMD_KR_TUNE_TXEQ_GET_OUT_PARAM_ID_WIDTH 8 -/* enum: TX Amplitude */ +/* enum: TX Amplitude (Huntington, Medford) */ #define MC_CMD_KR_TUNE_TXEQ_GET_OUT_TX_LEV 0x0 -/* enum: De-Emphasis Tap1 Magnitude (0-7) */ +/* enum: De-Emphasis Tap1 Magnitude (0-7) (Huntington) */ #define MC_CMD_KR_TUNE_TXEQ_GET_OUT_TX_MODE 0x1 /* enum: De-Emphasis Tap1 Fine */ #define MC_CMD_KR_TUNE_TXEQ_GET_OUT_TX_DTLEV 0x2 -/* enum: De-Emphasis Tap2 Magnitude (0-6) */ +/* enum: De-Emphasis Tap2 Magnitude (0-6) (Huntington) */ #define MC_CMD_KR_TUNE_TXEQ_GET_OUT_TX_D2 0x3 -/* enum: De-Emphasis Tap2 Fine */ +/* enum: De-Emphasis Tap2 Fine (Huntington) */ #define MC_CMD_KR_TUNE_TXEQ_GET_OUT_TX_D2TLEV 0x4 -/* enum: Pre-Emphasis Magnitude */ +/* enum: Pre-Emphasis Magnitude (Huntington) */ #define MC_CMD_KR_TUNE_TXEQ_GET_OUT_TX_E 0x5 -/* enum: Pre-Emphasis Fine */ +/* enum: Pre-Emphasis Fine (Huntington) */ #define MC_CMD_KR_TUNE_TXEQ_GET_OUT_TX_ETLEV 0x6 -/* enum: TX Slew Rate Coarse control */ +/* enum: TX Slew Rate Coarse control (Huntington) */ #define MC_CMD_KR_TUNE_TXEQ_GET_OUT_TX_PREDRV_DLY 0x7 -/* enum: TX Slew Rate Fine control */ +/* enum: TX Slew Rate Fine control (Huntington) */ #define MC_CMD_KR_TUNE_TXEQ_GET_OUT_TX_SR_SET 0x8 -/* enum: TX Termination Impedance control */ +/* enum: TX Termination Impedance control (Huntington) */ #define MC_CMD_KR_TUNE_TXEQ_GET_OUT_TX_RT_SET 0x9 +/* enum: TX Amplitude Fine control (Medford) */ +#define MC_CMD_KR_TUNE_TXEQ_GET_OUT_TX_LEV_FINE 0xa +/* enum: Pre-shoot Tap (Medford) */ +#define MC_CMD_KR_TUNE_TXEQ_GET_OUT_TAP_ADV 0xb +/* enum: De-emphasis Tap (Medford) */ +#define MC_CMD_KR_TUNE_TXEQ_GET_OUT_TAP_DLY 0xc #define MC_CMD_KR_TUNE_TXEQ_GET_OUT_PARAM_LANE_LBN 8 #define MC_CMD_KR_TUNE_TXEQ_GET_OUT_PARAM_LANE_WIDTH 3 #define MC_CMD_KR_TUNE_TXEQ_GET_OUT_LANE_0 0x0 /* enum */ @@ -11871,8 +12425,12 @@ #define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_DFE_DLEV 0x7 /* enum: Figure of Merit */ #define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_FOM 0x8 +/* enum: CTLE EQ Capacitor (HF Gain) */ +#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_CTLE_EQC 0x9 +/* enum: CTLE EQ Resistor (DC Gain) */ +#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_CTLE_EQRES 0xa #define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_PARAM_LANE_LBN 8 -#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_PARAM_LANE_WIDTH 4 +#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_PARAM_LANE_WIDTH 5 #define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_0 0x0 /* enum */ #define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_1 0x1 /* enum */ #define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_2 0x2 /* enum */ @@ -11881,12 +12439,57 @@ #define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_5 0x5 /* enum */ #define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_6 0x6 /* enum */ #define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_7 0x7 /* enum */ -#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_ALL 0x8 /* enum */ -#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_RESERVED_LBN 12 -#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_RESERVED_WIDTH 12 +#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_8 0x8 /* enum */ +#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_9 0x9 /* enum */ +#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_10 0xa /* enum */ +#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_11 0xb /* enum */ +#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_12 0xc /* enum */ +#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_13 0xd /* enum */ +#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_14 0xe /* enum */ +#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_15 0xf /* enum */ +#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_ALL 0x10 /* enum */ +#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_PARAM_AUTOCAL_LBN 13 +#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_PARAM_AUTOCAL_WIDTH 1 +#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_RESERVED_LBN 14 +#define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_RESERVED_WIDTH 10 #define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_PARAM_CURRENT_LBN 24 #define MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_PARAM_CURRENT_WIDTH 8 +/* MC_CMD_PCIE_TUNE_RXEQ_SET_IN msgrequest */ +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_LENMIN 8 +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_LENMAX 252 +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_LEN(num) (4+4*(num)) +/* Requested operation */ +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_PCIE_TUNE_OP_OFST 0 +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_PCIE_TUNE_OP_LEN 1 +/* Align the arguments to 32 bits */ +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_PCIE_TUNE_RSVD_OFST 1 +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_PCIE_TUNE_RSVD_LEN 3 +/* RXEQ Parameter */ +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_PARAM_OFST 4 +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_PARAM_LEN 4 +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_PARAM_MINNUM 1 +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_PARAM_MAXNUM 62 +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_PARAM_ID_LBN 0 +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_PARAM_ID_WIDTH 8 +/* Enum values, see field(s): */ +/* MC_CMD_PCIE_TUNE_RXEQ_GET_OUT/PARAM_ID */ +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_PARAM_LANE_LBN 8 +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_PARAM_LANE_WIDTH 5 +/* Enum values, see field(s): */ +/* MC_CMD_PCIE_TUNE_RXEQ_GET_OUT/PARAM_LANE */ +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_PARAM_AUTOCAL_LBN 13 +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_PARAM_AUTOCAL_WIDTH 1 +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_RESERVED_LBN 14 +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_RESERVED_WIDTH 2 +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_PARAM_INITIAL_LBN 16 +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_PARAM_INITIAL_WIDTH 8 +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_RESERVED2_LBN 24 +#define MC_CMD_PCIE_TUNE_RXEQ_SET_IN_RESERVED2_WIDTH 8 + +/* MC_CMD_PCIE_TUNE_RXEQ_SET_OUT msgresponse */ +#define MC_CMD_PCIE_TUNE_RXEQ_SET_OUT_LEN 0 + /* MC_CMD_PCIE_TUNE_TXEQ_GET_IN msgrequest */ #define MC_CMD_PCIE_TUNE_TXEQ_GET_IN_LEN 4 /* Requested operation */ @@ -11961,6 +12564,7 @@ /***********************************/ /* MC_CMD_LICENSING * Operations on the NVRAM_PARTITION_TYPE_LICENSE application license partition + * - not used for V3 licensing */ #define MC_CMD_LICENSING 0xf3 #undef MC_CMD_0xf3_PRIVILEGE_CTG @@ -12006,6 +12610,95 @@ /***********************************/ +/* MC_CMD_LICENSING_V3 + * Operations on the NVRAM_PARTITION_TYPE_LICENSE application license partition + * - V3 licensing (Medford) + */ +#define MC_CMD_LICENSING_V3 0xd0 +#undef MC_CMD_0xd0_PRIVILEGE_CTG + +#define MC_CMD_0xd0_PRIVILEGE_CTG SRIOV_CTG_GENERAL + +/* MC_CMD_LICENSING_V3_IN msgrequest */ +#define MC_CMD_LICENSING_V3_IN_LEN 4 +/* identifies the type of operation requested */ +#define MC_CMD_LICENSING_V3_IN_OP_OFST 0 +/* enum: re-read and apply licenses after a license key partition update; note + * that this operation returns a zero-length response + */ +#define MC_CMD_LICENSING_V3_IN_OP_UPDATE_LICENSE 0x0 +/* enum: report counts of installed licenses */ +#define MC_CMD_LICENSING_V3_IN_OP_REPORT_LICENSE 0x1 + +/* MC_CMD_LICENSING_V3_OUT msgresponse */ +#define MC_CMD_LICENSING_V3_OUT_LEN 88 +/* count of keys which are valid */ +#define MC_CMD_LICENSING_V3_OUT_VALID_KEYS_OFST 0 +/* sum of UNVERIFIABLE_KEYS + WRONG_NODE_KEYS (for compatibility with + * MC_CMD_FC_OP_LICENSE) + */ +#define MC_CMD_LICENSING_V3_OUT_INVALID_KEYS_OFST 4 +/* count of keys which are invalid due to being unverifiable */ +#define MC_CMD_LICENSING_V3_OUT_UNVERIFIABLE_KEYS_OFST 8 +/* count of keys which are invalid due to being for the wrong node */ +#define MC_CMD_LICENSING_V3_OUT_WRONG_NODE_KEYS_OFST 12 +/* licensing state (for diagnostics; the exact meaning of the bits in this + * field are private to the firmware) + */ +#define MC_CMD_LICENSING_V3_OUT_LICENSING_STATE_OFST 16 +/* licensing subsystem self-test report (for manftest) */ +#define MC_CMD_LICENSING_V3_OUT_LICENSING_SELF_TEST_OFST 20 +/* enum: licensing subsystem self-test failed */ +#define MC_CMD_LICENSING_V3_OUT_SELF_TEST_FAIL 0x0 +/* enum: licensing subsystem self-test passed */ +#define MC_CMD_LICENSING_V3_OUT_SELF_TEST_PASS 0x1 +/* bitmask of licensed applications */ +#define MC_CMD_LICENSING_V3_OUT_LICENSED_APPS_OFST 24 +#define MC_CMD_LICENSING_V3_OUT_LICENSED_APPS_LEN 8 +#define MC_CMD_LICENSING_V3_OUT_LICENSED_APPS_LO_OFST 24 +#define MC_CMD_LICENSING_V3_OUT_LICENSED_APPS_HI_OFST 28 +/* reserved for future use */ +#define MC_CMD_LICENSING_V3_OUT_RESERVED_0_OFST 32 +#define MC_CMD_LICENSING_V3_OUT_RESERVED_0_LEN 24 +/* bitmask of licensed features */ +#define MC_CMD_LICENSING_V3_OUT_LICENSED_FEATURES_OFST 56 +#define MC_CMD_LICENSING_V3_OUT_LICENSED_FEATURES_LEN 8 +#define MC_CMD_LICENSING_V3_OUT_LICENSED_FEATURES_LO_OFST 56 +#define MC_CMD_LICENSING_V3_OUT_LICENSED_FEATURES_HI_OFST 60 +/* reserved for future use */ +#define MC_CMD_LICENSING_V3_OUT_RESERVED_1_OFST 64 +#define MC_CMD_LICENSING_V3_OUT_RESERVED_1_LEN 24 + + +/***********************************/ +/* MC_CMD_LICENSING_GET_ID_V3 + * Get ID and type from the NVRAM_PARTITION_TYPE_LICENSE application license + * partition - V3 licensing (Medford) + */ +#define MC_CMD_LICENSING_GET_ID_V3 0xd1 +#undef MC_CMD_0xd1_PRIVILEGE_CTG + +#define MC_CMD_0xd1_PRIVILEGE_CTG SRIOV_CTG_GENERAL + +/* MC_CMD_LICENSING_GET_ID_V3_IN msgrequest */ +#define MC_CMD_LICENSING_GET_ID_V3_IN_LEN 0 + +/* MC_CMD_LICENSING_GET_ID_V3_OUT msgresponse */ +#define MC_CMD_LICENSING_GET_ID_V3_OUT_LENMIN 8 +#define MC_CMD_LICENSING_GET_ID_V3_OUT_LENMAX 252 +#define MC_CMD_LICENSING_GET_ID_V3_OUT_LEN(num) (8+1*(num)) +/* type of license (eg 3) */ +#define MC_CMD_LICENSING_GET_ID_V3_OUT_LICENSE_TYPE_OFST 0 +/* length of the license ID (in bytes) */ +#define MC_CMD_LICENSING_GET_ID_V3_OUT_LICENSE_ID_LENGTH_OFST 4 +/* the unique license ID of the adapter */ +#define MC_CMD_LICENSING_GET_ID_V3_OUT_LICENSE_ID_OFST 8 +#define MC_CMD_LICENSING_GET_ID_V3_OUT_LICENSE_ID_LEN 1 +#define MC_CMD_LICENSING_GET_ID_V3_OUT_LICENSE_ID_MINNUM 0 +#define MC_CMD_LICENSING_GET_ID_V3_OUT_LICENSE_ID_MAXNUM 244 + + +/***********************************/ /* MC_CMD_MC2MC_PROXY * Execute an arbitrary MCDI command on the slave MC of a dual-core device. * This will fail on a single-core system. @@ -12026,7 +12719,7 @@ /* MC_CMD_GET_LICENSED_APP_STATE * Query the state of an individual licensed application. (Note that the actual * state may be invalidated by the MC_CMD_LICENSING OP_UPDATE_LICENSE operation - * or a reboot of the MC.) + * or a reboot of the MC.) Not used for V3 licensing */ #define MC_CMD_GET_LICENSED_APP_STATE 0xf5 #undef MC_CMD_0xf5_PRIVILEGE_CTG @@ -12049,8 +12742,70 @@ /***********************************/ +/* MC_CMD_GET_LICENSED_V3_APP_STATE + * Query the state of an individual licensed application. (Note that the actual + * state may be invalidated by the MC_CMD_LICENSING_V3 OP_UPDATE_LICENSE + * operation or a reboot of the MC.) Used for V3 licensing (Medford) + */ +#define MC_CMD_GET_LICENSED_V3_APP_STATE 0xd2 +#undef MC_CMD_0xd2_PRIVILEGE_CTG + +#define MC_CMD_0xd2_PRIVILEGE_CTG SRIOV_CTG_GENERAL + +/* MC_CMD_GET_LICENSED_V3_APP_STATE_IN msgrequest */ +#define MC_CMD_GET_LICENSED_V3_APP_STATE_IN_LEN 8 +/* application ID to query (LICENSED_V3_APPS_xxx) expressed as a single bit + * mask + */ +#define MC_CMD_GET_LICENSED_V3_APP_STATE_IN_APP_ID_OFST 0 +#define MC_CMD_GET_LICENSED_V3_APP_STATE_IN_APP_ID_LEN 8 +#define MC_CMD_GET_LICENSED_V3_APP_STATE_IN_APP_ID_LO_OFST 0 +#define MC_CMD_GET_LICENSED_V3_APP_STATE_IN_APP_ID_HI_OFST 4 + +/* MC_CMD_GET_LICENSED_V3_APP_STATE_OUT msgresponse */ +#define MC_CMD_GET_LICENSED_V3_APP_STATE_OUT_LEN 4 +/* state of this application */ +#define MC_CMD_GET_LICENSED_V3_APP_STATE_OUT_STATE_OFST 0 +/* enum: no (or invalid) license is present for the application */ +#define MC_CMD_GET_LICENSED_V3_APP_STATE_OUT_NOT_LICENSED 0x0 +/* enum: a valid license is present for the application */ +#define MC_CMD_GET_LICENSED_V3_APP_STATE_OUT_LICENSED 0x1 + + +/***********************************/ +/* MC_CMD_GET_LICENSED_V3_FEATURE_STATES + * Query the state of an one or more licensed features. (Note that the actual + * state may be invalidated by the MC_CMD_LICENSING_V3 OP_UPDATE_LICENSE + * operation or a reboot of the MC.) Used for V3 licensing (Medford) + */ +#define MC_CMD_GET_LICENSED_V3_FEATURE_STATES 0xd3 +#undef MC_CMD_0xd3_PRIVILEGE_CTG + +#define MC_CMD_0xd3_PRIVILEGE_CTG SRIOV_CTG_GENERAL + +/* MC_CMD_GET_LICENSED_V3_FEATURE_STATES_IN msgrequest */ +#define MC_CMD_GET_LICENSED_V3_FEATURE_STATES_IN_LEN 8 +/* features to query (LICENSED_V3_FEATURES_xxx) expressed as a mask with one or + * more bits set + */ +#define MC_CMD_GET_LICENSED_V3_FEATURE_STATES_IN_FEATURES_OFST 0 +#define MC_CMD_GET_LICENSED_V3_FEATURE_STATES_IN_FEATURES_LEN 8 +#define MC_CMD_GET_LICENSED_V3_FEATURE_STATES_IN_FEATURES_LO_OFST 0 +#define MC_CMD_GET_LICENSED_V3_FEATURE_STATES_IN_FEATURES_HI_OFST 4 + +/* MC_CMD_GET_LICENSED_V3_FEATURE_STATES_OUT msgresponse */ +#define MC_CMD_GET_LICENSED_V3_FEATURE_STATES_OUT_LEN 8 +/* states of these features - bit set for licensed, clear for not licensed */ +#define MC_CMD_GET_LICENSED_V3_FEATURE_STATES_OUT_STATES_OFST 0 +#define MC_CMD_GET_LICENSED_V3_FEATURE_STATES_OUT_STATES_LEN 8 +#define MC_CMD_GET_LICENSED_V3_FEATURE_STATES_OUT_STATES_LO_OFST 0 +#define MC_CMD_GET_LICENSED_V3_FEATURE_STATES_OUT_STATES_HI_OFST 4 + + +/***********************************/ /* MC_CMD_LICENSED_APP_OP - * Perform an action for an individual licensed application. + * Perform an action for an individual licensed application - not used for V3 + * licensing. */ #define MC_CMD_LICENSED_APP_OP 0xf6 #undef MC_CMD_0xf6_PRIVILEGE_CTG @@ -12117,6 +12872,69 @@ /***********************************/ +/* MC_CMD_LICENSED_V3_VALIDATE_APP + * Perform validation for an individual licensed application - V3 licensing + * (Medford) + */ +#define MC_CMD_LICENSED_V3_VALIDATE_APP 0xd4 +#undef MC_CMD_0xd4_PRIVILEGE_CTG + +#define MC_CMD_0xd4_PRIVILEGE_CTG SRIOV_CTG_GENERAL + +/* MC_CMD_LICENSED_V3_VALIDATE_APP_IN msgrequest */ +#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_LEN 72 +/* application ID expressed as a single bit mask */ +#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_APP_ID_OFST 0 +#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_APP_ID_LEN 8 +#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_APP_ID_LO_OFST 0 +#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_APP_ID_HI_OFST 4 +/* challenge for validation */ +#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_CHALLENGE_OFST 8 +#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_CHALLENGE_LEN 64 + +/* MC_CMD_LICENSED_V3_VALIDATE_APP_OUT msgresponse */ +#define MC_CMD_LICENSED_V3_VALIDATE_APP_OUT_LEN 72 +/* application expiry time */ +#define MC_CMD_LICENSED_V3_VALIDATE_APP_OUT_EXPIRY_TIME_OFST 0 +/* application expiry units */ +#define MC_CMD_LICENSED_V3_VALIDATE_APP_OUT_EXPIRY_UNITS_OFST 4 +/* enum: expiry units are accounting units */ +#define MC_CMD_LICENSED_V3_VALIDATE_APP_OUT_EXPIRY_UNIT_ACC 0x0 +/* enum: expiry units are calendar days */ +#define MC_CMD_LICENSED_V3_VALIDATE_APP_OUT_EXPIRY_UNIT_DAYS 0x1 +/* validation response to challenge */ +#define MC_CMD_LICENSED_V3_VALIDATE_APP_OUT_RESPONSE_OFST 8 +#define MC_CMD_LICENSED_V3_VALIDATE_APP_OUT_RESPONSE_LEN 64 + + +/***********************************/ +/* MC_CMD_LICENSED_V3_MASK_FEATURES + * Mask features - V3 licensing (Medford) + */ +#define MC_CMD_LICENSED_V3_MASK_FEATURES 0xd5 +#undef MC_CMD_0xd5_PRIVILEGE_CTG + +#define MC_CMD_0xd5_PRIVILEGE_CTG SRIOV_CTG_GENERAL + +/* MC_CMD_LICENSED_V3_MASK_FEATURES_IN msgrequest */ +#define MC_CMD_LICENSED_V3_MASK_FEATURES_IN_LEN 12 +/* mask to be applied to features to be changed */ +#define MC_CMD_LICENSED_V3_MASK_FEATURES_IN_MASK_OFST 0 +#define MC_CMD_LICENSED_V3_MASK_FEATURES_IN_MASK_LEN 8 +#define MC_CMD_LICENSED_V3_MASK_FEATURES_IN_MASK_LO_OFST 0 +#define MC_CMD_LICENSED_V3_MASK_FEATURES_IN_MASK_HI_OFST 4 +/* whether to turn on or turn off the masked features */ +#define MC_CMD_LICENSED_V3_MASK_FEATURES_IN_FLAG_OFST 8 +/* enum: turn the features off */ +#define MC_CMD_LICENSED_V3_MASK_FEATURES_IN_OFF 0x0 +/* enum: turn the features back on */ +#define MC_CMD_LICENSED_V3_MASK_FEATURES_IN_ON 0x1 + +/* MC_CMD_LICENSED_V3_MASK_FEATURES_OUT msgresponse */ +#define MC_CMD_LICENSED_V3_MASK_FEATURES_OUT_LEN 0 + + +/***********************************/ /* MC_CMD_SET_PORT_SNIFF_CONFIG * Configure RX port sniffing for the physical port associated with the calling * function. Only a privileged function may change the port sniffing diff --git a/sys/dev/sfxge/common/efx_rx.c b/sys/dev/sfxge/common/efx_rx.c index 2481c86..a0b143f 100644 --- a/sys/dev/sfxge/common/efx_rx.c +++ b/sys/dev/sfxge/common/efx_rx.c @@ -31,10 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" -#include "efx_regs.h" #include "efx_impl.h" @@ -48,14 +45,6 @@ static void falconsiena_rx_fini( __in efx_nic_t *enp); -#if EFSYS_OPT_RX_HDR_SPLIT -static __checkReturn efx_rc_t -falconsiena_rx_hdr_split_enable( - __in efx_nic_t *enp, - __in unsigned int hdr_buf_size, - __in unsigned int pld_buf_size); -#endif /* EFSYS_OPT_RX_HDR_SPLIT */ - #if EFSYS_OPT_RX_SCATTER static __checkReturn efx_rc_t falconsiena_rx_scatter_enable( @@ -83,6 +72,18 @@ falconsiena_rx_scale_tbl_set( __in_ecount(n) unsigned int *table, __in size_t n); +static __checkReturn uint32_t +falconsiena_rx_prefix_hash( + __in efx_nic_t *enp, + __in efx_rx_hash_alg_t func, + __in uint8_t *buffer); + +static __checkReturn efx_rc_t +falconsiena_rx_prefix_pktlen( + __in efx_nic_t *enp, + __in uint8_t *buffer, + __out uint16_t *lengthp); + #endif /* EFSYS_OPT_RX_SCALE */ static void @@ -131,9 +132,6 @@ falconsiena_rx_qdestroy( static efx_rx_ops_t __efx_rx_falcon_ops = { falconsiena_rx_init, /* erxo_init */ falconsiena_rx_fini, /* erxo_fini */ -#if EFSYS_OPT_RX_HDR_SPLIT - falconsiena_rx_hdr_split_enable, /* erxo_hdr_split_enable */ -#endif #if EFSYS_OPT_RX_SCATTER falconsiena_rx_scatter_enable, /* erxo_scatter_enable */ #endif @@ -141,7 +139,9 @@ static efx_rx_ops_t __efx_rx_falcon_ops = { falconsiena_rx_scale_mode_set, /* erxo_scale_mode_set */ falconsiena_rx_scale_key_set, /* erxo_scale_key_set */ falconsiena_rx_scale_tbl_set, /* erxo_scale_tbl_set */ + falconsiena_rx_prefix_hash, /* erxo_prefix_hash */ #endif + falconsiena_rx_prefix_pktlen, /* erxo_prefix_pktlen */ falconsiena_rx_qpost, /* erxo_qpost */ falconsiena_rx_qpush, /* erxo_qpush */ falconsiena_rx_qflush, /* erxo_qflush */ @@ -155,9 +155,6 @@ static efx_rx_ops_t __efx_rx_falcon_ops = { static efx_rx_ops_t __efx_rx_siena_ops = { falconsiena_rx_init, /* erxo_init */ falconsiena_rx_fini, /* erxo_fini */ -#if EFSYS_OPT_RX_HDR_SPLIT - falconsiena_rx_hdr_split_enable, /* erxo_hdr_split_enable */ -#endif #if EFSYS_OPT_RX_SCATTER falconsiena_rx_scatter_enable, /* erxo_scatter_enable */ #endif @@ -165,7 +162,9 @@ static efx_rx_ops_t __efx_rx_siena_ops = { falconsiena_rx_scale_mode_set, /* erxo_scale_mode_set */ falconsiena_rx_scale_key_set, /* erxo_scale_key_set */ falconsiena_rx_scale_tbl_set, /* erxo_scale_tbl_set */ + falconsiena_rx_prefix_hash, /* erxo_prefix_hash */ #endif + falconsiena_rx_prefix_pktlen, /* erxo_prefix_pktlen */ falconsiena_rx_qpost, /* erxo_qpost */ falconsiena_rx_qpush, /* erxo_qpush */ falconsiena_rx_qflush, /* erxo_qflush */ @@ -175,29 +174,28 @@ static efx_rx_ops_t __efx_rx_siena_ops = { }; #endif /* EFSYS_OPT_SIENA */ -#if EFSYS_OPT_HUNTINGTON -static efx_rx_ops_t __efx_rx_hunt_ops = { - hunt_rx_init, /* erxo_init */ - hunt_rx_fini, /* erxo_fini */ -#if EFSYS_OPT_RX_HDR_SPLIT - hunt_rx_hdr_split_enable, /* erxo_hdr_split_enable */ -#endif +#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD +static efx_rx_ops_t __efx_rx_ef10_ops = { + ef10_rx_init, /* erxo_init */ + ef10_rx_fini, /* erxo_fini */ #if EFSYS_OPT_RX_SCATTER - hunt_rx_scatter_enable, /* erxo_scatter_enable */ + ef10_rx_scatter_enable, /* erxo_scatter_enable */ #endif #if EFSYS_OPT_RX_SCALE - hunt_rx_scale_mode_set, /* erxo_scale_mode_set */ - hunt_rx_scale_key_set, /* erxo_scale_key_set */ - hunt_rx_scale_tbl_set, /* erxo_scale_tbl_set */ + ef10_rx_scale_mode_set, /* erxo_scale_mode_set */ + ef10_rx_scale_key_set, /* erxo_scale_key_set */ + ef10_rx_scale_tbl_set, /* erxo_scale_tbl_set */ + ef10_rx_prefix_hash, /* erxo_prefix_hash */ #endif - hunt_rx_qpost, /* erxo_qpost */ - hunt_rx_qpush, /* erxo_qpush */ - hunt_rx_qflush, /* erxo_qflush */ - hunt_rx_qenable, /* erxo_qenable */ - hunt_rx_qcreate, /* erxo_qcreate */ - hunt_rx_qdestroy, /* erxo_qdestroy */ + ef10_rx_prefix_pktlen, /* erxo_prefix_pktlen */ + ef10_rx_qpost, /* erxo_qpost */ + ef10_rx_qpush, /* erxo_qpush */ + ef10_rx_qflush, /* erxo_qflush */ + ef10_rx_qenable, /* erxo_qenable */ + ef10_rx_qcreate, /* erxo_qcreate */ + ef10_rx_qdestroy, /* erxo_qdestroy */ }; -#endif /* EFSYS_OPT_HUNTINGTON */ +#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ __checkReturn efx_rc_t @@ -235,10 +233,16 @@ efx_rx_init( #if EFSYS_OPT_HUNTINGTON case EFX_FAMILY_HUNTINGTON: - erxop = (efx_rx_ops_t *)&__efx_rx_hunt_ops; + erxop = (efx_rx_ops_t *)&__efx_rx_ef10_ops; break; #endif /* EFSYS_OPT_HUNTINGTON */ +#if EFSYS_OPT_MEDFORD + case EFX_FAMILY_MEDFORD: + erxop = (efx_rx_ops_t *)&__efx_rx_ef10_ops; + break; +#endif /* EFSYS_OPT_MEDFORD */ + default: EFSYS_ASSERT(0); rc = ENOTSUP; @@ -283,32 +287,6 @@ efx_rx_fini( enp->en_mod_flags &= ~EFX_MOD_RX; } -#if EFSYS_OPT_RX_HDR_SPLIT - __checkReturn efx_rc_t -efx_rx_hdr_split_enable( - __in efx_nic_t *enp, - __in unsigned int hdr_buf_size, - __in unsigned int pld_buf_size) -{ - efx_rx_ops_t *erxop = enp->en_erxop; - efx_rc_t rc; - - EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); - EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_RX); - EFSYS_ASSERT3U(enp->en_family, >=, EFX_FAMILY_SIENA); - - if ((rc = erxop->erxo_hdr_split_enable(enp, hdr_buf_size, - pld_buf_size)) != 0) - goto fail1; - - return (0); - -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - return (rc); -} -#endif /* EFSYS_OPT_RX_HDR_SPLIT */ - #if EFSYS_OPT_RX_SCATTER __checkReturn efx_rc_t efx_rx_scatter_enable( @@ -590,90 +568,29 @@ efx_rx_qdestroy( erxop->erxo_qdestroy(erp); } -/* - * Psuedo-header info for Siena/Falcon. - * - * The psuedo-header is a byte array of one of the forms: - * - * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - * XX.XX.XX.XX.XX.XX.XX.XX.XX.XX.XX.XX.TT.TT.TT.TT - * XX.XX.XX.XX.XX.XX.XX.XX.XX.XX.XX.XX.XX.XX.LL.LL - * - * where: - * - * TT.TT.TT.TT is a 32-bit Toeplitz hash - * LL.LL is a 16-bit LFSR hash - * - * Hash values are in network (big-endian) byte order. - * - * - * On Huntington the pseudo-header is laid out as: - * (See also SF-109306-TC section 9) - * - * Toeplitz hash (32 bits, little-endian) - * Out-of-band outer VLAN tag - * (16 bits, big-endian, 0 if the packet did not have an outer VLAN tag) - * Out-of-band inner VLAN tag - * (16 bits, big-endian, 0 if the packet did not have an inner VLAN tag) - * Packet length (16 bits, little-endian, may be 0) - * MAC timestamp (32 bits, little-endian, may be 0) - * VLAN tag - * (16 bits, big-endian, 0 if the packet did not have an outer VLAN tag) - * VLAN tag - * (16 bits, big-endian, 0 if the packet did not have an inner VLAN tag) - */ - __checkReturn efx_rc_t efx_psuedo_hdr_pkt_length_get( __in efx_nic_t *enp, __in uint8_t *buffer, - __out uint16_t *pkt_lengthp) + __out uint16_t *lengthp) { - if (enp->en_family != EFX_FAMILY_HUNTINGTON) { - EFSYS_ASSERT(0); - return (ENOTSUP); - } - - *pkt_lengthp = buffer[8] | (buffer[9] << 8); + efx_rx_ops_t *erxop = enp->en_erxop; - return (0); + return (erxop->erxo_prefix_pktlen(enp, buffer, lengthp)); } #if EFSYS_OPT_RX_SCALE - -uint32_t + __checkReturn uint32_t efx_psuedo_hdr_hash_get( __in efx_nic_t *enp, __in efx_rx_hash_alg_t func, __in uint8_t *buffer) { - if (func == EFX_RX_HASHALG_TOEPLITZ) { - switch (enp->en_family) { - case EFX_FAMILY_FALCON: - case EFX_FAMILY_SIENA: - return ((buffer[12] << 24) | - (buffer[13] << 16) | - (buffer[14] << 8) | - buffer[15]); - case EFX_FAMILY_HUNTINGTON: - return (buffer[0] | - (buffer[1] << 8) | - (buffer[2] << 16) | - (buffer[3] << 24)); - default: - EFSYS_ASSERT(0); - return (0); - } - } else if (func == EFX_RX_HASHALG_LFSR) { - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_FALCON || - enp->en_family == EFX_FAMILY_SIENA); - return ((buffer[14] << 8) | buffer[15]); - } else { - EFSYS_ASSERT(0); - return (0); - } -} + efx_rx_ops_t *erxop = enp->en_erxop; + EFSYS_ASSERT3U(enp->en_hash_support, ==, EFX_RX_HASH_AVAILABLE); + return (erxop->erxo_prefix_hash(enp, func, buffer)); +} #endif /* EFSYS_OPT_RX_SCALE */ #if EFSYS_OPT_FALCON || EFSYS_OPT_SIENA @@ -714,60 +631,6 @@ falconsiena_rx_init( return (0); } -#if EFSYS_OPT_RX_HDR_SPLIT -static __checkReturn efx_rc_t -falconsiena_rx_hdr_split_enable( - __in efx_nic_t *enp, - __in unsigned int hdr_buf_size, - __in unsigned int pld_buf_size) -{ - unsigned int nhdr32; - unsigned int npld32; - efx_oword_t oword; - efx_rc_t rc; - - nhdr32 = hdr_buf_size / 32; - if ((nhdr32 == 0) || - (nhdr32 >= (1 << FRF_CZ_RX_HDR_SPLIT_HDR_BUF_SIZE_WIDTH)) || - ((hdr_buf_size % 32) != 0)) { - rc = EINVAL; - goto fail1; - } - - npld32 = pld_buf_size / 32; - if ((npld32 == 0) || - (npld32 >= (1 << FRF_CZ_RX_HDR_SPLIT_PLD_BUF_SIZE_WIDTH)) || - ((pld_buf_size % 32) != 0)) { - rc = EINVAL; - goto fail2; - } - - if (enp->en_rx_qcount > 0) { - rc = EBUSY; - goto fail3; - } - - EFX_BAR_READO(enp, FR_AZ_RX_CFG_REG, &oword); - - EFX_SET_OWORD_FIELD(oword, FRF_CZ_RX_HDR_SPLIT_EN, 1); - EFX_SET_OWORD_FIELD(oword, FRF_CZ_RX_HDR_SPLIT_HDR_BUF_SIZE, nhdr32); - EFX_SET_OWORD_FIELD(oword, FRF_CZ_RX_HDR_SPLIT_PLD_BUF_SIZE, npld32); - - EFX_BAR_WRITEO(enp, FR_AZ_RX_CFG_REG, &oword); - - return (0); - -fail3: - EFSYS_PROBE(fail3); -fail2: - EFSYS_PROBE(fail2); -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} -#endif /* EFSYS_OPT_RX_HDR_SPLIT */ - #if EFSYS_OPT_RX_SCATTER static __checkReturn efx_rc_t falconsiena_rx_scatter_enable( @@ -1115,6 +978,58 @@ fail1: } #endif +/* + * Falcon/Siena psuedo-header + * -------------------------- + * + * Receive packets are prefixed by an optional 16 byte pseudo-header. + * The psuedo-header is a byte array of one of the forms: + * + * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + * xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.TT.TT.TT.TT + * xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.LL.LL + * + * where: + * TT.TT.TT.TT Toeplitz hash (32-bit big-endian) + * LL.LL LFSR hash (16-bit big-endian) + */ + +#if EFSYS_OPT_RX_SCALE +static __checkReturn uint32_t +falconsiena_rx_prefix_hash( + __in efx_nic_t *enp, + __in efx_rx_hash_alg_t func, + __in uint8_t *buffer) +{ + switch (func) { + case EFX_RX_HASHALG_TOEPLITZ: + return ((buffer[12] << 24) | + (buffer[13] << 16) | + (buffer[14] << 8) | + buffer[15]); + + case EFX_RX_HASHALG_LFSR: + return ((buffer[14] << 8) | buffer[15]); + + default: + EFSYS_ASSERT(0); + return (0); + } +} +#endif /* EFSYS_OPT_RX_SCALE */ + +static __checkReturn efx_rc_t +falconsiena_rx_prefix_pktlen( + __in efx_nic_t *enp, + __in uint8_t *buffer, + __out uint16_t *lengthp) +{ + /* Not supported by Falcon/Siena hardware */ + EFSYS_ASSERT(0); + return (ENOTSUP); +} + + static void falconsiena_rx_qpost( __in efx_rxq_t *erp, @@ -1238,7 +1153,6 @@ falconsiena_rx_qcreate( efx_nic_cfg_t *encp = &(enp->en_nic_cfg); efx_oword_t oword; uint32_t size; - boolean_t split; boolean_t jumbo; efx_rc_t rc; @@ -1269,37 +1183,15 @@ falconsiena_rx_qcreate( switch (type) { case EFX_RXQ_TYPE_DEFAULT: - split = B_FALSE; jumbo = B_FALSE; break; -#if EFSYS_OPT_RX_HDR_SPLIT - case EFX_RXQ_TYPE_SPLIT_HEADER: - if ((enp->en_family < EFX_FAMILY_SIENA) || ((index & 1) != 0)) { - rc = EINVAL; - goto fail4; - } - split = B_TRUE; - jumbo = B_TRUE; - break; - - case EFX_RXQ_TYPE_SPLIT_PAYLOAD: - if ((enp->en_family < EFX_FAMILY_SIENA) || ((index & 1) == 0)) { - rc = EINVAL; - goto fail4; - } - split = B_FALSE; - jumbo = B_TRUE; - break; -#endif /* EFSYS_OPT_RX_HDR_SPLIT */ - #if EFSYS_OPT_RX_SCATTER case EFX_RXQ_TYPE_SCATTER: if (enp->en_family < EFX_FAMILY_SIENA) { rc = EINVAL; goto fail4; } - split = B_FALSE; jumbo = B_TRUE; break; #endif /* EFSYS_OPT_RX_SCATTER */ @@ -1310,10 +1202,7 @@ falconsiena_rx_qcreate( } /* Set up the new descriptor queue */ - EFX_POPULATE_OWORD_10(oword, - FRF_CZ_RX_HDR_SPLIT, split, - FRF_AZ_RX_ISCSI_DDIG_EN, 0, - FRF_AZ_RX_ISCSI_HDIG_EN, 0, + EFX_POPULATE_OWORD_7(oword, FRF_AZ_RX_DESCQ_BUF_BASE_ID, id, FRF_AZ_RX_DESCQ_EVQ_ID, eep->ee_index, FRF_AZ_RX_DESCQ_OWNER_ID, 0, diff --git a/sys/dev/sfxge/common/efx_sram.c b/sys/dev/sfxge/common/efx_sram.c index 8624478..f2a7b78 100644 --- a/sys/dev/sfxge/common/efx_sram.c +++ b/sys/dev/sfxge/common/efx_sram.c @@ -31,10 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" -#include "efx_regs.h" #include "efx_impl.h" __checkReturn efx_rc_t @@ -55,20 +52,21 @@ efx_sram_buf_tbl_set( EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC); -#if EFSYS_OPT_HUNTINGTON - if (enp->en_family == EFX_FAMILY_HUNTINGTON) { +#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD + if (enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD) { /* * FIXME: the efx_sram_buf_tbl_*() functionality needs to be * pulled inside the Falcon/Siena queue create/destroy code, * and then the original functions can be removed (see bug30834 * comment #1). But, for now, we just ensure that they are - * no-ops for Huntington, to allow bringing up existing drivers + * no-ops for EF10, to allow bringing up existing drivers * without modification. */ return (0); } -#endif /* EFSYS_OPT_HUNTINGTON */ +#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ if (stop >= EFX_BUF_TBL_SIZE) { rc = EFBIG; @@ -176,20 +174,21 @@ efx_sram_buf_tbl_clear( EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC); -#if EFSYS_OPT_HUNTINGTON - if (enp->en_family == EFX_FAMILY_HUNTINGTON) { +#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD + if (enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD) { /* * FIXME: the efx_sram_buf_tbl_*() functionality needs to be * pulled inside the Falcon/Siena queue create/destroy code, * and then the original functions can be removed (see bug30834 * comment #1). But, for now, we just ensure that they are - * no-ops for Huntington, to allow bringing up existing drivers + * no-ops for EF10, to allow bringing up existing drivers * without modification. */ return; } -#endif /* EFSYS_OPT_HUNTINGTON */ +#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ EFSYS_ASSERT3U(stop, <, EFX_BUF_TBL_SIZE); diff --git a/sys/dev/sfxge/common/efx_tx.c b/sys/dev/sfxge/common/efx_tx.c index 9cf31bc..cff7742 100644 --- a/sys/dev/sfxge/common/efx_tx.c +++ b/sys/dev/sfxge/common/efx_tx.c @@ -31,10 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" -#include "efx_regs.h" #include "efx_impl.h" #if EFSYS_OPT_QSTATS @@ -179,29 +176,54 @@ static efx_tx_ops_t __efx_tx_siena_ops = { #if EFSYS_OPT_HUNTINGTON static efx_tx_ops_t __efx_tx_hunt_ops = { - hunt_tx_init, /* etxo_init */ - hunt_tx_fini, /* etxo_fini */ - hunt_tx_qcreate, /* etxo_qcreate */ - hunt_tx_qdestroy, /* etxo_qdestroy */ - hunt_tx_qpost, /* etxo_qpost */ - hunt_tx_qpush, /* etxo_qpush */ - hunt_tx_qpace, /* etxo_qpace */ - hunt_tx_qflush, /* etxo_qflush */ - hunt_tx_qenable, /* etxo_qenable */ - hunt_tx_qpio_enable, /* etxo_qpio_enable */ - hunt_tx_qpio_disable, /* etxo_qpio_disable */ - hunt_tx_qpio_write, /* etxo_qpio_write */ - hunt_tx_qpio_post, /* etxo_qpio_post */ - hunt_tx_qdesc_post, /* etxo_qdesc_post */ - hunt_tx_qdesc_dma_create, /* etxo_qdesc_dma_create */ + ef10_tx_init, /* etxo_init */ + ef10_tx_fini, /* etxo_fini */ + ef10_tx_qcreate, /* etxo_qcreate */ + ef10_tx_qdestroy, /* etxo_qdestroy */ + ef10_tx_qpost, /* etxo_qpost */ + ef10_tx_qpush, /* etxo_qpush */ + ef10_tx_qpace, /* etxo_qpace */ + ef10_tx_qflush, /* etxo_qflush */ + ef10_tx_qenable, /* etxo_qenable */ + ef10_tx_qpio_enable, /* etxo_qpio_enable */ + ef10_tx_qpio_disable, /* etxo_qpio_disable */ + ef10_tx_qpio_write, /* etxo_qpio_write */ + ef10_tx_qpio_post, /* etxo_qpio_post */ + ef10_tx_qdesc_post, /* etxo_qdesc_post */ + ef10_tx_qdesc_dma_create, /* etxo_qdesc_dma_create */ hunt_tx_qdesc_tso_create, /* etxo_qdesc_tso_create */ - hunt_tx_qdesc_vlantci_create, /* etxo_qdesc_vlantci_create */ + ef10_tx_qdesc_vlantci_create, /* etxo_qdesc_vlantci_create */ #if EFSYS_OPT_QSTATS - hunt_tx_qstats_update, /* etxo_qstats_update */ + ef10_tx_qstats_update, /* etxo_qstats_update */ #endif }; #endif /* EFSYS_OPT_HUNTINGTON */ +#if EFSYS_OPT_MEDFORD +static efx_tx_ops_t __efx_tx_medford_ops = { + ef10_tx_init, /* etxo_init */ + ef10_tx_fini, /* etxo_fini */ + ef10_tx_qcreate, /* etxo_qcreate */ + ef10_tx_qdestroy, /* etxo_qdestroy */ + ef10_tx_qpost, /* etxo_qpost */ + ef10_tx_qpush, /* etxo_qpush */ + ef10_tx_qpace, /* etxo_qpace */ + ef10_tx_qflush, /* etxo_qflush */ + ef10_tx_qenable, /* etxo_qenable */ + ef10_tx_qpio_enable, /* etxo_qpio_enable */ + ef10_tx_qpio_disable, /* etxo_qpio_disable */ + ef10_tx_qpio_write, /* etxo_qpio_write */ + ef10_tx_qpio_post, /* etxo_qpio_post */ + ef10_tx_qdesc_post, /* etxo_qdesc_post */ + ef10_tx_qdesc_dma_create, /* etxo_qdesc_dma_create */ + NULL, /* etxo_qdesc_tso_create */ + ef10_tx_qdesc_vlantci_create, /* etxo_qdesc_vlantci_create */ +#if EFSYS_OPT_QSTATS + ef10_tx_qstats_update, /* etxo_qstats_update */ +#endif +}; +#endif /* EFSYS_OPT_MEDFORD */ + __checkReturn efx_rc_t efx_tx_init( __in efx_nic_t *enp) @@ -241,6 +263,12 @@ efx_tx_init( break; #endif /* EFSYS_OPT_HUNTINGTON */ +#if EFSYS_OPT_MEDFORD + case EFX_FAMILY_MEDFORD: + etxop = (efx_tx_ops_t *)&__efx_tx_medford_ops; + break; +#endif /* EFSYS_OPT_MEDFORD */ + default: EFSYS_ASSERT(0); rc = ENOTSUP; diff --git a/sys/dev/sfxge/common/efx_vpd.c b/sys/dev/sfxge/common/efx_vpd.c index 8c6e993..c1762e6 100644 --- a/sys/dev/sfxge/common/efx_vpd.c +++ b/sys/dev/sfxge/common/efx_vpd.c @@ -31,10 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" -#include "efx_regs.h" #include "efx_impl.h" #if EFSYS_OPT_VPD @@ -91,22 +88,22 @@ static efx_vpd_ops_t __efx_vpd_siena_ops = { #endif /* EFSYS_OPT_SIENA */ -#if EFSYS_OPT_HUNTINGTON - -static efx_vpd_ops_t __efx_vpd_hunt_ops = { - hunt_vpd_init, /* evpdo_init */ - hunt_vpd_size, /* evpdo_size */ - hunt_vpd_read, /* evpdo_read */ - hunt_vpd_verify, /* evpdo_verify */ - hunt_vpd_reinit, /* evpdo_reinit */ - hunt_vpd_get, /* evpdo_get */ - hunt_vpd_set, /* evpdo_set */ - hunt_vpd_next, /* evpdo_next */ - hunt_vpd_write, /* evpdo_write */ - hunt_vpd_fini, /* evpdo_fini */ +#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD + +static efx_vpd_ops_t __efx_vpd_ef10_ops = { + ef10_vpd_init, /* evpdo_init */ + ef10_vpd_size, /* evpdo_size */ + ef10_vpd_read, /* evpdo_read */ + ef10_vpd_verify, /* evpdo_verify */ + ef10_vpd_reinit, /* evpdo_reinit */ + ef10_vpd_get, /* evpdo_get */ + ef10_vpd_set, /* evpdo_set */ + ef10_vpd_next, /* evpdo_next */ + ef10_vpd_write, /* evpdo_write */ + ef10_vpd_fini, /* evpdo_fini */ }; -#endif /* EFSYS_OPT_HUNTINGTON */ +#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ __checkReturn efx_rc_t efx_vpd_init( @@ -134,10 +131,16 @@ efx_vpd_init( #if EFSYS_OPT_HUNTINGTON case EFX_FAMILY_HUNTINGTON: - evpdop = (efx_vpd_ops_t *)&__efx_vpd_hunt_ops; + evpdop = (efx_vpd_ops_t *)&__efx_vpd_ef10_ops; break; #endif /* EFSYS_OPT_HUNTINGTON */ +#if EFSYS_OPT_MEDFORD + case EFX_FAMILY_MEDFORD: + evpdop = (efx_vpd_ops_t *)&__efx_vpd_ef10_ops; + break; +#endif /* EFSYS_OPT_MEDFORD */ + default: EFSYS_ASSERT(0); rc = ENOTSUP; diff --git a/sys/dev/sfxge/common/efx_wol.c b/sys/dev/sfxge/common/efx_wol.c index d0d1fa0..aea3c55 100644 --- a/sys/dev/sfxge/common/efx_wol.c +++ b/sys/dev/sfxge/common/efx_wol.c @@ -31,9 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" #include "efx_impl.h" #if EFSYS_OPT_WOL diff --git a/sys/dev/sfxge/common/hunt_ev.c b/sys/dev/sfxge/common/hunt_ev.c index 5e6ccab..2cea2e0 100644 --- a/sys/dev/sfxge/common/hunt_ev.c +++ b/sys/dev/sfxge/common/hunt_ev.c @@ -31,10 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" -#include "efx_regs.h" #include "efx_impl.h" #if EFSYS_OPT_MON_STATS #include "mcdi_mon.h" @@ -54,35 +51,35 @@ __FBSDID("$FreeBSD$"); static __checkReturn boolean_t -hunt_ev_rx( +ef10_ev_rx( __in efx_evq_t *eep, __in efx_qword_t *eqp, __in const efx_ev_callbacks_t *eecp, __in_opt void *arg); static __checkReturn boolean_t -hunt_ev_tx( +ef10_ev_tx( __in efx_evq_t *eep, __in efx_qword_t *eqp, __in const efx_ev_callbacks_t *eecp, __in_opt void *arg); static __checkReturn boolean_t -hunt_ev_driver( +ef10_ev_driver( __in efx_evq_t *eep, __in efx_qword_t *eqp, __in const efx_ev_callbacks_t *eecp, __in_opt void *arg); static __checkReturn boolean_t -hunt_ev_drv_gen( +ef10_ev_drv_gen( __in efx_evq_t *eep, __in efx_qword_t *eqp, __in const efx_ev_callbacks_t *eecp, __in_opt void *arg); static __checkReturn boolean_t -hunt_ev_mcdi( +ef10_ev_mcdi( __in efx_evq_t *eep, __in efx_qword_t *eqp, __in const efx_ev_callbacks_t *eecp, @@ -230,7 +227,7 @@ fail1: __checkReturn efx_rc_t -hunt_ev_init( +ef10_ev_init( __in efx_nic_t *enp) { _NOTE(ARGUNUSED(enp)) @@ -238,14 +235,14 @@ hunt_ev_init( } void -hunt_ev_fini( +ef10_ev_fini( __in efx_nic_t *enp) { _NOTE(ARGUNUSED(enp)) } __checkReturn efx_rc_t -hunt_ev_qcreate( +ef10_ev_qcreate( __in efx_nic_t *enp, __in unsigned int index, __in efsys_mem_t *esmp, @@ -272,11 +269,11 @@ hunt_ev_qcreate( } /* Set up the handler table */ - eep->ee_rx = hunt_ev_rx; - eep->ee_tx = hunt_ev_tx; - eep->ee_driver = hunt_ev_driver; - eep->ee_drv_gen = hunt_ev_drv_gen; - eep->ee_mcdi = hunt_ev_mcdi; + eep->ee_rx = ef10_ev_rx; + eep->ee_tx = ef10_ev_tx; + eep->ee_driver = ef10_ev_driver; + eep->ee_drv_gen = ef10_ev_drv_gen; + eep->ee_mcdi = ef10_ev_mcdi; /* * Set up the event queue @@ -299,18 +296,19 @@ fail1: } void -hunt_ev_qdestroy( +ef10_ev_qdestroy( __in efx_evq_t *eep) { efx_nic_t *enp = eep->ee_enp; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); (void) efx_mcdi_fini_evq(eep->ee_enp, eep->ee_index); } __checkReturn efx_rc_t -hunt_ev_qprime( +ef10_ev_qprime( __in efx_evq_t *eep, __in unsigned int count) { @@ -390,7 +388,7 @@ fail1: } void -hunt_ev_qpost( +ef10_ev_qpost( __in efx_evq_t *eep, __in uint16_t data) { @@ -406,7 +404,7 @@ hunt_ev_qpost( } __checkReturn efx_rc_t -hunt_ev_qmoderate( +ef10_ev_qmoderate( __in efx_evq_t *eep, __in unsigned int us) { @@ -463,14 +461,10 @@ fail1: #if EFSYS_OPT_QSTATS void -hunt_ev_qstats_update( +ef10_ev_qstats_update( __in efx_evq_t *eep, __inout_ecount(EV_NQSTATS) efsys_stat_t *stat) { - /* - * TBD: Consider a common Siena/Huntington function. The code is - * essentially identical. - */ unsigned int id; for (id = 0; id < EV_NQSTATS; id++) { @@ -484,7 +478,7 @@ hunt_ev_qstats_update( static __checkReturn boolean_t -hunt_ev_rx( +ef10_ev_rx( __in efx_evq_t *eep, __in efx_qword_t *eqp, __in const efx_ev_callbacks_t *eecp, @@ -502,7 +496,6 @@ hunt_ev_rx( uint32_t l3_class; uint32_t l4_class; uint32_t next_read_lbits; - boolean_t soft1, soft2; uint16_t flags; boolean_t should_abort; efx_evq_rxq_state_t *eersp; @@ -564,10 +557,6 @@ hunt_ev_rx( flags |= EFX_DISCARD; } - /* FIXME: do we need soft bits from RXDP firmware ? */ - soft1 = (EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_EV_SOFT1) != 0); - soft2 = (EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_EV_SOFT2) != 0); - mcast = EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_MAC_CLASS); if (mcast == ESE_DZ_MAC_CLASS_UCAST) flags |= EFX_PKT_UNICAST; @@ -691,7 +680,7 @@ hunt_ev_rx( } static __checkReturn boolean_t -hunt_ev_tx( +ef10_ev_tx( __in efx_evq_t *eep, __in efx_qword_t *eqp, __in const efx_ev_callbacks_t *eecp, @@ -726,7 +715,7 @@ hunt_ev_tx( } static __checkReturn boolean_t -hunt_ev_driver( +ef10_ev_driver( __in efx_evq_t *eep, __in efx_qword_t *eqp, __in const efx_ev_callbacks_t *eecp, @@ -776,7 +765,7 @@ hunt_ev_driver( } static __checkReturn boolean_t -hunt_ev_drv_gen( +ef10_ev_drv_gen( __in efx_evq_t *eep, __in efx_qword_t *eqp, __in const efx_ev_callbacks_t *eecp, @@ -804,7 +793,7 @@ hunt_ev_drv_gen( } static __checkReturn boolean_t -hunt_ev_mcdi( +ef10_ev_mcdi( __in efx_evq_t *eep, __in efx_qword_t *eqp, __in const efx_ev_callbacks_t *eecp, @@ -1000,7 +989,7 @@ hunt_ev_mcdi( } void -hunt_ev_rxlabel_init( +ef10_ev_rxlabel_init( __in efx_evq_t *eep, __in efx_rxq_t *erp, __in unsigned int label) @@ -1017,7 +1006,7 @@ hunt_ev_rxlabel_init( } void -hunt_ev_rxlabel_fini( +ef10_ev_rxlabel_fini( __in efx_evq_t *eep, __in unsigned int label) { diff --git a/sys/dev/sfxge/common/hunt_filter.c b/sys/dev/sfxge/common/hunt_filter.c index 0666d9d..eaa0720 100644 --- a/sys/dev/sfxge/common/hunt_filter.c +++ b/sys/dev/sfxge/common/hunt_filter.c @@ -31,100 +31,98 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" -#include "efx_regs_mcdi.h" #include "efx_impl.h" #if EFSYS_OPT_HUNTINGTON #if EFSYS_OPT_FILTER -#define HFE_SPEC(hftp, index) ((hftp)->hft_entry[(index)].hfe_spec) +#define EFE_SPEC(eftp, index) ((eftp)->eft_entry[(index)].efe_spec) static efx_filter_spec_t * -hunt_filter_entry_spec( - __in const hunt_filter_table_t *hftp, +ef10_filter_entry_spec( + __in const ef10_filter_table_t *eftp, __in unsigned int index) { - return ((efx_filter_spec_t *)(HFE_SPEC(hftp, index) & - ~(uintptr_t)EFX_HUNT_FILTER_FLAGS)); + return ((efx_filter_spec_t *)(EFE_SPEC(eftp, index) & + ~(uintptr_t)EFX_EF10_FILTER_FLAGS)); } static boolean_t -hunt_filter_entry_is_busy( - __in const hunt_filter_table_t *hftp, +ef10_filter_entry_is_busy( + __in const ef10_filter_table_t *eftp, __in unsigned int index) { - if (HFE_SPEC(hftp, index) & EFX_HUNT_FILTER_FLAG_BUSY) + if (EFE_SPEC(eftp, index) & EFX_EF10_FILTER_FLAG_BUSY) return (B_TRUE); else return (B_FALSE); } static boolean_t -hunt_filter_entry_is_auto_old( - __in const hunt_filter_table_t *hftp, +ef10_filter_entry_is_auto_old( + __in const ef10_filter_table_t *eftp, __in unsigned int index) { - if (HFE_SPEC(hftp, index) & EFX_HUNT_FILTER_FLAG_AUTO_OLD) + if (EFE_SPEC(eftp, index) & EFX_EF10_FILTER_FLAG_AUTO_OLD) return (B_TRUE); else return (B_FALSE); } static void -hunt_filter_set_entry( - __inout hunt_filter_table_t *hftp, +ef10_filter_set_entry( + __inout ef10_filter_table_t *eftp, __in unsigned int index, __in_opt const efx_filter_spec_t *efsp) { - HFE_SPEC(hftp, index) = (uintptr_t)efsp; + EFE_SPEC(eftp, index) = (uintptr_t)efsp; } static void -hunt_filter_set_entry_busy( - __inout hunt_filter_table_t *hftp, +ef10_filter_set_entry_busy( + __inout ef10_filter_table_t *eftp, __in unsigned int index) { - HFE_SPEC(hftp, index) |= (uintptr_t)EFX_HUNT_FILTER_FLAG_BUSY; + EFE_SPEC(eftp, index) |= (uintptr_t)EFX_EF10_FILTER_FLAG_BUSY; } static void -hunt_filter_set_entry_not_busy( - __inout hunt_filter_table_t *hftp, +ef10_filter_set_entry_not_busy( + __inout ef10_filter_table_t *eftp, __in unsigned int index) { - HFE_SPEC(hftp, index) &= ~(uintptr_t)EFX_HUNT_FILTER_FLAG_BUSY; + EFE_SPEC(eftp, index) &= ~(uintptr_t)EFX_EF10_FILTER_FLAG_BUSY; } static void -hunt_filter_set_entry_auto_old( - __inout hunt_filter_table_t *hftp, +ef10_filter_set_entry_auto_old( + __inout ef10_filter_table_t *eftp, __in unsigned int index) { - EFSYS_ASSERT(hunt_filter_entry_spec(hftp, index) != NULL); - HFE_SPEC(hftp, index) |= (uintptr_t)EFX_HUNT_FILTER_FLAG_AUTO_OLD; + EFSYS_ASSERT(ef10_filter_entry_spec(eftp, index) != NULL); + EFE_SPEC(eftp, index) |= (uintptr_t)EFX_EF10_FILTER_FLAG_AUTO_OLD; } static void -hunt_filter_set_entry_not_auto_old( - __inout hunt_filter_table_t *hftp, +ef10_filter_set_entry_not_auto_old( + __inout ef10_filter_table_t *eftp, __in unsigned int index) { - HFE_SPEC(hftp, index) &= ~(uintptr_t)EFX_HUNT_FILTER_FLAG_AUTO_OLD; - EFSYS_ASSERT(hunt_filter_entry_spec(hftp, index) != NULL); + EFE_SPEC(eftp, index) &= ~(uintptr_t)EFX_EF10_FILTER_FLAG_AUTO_OLD; + EFSYS_ASSERT(ef10_filter_entry_spec(eftp, index) != NULL); } __checkReturn efx_rc_t -hunt_filter_init( +ef10_filter_init( __in efx_nic_t *enp) { efx_rc_t rc; - hunt_filter_table_t *hftp; + ef10_filter_table_t *eftp; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); #define MATCH_MASK(match) (EFX_MASK32(match) << EFX_LOW_BIT(match)) EFX_STATIC_ASSERT(EFX_FILTER_MATCH_REM_HOST == @@ -149,14 +147,14 @@ hunt_filter_init( MATCH_MASK(MC_CMD_FILTER_OP_IN_MATCH_IP_PROTO)); #undef MATCH_MASK - EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (hunt_filter_table_t), hftp); + EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (ef10_filter_table_t), eftp); - if (!hftp) { + if (!eftp) { rc = ENOMEM; goto fail1; } - enp->en_filter.ef_hunt_filter_table = hftp; + enp->en_filter.ef_ef10_filter_table = eftp; return (0); @@ -167,14 +165,15 @@ fail1: } void -hunt_filter_fini( +ef10_filter_fini( __in efx_nic_t *enp) { - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); - if (enp->en_filter.ef_hunt_filter_table != NULL) { - EFSYS_KMEM_FREE(enp->en_esip, sizeof (hunt_filter_table_t), - enp->en_filter.ef_hunt_filter_table); + if (enp->en_filter.ef_ef10_filter_table != NULL) { + EFSYS_KMEM_FREE(enp->en_esip, sizeof (ef10_filter_table_t), + enp->en_filter.ef_ef10_filter_table); } } @@ -183,7 +182,7 @@ efx_mcdi_filter_op_add( __in efx_nic_t *enp, __in efx_filter_spec_t *spec, __in unsigned int filter_op, - __inout hunt_filter_handle_t *handle) + __inout ef10_filter_handle_t *handle) { efx_mcdi_req_t req; uint8_t payload[MAX(MC_CMD_FILTER_OP_IN_LEN, @@ -201,9 +200,9 @@ efx_mcdi_filter_op_add( switch (filter_op) { case MC_CMD_FILTER_OP_IN_OP_REPLACE: MCDI_IN_SET_DWORD(req, FILTER_OP_IN_HANDLE_LO, - handle->hfh_lo); + handle->efh_lo); MCDI_IN_SET_DWORD(req, FILTER_OP_IN_HANDLE_HI, - handle->hfh_hi); + handle->efh_hi); /* Fall through */ case MC_CMD_FILTER_OP_IN_OP_INSERT: case MC_CMD_FILTER_OP_IN_OP_SUBSCRIBE: @@ -302,8 +301,8 @@ efx_mcdi_filter_op_add( goto fail3; } - handle->hfh_lo = MCDI_OUT_DWORD(req, FILTER_OP_OUT_HANDLE_LO); - handle->hfh_hi = MCDI_OUT_DWORD(req, FILTER_OP_OUT_HANDLE_HI); + handle->efh_lo = MCDI_OUT_DWORD(req, FILTER_OP_OUT_HANDLE_LO); + handle->efh_hi = MCDI_OUT_DWORD(req, FILTER_OP_OUT_HANDLE_HI); return (0); @@ -322,7 +321,7 @@ static __checkReturn efx_rc_t efx_mcdi_filter_op_delete( __in efx_nic_t *enp, __in unsigned int filter_op, - __inout hunt_filter_handle_t *handle) + __inout ef10_filter_handle_t *handle) { efx_mcdi_req_t req; uint8_t payload[MAX(MC_CMD_FILTER_OP_IN_LEN, @@ -351,8 +350,8 @@ efx_mcdi_filter_op_delete( goto fail1; } - MCDI_IN_SET_DWORD(req, FILTER_OP_IN_HANDLE_LO, handle->hfh_lo); - MCDI_IN_SET_DWORD(req, FILTER_OP_IN_HANDLE_HI, handle->hfh_hi); + MCDI_IN_SET_DWORD(req, FILTER_OP_IN_HANDLE_LO, handle->efh_lo); + MCDI_IN_SET_DWORD(req, FILTER_OP_IN_HANDLE_HI, handle->efh_hi); efx_mcdi_execute(enp, &req); @@ -380,7 +379,7 @@ fail1: } static __checkReturn boolean_t -hunt_filter_equal( +ef10_filter_equal( __in const efx_filter_spec_t *left, __in const efx_filter_spec_t *right) { @@ -413,7 +412,7 @@ hunt_filter_equal( } static __checkReturn boolean_t -hunt_filter_same_dest( +ef10_filter_same_dest( __in const efx_filter_spec_t *left, __in const efx_filter_spec_t *right) { @@ -430,7 +429,7 @@ hunt_filter_same_dest( } static __checkReturn uint32_t -hunt_filter_hash( +ef10_filter_hash( __in efx_filter_spec_t *spec) { EFX_STATIC_ASSERT((sizeof (efx_filter_spec_t) % sizeof (uint32_t)) @@ -456,7 +455,7 @@ hunt_filter_hash( * exclusive. */ static __checkReturn boolean_t -hunt_filter_is_exclusive( +ef10_filter_is_exclusive( __in efx_filter_spec_t *spec) { if ((spec->efs_match_flags & EFX_FILTER_MATCH_LOC_MAC) && @@ -478,30 +477,31 @@ hunt_filter_is_exclusive( } __checkReturn efx_rc_t -hunt_filter_restore( +ef10_filter_restore( __in efx_nic_t *enp) { int tbl_id; efx_filter_spec_t *spec; - hunt_filter_table_t *hftp = enp->en_filter.ef_hunt_filter_table; + ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table; boolean_t restoring; int state; efx_rc_t rc; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); - for (tbl_id = 0; tbl_id < EFX_HUNT_FILTER_TBL_ROWS; tbl_id++) { + for (tbl_id = 0; tbl_id < EFX_EF10_FILTER_TBL_ROWS; tbl_id++) { EFSYS_LOCK(enp->en_eslp, state); - spec = hunt_filter_entry_spec(hftp, tbl_id); + spec = ef10_filter_entry_spec(eftp, tbl_id); if (spec == NULL) { restoring = B_FALSE; - } else if (hunt_filter_entry_is_busy(hftp, tbl_id)) { + } else if (ef10_filter_entry_is_busy(eftp, tbl_id)) { /* Ignore busy entries. */ restoring = B_FALSE; } else { - hunt_filter_set_entry_busy(hftp, tbl_id); + ef10_filter_set_entry_busy(eftp, tbl_id); restoring = B_TRUE; } @@ -510,14 +510,14 @@ hunt_filter_restore( if (restoring == B_FALSE) continue; - if (hunt_filter_is_exclusive(spec)) { + if (ef10_filter_is_exclusive(spec)) { rc = efx_mcdi_filter_op_add(enp, spec, MC_CMD_FILTER_OP_IN_OP_INSERT, - &hftp->hft_entry[tbl_id].hfe_handle); + &eftp->eft_entry[tbl_id].efe_handle); } else { rc = efx_mcdi_filter_op_add(enp, spec, MC_CMD_FILTER_OP_IN_OP_SUBSCRIBE, - &hftp->hft_entry[tbl_id].hfe_handle); + &eftp->eft_entry[tbl_id].efe_handle); } if (rc != 0) @@ -525,7 +525,7 @@ hunt_filter_restore( EFSYS_LOCK(enp->en_eslp, state); - hunt_filter_set_entry_not_busy(hftp, tbl_id); + ef10_filter_set_entry_not_busy(eftp, tbl_id); EFSYS_UNLOCK(enp->en_eslp, state); } @@ -542,17 +542,17 @@ fail1: * An arbitrary search limit for the software hash table. As per the linux net * driver. */ -#define EFX_HUNT_FILTER_SEARCH_LIMIT 200 +#define EF10_FILTER_SEARCH_LIMIT 200 static __checkReturn efx_rc_t -hunt_filter_add_internal( +ef10_filter_add_internal( __in efx_nic_t *enp, __inout efx_filter_spec_t *spec, __in boolean_t may_replace, __out_opt uint32_t *filter_id) { efx_rc_t rc; - hunt_filter_table_t *hftp = enp->en_filter.ef_hunt_filter_table; + ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table; efx_filter_spec_t *saved_spec; uint32_t hash; unsigned int depth; @@ -562,13 +562,14 @@ hunt_filter_add_internal( int state; boolean_t locked = B_FALSE; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); #if EFSYS_OPT_RX_SCALE spec->efs_rss_context = enp->en_rss_context; #endif - hash = hunt_filter_hash(spec); + hash = ef10_filter_hash(spec); /* * FIXME: Add support for inserting filters of different priorities @@ -587,21 +588,21 @@ hunt_filter_add_internal( locked = B_TRUE; for (;;) { - i = (hash + depth) & (EFX_HUNT_FILTER_TBL_ROWS - 1); - saved_spec = hunt_filter_entry_spec(hftp, i); + i = (hash + depth) & (EFX_EF10_FILTER_TBL_ROWS - 1); + saved_spec = ef10_filter_entry_spec(eftp, i); if (!saved_spec) { if (ins_index < 0) { ins_index = i; } - } else if (hunt_filter_equal(spec, saved_spec)) { - if (hunt_filter_entry_is_busy(hftp, i)) + } else if (ef10_filter_equal(spec, saved_spec)) { + if (ef10_filter_entry_is_busy(eftp, i)) break; if (saved_spec->efs_priority == EFX_FILTER_PRI_AUTO) { ins_index = i; goto found; - } else if (hunt_filter_is_exclusive(spec)) { + } else if (ef10_filter_is_exclusive(spec)) { if (may_replace) { ins_index = i; goto found; @@ -619,7 +620,7 @@ hunt_filter_add_internal( * the first suitable slot or return EBUSY if * there was none. */ - if (depth == EFX_HUNT_FILTER_SEARCH_LIMIT) { + if (depth == EF10_FILTER_SEARCH_LIMIT) { if (ins_index < 0) { rc = EBUSY; goto fail2; @@ -639,11 +640,11 @@ found: * insert a conflicting filter while we're waiting for the * firmware must find the busy entry. */ - saved_spec = hunt_filter_entry_spec(hftp, ins_index); + saved_spec = ef10_filter_entry_spec(eftp, ins_index); if (saved_spec) { if (saved_spec->efs_priority == EFX_FILTER_PRI_AUTO) { /* This is a filter we are refreshing */ - hunt_filter_set_entry_not_auto_old(hftp, ins_index); + ef10_filter_set_entry_not_auto_old(eftp, ins_index); goto out_unlock; } @@ -655,9 +656,9 @@ found: goto fail3; } *saved_spec = *spec; - hunt_filter_set_entry(hftp, ins_index, saved_spec); + ef10_filter_set_entry(eftp, ins_index, saved_spec); } - hunt_filter_set_entry_busy(hftp, ins_index); + ef10_filter_set_entry_busy(eftp, ins_index); EFSYS_UNLOCK(enp->en_eslp, state); locked = B_FALSE; @@ -669,15 +670,15 @@ found: if (replacing) { rc = efx_mcdi_filter_op_add(enp, spec, MC_CMD_FILTER_OP_IN_OP_REPLACE, - &hftp->hft_entry[ins_index].hfe_handle); - } else if (hunt_filter_is_exclusive(spec)) { + &eftp->eft_entry[ins_index].efe_handle); + } else if (ef10_filter_is_exclusive(spec)) { rc = efx_mcdi_filter_op_add(enp, spec, MC_CMD_FILTER_OP_IN_OP_INSERT, - &hftp->hft_entry[ins_index].hfe_handle); + &eftp->eft_entry[ins_index].efe_handle); } else { rc = efx_mcdi_filter_op_add(enp, spec, MC_CMD_FILTER_OP_IN_OP_SUBSCRIBE, - &hftp->hft_entry[ins_index].hfe_handle); + &eftp->eft_entry[ins_index].efe_handle); } if (rc != 0) @@ -694,7 +695,7 @@ found: saved_spec->efs_dmaq_id = spec->efs_dmaq_id; } - hunt_filter_set_entry_not_busy(hftp, ins_index); + ef10_filter_set_entry_not_busy(eftp, ins_index); out_unlock: @@ -713,8 +714,8 @@ fail4: EFSYS_KMEM_FREE(enp->en_esip, sizeof (*spec), saved_spec); saved_spec = NULL; } - hunt_filter_set_entry_not_busy(hftp, ins_index); - hunt_filter_set_entry(hftp, ins_index, NULL); + ef10_filter_set_entry_not_busy(eftp, ins_index); + ef10_filter_set_entry(eftp, ins_index, NULL); fail3: EFSYS_PROBE(fail3); @@ -732,14 +733,14 @@ fail1: } __checkReturn efx_rc_t -hunt_filter_add( +ef10_filter_add( __in efx_nic_t *enp, __inout efx_filter_spec_t *spec, __in boolean_t may_replace) { efx_rc_t rc; - rc = hunt_filter_add_internal(enp, spec, may_replace, NULL); + rc = ef10_filter_add_internal(enp, spec, may_replace, NULL); if (rc != 0) goto fail1; @@ -753,15 +754,15 @@ fail1: static __checkReturn efx_rc_t -hunt_filter_delete_internal( +ef10_filter_delete_internal( __in efx_nic_t *enp, __in uint32_t filter_id) { efx_rc_t rc; - hunt_filter_table_t *table = enp->en_filter.ef_hunt_filter_table; + ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table; efx_filter_spec_t *spec; int state; - uint32_t filter_idx = filter_id % EFX_HUNT_FILTER_TBL_ROWS; + uint32_t filter_idx = filter_id % EFX_EF10_FILTER_TBL_ROWS; /* * Find the software table entry and mark it busy. Don't @@ -771,13 +772,13 @@ hunt_filter_delete_internal( * FIXME: What if the busy flag is never cleared? */ EFSYS_LOCK(enp->en_eslp, state); - while (hunt_filter_entry_is_busy(table, filter_idx)) { + while (ef10_filter_entry_is_busy(table, filter_idx)) { EFSYS_UNLOCK(enp->en_eslp, state); EFSYS_SPIN(1); EFSYS_LOCK(enp->en_eslp, state); } - if ((spec = hunt_filter_entry_spec(table, filter_idx)) != NULL) { - hunt_filter_set_entry_busy(table, filter_idx); + if ((spec = ef10_filter_entry_spec(table, filter_idx)) != NULL) { + ef10_filter_set_entry_busy(table, filter_idx); } EFSYS_UNLOCK(enp->en_eslp, state); @@ -790,20 +791,20 @@ hunt_filter_delete_internal( * Try to remove the hardware filter. This may fail if the MC has * rebooted (which frees all hardware filter resources). */ - if (hunt_filter_is_exclusive(spec)) { + if (ef10_filter_is_exclusive(spec)) { rc = efx_mcdi_filter_op_delete(enp, MC_CMD_FILTER_OP_IN_OP_REMOVE, - &table->hft_entry[filter_idx].hfe_handle); + &table->eft_entry[filter_idx].efe_handle); } else { rc = efx_mcdi_filter_op_delete(enp, MC_CMD_FILTER_OP_IN_OP_UNSUBSCRIBE, - &table->hft_entry[filter_idx].hfe_handle); + &table->eft_entry[filter_idx].efe_handle); } /* Free the software table entry */ EFSYS_LOCK(enp->en_eslp, state); - hunt_filter_set_entry_not_busy(table, filter_idx); - hunt_filter_set_entry(table, filter_idx, NULL); + ef10_filter_set_entry_not_busy(table, filter_idx); + ef10_filter_set_entry(table, filter_idx, NULL); EFSYS_UNLOCK(enp->en_eslp, state); EFSYS_KMEM_FREE(enp->en_esip, sizeof (*spec), spec); @@ -824,12 +825,12 @@ fail1: } __checkReturn efx_rc_t -hunt_filter_delete( +ef10_filter_delete( __in efx_nic_t *enp, __inout efx_filter_spec_t *spec) { efx_rc_t rc; - hunt_filter_table_t *table = enp->en_filter.ef_hunt_filter_table; + ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table; efx_filter_spec_t *saved_spec; unsigned int hash; unsigned int depth; @@ -837,22 +838,23 @@ hunt_filter_delete( int state; boolean_t locked = B_FALSE; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); - hash = hunt_filter_hash(spec); + hash = ef10_filter_hash(spec); EFSYS_LOCK(enp->en_eslp, state); locked = B_TRUE; depth = 1; for (;;) { - i = (hash + depth) & (EFX_HUNT_FILTER_TBL_ROWS - 1); - saved_spec = hunt_filter_entry_spec(table, i); - if (saved_spec && hunt_filter_equal(spec, saved_spec) && - hunt_filter_same_dest(spec, saved_spec)) { + i = (hash + depth) & (EFX_EF10_FILTER_TBL_ROWS - 1); + saved_spec = ef10_filter_entry_spec(table, i); + if (saved_spec && ef10_filter_equal(spec, saved_spec) && + ef10_filter_same_dest(spec, saved_spec)) { break; } - if (depth == EFX_HUNT_FILTER_SEARCH_LIMIT) { + if (depth == EF10_FILTER_SEARCH_LIMIT) { rc = ENOENT; goto fail1; } @@ -862,7 +864,7 @@ hunt_filter_delete( EFSYS_UNLOCK(enp->en_eslp, state); locked = B_FALSE; - rc = hunt_filter_delete_internal(enp, i); + rc = ef10_filter_delete_internal(enp, i); if (rc != 0) goto fail2; @@ -961,7 +963,7 @@ fail1: } __checkReturn efx_rc_t -hunt_filter_supported_filters( +ef10_filter_supported_filters( __in efx_nic_t *enp, __out uint32_t *list, __out size_t *length) @@ -980,13 +982,13 @@ fail1: } static __checkReturn efx_rc_t -hunt_filter_unicast_refresh( +ef10_filter_unicast_refresh( __in efx_nic_t *enp, __in_ecount(6) uint8_t const *addr, __in boolean_t all_unicst, __in efx_filter_flag_t filter_flags) { - hunt_filter_table_t *hftp = enp->en_filter.ef_hunt_filter_table; + ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table; efx_filter_spec_t spec; efx_rc_t rc; @@ -996,11 +998,11 @@ hunt_filter_unicast_refresh( /* Insert the filter for the local station address */ efx_filter_spec_init_rx(&spec, EFX_FILTER_PRI_AUTO, filter_flags, - hftp->hft_default_rxq); + eftp->eft_default_rxq); efx_filter_spec_set_eth_local(&spec, EFX_FILTER_SPEC_VID_UNSPEC, addr); - rc = hunt_filter_add_internal(enp, &spec, B_TRUE, - &hftp->hft_unicst_filter_index); + rc = ef10_filter_add_internal(enp, &spec, B_TRUE, + &eftp->eft_unicst_filter_index); if (rc != 0) { /* * Fall back to an unknown filter. We may be able to subscribe @@ -1008,7 +1010,7 @@ hunt_filter_unicast_refresh( */ goto use_uc_def; } - hftp->hft_unicst_filter_set = B_TRUE; + eftp->eft_unicst_filter_set = B_TRUE; return (0); @@ -1016,32 +1018,32 @@ use_uc_def: /* Insert the unknown unicast filter */ efx_filter_spec_init_rx(&spec, EFX_FILTER_PRI_AUTO, filter_flags, - hftp->hft_default_rxq); + eftp->eft_default_rxq); efx_filter_spec_set_uc_def(&spec); - rc = hunt_filter_add_internal(enp, &spec, B_TRUE, - &hftp->hft_unicst_filter_index); + rc = ef10_filter_add_internal(enp, &spec, B_TRUE, + &eftp->eft_unicst_filter_index); if (rc != 0) goto fail1; - hftp->hft_unicst_filter_set = B_TRUE; + eftp->eft_unicst_filter_set = B_TRUE; return (0); fail1: EFSYS_PROBE1(fail1, efx_rc_t, rc); - if (hftp->hft_unicst_filter_set != B_FALSE) { - (void) hunt_filter_delete_internal(enp, - hftp->hft_unicst_filter_index); + if (eftp->eft_unicst_filter_set != B_FALSE) { + (void) ef10_filter_delete_internal(enp, + eftp->eft_unicst_filter_index); - hftp->hft_unicst_filter_set = B_FALSE; + eftp->eft_unicst_filter_set = B_FALSE; } return (rc); } static __checkReturn efx_rc_t -hunt_filter_multicast_refresh( +ef10_filter_multicast_refresh( __in efx_nic_t *enp, __in boolean_t mulcst, __in boolean_t all_mulcst, @@ -1050,7 +1052,7 @@ hunt_filter_multicast_refresh( __in int count, __in efx_filter_flag_t filter_flags) { - hunt_filter_table_t *hftp = enp->en_filter.ef_hunt_filter_table; + ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table; efx_filter_spec_t spec; uint8_t addr[6]; unsigned i; @@ -1063,25 +1065,25 @@ hunt_filter_multicast_refresh( count = 0; if (count + (brdcst ? 1 : 0) > - EFX_ARRAY_SIZE(hftp->hft_mulcst_filter_indexes)) { + EFX_ARRAY_SIZE(eftp->eft_mulcst_filter_indexes)) { /* Too many MAC addresses; use unknown multicast filter */ goto use_mc_def; } /* Insert/renew multicast address list filters */ - hftp->hft_mulcst_filter_count = count; - for (i = 0; i < hftp->hft_mulcst_filter_count; i++) { + eftp->eft_mulcst_filter_count = count; + for (i = 0; i < eftp->eft_mulcst_filter_count; i++) { efx_filter_spec_init_rx(&spec, EFX_FILTER_PRI_AUTO, filter_flags, - hftp->hft_default_rxq); + eftp->eft_default_rxq); efx_filter_spec_set_eth_local(&spec, EFX_FILTER_SPEC_VID_UNSPEC, &addrs[i * EFX_MAC_ADDR_LEN]); - rc = hunt_filter_add_internal(enp, &spec, B_TRUE, - &hftp->hft_mulcst_filter_indexes[i]); + rc = ef10_filter_add_internal(enp, &spec, B_TRUE, + &eftp->eft_mulcst_filter_indexes[i]); if (rc != 0) { /* Rollback, then use unknown multicast filter */ goto rollback; @@ -1090,18 +1092,18 @@ hunt_filter_multicast_refresh( if (brdcst == B_TRUE) { /* Insert/renew broadcast address filter */ - hftp->hft_mulcst_filter_count++; + eftp->eft_mulcst_filter_count++; efx_filter_spec_init_rx(&spec, EFX_FILTER_PRI_AUTO, filter_flags, - hftp->hft_default_rxq); + eftp->eft_default_rxq); EFX_MAC_BROADCAST_ADDR_SET(addr); efx_filter_spec_set_eth_local(&spec, EFX_FILTER_SPEC_VID_UNSPEC, addr); - rc = hunt_filter_add_internal(enp, &spec, B_TRUE, - &hftp->hft_mulcst_filter_indexes[ - hftp->hft_mulcst_filter_count - 1]); + rc = ef10_filter_add_internal(enp, &spec, B_TRUE, + &eftp->eft_mulcst_filter_indexes[ + eftp->eft_mulcst_filter_count - 1]); if (rc != 0) { /* Rollback, then use unknown multicast filter */ goto rollback; @@ -1116,24 +1118,24 @@ rollback: * before inserting the unknown multicast filter. */ while (i--) { - (void) hunt_filter_delete_internal(enp, - hftp->hft_mulcst_filter_indexes[i]); + (void) ef10_filter_delete_internal(enp, + eftp->eft_mulcst_filter_indexes[i]); } - hftp->hft_mulcst_filter_count = 0; + eftp->eft_mulcst_filter_count = 0; use_mc_def: /* Insert the unknown multicast filter */ efx_filter_spec_init_rx(&spec, EFX_FILTER_PRI_AUTO, filter_flags, - hftp->hft_default_rxq); + eftp->eft_default_rxq); efx_filter_spec_set_mc_def(&spec); - rc = hunt_filter_add_internal(enp, &spec, B_TRUE, - &hftp->hft_mulcst_filter_indexes[0]); + rc = ef10_filter_add_internal(enp, &spec, B_TRUE, + &eftp->eft_mulcst_filter_indexes[0]); if (rc != 0) goto fail1; - hftp->hft_mulcst_filter_count = 1; + eftp->eft_mulcst_filter_count = 1; /* * FIXME: If brdcst == B_FALSE, add a filter to drop broadcast traffic. @@ -1192,7 +1194,7 @@ fail1: * still applied in this case). */ __checkReturn efx_rc_t -hunt_filter_reconfigure( +ef10_filter_reconfigure( __in efx_nic_t *enp, __in_ecount(6) uint8_t const *mac_addr, __in boolean_t all_unicst, @@ -1202,58 +1204,58 @@ hunt_filter_reconfigure( __in_ecount(6*count) uint8_t const *addrs, __in int count) { - hunt_filter_table_t *table = enp->en_filter.ef_hunt_filter_table; + ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table; efx_filter_flag_t filter_flags; unsigned i; int all_unicst_rc; int all_mulcst_rc; efx_rc_t rc; - if (table->hft_default_rxq == NULL) { + if (table->eft_default_rxq == NULL) { /* * Filters direct traffic to the default RXQ, and so cannot be * inserted until it is available. Any currently configured * filters must be removed (ignore errors in case the MC * has rebooted, which removes hardware filters). */ - if (table->hft_unicst_filter_set != B_FALSE) { - (void) hunt_filter_delete_internal(enp, - table->hft_unicst_filter_index); - table->hft_unicst_filter_set = B_FALSE; + if (table->eft_unicst_filter_set != B_FALSE) { + (void) ef10_filter_delete_internal(enp, + table->eft_unicst_filter_index); + table->eft_unicst_filter_set = B_FALSE; } - for (i = 0; i < table->hft_mulcst_filter_count; i++) { - (void) hunt_filter_delete_internal(enp, - table->hft_mulcst_filter_indexes[i]); + for (i = 0; i < table->eft_mulcst_filter_count; i++) { + (void) ef10_filter_delete_internal(enp, + table->eft_mulcst_filter_indexes[i]); } - table->hft_mulcst_filter_count = 0; + table->eft_mulcst_filter_count = 0; return (0); } - if (table->hft_using_rss) + if (table->eft_using_rss) filter_flags = EFX_FILTER_FLAG_RX_RSS; else filter_flags = 0; /* Mark old filters which may need to be removed */ - if (table->hft_unicst_filter_set != B_FALSE) { - hunt_filter_set_entry_auto_old(table, - table->hft_unicst_filter_index); + if (table->eft_unicst_filter_set != B_FALSE) { + ef10_filter_set_entry_auto_old(table, + table->eft_unicst_filter_index); } - for (i = 0; i < table->hft_mulcst_filter_count; i++) { - hunt_filter_set_entry_auto_old(table, - table->hft_mulcst_filter_indexes[i]); + for (i = 0; i < table->eft_mulcst_filter_count; i++) { + ef10_filter_set_entry_auto_old(table, + table->eft_mulcst_filter_indexes[i]); } /* Insert or renew unicast filters */ - if ((all_unicst_rc = hunt_filter_unicast_refresh(enp, mac_addr, + if ((all_unicst_rc = ef10_filter_unicast_refresh(enp, mac_addr, all_unicst, filter_flags)) != 0) { if (all_unicst == B_FALSE) { rc = all_unicst_rc; goto fail1; } /* Retry without all_unicast flag */ - rc = hunt_filter_unicast_refresh(enp, mac_addr, + rc = ef10_filter_unicast_refresh(enp, mac_addr, B_FALSE, filter_flags); if (rc != 0) goto fail2; @@ -1272,12 +1274,14 @@ hunt_filter_reconfigure( * filters. This ensures that encp->enc_workaround_bug26807 matches the * firmware state, and that later changes to enable/disable the * workaround will result in this function seeing a reset (FLR). + * + * FIXME: On Medford mulicast chaining should always be on. */ if ((rc = hunt_filter_get_workarounds(enp)) != 0) goto fail3; /* Insert or renew multicast filters */ - if ((all_mulcst_rc = hunt_filter_multicast_refresh(enp, mulcst, + if ((all_mulcst_rc = ef10_filter_multicast_refresh(enp, mulcst, all_mulcst, brdcst, addrs, count, filter_flags)) != 0) { if (all_mulcst == B_FALSE) { @@ -1285,7 +1289,7 @@ hunt_filter_reconfigure( goto fail4; } /* Retry without all_mulcast flag */ - rc = hunt_filter_multicast_refresh(enp, mulcst, + rc = ef10_filter_multicast_refresh(enp, mulcst, B_FALSE, brdcst, addrs, count, filter_flags); if (rc != 0) @@ -1293,9 +1297,9 @@ hunt_filter_reconfigure( } /* Remove old filters which were not renewed */ - for (i = 0; i < EFX_ARRAY_SIZE(table->hft_entry); i++) { - if (hunt_filter_entry_is_auto_old(table, i)) { - (void) hunt_filter_delete_internal(enp, i); + for (i = 0; i < EFX_ARRAY_SIZE(table->eft_entry); i++) { + if (ef10_filter_entry_is_auto_old(table, i)) { + (void) ef10_filter_delete_internal(enp, i); } } @@ -1319,9 +1323,9 @@ fail1: EFSYS_PROBE1(fail1, efx_rc_t, rc); /* Clear auto old flags */ - for (i = 0; i < EFX_ARRAY_SIZE(table->hft_entry); i++) { - if (hunt_filter_entry_is_auto_old(table, i)) { - hunt_filter_set_entry_not_auto_old(table, i); + for (i = 0; i < EFX_ARRAY_SIZE(table->eft_entry); i++) { + if (ef10_filter_entry_is_auto_old(table, i)) { + ef10_filter_set_entry_not_auto_old(table, i); } } @@ -1329,45 +1333,45 @@ fail1: } void -hunt_filter_get_default_rxq( +ef10_filter_get_default_rxq( __in efx_nic_t *enp, __out efx_rxq_t **erpp, __out boolean_t *using_rss) { - hunt_filter_table_t *table = enp->en_filter.ef_hunt_filter_table; + ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table; - *erpp = table->hft_default_rxq; - *using_rss = table->hft_using_rss; + *erpp = table->eft_default_rxq; + *using_rss = table->eft_using_rss; } void -hunt_filter_default_rxq_set( +ef10_filter_default_rxq_set( __in efx_nic_t *enp, __in efx_rxq_t *erp, __in boolean_t using_rss) { - hunt_filter_table_t *table = enp->en_filter.ef_hunt_filter_table; + ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table; #if EFSYS_OPT_RX_SCALE EFSYS_ASSERT((using_rss == B_FALSE) || - (enp->en_rss_context != HUNTINGTON_RSS_CONTEXT_INVALID)); - table->hft_using_rss = using_rss; + (enp->en_rss_context != EF10_RSS_CONTEXT_INVALID)); + table->eft_using_rss = using_rss; #else EFSYS_ASSERT(using_rss == B_FALSE); - table->hft_using_rss = B_FALSE; + table->eft_using_rss = B_FALSE; #endif - table->hft_default_rxq = erp; + table->eft_default_rxq = erp; } void -hunt_filter_default_rxq_clear( +ef10_filter_default_rxq_clear( __in efx_nic_t *enp) { - hunt_filter_table_t *table = enp->en_filter.ef_hunt_filter_table; + ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table; - table->hft_default_rxq = NULL; - table->hft_using_rss = B_FALSE; + table->eft_default_rxq = NULL; + table->eft_using_rss = B_FALSE; } diff --git a/sys/dev/sfxge/common/hunt_impl.h b/sys/dev/sfxge/common/hunt_impl.h index 49a1244..ab5857f 100644 --- a/sys/dev/sfxge/common/hunt_impl.h +++ b/sys/dev/sfxge/common/hunt_impl.h @@ -42,29 +42,34 @@ extern "C" { #endif -#define HUNTINGTON_NVRAM_CHUNK 0x80 +/* + * FIXME: This is just a power of 2 which fits in an MCDI v1 message, and could + * possibly be increased, or the write size reported by newer firmware used + * instead. + */ +#define EF10_NVRAM_CHUNK 0x80 /* Alignment requirement for value written to RX WPTR: * the WPTR must be aligned to an 8 descriptor boundary */ -#define HUNTINGTON_RX_WPTR_ALIGN 8 +#define EF10_RX_WPTR_ALIGN 8 /* Invalid RSS context handle */ -#define HUNTINGTON_RSS_CONTEXT_INVALID (0xffffffff) +#define EF10_RSS_CONTEXT_INVALID (0xffffffff) /* EV */ __checkReturn efx_rc_t -hunt_ev_init( +ef10_ev_init( __in efx_nic_t *enp); void -hunt_ev_fini( +ef10_ev_fini( __in efx_nic_t *enp); __checkReturn efx_rc_t -hunt_ev_qcreate( +ef10_ev_qcreate( __in efx_nic_t *enp, __in unsigned int index, __in efsys_mem_t *esmp, @@ -73,116 +78,131 @@ hunt_ev_qcreate( __in efx_evq_t *eep); void -hunt_ev_qdestroy( +ef10_ev_qdestroy( __in efx_evq_t *eep); __checkReturn efx_rc_t -hunt_ev_qprime( +ef10_ev_qprime( __in efx_evq_t *eep, __in unsigned int count); void -hunt_ev_qpost( +ef10_ev_qpost( __in efx_evq_t *eep, __in uint16_t data); __checkReturn efx_rc_t -hunt_ev_qmoderate( +ef10_ev_qmoderate( __in efx_evq_t *eep, __in unsigned int us); #if EFSYS_OPT_QSTATS void -hunt_ev_qstats_update( +ef10_ev_qstats_update( __in efx_evq_t *eep, __inout_ecount(EV_NQSTATS) efsys_stat_t *stat); #endif /* EFSYS_OPT_QSTATS */ void -hunt_ev_rxlabel_init( +ef10_ev_rxlabel_init( __in efx_evq_t *eep, __in efx_rxq_t *erp, __in unsigned int label); void -hunt_ev_rxlabel_fini( +ef10_ev_rxlabel_fini( __in efx_evq_t *eep, __in unsigned int label); /* INTR */ __checkReturn efx_rc_t -hunt_intr_init( +ef10_intr_init( __in efx_nic_t *enp, __in efx_intr_type_t type, __in efsys_mem_t *esmp); void -hunt_intr_enable( +ef10_intr_enable( __in efx_nic_t *enp); void -hunt_intr_disable( +ef10_intr_disable( __in efx_nic_t *enp); void -hunt_intr_disable_unlocked( +ef10_intr_disable_unlocked( __in efx_nic_t *enp); __checkReturn efx_rc_t -hunt_intr_trigger( +ef10_intr_trigger( __in efx_nic_t *enp, __in unsigned int level); void -hunt_intr_fini( +ef10_intr_status_line( + __in efx_nic_t *enp, + __out boolean_t *fatalp, + __out uint32_t *qmaskp); + + void +ef10_intr_status_message( + __in efx_nic_t *enp, + __in unsigned int message, + __out boolean_t *fatalp); + + void +ef10_intr_fatal( + __in efx_nic_t *enp); + void +ef10_intr_fini( __in efx_nic_t *enp); /* NIC */ extern __checkReturn efx_rc_t -hunt_nic_probe( +ef10_nic_probe( __in efx_nic_t *enp); extern __checkReturn efx_rc_t -hunt_nic_set_drv_limits( +ef10_nic_set_drv_limits( __inout efx_nic_t *enp, __in efx_drv_limits_t *edlp); extern __checkReturn efx_rc_t -hunt_nic_get_vi_pool( +ef10_nic_get_vi_pool( __in efx_nic_t *enp, __out uint32_t *vi_countp); extern __checkReturn efx_rc_t -hunt_nic_get_bar_region( +ef10_nic_get_bar_region( __in efx_nic_t *enp, __in efx_nic_region_t region, __out uint32_t *offsetp, __out size_t *sizep); extern __checkReturn efx_rc_t -hunt_nic_reset( +ef10_nic_reset( __in efx_nic_t *enp); extern __checkReturn efx_rc_t -hunt_nic_init( +ef10_nic_init( __in efx_nic_t *enp); #if EFSYS_OPT_DIAG extern __checkReturn efx_rc_t -hunt_nic_register_test( +ef10_nic_register_test( __in efx_nic_t *enp); #endif /* EFSYS_OPT_DIAG */ extern void -hunt_nic_fini( +ef10_nic_fini( __in efx_nic_t *enp); extern void -hunt_nic_unprobe( +ef10_nic_unprobe( __in efx_nic_t *enp); @@ -247,16 +267,16 @@ hunt_mac_stats_update( #if EFSYS_OPT_MCDI extern __checkReturn efx_rc_t -hunt_mcdi_init( +ef10_mcdi_init( __in efx_nic_t *enp, __in const efx_mcdi_transport_t *mtp); extern void -hunt_mcdi_fini( +ef10_mcdi_fini( __in efx_nic_t *enp); extern void -hunt_mcdi_request_copyin( +ef10_mcdi_request_copyin( __in efx_nic_t *enp, __in efx_mcdi_req_t *emrp, __in unsigned int seq, @@ -264,27 +284,27 @@ hunt_mcdi_request_copyin( __in boolean_t new_epoch); extern __checkReturn boolean_t -hunt_mcdi_poll_response( +ef10_mcdi_poll_response( __in efx_nic_t *enp); extern void -hunt_mcdi_read_response( +ef10_mcdi_read_response( __in efx_nic_t *enp, __out void *bufferp, __in size_t offset, __in size_t length); extern void -hunt_mcdi_request_copyout( +ef10_mcdi_request_copyout( __in efx_nic_t *enp, __in efx_mcdi_req_t *emrp); extern efx_rc_t -hunt_mcdi_poll_reboot( +ef10_mcdi_poll_reboot( __in efx_nic_t *enp); extern __checkReturn efx_rc_t -hunt_mcdi_feature_supported( +ef10_mcdi_feature_supported( __in efx_nic_t *enp, __in efx_mcdi_feature_id_t id, __out boolean_t *supportedp); @@ -296,7 +316,7 @@ hunt_mcdi_feature_supported( #if EFSYS_OPT_NVRAM || EFSYS_OPT_VPD extern __checkReturn efx_rc_t -hunt_nvram_buf_read_tlv( +ef10_nvram_buf_read_tlv( __in efx_nic_t *enp, __in_bcount(max_seg_size) caddr_t seg_data, __in size_t max_seg_size, @@ -305,7 +325,7 @@ hunt_nvram_buf_read_tlv( __out size_t *sizep); extern __checkReturn efx_rc_t -hunt_nvram_buf_write_tlv( +ef10_nvram_buf_write_tlv( __inout_bcount(partn_size) caddr_t partn_data, __in size_t partn_size, __in uint32_t tag, @@ -314,7 +334,7 @@ hunt_nvram_buf_write_tlv( __out size_t *total_lengthp); extern __checkReturn efx_rc_t -hunt_nvram_partn_read_tlv( +ef10_nvram_partn_read_tlv( __in efx_nic_t *enp, __in uint32_t partn, __in uint32_t tag, @@ -322,7 +342,7 @@ hunt_nvram_partn_read_tlv( __out size_t *sizep); extern __checkReturn efx_rc_t -hunt_nvram_partn_write_tlv( +ef10_nvram_partn_write_tlv( __in efx_nic_t *enp, __in uint32_t partn, __in uint32_t tag, @@ -330,7 +350,7 @@ hunt_nvram_partn_write_tlv( __in size_t size); extern __checkReturn efx_rc_t -hunt_nvram_partn_write_segment_tlv( +ef10_nvram_partn_write_segment_tlv( __in efx_nic_t *enp, __in uint32_t partn, __in uint32_t tag, @@ -339,43 +359,43 @@ hunt_nvram_partn_write_segment_tlv( __in boolean_t all_segments); extern __checkReturn efx_rc_t -hunt_nvram_partn_size( +ef10_nvram_partn_size( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __out size_t *sizep); extern __checkReturn efx_rc_t -hunt_nvram_partn_lock( +ef10_nvram_partn_lock( __in efx_nic_t *enp, - __in unsigned int partn); + __in uint32_t partn); extern __checkReturn efx_rc_t -hunt_nvram_partn_read( +ef10_nvram_partn_read( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __in unsigned int offset, __out_bcount(size) caddr_t data, __in size_t size); extern __checkReturn efx_rc_t -hunt_nvram_partn_erase( +ef10_nvram_partn_erase( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __in unsigned int offset, __in size_t size); extern __checkReturn efx_rc_t -hunt_nvram_partn_write( +ef10_nvram_partn_write( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __in unsigned int offset, __out_bcount(size) caddr_t data, __in size_t size); extern void -hunt_nvram_partn_unlock( +ef10_nvram_partn_unlock( __in efx_nic_t *enp, - __in unsigned int partn); + __in uint32_t partn); #endif /* EFSYS_OPT_NVRAM || EFSYS_OPT_VPD */ @@ -384,32 +404,32 @@ hunt_nvram_partn_unlock( #if EFSYS_OPT_DIAG extern __checkReturn efx_rc_t -hunt_nvram_test( +ef10_nvram_test( __in efx_nic_t *enp); #endif /* EFSYS_OPT_DIAG */ extern __checkReturn efx_rc_t -hunt_nvram_size( +ef10_nvram_size( __in efx_nic_t *enp, __in efx_nvram_type_t type, __out size_t *sizep); extern __checkReturn efx_rc_t -hunt_nvram_get_version( +ef10_nvram_get_version( __in efx_nic_t *enp, __in efx_nvram_type_t type, __out uint32_t *subtypep, __out_ecount(4) uint16_t version[4]); extern __checkReturn efx_rc_t -hunt_nvram_rw_start( +ef10_nvram_rw_start( __in efx_nic_t *enp, __in efx_nvram_type_t type, __out size_t *pref_chunkp); extern __checkReturn efx_rc_t -hunt_nvram_read_chunk( +ef10_nvram_read_chunk( __in efx_nic_t *enp, __in efx_nvram_type_t type, __in unsigned int offset, @@ -417,12 +437,12 @@ hunt_nvram_read_chunk( __in size_t size); extern __checkReturn efx_rc_t -hunt_nvram_erase( +ef10_nvram_erase( __in efx_nic_t *enp, __in efx_nvram_type_t type); extern __checkReturn efx_rc_t -hunt_nvram_write_chunk( +ef10_nvram_write_chunk( __in efx_nic_t *enp, __in efx_nvram_type_t type, __in unsigned int offset, @@ -430,22 +450,28 @@ hunt_nvram_write_chunk( __in size_t size); extern void -hunt_nvram_rw_finish( +ef10_nvram_rw_finish( __in efx_nic_t *enp, __in efx_nvram_type_t type); extern __checkReturn efx_rc_t -hunt_nvram_partn_set_version( +ef10_nvram_partn_set_version( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __in_ecount(4) uint16_t version[4]); extern __checkReturn efx_rc_t -hunt_nvram_set_version( +ef10_nvram_set_version( __in efx_nic_t *enp, __in efx_nvram_type_t type, __in_ecount(4) uint16_t version[4]); +extern __checkReturn efx_rc_t +ef10_nvram_type_to_partn( + __in efx_nic_t *enp, + __in efx_nvram_type_t type, + __out uint32_t *partnp); + #endif /* EFSYS_OPT_NVRAM */ @@ -562,7 +588,7 @@ hunt_bist_stop( #if EFSYS_OPT_DIAG extern __checkReturn efx_rc_t -hunt_sram_test( +ef10_sram_test( __in efx_nic_t *enp, __in efx_sram_pattern_fn_t func); @@ -572,15 +598,15 @@ hunt_sram_test( /* TX */ extern __checkReturn efx_rc_t -hunt_tx_init( +ef10_tx_init( __in efx_nic_t *enp); extern void -hunt_tx_fini( +ef10_tx_fini( __in efx_nic_t *enp); extern __checkReturn efx_rc_t -hunt_tx_qcreate( +ef10_tx_qcreate( __in efx_nic_t *enp, __in unsigned int index, __in unsigned int label, @@ -593,11 +619,11 @@ hunt_tx_qcreate( __out unsigned int *addedp); extern void -hunt_tx_qdestroy( +ef10_tx_qdestroy( __in efx_txq_t *etp); extern __checkReturn efx_rc_t -hunt_tx_qpost( +ef10_tx_qpost( __in efx_txq_t *etp, __in_ecount(n) efx_buffer_t *eb, __in unsigned int n, @@ -605,48 +631,48 @@ hunt_tx_qpost( __inout unsigned int *addedp); extern void -hunt_tx_qpush( +ef10_tx_qpush( __in efx_txq_t *etp, __in unsigned int added, __in unsigned int pushed); extern __checkReturn efx_rc_t -hunt_tx_qpace( +ef10_tx_qpace( __in efx_txq_t *etp, __in unsigned int ns); extern __checkReturn efx_rc_t -hunt_tx_qflush( +ef10_tx_qflush( __in efx_txq_t *etp); extern void -hunt_tx_qenable( +ef10_tx_qenable( __in efx_txq_t *etp); extern __checkReturn efx_rc_t -hunt_tx_qpio_enable( +ef10_tx_qpio_enable( __in efx_txq_t *etp); extern void -hunt_tx_qpio_disable( +ef10_tx_qpio_disable( __in efx_txq_t *etp); extern __checkReturn efx_rc_t -hunt_tx_qpio_write( +ef10_tx_qpio_write( __in efx_txq_t *etp, __in_ecount(buf_length) uint8_t *buffer, __in size_t buf_length, __in size_t pio_buf_offset); extern __checkReturn efx_rc_t -hunt_tx_qpio_post( +ef10_tx_qpio_post( __in efx_txq_t *etp, __in size_t pkt_length, __in unsigned int completed, __inout unsigned int *addedp); extern __checkReturn efx_rc_t -hunt_tx_qdesc_post( +ef10_tx_qdesc_post( __in efx_txq_t *etp, __in_ecount(n) efx_desc_t *ed, __in unsigned int n, @@ -654,7 +680,7 @@ hunt_tx_qdesc_post( __inout unsigned int *addedp); extern void -hunt_tx_qdesc_dma_create( +ef10_tx_qdesc_dma_create( __in efx_txq_t *etp, __in efsys_dma_addr_t addr, __in size_t size, @@ -670,7 +696,7 @@ hunt_tx_qdesc_tso_create( __out efx_desc_t *edp); extern void -hunt_tx_qdesc_vlantci_create( +ef10_tx_qdesc_vlantci_create( __in efx_txq_t *etp, __in uint16_t vlan_tci, __out efx_desc_t *edp); @@ -679,7 +705,7 @@ hunt_tx_qdesc_vlantci_create( #if EFSYS_OPT_QSTATS extern void -hunt_tx_qstats_update( +ef10_tx_qstats_update( __in efx_txq_t *etp, __inout_ecount(TX_NQSTATS) efsys_stat_t *stat); @@ -727,7 +753,7 @@ typedef uint32_t efx_piobuf_handle_t; #define EFX_PIOBUF_HANDLE_INVALID ((efx_piobuf_handle_t) -1) extern __checkReturn efx_rc_t -hunt_nic_pio_alloc( +ef10_nic_pio_alloc( __inout efx_nic_t *enp, __out uint32_t *bufnump, __out efx_piobuf_handle_t *handlep, @@ -736,19 +762,19 @@ hunt_nic_pio_alloc( __out size_t *sizep); extern __checkReturn efx_rc_t -hunt_nic_pio_free( +ef10_nic_pio_free( __inout efx_nic_t *enp, __in uint32_t bufnum, __in uint32_t blknum); extern __checkReturn efx_rc_t -hunt_nic_pio_link( +ef10_nic_pio_link( __inout efx_nic_t *enp, __in uint32_t vi_index, __in efx_piobuf_handle_t handle); extern __checkReturn efx_rc_t -hunt_nic_pio_unlink( +ef10_nic_pio_unlink( __inout efx_nic_t *enp, __in uint32_t vi_index); @@ -758,48 +784,48 @@ hunt_nic_pio_unlink( #if EFSYS_OPT_VPD extern __checkReturn efx_rc_t -hunt_vpd_init( +ef10_vpd_init( __in efx_nic_t *enp); extern __checkReturn efx_rc_t -hunt_vpd_size( +ef10_vpd_size( __in efx_nic_t *enp, __out size_t *sizep); extern __checkReturn efx_rc_t -hunt_vpd_read( +ef10_vpd_read( __in efx_nic_t *enp, __out_bcount(size) caddr_t data, __in size_t size); extern __checkReturn efx_rc_t -hunt_vpd_verify( +ef10_vpd_verify( __in efx_nic_t *enp, __in_bcount(size) caddr_t data, __in size_t size); extern __checkReturn efx_rc_t -hunt_vpd_reinit( +ef10_vpd_reinit( __in efx_nic_t *enp, __in_bcount(size) caddr_t data, __in size_t size); extern __checkReturn efx_rc_t -hunt_vpd_get( +ef10_vpd_get( __in efx_nic_t *enp, __in_bcount(size) caddr_t data, __in size_t size, __inout efx_vpd_value_t *evvp); extern __checkReturn efx_rc_t -hunt_vpd_set( +ef10_vpd_set( __in efx_nic_t *enp, __in_bcount(size) caddr_t data, __in size_t size, __in efx_vpd_value_t *evvp); extern __checkReturn efx_rc_t -hunt_vpd_next( +ef10_vpd_next( __in efx_nic_t *enp, __in_bcount(size) caddr_t data, __in size_t size, @@ -807,13 +833,13 @@ hunt_vpd_next( __inout unsigned int *contp); extern __checkReturn efx_rc_t -hunt_vpd_write( +ef10_vpd_write( __in efx_nic_t *enp, __in_bcount(size) caddr_t data, __in size_t size); extern void -hunt_vpd_fini( +ef10_vpd_fini( __in efx_nic_t *enp); #endif /* EFSYS_OPT_VPD */ @@ -822,20 +848,12 @@ hunt_vpd_fini( /* RX */ extern __checkReturn efx_rc_t -hunt_rx_init( +ef10_rx_init( __in efx_nic_t *enp); -#if EFSYS_OPT_RX_HDR_SPLIT -extern __checkReturn efx_rc_t -hunt_rx_hdr_split_enable( - __in efx_nic_t *enp, - __in unsigned int hdr_buf_size, - __in unsigned int pld_buf_size); -#endif /* EFSYS_OPT_RX_HDR_SPLIT */ - #if EFSYS_OPT_RX_SCATTER extern __checkReturn efx_rc_t -hunt_rx_scatter_enable( +ef10_rx_scatter_enable( __in efx_nic_t *enp, __in unsigned int buf_size); #endif /* EFSYS_OPT_RX_SCATTER */ @@ -844,28 +862,40 @@ hunt_rx_scatter_enable( #if EFSYS_OPT_RX_SCALE extern __checkReturn efx_rc_t -hunt_rx_scale_mode_set( +ef10_rx_scale_mode_set( __in efx_nic_t *enp, __in efx_rx_hash_alg_t alg, __in efx_rx_hash_type_t type, __in boolean_t insert); extern __checkReturn efx_rc_t -hunt_rx_scale_key_set( +ef10_rx_scale_key_set( __in efx_nic_t *enp, __in_ecount(n) uint8_t *key, __in size_t n); extern __checkReturn efx_rc_t -hunt_rx_scale_tbl_set( +ef10_rx_scale_tbl_set( __in efx_nic_t *enp, __in_ecount(n) unsigned int *table, __in size_t n); +extern __checkReturn uint32_t +ef10_rx_prefix_hash( + __in efx_nic_t *enp, + __in efx_rx_hash_alg_t func, + __in uint8_t *buffer); + +extern __checkReturn efx_rc_t +ef10_rx_prefix_pktlen( + __in efx_nic_t *enp, + __in uint8_t *buffer, + __out uint16_t *lengthp); + #endif /* EFSYS_OPT_RX_SCALE */ extern void -hunt_rx_qpost( +ef10_rx_qpost( __in efx_rxq_t *erp, __in_ecount(n) efsys_dma_addr_t *addrp, __in size_t size, @@ -874,21 +904,21 @@ hunt_rx_qpost( __in unsigned int added); extern void -hunt_rx_qpush( +ef10_rx_qpush( __in efx_rxq_t *erp, __in unsigned int added, __inout unsigned int *pushedp); extern __checkReturn efx_rc_t -hunt_rx_qflush( +ef10_rx_qflush( __in efx_rxq_t *erp); extern void -hunt_rx_qenable( +ef10_rx_qenable( __in efx_rxq_t *erp); extern __checkReturn efx_rc_t -hunt_rx_qcreate( +ef10_rx_qcreate( __in efx_nic_t *enp, __in unsigned int index, __in unsigned int label, @@ -900,80 +930,84 @@ hunt_rx_qcreate( __in efx_rxq_t *erp); extern void -hunt_rx_qdestroy( +ef10_rx_qdestroy( __in efx_rxq_t *erp); extern void -hunt_rx_fini( +ef10_rx_fini( __in efx_nic_t *enp); #if EFSYS_OPT_FILTER -typedef struct hunt_filter_handle_s { - uint32_t hfh_lo; - uint32_t hfh_hi; -} hunt_filter_handle_t; +typedef struct ef10_filter_handle_s { + uint32_t efh_lo; + uint32_t efh_hi; +} ef10_filter_handle_t; -typedef struct hunt_filter_entry_s { - uintptr_t hfe_spec; /* pointer to filter spec plus busy bit */ - hunt_filter_handle_t hfe_handle; -} hunt_filter_entry_t; +typedef struct ef10_filter_entry_s { + uintptr_t efe_spec; /* pointer to filter spec plus busy bit */ + ef10_filter_handle_t efe_handle; +} ef10_filter_entry_t; /* * BUSY flag indicates that an update is in progress. * AUTO_OLD flag is used to mark and sweep MAC packet filters. */ -#define EFX_HUNT_FILTER_FLAG_BUSY 1U -#define EFX_HUNT_FILTER_FLAG_AUTO_OLD 2U -#define EFX_HUNT_FILTER_FLAGS 3U +#define EFX_EF10_FILTER_FLAG_BUSY 1U +#define EFX_EF10_FILTER_FLAG_AUTO_OLD 2U +#define EFX_EF10_FILTER_FLAGS 3U -#define EFX_HUNT_FILTER_TBL_ROWS 8192 +/* + * Size of the hash table used by the driver. Doesn't need to be the + * same size as the hardware's table. + */ +#define EFX_EF10_FILTER_TBL_ROWS 8192 /* Allow for the broadcast address to be added to the multicast list */ -#define EFX_HUNT_FILTER_MULTICAST_FILTERS_MAX (EFX_MAC_MULTICAST_LIST_MAX + 1) - -typedef struct hunt_filter_table_s { - hunt_filter_entry_t hft_entry[EFX_HUNT_FILTER_TBL_ROWS]; - efx_rxq_t * hft_default_rxq; - boolean_t hft_using_rss; - uint32_t hft_unicst_filter_index; - boolean_t hft_unicst_filter_set; - uint32_t hft_mulcst_filter_indexes[ - EFX_HUNT_FILTER_MULTICAST_FILTERS_MAX]; - uint32_t hft_mulcst_filter_count; -} hunt_filter_table_t; +#define EFX_EF10_FILTER_MULTICAST_FILTERS_MAX (EFX_MAC_MULTICAST_LIST_MAX + 1) + +typedef struct ef10_filter_table_s { + ef10_filter_entry_t eft_entry[EFX_EF10_FILTER_TBL_ROWS]; + efx_rxq_t * eft_default_rxq; + boolean_t eft_using_rss; + uint32_t eft_unicst_filter_index; + boolean_t eft_unicst_filter_set; + uint32_t eft_mulcst_filter_indexes[ + EFX_EF10_FILTER_MULTICAST_FILTERS_MAX]; + uint32_t eft_mulcst_filter_count; +} ef10_filter_table_t; __checkReturn efx_rc_t -hunt_filter_init( +ef10_filter_init( __in efx_nic_t *enp); void -hunt_filter_fini( +ef10_filter_fini( __in efx_nic_t *enp); __checkReturn efx_rc_t -hunt_filter_restore( +ef10_filter_restore( __in efx_nic_t *enp); __checkReturn efx_rc_t -hunt_filter_add( +ef10_filter_add( __in efx_nic_t *enp, __inout efx_filter_spec_t *spec, __in boolean_t may_replace); __checkReturn efx_rc_t -hunt_filter_delete( +ef10_filter_delete( __in efx_nic_t *enp, __inout efx_filter_spec_t *spec); extern __checkReturn efx_rc_t -hunt_filter_supported_filters( +ef10_filter_supported_filters( __in efx_nic_t *enp, __out uint32_t *list, __out size_t *length); extern __checkReturn efx_rc_t -hunt_filter_reconfigure( +ef10_filter_reconfigure( __in efx_nic_t *enp, __in_ecount(6) uint8_t const *mac_addr, __in boolean_t all_unicst, @@ -984,45 +1018,25 @@ hunt_filter_reconfigure( __in int count); extern void -hunt_filter_get_default_rxq( +ef10_filter_get_default_rxq( __in efx_nic_t *enp, __out efx_rxq_t **erpp, __out boolean_t *using_rss); extern void -hunt_filter_default_rxq_set( +ef10_filter_default_rxq_set( __in efx_nic_t *enp, __in efx_rxq_t *erp, __in boolean_t using_rss); extern void -hunt_filter_default_rxq_clear( +ef10_filter_default_rxq_clear( __in efx_nic_t *enp); #endif /* EFSYS_OPT_FILTER */ extern __checkReturn efx_rc_t -hunt_pktfilter_set( - __in efx_nic_t *enp, - __in boolean_t unicst, - __in boolean_t brdcst); - -#if EFSYS_OPT_MCAST_FILTER_LIST - -extern __checkReturn efx_rc_t -hunt_pktfilter_mcast_set( - __in efx_nic_t *enp, - __in uint8_t const *addrs, - __in int count); - -#endif /* EFSYS_OPT_MCAST_FILTER_LIST */ - -extern __checkReturn efx_rc_t -hunt_pktfilter_mcast_all( - __in efx_nic_t *enp); - -extern __checkReturn efx_rc_t efx_mcdi_get_function_info( __in efx_nic_t *enp, __out uint32_t *pfp, diff --git a/sys/dev/sfxge/common/hunt_intr.c b/sys/dev/sfxge/common/hunt_intr.c index d5e977a..7a4293c 100644 --- a/sys/dev/sfxge/common/hunt_intr.c +++ b/sys/dev/sfxge/common/hunt_intr.c @@ -31,7 +31,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" #include "efx_impl.h" @@ -39,7 +38,7 @@ __FBSDID("$FreeBSD$"); #if EFSYS_OPT_HUNTINGTON __checkReturn efx_rc_t -hunt_intr_init( +ef10_intr_init( __in efx_nic_t *enp, __in efx_intr_type_t type, __in efsys_mem_t *esmp) @@ -50,7 +49,7 @@ hunt_intr_init( void -hunt_intr_enable( +ef10_intr_enable( __in efx_nic_t *enp) { _NOTE(ARGUNUSED(enp)) @@ -58,7 +57,7 @@ hunt_intr_enable( void -hunt_intr_disable( +ef10_intr_disable( __in efx_nic_t *enp) { _NOTE(ARGUNUSED(enp)) @@ -66,7 +65,7 @@ hunt_intr_disable( void -hunt_intr_disable_unlocked( +ef10_intr_disable_unlocked( __in efx_nic_t *enp) { _NOTE(ARGUNUSED(enp)) @@ -83,7 +82,8 @@ efx_mcdi_trigger_interrupt( MC_CMD_TRIGGER_INTERRUPT_OUT_LEN)]; efx_rc_t rc; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); if (level >= enp->en_nic_cfg.enc_intr_limit) { rc = EINVAL; @@ -118,7 +118,7 @@ fail1: } __checkReturn efx_rc_t -hunt_intr_trigger( +ef10_intr_trigger( __in efx_nic_t *enp, __in unsigned int level) { @@ -126,7 +126,10 @@ hunt_intr_trigger( efx_rc_t rc; if (encp->enc_bug41750_workaround) { - /* bug 41750: Test interrupts don't work on Greenport */ + /* + * bug 41750: Test interrupts don't work on Greenport + * bug 50084: Test interrupts don't work on VFs + */ rc = ENOTSUP; goto fail1; } @@ -144,9 +147,51 @@ fail1: return (rc); } + void +ef10_intr_status_line( + __in efx_nic_t *enp, + __out boolean_t *fatalp, + __out uint32_t *qmaskp) +{ + efx_dword_t dword; + + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); + + /* Read the queue mask and implicitly acknowledge the interrupt. */ + EFX_BAR_READD(enp, ER_DZ_BIU_INT_ISR_REG, &dword, B_FALSE); + *qmaskp = EFX_DWORD_FIELD(dword, EFX_DWORD_0); + + EFSYS_PROBE1(qmask, uint32_t, *qmaskp); + + *fatalp = B_FALSE; +} + + void +ef10_intr_status_message( + __in efx_nic_t *enp, + __in unsigned int message, + __out boolean_t *fatalp) +{ + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); + + _NOTE(ARGUNUSED(enp, message)) + + /* EF10 fatal errors are reported via events */ + *fatalp = B_FALSE; +} + + void +ef10_intr_fatal( + __in efx_nic_t *enp) +{ + /* EF10 fatal errors are reported via events */ + _NOTE(ARGUNUSED(enp)) +} void -hunt_intr_fini( +ef10_intr_fini( __in efx_nic_t *enp) { _NOTE(ARGUNUSED(enp)) diff --git a/sys/dev/sfxge/common/hunt_mac.c b/sys/dev/sfxge/common/hunt_mac.c index 5d5d26f..358c4d9 100644 --- a/sys/dev/sfxge/common/hunt_mac.c +++ b/sys/dev/sfxge/common/hunt_mac.c @@ -31,7 +31,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" #include "efx_impl.h" @@ -281,9 +280,9 @@ hunt_mac_filter_default_rxq_set( boolean_t old_using_rss; efx_rc_t rc; - hunt_filter_get_default_rxq(enp, &old_rxq, &old_using_rss); + ef10_filter_get_default_rxq(enp, &old_rxq, &old_using_rss); - hunt_filter_default_rxq_set(enp, erp, using_rss); + ef10_filter_default_rxq_set(enp, erp, using_rss); rc = efx_filter_reconfigure(enp, epp->ep_mac_addr, epp->ep_all_unicst, epp->ep_mulcst, @@ -299,7 +298,7 @@ hunt_mac_filter_default_rxq_set( fail1: EFSYS_PROBE1(fail1, efx_rc_t, rc); - hunt_filter_default_rxq_set(enp, old_rxq, old_using_rss); + ef10_filter_default_rxq_set(enp, old_rxq, old_using_rss); return (rc); } @@ -310,7 +309,7 @@ hunt_mac_filter_default_rxq_clear( { efx_port_t *epp = &(enp->en_port); - hunt_filter_default_rxq_clear(enp); + ef10_filter_default_rxq_clear(enp); efx_filter_reconfigure(enp, epp->ep_mac_addr, epp->ep_all_unicst, epp->ep_mulcst, diff --git a/sys/dev/sfxge/common/hunt_mcdi.c b/sys/dev/sfxge/common/hunt_mcdi.c index 2e61e74..5b32150 100644 --- a/sys/dev/sfxge/common/hunt_mcdi.c +++ b/sys/dev/sfxge/common/hunt_mcdi.c @@ -31,17 +31,16 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" #include "efx_impl.h" -#if EFSYS_OPT_HUNTINGTON +#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD #if EFSYS_OPT_MCDI #ifndef WITH_MCDI_V2 -#error "WITH_MCDI_V2 required for Huntington MCDIv2 commands." +#error "WITH_MCDI_V2 required for EF10 MCDIv2 commands." #endif typedef enum efx_mcdi_header_type_e { @@ -77,18 +76,27 @@ typedef enum efx_mcdi_header_type_e { __checkReturn efx_rc_t -hunt_mcdi_init( +ef10_mcdi_init( __in efx_nic_t *enp, __in const efx_mcdi_transport_t *emtp) { + efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); efsys_mem_t *esmp = emtp->emt_dma_mem; efx_dword_t dword; efx_rc_t rc; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); EFSYS_ASSERT(enp->en_features & EFX_FEATURE_MCDI_DMA); - /* A host DMA buffer is required for Huntington MCDI */ + /* + * All EF10 firmware supports MCDIv2 and MCDIv1. + * Medford BootROM supports MCDIv2 and MCDIv1. + * Huntington BootROM supports MCDIv1 only. + */ + emip->emi_max_version = 2; + + /* A host DMA buffer is required for EF10 MCDI */ if (esmp == NULL) { rc = EINVAL; goto fail1; @@ -107,7 +115,7 @@ hunt_mcdi_init( EFX_BAR_WRITED(enp, ER_DZ_MC_DB_HWRD_REG, &dword, B_FALSE); /* Save initial MC reboot status */ - (void) hunt_mcdi_poll_reboot(enp); + (void) ef10_mcdi_poll_reboot(enp); /* Start a new epoch (allow fresh MCDI requests to succeed) */ efx_mcdi_new_epoch(enp); @@ -123,7 +131,7 @@ fail1: } void -hunt_mcdi_fini( +ef10_mcdi_fini( __in efx_nic_t *enp) { efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); @@ -131,36 +139,77 @@ hunt_mcdi_fini( emip->emi_new_epoch = B_FALSE; } +static void +ef10_mcdi_send_request( + __in efx_nic_t *enp, + __in void *hdrp, + __in size_t hdr_len, + __in void *sdup, + __in size_t sdu_len) +{ + const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp; + efsys_mem_t *esmp = emtp->emt_dma_mem; + efx_dword_t dword; + unsigned int pos; + + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); + + /* Write the header */ + for (pos = 0; pos < hdr_len; pos += sizeof (efx_dword_t)) { + dword = *(efx_dword_t *)((uint8_t *)hdrp + pos); + EFSYS_MEM_WRITED(esmp, pos, &dword); + } + + /* Write the payload */ + for (pos = 0; pos < sdu_len; pos += sizeof (efx_dword_t)) { + dword = *(efx_dword_t *)((uint8_t *)sdup + pos); + EFSYS_MEM_WRITED(esmp, hdr_len + pos, &dword); + } + + /* Guarantee ordering of memory (MCDI request) and PIO (MC doorbell) */ + EFSYS_DMA_SYNC_FOR_DEVICE(esmp, 0, hdr_len + sdu_len); + EFSYS_PIO_WRITE_BARRIER(); + + /* Ring the doorbell to post the command DMA address to the MC */ + EFX_POPULATE_DWORD_1(dword, EFX_DWORD_0, + EFSYS_MEM_ADDR(esmp) >> 32); + EFX_BAR_WRITED(enp, ER_DZ_MC_DB_LWRD_REG, &dword, B_FALSE); + + EFX_POPULATE_DWORD_1(dword, EFX_DWORD_0, + EFSYS_MEM_ADDR(esmp) & 0xffffffff); + EFX_BAR_WRITED(enp, ER_DZ_MC_DB_HWRD_REG, &dword, B_FALSE); +} + void -hunt_mcdi_request_copyin( +ef10_mcdi_request_copyin( __in efx_nic_t *enp, __in efx_mcdi_req_t *emrp, __in unsigned int seq, __in boolean_t ev_cpl, __in boolean_t new_epoch) { +#if EFSYS_OPT_MCDI_LOGGING const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp; - efsys_mem_t *esmp = emtp->emt_dma_mem; +#endif /* EFSYS_OPT_MCDI_LOGGING */ efx_mcdi_header_type_t hdr_type; - efx_dword_t dword; efx_dword_t hdr[2]; + size_t hdr_len; unsigned int xflags; - unsigned int pos; - size_t offset; - EFSYS_ASSERT3U(enp->en_family, ==, EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); xflags = 0; if (ev_cpl) xflags |= MCDI_HEADER_XFLAGS_EVREQ; - offset = 0; - hdr_type = EFX_MCDI_HEADER_TYPE(emrp->emr_cmd, MAX(emrp->emr_in_length, emrp->emr_out_length)); if (hdr_type == EFX_MCDI_HEADER_TYPE_V2) { /* Construct MCDI v2 header */ + hdr_len = sizeof (hdr); EFX_POPULATE_DWORD_8(hdr[0], MCDI_HEADER_CODE, MC_CMD_V2_EXTN, MCDI_HEADER_RESYNC, 1, @@ -170,16 +219,13 @@ hunt_mcdi_request_copyin( MCDI_HEADER_ERROR, 0, MCDI_HEADER_RESPONSE, 0, MCDI_HEADER_XFLAGS, xflags); - EFSYS_MEM_WRITED(esmp, offset, &hdr[0]); - offset += sizeof (efx_dword_t); EFX_POPULATE_DWORD_2(hdr[1], MC_CMD_V2_EXTN_IN_EXTENDED_CMD, emrp->emr_cmd, MC_CMD_V2_EXTN_IN_ACTUAL_LEN, emrp->emr_in_length); - EFSYS_MEM_WRITED(esmp, offset, &hdr[1]); - offset += sizeof (efx_dword_t); } else { /* Construct MCDI v1 header */ + hdr_len = sizeof (hdr[0]); EFX_POPULATE_DWORD_8(hdr[0], MCDI_HEADER_CODE, emrp->emr_cmd, MCDI_HEADER_RESYNC, 1, @@ -189,43 +235,22 @@ hunt_mcdi_request_copyin( MCDI_HEADER_ERROR, 0, MCDI_HEADER_RESPONSE, 0, MCDI_HEADER_XFLAGS, xflags); - EFSYS_MEM_WRITED(esmp, 0, &hdr[0]); - offset += sizeof (efx_dword_t); } #if EFSYS_OPT_MCDI_LOGGING if (emtp->emt_logger != NULL) { emtp->emt_logger(emtp->emt_context, EFX_LOG_MCDI_REQUEST, - &hdr, offset, + &hdr, hdr_len, emrp->emr_in_buf, emrp->emr_in_length); } #endif /* EFSYS_OPT_MCDI_LOGGING */ - /* Construct the payload */ - for (pos = 0; pos < emrp->emr_in_length; pos += sizeof (efx_dword_t)) { - memcpy(&dword, MCDI_IN(*emrp, efx_dword_t, pos), - MIN(sizeof (dword), emrp->emr_in_length - pos)); - EFSYS_MEM_WRITED(esmp, offset + pos, &dword); - } - - /* Ring the doorbell to post the command DMA address to the MC */ - EFSYS_ASSERT((EFSYS_MEM_ADDR(esmp) & 0xFF) == 0); - - /* Guarantee ordering of memory (MCDI request) and PIO (MC doorbell) */ - EFSYS_DMA_SYNC_FOR_DEVICE(esmp, 0, offset + emrp->emr_in_length); - EFSYS_PIO_WRITE_BARRIER(); - - EFX_POPULATE_DWORD_1(dword, - EFX_DWORD_0, EFSYS_MEM_ADDR(esmp) >> 32); - EFX_BAR_WRITED(enp, ER_DZ_MC_DB_LWRD_REG, &dword, B_FALSE); - - EFX_POPULATE_DWORD_1(dword, - EFX_DWORD_0, EFSYS_MEM_ADDR(esmp) & 0xffffffff); - EFX_BAR_WRITED(enp, ER_DZ_MC_DB_HWRD_REG, &dword, B_FALSE); + ef10_mcdi_send_request(enp, &hdr[0], hdr_len, + emrp->emr_in_buf, emrp->emr_in_length); } void -hunt_mcdi_request_copyout( +ef10_mcdi_request_copyout( __in efx_nic_t *enp, __in efx_mcdi_req_t *emrp) { @@ -241,13 +266,13 @@ hunt_mcdi_request_copyout( /* Read the command header to detect MCDI response format */ hdr_len = sizeof (hdr[0]); - hunt_mcdi_read_response(enp, &hdr[0], 0, hdr_len); + ef10_mcdi_read_response(enp, &hdr[0], 0, hdr_len); if (EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_CODE) == MC_CMD_V2_EXTN) { /* * Read the actual payload length. The length given in the event * is only correct for responses with the V1 format. */ - hunt_mcdi_read_response(enp, &hdr[1], hdr_len, sizeof (hdr[1])); + ef10_mcdi_read_response(enp, &hdr[1], hdr_len, sizeof (hdr[1])); hdr_len += sizeof (hdr[1]); emrp->emr_out_length_used = EFX_DWORD_FIELD(hdr[1], @@ -256,7 +281,7 @@ hunt_mcdi_request_copyout( /* Copy payload out into caller supplied buffer */ bytes = MIN(emrp->emr_out_length_used, emrp->emr_out_length); - hunt_mcdi_read_response(enp, emrp->emr_out_buf, hdr_len, bytes); + ef10_mcdi_read_response(enp, emrp->emr_out_buf, hdr_len, bytes); #if EFSYS_OPT_MCDI_LOGGING if (emtp->emt_logger != NULL) { @@ -269,7 +294,7 @@ hunt_mcdi_request_copyout( } __checkReturn boolean_t -hunt_mcdi_poll_response( +ef10_mcdi_poll_response( __in efx_nic_t *enp) { const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp; @@ -281,7 +306,7 @@ hunt_mcdi_poll_response( } void -hunt_mcdi_read_response( +ef10_mcdi_read_response( __in efx_nic_t *enp, __out void *bufferp, __in size_t offset, @@ -300,7 +325,7 @@ hunt_mcdi_read_response( } efx_rc_t -hunt_mcdi_poll_reboot( +ef10_mcdi_poll_reboot( __in efx_nic_t *enp) { efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); @@ -324,7 +349,7 @@ hunt_mcdi_poll_reboot( * * The Siena support for checking for MC reboot from status * flags is broken - see comments in siena_mcdi_poll_reboot(). - * As the generic MCDI code is shared the Huntington reboot + * As the generic MCDI code is shared the EF10 reboot * detection suffers similar problems. * * Do not report an error when the boot status changes until @@ -346,7 +371,7 @@ fail1: } __checkReturn efx_rc_t -hunt_mcdi_feature_supported( +ef10_mcdi_feature_supported( __in efx_nic_t *enp, __in efx_mcdi_feature_id_t id, __out boolean_t *supportedp) @@ -355,7 +380,8 @@ hunt_mcdi_feature_supported( uint32_t privilege_mask = encp->enc_privilege_mask; efx_rc_t rc; - EFSYS_ASSERT3U(enp->en_family, ==, EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); /* * Use privilege mask state at MCDI attach. @@ -417,4 +443,4 @@ fail1: #endif /* EFSYS_OPT_MCDI */ -#endif /* EFSYS_OPT_HUNTINGTON */ +#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ diff --git a/sys/dev/sfxge/common/hunt_nic.c b/sys/dev/sfxge/common/hunt_nic.c index 2869ad5..d87f3cd 100644 --- a/sys/dev/sfxge/common/hunt_nic.c +++ b/sys/dev/sfxge/common/hunt_nic.c @@ -31,10 +31,11 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" #include "efx_impl.h" +#if EFSYS_OPT_MON_MCDI #include "mcdi_mon.h" +#endif #if EFSYS_OPT_HUNTINGTON @@ -50,7 +51,8 @@ efx_mcdi_get_port_assignment( MC_CMD_GET_PORT_ASSIGNMENT_OUT_LEN)]; efx_rc_t rc; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); (void) memset(payload, 0, sizeof (payload)); req.emr_cmd = MC_CMD_GET_PORT_ASSIGNMENT; @@ -93,7 +95,8 @@ efx_mcdi_get_port_modes( MC_CMD_GET_PORT_MODES_OUT_LEN)]; efx_rc_t rc; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); (void) memset(payload, 0, sizeof (payload)); req.emr_cmd = MC_CMD_GET_PORT_MODES; @@ -212,7 +215,8 @@ efx_mcdi_get_mac_address_pf( MC_CMD_GET_MAC_ADDRESSES_OUT_LEN)]; efx_rc_t rc; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); (void) memset(payload, 0, sizeof (payload)); req.emr_cmd = MC_CMD_GET_MAC_ADDRESSES; @@ -269,7 +273,8 @@ efx_mcdi_get_mac_address_vf( MC_CMD_VPORT_GET_MAC_ADDRESSES_OUT_LENMAX)]; efx_rc_t rc; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); (void) memset(payload, 0, sizeof (payload)); req.emr_cmd = MC_CMD_VPORT_GET_MAC_ADDRESSES; @@ -331,7 +336,8 @@ efx_mcdi_get_clock( MC_CMD_GET_CLOCK_OUT_LEN)]; efx_rc_t rc; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); (void) memset(payload, 0, sizeof (payload)); req.emr_cmd = MC_CMD_GET_CLOCK; @@ -421,11 +427,12 @@ fail1: static __checkReturn efx_rc_t efx_mcdi_get_capabilities( __in efx_nic_t *enp, - __out efx_dword_t *flagsp) + __out efx_dword_t *flagsp, + __out efx_dword_t *flags2p) { efx_mcdi_req_t req; uint8_t payload[MAX(MC_CMD_GET_CAPABILITIES_IN_LEN, - MC_CMD_GET_CAPABILITIES_OUT_LEN)]; + MC_CMD_GET_CAPABILITIES_V2_OUT_LEN)]; efx_rc_t rc; (void) memset(payload, 0, sizeof (payload)); @@ -433,7 +440,7 @@ efx_mcdi_get_capabilities( req.emr_in_buf = payload; req.emr_in_length = MC_CMD_GET_CAPABILITIES_IN_LEN; req.emr_out_buf = payload; - req.emr_out_length = MC_CMD_GET_CAPABILITIES_OUT_LEN; + req.emr_out_length = MC_CMD_GET_CAPABILITIES_V2_OUT_LEN; efx_mcdi_execute(enp, &req); @@ -449,6 +456,12 @@ efx_mcdi_get_capabilities( *flagsp = *MCDI_OUT2(req, efx_dword_t, GET_CAPABILITIES_OUT_FLAGS1); + if (req.emr_out_length_used < MC_CMD_GET_CAPABILITIES_V2_OUT_LEN) + EFX_ZERO_DWORD(*flags2p); + else + *flags2p = *MCDI_OUT2(req, efx_dword_t, + GET_CAPABILITIES_V2_OUT_FLAGS2); + return (0); fail2: @@ -465,9 +478,9 @@ efx_mcdi_alloc_vis( __in efx_nic_t *enp, __in uint32_t min_vi_count, __in uint32_t max_vi_count, - __out_opt uint32_t *vi_basep, - __out uint32_t *vi_countp) - + __out uint32_t *vi_basep, + __out uint32_t *vi_countp, + __out uint32_t *vi_shiftp) { efx_mcdi_req_t req; uint8_t payload[MAX(MC_CMD_ALLOC_VIS_IN_LEN, @@ -501,11 +514,14 @@ efx_mcdi_alloc_vis( goto fail3; } - if (vi_basep != NULL) - *vi_basep = MCDI_OUT_DWORD(req, ALLOC_VIS_OUT_VI_BASE); + *vi_basep = MCDI_OUT_DWORD(req, ALLOC_VIS_OUT_VI_BASE); + *vi_countp = MCDI_OUT_DWORD(req, ALLOC_VIS_OUT_VI_COUNT); - if (vi_countp != NULL) - *vi_countp = MCDI_OUT_DWORD(req, ALLOC_VIS_OUT_VI_COUNT); + /* Report VI_SHIFT if available (always zero for Huntington) */ + if (req.emr_out_length_used < MC_CMD_ALLOC_VIS_EXT_OUT_LEN) + *vi_shiftp = 0; + else + *vi_shiftp = MCDI_OUT_DWORD(req, ALLOC_VIS_EXT_OUT_VI_SHIFT); return (0); @@ -706,7 +722,7 @@ fail1: } static void -hunt_nic_alloc_piobufs( +ef10_nic_alloc_piobufs( __in efx_nic_t *enp, __in uint32_t max_piobuf_count) { @@ -715,52 +731,52 @@ hunt_nic_alloc_piobufs( efx_rc_t rc; EFSYS_ASSERT3U(max_piobuf_count, <=, - EFX_ARRAY_SIZE(enp->en_u.hunt.enu_piobuf_handle)); + EFX_ARRAY_SIZE(enp->en_arch.ef10.ena_piobuf_handle)); - enp->en_u.hunt.enu_piobuf_count = 0; + enp->en_arch.ef10.ena_piobuf_count = 0; for (i = 0; i < max_piobuf_count; i++) { - handlep = &enp->en_u.hunt.enu_piobuf_handle[i]; + handlep = &enp->en_arch.ef10.ena_piobuf_handle[i]; if ((rc = efx_mcdi_alloc_piobuf(enp, handlep)) != 0) goto fail1; - enp->en_u.hunt.enu_pio_alloc_map[i] = 0; - enp->en_u.hunt.enu_piobuf_count++; + enp->en_arch.ef10.ena_pio_alloc_map[i] = 0; + enp->en_arch.ef10.ena_piobuf_count++; } return; fail1: - for (i = 0; i < enp->en_u.hunt.enu_piobuf_count; i++) { - handlep = &enp->en_u.hunt.enu_piobuf_handle[i]; + for (i = 0; i < enp->en_arch.ef10.ena_piobuf_count; i++) { + handlep = &enp->en_arch.ef10.ena_piobuf_handle[i]; efx_mcdi_free_piobuf(enp, *handlep); *handlep = EFX_PIOBUF_HANDLE_INVALID; } - enp->en_u.hunt.enu_piobuf_count = 0; + enp->en_arch.ef10.ena_piobuf_count = 0; } static void -hunt_nic_free_piobufs( +ef10_nic_free_piobufs( __in efx_nic_t *enp) { efx_piobuf_handle_t *handlep; unsigned int i; - for (i = 0; i < enp->en_u.hunt.enu_piobuf_count; i++) { - handlep = &enp->en_u.hunt.enu_piobuf_handle[i]; + for (i = 0; i < enp->en_arch.ef10.ena_piobuf_count; i++) { + handlep = &enp->en_arch.ef10.ena_piobuf_handle[i]; efx_mcdi_free_piobuf(enp, *handlep); *handlep = EFX_PIOBUF_HANDLE_INVALID; } - enp->en_u.hunt.enu_piobuf_count = 0; + enp->en_arch.ef10.ena_piobuf_count = 0; } /* Sub-allocate a block from a piobuf */ __checkReturn efx_rc_t -hunt_nic_pio_alloc( +ef10_nic_pio_alloc( __inout efx_nic_t *enp, __out uint32_t *bufnump, __out efx_piobuf_handle_t *handlep, @@ -768,12 +784,14 @@ hunt_nic_pio_alloc( __out uint32_t *offsetp, __out size_t *sizep) { + efx_nic_cfg_t *encp = &enp->en_nic_cfg; efx_drv_cfg_t *edcp = &enp->en_drv_cfg; uint32_t blk_per_buf; uint32_t buf, blk; efx_rc_t rc; - EFSYS_ASSERT3U(enp->en_family, ==, EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); EFSYS_ASSERT(bufnump); EFSYS_ASSERT(handlep); EFSYS_ASSERT(blknump); @@ -781,14 +799,14 @@ hunt_nic_pio_alloc( EFSYS_ASSERT(sizep); if ((edcp->edc_pio_alloc_size == 0) || - (enp->en_u.hunt.enu_piobuf_count == 0)) { + (enp->en_arch.ef10.ena_piobuf_count == 0)) { rc = ENOMEM; goto fail1; } - blk_per_buf = HUNT_PIOBUF_SIZE / edcp->edc_pio_alloc_size; + blk_per_buf = encp->enc_piobuf_size / edcp->edc_pio_alloc_size; - for (buf = 0; buf < enp->en_u.hunt.enu_piobuf_count; buf++) { - uint32_t *map = &enp->en_u.hunt.enu_pio_alloc_map[buf]; + for (buf = 0; buf < enp->en_arch.ef10.ena_piobuf_count; buf++) { + uint32_t *map = &enp->en_arch.ef10.ena_pio_alloc_map[buf]; if (~(*map) == 0) continue; @@ -805,7 +823,7 @@ hunt_nic_pio_alloc( goto fail2; done: - *handlep = enp->en_u.hunt.enu_piobuf_handle[buf]; + *handlep = enp->en_arch.ef10.ena_piobuf_handle[buf]; *bufnump = buf; *blknump = blk; *sizep = edcp->edc_pio_alloc_size; @@ -823,7 +841,7 @@ fail1: /* Free a piobuf sub-allocated block */ __checkReturn efx_rc_t -hunt_nic_pio_free( +ef10_nic_pio_free( __inout efx_nic_t *enp, __in uint32_t bufnum, __in uint32_t blknum) @@ -831,13 +849,13 @@ hunt_nic_pio_free( uint32_t *map; efx_rc_t rc; - if ((bufnum >= enp->en_u.hunt.enu_piobuf_count) || + if ((bufnum >= enp->en_arch.ef10.ena_piobuf_count) || (blknum >= (8 * sizeof (*map)))) { rc = EINVAL; goto fail1; } - map = &enp->en_u.hunt.enu_pio_alloc_map[bufnum]; + map = &enp->en_arch.ef10.ena_pio_alloc_map[bufnum]; if ((*map & (1u << blknum)) == 0) { rc = ENOENT; goto fail2; @@ -855,7 +873,7 @@ fail1: } __checkReturn efx_rc_t -hunt_nic_pio_link( +ef10_nic_pio_link( __inout efx_nic_t *enp, __in uint32_t vi_index, __in efx_piobuf_handle_t handle) @@ -864,7 +882,7 @@ hunt_nic_pio_link( } __checkReturn efx_rc_t -hunt_nic_pio_unlink( +ef10_nic_pio_unlink( __inout efx_nic_t *enp, __in uint32_t vi_index) { @@ -872,14 +890,16 @@ hunt_nic_pio_unlink( } static __checkReturn efx_rc_t -hunt_get_datapath_caps( +ef10_get_datapath_caps( __in efx_nic_t *enp) { efx_nic_cfg_t *encp = &(enp->en_nic_cfg); efx_dword_t datapath_capabilities; + efx_dword_t datapath_capabilities_v2; efx_rc_t rc; - if ((rc = efx_mcdi_get_capabilities(enp, &datapath_capabilities)) != 0) + if ((rc = efx_mcdi_get_capabilities(enp, &datapath_capabilities, + &datapath_capabilities_v2)) != 0) goto fail1; /* @@ -963,7 +983,7 @@ static struct { efx_family_t family; uint32_t modes_mask; uint32_t stride; -} __hunt_external_port_mappings[] = { +} __ef10_external_port_mappings[] = { /* Supported modes requiring 1 output per port */ { EFX_FAMILY_HUNTINGTON, @@ -992,7 +1012,7 @@ static struct { }; static __checkReturn efx_rc_t -hunt_external_port_mapping( +ef10_external_port_mapping( __in efx_nic_t *enp, __in uint32_t port, __out uint8_t *external_portp) @@ -1012,14 +1032,14 @@ hunt_external_port_mapping( * Infer the internal port -> external port mapping from * the possible port modes for this NIC. */ - for (i = 0; i < EFX_ARRAY_SIZE(__hunt_external_port_mappings); ++i) { - if (__hunt_external_port_mappings[i].family != + for (i = 0; i < EFX_ARRAY_SIZE(__ef10_external_port_mappings); ++i) { + if (__ef10_external_port_mappings[i].family != enp->en_family) continue; - matches = (__hunt_external_port_mappings[i].modes_mask & + matches = (__ef10_external_port_mappings[i].modes_mask & port_modes); if (matches != 0) { - stride = __hunt_external_port_mappings[i].stride; + stride = __ef10_external_port_mappings[i].stride; port_modes &= ~matches; } } @@ -1072,7 +1092,7 @@ hunt_board_cfg( */ emip->emi_port = port + 1; - if ((rc = hunt_external_port_mapping(enp, port, + if ((rc = ef10_external_port_mapping(enp, port, &encp->enc_external_port)) != 0) goto fail2; @@ -1236,7 +1256,7 @@ hunt_board_cfg( } /* Check capabilities of running datapath firmware */ - if ((rc = hunt_get_datapath_caps(enp)) != 0) + if ((rc = ef10_get_datapath_caps(enp)) != 0) goto fail12; /* Alignment for receive packet DMA buffers */ @@ -1244,7 +1264,7 @@ hunt_board_cfg( encp->enc_rx_buf_align_end = 64; /* RX DMA end padding */ /* Alignment for WPTR updates */ - encp->enc_rx_push_align = HUNTINGTON_RX_WPTR_ALIGN; + encp->enc_rx_push_align = EF10_RX_WPTR_ALIGN; /* * Set resource limits for MC_CMD_ALLOC_VIS. Note that we cannot use @@ -1260,6 +1280,7 @@ hunt_board_cfg( encp->enc_piobuf_limit = HUNT_PIOBUF_NBUFS; encp->enc_piobuf_size = HUNT_PIOBUF_SIZE; + encp->enc_piobuf_min_alloc_size = HUNT_MIN_PIO_ALLOC_SIZE; /* * Get the current privilege mask. Note that this may be modified @@ -1337,14 +1358,15 @@ fail1: __checkReturn efx_rc_t -hunt_nic_probe( +ef10_nic_probe( __in efx_nic_t *enp) { efx_nic_cfg_t *encp = &(enp->en_nic_cfg); efx_drv_cfg_t *edcp = &(enp->en_drv_cfg); efx_rc_t rc; - EFSYS_ASSERT3U(enp->en_family, ==, EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); /* Read and clear any assertion state */ if ((rc = efx_mcdi_read_assertion(enp)) != 0) @@ -1424,7 +1446,7 @@ fail1: } __checkReturn efx_rc_t -hunt_nic_set_drv_limits( +ef10_nic_set_drv_limits( __inout efx_nic_t *enp, __in efx_drv_limits_t *edlp) { @@ -1470,7 +1492,8 @@ hunt_nic_set_drv_limits( uint32_t blk_size, blk_count, blks_per_piobuf; blk_size = - MAX(edlp->edl_min_pio_alloc_size, HUNT_MIN_PIO_ALLOC_SIZE); + MAX(edlp->edl_min_pio_alloc_size, + encp->enc_piobuf_min_alloc_size); blks_per_piobuf = encp->enc_piobuf_size / blk_size; EFSYS_ASSERT3U(blks_per_piobuf, <=, 32); @@ -1498,7 +1521,7 @@ fail1: __checkReturn efx_rc_t -hunt_nic_reset( +ef10_nic_reset( __in efx_nic_t *enp) { efx_mcdi_req_t req; @@ -1506,7 +1529,7 @@ hunt_nic_reset( MC_CMD_ENTITY_RESET_OUT_LEN)]; efx_rc_t rc; - /* hunt_nic_reset() is called to recover from BADASSERT failures. */ + /* ef10_nic_reset() is called to recover from BADASSERT failures. */ if ((rc = efx_mcdi_read_assertion(enp)) != 0) goto fail1; if ((rc = efx_mcdi_exit_assertion_handler(enp)) != 0) @@ -1545,25 +1568,26 @@ fail1: } __checkReturn efx_rc_t -hunt_nic_init( +ef10_nic_init( __in efx_nic_t *enp) { efx_drv_cfg_t *edcp = &(enp->en_drv_cfg); uint32_t min_vi_count, max_vi_count; - uint32_t vi_count, vi_base; + uint32_t vi_count, vi_base, vi_shift; uint32_t i; uint32_t retry; uint32_t delay_us; efx_rc_t rc; - EFSYS_ASSERT3U(enp->en_family, ==, EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); /* Enable reporting of some events (e.g. link change) */ if ((rc = efx_mcdi_log_ctrl(enp)) != 0) goto fail1; /* Allocate (optional) on-chip PIO buffers */ - hunt_nic_alloc_piobufs(enp, edcp->edc_max_piobuf_count); + ef10_nic_alloc_piobufs(enp, edcp->edc_max_piobuf_count); /* * For best performance, PIO writes should use a write-combined @@ -1579,7 +1603,8 @@ hunt_nic_init( * each VI that is using a sub-allocated block from the piobuf. */ min_vi_count = edcp->edc_min_vi_count; - max_vi_count = edcp->edc_max_vi_count + enp->en_u.hunt.enu_piobuf_count; + max_vi_count = + edcp->edc_max_vi_count + enp->en_arch.ef10.ena_piobuf_count; /* Ensure that the previously attached driver's VIs are freed */ if ((rc = efx_mcdi_free_vis(enp)) != 0) @@ -1591,7 +1616,7 @@ hunt_nic_init( */ vi_count = 0; if ((rc = efx_mcdi_alloc_vis(enp, min_vi_count, max_vi_count, - &vi_base, &vi_count)) != 0) + &vi_base, &vi_count, &vi_shift)) != 0) goto fail3; EFSYS_PROBE2(vi_alloc, uint32_t, vi_base, uint32_t, vi_count); @@ -1601,44 +1626,45 @@ hunt_nic_init( goto fail4; } - enp->en_u.hunt.enu_vi_base = vi_base; - enp->en_u.hunt.enu_vi_count = vi_count; + enp->en_arch.ef10.ena_vi_base = vi_base; + enp->en_arch.ef10.ena_vi_count = vi_count; + enp->en_arch.ef10.ena_vi_shift = vi_shift; - if (vi_count < min_vi_count + enp->en_u.hunt.enu_piobuf_count) { + if (vi_count < min_vi_count + enp->en_arch.ef10.ena_piobuf_count) { /* Not enough extra VIs to map piobufs */ - hunt_nic_free_piobufs(enp); + ef10_nic_free_piobufs(enp); } - enp->en_u.hunt.enu_pio_write_vi_base = - vi_count - enp->en_u.hunt.enu_piobuf_count; + enp->en_arch.ef10.ena_pio_write_vi_base = + vi_count - enp->en_arch.ef10.ena_piobuf_count; /* Save UC memory mapping details */ - enp->en_u.hunt.enu_uc_mem_map_offset = 0; - if (enp->en_u.hunt.enu_piobuf_count > 0) { - enp->en_u.hunt.enu_uc_mem_map_size = + enp->en_arch.ef10.ena_uc_mem_map_offset = 0; + if (enp->en_arch.ef10.ena_piobuf_count > 0) { + enp->en_arch.ef10.ena_uc_mem_map_size = (ER_DZ_TX_PIOBUF_STEP * - enp->en_u.hunt.enu_pio_write_vi_base); + enp->en_arch.ef10.ena_pio_write_vi_base); } else { - enp->en_u.hunt.enu_uc_mem_map_size = + enp->en_arch.ef10.ena_uc_mem_map_size = (ER_DZ_TX_PIOBUF_STEP * - enp->en_u.hunt.enu_vi_count); + enp->en_arch.ef10.ena_vi_count); } /* Save WC memory mapping details */ - enp->en_u.hunt.enu_wc_mem_map_offset = - enp->en_u.hunt.enu_uc_mem_map_offset + - enp->en_u.hunt.enu_uc_mem_map_size; + enp->en_arch.ef10.ena_wc_mem_map_offset = + enp->en_arch.ef10.ena_uc_mem_map_offset + + enp->en_arch.ef10.ena_uc_mem_map_size; - enp->en_u.hunt.enu_wc_mem_map_size = + enp->en_arch.ef10.ena_wc_mem_map_size = (ER_DZ_TX_PIOBUF_STEP * - enp->en_u.hunt.enu_piobuf_count); + enp->en_arch.ef10.ena_piobuf_count); /* Link piobufs to extra VIs in WC mapping */ - if (enp->en_u.hunt.enu_piobuf_count > 0) { - for (i = 0; i < enp->en_u.hunt.enu_piobuf_count; i++) { + if (enp->en_arch.ef10.ena_piobuf_count > 0) { + for (i = 0; i < enp->en_arch.ef10.ena_piobuf_count; i++) { rc = efx_mcdi_link_piobuf(enp, - enp->en_u.hunt.enu_pio_write_vi_base + i, - enp->en_u.hunt.enu_piobuf_handle[i]); + enp->en_arch.ef10.ena_pio_write_vi_base + i, + enp->en_arch.ef10.ena_piobuf_handle[i]); if (rc != 0) break; } @@ -1696,7 +1722,7 @@ fail3: fail2: EFSYS_PROBE(fail2); - hunt_nic_free_piobufs(enp); + ef10_nic_free_piobufs(enp); fail1: EFSYS_PROBE1(fail1, efx_rc_t, rc); @@ -1705,23 +1731,24 @@ fail1: } __checkReturn efx_rc_t -hunt_nic_get_vi_pool( +ef10_nic_get_vi_pool( __in efx_nic_t *enp, __out uint32_t *vi_countp) { - EFSYS_ASSERT3U(enp->en_family, ==, EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); /* * Report VIs that the client driver can use. * Do not include VIs used for PIO buffer writes. */ - *vi_countp = enp->en_u.hunt.enu_pio_write_vi_base; + *vi_countp = enp->en_arch.ef10.ena_pio_write_vi_base; return (0); } __checkReturn efx_rc_t -hunt_nic_get_bar_region( +ef10_nic_get_bar_region( __in efx_nic_t *enp, __in efx_nic_region_t region, __out uint32_t *offsetp, @@ -1729,7 +1756,8 @@ hunt_nic_get_bar_region( { efx_rc_t rc; - EFSYS_ASSERT3U(enp->en_family, ==, EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); /* * TODO: Specify host memory mapping alignment and granularity @@ -1739,14 +1767,14 @@ hunt_nic_get_bar_region( switch (region) { case EFX_REGION_VI: /* UC mapped memory BAR region for VI registers */ - *offsetp = enp->en_u.hunt.enu_uc_mem_map_offset; - *sizep = enp->en_u.hunt.enu_uc_mem_map_size; + *offsetp = enp->en_arch.ef10.ena_uc_mem_map_offset; + *sizep = enp->en_arch.ef10.ena_uc_mem_map_size; break; case EFX_REGION_PIO_WRITE_VI: /* WC mapped memory BAR region for piobuf writes */ - *offsetp = enp->en_u.hunt.enu_wc_mem_map_offset; - *sizep = enp->en_u.hunt.enu_wc_mem_map_size; + *offsetp = enp->en_arch.ef10.ena_wc_mem_map_offset; + *sizep = enp->en_arch.ef10.ena_wc_mem_map_size; break; default: @@ -1763,7 +1791,7 @@ fail1: } void -hunt_nic_fini( +ef10_nic_fini( __in efx_nic_t *enp) { uint32_t i; @@ -1773,23 +1801,23 @@ hunt_nic_fini( enp->en_vport_id = 0; /* Unlink piobufs from extra VIs in WC mapping */ - if (enp->en_u.hunt.enu_piobuf_count > 0) { - for (i = 0; i < enp->en_u.hunt.enu_piobuf_count; i++) { + if (enp->en_arch.ef10.ena_piobuf_count > 0) { + for (i = 0; i < enp->en_arch.ef10.ena_piobuf_count; i++) { rc = efx_mcdi_unlink_piobuf(enp, - enp->en_u.hunt.enu_pio_write_vi_base + i); + enp->en_arch.ef10.ena_pio_write_vi_base + i); if (rc != 0) break; } } - hunt_nic_free_piobufs(enp); + ef10_nic_free_piobufs(enp); (void) efx_mcdi_free_vis(enp); - enp->en_u.hunt.enu_vi_count = 0; + enp->en_arch.ef10.ena_vi_count = 0; } void -hunt_nic_unprobe( +ef10_nic_unprobe( __in efx_nic_t *enp) { #if EFSYS_OPT_MON_STATS @@ -1801,7 +1829,7 @@ hunt_nic_unprobe( #if EFSYS_OPT_DIAG __checkReturn efx_rc_t -hunt_nic_register_test( +ef10_nic_register_test( __in efx_nic_t *enp) { efx_rc_t rc; diff --git a/sys/dev/sfxge/common/hunt_nvram.c b/sys/dev/sfxge/common/hunt_nvram.c index c25fa10..324c0d8 100644 --- a/sys/dev/sfxge/common/hunt_nvram.c +++ b/sys/dev/sfxge/common/hunt_nvram.c @@ -31,10 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" -#include "efx_regs.h" #include "efx_impl.h" #if EFSYS_OPT_HUNTINGTON @@ -489,7 +486,7 @@ efx_nvram_tlv_validate( int pos; efx_rc_t rc; - EFX_STATIC_ASSERT(sizeof (*header) <= HUNTINGTON_NVRAM_CHUNK); + EFX_STATIC_ASSERT(sizeof (*header) <= EF10_NVRAM_CHUNK); if ((partn_data == NULL) || (partn_size == 0)) { rc = EINVAL; @@ -578,7 +575,7 @@ fail1: * beyond the first to be read. */ static __checkReturn efx_rc_t -hunt_nvram_read_tlv_segment( +ef10_nvram_read_tlv_segment( __in efx_nic_t *enp, __in uint32_t partn, __in size_t seg_offset, @@ -593,7 +590,7 @@ hunt_nvram_read_tlv_segment( int pos; efx_rc_t rc; - EFX_STATIC_ASSERT(sizeof (*header) <= HUNTINGTON_NVRAM_CHUNK); + EFX_STATIC_ASSERT(sizeof (*header) <= EF10_NVRAM_CHUNK); if ((seg_data == NULL) || (max_seg_size == 0)) { rc = EINVAL; @@ -601,8 +598,8 @@ hunt_nvram_read_tlv_segment( } /* Read initial chunk of the segment, starting at offset */ - if ((rc = hunt_nvram_partn_read(enp, partn, seg_offset, seg_data, - HUNTINGTON_NVRAM_CHUNK)) != 0) { + if ((rc = ef10_nvram_partn_read(enp, partn, seg_offset, seg_data, + EF10_NVRAM_CHUNK)) != 0) { goto fail2; } @@ -626,11 +623,11 @@ hunt_nvram_read_tlv_segment( } /* Read the remaining segment content */ - if (total_length > HUNTINGTON_NVRAM_CHUNK) { - if ((rc = hunt_nvram_partn_read(enp, partn, - seg_offset + HUNTINGTON_NVRAM_CHUNK, - seg_data + HUNTINGTON_NVRAM_CHUNK, - total_length - HUNTINGTON_NVRAM_CHUNK)) != 0) + if (total_length > EF10_NVRAM_CHUNK) { + if ((rc = ef10_nvram_partn_read(enp, partn, + seg_offset + EF10_NVRAM_CHUNK, + seg_data + EF10_NVRAM_CHUNK, + total_length - EF10_NVRAM_CHUNK)) != 0) goto fail6; } @@ -705,7 +702,7 @@ fail1: * buffer containing a TLV formatted segment. */ __checkReturn efx_rc_t -hunt_nvram_buf_read_tlv( +ef10_nvram_buf_read_tlv( __in efx_nic_t *enp, __in_bcount(max_seg_size) caddr_t seg_data, __in size_t max_seg_size, @@ -768,7 +765,7 @@ fail1: /* Read a single TLV item from the first segment in a TLV formatted partition */ __checkReturn efx_rc_t -hunt_nvram_partn_read_tlv( +ef10_nvram_partn_read_tlv( __in efx_nic_t *enp, __in uint32_t partn, __in uint32_t tag, @@ -783,7 +780,7 @@ hunt_nvram_partn_read_tlv( efx_rc_t rc; /* Allocate sufficient memory for the entire partition */ - if ((rc = hunt_nvram_partn_size(enp, partn, &partn_size)) != 0) + if ((rc = ef10_nvram_partn_size(enp, partn, &partn_size)) != 0) goto fail1; if (partn_size == 0) { @@ -807,7 +804,7 @@ hunt_nvram_partn_read_tlv( */ retry = 10; do { - rc = hunt_nvram_read_tlv_segment(enp, partn, 0, + rc = ef10_nvram_read_tlv_segment(enp, partn, 0, seg_data, partn_size); } while ((rc == EAGAIN) && (--retry > 0)); @@ -816,7 +813,7 @@ hunt_nvram_partn_read_tlv( goto fail4; } - if ((rc = hunt_nvram_buf_read_tlv(enp, seg_data, partn_size, + if ((rc = ef10_nvram_buf_read_tlv(enp, seg_data, partn_size, tag, &data, &length)) != 0) goto fail5; @@ -845,7 +842,7 @@ fail1: /* Compute the size of a segment. */ static __checkReturn efx_rc_t -hunt_nvram_buf_segment_size( +ef10_nvram_buf_segment_size( __in caddr_t seg_data, __in size_t max_seg_size, __out size_t *seg_sizep) @@ -976,7 +973,7 @@ fail1: * formatted segment. Historically partitions consisted of only one segment. */ __checkReturn efx_rc_t -hunt_nvram_buf_write_tlv( +ef10_nvram_buf_write_tlv( __inout_bcount(max_seg_size) caddr_t seg_data, __in size_t max_seg_size, __in uint32_t tag, @@ -1077,14 +1074,14 @@ fail1: * configuration. */ __checkReturn efx_rc_t -hunt_nvram_partn_write_tlv( +ef10_nvram_partn_write_tlv( __in efx_nic_t *enp, __in uint32_t partn, __in uint32_t tag, __in_bcount(size) caddr_t data, __in size_t size) { - return hunt_nvram_partn_write_segment_tlv(enp, partn, tag, data, + return ef10_nvram_partn_write_segment_tlv(enp, partn, tag, data, size, B_FALSE); } @@ -1093,7 +1090,7 @@ hunt_nvram_partn_write_tlv( * and optionally write a new tag to it. */ static __checkReturn efx_rc_t -hunt_nvram_segment_write_tlv( +ef10_nvram_segment_write_tlv( __in efx_nic_t *enp, __in uint32_t partn, __in uint32_t tag, @@ -1116,19 +1113,19 @@ hunt_nvram_segment_write_tlv( * this is the first segment in a partition. In this case the caller * must propogate the error. */ - status = hunt_nvram_read_tlv_segment(enp, partn, *partn_offsetp, + status = ef10_nvram_read_tlv_segment(enp, partn, *partn_offsetp, *seg_datap, *src_remain_lenp); if (status != 0) return (EINVAL); - status = hunt_nvram_buf_segment_size(*seg_datap, + status = ef10_nvram_buf_segment_size(*seg_datap, *src_remain_lenp, &original_segment_size); if (status != 0) return (EINVAL); if (write) { /* Update the contents of the segment in the buffer */ - if ((rc = hunt_nvram_buf_write_tlv(*seg_datap, + if ((rc = ef10_nvram_buf_write_tlv(*seg_datap, *dest_remain_lenp, tag, data, size, &modified_segment_size)) != 0) goto fail1; @@ -1176,7 +1173,7 @@ fail1: * invalidate them. */ __checkReturn efx_rc_t -hunt_nvram_partn_write_segment_tlv( +ef10_nvram_partn_write_segment_tlv( __in efx_nic_t *enp, __in uint32_t partn, __in uint32_t tag, @@ -1196,7 +1193,7 @@ hunt_nvram_partn_write_segment_tlv( EFSYS_ASSERT3U(partn, ==, NVRAM_PARTITION_TYPE_DYNAMIC_CONFIG); /* Allocate sufficient memory for the entire partition */ - if ((rc = hunt_nvram_partn_size(enp, partn, &partn_size)) != 0) + if ((rc = ef10_nvram_partn_size(enp, partn, &partn_size)) != 0) goto fail1; EFSYS_KMEM_ALLOC(enp->en_esip, partn_size, partn_data); @@ -1210,14 +1207,14 @@ hunt_nvram_partn_write_segment_tlv( segment_data = partn_data; /* Lock the partition */ - if ((rc = hunt_nvram_partn_lock(enp, partn)) != 0) + if ((rc = ef10_nvram_partn_lock(enp, partn)) != 0) goto fail3; /* Iterate over each (potential) segment to update it. */ do { boolean_t write = all_segments || current_offset == 0; - rc = hunt_nvram_segment_write_tlv(enp, partn, tag, data, size, + rc = ef10_nvram_segment_write_tlv(enp, partn, tag, data, size, &segment_data, ¤t_offset, &remaining_original_length, &remaining_modified_length, write); if (rc != 0) { @@ -1236,7 +1233,7 @@ hunt_nvram_partn_write_segment_tlv( /* * We've run out of space. This should actually be dealt with by - * hunt_nvram_buf_write_tlv returning ENOSPC. + * ef10_nvram_buf_write_tlv returning ENOSPC. */ if (total_length > partn_size) { rc = ENOSPC; @@ -1244,16 +1241,16 @@ hunt_nvram_partn_write_segment_tlv( } /* Erase the whole partition in NVRAM */ - if ((rc = hunt_nvram_partn_erase(enp, partn, 0, partn_size)) != 0) + if ((rc = ef10_nvram_partn_erase(enp, partn, 0, partn_size)) != 0) goto fail6; /* Write new partition contents from the buffer to NVRAM */ - if ((rc = hunt_nvram_partn_write(enp, partn, 0, partn_data, + if ((rc = ef10_nvram_partn_write(enp, partn, 0, partn_data, total_length)) != 0) goto fail7; /* Unlock the partition */ - hunt_nvram_partn_unlock(enp, partn); + ef10_nvram_partn_unlock(enp, partn); EFSYS_KMEM_FREE(enp->en_esip, partn_size, partn_data); @@ -1268,7 +1265,7 @@ fail5: fail4: EFSYS_PROBE(fail4); - hunt_nvram_partn_unlock(enp, partn); + ef10_nvram_partn_unlock(enp, partn); fail3: EFSYS_PROBE(fail3); @@ -1286,9 +1283,9 @@ fail1: * not the data used by the segments in the partition. */ __checkReturn efx_rc_t -hunt_nvram_partn_size( +ef10_nvram_partn_size( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __out size_t *sizep) { efx_rc_t rc; @@ -1306,9 +1303,9 @@ fail1: } __checkReturn efx_rc_t -hunt_nvram_partn_lock( +ef10_nvram_partn_lock( __in efx_nic_t *enp, - __in unsigned int partn) + __in uint32_t partn) { efx_rc_t rc; @@ -1324,9 +1321,9 @@ fail1: } __checkReturn efx_rc_t -hunt_nvram_partn_read( +ef10_nvram_partn_read( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __in unsigned int offset, __out_bcount(size) caddr_t data, __in size_t size) @@ -1335,7 +1332,7 @@ hunt_nvram_partn_read( efx_rc_t rc; while (size > 0) { - chunk = MIN(size, HUNTINGTON_NVRAM_CHUNK); + chunk = MIN(size, EF10_NVRAM_CHUNK); if ((rc = efx_mcdi_nvram_read(enp, partn, offset, data, chunk)) != 0) { @@ -1356,9 +1353,9 @@ fail1: } __checkReturn efx_rc_t -hunt_nvram_partn_erase( +ef10_nvram_partn_erase( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __in unsigned int offset, __in size_t size) { @@ -1401,9 +1398,9 @@ fail1: } __checkReturn efx_rc_t -hunt_nvram_partn_write( +ef10_nvram_partn_write( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __in unsigned int offset, __out_bcount(size) caddr_t data, __in size_t size) @@ -1426,7 +1423,7 @@ hunt_nvram_partn_write( goto fail2; } } else { - write_size = HUNTINGTON_NVRAM_CHUNK; + write_size = EF10_NVRAM_CHUNK; } while (size > 0) { @@ -1455,9 +1452,9 @@ fail1: } void -hunt_nvram_partn_unlock( +ef10_nvram_partn_unlock( __in efx_nic_t *enp, - __in unsigned int partn) + __in uint32_t partn) { boolean_t reboot; efx_rc_t rc; @@ -1473,9 +1470,9 @@ fail1: } __checkReturn efx_rc_t -hunt_nvram_partn_set_version( +ef10_nvram_partn_set_version( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __in_ecount(4) uint16_t version[4]) { struct tlv_partition_version partn_version; @@ -1491,7 +1488,7 @@ hunt_nvram_partn_set_version( size = sizeof (partn_version) - (2 * sizeof (uint32_t)); /* Write the version number to all segments in the partition */ - if ((rc = hunt_nvram_partn_write_segment_tlv(enp, + if ((rc = ef10_nvram_partn_write_segment_tlv(enp, NVRAM_PARTITION_TYPE_DYNAMIC_CONFIG, TLV_TAG_PARTITION_VERSION(partn), (caddr_t)&partn_version.version_w, size, B_TRUE)) != 0) @@ -1509,14 +1506,14 @@ fail1: #if EFSYS_OPT_NVRAM -typedef struct hunt_parttbl_entry_s { +typedef struct ef10_parttbl_entry_s { unsigned int partn; unsigned int port; efx_nvram_type_t nvtype; -} hunt_parttbl_entry_t; +} ef10_parttbl_entry_t; /* Translate EFX NVRAM types to firmware partition types */ -static hunt_parttbl_entry_t hunt_parttbl[] = { +static ef10_parttbl_entry_t hunt_parttbl[] = { {NVRAM_PARTITION_TYPE_MC_FIRMWARE, 1, EFX_NVRAM_MC_FIRMWARE}, {NVRAM_PARTITION_TYPE_MC_FIRMWARE, 2, EFX_NVRAM_MC_FIRMWARE}, {NVRAM_PARTITION_TYPE_MC_FIRMWARE, 3, EFX_NVRAM_MC_FIRMWARE}, @@ -1547,44 +1544,134 @@ static hunt_parttbl_entry_t hunt_parttbl[] = { {NVRAM_PARTITION_TYPE_FPGA_BACKUP, 4, EFX_NVRAM_FPGA_BACKUP} }; -static __checkReturn hunt_parttbl_entry_t * -hunt_parttbl_entry( +static ef10_parttbl_entry_t medford_parttbl[] = { + {NVRAM_PARTITION_TYPE_MC_FIRMWARE, 1, EFX_NVRAM_MC_FIRMWARE}, + {NVRAM_PARTITION_TYPE_MC_FIRMWARE, 2, EFX_NVRAM_MC_FIRMWARE}, + {NVRAM_PARTITION_TYPE_MC_FIRMWARE, 3, EFX_NVRAM_MC_FIRMWARE}, + {NVRAM_PARTITION_TYPE_MC_FIRMWARE, 4, EFX_NVRAM_MC_FIRMWARE}, + {NVRAM_PARTITION_TYPE_MC_FIRMWARE_BACKUP, 1, EFX_NVRAM_MC_GOLDEN}, + {NVRAM_PARTITION_TYPE_MC_FIRMWARE_BACKUP, 2, EFX_NVRAM_MC_GOLDEN}, + {NVRAM_PARTITION_TYPE_MC_FIRMWARE_BACKUP, 3, EFX_NVRAM_MC_GOLDEN}, + {NVRAM_PARTITION_TYPE_MC_FIRMWARE_BACKUP, 4, EFX_NVRAM_MC_GOLDEN}, + {NVRAM_PARTITION_TYPE_EXPANSION_ROM, 1, EFX_NVRAM_BOOTROM}, + {NVRAM_PARTITION_TYPE_EXPANSION_ROM, 2, EFX_NVRAM_BOOTROM}, + {NVRAM_PARTITION_TYPE_EXPANSION_ROM, 3, EFX_NVRAM_BOOTROM}, + {NVRAM_PARTITION_TYPE_EXPANSION_ROM, 4, EFX_NVRAM_BOOTROM}, + {NVRAM_PARTITION_TYPE_EXPROM_CONFIG_PORT0, 1, EFX_NVRAM_BOOTROM_CFG}, + {NVRAM_PARTITION_TYPE_EXPROM_CONFIG_PORT0, 2, EFX_NVRAM_BOOTROM_CFG}, + {NVRAM_PARTITION_TYPE_EXPROM_CONFIG_PORT0, 3, EFX_NVRAM_BOOTROM_CFG}, + {NVRAM_PARTITION_TYPE_EXPROM_CONFIG_PORT0, 4, EFX_NVRAM_BOOTROM_CFG}, + {NVRAM_PARTITION_TYPE_DYNAMIC_CONFIG, 1, EFX_NVRAM_DYNAMIC_CFG}, + {NVRAM_PARTITION_TYPE_DYNAMIC_CONFIG, 2, EFX_NVRAM_DYNAMIC_CFG}, + {NVRAM_PARTITION_TYPE_DYNAMIC_CONFIG, 3, EFX_NVRAM_DYNAMIC_CFG}, + {NVRAM_PARTITION_TYPE_DYNAMIC_CONFIG, 4, EFX_NVRAM_DYNAMIC_CFG}, + {NVRAM_PARTITION_TYPE_FPGA, 1, EFX_NVRAM_FPGA}, + {NVRAM_PARTITION_TYPE_FPGA, 2, EFX_NVRAM_FPGA}, + {NVRAM_PARTITION_TYPE_FPGA, 3, EFX_NVRAM_FPGA}, + {NVRAM_PARTITION_TYPE_FPGA, 4, EFX_NVRAM_FPGA}, + {NVRAM_PARTITION_TYPE_FPGA_BACKUP, 1, EFX_NVRAM_FPGA_BACKUP}, + {NVRAM_PARTITION_TYPE_FPGA_BACKUP, 2, EFX_NVRAM_FPGA_BACKUP}, + {NVRAM_PARTITION_TYPE_FPGA_BACKUP, 3, EFX_NVRAM_FPGA_BACKUP}, + {NVRAM_PARTITION_TYPE_FPGA_BACKUP, 4, EFX_NVRAM_FPGA_BACKUP} +}; + +static __checkReturn efx_rc_t +ef10_parttbl_get( __in efx_nic_t *enp, - __in efx_nvram_type_t type) + __out ef10_parttbl_entry_t **parttblp, + __out size_t *parttbl_rowsp) +{ + switch (enp->en_family) { + case EFX_FAMILY_HUNTINGTON: + *parttblp = hunt_parttbl; + *parttbl_rowsp = EFX_ARRAY_SIZE(hunt_parttbl); + break; + + case EFX_FAMILY_MEDFORD: + *parttblp = medford_parttbl; + *parttbl_rowsp = EFX_ARRAY_SIZE(medford_parttbl); + break; + + default: + EFSYS_ASSERT(B_FALSE); + return (EINVAL); + } + return (0); +} + + __checkReturn efx_rc_t +ef10_nvram_type_to_partn( + __in efx_nic_t *enp, + __in efx_nvram_type_t type, + __out uint32_t *partnp) { efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); - hunt_parttbl_entry_t *entry; - int i; + ef10_parttbl_entry_t *parttbl = NULL; + size_t parttbl_rows = 0; + unsigned int i; EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES); + EFSYS_ASSERT(partnp != NULL); + + if (ef10_parttbl_get(enp, &parttbl, &parttbl_rows) == 0) { + for (i = 0; i < parttbl_rows; i++) { + ef10_parttbl_entry_t *entry = &parttbl[i]; + + if (entry->nvtype == type && + entry->port == emip->emi_port) { + *partnp = entry->partn; + return (0); + } + } + } + + return (ENOTSUP); +} + - for (i = 0; i < EFX_ARRAY_SIZE(hunt_parttbl); i++) { - entry = &hunt_parttbl[i]; +static __checkReturn efx_rc_t +ef10_nvram_partn_to_type( + __in efx_nic_t *enp, + __in uint32_t partn, + __out efx_nvram_type_t *typep) +{ + efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); + ef10_parttbl_entry_t *parttbl = NULL; + size_t parttbl_rows = 0; + unsigned int i; - if (entry->port == emip->emi_port && entry->nvtype == type) - return (entry); + EFSYS_ASSERT(typep != NULL); + + if (ef10_parttbl_get(enp, &parttbl, &parttbl_rows) == 0) { + for (i = 0; i < parttbl_rows; i++) { + ef10_parttbl_entry_t *entry = &parttbl[i]; + + if (entry->partn == partn && + entry->port == emip->emi_port) { + *typep = entry->nvtype; + return (0); + } + } } - return (NULL); + return (ENOTSUP); } #if EFSYS_OPT_DIAG __checkReturn efx_rc_t -hunt_nvram_test( +ef10_nvram_test( __in efx_nic_t *enp) { - efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); - hunt_parttbl_entry_t *entry; + efx_nvram_type_t type; unsigned int npartns = 0; uint32_t *partns = NULL; size_t size; - int i; - unsigned int j; + unsigned int i; efx_rc_t rc; - /* Find supported partitions */ + /* Read available partitions from NVRAM partition map */ size = MC_CMD_NVRAM_PARTITIONS_OUT_TYPE_ID_MAXNUM * sizeof (uint32_t); EFSYS_KMEM_ALLOC(enp->en_esip, size, partns); if (partns == NULL) { @@ -1597,23 +1684,13 @@ hunt_nvram_test( goto fail2; } - /* - * Iterate over the list of supported partition types - * applicable to *this* port - */ - for (i = 0; i < EFX_ARRAY_SIZE(hunt_parttbl); i++) { - entry = &hunt_parttbl[i]; - - if (entry->port != emip->emi_port) + for (i = 0; i < npartns; i++) { + /* Check if the partition is supported for this port */ + if ((rc = ef10_nvram_partn_to_type(enp, partns[i], &type)) != 0) continue; - for (j = 0; j < npartns; j++) { - if (entry->partn == partns[j]) { - rc = efx_mcdi_nvram_test(enp, entry->partn); - if (rc != 0) - goto fail3; - } - } + if ((rc = efx_mcdi_nvram_test(enp, partns[i])) != 0) + goto fail3; } EFSYS_KMEM_FREE(enp->en_esip, size, partns); @@ -1632,22 +1709,18 @@ fail1: #endif /* EFSYS_OPT_DIAG */ __checkReturn efx_rc_t -hunt_nvram_size( +ef10_nvram_size( __in efx_nic_t *enp, __in efx_nvram_type_t type, __out size_t *sizep) { - hunt_parttbl_entry_t *entry; uint32_t partn; efx_rc_t rc; - if ((entry = hunt_parttbl_entry(enp, type)) == NULL) { - rc = ENOTSUP; + if ((rc = ef10_nvram_type_to_partn(enp, type, &partn)) != 0) goto fail1; - } - partn = entry->partn; - if ((rc = hunt_nvram_partn_size(enp, partn, sizep)) != 0) + if ((rc = ef10_nvram_partn_size(enp, partn, sizep)) != 0) goto fail2; return (0); @@ -1663,21 +1736,17 @@ fail1: } __checkReturn efx_rc_t -hunt_nvram_get_version( +ef10_nvram_get_version( __in efx_nic_t *enp, __in efx_nvram_type_t type, __out uint32_t *subtypep, __out_ecount(4) uint16_t version[4]) { - hunt_parttbl_entry_t *entry; uint32_t partn; efx_rc_t rc; - if ((entry = hunt_parttbl_entry(enp, type)) == NULL) { - rc = ENOTSUP; + if ((rc = ef10_nvram_type_to_partn(enp, type, &partn)) != 0) goto fail1; - } - partn = entry->partn; /* FIXME: get highest partn version from all ports */ /* FIXME: return partn description if available */ @@ -1697,26 +1766,22 @@ fail1: } __checkReturn efx_rc_t -hunt_nvram_rw_start( +ef10_nvram_rw_start( __in efx_nic_t *enp, __in efx_nvram_type_t type, __out size_t *chunk_sizep) { - hunt_parttbl_entry_t *entry; uint32_t partn; efx_rc_t rc; - if ((entry = hunt_parttbl_entry(enp, type)) == NULL) { - rc = ENOTSUP; + if ((rc = ef10_nvram_type_to_partn(enp, type, &partn)) != 0) goto fail1; - } - partn = entry->partn; - if ((rc = hunt_nvram_partn_lock(enp, partn)) != 0) + if ((rc = ef10_nvram_partn_lock(enp, partn)) != 0) goto fail2; if (chunk_sizep != NULL) - *chunk_sizep = HUNTINGTON_NVRAM_CHUNK; + *chunk_sizep = EF10_NVRAM_CHUNK; return (0); @@ -1729,23 +1794,20 @@ fail1: } __checkReturn efx_rc_t -hunt_nvram_read_chunk( +ef10_nvram_read_chunk( __in efx_nic_t *enp, __in efx_nvram_type_t type, __in unsigned int offset, __out_bcount(size) caddr_t data, __in size_t size) { - hunt_parttbl_entry_t *entry; + uint32_t partn; efx_rc_t rc; - if ((entry = hunt_parttbl_entry(enp, type)) == NULL) { - rc = ENOTSUP; + if ((rc = ef10_nvram_type_to_partn(enp, type, &partn)) != 0) goto fail1; - } - if ((rc = hunt_nvram_partn_read(enp, entry->partn, - offset, data, size)) != 0) + if ((rc = ef10_nvram_partn_read(enp, partn, offset, data, size)) != 0) goto fail2; return (0); @@ -1759,23 +1821,21 @@ fail1: } __checkReturn efx_rc_t -hunt_nvram_erase( +ef10_nvram_erase( __in efx_nic_t *enp, __in efx_nvram_type_t type) { - hunt_parttbl_entry_t *entry; + uint32_t partn; size_t size; efx_rc_t rc; - if ((entry = hunt_parttbl_entry(enp, type)) == NULL) { - rc = ENOTSUP; + if ((rc = ef10_nvram_type_to_partn(enp, type, &partn)) != 0) goto fail1; - } - if ((rc = hunt_nvram_partn_size(enp, entry->partn, &size)) != 0) + if ((rc = ef10_nvram_partn_size(enp, partn, &size)) != 0) goto fail2; - if ((rc = hunt_nvram_partn_erase(enp, entry->partn, 0, size)) != 0) + if ((rc = ef10_nvram_partn_erase(enp, partn, 0, size)) != 0) goto fail3; return (0); @@ -1791,23 +1851,20 @@ fail1: } __checkReturn efx_rc_t -hunt_nvram_write_chunk( +ef10_nvram_write_chunk( __in efx_nic_t *enp, __in efx_nvram_type_t type, __in unsigned int offset, __in_bcount(size) caddr_t data, __in size_t size) { - hunt_parttbl_entry_t *entry; + uint32_t partn; efx_rc_t rc; - if ((entry = hunt_parttbl_entry(enp, type)) == NULL) { - rc = ENOTSUP; + if ((rc = ef10_nvram_type_to_partn(enp, type, &partn)) != 0) goto fail1; - } - if ((rc = hunt_nvram_partn_write(enp, entry->partn, - offset, data, size)) != 0) + if ((rc = ef10_nvram_partn_write(enp, partn, offset, data, size)) != 0) goto fail2; return (0); @@ -1821,40 +1878,36 @@ fail1: } void -hunt_nvram_rw_finish( +ef10_nvram_rw_finish( __in efx_nic_t *enp, __in efx_nvram_type_t type) { - hunt_parttbl_entry_t *entry; + uint32_t partn; + efx_rc_t rc; - if ((entry = hunt_parttbl_entry(enp, type)) != NULL) - hunt_nvram_partn_unlock(enp, entry->partn); + if ((rc = ef10_nvram_type_to_partn(enp, type, &partn)) == 0) + ef10_nvram_partn_unlock(enp, partn); } __checkReturn efx_rc_t -hunt_nvram_set_version( +ef10_nvram_set_version( __in efx_nic_t *enp, __in efx_nvram_type_t type, __in_ecount(4) uint16_t version[4]) { - hunt_parttbl_entry_t *entry; - unsigned int partn; + uint32_t partn; efx_rc_t rc; - if ((entry = hunt_parttbl_entry(enp, type)) == NULL) { - rc = ENOTSUP; + if ((rc = ef10_nvram_type_to_partn(enp, type, &partn)) != 0) goto fail1; - } - partn = entry->partn; - if ((rc = hunt_nvram_partn_set_version(enp, partn, version)) != 0) + if ((rc = ef10_nvram_partn_set_version(enp, partn, version)) != 0) goto fail2; return (0); fail2: EFSYS_PROBE(fail2); - fail1: EFSYS_PROBE1(fail1, efx_rc_t, rc); diff --git a/sys/dev/sfxge/common/hunt_phy.c b/sys/dev/sfxge/common/hunt_phy.c index e8d234a..c25e820 100644 --- a/sys/dev/sfxge/common/hunt_phy.c +++ b/sys/dev/sfxge/common/hunt_phy.c @@ -31,7 +31,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" #include "efx_impl.h" diff --git a/sys/dev/sfxge/common/hunt_rx.c b/sys/dev/sfxge/common/hunt_rx.c index 6fdc747..984d48d 100644 --- a/sys/dev/sfxge/common/hunt_rx.c +++ b/sys/dev/sfxge/common/hunt_rx.c @@ -31,7 +31,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" #include "efx_impl.h" @@ -147,14 +146,34 @@ fail1: static __checkReturn efx_rc_t efx_mcdi_rss_context_alloc( __in efx_nic_t *enp, + __in efx_rx_scale_support_t scale_support, + __in uint32_t num_queues, __out uint32_t *rss_contextp) { efx_mcdi_req_t req; uint8_t payload[MAX(MC_CMD_RSS_CONTEXT_ALLOC_IN_LEN, MC_CMD_RSS_CONTEXT_ALLOC_OUT_LEN)]; uint32_t rss_context; + uint32_t context_type; efx_rc_t rc; + if (num_queues > EFX_MAXRSS) { + rc = EINVAL; + goto fail1; + } + + switch (scale_support) { + case EFX_RX_SCALE_EXCLUSIVE: + context_type = MC_CMD_RSS_CONTEXT_ALLOC_IN_TYPE_EXCLUSIVE; + break; + case EFX_RX_SCALE_SHARED: + context_type = MC_CMD_RSS_CONTEXT_ALLOC_IN_TYPE_SHARED; + break; + default: + rc = EINVAL; + goto fail2; + } + (void) memset(payload, 0, sizeof (payload)); req.emr_cmd = MC_CMD_RSS_CONTEXT_ALLOC; req.emr_in_buf = payload; @@ -164,33 +183,36 @@ efx_mcdi_rss_context_alloc( MCDI_IN_SET_DWORD(req, RSS_CONTEXT_ALLOC_IN_UPSTREAM_PORT_ID, EVB_PORT_ID_ASSIGNED); - MCDI_IN_SET_DWORD(req, RSS_CONTEXT_ALLOC_IN_TYPE, - MC_CMD_RSS_CONTEXT_ALLOC_IN_TYPE_EXCLUSIVE); + MCDI_IN_SET_DWORD(req, RSS_CONTEXT_ALLOC_IN_TYPE, context_type); /* NUM_QUEUES is only used to validate indirection table offsets */ - MCDI_IN_SET_DWORD(req, RSS_CONTEXT_ALLOC_IN_NUM_QUEUES, 64); + MCDI_IN_SET_DWORD(req, RSS_CONTEXT_ALLOC_IN_NUM_QUEUES, num_queues); efx_mcdi_execute(enp, &req); if (req.emr_rc != 0) { rc = req.emr_rc; - goto fail1; + goto fail3; } if (req.emr_out_length_used < MC_CMD_RSS_CONTEXT_ALLOC_OUT_LEN) { rc = EMSGSIZE; - goto fail2; + goto fail4; } rss_context = MCDI_OUT_DWORD(req, RSS_CONTEXT_ALLOC_OUT_RSS_CONTEXT_ID); - if (rss_context == HUNTINGTON_RSS_CONTEXT_INVALID) { + if (rss_context == EF10_RSS_CONTEXT_INVALID) { rc = ENOENT; - goto fail3; + goto fail5; } *rss_contextp = rss_context; return (0); +fail5: + EFSYS_PROBE(fail5); +fail4: + EFSYS_PROBE(fail4); fail3: EFSYS_PROBE(fail3); fail2: @@ -213,7 +235,7 @@ efx_mcdi_rss_context_free( MC_CMD_RSS_CONTEXT_FREE_OUT_LEN)]; efx_rc_t rc; - if (rss_context == HUNTINGTON_RSS_CONTEXT_INVALID) { + if (rss_context == EF10_RSS_CONTEXT_INVALID) { rc = EINVAL; goto fail1; } @@ -257,7 +279,7 @@ efx_mcdi_rss_context_set_flags( MC_CMD_RSS_CONTEXT_SET_FLAGS_OUT_LEN)]; efx_rc_t rc; - if (rss_context == HUNTINGTON_RSS_CONTEXT_INVALID) { + if (rss_context == EF10_RSS_CONTEXT_INVALID) { rc = EINVAL; goto fail1; } @@ -313,7 +335,7 @@ efx_mcdi_rss_context_set_key( MC_CMD_RSS_CONTEXT_SET_KEY_OUT_LEN)]; efx_rc_t rc; - if (rss_context == HUNTINGTON_RSS_CONTEXT_INVALID) { + if (rss_context == EF10_RSS_CONTEXT_INVALID) { rc = EINVAL; goto fail1; } @@ -371,7 +393,7 @@ efx_mcdi_rss_context_set_table( uint8_t *req_table; int i, rc; - if (rss_context == HUNTINGTON_RSS_CONTEXT_INVALID) { + if (rss_context == EF10_RSS_CONTEXT_INVALID) { rc = EINVAL; goto fail1; } @@ -415,12 +437,13 @@ fail1: __checkReturn efx_rc_t -hunt_rx_init( +ef10_rx_init( __in efx_nic_t *enp) { #if EFSYS_OPT_RX_SCALE - if (efx_mcdi_rss_context_alloc(enp, &enp->en_rss_context) == 0) { + if (efx_mcdi_rss_context_alloc(enp, EFX_RX_SCALE_EXCLUSIVE, EFX_MAXRSS, + &enp->en_rss_context) == 0) { /* * Allocated an exclusive RSS context, which allows both the * indirection table and key to be modified. @@ -442,35 +465,9 @@ hunt_rx_init( return (0); } -#if EFSYS_OPT_RX_HDR_SPLIT - __checkReturn efx_rc_t -hunt_rx_hdr_split_enable( - __in efx_nic_t *enp, - __in unsigned int hdr_buf_size, - __in unsigned int pld_buf_size) -{ - efx_rc_t rc; - - /* FIXME */ - _NOTE(ARGUNUSED(enp, hdr_buf_size, pld_buf_size)) - if (B_FALSE) { - rc = ENOTSUP; - goto fail1; - } - /* FIXME */ - - return (0); - -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} -#endif /* EFSYS_OPT_RX_HDR_SPLIT */ - #if EFSYS_OPT_RX_SCATTER __checkReturn efx_rc_t -hunt_rx_scatter_enable( +ef10_rx_scatter_enable( __in efx_nic_t *enp, __in unsigned int buf_size) { @@ -481,7 +478,7 @@ hunt_rx_scatter_enable( #if EFSYS_OPT_RX_SCALE __checkReturn efx_rc_t -hunt_rx_scale_mode_set( +ef10_rx_scale_mode_set( __in efx_nic_t *enp, __in efx_rx_hash_alg_t alg, __in efx_rx_hash_type_t type, @@ -521,7 +518,7 @@ fail1: #if EFSYS_OPT_RX_SCALE __checkReturn efx_rc_t -hunt_rx_scale_key_set( +ef10_rx_scale_key_set( __in efx_nic_t *enp, __in_ecount(n) uint8_t *key, __in size_t n) @@ -550,7 +547,7 @@ fail1: #if EFSYS_OPT_RX_SCALE __checkReturn efx_rc_t -hunt_rx_scale_tbl_set( +ef10_rx_scale_tbl_set( __in efx_nic_t *enp, __in_ecount(n) unsigned int *table, __in size_t n) @@ -577,8 +574,67 @@ fail1: } #endif /* EFSYS_OPT_RX_SCALE */ + +/* + * EF10 RX pseudo-header + * --------------------- + * + * Receive packets are prefixed by an (optional) 14 byte pseudo-header: + * + * +00: Toeplitz hash value. + * (32bit little-endian) + * +04: Outer VLAN tag. Zero if the packet did not have an outer VLAN tag. + * (16bit big-endian) + * +06: Inner VLAN tag. Zero if the packet did not have an inner VLAN tag. + * (16bit big-endian) + * +08: Packet Length. Zero if the RX datapath was in cut-through mode. + * (16bit little-endian) + * +10: MAC timestamp. Zero if timestamping is not enabled. + * (32bit little-endian) + * + * See "The RX Pseudo-header" in SF-109306-TC. + */ + + __checkReturn efx_rc_t +ef10_rx_prefix_pktlen( + __in efx_nic_t *enp, + __in uint8_t *buffer, + __out uint16_t *lengthp) +{ + /* + * The RX pseudo-header contains the packet length, excluding the + * pseudo-header. If the hardware receive datapath was operating in + * cut-through mode then the length in the RX pseudo-header will be + * zero, and the packet length must be obtained from the DMA length + * reported in the RX event. + */ + *lengthp = buffer[8] | (buffer[9] << 8); + return (0); +} + +#if EFSYS_OPT_RX_SCALE + __checkReturn uint32_t +ef10_rx_prefix_hash( + __in efx_nic_t *enp, + __in efx_rx_hash_alg_t func, + __in uint8_t *buffer) +{ + switch (func) { + case EFX_RX_HASHALG_TOEPLITZ: + return (buffer[0] | + (buffer[1] << 8) | + (buffer[2] << 16) | + (buffer[3] << 24)); + + default: + EFSYS_ASSERT(0); + return (0); + } +} +#endif /* EFSYS_OPT_RX_SCALE */ + void -hunt_rx_qpost( +ef10_rx_qpost( __in efx_rxq_t *erp, __in_ecount(n) efsys_dma_addr_t *addrp, __in size_t size, @@ -616,7 +672,7 @@ hunt_rx_qpost( } void -hunt_rx_qpush( +ef10_rx_qpush( __in efx_rxq_t *erp, __in unsigned int added, __inout unsigned int *pushedp) @@ -627,7 +683,7 @@ hunt_rx_qpush( efx_dword_t dword; /* Hardware has alignment restriction for WPTR */ - wptr = P2ALIGN(added, HUNTINGTON_RX_WPTR_ALIGN); + wptr = P2ALIGN(added, EF10_RX_WPTR_ALIGN); if (pushed == wptr) return; @@ -647,7 +703,7 @@ hunt_rx_qpush( } __checkReturn efx_rc_t -hunt_rx_qflush( +ef10_rx_qflush( __in efx_rxq_t *erp) { efx_nic_t *enp = erp->er_enp; @@ -665,7 +721,7 @@ fail1: } void -hunt_rx_qenable( +ef10_rx_qenable( __in efx_rxq_t *erp) { /* FIXME */ @@ -674,7 +730,7 @@ hunt_rx_qenable( } __checkReturn efx_rc_t -hunt_rx_qcreate( +ef10_rx_qcreate( __in efx_nic_t *enp, __in unsigned int index, __in unsigned int label, @@ -715,11 +771,6 @@ hunt_rx_qcreate( disable_scatter = B_FALSE; } - /* - * Note: EFX_RXQ_TYPE_SPLIT_HEADER and EFX_RXQ_TYPE_SPLIT_PAYLOAD are - * not supported here. - */ - if ((rc = efx_mcdi_init_rxq(enp, n, eep->ee_index, label, index, esmp, disable_scatter)) != 0) goto fail3; @@ -727,7 +778,7 @@ hunt_rx_qcreate( erp->er_eep = eep; erp->er_label = label; - hunt_ev_rxlabel_init(eep, erp, label); + ef10_ev_rxlabel_init(eep, erp, label); return (0); @@ -742,14 +793,14 @@ fail1: } void -hunt_rx_qdestroy( +ef10_rx_qdestroy( __in efx_rxq_t *erp) { efx_nic_t *enp = erp->er_enp; efx_evq_t *eep = erp->er_eep; unsigned int label = erp->er_label; - hunt_ev_rxlabel_fini(eep, label); + ef10_ev_rxlabel_fini(eep, label); EFSYS_ASSERT(enp->en_rx_qcount != 0); --enp->en_rx_qcount; @@ -758,7 +809,7 @@ hunt_rx_qdestroy( } void -hunt_rx_fini( +ef10_rx_fini( __in efx_nic_t *enp) { #if EFSYS_OPT_RX_SCALE diff --git a/sys/dev/sfxge/common/hunt_sram.c b/sys/dev/sfxge/common/hunt_sram.c index 9eb1480..1e35991 100644 --- a/sys/dev/sfxge/common/hunt_sram.c +++ b/sys/dev/sfxge/common/hunt_sram.c @@ -31,7 +31,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" #include "efx_impl.h" @@ -41,7 +40,7 @@ __FBSDID("$FreeBSD$"); #if EFSYS_OPT_DIAG __checkReturn efx_rc_t -hunt_sram_test( +ef10_sram_test( __in efx_nic_t *enp, __in efx_sram_pattern_fn_t func) { diff --git a/sys/dev/sfxge/common/hunt_tx.c b/sys/dev/sfxge/common/hunt_tx.c index 45fdd83..593db88 100755 --- a/sys/dev/sfxge/common/hunt_tx.c +++ b/sys/dev/sfxge/common/hunt_tx.c @@ -31,7 +31,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" #include "efx_impl.h" @@ -165,7 +164,7 @@ fail1: } __checkReturn efx_rc_t -hunt_tx_init( +ef10_tx_init( __in efx_nic_t *enp) { _NOTE(ARGUNUSED(enp)) @@ -173,14 +172,14 @@ hunt_tx_init( } void -hunt_tx_fini( +ef10_tx_fini( __in efx_nic_t *enp) { _NOTE(ARGUNUSED(enp)) } __checkReturn efx_rc_t -hunt_tx_qcreate( +ef10_tx_qcreate( __in efx_nic_t *enp, __in unsigned int index, __in unsigned int label, @@ -218,7 +217,7 @@ hunt_tx_qcreate( (flags & EFX_TXQ_CKSUM_IPV4) ? 1 : 0); EFSYS_MEM_WRITEQ(etp->et_esmp, 0, &desc); - hunt_tx_qpush(etp, *addedp, 0); + ef10_tx_qpush(etp, *addedp, 0); return (0); @@ -229,7 +228,7 @@ fail1: } void -hunt_tx_qdestroy( +ef10_tx_qdestroy( __in efx_txq_t *etp) { /* FIXME */ @@ -238,7 +237,7 @@ hunt_tx_qdestroy( } __checkReturn efx_rc_t -hunt_tx_qpio_enable( +ef10_tx_qpio_enable( __in efx_txq_t *etp) { efx_nic_t *enp = etp->et_enp; @@ -251,7 +250,7 @@ hunt_tx_qpio_enable( } /* Sub-allocate a PIO block from a piobuf */ - if ((rc = hunt_nic_pio_alloc(enp, + if ((rc = ef10_nic_pio_alloc(enp, &etp->et_pio_bufnum, &handle, &etp->et_pio_blknum, @@ -262,7 +261,7 @@ hunt_tx_qpio_enable( EFSYS_ASSERT3U(etp->et_pio_size, !=, 0); /* Link the piobuf to this TXQ */ - if ((rc = hunt_nic_pio_link(enp, etp->et_index, handle)) != 0) { + if ((rc = ef10_nic_pio_link(enp, etp->et_index, handle)) != 0) { goto fail3; } @@ -283,7 +282,7 @@ hunt_tx_qpio_enable( fail3: EFSYS_PROBE(fail3); - hunt_nic_pio_free(enp, etp->et_pio_bufnum, etp->et_pio_blknum); + ef10_nic_pio_free(enp, etp->et_pio_bufnum, etp->et_pio_blknum); etp->et_pio_size = 0; fail2: EFSYS_PROBE(fail2); @@ -294,24 +293,24 @@ fail1: } void -hunt_tx_qpio_disable( +ef10_tx_qpio_disable( __in efx_txq_t *etp) { efx_nic_t *enp = etp->et_enp; if (etp->et_pio_size != 0) { /* Unlink the piobuf from this TXQ */ - hunt_nic_pio_unlink(enp, etp->et_index); + ef10_nic_pio_unlink(enp, etp->et_index); /* Free the sub-allocated PIO block */ - hunt_nic_pio_free(enp, etp->et_pio_bufnum, etp->et_pio_blknum); + ef10_nic_pio_free(enp, etp->et_pio_bufnum, etp->et_pio_blknum); etp->et_pio_size = 0; etp->et_pio_write_offset = 0; } } __checkReturn efx_rc_t -hunt_tx_qpio_write( +ef10_tx_qpio_write( __in efx_txq_t *etp, __in_ecount(length) uint8_t *buffer, __in size_t length, @@ -359,7 +358,7 @@ fail1: } __checkReturn efx_rc_t -hunt_tx_qpio_post( +ef10_tx_qpio_post( __in efx_txq_t *etp, __in size_t pkt_length, __in unsigned int completed, @@ -412,7 +411,7 @@ fail1: } __checkReturn efx_rc_t -hunt_tx_qpost( +ef10_tx_qpost( __in efx_txq_t *etp, __in_ecount(n) efx_buffer_t *eb, __in unsigned int n, @@ -474,7 +473,7 @@ fail1: * hardware decides not to use the pushed descriptor. */ void -hunt_tx_qpush( +ef10_tx_qpush( __in efx_txq_t *etp, __in unsigned int added, __in unsigned int pushed) @@ -504,7 +503,7 @@ hunt_tx_qpush( } __checkReturn efx_rc_t -hunt_tx_qdesc_post( +ef10_tx_qdesc_post( __in efx_txq_t *etp, __in_ecount(n) efx_desc_t *ed, __in unsigned int n, @@ -546,7 +545,7 @@ fail1: } void -hunt_tx_qdesc_dma_create( +ef10_tx_qdesc_dma_create( __in efx_txq_t *etp, __in efsys_dma_addr_t addr, __in size_t size, @@ -590,7 +589,7 @@ hunt_tx_qdesc_tso_create( } void -hunt_tx_qdesc_vlantci_create( +ef10_tx_qdesc_vlantci_create( __in efx_txq_t *etp, __in uint16_t tci, __out efx_desc_t *edp) @@ -608,7 +607,7 @@ hunt_tx_qdesc_vlantci_create( __checkReturn efx_rc_t -hunt_tx_qpace( +ef10_tx_qpace( __in efx_txq_t *etp, __in unsigned int ns) { @@ -631,7 +630,7 @@ fail1: } __checkReturn efx_rc_t -hunt_tx_qflush( +ef10_tx_qflush( __in efx_txq_t *etp) { efx_nic_t *enp = etp->et_enp; @@ -649,7 +648,7 @@ fail1: } void -hunt_tx_qenable( +ef10_tx_qenable( __in efx_txq_t *etp) { /* FIXME */ @@ -659,15 +658,10 @@ hunt_tx_qenable( #if EFSYS_OPT_QSTATS void -hunt_tx_qstats_update( +ef10_tx_qstats_update( __in efx_txq_t *etp, __inout_ecount(TX_NQSTATS) efsys_stat_t *stat) { - /* - * TBD: Consider a common Siena/Huntington function. The code is - * essentially identical. - */ - unsigned int id; for (id = 0; id < TX_NQSTATS; id++) { diff --git a/sys/dev/sfxge/common/hunt_vpd.c b/sys/dev/sfxge/common/hunt_vpd.c index 129167c..58e9a66 100644 --- a/sys/dev/sfxge/common/hunt_vpd.c +++ b/sys/dev/sfxge/common/hunt_vpd.c @@ -31,10 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" -#include "efx_regs.h" #include "efx_impl.h" @@ -45,7 +42,7 @@ __FBSDID("$FreeBSD$"); #include "ef10_tlv_layout.h" __checkReturn efx_rc_t -hunt_vpd_init( +ef10_vpd_init( __in efx_nic_t *enp) { caddr_t svpd; @@ -54,7 +51,8 @@ hunt_vpd_init( efx_rc_t rc; EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE); - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); pci_pf = enp->en_nic_cfg.enc_pf; /* @@ -64,7 +62,7 @@ hunt_vpd_init( */ svpd = NULL; svpd_size = 0; - rc = hunt_nvram_partn_read_tlv(enp, + rc = ef10_nvram_partn_read_tlv(enp, NVRAM_PARTITION_TYPE_STATIC_CONFIG, TLV_TAG_PF_STATIC_VPD(pci_pf), &svpd, &svpd_size); @@ -81,8 +79,8 @@ hunt_vpd_init( goto fail2; } - enp->en_u.hunt.enu_svpd = svpd; - enp->en_u.hunt.enu_svpd_length = svpd_size; + enp->en_arch.ef10.ena_svpd = svpd; + enp->en_arch.ef10.ena_svpd_length = svpd_size; out: return (0); @@ -98,13 +96,14 @@ fail1: } __checkReturn efx_rc_t -hunt_vpd_size( +ef10_vpd_size( __in efx_nic_t *enp, __out size_t *sizep) { efx_rc_t rc; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); /* * This function returns the total size the user should allocate @@ -125,7 +124,7 @@ fail1: } __checkReturn efx_rc_t -hunt_vpd_read( +ef10_vpd_read( __in efx_nic_t *enp, __out_bcount(size) caddr_t data, __in size_t size) @@ -135,11 +134,12 @@ hunt_vpd_read( uint32_t pci_pf; efx_rc_t rc; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); pci_pf = enp->en_nic_cfg.enc_pf; - if ((rc = hunt_nvram_partn_read_tlv(enp, + if ((rc = ef10_nvram_partn_read_tlv(enp, NVRAM_PARTITION_TYPE_DYNAMIC_CONFIG, TLV_TAG_PF_DYNAMIC_VPD(pci_pf), &dvpd, &dvpd_size)) != 0) @@ -169,7 +169,7 @@ fail1: } __checkReturn efx_rc_t -hunt_vpd_verify( +ef10_vpd_verify( __in efx_nic_t *enp, __in_bcount(size) caddr_t data, __in size_t size) @@ -182,12 +182,13 @@ hunt_vpd_verify( unsigned int dcont; efx_rc_t rc; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); /* * Strictly you could take the view that dynamic vpd is optional. * Instead, to conform more closely to the read/verify/reinit() - * paradigm, we require dynamic vpd. hunt_vpd_reinit() will + * paradigm, we require dynamic vpd. ef10_vpd_reinit() will * reinitialize it as required. */ if ((rc = efx_vpd_hunk_verify(data, size, NULL)) != 0) @@ -197,7 +198,7 @@ hunt_vpd_verify( * Verify that there is no duplication between the static and * dynamic cfg sectors. */ - if (enp->en_u.hunt.enu_svpd_length == 0) + if (enp->en_arch.ef10.ena_svpd_length == 0) goto done; dcont = 0; @@ -213,8 +214,8 @@ hunt_vpd_verify( _NOTE(CONSTANTCONDITION) while (1) { if ((rc = efx_vpd_hunk_next( - enp->en_u.hunt.enu_svpd, - enp->en_u.hunt.enu_svpd_length, &stag, &skey, + enp->en_arch.ef10.ena_svpd, + enp->en_arch.ef10.ena_svpd_length, &stag, &skey, NULL, NULL, &scont)) != 0) goto fail3; if (scont == 0) @@ -243,7 +244,7 @@ fail1: } __checkReturn efx_rc_t -hunt_vpd_reinit( +ef10_vpd_reinit( __in efx_nic_t *enp, __in_bcount(size) caddr_t data, __in size_t size) @@ -254,14 +255,14 @@ hunt_vpd_reinit( /* * Only create an ID string if the dynamic cfg doesn't have one */ - if (enp->en_u.hunt.enu_svpd_length == 0) + if (enp->en_arch.ef10.ena_svpd_length == 0) wantpid = B_TRUE; else { unsigned int offset; uint8_t length; - rc = efx_vpd_hunk_get(enp->en_u.hunt.enu_svpd, - enp->en_u.hunt.enu_svpd_length, + rc = efx_vpd_hunk_get(enp->en_arch.ef10.ena_svpd, + enp->en_arch.ef10.ena_svpd_length, EFX_VPD_ID, 0, &offset, &length); if (rc == 0) wantpid = B_FALSE; @@ -285,7 +286,7 @@ fail1: } __checkReturn efx_rc_t -hunt_vpd_get( +ef10_vpd_get( __in efx_nic_t *enp, __in_bcount(size) caddr_t data, __in size_t size, @@ -295,16 +296,17 @@ hunt_vpd_get( uint8_t length; efx_rc_t rc; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); /* Attempt to satisfy the request from svpd first */ - if (enp->en_u.hunt.enu_svpd_length > 0) { - if ((rc = efx_vpd_hunk_get(enp->en_u.hunt.enu_svpd, - enp->en_u.hunt.enu_svpd_length, evvp->evv_tag, + if (enp->en_arch.ef10.ena_svpd_length > 0) { + if ((rc = efx_vpd_hunk_get(enp->en_arch.ef10.ena_svpd, + enp->en_arch.ef10.ena_svpd_length, evvp->evv_tag, evvp->evv_keyword, &offset, &length)) == 0) { evvp->evv_length = length; memcpy(evvp->evv_value, - enp->en_u.hunt.enu_svpd + offset, length); + enp->en_arch.ef10.ena_svpd + offset, length); return (0); } else if (rc != ENOENT) goto fail1; @@ -329,7 +331,7 @@ fail1: } __checkReturn efx_rc_t -hunt_vpd_set( +ef10_vpd_set( __in efx_nic_t *enp, __in_bcount(size) caddr_t data, __in size_t size, @@ -337,15 +339,16 @@ hunt_vpd_set( { efx_rc_t rc; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); /* If the provided (tag,keyword) exists in svpd, then it is readonly */ - if (enp->en_u.hunt.enu_svpd_length > 0) { + if (enp->en_arch.ef10.ena_svpd_length > 0) { unsigned int offset; uint8_t length; - if ((rc = efx_vpd_hunk_get(enp->en_u.hunt.enu_svpd, - enp->en_u.hunt.enu_svpd_length, evvp->evv_tag, + if ((rc = efx_vpd_hunk_get(enp->en_arch.ef10.ena_svpd, + enp->en_arch.ef10.ena_svpd_length, evvp->evv_tag, evvp->evv_keyword, &offset, &length)) == 0) { rc = EACCES; goto fail1; @@ -366,7 +369,7 @@ fail1: } __checkReturn efx_rc_t -hunt_vpd_next( +ef10_vpd_next( __in efx_nic_t *enp, __in_bcount(size) caddr_t data, __in size_t size, @@ -379,7 +382,7 @@ hunt_vpd_next( } __checkReturn efx_rc_t -hunt_vpd_write( +ef10_vpd_write( __in efx_nic_t *enp, __in_bcount(size) caddr_t data, __in size_t size) @@ -388,7 +391,8 @@ hunt_vpd_write( uint32_t pci_pf; efx_rc_t rc; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); pci_pf = enp->en_nic_cfg.enc_pf; @@ -397,7 +401,7 @@ hunt_vpd_write( goto fail1; /* Store new dynamic VPD in all segments in DYNAMIC_CONFIG partition */ - if ((rc = hunt_nvram_partn_write_segment_tlv(enp, + if ((rc = ef10_nvram_partn_write_segment_tlv(enp, NVRAM_PARTITION_TYPE_DYNAMIC_CONFIG, TLV_TAG_PF_DYNAMIC_VPD(pci_pf), data, vpd_length, B_TRUE)) != 0) { @@ -416,17 +420,18 @@ fail1: } void -hunt_vpd_fini( +ef10_vpd_fini( __in efx_nic_t *enp) { - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON); + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || + enp->en_family == EFX_FAMILY_MEDFORD); - if (enp->en_u.hunt.enu_svpd_length > 0) { - EFSYS_KMEM_FREE(enp->en_esip, enp->en_u.hunt.enu_svpd_length, - enp->en_u.hunt.enu_svpd); + if (enp->en_arch.ef10.ena_svpd_length > 0) { + EFSYS_KMEM_FREE(enp->en_esip, enp->en_arch.ef10.ena_svpd_length, + enp->en_arch.ef10.ena_svpd); - enp->en_u.hunt.enu_svpd = NULL; - enp->en_u.hunt.enu_svpd_length = 0; + enp->en_arch.ef10.ena_svpd = NULL; + enp->en_arch.ef10.ena_svpd_length = 0; } } diff --git a/sys/dev/sfxge/common/mcdi_mon.c b/sys/dev/sfxge/common/mcdi_mon.c index f8b1681..4c7f961 100644 --- a/sys/dev/sfxge/common/mcdi_mon.c +++ b/sys/dev/sfxge/common/mcdi_mon.c @@ -31,7 +31,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" #include "efx_impl.h" @@ -149,6 +148,13 @@ static const struct mcdi_sensor_map_s { STAT(Px, CONTROLLER_SLAVE_VPTAT_EXT_ADC), /* 0x46 SLAVE_VPTAT_EXT_ADC */ STAT(Px, CONTROLLER_SLAVE_INTERNAL_TEMP_EXT_ADC), /* 0x47 SLAVE_INTERNAL_TEMP_EXT_ADC */ + STAT_NO_SENSOR(), /* 0x48 (no sensor) */ + STAT(Px, SODIMM_VOUT), /* 0x49 SODIMM_VOUT */ + STAT(Px, SODIMM_0_TEMP), /* 0x4a SODIMM_0_TEMP */ + STAT(Px, SODIMM_1_TEMP), /* 0x4b SODIMM_1_TEMP */ + STAT(Px, PHY0_VCC), /* 0x4c PHY0_VCC */ + STAT(Px, PHY1_VCC), /* 0x4d PHY1_VCC */ + STAT(Px, CONTROLLER_TDIODE_TEMP), /* 0x4e CONTROLLER_TDIODE_TEMP */ }; #define MCDI_STATIC_SENSOR_ASSERT(_field) \ @@ -478,6 +484,11 @@ mcdi_mon_cfg_build( encp->enc_mon_type = EFX_MON_SFC91X0; break; #endif +#if EFSYS_OPT_MEDFORD + case EFX_FAMILY_MEDFORD: + encp->enc_mon_type = EFX_MON_SFC92X0; + break; +#endif default: rc = EINVAL; goto fail1; diff --git a/sys/dev/sfxge/common/medford_impl.h b/sys/dev/sfxge/common/medford_impl.h new file mode 100644 index 0000000..11084dc --- /dev/null +++ b/sys/dev/sfxge/common/medford_impl.h @@ -0,0 +1,47 @@ +/*- + * Copyright (c) 2015 Solarflare Communications Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are + * those of the authors and should not be interpreted as representing official + * policies, either expressed or implied, of the FreeBSD Project. + * + * $FreeBSD$ + */ + +#ifndef _SYS_MEDFORD_IMPL_H +#define _SYS_MEDFORD_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define MEDFORD_PIOBUF_NBUFS (16) + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MEDFORD_IMPL_H */ diff --git a/sys/dev/sfxge/common/medford_nic.c b/sys/dev/sfxge/common/medford_nic.c new file mode 100644 index 0000000..68c8184 --- /dev/null +++ b/sys/dev/sfxge/common/medford_nic.c @@ -0,0 +1,45 @@ +/*- + * Copyright (c) 2015 Solarflare Communications Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are + * those of the authors and should not be interpreted as representing official + * policies, either expressed or implied, of the FreeBSD Project. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "efx.h" +#include "efx_impl.h" +#include "mcdi_mon.h" + +#if EFSYS_OPT_MEDFORD + +#include "ef10_tlv_layout.h" + + + + +#endif /* EFSYS_OPT_MEDFORD */ diff --git a/sys/dev/sfxge/common/siena_flash.h b/sys/dev/sfxge/common/siena_flash.h index 51e29e7..48ddfac 100644 --- a/sys/dev/sfxge/common/siena_flash.h +++ b/sys/dev/sfxge/common/siena_flash.h @@ -91,6 +91,19 @@ typedef struct blob_hdr_s { /* GENERATED BY scripts/genfwdef */ #define BLOB_CPU_TYPE_RXDI_VTBL1 (14) #define BLOB_CPU_TYPE_TXDI_VTBL1 (15) #define BLOB_CPU_TYPE_DUMPSPEC (32) +#define BLOB_CPU_TYPE_MC_XIP (33) + +#define BLOB_CPU_TYPE_INVALID (31) + +/* + * The upper four bits of the CPU type field specify the compression + * algorithm used for this blob. + */ +#define BLOB_COMPRESSION_MASK (0xf0000000) +#define BLOB_CPU_TYPE_MASK (0x0fffffff) + +#define BLOB_COMPRESSION_NONE (0x00000000) /* Stored as is */ +#define BLOB_COMPRESSION_LZ (0x10000000) /* see lib/lzdecoder.c */ typedef struct siena_mc_boot_hdr_s { /* GENERATED BY scripts/genfwdef */ efx_dword_t magic; /* = SIENA_MC_BOOT_MAGIC */ diff --git a/sys/dev/sfxge/common/siena_impl.h b/sys/dev/sfxge/common/siena_impl.h index 0433edb..effa113 100644 --- a/sys/dev/sfxge/common/siena_impl.h +++ b/sys/dev/sfxge/common/siena_impl.h @@ -158,18 +158,18 @@ siena_mcdi_feature_supported( extern __checkReturn efx_rc_t siena_nvram_partn_size( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __out size_t *sizep); extern __checkReturn efx_rc_t siena_nvram_partn_lock( __in efx_nic_t *enp, - __in unsigned int partn); + __in uint32_t partn); extern __checkReturn efx_rc_t siena_nvram_partn_read( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __in unsigned int offset, __out_bcount(size) caddr_t data, __in size_t size); @@ -177,14 +177,14 @@ siena_nvram_partn_read( extern __checkReturn efx_rc_t siena_nvram_partn_erase( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __in unsigned int offset, __in size_t size); extern __checkReturn efx_rc_t siena_nvram_partn_write( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __in unsigned int offset, __out_bcount(size) caddr_t data, __in size_t size); @@ -192,12 +192,12 @@ siena_nvram_partn_write( extern void siena_nvram_partn_unlock( __in efx_nic_t *enp, - __in unsigned int partn); + __in uint32_t partn); extern __checkReturn efx_rc_t siena_nvram_get_dynamic_cfg( __in efx_nic_t *enp, - __in unsigned int index, + __in uint32_t partn, __in boolean_t vpd, __out siena_mc_dynamic_config_hdr_t **dcfgp, __out size_t *sizep); @@ -223,7 +223,7 @@ siena_nvram_size( extern __checkReturn efx_rc_t siena_nvram_get_subtype( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __out uint32_t *subtypep); extern __checkReturn efx_rc_t @@ -271,6 +271,12 @@ siena_nvram_set_version( __in efx_nvram_type_t type, __in_ecount(4) uint16_t version[4]); +extern __checkReturn efx_rc_t +siena_nvram_type_to_partn( + __in efx_nic_t *enp, + __in efx_nvram_type_t type, + __out uint32_t *partnp); + #endif /* EFSYS_OPT_NVRAM */ #if EFSYS_OPT_VPD diff --git a/sys/dev/sfxge/common/siena_mac.c b/sys/dev/sfxge/common/siena_mac.c index ff8e11a..12ecffd 100644 --- a/sys/dev/sfxge/common/siena_mac.c +++ b/sys/dev/sfxge/common/siena_mac.c @@ -31,7 +31,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" #include "efx_impl.h" diff --git a/sys/dev/sfxge/common/siena_mcdi.c b/sys/dev/sfxge/common/siena_mcdi.c index a350598..b6d6fcb 100644 --- a/sys/dev/sfxge/common/siena_mcdi.c +++ b/sys/dev/sfxge/common/siena_mcdi.c @@ -31,7 +31,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" #include "efx_impl.h" @@ -53,6 +52,43 @@ __FBSDID("$FreeBSD$"); : MC_SMEM_P1_STATUS_OFST >> 2) +static void +siena_mcdi_send_request( + __in efx_nic_t *enp, + __in void *hdrp, + __in size_t hdr_len, + __in void *sdup, + __in size_t sdu_len) +{ + efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); + efx_dword_t dword; + unsigned int pdur; + unsigned int dbr; + unsigned int pos; + + EFSYS_ASSERT(enp->en_family == EFX_FAMILY_SIENA); + + EFSYS_ASSERT(emip->emi_port == 1 || emip->emi_port == 2); + pdur = SIENA_MCDI_PDU(emip); + dbr = SIENA_MCDI_DOORBELL(emip); + + /* Write the header */ + EFSYS_ASSERT3U(hdr_len, ==, sizeof (efx_dword_t)); + dword = *(efx_dword_t *)hdrp; + EFX_BAR_TBL_WRITED(enp, FR_CZ_MC_TREG_SMEM, pdur, &dword, B_TRUE); + + /* Write the payload */ + for (pos = 0; pos < sdu_len; pos += sizeof (efx_dword_t)) { + dword = *(efx_dword_t *)((uint8_t *)sdup + pos); + EFX_BAR_TBL_WRITED(enp, FR_CZ_MC_TREG_SMEM, + pdur + 1 + (pos >> 2), &dword, B_FALSE); + } + + /* Ring the doorbell */ + EFX_POPULATE_DWORD_1(dword, EFX_DWORD_0, 0xd004be11); + EFX_BAR_TBL_WRITED(enp, FR_CZ_MC_TREG_SMEM, dbr, &dword, B_FALSE); +} + void siena_mcdi_request_copyin( __in efx_nic_t *enp, @@ -64,26 +100,19 @@ siena_mcdi_request_copyin( #if EFSYS_OPT_MCDI_LOGGING const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp; #endif - efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); efx_dword_t hdr; - efx_dword_t dword; + size_t hdr_len; unsigned int xflags; - unsigned int pdur; - unsigned int dbr; - unsigned int pos; EFSYS_ASSERT(enp->en_family == EFX_FAMILY_SIENA); _NOTE(ARGUNUSED(new_epoch)) - EFSYS_ASSERT(emip->emi_port == 1 || emip->emi_port == 2); - pdur = SIENA_MCDI_PDU(emip); - dbr = SIENA_MCDI_DOORBELL(emip); - xflags = 0; if (ev_cpl) xflags |= MCDI_HEADER_XFLAGS_EVREQ; - /* Construct the header in shared memory */ + /* Construct the header */ + hdr_len = sizeof (hdr); EFX_POPULATE_DWORD_6(hdr, MCDI_HEADER_CODE, emrp->emr_cmd, MCDI_HEADER_RESYNC, 1, @@ -91,7 +120,6 @@ siena_mcdi_request_copyin( MCDI_HEADER_SEQ, seq, MCDI_HEADER_RESPONSE, 0, MCDI_HEADER_XFLAGS, xflags); - EFX_BAR_TBL_WRITED(enp, FR_CZ_MC_TREG_SMEM, pdur, &hdr, B_TRUE); #if EFSYS_OPT_MCDI_LOGGING if (emtp->emt_logger != NULL) { @@ -101,17 +129,8 @@ siena_mcdi_request_copyin( } #endif /* EFSYS_OPT_MCDI_LOGGING */ - /* Construct the payload */ - for (pos = 0; pos < emrp->emr_in_length; pos += sizeof (efx_dword_t)) { - memcpy(&dword, MCDI_IN(*emrp, efx_dword_t, pos), - MIN(sizeof (dword), emrp->emr_in_length - pos)); - EFX_BAR_TBL_WRITED(enp, FR_CZ_MC_TREG_SMEM, - pdur + 1 + (pos >> 2), &dword, B_FALSE); - } - - /* Ring the doorbell */ - EFX_POPULATE_DWORD_1(dword, EFX_DWORD_0, 0xd004be11); - EFX_BAR_TBL_WRITED(enp, FR_CZ_MC_TREG_SMEM, dbr, &dword, B_FALSE); + siena_mcdi_send_request(enp, &hdr, hdr_len, + emrp->emr_in_buf, emrp->emr_in_length); } void @@ -244,6 +263,9 @@ siena_mcdi_init( goto fail1; } + /* Siena BootROM and firmware only support MCDIv1 */ + emip->emi_max_version = 1; + /* * Wipe the atomic reboot status so subsequent MCDI requests succeed. * BOOT_STATUS is preserved so eno_nic_probe() can boot out of the diff --git a/sys/dev/sfxge/common/siena_nic.c b/sys/dev/sfxge/common/siena_nic.c index e3f1732..70e7b5d 100644 --- a/sys/dev/sfxge/common/siena_nic.c +++ b/sys/dev/sfxge/common/siena_nic.c @@ -31,7 +31,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" #include "efx_impl.h" #include "mcdi_mon.h" diff --git a/sys/dev/sfxge/common/siena_nvram.c b/sys/dev/sfxge/common/siena_nvram.c index ecc5195..8f107b4 100644 --- a/sys/dev/sfxge/common/siena_nvram.c +++ b/sys/dev/sfxge/common/siena_nvram.c @@ -31,10 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" -#include "efx_regs.h" #include "efx_impl.h" #if EFSYS_OPT_SIENA @@ -44,7 +41,7 @@ __FBSDID("$FreeBSD$"); __checkReturn efx_rc_t siena_nvram_partn_size( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __out size_t *sizep) { efx_rc_t rc; @@ -72,7 +69,7 @@ fail1: __checkReturn efx_rc_t siena_nvram_partn_lock( __in efx_nic_t *enp, - __in unsigned int partn) + __in uint32_t partn) { efx_rc_t rc; @@ -91,7 +88,7 @@ fail1: __checkReturn efx_rc_t siena_nvram_partn_read( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __in unsigned int offset, __out_bcount(size) caddr_t data, __in size_t size) @@ -123,7 +120,7 @@ fail1: __checkReturn efx_rc_t siena_nvram_partn_erase( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __in unsigned int offset, __in size_t size) { @@ -144,7 +141,7 @@ fail1: __checkReturn efx_rc_t siena_nvram_partn_write( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __in unsigned int offset, __out_bcount(size) caddr_t data, __in size_t size) @@ -176,7 +173,7 @@ fail1: void siena_nvram_partn_unlock( __in efx_nic_t *enp, - __in unsigned int partn) + __in uint32_t partn) { boolean_t reboot; efx_rc_t rc; @@ -232,27 +229,31 @@ static siena_parttbl_entry_t siena_parttbl[] = { {MC_CMD_NVRAM_TYPE_CPLD, 2, EFX_NVRAM_CPLD}, }; -static __checkReturn siena_parttbl_entry_t * -siena_parttbl_entry( + __checkReturn efx_rc_t +siena_nvram_type_to_partn( __in efx_nic_t *enp, - __in efx_nvram_type_t type) + __in efx_nvram_type_t type, + __out uint32_t *partnp) { efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); - siena_parttbl_entry_t *entry; unsigned int i; EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES); + EFSYS_ASSERT(partnp != NULL); for (i = 0; i < EFX_ARRAY_SIZE(siena_parttbl); i++) { - entry = &siena_parttbl[i]; + siena_parttbl_entry_t *entry = &siena_parttbl[i]; - if (entry->port == emip->emi_port && entry->nvtype == type) - return (entry); + if (entry->port == emip->emi_port && entry->nvtype == type) { + *partnp = entry->partn; + return (0); + } } - return (NULL); + return (ENOTSUP); } + #if EFSYS_OPT_DIAG __checkReturn efx_rc_t @@ -296,15 +297,13 @@ siena_nvram_size( __in efx_nvram_type_t type, __out size_t *sizep) { - siena_parttbl_entry_t *entry; + uint32_t partn; efx_rc_t rc; - if ((entry = siena_parttbl_entry(enp, type)) == NULL) { - rc = ENOTSUP; + if ((rc = siena_nvram_type_to_partn(enp, type, &partn)) != 0) goto fail1; - } - if ((rc = siena_nvram_partn_size(enp, entry->partn, sizep)) != 0) + if ((rc = siena_nvram_partn_size(enp, partn, sizep)) != 0) goto fail2; return (0); @@ -326,7 +325,7 @@ fail1: __checkReturn efx_rc_t siena_nvram_get_dynamic_cfg( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __in boolean_t vpd, __out siena_mc_dynamic_config_hdr_t **dcfgp, __out size_t *sizep) @@ -455,7 +454,7 @@ fail1: __checkReturn efx_rc_t siena_nvram_get_subtype( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __out uint32_t *subtypep) { efx_mcdi_req_t req; @@ -515,16 +514,13 @@ siena_nvram_get_version( { siena_mc_dynamic_config_hdr_t *dcfg; siena_parttbl_entry_t *entry; - unsigned int dcfg_partn; - unsigned int partn; + uint32_t dcfg_partn; + uint32_t partn; unsigned int i; efx_rc_t rc; - if ((entry = siena_parttbl_entry(enp, type)) == NULL) { - rc = ENOTSUP; + if ((rc = siena_nvram_type_to_partn(enp, type, &partn)) != 0) goto fail1; - } - partn = entry->partn; if ((1 << partn) & ~enp->en_u.siena.enu_partn_mask) { rc = ENOTSUP; @@ -605,15 +601,13 @@ siena_nvram_rw_start( __in efx_nvram_type_t type, __out size_t *chunk_sizep) { - siena_parttbl_entry_t *entry; + uint32_t partn; efx_rc_t rc; - if ((entry = siena_parttbl_entry(enp, type)) == NULL) { - rc = ENOTSUP; + if ((rc = siena_nvram_type_to_partn(enp, type, &partn)) != 0) goto fail1; - } - if ((rc = siena_nvram_partn_lock(enp, entry->partn)) != 0) + if ((rc = siena_nvram_partn_lock(enp, partn)) != 0) goto fail2; if (chunk_sizep != NULL) @@ -637,16 +631,13 @@ siena_nvram_read_chunk( __out_bcount(size) caddr_t data, __in size_t size) { - siena_parttbl_entry_t *entry; + uint32_t partn; efx_rc_t rc; - if ((entry = siena_parttbl_entry(enp, type)) == NULL) { - rc = ENOTSUP; + if ((rc = siena_nvram_type_to_partn(enp, type, &partn)) != 0) goto fail1; - } - if ((rc = siena_nvram_partn_read(enp, entry->partn, - offset, data, size)) != 0) + if ((rc = siena_nvram_partn_read(enp, partn, offset, data, size)) != 0) goto fail2; return (0); @@ -664,19 +655,17 @@ siena_nvram_erase( __in efx_nic_t *enp, __in efx_nvram_type_t type) { - siena_parttbl_entry_t *entry; size_t size; + uint32_t partn; efx_rc_t rc; - if ((entry = siena_parttbl_entry(enp, type)) == NULL) { - rc = ENOTSUP; + if ((rc = siena_nvram_type_to_partn(enp, type, &partn)) != 0) goto fail1; - } - if ((rc = siena_nvram_partn_size(enp, entry->partn, &size)) != 0) + if ((rc = siena_nvram_partn_size(enp, partn, &size)) != 0) goto fail2; - if ((rc = siena_nvram_partn_erase(enp, entry->partn, 0, size)) != 0) + if ((rc = siena_nvram_partn_erase(enp, partn, 0, size)) != 0) goto fail3; return (0); @@ -699,16 +688,13 @@ siena_nvram_write_chunk( __in_bcount(size) caddr_t data, __in size_t size) { - siena_parttbl_entry_t *entry; + uint32_t partn; efx_rc_t rc; - if ((entry = siena_parttbl_entry(enp, type)) == NULL) { - rc = ENOTSUP; + if ((rc = siena_nvram_type_to_partn(enp, type, &partn)) != 0) goto fail1; - } - if ((rc = siena_nvram_partn_write(enp, entry->partn, - offset, data, size)) != 0) + if ((rc = siena_nvram_partn_write(enp, partn, offset, data, size)) != 0) goto fail2; return (0); @@ -726,10 +712,11 @@ siena_nvram_rw_finish( __in efx_nic_t *enp, __in efx_nvram_type_t type) { - siena_parttbl_entry_t *entry; + uint32_t partn; + efx_rc_t rc; - if ((entry = siena_parttbl_entry(enp, type)) != NULL) - siena_nvram_partn_unlock(enp, entry->partn); + if ((rc = siena_nvram_type_to_partn(enp, type, &partn)) == 0) + siena_nvram_partn_unlock(enp, partn); } __checkReturn efx_rc_t @@ -738,10 +725,11 @@ siena_nvram_set_version( __in efx_nvram_type_t type, __in_ecount(4) uint16_t version[4]) { + efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); siena_mc_dynamic_config_hdr_t *dcfg = NULL; - siena_parttbl_entry_t *entry; - unsigned int dcfg_partn; - size_t partn_size; + siena_mc_fw_version_t *fwverp; + uint32_t dcfg_partn, partn; + size_t dcfg_size; unsigned int hdr_length; unsigned int vpd_length; unsigned int vpd_offset; @@ -753,16 +741,14 @@ siena_nvram_set_version( size_t length; efx_rc_t rc; - if ((entry = siena_parttbl_entry(enp, type)) == NULL) { - rc = ENOTSUP; + if ((rc = siena_nvram_type_to_partn(enp, type, &partn)) != 0) goto fail1; - } - dcfg_partn = (entry->port == 1) + dcfg_partn = (emip->emi_port == 1) ? MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT0 : MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT1; - if ((rc = siena_nvram_partn_size(enp, dcfg_partn, &partn_size)) != 0) + if ((rc = siena_nvram_partn_size(enp, dcfg_partn, &dcfg_size)) != 0) goto fail2; if ((rc = siena_nvram_partn_lock(enp, dcfg_partn)) != 0) @@ -781,7 +767,7 @@ siena_nvram_set_version( * NOTE: This function will blatt any fields trailing the version * vector, or the VPD chunk. */ - required_hdr_length = SIENA_DYNAMIC_CFG_SIZE(entry->partn + 1); + required_hdr_length = SIENA_DYNAMIC_CFG_SIZE(partn + 1); if (required_hdr_length + vpd_length > length) { rc = ENOSPC; goto fail4; @@ -804,24 +790,20 @@ siena_nvram_set_version( } /* Get the subtype to insert into the fw_subtype array */ - if ((rc = siena_nvram_get_subtype(enp, entry->partn, &subtype)) != 0) + if ((rc = siena_nvram_get_subtype(enp, partn, &subtype)) != 0) goto fail5; /* Fill out the new version */ - EFX_POPULATE_DWORD_1(dcfg->fw_version[entry->partn].fw_subtype, - EFX_DWORD_0, subtype); - EFX_POPULATE_WORD_1(dcfg->fw_version[entry->partn].version_w, - EFX_WORD_0, version[0]); - EFX_POPULATE_WORD_1(dcfg->fw_version[entry->partn].version_x, - EFX_WORD_0, version[1]); - EFX_POPULATE_WORD_1(dcfg->fw_version[entry->partn].version_y, - EFX_WORD_0, version[2]); - EFX_POPULATE_WORD_1(dcfg->fw_version[entry->partn].version_z, - EFX_WORD_0, version[3]); + fwverp = &dcfg->fw_version[partn]; + EFX_POPULATE_DWORD_1(fwverp->fw_subtype, EFX_DWORD_0, subtype); + EFX_POPULATE_WORD_1(fwverp->version_w, EFX_WORD_0, version[0]); + EFX_POPULATE_WORD_1(fwverp->version_x, EFX_WORD_0, version[1]); + EFX_POPULATE_WORD_1(fwverp->version_y, EFX_WORD_0, version[2]); + EFX_POPULATE_WORD_1(fwverp->version_z, EFX_WORD_0, version[3]); /* Update the version count */ - if (nitems < entry->partn + 1) { - nitems = entry->partn + 1; + if (nitems < partn + 1) { + nitems = partn + 1; EFX_POPULATE_DWORD_1(dcfg->num_fw_version_items, EFX_DWORD_0, nitems); } @@ -833,7 +815,7 @@ siena_nvram_set_version( dcfg->csum.eb_u8[0] -= cksum; /* Erase and write the new partition */ - if ((rc = siena_nvram_partn_erase(enp, dcfg_partn, 0, partn_size)) != 0) + if ((rc = siena_nvram_partn_erase(enp, dcfg_partn, 0, dcfg_size)) != 0) goto fail6; /* Write out the new structure to nvram */ diff --git a/sys/dev/sfxge/common/siena_phy.c b/sys/dev/sfxge/common/siena_phy.c index d39ae97..920314a 100644 --- a/sys/dev/sfxge/common/siena_phy.c +++ b/sys/dev/sfxge/common/siena_phy.c @@ -31,7 +31,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" #include "efx_impl.h" diff --git a/sys/dev/sfxge/common/siena_sram.c b/sys/dev/sfxge/common/siena_sram.c index 9a9c5ca..762de42 100644 --- a/sys/dev/sfxge/common/siena_sram.c +++ b/sys/dev/sfxge/common/siena_sram.c @@ -31,7 +31,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" #include "efx_impl.h" diff --git a/sys/dev/sfxge/common/siena_vpd.c b/sys/dev/sfxge/common/siena_vpd.c index df6797d..9a07f91 100644 --- a/sys/dev/sfxge/common/siena_vpd.c +++ b/sys/dev/sfxge/common/siena_vpd.c @@ -31,10 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" -#include "efx_regs.h" #include "efx_impl.h" #if EFSYS_OPT_VPD @@ -44,7 +41,7 @@ __FBSDID("$FreeBSD$"); static __checkReturn efx_rc_t siena_vpd_get_static( __in efx_nic_t *enp, - __in unsigned int partn, + __in uint32_t partn, __deref_out_bcount_opt(*sizep) caddr_t *svpdp, __out size_t *sizep) { @@ -207,7 +204,7 @@ siena_vpd_size( __out size_t *sizep) { efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); - unsigned int partn; + uint32_t partn; efx_rc_t rc; EFSYS_ASSERT(enp->en_family == EFX_FAMILY_SIENA); diff --git a/sys/dev/syscons/plasma/fp16.c b/sys/dev/syscons/plasma/fp16.c new file mode 100644 index 0000000..dddba2e --- /dev/null +++ b/sys/dev/syscons/plasma/fp16.c @@ -0,0 +1,155 @@ +/*- + * Copyright (c) 2015 Dag-Erling Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifdef _KERNEL +#include <sys/libkern.h> +#else +#include <stdio.h> +#include <strings.h> +#endif + +#include "fp16.h" + +/* + * Compute the quare root of x, using Newton's method with 2^(log2(x)/2) + * as the initial estimate. + */ +fp16_t +fp16_sqrt(fp16_t x) +{ + fp16_t y, delta; + signed int log2x; + + /* special case */ + if (x == 0) + return (0); + + /* shift toward 0 by half the logarithm */ + log2x = flsl(x) - 1; + if (log2x >= 16) { + y = x >> (log2x - 16) / 2; + } else { +#if 0 + y = x << (16 - log2x) / 2; +#else + /* XXX for now, return 0 for anything < 1 */ + return (0); +#endif + } + while (y > 0) { + /* delta = y^2 / 2y */ + delta = fp16_div(fp16_sub(fp16_mul(y, y), x), y * 2); + if (delta == 0) + break; + y = fp16_sub(y, delta); + } + return (y); +} + +static fp16_t fp16_sin_table[256] = { + 0, 402, 804, 1206, 1608, 2010, 2412, 2814, + 3215, 3617, 4018, 4420, 4821, 5222, 5622, 6023, + 6423, 6823, 7223, 7623, 8022, 8421, 8819, 9218, + 9616, 10013, 10410, 10807, 11204, 11600, 11995, 12390, + 12785, 13179, 13573, 13966, 14359, 14751, 15142, 15533, + 15923, 16313, 16702, 17091, 17479, 17866, 18253, 18638, + 19024, 19408, 19792, 20175, 20557, 20938, 21319, 21699, + 22078, 22456, 22833, 23210, 23586, 23960, 24334, 24707, + 25079, 25450, 25820, 26189, 26557, 26925, 27291, 27656, + 28020, 28383, 28745, 29105, 29465, 29824, 30181, 30538, + 30893, 31247, 31600, 31952, 32302, 32651, 32999, 33346, + 33692, 34036, 34379, 34721, 35061, 35400, 35738, 36074, + 36409, 36743, 37075, 37406, 37736, 38064, 38390, 38716, + 39039, 39362, 39682, 40002, 40319, 40636, 40950, 41263, + 41575, 41885, 42194, 42501, 42806, 43110, 43412, 43712, + 44011, 44308, 44603, 44897, 45189, 45480, 45768, 46055, + 46340, 46624, 46906, 47186, 47464, 47740, 48015, 48288, + 48558, 48828, 49095, 49360, 49624, 49886, 50146, 50403, + 50660, 50914, 51166, 51416, 51665, 51911, 52155, 52398, + 52639, 52877, 53114, 53348, 53581, 53811, 54040, 54266, + 54491, 54713, 54933, 55152, 55368, 55582, 55794, 56004, + 56212, 56417, 56621, 56822, 57022, 57219, 57414, 57606, + 57797, 57986, 58172, 58356, 58538, 58718, 58895, 59070, + 59243, 59414, 59583, 59749, 59913, 60075, 60235, 60392, + 60547, 60700, 60850, 60998, 61144, 61288, 61429, 61568, + 61705, 61839, 61971, 62100, 62228, 62353, 62475, 62596, + 62714, 62829, 62942, 63053, 63162, 63268, 63371, 63473, + 63571, 63668, 63762, 63854, 63943, 64030, 64115, 64197, + 64276, 64353, 64428, 64501, 64571, 64638, 64703, 64766, + 64826, 64884, 64939, 64992, 65043, 65091, 65136, 65179, + 65220, 65258, 65294, 65327, 65358, 65386, 65412, 65436, + 65457, 65475, 65491, 65505, 65516, 65524, 65531, 65534, +}; + +/* + * Compute the sine of theta. + */ +fp16_t +fp16_sin(fp16_t theta) +{ + unsigned int i; + + i = 1024 * (theta % FP16_2PI) / FP16_2PI; + switch (i / 256) { + case 0: + return (fp16_sin_table[i % 256]); + case 1: + return (fp16_sin_table[255 - i % 256]); + case 2: + return (-fp16_sin_table[i % 256]); + case 3: + return (-fp16_sin_table[255 - i % 256]); + default: + /* inconceivable! */ + return (0); + } +} + +/* + * Compute the cosine of theta. + */ +fp16_t +fp16_cos(fp16_t theta) +{ + unsigned int i; + + i = 1024 * (theta % FP16_2PI) / FP16_2PI; + switch (i / 256) { + case 0: + return (fp16_sin_table[255 - i % 256]); + case 1: + return (-fp16_sin_table[i % 256]); + case 2: + return (-fp16_sin_table[255 - i % 256]); + case 3: + return (fp16_sin_table[i % 256]); + default: + /* inconceivable! */ + return (0); + } +} diff --git a/sys/dev/syscons/plasma/fp16.h b/sys/dev/syscons/plasma/fp16.h new file mode 100644 index 0000000..ae54d20 --- /dev/null +++ b/sys/dev/syscons/plasma/fp16.h @@ -0,0 +1,85 @@ +/*- + * Copyright (c) 2015 Dag-Erling Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef FP16_H_INCLUDED +#define FP16_H_INCLUDED + +typedef signed long long fp16_t; + +#define ItoFP16(n) ((signed long long)(n) << 16) +#define FP16toI(n) ((signed long long)(n) >> 16) + +#ifndef _KERNEL +#define FP16toF(n) ((n) / 65536.0) +#endif + +/* add a and b */ +static inline fp16_t +fp16_add(fp16_t a, fp16_t b) +{ + + return (a + b); +} + +/* subtract b from a */ +static inline fp16_t +fp16_sub(fp16_t a, fp16_t b) +{ + + return (a - b); +} + +/* multiply a by b */ +static inline fp16_t +fp16_mul(fp16_t a, fp16_t b) +{ + + return (a * b >> 16); +} + +/* divide a by b */ +static inline fp16_t +fp16_div(fp16_t a, fp16_t b) +{ + + return ((a << 16) / b); +} + +/* square root */ +fp16_t fp16_sqrt(fp16_t); + +#define FP16_2PI 411774 +#define FP16_PI 205887 +#define FP16_PI_2 102943 +#define FP16_PI_4 51471 + +/* sine and cosine */ +fp16_t fp16_sin(fp16_t); +fp16_t fp16_cos(fp16_t); + +#endif diff --git a/sys/dev/syscons/plasma/plasma_saver.c b/sys/dev/syscons/plasma/plasma_saver.c new file mode 100644 index 0000000..761aa5c --- /dev/null +++ b/sys/dev/syscons/plasma/plasma_saver.c @@ -0,0 +1,239 @@ +/*- + * Copyright (c) 2015 Dag-Erling Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + * + * To CJA, in appreciation of Nighthawk brunches past and future. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/module.h> +#include <sys/syslog.h> +#include <sys/consio.h> +#include <sys/fbio.h> + +#include <dev/fb/fbreg.h> +#include <dev/fb/splashreg.h> +#include <dev/syscons/syscons.h> + +#define SAVER_NAME "plasma_saver" + +#include "fp16.h" + +/* + * Preferred video modes + */ +static int modes[] = { + M_VGA_CG640, + M_PC98_PEGC640x480, + M_PC98_PEGC640x400, + M_VGA_CG320, + -1 +}; + +/* + * Display parameters + */ +static unsigned char *vid; +static unsigned int banksize, scrmode, scrw, scrh; +static unsigned int blanked; + +/* + * List of foci + */ +#define FOCI 3 +static struct { + int x, y; /* coordinates */ + int vx, vy; /* velocity */ +} plasma_foci[FOCI]; + +/* + * Palette + */ +static struct { + unsigned char r, g, b; +} plasma_pal[256]; + +/* + * Draw a new frame + */ +static void +plasma_update(video_adapter_t *adp) +{ + unsigned int x, y; /* coordinates */ + signed int dx, dy; /* horizontal / vertical distance */ + fp16_t sqd, d; /* square of distance and distance */ + fp16_t m; /* magnitude */ + unsigned int org, off; /* origin and offset */ + unsigned int i; /* loop index */ + + /* switch to bank 0 */ + vidd_set_win_org(adp, 0); + /* for each scan line */ + for (y = org = off = 0; y < scrh; ++y) { + /* for each pixel on scan line */ + for (x = 0; x < scrw; ++x, ++off) { + /* for each focus */ + for (i = m = 0; i < FOCI; ++i) { + dx = x - plasma_foci[i].x; + dy = y - plasma_foci[i].y; + sqd = ItoFP16(dx * dx + dy * dy); + d = fp16_sqrt(sqd); + /* divide by 4 to stretch out the pattern */ + m = fp16_sub(m, fp16_cos(d / 4)); + } + /* + * m is now in the range +/- FOCI, but we need a + * value between 0 and 255. We scale to +/- 127 + * and add 127, which moves it into the range [0, + * 254]. + */ + m = fp16_mul(m, ItoFP16(127)); + m = fp16_div(m, ItoFP16(FOCI)); + m = fp16_add(m, ItoFP16(127)); + /* switch banks if necessary */ + if (off > banksize) { + off -= banksize; + org += banksize; + vidd_set_win_org(adp, org); + } + /* plot */ + vid[off] = FP16toI(m); + } + } + /* now move the foci */ + for (i = 0; i < FOCI; ++i) { + plasma_foci[i].x += plasma_foci[i].vx; + if (plasma_foci[i].x < 0) { + /* bounce against left wall */ + plasma_foci[i].vx = -plasma_foci[i].vx; + plasma_foci[i].x = -plasma_foci[i].x; + } else if (plasma_foci[i].x >= scrw) { + /* bounce against right wall */ + plasma_foci[i].vx = -plasma_foci[i].vx; + plasma_foci[i].x = scrw - (plasma_foci[i].x - scrw); + } + plasma_foci[i].y += plasma_foci[i].vy; + if (plasma_foci[i].y < 0) { + /* bounce against ceiling */ + plasma_foci[i].vy = -plasma_foci[i].vy; + plasma_foci[i].y = -plasma_foci[i].y; + } else if (plasma_foci[i].y >= scrh) { + /* bounce against floor */ + plasma_foci[i].vy = -plasma_foci[i].vy; + plasma_foci[i].y = scrh - (plasma_foci[i].y - scrh); + } + } +} + +/* + * Start or stop the screensaver + */ +static int +plasma_saver(video_adapter_t *adp, int blank) +{ + int pl; + + if (blank) { + /* switch to graphics mode */ + if (blanked <= 0) { + pl = splhigh(); + vidd_set_mode(adp, scrmode); + vidd_load_palette(adp, (unsigned char *)plasma_pal); + vidd_set_border(adp, 0); + blanked++; + vid = (unsigned char *)adp->va_window; + banksize = adp->va_window_size; + splx(pl); + vidd_clear(adp); + } + /* update display */ + plasma_update(adp); + } else { + blanked = 0; + } + return (0); +} + +/* + * Initialize on module load + */ +static int +plasma_init(video_adapter_t *adp) +{ + video_info_t info; + int i; + + /* select video mode */ + for (i = 0; modes[i] >= 0; ++i) + if (vidd_get_info(adp, modes[i], &info) == 0) + break; + if (modes[i] < 0) { + log(LOG_NOTICE, "%s: no supported video modes\n", SAVER_NAME); + return (ENODEV); + } + scrmode = modes[i]; + scrw = info.vi_width; + scrh = info.vi_height; + + /* initialize the palette */ + for (i = 0; i < 256; ++i) + plasma_pal[i].r = plasma_pal[i].g = plasma_pal[i].b = i; + + /* randomize the foci */ + for (i = 0; i < FOCI; i++) { + plasma_foci[i].x = random() % scrw; + plasma_foci[i].y = random() % scrh; + plasma_foci[i].vx = random() % 5 - 2; + plasma_foci[i].vy = random() % 5 - 2; + } + + return (0); +} + +/* + * Clean up before module unload + */ +static int +plasma_term(video_adapter_t *adp) +{ + + return (0); +} + +/* + * Boilerplate + */ +static scrn_saver_t plasma_module = { + SAVER_NAME, + plasma_init, + plasma_term, + plasma_saver, + NULL +}; + +SAVER_MODULE(plasma_saver, plasma_module); diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c index 9b9c4a1..eba7f7b 100644 --- a/sys/dev/ti/if_ti.c +++ b/sys/dev/ti/if_ti.c @@ -1634,7 +1634,7 @@ ti_newbuf_jumbo(struct ti_softc *sc, int idx, struct mbuf *m_old) m[i]->m_data = (void *)sf_buf_kva(sf[i]); m[i]->m_len = PAGE_SIZE; MEXTADD(m[i], sf_buf_kva(sf[i]), PAGE_SIZE, - sf_buf_mext, (void*)sf_buf_kva(sf[i]), sf[i], + sf_mext_free, (void*)sf_buf_kva(sf[i]), sf[i], 0, EXT_DISPOSABLE); m[i]->m_next = m[i+1]; } @@ -1699,7 +1699,7 @@ nobufs: if (m[i]) m_freem(m[i]); if (sf[i]) - sf_buf_mext((void *)sf_buf_kva(sf[i]), sf[i]); + sf_mext_free((void *)sf_buf_kva(sf[i]), sf[i]); } return (ENOBUFS); } diff --git a/sys/dev/tsec/if_tsec.c b/sys/dev/tsec/if_tsec.c index 7ec2f98..3fd8726 100644 --- a/sys/dev/tsec/if_tsec.c +++ b/sys/dev/tsec/if_tsec.c @@ -561,7 +561,7 @@ tsec_set_mac_address(struct tsec_softc *sc) TSEC_GLOBAL_LOCK_ASSERT(sc); KASSERT((ETHER_ADDR_LEN <= sizeof(macbuf)), - ("tsec_set_mac_address: (%d <= %d", ETHER_ADDR_LEN, + ("tsec_set_mac_address: (%d <= %zd", ETHER_ADDR_LEN, sizeof(macbuf))); macbufp = (char *)macbuf; diff --git a/sys/dev/uart/uart_bus.h b/sys/dev/uart/uart_bus.h index 11d599e67..d46c28d 100644 --- a/sys/dev/uart/uart_bus.h +++ b/sys/dev/uart/uart_bus.h @@ -113,6 +113,7 @@ struct uart_softc { /* Pulse capturing support (PPS). */ struct pps_state sc_pps; int sc_pps_mode; + sbintime_t sc_pps_captime; /* Upper layer data. */ void *sc_softih; diff --git a/sys/dev/uart/uart_core.c b/sys/dev/uart/uart_core.c index 96b4529..9650dd5 100644 --- a/sys/dev/uart/uart_core.c +++ b/sys/dev/uart/uart_core.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include <dev/uart/uart.h> #include <dev/uart/uart_bus.h> #include <dev/uart/uart_cpu.h> +#include <dev/uart/uart_ppstypes.h> #include "uart_if.h" @@ -70,47 +71,47 @@ static int uart_force_poll; SYSCTL_INT(_debug, OID_AUTO, uart_force_poll, CTLFLAG_RDTUN, &uart_force_poll, 0, "Force UART polling"); -#define PPS_MODE_DISABLED 0 -#define PPS_MODE_CTS 1 -#define PPS_MODE_DCD 2 - -static inline int -uart_pps_signal(int pps_mode) -{ - - switch(pps_mode) { - case PPS_MODE_CTS: - return (SER_CTS); - case PPS_MODE_DCD: - return (SER_DCD); - } - return (0); -} static inline int uart_pps_mode_valid(int pps_mode) { - - switch(pps_mode) { - case PPS_MODE_DISABLED: - case PPS_MODE_CTS: - case PPS_MODE_DCD: - return (true); + int opt; + + switch(pps_mode & UART_PPS_SIGNAL_MASK) { + case UART_PPS_DISABLED: + case UART_PPS_CTS: + case UART_PPS_DCD: + break; + default: + return (false); } - return (false); + + opt = pps_mode & UART_PPS_OPTION_MASK; + if ((opt & ~(UART_PPS_INVERT_PULSE | UART_PPS_NARROW_PULSE)) != 0) + return (false); + + return (true); } -static const char * -uart_pps_mode_name(int pps_mode) +static void +uart_pps_print_mode(struct uart_softc *sc) { - switch(pps_mode) { - case PPS_MODE_DISABLED: - return ("disabled"); - case PPS_MODE_CTS: - return ("CTS"); - case PPS_MODE_DCD: - return ("DCD"); + + device_printf(sc->sc_dev, "PPS capture mode: "); + switch(sc->sc_pps_mode) { + case UART_PPS_DISABLED: + printf("disabled"); + case UART_PPS_CTS: + printf("CTS"); + case UART_PPS_DCD: + printf("DCD"); + default: + printf("invalid"); } - return ("invalid"); + if (sc->sc_pps_mode & UART_PPS_INVERT_PULSE) + printf("-Inverted"); + if (sc->sc_pps_mode & UART_PPS_NARROW_PULSE) + printf("-NarrowPulse"); + printf("\n"); } static int @@ -131,6 +132,55 @@ uart_pps_mode_sysctl(SYSCTL_HANDLER_ARGS) } static void +uart_pps_process(struct uart_softc *sc, int ser_sig) +{ + sbintime_t now; + int is_assert, pps_sig; + + /* Which signal is configured as PPS? Early out if none. */ + switch(sc->sc_pps_mode & UART_PPS_SIGNAL_MASK) { + case UART_PPS_CTS: + pps_sig = SER_CTS; + break; + case UART_PPS_DCD: + pps_sig = SER_DCD; + break; + default: + return; + } + + /* Early out if there is no change in the signal configured as PPS. */ + if ((ser_sig & SER_DELTA(pps_sig)) == 0) + return; + + /* + * In narrow-pulse mode we need to synthesize both capture and clear + * events from a single "delta occurred" indication from the uart + * hardware because the pulse width is too narrow to reliably detect + * both edges. However, when the pulse width is close to our interrupt + * processing latency we might intermittantly catch both edges. To + * guard against generating spurious events when that happens, we use a + * separate timer to ensure at least half a second elapses before we + * generate another event. + */ + pps_capture(&sc->sc_pps); + if (sc->sc_pps_mode & UART_PPS_NARROW_PULSE) { + now = getsbinuptime(); + if (now > sc->sc_pps_captime + 500 * SBT_1MS) { + sc->sc_pps_captime = now; + pps_event(&sc->sc_pps, PPS_CAPTUREASSERT); + pps_event(&sc->sc_pps, PPS_CAPTURECLEAR); + } + } else { + is_assert = ser_sig & pps_sig; + if (sc->sc_pps_mode & UART_PPS_INVERT_PULSE) + is_assert = !is_assert; + pps_event(&sc->sc_pps, is_assert ? PPS_CAPTUREASSERT : + PPS_CAPTURECLEAR); + } +} + +static void uart_pps_init(struct uart_softc *sc) { struct sysctl_ctx_list *ctx; @@ -147,23 +197,23 @@ uart_pps_init(struct uart_softc *sc) * for one specific device. */ #ifdef UART_PPS_ON_CTS - sc->sc_pps_mode = PPS_MODE_CTS; + sc->sc_pps_mode = UART_PPS_CTS; #else - sc->sc_pps_mode = PPS_MODE_DCD; + sc->sc_pps_mode = UART_PPS_DCD; #endif TUNABLE_INT_FETCH("hw.uart.pps_mode", &sc->sc_pps_mode); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "pps_mode", CTLTYPE_INT | CTLFLAG_RWTUN, sc, 0, uart_pps_mode_sysctl, "I", - "pulse capturing mode - 0/1/2 - disabled/CTS/DCD"); + "pulse mode: 0/1/2=disabled/CTS/DCD; " + "add 0x10 to invert, 0x20 for narrow pulse"); if (!uart_pps_mode_valid(sc->sc_pps_mode)) { device_printf(sc->sc_dev, - "Invalid pps_mode %d configured; disabling PPS capture\n", + "Invalid pps_mode 0x%02x configured; disabling PPS capture\n", sc->sc_pps_mode); - sc->sc_pps_mode = PPS_MODE_DISABLED; + sc->sc_pps_mode = UART_PPS_DISABLED; } else if (bootverbose) { - device_printf(sc->sc_dev, "PPS capture mode %d (%s)\n", - sc->sc_pps_mode, uart_pps_mode_name(sc->sc_pps_mode)); + uart_pps_print_mode(sc); } sc->sc_pps.ppscap = PPS_CAPTUREBOTH; @@ -313,23 +363,16 @@ static __inline int uart_intr_sigchg(void *arg) { struct uart_softc *sc = arg; - int new, old, pps_sig, sig; + int new, old, sig; sig = UART_GETSIG(sc); /* - * Time pulse counting support. Note that both CTS and DCD are - * active-low signals. The status bit is high to indicate that - * the signal on the line is low, which corresponds to a PPS - * clear event. + * Time pulse counting support, invoked whenever the PPS parameters are + * currently set to capture either edge of the signal. */ if (sc->sc_pps.ppsparam.mode & PPS_CAPTUREBOTH) { - pps_sig = uart_pps_signal(sc->sc_pps_mode); - if (sig & SER_DELTA(pps_sig)) { - pps_capture(&sc->sc_pps); - pps_event(&sc->sc_pps, (sig & pps_sig) ? - PPS_CAPTURECLEAR : PPS_CAPTUREASSERT); - } + uart_pps_process(sc, sig); } /* diff --git a/sys/dev/uart/uart_dev_ns8250.c b/sys/dev/uart/uart_dev_ns8250.c index ee0b37b..ee21f43 100644 --- a/sys/dev/uart/uart_dev_ns8250.c +++ b/sys/dev/uart/uart_dev_ns8250.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #endif #include <dev/uart/uart_bus.h> #include <dev/uart/uart_dev_ns8250.h> +#include <dev/uart/uart_ppstypes.h> #include <dev/ic/ns16550.h> @@ -401,11 +402,40 @@ static struct ofw_compat_data compat_data[] = { UART_FDT_CLASS_AND_DEVICE(compat_data); #endif -#define SIGCHG(c, i, s, d) \ - if (c) { \ - i |= (i & s) ? s : s | d; \ - } else { \ - i = (i & s) ? (i & ~s) | d : i; \ +/* Use token-pasting to form SER_ and MSR_ named constants. */ +#define SER(sig) SER_##sig +#define SERD(sig) SER_D##sig +#define MSR(sig) MSR_##sig +#define MSRD(sig) MSR_D##sig + +/* + * Detect signal changes using software delta detection. The previous state of + * the signals is in 'var' the new hardware state is in 'msr', and 'sig' is the + * short name (DCD, CTS, etc) of the signal bit being processed; 'var' gets the + * new state of both the signal and the delta bits. + */ +#define SIGCHGSW(var, msr, sig) \ + if ((msr) & MSR(sig)) { \ + if ((var & SER(sig)) == 0) \ + var |= SERD(sig) | SER(sig); \ + } else { \ + if ((var & SER(sig)) != 0) \ + var = SERD(sig) | (var & ~SER(sig)); \ + } + +/* + * Detect signal changes using the hardware msr delta bits. This is currently + * used only when PPS timing information is being captured using the "narrow + * pulse" option. With a narrow PPS pulse the signal may not still be asserted + * by time the interrupt handler is invoked. The hardware will latch the fact + * that it changed in the delta bits. + */ +#define SIGCHGHW(var, msr, sig) \ + if ((msr) & MSRD(sig)) { \ + if (((msr) & MSR(sig)) != 0) \ + var |= SERD(sig) | SER(sig); \ + else \ + var = SERD(sig) | (var & ~SER(sig)); \ } int @@ -532,21 +562,37 @@ ns8250_bus_flush(struct uart_softc *sc, int what) int ns8250_bus_getsig(struct uart_softc *sc) { - uint32_t new, old, sig; + uint32_t old, sig; uint8_t msr; + /* + * The delta bits are reputed to be broken on some hardware, so use + * software delta detection by default. Use the hardware delta bits + * when capturing PPS pulses which are too narrow for software detection + * to see the edges. Hardware delta for RI doesn't work like the + * others, so always use software for it. Other threads may be changing + * other (non-MSR) bits in sc_hwsig, so loop until it can succesfully + * update without other changes happening. Note that the SIGCHGxx() + * macros carefully preserve the delta bits when we have to loop several + * times and a signal transitions between iterations. + */ do { old = sc->sc_hwsig; sig = old; uart_lock(sc->sc_hwmtx); msr = uart_getreg(&sc->sc_bas, REG_MSR); uart_unlock(sc->sc_hwmtx); - SIGCHG(msr & MSR_DSR, sig, SER_DSR, SER_DDSR); - SIGCHG(msr & MSR_CTS, sig, SER_CTS, SER_DCTS); - SIGCHG(msr & MSR_DCD, sig, SER_DCD, SER_DDCD); - SIGCHG(msr & MSR_RI, sig, SER_RI, SER_DRI); - new = sig & ~SER_MASK_DELTA; - } while (!atomic_cmpset_32(&sc->sc_hwsig, old, new)); + if (sc->sc_pps_mode & UART_PPS_NARROW_PULSE) { + SIGCHGHW(sig, msr, DSR); + SIGCHGHW(sig, msr, CTS); + SIGCHGHW(sig, msr, DCD); + } else { + SIGCHGSW(sig, msr, DSR); + SIGCHGSW(sig, msr, CTS); + SIGCHGSW(sig, msr, DCD); + } + SIGCHGSW(sig, msr, RI); + } while (!atomic_cmpset_32(&sc->sc_hwsig, old, sig & ~SER_MASK_DELTA)); return (sig); } @@ -900,12 +946,10 @@ ns8250_bus_setsig(struct uart_softc *sc, int sig) old = sc->sc_hwsig; new = old; if (sig & SER_DDTR) { - SIGCHG(sig & SER_DTR, new, SER_DTR, - SER_DDTR); + new = (new & ~SER_DTR) | (sig & (SER_DTR | SER_DDTR)); } if (sig & SER_DRTS) { - SIGCHG(sig & SER_RTS, new, SER_RTS, - SER_DRTS); + new = (new & ~SER_RTS) | (sig & (SER_RTS | SER_DRTS)); } } while (!atomic_cmpset_32(&sc->sc_hwsig, old, new)); uart_lock(sc->sc_hwmtx); diff --git a/sys/dev/uart/uart_ppstypes.h b/sys/dev/uart/uart_ppstypes.h new file mode 100644 index 0000000..142d0f1 --- /dev/null +++ b/sys/dev/uart/uart_ppstypes.h @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 2015 Ian Lepore + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _DEV_UART_PPSTYPES_H_ +#define _DEV_UART_PPSTYPES_H_ + +/* + * These constants are shared by several drivers including uart and usb_serial. + */ + +#define UART_PPS_SIGNAL_MASK 0x0f +#define UART_PPS_OPTION_MASK 0xf0 + +#define UART_PPS_DISABLED 0x00 +#define UART_PPS_CTS 0x01 +#define UART_PPS_DCD 0x02 + +#define UART_PPS_INVERT_PULSE 0x10 +#define UART_PPS_NARROW_PULSE 0x20 + +#endif /* _DEV_UART_PPSTYPES_H_ */ diff --git a/sys/dev/usb/controller/dwc_otg.c b/sys/dev/usb/controller/dwc_otg.c index 5e51527d..16c4c3a 100644 --- a/sys/dev/usb/controller/dwc_otg.c +++ b/sys/dev/usb/controller/dwc_otg.c @@ -456,6 +456,18 @@ dwc_otg_init_fifo(struct dwc_otg_softc *sc, uint8_t mode) return (0); } +static uint8_t +dwc_otg_uses_split(struct usb_device *udev) +{ + /* + * When a LOW or FULL speed device is connected directly to + * the USB port we don't use split transactions: + */ + return (udev->speed != USB_SPEED_HIGH && + udev->parent_hs_hub != NULL && + udev->parent_hs_hub->parent_hub != NULL); +} + static void dwc_otg_update_host_frame_interval(struct dwc_otg_softc *sc) { @@ -3329,16 +3341,16 @@ dwc_otg_setup_standard_chain(struct usb_xfer *xfer) else hcchar |= (td->ep_type << HCCHAR_EPTYPE_SHIFT); - if (usbd_get_speed(xfer->xroot->udev) == USB_SPEED_LOW) - hcchar |= HCCHAR_LSPDDEV; if (UE_GET_DIR(xfer->endpointno) == UE_DIR_IN) hcchar |= HCCHAR_EPDIR_IN; switch (xfer->xroot->udev->speed) { - case USB_SPEED_FULL: case USB_SPEED_LOW: + hcchar |= HCCHAR_LSPDDEV; + /* FALLTHROUGH */ + case USB_SPEED_FULL: /* check if root HUB port is running High Speed */ - if (xfer->xroot->udev->parent_hs_hub != NULL) { + if (dwc_otg_uses_split(xfer->xroot->udev)) { hcsplt = HCSPLT_SPLTENA | (xfer->xroot->udev->hs_port_no << HCSPLT_PRTADDR_SHIFT) | @@ -4160,7 +4172,10 @@ dwc_otg_device_isoc_start(struct usb_xfer *xfer) framenum = DSTS_SOFFN_GET(temp); } - if (xfer->xroot->udev->parent_hs_hub != NULL) + /* + * Check if port is doing 8000 or 1000 frames per second: + */ + if (sc->sc_flags.status_high_speed) framenum /= 8; framenum &= DWC_OTG_FRAME_MASK; @@ -4837,7 +4852,7 @@ dwc_otg_xfer_setup(struct usb_setup_params *parm) td = USB_ADD_BYTES(parm->buf, parm->size[0]); /* compute shared bandwidth resource index for TT */ - if (parm->udev->parent_hs_hub != NULL && parm->udev->speed != USB_SPEED_HIGH) { + if (dwc_otg_uses_split(parm->udev)) { if (parm->udev->parent_hs_hub->ddesc.bDeviceProtocol == UDPROTO_HSHUBMTT) td->tt_index = parm->udev->device_index; else diff --git a/sys/dev/usb/wlan/if_rsu.c b/sys/dev/usb/wlan/if_rsu.c index ea89bff..0dcde19 100644 --- a/sys/dev/usb/wlan/if_rsu.c +++ b/sys/dev/usb/wlan/if_rsu.c @@ -403,7 +403,8 @@ rsu_attach(device_t self) struct rsu_softc *sc = device_get_softc(self); struct ieee80211com *ic = &sc->sc_ic; int error; - uint8_t iface_index, bands; + uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)]; + uint8_t iface_index; struct usb_interface *iface; const char *rft; @@ -531,12 +532,12 @@ rsu_attach(device_t self) } /* Set supported .11b and .11g rates. */ - bands = 0; - setbit(&bands, IEEE80211_MODE_11B); - setbit(&bands, IEEE80211_MODE_11G); + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); if (sc->sc_ht) - setbit(&bands, IEEE80211_MODE_11NG); - ieee80211_init_channels(ic, NULL, &bands); + setbit(bands, IEEE80211_MODE_11NG); + ieee80211_init_channels(ic, NULL, bands); ieee80211_ifattach(ic); ic->ic_raw_xmit = rsu_raw_xmit; diff --git a/sys/dev/usb/wlan/if_rum.c b/sys/dev/usb/wlan/if_rum.c index 02b82ef..3fada69 100644 --- a/sys/dev/usb/wlan/if_rum.c +++ b/sys/dev/usb/wlan/if_rum.c @@ -468,8 +468,9 @@ rum_attach(device_t self) struct usb_attach_arg *uaa = device_get_ivars(self); struct rum_softc *sc = device_get_softc(self); struct ieee80211com *ic = &sc->sc_ic; - uint8_t iface_index, bands; uint32_t tmp; + uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)]; + uint8_t iface_index; int error, ntries; device_set_usb_desc(self); @@ -537,12 +538,12 @@ rum_attach(device_t self) IEEE80211_CRYPTO_TKIPMIC | IEEE80211_CRYPTO_TKIP; - bands = 0; - setbit(&bands, IEEE80211_MODE_11B); - setbit(&bands, IEEE80211_MODE_11G); + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); if (sc->rf_rev == RT2573_RF_5225 || sc->rf_rev == RT2573_RF_5226) - setbit(&bands, IEEE80211_MODE_11A); - ieee80211_init_channels(ic, NULL, &bands); + setbit(bands, IEEE80211_MODE_11A); + ieee80211_init_channels(ic, NULL, bands); ieee80211_ifattach(ic); ic->ic_update_promisc = rum_update_promisc; diff --git a/sys/dev/usb/wlan/if_run.c b/sys/dev/usb/wlan/if_run.c index 1ad9f60..7a10d2c 100644 --- a/sys/dev/usb/wlan/if_run.c +++ b/sys/dev/usb/wlan/if_run.c @@ -704,8 +704,9 @@ run_attach(device_t self) struct usb_attach_arg *uaa = device_get_ivars(self); struct ieee80211com *ic = &sc->sc_ic; uint32_t ver; + uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)]; + uint8_t iface_index; int ntries, error; - uint8_t iface_index, bands; device_set_usb_desc(self); sc->sc_udev = uaa->device; @@ -785,14 +786,14 @@ run_attach(device_t self) ic->ic_flags |= IEEE80211_F_DATAPAD; ic->ic_flags_ext |= IEEE80211_FEXT_SWBMISS; - bands = 0; - setbit(&bands, IEEE80211_MODE_11B); - setbit(&bands, IEEE80211_MODE_11G); + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); if (sc->rf_rev == RT2860_RF_2750 || sc->rf_rev == RT2860_RF_2850 || sc->rf_rev == RT3070_RF_3052 || sc->rf_rev == RT3593_RF_3053 || sc->rf_rev == RT5592_RF_5592) - setbit(&bands, IEEE80211_MODE_11A); - ieee80211_init_channels(ic, NULL, &bands); + setbit(bands, IEEE80211_MODE_11A); + ieee80211_init_channels(ic, NULL, bands); ieee80211_ifattach(ic); diff --git a/sys/dev/usb/wlan/if_uath.c b/sys/dev/usb/wlan/if_uath.c index 747d49d..404fdd8 100644 --- a/sys/dev/usb/wlan/if_uath.c +++ b/sys/dev/usb/wlan/if_uath.c @@ -328,7 +328,8 @@ uath_attach(device_t dev) struct uath_softc *sc = device_get_softc(dev); struct usb_attach_arg *uaa = device_get_ivars(dev); struct ieee80211com *ic = &sc->sc_ic; - uint8_t bands, iface_index = UATH_IFACE_INDEX; /* XXX */ + uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)]; + uint8_t iface_index = UATH_IFACE_INDEX; /* XXX */ usb_error_t error; sc->sc_dev = dev; @@ -431,13 +432,13 @@ uath_attach(device_t dev) /* put a regulatory domain to reveal informations. */ uath_regdomain = sc->sc_devcap.regDomain; - bands = 0; - setbit(&bands, IEEE80211_MODE_11B); - setbit(&bands, IEEE80211_MODE_11G); + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); if ((sc->sc_devcap.analog5GhzRevision & 0xf0) == 0x30) - setbit(&bands, IEEE80211_MODE_11A); + setbit(bands, IEEE80211_MODE_11A); /* XXX turbo */ - ieee80211_init_channels(ic, NULL, &bands); + ieee80211_init_channels(ic, NULL, bands); ieee80211_ifattach(ic); ic->ic_raw_xmit = uath_raw_xmit; diff --git a/sys/dev/usb/wlan/if_upgt.c b/sys/dev/usb/wlan/if_upgt.c index 8030c6f..7f1e8ad 100644 --- a/sys/dev/usb/wlan/if_upgt.c +++ b/sys/dev/usb/wlan/if_upgt.c @@ -243,7 +243,8 @@ upgt_attach(device_t dev) struct upgt_softc *sc = device_get_softc(dev); struct ieee80211com *ic = &sc->sc_ic; struct usb_attach_arg *uaa = device_get_ivars(dev); - uint8_t bands, iface_index = UPGT_IFACE_INDEX; + uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)]; + uint8_t iface_index = UPGT_IFACE_INDEX; int error; sc->sc_dev = dev; @@ -337,10 +338,10 @@ upgt_attach(device_t dev) | IEEE80211_C_WPA /* 802.11i */ ; - bands = 0; - setbit(&bands, IEEE80211_MODE_11B); - setbit(&bands, IEEE80211_MODE_11G); - ieee80211_init_channels(ic, NULL, &bands); + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); + ieee80211_init_channels(ic, NULL, bands); ieee80211_ifattach(ic); ic->ic_raw_xmit = upgt_raw_xmit; diff --git a/sys/dev/usb/wlan/if_ural.c b/sys/dev/usb/wlan/if_ural.c index 4d84e5a..328b0a2 100644 --- a/sys/dev/usb/wlan/if_ural.c +++ b/sys/dev/usb/wlan/if_ural.c @@ -424,7 +424,8 @@ ural_attach(device_t self) struct usb_attach_arg *uaa = device_get_ivars(self); struct ural_softc *sc = device_get_softc(self); struct ieee80211com *ic = &sc->sc_ic; - uint8_t iface_index, bands; + uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)]; + uint8_t iface_index; int error; device_set_usb_desc(self); @@ -473,12 +474,12 @@ ural_attach(device_t self) | IEEE80211_C_WPA /* 802.11i */ ; - bands = 0; - setbit(&bands, IEEE80211_MODE_11B); - setbit(&bands, IEEE80211_MODE_11G); + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); if (sc->rf_rev == RAL_RF_5222) - setbit(&bands, IEEE80211_MODE_11A); - ieee80211_init_channels(ic, NULL, &bands); + setbit(bands, IEEE80211_MODE_11A); + ieee80211_init_channels(ic, NULL, bands); ieee80211_ifattach(ic); ic->ic_update_promisc = ural_update_promisc; diff --git a/sys/dev/usb/wlan/if_urtw.c b/sys/dev/usb/wlan/if_urtw.c index 105fd9d..0f7b4d9 100644 --- a/sys/dev/usb/wlan/if_urtw.c +++ b/sys/dev/usb/wlan/if_urtw.c @@ -785,7 +785,8 @@ urtw_attach(device_t dev) struct urtw_softc *sc = device_get_softc(dev); struct usb_attach_arg *uaa = device_get_ivars(dev); struct ieee80211com *ic = &sc->sc_ic; - uint8_t bands, iface_index = URTW_IFACE_INDEX; /* XXX */ + uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)]; + uint8_t iface_index = URTW_IFACE_INDEX; /* XXX */ uint16_t n_setup; uint32_t data; usb_error_t error; @@ -876,10 +877,10 @@ urtw_attach(device_t dev) IEEE80211_C_BGSCAN | /* capable of bg scanning */ IEEE80211_C_WPA; /* 802.11i */ - bands = 0; - setbit(&bands, IEEE80211_MODE_11B); - setbit(&bands, IEEE80211_MODE_11G); - ieee80211_init_channels(ic, NULL, &bands); + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); + ieee80211_init_channels(ic, NULL, bands); ieee80211_ifattach(ic); ic->ic_raw_xmit = urtw_raw_xmit; diff --git a/sys/dev/usb/wlan/if_urtwn.c b/sys/dev/usb/wlan/if_urtwn.c index 6ca43c3..13f3926 100644 --- a/sys/dev/usb/wlan/if_urtwn.c +++ b/sys/dev/usb/wlan/if_urtwn.c @@ -439,7 +439,7 @@ urtwn_attach(device_t self) struct usb_attach_arg *uaa = device_get_ivars(self); struct urtwn_softc *sc = device_get_softc(self); struct ieee80211com *ic = &sc->sc_ic; - uint8_t bands; + uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)]; int error; device_set_usb_desc(self); @@ -525,10 +525,10 @@ urtwn_attach(device_t self) IEEE80211_CRYPTO_TKIP | IEEE80211_CRYPTO_AES_CCM; - bands = 0; - setbit(&bands, IEEE80211_MODE_11B); - setbit(&bands, IEEE80211_MODE_11G); - ieee80211_init_channels(ic, NULL, &bands); + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); + ieee80211_init_channels(ic, NULL, bands); ieee80211_ifattach(ic); ic->ic_raw_xmit = urtwn_raw_xmit; @@ -2277,7 +2277,7 @@ urtwn_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) case IEEE80211_S_SCAN: /* Pause AC Tx queues. */ urtwn_write_1(sc, R92C_TXPAUSE, - urtwn_read_1(sc, R92C_TXPAUSE) | 0x0f); + urtwn_read_1(sc, R92C_TXPAUSE) | R92C_TX_QUEUE_AC); break; case IEEE80211_S_AUTH: urtwn_set_chan(sc, ic->ic_curchan, NULL); @@ -4425,7 +4425,7 @@ urtwn_lc_calib(struct urtwn_softc *sc) } } else { /* Block all Tx queues. */ - urtwn_write_1(sc, R92C_TXPAUSE, 0xff); + urtwn_write_1(sc, R92C_TXPAUSE, R92C_TX_QUEUE_ALL); } /* Start calibration. */ urtwn_rf_write(sc, 0, R92C_RF_CHNLBW, @@ -4640,7 +4640,7 @@ urtwn_init(struct urtwn_softc *sc) ieee80211_runtask(ic, &sc->cmdq_task); /* Enable hardware sequence numbering. */ - urtwn_write_1(sc, R92C_HWSEQ_CTRL, 0xff); + urtwn_write_1(sc, R92C_HWSEQ_CTRL, R92C_TX_QUEUE_ALL); /* Enable per-packet TX report. */ if (sc->chip & URTWN_CHIP_88E) { diff --git a/sys/dev/usb/wlan/if_urtwnreg.h b/sys/dev/usb/wlan/if_urtwnreg.h index 1a43297..2c5f2ef 100644 --- a/sys/dev/usb/wlan/if_urtwnreg.h +++ b/sys/dev/usb/wlan/if_urtwnreg.h @@ -496,6 +496,24 @@ #define R92C_EDCA_PARAM_TXOP_M 0xffff0000 #define R92C_EDCA_PARAM_TXOP_S 16 +/* Bits for R92C_HWSEQ_CTRL / R92C_TXPAUSE. */ +#define R92C_TX_QUEUE_VO 0x01 +#define R92C_TX_QUEUE_VI 0x02 +#define R92C_TX_QUEUE_BE 0x04 +#define R92C_TX_QUEUE_BK 0x08 +#define R92C_TX_QUEUE_MGT 0x10 +#define R92C_TX_QUEUE_HIGH 0x20 +#define R92C_TX_QUEUE_BCN 0x40 + +/* Shortcuts. */ +#define R92C_TX_QUEUE_AC \ + (R92C_TX_QUEUE_VO | R92C_TX_QUEUE_VI | \ + R92C_TX_QUEUE_BE | R92C_TX_QUEUE_BK) + +#define R92C_TX_QUEUE_ALL \ + (R92C_TX_QUEUE_AC | R92C_TX_QUEUE_MGT | \ + R92C_TX_QUEUE_HIGH | R92C_TX_QUEUE_BCN | 0x80) /* XXX */ + /* Bits for R92C_BCN_CTRL. */ #define R92C_BCN_CTRL_EN_MBSSID 0x02 #define R92C_BCN_CTRL_TXBCN_RPT 0x04 diff --git a/sys/dev/usb/wlan/if_zyd.c b/sys/dev/usb/wlan/if_zyd.c index d23f306..4463fc6 100644 --- a/sys/dev/usb/wlan/if_zyd.c +++ b/sys/dev/usb/wlan/if_zyd.c @@ -334,7 +334,8 @@ zyd_attach(device_t dev) struct usb_attach_arg *uaa = device_get_ivars(dev); struct zyd_softc *sc = device_get_softc(dev); struct ieee80211com *ic = &sc->sc_ic; - uint8_t iface_index, bands; + uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)]; + uint8_t iface_index; int error; if (uaa->info.bcdDevice < 0x4330) { @@ -387,10 +388,10 @@ zyd_attach(device_t dev) | IEEE80211_C_WPA /* 802.11i */ ; - bands = 0; - setbit(&bands, IEEE80211_MODE_11B); - setbit(&bands, IEEE80211_MODE_11G); - ieee80211_init_channels(ic, NULL, &bands); + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); + ieee80211_init_channels(ic, NULL, bands); ieee80211_ifattach(ic); ic->ic_raw_xmit = zyd_raw_xmit; diff --git a/sys/dev/vt/hw/ofwfb/ofwfb.c b/sys/dev/vt/hw/ofwfb/ofwfb.c index acad5d4..c3ac185 100644 --- a/sys/dev/vt/hw/ofwfb/ofwfb.c +++ b/sys/dev/vt/hw/ofwfb/ofwfb.c @@ -57,6 +57,7 @@ struct ofwfb_softc { int iso_palette; }; +static void ofwfb_initialize(struct vt_device *vd); static vd_probe_t ofwfb_probe; static vd_init_t ofwfb_init; static vd_bitblt_text_t ofwfb_bitblt_text; @@ -124,6 +125,18 @@ ofwfb_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw, uint8_t c[4]; } ch1, ch2; +#ifdef __powerpc__ + /* Deal with unmapped framebuffers */ + if (sc->fb_flags & FB_FLAG_NOWRITE) { + if (pmap_bootstrapped) { + sc->fb_flags &= ~FB_FLAG_NOWRITE; + ofwfb_initialize(vd); + } else { + return; + } + } +#endif + fgc = sc->fb_cmap[fg]; bgc = sc->fb_cmap[bg]; b = m = 0; @@ -271,6 +284,11 @@ ofwfb_initialize(struct vt_device *vd) cell_t retval; uint32_t oldpix; + sc->fb.fb_cmsize = 16; + + if (sc->fb.fb_flags & FB_FLAG_NOWRITE) + return; + /* * Set up the color map */ @@ -318,8 +336,6 @@ ofwfb_initialize(struct vt_device *vd) panic("Unknown color space depth %d", sc->fb.fb_bpp); break; } - - sc->fb.fb_cmsize = 16; } static int @@ -466,6 +482,11 @@ ofwfb_init(struct vt_device *vd) #if defined(__powerpc__) OF_decode_addr(node, fb_phys, &sc->sc_memt, &sc->fb.fb_vbase); sc->fb.fb_pbase = sc->fb.fb_vbase; /* 1:1 mapped */ + #ifdef __powerpc64__ + /* Real mode under a hypervisor probably doesn't cover FB */ + if (!(mfmsr() & (PSL_HV | PSL_DR))) + sc->fb.fb_flags |= FB_FLAG_NOWRITE; + #endif #else /* No ability to interpret assigned-addresses otherwise */ return (CN_DEAD); diff --git a/sys/dev/wpi/if_wpi.c b/sys/dev/wpi/if_wpi.c index b59d3e6..824f75b 100644 --- a/sys/dev/wpi/if_wpi.c +++ b/sys/dev/wpi/if_wpi.c @@ -166,10 +166,13 @@ static void wpi_free_tx_ring(struct wpi_softc *, struct wpi_tx_ring *); static int wpi_read_eeprom(struct wpi_softc *, uint8_t macaddr[IEEE80211_ADDR_LEN]); static uint32_t wpi_eeprom_channel_flags(struct wpi_eeprom_chan *); -static void wpi_read_eeprom_band(struct wpi_softc *, uint8_t); +static void wpi_read_eeprom_band(struct wpi_softc *, uint8_t, int, int *, + struct ieee80211_channel[]); static int wpi_read_eeprom_channels(struct wpi_softc *, uint8_t); static struct wpi_eeprom_chan *wpi_find_eeprom_channel(struct wpi_softc *, struct ieee80211_channel *); +static void wpi_getradiocaps(struct ieee80211com *, int, int *, + struct ieee80211_channel[]); static int wpi_setregdomain(struct ieee80211com *, struct ieee80211_regdomain *, int, struct ieee80211_channel[]); @@ -516,6 +519,7 @@ wpi_attach(device_t dev) ic->ic_set_channel = wpi_set_channel; ic->ic_scan_curchan = wpi_scan_curchan; ic->ic_scan_mindwell = wpi_scan_mindwell; + ic->ic_getradiocaps = wpi_getradiocaps; ic->ic_setregdomain = wpi_setregdomain; sc->sc_update_rx_ring = wpi_update_rx_ring; @@ -1417,9 +1421,9 @@ wpi_eeprom_channel_flags(struct wpi_eeprom_chan *channel) } static void -wpi_read_eeprom_band(struct wpi_softc *sc, uint8_t n) +wpi_read_eeprom_band(struct wpi_softc *sc, uint8_t n, int maxchans, + int *nchans, struct ieee80211_channel chans[]) { - struct ieee80211com *ic = &sc->sc_ic; struct wpi_eeprom_chan *channels = sc->eeprom_channels[n]; const struct wpi_chan_band *band = &wpi_bands[n]; struct ieee80211_channel *c; @@ -1434,10 +1438,13 @@ wpi_read_eeprom_band(struct wpi_softc *sc, uint8_t n) continue; } + if (*nchans >= maxchans) + break; + chan = band->chan[i]; nflags = wpi_eeprom_channel_flags(&channels[i]); - c = &ic->ic_channels[ic->ic_nchans++]; + c = &chans[(*nchans)++]; c->ic_ieee = chan; c->ic_maxregpower = channels[i].maxpwr; c->ic_maxpower = 2*c->ic_maxregpower; @@ -1448,7 +1455,11 @@ wpi_read_eeprom_band(struct wpi_softc *sc, uint8_t n) /* G =>'s B is supported */ c->ic_flags = IEEE80211_CHAN_B | nflags; - c = &ic->ic_channels[ic->ic_nchans++]; + + if (*nchans >= maxchans) + break; + + c = &chans[(*nchans)++]; c[0] = c[-1]; c->ic_flags = IEEE80211_CHAN_G | nflags; } else { /* 5GHz band */ @@ -1465,7 +1476,7 @@ wpi_read_eeprom_band(struct wpi_softc *sc, uint8_t n) "adding chan %d (%dMHz) flags=0x%x maxpwr=%d passive=%d," " offset %d\n", chan, c->ic_freq, channels[i].flags, sc->maxpwr[chan], - IEEE80211_IS_CHAN_PASSIVE(c), ic->ic_nchans); + IEEE80211_IS_CHAN_PASSIVE(c), *nchans); } } @@ -1489,7 +1500,8 @@ wpi_read_eeprom_channels(struct wpi_softc *sc, uint8_t n) return error; } - wpi_read_eeprom_band(sc, n); + wpi_read_eeprom_band(sc, n, IEEE80211_CHAN_MAX, &ic->ic_nchans, + ic->ic_channels); ieee80211_sort_channels(ic->ic_channels, ic->ic_nchans); @@ -1511,6 +1523,18 @@ wpi_find_eeprom_channel(struct wpi_softc *sc, struct ieee80211_channel *c) return NULL; } +static void +wpi_getradiocaps(struct ieee80211com *ic, + int maxchans, int *nchans, struct ieee80211_channel chans[]) +{ + struct wpi_softc *sc = ic->ic_softc; + int i; + + /* Parse the list of authorized channels. */ + for (i = 0; i < WPI_CHAN_BANDS_COUNT && *nchans < maxchans; i++) + wpi_read_eeprom_band(sc, i, maxchans, nchans, chans); +} + /* * Enforce flags read from EEPROM. */ diff --git a/sys/dev/xen/blkfront/blkfront.c b/sys/dev/xen/blkfront/blkfront.c index 0a75d79..c193d84 100644 --- a/sys/dev/xen/blkfront/blkfront.c +++ b/sys/dev/xen/blkfront/blkfront.c @@ -170,6 +170,11 @@ xbd_mksegarray(bus_dma_segment_t *segs, int nsegs, int ref; while (sg < last_block_sg) { + KASSERT(segs->ds_addr % (1 << XBD_SECTOR_SHFT) == 0, + ("XEN disk driver I/O must be sector aligned")); + KASSERT(segs->ds_len % (1 << XBD_SECTOR_SHFT) == 0, + ("XEN disk driver I/Os must be a multiple of " + "the sector length")); buffer_ma = segs->ds_addr; fsect = (buffer_ma & PAGE_MASK) >> XBD_SECTOR_SHFT; lsect = fsect + (segs->ds_len >> XBD_SECTOR_SHFT) - 1; diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index eb2f98a..8a6b0c5 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -244,18 +244,18 @@ devfs_populate_vp(struct vnode *vp) if (DEVFS_DMP_DROP(dmp)) { sx_xunlock(&dmp->dm_lock); devfs_unmount_final(dmp); - return (EBADF); + return (ERESTART); } if ((vp->v_iflag & VI_DOOMED) != 0) { sx_xunlock(&dmp->dm_lock); - return (EBADF); + return (ERESTART); } de = vp->v_data; KASSERT(de != NULL, ("devfs_populate_vp: vp->v_data == NULL but vnode not doomed")); if ((de->de_flags & DE_DOOMED) != 0) { sx_xunlock(&dmp->dm_lock); - return (EBADF); + return (ERESTART); } return (0); @@ -1147,7 +1147,7 @@ devfs_open(struct vop_open_args *ap) error = dsw->d_fdopen(dev, ap->a_mode, td, fp); else error = dsw->d_open(dev, ap->a_mode, S_IFCHR, td); - /* cleanup any cdevpriv upon error */ + /* Clean up any cdevpriv upon error. */ if (error != 0) devfs_clear_cdevpriv(); td->td_fpop = fpop; diff --git a/sys/fs/ext2fs/ext2_bmap.c b/sys/fs/ext2fs/ext2_bmap.c index d144e92..8656e59 100644 --- a/sys/fs/ext2fs/ext2_bmap.c +++ b/sys/fs/ext2fs/ext2_bmap.c @@ -96,14 +96,12 @@ ext4_bmapext(struct vnode *vp, int32_t bn, int64_t *bnp, int *runp, int *runb) struct ext4_extent *ep; struct ext4_extent_path path = { .ep_bp = NULL }; daddr_t lbn; + int ret = 0; ip = VTOI(vp); fs = ip->i_e2fs; lbn = bn; - /* - * TODO: need to implement read ahead to improve the performance. - */ if (runp != NULL) *runp = 0; @@ -111,17 +109,33 @@ ext4_bmapext(struct vnode *vp, int32_t bn, int64_t *bnp, int *runp, int *runb) *runb = 0; ext4_ext_find_extent(fs, ip, lbn, &path); - ep = path.ep_ext; - if (ep == NULL) - return (EIO); - - *bnp = fsbtodb(fs, lbn - ep->e_blk + - (ep->e_start_lo | (daddr_t)ep->e_start_hi << 32)); - - if (*bnp == 0) + if (path.ep_is_sparse) { *bnp = -1; + if (runp != NULL) + *runp = path.ep_sparse_ext.e_len - + (lbn - path.ep_sparse_ext.e_blk) - 1; + } else { + ep = path.ep_ext; + if (ep == NULL) + ret = EIO; + else { + *bnp = fsbtodb(fs, lbn - ep->e_blk + + (ep->e_start_lo | (daddr_t)ep->e_start_hi << 32)); + + if (*bnp == 0) + *bnp = -1; + + if (runp != NULL) + *runp = ep->e_len - (lbn - ep->e_blk) - 1; + } + } - return (0); + if (path.ep_bp != NULL) { + brelse(path.ep_bp); + path.ep_bp = NULL; + } + + return (ret); } /* diff --git a/sys/fs/ext2fs/ext2_extents.c b/sys/fs/ext2fs/ext2_extents.c index 68704bb..1317fdc 100644 --- a/sys/fs/ext2fs/ext2_extents.c +++ b/sys/fs/ext2fs/ext2_extents.c @@ -66,13 +66,14 @@ static void ext4_ext_binsearch(struct inode *ip, struct ext4_extent_path *path, daddr_t lbn) { struct ext4_extent_header *ehp = path->ep_header; - struct ext4_extent *l, *r, *m; + struct ext4_extent *first, *l, *r, *m; if (ehp->eh_ecount == 0) return; - l = (struct ext4_extent *)(char *)(ehp + 1); - r = (struct ext4_extent *)(char *)(ehp + 1) + ehp->eh_ecount - 1; + first = (struct ext4_extent *)(char *)(ehp + 1); + l = first; + r = first + ehp->eh_ecount - 1; while (l <= r) { m = l + (r - l) / 2; if (lbn < m->e_blk) @@ -81,7 +82,25 @@ ext4_ext_binsearch(struct inode *ip, struct ext4_extent_path *path, daddr_t lbn) l = m + 1; } + if (l == first) { + path->ep_sparse_ext.e_blk = lbn; + path->ep_sparse_ext.e_len = first->e_blk - lbn; + path->ep_sparse_ext.e_start_hi = 0; + path->ep_sparse_ext.e_start_lo = 0; + path->ep_is_sparse = 1; + return; + } path->ep_ext = l - 1; + if (path->ep_ext->e_blk + path->ep_ext->e_len <= lbn) { + path->ep_sparse_ext.e_blk = lbn; + if (l <= (first + ehp->eh_ecount - 1)) + path->ep_sparse_ext.e_len = l->e_blk - lbn; + else // XXX: where does it end? + path->ep_sparse_ext.e_len = 1; + path->ep_sparse_ext.e_start_hi = 0; + path->ep_sparse_ext.e_start_lo = 0; + path->ep_is_sparse = 1; + } } /* @@ -169,6 +188,7 @@ ext4_ext_find_extent(struct m_ext2fs *fs, struct inode *ip, path->ep_depth = i; path->ep_ext = NULL; path->ep_index = NULL; + path->ep_is_sparse = 0; ext4_ext_binsearch(ip, path, lbn); return (path); diff --git a/sys/fs/ext2fs/ext2_extents.h b/sys/fs/ext2fs/ext2_extents.h index 94ded83..4ce16f3 100644 --- a/sys/fs/ext2fs/ext2_extents.h +++ b/sys/fs/ext2fs/ext2_extents.h @@ -84,7 +84,11 @@ struct ext4_extent_cache { struct ext4_extent_path { uint16_t ep_depth; struct buf *ep_bp; - struct ext4_extent *ep_ext; + int ep_is_sparse; + union { + struct ext4_extent ep_sparse_ext; + struct ext4_extent *ep_ext; + }; struct ext4_extent_index *ep_index; struct ext4_extent_header *ep_header; }; diff --git a/sys/fs/ext2fs/ext2_vfsops.c b/sys/fs/ext2fs/ext2_vfsops.c index ce943ea..5339aa2 100644 --- a/sys/fs/ext2fs/ext2_vfsops.c +++ b/sys/fs/ext2fs/ext2_vfsops.c @@ -590,7 +590,7 @@ ext2_mountfs(struct vnode *devvp, struct mount *mp) * while Linux keeps the super block in a locked buffer. */ ump->um_e2fs = malloc(sizeof(struct m_ext2fs), - M_EXT2MNT, M_WAITOK); + M_EXT2MNT, M_WAITOK | M_ZERO); ump->um_e2fs->e2fs = malloc(sizeof(struct ext2fs), M_EXT2MNT, M_WAITOK); mtx_init(EXT2_MTX(ump), "EXT2FS", "EXT2FS Lock", MTX_DEF); diff --git a/sys/fs/ext2fs/ext2_vnops.c b/sys/fs/ext2fs/ext2_vnops.c index 5b8990ee..bc239b8 100644 --- a/sys/fs/ext2fs/ext2_vnops.c +++ b/sys/fs/ext2fs/ext2_vnops.c @@ -1787,6 +1787,7 @@ ext2_ioctl(struct vop_ioctl_args *ap) static int ext4_ext_read(struct vop_read_args *ap) { + static unsigned char zeroes[EXT2_MAX_BLOCK_SIZE]; struct vnode *vp; struct inode *ip; struct uio *uio; @@ -1831,11 +1832,15 @@ ext4_ext_read(struct vop_read_args *ap) switch (cache_type) { case EXT4_EXT_CACHE_NO: ext4_ext_find_extent(fs, ip, lbn, &path); - ep = path.ep_ext; + if (path.ep_is_sparse) + ep = &path.ep_sparse_ext; + else + ep = path.ep_ext; if (ep == NULL) return (EIO); - ext4_ext_put_cache(ip, ep, EXT4_EXT_CACHE_IN); + ext4_ext_put_cache(ip, ep, + path.ep_is_sparse ? EXT4_EXT_CACHE_GAP : EXT4_EXT_CACHE_IN); newblk = lbn - ep->e_blk + (ep->e_start_lo | (daddr_t)ep->e_start_hi << 32); @@ -1848,7 +1853,7 @@ ext4_ext_read(struct vop_read_args *ap) case EXT4_EXT_CACHE_GAP: /* block has not been allocated yet */ - return (0); + break; case EXT4_EXT_CACHE_IN: newblk = lbn - nex.e_blk + (nex.e_start_lo | @@ -1859,24 +1864,34 @@ ext4_ext_read(struct vop_read_args *ap) panic("%s: invalid cache type", __func__); } - error = bread(ip->i_devvp, fsbtodb(fs, newblk), size, NOCRED, &bp); - if (error) { - brelse(bp); - return (error); - } + if (cache_type == EXT4_EXT_CACHE_GAP || + (cache_type == EXT4_EXT_CACHE_NO && path.ep_is_sparse)) { + if (xfersize > sizeof(zeroes)) + xfersize = sizeof(zeroes); + error = uiomove(zeroes, xfersize, uio); + if (error) + return (error); + } else { + error = bread(ip->i_devvp, fsbtodb(fs, newblk), size, + NOCRED, &bp); + if (error) { + brelse(bp); + return (error); + } - size -= bp->b_resid; - if (size < xfersize) { - if (size == 0) { - bqrelse(bp); - break; + size -= bp->b_resid; + if (size < xfersize) { + if (size == 0) { + bqrelse(bp); + break; + } + xfersize = size; } - xfersize = size; + error = uiomove(bp->b_data + blkoffset, xfersize, uio); + bqrelse(bp); + if (error) + return (error); } - error = uiomove(bp->b_data + blkoffset, (int)xfersize, uio); - bqrelse(bp); - if (error) - return (error); } return (0); diff --git a/sys/fs/smbfs/smbfs_smb.c b/sys/fs/smbfs/smbfs_smb.c index ada84c2..c5b8a68 100644 --- a/sys/fs/smbfs/smbfs_smb.c +++ b/sys/fs/smbfs/smbfs_smb.c @@ -333,18 +333,18 @@ smbfs_smb_flush(struct smbnode *np, struct smb_cred *scred) } int -smbfs_smb_setfsize(struct smbnode *np, int newsize, struct smb_cred *scred) +smbfs_smb_setfsize(struct smbnode *np, int64_t newsize, struct smb_cred *scred) { struct smb_share *ssp = np->n_mount->sm_share; struct smb_rq *rqp; struct mbchain *mbp; int error; - if (!smbfs_smb_seteof(np, (int64_t) newsize, scred)) { + if (!smbfs_smb_seteof(np, newsize, scred)) { np->n_flag |= NFLUSHWIRE; return (0); } - + /* XXX: We should use SMB_COM_WRITE_ANDX to support large offsets */ error = smb_rq_alloc(SSTOCP(ssp), SMB_COM_WRITE, scred, &rqp); if (error) return (error); @@ -352,7 +352,7 @@ smbfs_smb_setfsize(struct smbnode *np, int newsize, struct smb_cred *scred) smb_rq_wstart(rqp); mb_put_mem(mbp, (caddr_t)&np->n_fid, 2, MB_MSYSTEM); mb_put_uint16le(mbp, 0); - mb_put_uint32le(mbp, newsize); + mb_put_uint32le(mbp, (uint32_t)newsize); mb_put_uint16le(mbp, 0); smb_rq_wend(rqp); smb_rq_bstart(rqp); diff --git a/sys/fs/smbfs/smbfs_subr.h b/sys/fs/smbfs/smbfs_subr.h index d22df08..4ee143c 100644 --- a/sys/fs/smbfs/smbfs_subr.h +++ b/sys/fs/smbfs/smbfs_subr.h @@ -128,7 +128,8 @@ int smbfs_smb_lock(struct smbnode *np, int op, caddr_t id, off_t start, off_t end, struct smb_cred *scred); int smbfs_smb_statfs(struct smb_share *ssp, struct statfs *sbp, struct smb_cred *scred); -int smbfs_smb_setfsize(struct smbnode *np, int newsize, struct smb_cred *scred); +int smbfs_smb_setfsize(struct smbnode *np, int64_t newsize, + struct smb_cred *scred); int smbfs_smb_query_info(struct smbnode *np, const char *name, int len, struct smbfattr *fap, struct smb_cred *scred); diff --git a/sys/fs/smbfs/smbfs_vnops.c b/sys/fs/smbfs/smbfs_vnops.c index 8ea1198..c78ceb2 100644 --- a/sys/fs/smbfs/smbfs_vnops.c +++ b/sys/fs/smbfs/smbfs_vnops.c @@ -358,7 +358,8 @@ smbfs_setattr(ap) doclose = 1; } if (error == 0) - error = smbfs_smb_setfsize(np, vap->va_size, scred); + error = smbfs_smb_setfsize(np, + (int64_t)vap->va_size, scred); if (doclose) smbfs_smb_close(ssp, np->n_fid, NULL, scred); if (error) { diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c index 57adc40..a2b4e65 100644 --- a/sys/geom/eli/g_eli.c +++ b/sys/geom/eli/g_eli.c @@ -571,40 +571,6 @@ again: } } -/* - * Here we generate IV. It is unique for every sector. - */ -void -g_eli_crypto_ivgen(struct g_eli_softc *sc, off_t offset, u_char *iv, - size_t size) -{ - uint8_t off[8]; - - if ((sc->sc_flags & G_ELI_FLAG_NATIVE_BYTE_ORDER) != 0) - bcopy(&offset, off, sizeof(off)); - else - le64enc(off, (uint64_t)offset); - - switch (sc->sc_ealgo) { - case CRYPTO_AES_XTS: - bcopy(off, iv, sizeof(off)); - bzero(iv + sizeof(off), size - sizeof(off)); - break; - default: - { - u_char hash[SHA256_DIGEST_LENGTH]; - SHA256_CTX ctx; - - /* Copy precalculated SHA256 context for IV-Key. */ - bcopy(&sc->sc_ivctx, &ctx, sizeof(ctx)); - SHA256_Update(&ctx, off, sizeof(off)); - SHA256_Final(hash, &ctx); - bcopy(hash, iv, MIN(sizeof(hash), size)); - break; - } - } -} - int g_eli_read_metadata(struct g_class *mp, struct g_provider *pp, struct g_eli_metadata *md) @@ -751,44 +717,9 @@ g_eli_create(struct gctl_req *req, struct g_class *mp, struct g_provider *bpp, else gp->access = g_std_access; - sc->sc_version = md->md_version; - sc->sc_inflight = 0; - sc->sc_crypto = G_ELI_CRYPTO_UNKNOWN; - sc->sc_flags = md->md_flags; - /* Backward compatibility. */ - if (md->md_version < G_ELI_VERSION_04) - sc->sc_flags |= G_ELI_FLAG_NATIVE_BYTE_ORDER; - if (md->md_version < G_ELI_VERSION_05) - sc->sc_flags |= G_ELI_FLAG_SINGLE_KEY; - if (md->md_version < G_ELI_VERSION_06 && - (sc->sc_flags & G_ELI_FLAG_AUTH) != 0) { - sc->sc_flags |= G_ELI_FLAG_FIRST_KEY; - } - if (md->md_version < G_ELI_VERSION_07) - sc->sc_flags |= G_ELI_FLAG_ENC_IVKEY; - sc->sc_ealgo = md->md_ealgo; + eli_metadata_softc(sc, md, bpp->sectorsize, bpp->mediasize); sc->sc_nkey = nkey; - if (sc->sc_flags & G_ELI_FLAG_AUTH) { - sc->sc_akeylen = sizeof(sc->sc_akey) * 8; - sc->sc_aalgo = md->md_aalgo; - sc->sc_alen = g_eli_hashlen(sc->sc_aalgo); - - sc->sc_data_per_sector = bpp->sectorsize - sc->sc_alen; - /* - * Some hash functions (like SHA1 and RIPEMD160) generates hash - * which length is not multiple of 128 bits, but we want data - * length to be multiple of 128, so we can encrypt without - * padding. The line below rounds down data length to multiple - * of 128 bits. - */ - sc->sc_data_per_sector -= sc->sc_data_per_sector % 16; - - sc->sc_bytes_per_sector = - (md->md_sectorsize - 1) / sc->sc_data_per_sector + 1; - sc->sc_bytes_per_sector *= bpp->sectorsize; - } - gp->softc = sc; sc->sc_geom = gp; @@ -831,22 +762,10 @@ g_eli_create(struct gctl_req *req, struct g_class *mp, struct g_provider *bpp, goto failed; } - sc->sc_sectorsize = md->md_sectorsize; - sc->sc_mediasize = bpp->mediasize; - if (!(sc->sc_flags & G_ELI_FLAG_ONETIME)) - sc->sc_mediasize -= bpp->sectorsize; - if (!(sc->sc_flags & G_ELI_FLAG_AUTH)) - sc->sc_mediasize -= (sc->sc_mediasize % sc->sc_sectorsize); - else { - sc->sc_mediasize /= sc->sc_bytes_per_sector; - sc->sc_mediasize *= sc->sc_sectorsize; - } - /* * Remember the keys in our softc structure. */ g_eli_mkey_propagate(sc, mkey); - sc->sc_ekeylen = md->md_keylen; LIST_INIT(&sc->sc_workers); diff --git a/sys/geom/eli/g_eli.h b/sys/geom/eli/g_eli.h index e4dbee6..3deb865 100644 --- a/sys/geom/eli/g_eli.h +++ b/sys/geom/eli/g_eli.h @@ -40,8 +40,6 @@ #include <sys/libkern.h> #include <sys/lock.h> #include <sys/mutex.h> -#include <sys/queue.h> -#include <sys/tree.h> #include <geom/geom.h> #else #include <assert.h> @@ -49,6 +47,8 @@ #include <string.h> #include <strings.h> #endif +#include <sys/queue.h> +#include <sys/tree.h> #ifndef _OpenSSL_ #include <sys/md5.h> #endif @@ -132,15 +132,15 @@ /* Switch data encryption key every 2^20 blocks. */ #define G_ELI_KEY_SHIFT 20 +#define G_ELI_CRYPTO_UNKNOWN 0 +#define G_ELI_CRYPTO_HW 1 +#define G_ELI_CRYPTO_SW 2 + #ifdef _KERNEL extern int g_eli_debug; extern u_int g_eli_overwrites; extern u_int g_eli_batch; -#define G_ELI_CRYPTO_UNKNOWN 0 -#define G_ELI_CRYPTO_HW 1 -#define G_ELI_CRYPTO_SW 2 - #define G_ELI_DEBUG(lvl, ...) do { \ if (g_eli_debug >= (lvl)) { \ printf("GEOM_ELI"); \ @@ -173,6 +173,8 @@ struct g_eli_worker { LIST_ENTRY(g_eli_worker) w_next; }; +#endif /* _KERNEL */ + struct g_eli_softc { struct g_geom *sc_geom; u_int sc_version; @@ -200,15 +202,35 @@ struct g_eli_softc { size_t sc_sectorsize; u_int sc_bytes_per_sector; u_int sc_data_per_sector; +#ifndef _KERNEL + int sc_cpubind; +#else /* _KERNEL */ boolean_t sc_cpubind; /* Only for software cryptography. */ struct bio_queue_head sc_queue; struct mtx sc_queue_mtx; LIST_HEAD(, g_eli_worker) sc_workers; +#endif /* _KERNEL */ }; #define sc_name sc_geom->name -#endif /* _KERNEL */ + +#define G_ELI_KEY_MAGIC 0xe11341c + +struct g_eli_key { + /* Key value, must be first in the structure. */ + uint8_t gek_key[G_ELI_DATAKEYLEN]; + /* Magic. */ + int gek_magic; + /* Key number. */ + uint64_t gek_keyno; + /* Reference counter. */ + int gek_count; + /* Keeps keys sorted by most recent use. */ + TAILQ_ENTRY(g_eli_key) gek_next; + /* Keeps keys sorted by number. */ + RB_ENTRY(g_eli_key) gek_link; +}; struct g_eli_metadata { char md_magic[16]; /* Magic value. */ @@ -569,6 +591,60 @@ g_eli_hashlen(u_int algo) return (0); } +static __inline void +eli_metadata_softc(struct g_eli_softc *sc, const struct g_eli_metadata *md, + u_int sectorsize, off_t mediasize) +{ + + sc->sc_version = md->md_version; + sc->sc_inflight = 0; + sc->sc_crypto = G_ELI_CRYPTO_UNKNOWN; + sc->sc_flags = md->md_flags; + /* Backward compatibility. */ + if (md->md_version < G_ELI_VERSION_04) + sc->sc_flags |= G_ELI_FLAG_NATIVE_BYTE_ORDER; + if (md->md_version < G_ELI_VERSION_05) + sc->sc_flags |= G_ELI_FLAG_SINGLE_KEY; + if (md->md_version < G_ELI_VERSION_06 && + (sc->sc_flags & G_ELI_FLAG_AUTH) != 0) { + sc->sc_flags |= G_ELI_FLAG_FIRST_KEY; + } + if (md->md_version < G_ELI_VERSION_07) + sc->sc_flags |= G_ELI_FLAG_ENC_IVKEY; + sc->sc_ealgo = md->md_ealgo; + + if (sc->sc_flags & G_ELI_FLAG_AUTH) { + sc->sc_akeylen = sizeof(sc->sc_akey) * 8; + sc->sc_aalgo = md->md_aalgo; + sc->sc_alen = g_eli_hashlen(sc->sc_aalgo); + + sc->sc_data_per_sector = sectorsize - sc->sc_alen; + /* + * Some hash functions (like SHA1 and RIPEMD160) generates hash + * which length is not multiple of 128 bits, but we want data + * length to be multiple of 128, so we can encrypt without + * padding. The line below rounds down data length to multiple + * of 128 bits. + */ + sc->sc_data_per_sector -= sc->sc_data_per_sector % 16; + + sc->sc_bytes_per_sector = + (md->md_sectorsize - 1) / sc->sc_data_per_sector + 1; + sc->sc_bytes_per_sector *= sectorsize; + } + sc->sc_sectorsize = md->md_sectorsize; + sc->sc_mediasize = mediasize; + if (!(sc->sc_flags & G_ELI_FLAG_ONETIME)) + sc->sc_mediasize -= sectorsize; + if (!(sc->sc_flags & G_ELI_FLAG_AUTH)) + sc->sc_mediasize -= (sc->sc_mediasize % sc->sc_sectorsize); + else { + sc->sc_mediasize /= sc->sc_bytes_per_sector; + sc->sc_mediasize *= sc->sc_sectorsize; + } + sc->sc_ekeylen = md->md_keylen; +} + #ifdef _KERNEL int g_eli_read_metadata(struct g_class *mp, struct g_provider *pp, struct g_eli_metadata *md); @@ -583,8 +659,6 @@ void g_eli_config(struct gctl_req *req, struct g_class *mp, const char *verb); void g_eli_read_done(struct bio *bp); void g_eli_write_done(struct bio *bp); int g_eli_crypto_rerun(struct cryptop *crp); -void g_eli_crypto_ivgen(struct g_eli_softc *sc, off_t offset, u_char *iv, - size_t size); void g_eli_crypto_read(struct g_eli_softc *sc, struct bio *bp, boolean_t fromworker); void g_eli_crypto_run(struct g_eli_worker *wr, struct bio *bp); @@ -592,6 +666,8 @@ void g_eli_crypto_run(struct g_eli_worker *wr, struct bio *bp); void g_eli_auth_read(struct g_eli_softc *sc, struct bio *bp); void g_eli_auth_run(struct g_eli_worker *wr, struct bio *bp); #endif +void g_eli_crypto_ivgen(struct g_eli_softc *sc, off_t offset, u_char *iv, + size_t size); void g_eli_mkey_hmac(unsigned char *mkey, const unsigned char *key); int g_eli_mkey_decrypt(const struct g_eli_metadata *md, @@ -620,6 +696,8 @@ void g_eli_crypto_hmac_final(struct hmac_ctx *ctx, uint8_t *md, size_t mdsize); void g_eli_crypto_hmac(const uint8_t *hkey, size_t hkeysize, const uint8_t *data, size_t datasize, uint8_t *md, size_t mdsize); +void g_eli_key_fill(struct g_eli_softc *sc, struct g_eli_key *key, + uint64_t keyno); #ifdef _KERNEL void g_eli_key_init(struct g_eli_softc *sc); void g_eli_key_destroy(struct g_eli_softc *sc); diff --git a/sys/geom/eli/g_eli_crypto.c b/sys/geom/eli/g_eli_crypto.c index 43eabf4..2d145fd 100644 --- a/sys/geom/eli/g_eli_crypto.c +++ b/sys/geom/eli/g_eli_crypto.c @@ -221,75 +221,3 @@ g_eli_crypto_decrypt(u_int algo, u_char *data, size_t datasize, return (g_eli_crypto_cipher(algo, 0, data, datasize, key, keysize)); } - -void -g_eli_crypto_hmac_init(struct hmac_ctx *ctx, const uint8_t *hkey, - size_t hkeylen) -{ - u_char k_ipad[128], key[128]; - SHA512_CTX lctx; - u_int i; - - bzero(key, sizeof(key)); - if (hkeylen == 0) - ; /* do nothing */ - else if (hkeylen <= 128) - bcopy(hkey, key, hkeylen); - else { - /* If key is longer than 128 bytes reset it to key = SHA512(key). */ - SHA512_Init(&lctx); - SHA512_Update(&lctx, hkey, hkeylen); - SHA512_Final(key, &lctx); - } - - /* XOR key with ipad and opad values. */ - for (i = 0; i < sizeof(key); i++) { - k_ipad[i] = key[i] ^ 0x36; - ctx->k_opad[i] = key[i] ^ 0x5c; - } - bzero(key, sizeof(key)); - /* Perform inner SHA512. */ - SHA512_Init(&ctx->shactx); - SHA512_Update(&ctx->shactx, k_ipad, sizeof(k_ipad)); - bzero(k_ipad, sizeof(k_ipad)); -} - -void -g_eli_crypto_hmac_update(struct hmac_ctx *ctx, const uint8_t *data, - size_t datasize) -{ - - SHA512_Update(&ctx->shactx, data, datasize); -} - -void -g_eli_crypto_hmac_final(struct hmac_ctx *ctx, uint8_t *md, size_t mdsize) -{ - u_char digest[SHA512_MDLEN]; - SHA512_CTX lctx; - - SHA512_Final(digest, &ctx->shactx); - /* Perform outer SHA512. */ - SHA512_Init(&lctx); - SHA512_Update(&lctx, ctx->k_opad, sizeof(ctx->k_opad)); - bzero(ctx, sizeof(*ctx)); - SHA512_Update(&lctx, digest, sizeof(digest)); - SHA512_Final(digest, &lctx); - bzero(&lctx, sizeof(lctx)); - /* mdsize == 0 means "Give me the whole hash!" */ - if (mdsize == 0) - mdsize = SHA512_MDLEN; - bcopy(digest, md, mdsize); - bzero(digest, sizeof(digest)); -} - -void -g_eli_crypto_hmac(const uint8_t *hkey, size_t hkeysize, const uint8_t *data, - size_t datasize, uint8_t *md, size_t mdsize) -{ - struct hmac_ctx ctx; - - g_eli_crypto_hmac_init(&ctx, hkey, hkeysize); - g_eli_crypto_hmac_update(&ctx, data, datasize); - g_eli_crypto_hmac_final(&ctx, md, mdsize); -} diff --git a/sys/geom/eli/g_eli_hmac.c b/sys/geom/eli/g_eli_hmac.c new file mode 100644 index 0000000..36b76de --- /dev/null +++ b/sys/geom/eli/g_eli_hmac.c @@ -0,0 +1,150 @@ +/*- + * Copyright (c) 2005-2010 Pawel Jakub Dawidek <pjd@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#ifdef _KERNEL +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/malloc.h> +#else +#include <stdint.h> +#include <string.h> +#include <strings.h> +#include <errno.h> +#include <assert.h> +#include <openssl/evp.h> +#define _OpenSSL_ +#endif +#include <geom/eli/g_eli.h> + +void +g_eli_crypto_hmac_init(struct hmac_ctx *ctx, const uint8_t *hkey, + size_t hkeylen) +{ + u_char k_ipad[128], key[128]; + SHA512_CTX lctx; + u_int i; + + bzero(key, sizeof(key)); + if (hkeylen == 0) + ; /* do nothing */ + else if (hkeylen <= 128) + bcopy(hkey, key, hkeylen); + else { + /* If key is longer than 128 bytes reset it to key = SHA512(key). */ + SHA512_Init(&lctx); + SHA512_Update(&lctx, hkey, hkeylen); + SHA512_Final(key, &lctx); + } + + /* XOR key with ipad and opad values. */ + for (i = 0; i < sizeof(key); i++) { + k_ipad[i] = key[i] ^ 0x36; + ctx->k_opad[i] = key[i] ^ 0x5c; + } + bzero(key, sizeof(key)); + /* Perform inner SHA512. */ + SHA512_Init(&ctx->shactx); + SHA512_Update(&ctx->shactx, k_ipad, sizeof(k_ipad)); + bzero(k_ipad, sizeof(k_ipad)); +} + +void +g_eli_crypto_hmac_update(struct hmac_ctx *ctx, const uint8_t *data, + size_t datasize) +{ + + SHA512_Update(&ctx->shactx, data, datasize); +} + +void +g_eli_crypto_hmac_final(struct hmac_ctx *ctx, uint8_t *md, size_t mdsize) +{ + u_char digest[SHA512_MDLEN]; + SHA512_CTX lctx; + + SHA512_Final(digest, &ctx->shactx); + /* Perform outer SHA512. */ + SHA512_Init(&lctx); + SHA512_Update(&lctx, ctx->k_opad, sizeof(ctx->k_opad)); + bzero(ctx, sizeof(*ctx)); + SHA512_Update(&lctx, digest, sizeof(digest)); + SHA512_Final(digest, &lctx); + bzero(&lctx, sizeof(lctx)); + /* mdsize == 0 means "Give me the whole hash!" */ + if (mdsize == 0) + mdsize = SHA512_MDLEN; + bcopy(digest, md, mdsize); + bzero(digest, sizeof(digest)); +} + +void +g_eli_crypto_hmac(const uint8_t *hkey, size_t hkeysize, const uint8_t *data, + size_t datasize, uint8_t *md, size_t mdsize) +{ + struct hmac_ctx ctx; + + g_eli_crypto_hmac_init(&ctx, hkey, hkeysize); + g_eli_crypto_hmac_update(&ctx, data, datasize); + g_eli_crypto_hmac_final(&ctx, md, mdsize); +} + +/* + * Here we generate IV. It is unique for every sector. + */ +void +g_eli_crypto_ivgen(struct g_eli_softc *sc, off_t offset, u_char *iv, + size_t size) +{ + uint8_t off[8]; + + if ((sc->sc_flags & G_ELI_FLAG_NATIVE_BYTE_ORDER) != 0) + bcopy(&offset, off, sizeof(off)); + else + le64enc(off, (uint64_t)offset); + + switch (sc->sc_ealgo) { + case CRYPTO_AES_XTS: + bcopy(off, iv, sizeof(off)); + bzero(iv + sizeof(off), size - sizeof(off)); + break; + default: + { + u_char hash[SHA256_DIGEST_LENGTH]; + SHA256_CTX ctx; + + /* Copy precalculated SHA256 context for IV-Key. */ + bcopy(&sc->sc_ivctx, &ctx, sizeof(ctx)); + SHA256_Update(&ctx, off, sizeof(off)); + SHA256_Final(hash, &ctx); + bcopy(hash, iv, MIN(sizeof(hash), size)); + break; + } + } +} diff --git a/sys/geom/eli/g_eli_key_cache.c b/sys/geom/eli/g_eli_key_cache.c index cb86716..0b909be 100644 --- a/sys/geom/eli/g_eli_key_cache.c +++ b/sys/geom/eli/g_eli_key_cache.c @@ -28,17 +28,20 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> +#ifdef _KERNEL #include <sys/kernel.h> #include <sys/malloc.h> -#include <sys/queue.h> #include <sys/sysctl.h> #include <sys/systm.h> +#endif /* _KERNEL */ +#include <sys/queue.h> #include <sys/tree.h> #include <geom/geom.h> #include <geom/eli/g_eli.h> +#ifdef _KERNEL MALLOC_DECLARE(M_ELI); SYSCTL_DECL(_kern_geom_eli); @@ -56,22 +59,7 @@ static uint64_t g_eli_key_cache_misses; SYSCTL_UQUAD(_kern_geom_eli, OID_AUTO, key_cache_misses, CTLFLAG_RW, &g_eli_key_cache_misses, 0, "Key cache misses"); -#define G_ELI_KEY_MAGIC 0xe11341c - -struct g_eli_key { - /* Key value, must be first in the structure. */ - uint8_t gek_key[G_ELI_DATAKEYLEN]; - /* Magic. */ - int gek_magic; - /* Key number. */ - uint64_t gek_keyno; - /* Reference counter. */ - int gek_count; - /* Keeps keys sorted by most recent use. */ - TAILQ_ENTRY(g_eli_key) gek_next; - /* Keeps keys sorted by number. */ - RB_ENTRY(g_eli_key) gek_link; -}; +#endif /* _KERNEL */ static int g_eli_key_cmp(const struct g_eli_key *a, const struct g_eli_key *b) @@ -84,10 +72,7 @@ g_eli_key_cmp(const struct g_eli_key *a, const struct g_eli_key *b) return (0); } -RB_PROTOTYPE(g_eli_key_tree, g_eli_key, gek_link, g_eli_key_cmp); -RB_GENERATE(g_eli_key_tree, g_eli_key, gek_link, g_eli_key_cmp); - -static void +void g_eli_key_fill(struct g_eli_softc *sc, struct g_eli_key *key, uint64_t keyno) { const uint8_t *ekey; @@ -110,6 +95,10 @@ g_eli_key_fill(struct g_eli_softc *sc, struct g_eli_key *key, uint64_t keyno) key->gek_magic = G_ELI_KEY_MAGIC; } +#ifdef _KERNEL +RB_PROTOTYPE(g_eli_key_tree, g_eli_key, gek_link, g_eli_key_cmp); +RB_GENERATE(g_eli_key_tree, g_eli_key, gek_link, g_eli_key_cmp); + static struct g_eli_key * g_eli_key_allocate(struct g_eli_softc *sc, uint64_t keyno) { @@ -350,3 +339,4 @@ g_eli_key_drop(struct g_eli_softc *sc, uint8_t *rawkey) } mtx_unlock(&sc->sc_ekeys_lock); } +#endif /* _KERNEL */ diff --git a/sys/geom/eli/pkcs5v2.c b/sys/geom/eli/pkcs5v2.c index 05677c1..6992801 100644 --- a/sys/geom/eli/pkcs5v2.c +++ b/sys/geom/eli/pkcs5v2.c @@ -83,6 +83,7 @@ pkcs5v2_genkey(uint8_t *key, unsigned keylen, const uint8_t *salt, } #ifndef _KERNEL +#ifndef _STAND /* * Return the number of microseconds needed for 'interations' iterations. */ @@ -120,4 +121,5 @@ pkcs5v2_calculate(int usecs) } return (((intmax_t)iterations * (intmax_t)usecs) / v); } +#endif /* !_STAND */ #endif /* !_KERNEL */ diff --git a/sys/i386/i386/elf_machdep.c b/sys/i386/i386/elf_machdep.c index b11cb03..3c76ab2 100644 --- a/sys/i386/i386/elf_machdep.c +++ b/sys/i386/i386/elf_machdep.c @@ -87,6 +87,7 @@ struct sysentvec elf32_freebsd_sysvec = { .sv_shared_page_len = PAGE_SIZE, .sv_schedtail = NULL, .sv_thread_detach = NULL, + .sv_trap = NULL, }; INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec); diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 894244c..67f6ee0 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -2462,10 +2462,11 @@ init386(first) } else { metadata_missing = 1; } - if (envmode == 1) - kern_envp = static_env; - else if (bootinfo.bi_envp) - kern_envp = (caddr_t)bootinfo.bi_envp + KERNBASE; + + if (bootinfo.bi_envp) + init_static_kenv((caddr_t)bootinfo.bi_envp + KERNBASE, 0); + else + init_static_kenv(NULL, 0); /* Init basic tunables, hz etc */ init_param1(); diff --git a/sys/i386/ibcs2/ibcs2_sysvec.c b/sys/i386/ibcs2/ibcs2_sysvec.c index 16507ee..372e5ea 100644 --- a/sys/i386/ibcs2/ibcs2_sysvec.c +++ b/sys/i386/ibcs2/ibcs2_sysvec.c @@ -90,6 +90,7 @@ struct sysentvec ibcs2_svr3_sysvec = { .sv_syscallnames = NULL, .sv_schedtail = NULL, .sv_thread_detach = NULL, + .sv_trap = NULL, }; static int diff --git a/sys/i386/include/metadata.h b/sys/i386/include/metadata.h index 9003c15..98d0272 100644 --- a/sys/i386/include/metadata.h +++ b/sys/i386/include/metadata.h @@ -1,37 +1,6 @@ /*- - * Copyright (c) 2003 Peter Wemm <peter@FreeBSD.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ + * This file is in the public domain. */ +/* $FreeBSD$ */ -#ifndef _MACHINE_METADATA_H_ -#define _MACHINE_METADATA_H_ - -#define MODINFOMD_SMAP 0x1001 -#define MODINFOMD_SMAP_XATTR 0x1002 -#define MODINFOMD_DTBP 0x1003 -#define MODINFOMD_MODULEP 0x1006 - -#endif /* !_MACHINE_METADATA_H_ */ +#include <x86/metadata.h> diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index 2a8b7d2..cc5fcaa 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -985,6 +985,7 @@ struct sysentvec linux_sysvec = { .sv_shared_page_len = PAGE_SIZE, .sv_schedtail = linux_schedtail, .sv_thread_detach = linux_thread_detach, + .sv_trap = NULL, }; INIT_SYSENTVEC(aout_sysvec, &linux_sysvec); @@ -1021,6 +1022,7 @@ struct sysentvec elf_linux_sysvec = { .sv_shared_page_len = PAGE_SIZE, .sv_schedtail = linux_schedtail, .sv_thread_detach = linux_thread_detach, + .sv_trap = NULL, }; static void diff --git a/sys/kern/imgact_aout.c b/sys/kern/imgact_aout.c index a7db17e..cbde46b 100644 --- a/sys/kern/imgact_aout.c +++ b/sys/kern/imgact_aout.c @@ -97,6 +97,7 @@ struct sysentvec aout_sysvec = { .sv_syscallnames = syscallnames, .sv_schedtail = NULL, .sv_thread_detach = NULL, + .sv_trap = NULL, }; #elif defined(__amd64__) diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index f0cd3c8..8d5580b 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -414,6 +414,7 @@ struct sysentvec null_sysvec = { .sv_syscallnames = NULL, .sv_schedtail = NULL, .sv_thread_detach = NULL, + .sv_trap = NULL, }; /* diff --git a/sys/kern/kern_condvar.c b/sys/kern/kern_condvar.c index 2700a25..95a6d09 100644 --- a/sys/kern/kern_condvar.c +++ b/sys/kern/kern_condvar.c @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/systm.h> +#include <sys/limits.h> #include <sys/lock.h> #include <sys/mutex.h> #include <sys/proc.h> @@ -47,6 +48,17 @@ __FBSDID("$FreeBSD$"); #endif /* + * A bound below which cv_waiters is valid. Once cv_waiters reaches this bound, + * cv_signal must manually check the wait queue for threads. + */ +#define CV_WAITERS_BOUND INT_MAX + +#define CV_WAITERS_INC(cvp) do { \ + if ((cvp)->cv_waiters < CV_WAITERS_BOUND) \ + (cvp)->cv_waiters++; \ +} while (0) + +/* * Common sanity checks for cv_wait* functions. */ #define CV_ASSERT(cvp, lock, td) do { \ @@ -122,7 +134,7 @@ _cv_wait(struct cv *cvp, struct lock_object *lock) sleepq_lock(cvp); - cvp->cv_waiters++; + CV_WAITERS_INC(cvp); if (lock == &Giant.lock_object) mtx_assert(&Giant, MA_OWNED); DROP_GIANT(); @@ -184,7 +196,7 @@ _cv_wait_unlock(struct cv *cvp, struct lock_object *lock) sleepq_lock(cvp); - cvp->cv_waiters++; + CV_WAITERS_INC(cvp); DROP_GIANT(); sleepq_add(cvp, lock, cvp->cv_description, SLEEPQ_CONDVAR, 0); @@ -240,7 +252,7 @@ _cv_wait_sig(struct cv *cvp, struct lock_object *lock) sleepq_lock(cvp); - cvp->cv_waiters++; + CV_WAITERS_INC(cvp); if (lock == &Giant.lock_object) mtx_assert(&Giant, MA_OWNED); DROP_GIANT(); @@ -307,7 +319,7 @@ _cv_timedwait_sbt(struct cv *cvp, struct lock_object *lock, sbintime_t sbt, sleepq_lock(cvp); - cvp->cv_waiters++; + CV_WAITERS_INC(cvp); if (lock == &Giant.lock_object) mtx_assert(&Giant, MA_OWNED); DROP_GIANT(); @@ -376,7 +388,7 @@ _cv_timedwait_sig_sbt(struct cv *cvp, struct lock_object *lock, sleepq_lock(cvp); - cvp->cv_waiters++; + CV_WAITERS_INC(cvp); if (lock == &Giant.lock_object) mtx_assert(&Giant, MA_OWNED); DROP_GIANT(); @@ -422,8 +434,15 @@ cv_signal(struct cv *cvp) wakeup_swapper = 0; sleepq_lock(cvp); if (cvp->cv_waiters > 0) { - cvp->cv_waiters--; - wakeup_swapper = sleepq_signal(cvp, SLEEPQ_CONDVAR, 0, 0); + if (cvp->cv_waiters == CV_WAITERS_BOUND && + sleepq_lookup(cvp) == NULL) { + cvp->cv_waiters = 0; + } else { + if (cvp->cv_waiters < CV_WAITERS_BOUND) + cvp->cv_waiters--; + wakeup_swapper = sleepq_signal(cvp, SLEEPQ_CONDVAR, 0, + 0); + } } sleepq_release(cvp); if (wakeup_swapper) diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 2056542..ea68a6d 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -566,22 +566,26 @@ notify_destroy(struct cdev *dev) } static struct cdev * -newdev(struct cdevsw *csw, int unit, struct cdev *si) +newdev(struct make_dev_args *args, struct cdev *si) { struct cdev *si2; + struct cdevsw *csw; mtx_assert(&devmtx, MA_OWNED); + csw = args->mda_devsw; if (csw->d_flags & D_NEEDMINOR) { /* We may want to return an existing device */ LIST_FOREACH(si2, &csw->d_devs, si_list) { - if (dev2unit(si2) == unit) { + if (dev2unit(si2) == args->mda_unit) { dev_free_devlocked(si); return (si2); } } } - si->si_drv0 = unit; + si->si_drv0 = args->mda_unit; si->si_devsw = csw; + si->si_drv1 = args->mda_si_drv1; + si->si_drv2 = args->mda_si_drv2; LIST_INSERT_HEAD(&csw->d_devs, si, si_list); return (si); } @@ -737,33 +741,46 @@ prep_devname(struct cdev *dev, const char *fmt, va_list ap) return (0); } +void +make_dev_args_init_impl(struct make_dev_args *args, size_t sz) +{ + + bzero(args, sz); + args->mda_size = sz; +} + static int -make_dev_credv(int flags, struct cdev **dres, struct cdevsw *devsw, int unit, - struct ucred *cr, uid_t uid, gid_t gid, int mode, const char *fmt, - va_list ap) +make_dev_sv(struct make_dev_args *args1, struct cdev **dres, + const char *fmt, va_list ap) { struct cdev *dev, *dev_new; + struct make_dev_args args; int res; - KASSERT((flags & MAKEDEV_WAITOK) == 0 || (flags & MAKEDEV_NOWAIT) == 0, - ("make_dev_credv: both WAITOK and NOWAIT specified")); - dev_new = devfs_alloc(flags); + bzero(&args, sizeof(args)); + if (sizeof(args) < args1->mda_size) + return (EINVAL); + bcopy(args1, &args, args1->mda_size); + KASSERT((args.mda_flags & MAKEDEV_WAITOK) == 0 || + (args.mda_flags & MAKEDEV_NOWAIT) == 0, + ("make_dev_sv: both WAITOK and NOWAIT specified")); + dev_new = devfs_alloc(args.mda_flags); if (dev_new == NULL) return (ENOMEM); dev_lock(); - res = prep_cdevsw(devsw, flags); + res = prep_cdevsw(args.mda_devsw, args.mda_flags); if (res != 0) { dev_unlock(); devfs_free(dev_new); return (res); } - dev = newdev(devsw, unit, dev_new); + dev = newdev(&args, dev_new); if ((dev->si_flags & SI_NAMED) == 0) { res = prep_devname(dev, fmt, ap); if (res != 0) { - if ((flags & MAKEDEV_CHECKNAME) == 0) { + if ((args.mda_flags & MAKEDEV_CHECKNAME) == 0) { panic( - "make_dev_credv: bad si_name (error=%d, si_name=%s)", + "make_dev_sv: bad si_name (error=%d, si_name=%s)", res, dev->si_name); } if (dev == dev_new) { @@ -775,9 +792,9 @@ make_dev_credv(int flags, struct cdev **dres, struct cdevsw *devsw, int unit, return (res); } } - if (flags & MAKEDEV_REF) + if ((args.mda_flags & MAKEDEV_REF) != 0) dev_refl(dev); - if (flags & MAKEDEV_ETERNAL) + if ((args.mda_flags & MAKEDEV_ETERNAL) != 0) dev->si_flags |= SI_ETERNAL; if (dev->si_flags & SI_CHEAPCLONE && dev->si_flags & SI_NAMED) { @@ -792,24 +809,55 @@ make_dev_credv(int flags, struct cdev **dres, struct cdevsw *devsw, int unit, } KASSERT(!(dev->si_flags & SI_NAMED), ("make_dev() by driver %s on pre-existing device (min=%x, name=%s)", - devsw->d_name, dev2unit(dev), devtoname(dev))); + args.mda_devsw->d_name, dev2unit(dev), devtoname(dev))); dev->si_flags |= SI_NAMED; - if (cr != NULL) - dev->si_cred = crhold(cr); - dev->si_uid = uid; - dev->si_gid = gid; - dev->si_mode = mode; + if (args.mda_cr != NULL) + dev->si_cred = crhold(args.mda_cr); + dev->si_uid = args.mda_uid; + dev->si_gid = args.mda_gid; + dev->si_mode = args.mda_mode; devfs_create(dev); clean_unrhdrl(devfs_inos); dev_unlock_and_free(); - notify_create(dev, flags); + notify_create(dev, args.mda_flags); *dres = dev; return (0); } +int +make_dev_s(struct make_dev_args *args, struct cdev **dres, + const char *fmt, ...) +{ + va_list ap; + int res; + + va_start(ap, fmt); + res = make_dev_sv(args, dres, fmt, ap); + va_end(ap); + return (res); +} + +static int +make_dev_credv(int flags, struct cdev **dres, struct cdevsw *devsw, int unit, + struct ucred *cr, uid_t uid, gid_t gid, int mode, const char *fmt, + va_list ap) +{ + struct make_dev_args args; + + make_dev_args_init(&args); + args.mda_flags = flags; + args.mda_devsw = devsw; + args.mda_cr = cr; + args.mda_uid = uid; + args.mda_gid = gid; + args.mda_mode = mode; + args.mda_unit = unit; + return (make_dev_sv(&args, dres, fmt, ap)); +} + struct cdev * make_dev(struct cdevsw *devsw, int unit, uid_t uid, gid_t gid, int mode, const char *fmt, ...) @@ -1247,6 +1295,7 @@ clone_create(struct clonedevs **cdp, struct cdevsw *csw, int *up, { struct clonedevs *cd; struct cdev *dev, *ndev, *dl, *de; + struct make_dev_args args; int unit, low, u; KASSERT(*cdp != NULL, @@ -1298,7 +1347,10 @@ clone_create(struct clonedevs **cdp, struct cdevsw *csw, int *up, } if (unit == -1) unit = low & CLONE_UNITMASK; - dev = newdev(csw, unit | extra, ndev); + make_dev_args_init(&args); + args.mda_unit = unit | extra; + args.mda_devsw = csw; + dev = newdev(&args, ndev); if (dev->si_flags & SI_CLONELIST) { printf("dev %p (%s) is on clonelist\n", dev, dev->si_name); printf("unit=%d, low=%d, extra=0x%x\n", unit, low, extra); diff --git a/sys/kern/kern_environment.c b/sys/kern/kern_environment.c index 03c7226..cd6930b 100644 --- a/sys/kern/kern_environment.c +++ b/sys/kern/kern_environment.c @@ -210,12 +210,44 @@ done: return (error); } +/* + * Populate the initial kernel environment. + * + * This is called very early in MD startup, either to provide a copy of the + * environment obtained from a boot loader, or to provide an empty buffer into + * which MD code can store an initial environment using kern_setenv() calls. + * + * If the global envmode is 1, the environment is initialized from the global + * static_env[], regardless of the arguments passed. This implements the env + * keyword described in config(5). In this case env_pos is set to env_len, + * causing kern_setenv() to return -1 (if len > 0) or panic (if len == 0) until + * the dynamic environment is available. The envmode and static_env variables + * are defined in env.c which is generated by config(8). + * + * If len is non-zero, the caller is providing an empty buffer. The caller will + * subsequently use kern_setenv() to add up to len bytes of initial environment + * before the dynamic environment is available. + * + * If len is zero, the caller is providing a pre-loaded buffer containing + * environment strings. Additional strings cannot be added until the dynamic + * environment is available. The memory pointed to must remain stable at least + * until sysinit runs init_dynamic_kenv(). If no initial environment is + * available from the boot loader, passing a NULL pointer allows the static_env + * to be installed if it is configured. + */ void init_static_kenv(char *buf, size_t len) { - kern_envp = buf; - env_len = len; - env_pos = 0; + + if (envmode == 1) { + kern_envp = static_env; + env_len = len; + env_pos = len; + } else { + kern_envp = buf; + env_len = len; + env_pos = 0; + } } /* diff --git a/sys/kern/subr_bus_dma.c b/sys/kern/subr_bus_dma.c index ae30276..cdf176b 100644 --- a/sys/kern/subr_bus_dma.c +++ b/sys/kern/subr_bus_dma.c @@ -131,28 +131,6 @@ _bus_dmamap_load_mbuf_sg(bus_dma_tag_t dmat, bus_dmamap_t map, } /* - * Load tlen data starting at offset within a region specified by a list of - * physical pages. - */ -static int -_bus_dmamap_load_pages(bus_dma_tag_t dmat, bus_dmamap_t map, - vm_page_t *pages, bus_size_t tlen, int offset, int *nsegs, int flags) -{ - vm_paddr_t paddr; - bus_size_t len; - int error, i; - - for (i = 0, error = 0; error == 0 && tlen > 0; i++, tlen -= len) { - len = min(PAGE_SIZE - offset, tlen); - paddr = VM_PAGE_TO_PHYS(pages[i]) + offset; - error = _bus_dmamap_load_phys(dmat, map, paddr, len, - flags, NULL, nsegs); - offset = 0; - } - return (error); -} - -/* * Load from block io. */ static int @@ -168,8 +146,8 @@ _bus_dmamap_load_bio(bus_dma_tag_t dmat, bus_dmamap_t map, struct bio *bio, } if ((bio->bio_flags & BIO_UNMAPPED) != 0) - return (_bus_dmamap_load_pages(dmat, map, bio->bio_ma, - bio->bio_bcount, bio->bio_ma_offset, nsegs, flags)); + return (_bus_dmamap_load_ma(dmat, map, bio->bio_ma, + bio->bio_bcount, bio->bio_ma_offset, flags, NULL, nsegs)); return (_bus_dmamap_load_buffer(dmat, map, bio->bio_data, bio->bio_bcount, kernel_pmap, flags, NULL, nsegs)); diff --git a/sys/kern/tty.c b/sys/kern/tty.c index d9d0cce..9695312 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -237,14 +237,10 @@ static int ttydev_open(struct cdev *dev, int oflags, int devtype, struct thread *td) { struct tty *tp; - int error = 0; - - while ((tp = dev->si_drv1) == NULL) { - error = tsleep(&dev->si_drv1, PCATCH, "ttdrv1", 1); - if (error != EWOULDBLOCK) - return (error); - } + int error; + tp = dev->si_drv1; + error = 0; tty_lock(tp); if (tty_gone(tp)) { /* Device is already gone. */ @@ -755,13 +751,10 @@ static int ttyil_open(struct cdev *dev, int oflags, int devtype, struct thread *td) { struct tty *tp; - int error = 0; + int error; - while ((tp = dev->si_drv1) == NULL) { - error = tsleep(&dev->si_drv1, PCATCH, "ttdrv1", 1); - if (error != EWOULDBLOCK) - return (error); - } + tp = dev->si_drv1; + error = 0; tty_lock(tp); if (tty_gone(tp)) error = ENODEV; @@ -1189,6 +1182,7 @@ tty_makedevf(struct tty *tp, struct ucred *cred, int flags, const char *fmt, ...) { va_list ap; + struct make_dev_args args; struct cdev *dev, *init, *lock, *cua, *cinit, *clock; const char *prefix = "tty"; char name[SPECNAMELEN - 3]; /* for "tty" and "cua". */ @@ -1221,71 +1215,72 @@ tty_makedevf(struct tty *tp, struct ucred *cred, int flags, flags |= MAKEDEV_CHECKNAME; /* Master call-in device. */ - error = make_dev_p(flags, &dev, &ttydev_cdevsw, cred, uid, gid, mode, - "%s%s", prefix, name); - if (error) + make_dev_args_init(&args); + args.mda_flags = flags; + args.mda_devsw = &ttydev_cdevsw; + args.mda_cr = cred; + args.mda_uid = uid; + args.mda_gid = gid; + args.mda_mode = mode; + args.mda_si_drv1 = tp; + error = make_dev_s(&args, &dev, "%s%s", prefix, name); + if (error != 0) return (error); - dev->si_drv1 = tp; - wakeup(&dev->si_drv1); tp->t_dev = dev; init = lock = cua = cinit = clock = NULL; /* Slave call-in devices. */ if (tp->t_flags & TF_INITLOCK) { - error = make_dev_p(flags, &init, &ttyil_cdevsw, cred, uid, - gid, mode, "%s%s.init", prefix, name); - if (error) + args.mda_devsw = &ttyil_cdevsw; + args.mda_unit = TTYUNIT_INIT; + args.mda_si_drv1 = tp; + args.mda_si_drv2 = &tp->t_termios_init_in; + error = make_dev_s(&args, &init, "%s%s.init", prefix, name); + if (error != 0) goto fail; dev_depends(dev, init); - dev2unit(init) = TTYUNIT_INIT; - init->si_drv1 = tp; - wakeup(&init->si_drv1); - init->si_drv2 = &tp->t_termios_init_in; - error = make_dev_p(flags, &lock, &ttyil_cdevsw, cred, uid, - gid, mode, "%s%s.lock", prefix, name); - if (error) + args.mda_unit = TTYUNIT_LOCK; + args.mda_si_drv2 = &tp->t_termios_lock_in; + error = make_dev_s(&args, &lock, "%s%s.lock", prefix, name); + if (error != 0) goto fail; dev_depends(dev, lock); - dev2unit(lock) = TTYUNIT_LOCK; - lock->si_drv1 = tp; - wakeup(&lock->si_drv1); - lock->si_drv2 = &tp->t_termios_lock_in; } /* Call-out devices. */ if (tp->t_flags & TF_CALLOUT) { - error = make_dev_p(flags, &cua, &ttydev_cdevsw, cred, - UID_UUCP, GID_DIALER, 0660, "cua%s", name); - if (error) + make_dev_args_init(&args); + args.mda_flags = flags; + args.mda_devsw = &ttydev_cdevsw; + args.mda_cr = cred; + args.mda_uid = UID_UUCP; + args.mda_gid = GID_DIALER; + args.mda_mode = 0660; + args.mda_unit = TTYUNIT_CALLOUT; + args.mda_si_drv1 = tp; + error = make_dev_s(&args, &cua, "cua%s", name); + if (error != 0) goto fail; dev_depends(dev, cua); - dev2unit(cua) = TTYUNIT_CALLOUT; - cua->si_drv1 = tp; - wakeup(&cua->si_drv1); /* Slave call-out devices. */ if (tp->t_flags & TF_INITLOCK) { - error = make_dev_p(flags, &cinit, &ttyil_cdevsw, cred, - UID_UUCP, GID_DIALER, 0660, "cua%s.init", name); - if (error) + args.mda_devsw = &ttyil_cdevsw; + args.mda_unit = TTYUNIT_CALLOUT | TTYUNIT_INIT; + args.mda_si_drv2 = &tp->t_termios_init_out; + error = make_dev_s(&args, &cinit, "cua%s.init", name); + if (error != 0) goto fail; dev_depends(dev, cinit); - dev2unit(cinit) = TTYUNIT_CALLOUT | TTYUNIT_INIT; - cinit->si_drv1 = tp; - wakeup(&cinit->si_drv1); - cinit->si_drv2 = &tp->t_termios_init_out; - error = make_dev_p(flags, &clock, &ttyil_cdevsw, cred, - UID_UUCP, GID_DIALER, 0660, "cua%s.lock", name); - if (error) + args.mda_unit = TTYUNIT_CALLOUT | TTYUNIT_LOCK; + args.mda_si_drv2 = &tp->t_termios_lock_out; + error = make_dev_s(&args, &clock, "cua%s.lock", name); + if (error != 0) goto fail; dev_depends(dev, clock); - dev2unit(clock) = TTYUNIT_CALLOUT | TTYUNIT_LOCK; - clock->si_drv1 = tp; - wakeup(&clock->si_drv1); - clock->si_drv2 = &tp->t_termios_lock_out; } } diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index de6b313..0b0b697 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -338,6 +338,9 @@ mb_free_ext(struct mbuf *m) case EXT_SFBUF: sf_ext_free(m->m_ext.ext_arg1, m->m_ext.ext_arg2); break; + case EXT_SFBUF_NOCACHE: + sf_ext_free_nocache(m->m_ext.ext_arg1, m->m_ext.ext_arg2); + break; default: KASSERT(m->m_ext.ext_cnt != NULL, ("%s: no refcounting pointer on %p", __func__, m)); @@ -404,6 +407,7 @@ mb_dupcl(struct mbuf *n, const struct mbuf *m) switch (m->m_ext.ext_type) { case EXT_SFBUF: + case EXT_SFBUF_NOCACHE: sf_ext_ref(m->m_ext.ext_arg1, m->m_ext.ext_arg2); break; default: diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c index 243450d..ba77fca 100644 --- a/sys/kern/uipc_sockbuf.c +++ b/sys/kern/uipc_sockbuf.c @@ -69,6 +69,23 @@ static struct mbuf *sbcut_internal(struct sockbuf *sb, int len); static void sbflush_internal(struct sockbuf *sb); /* + * Our own version of m_clrprotoflags(), that can preserve M_NOTREADY. + */ +static void +sbm_clrprotoflags(struct mbuf *m, int flags) +{ + int mask; + + mask = ~M_PROTOFLAGS; + if (flags & PRUS_NOTREADY) + mask |= M_NOTREADY; + while (m) { + m->m_flags &= mask; + m = m->m_next; + } +} + +/* * Mark ready "count" mbufs starting with "m". */ int @@ -569,7 +586,7 @@ sblastmbufchk(struct sockbuf *sb, const char *file, int line) * are discarded and mbufs are compacted where possible. */ void -sbappend_locked(struct sockbuf *sb, struct mbuf *m) +sbappend_locked(struct sockbuf *sb, struct mbuf *m, int flags) { struct mbuf *n; @@ -577,7 +594,7 @@ sbappend_locked(struct sockbuf *sb, struct mbuf *m) if (m == 0) return; - m_clrprotoflags(m); + sbm_clrprotoflags(m, flags); SBLASTRECORDCHK(sb); n = sb->sb_mb; if (n) { @@ -620,11 +637,11 @@ sbappend_locked(struct sockbuf *sb, struct mbuf *m) * are discarded and mbufs are compacted where possible. */ void -sbappend(struct sockbuf *sb, struct mbuf *m) +sbappend(struct sockbuf *sb, struct mbuf *m, int flags) { SOCKBUF_LOCK(sb); - sbappend_locked(sb, m); + sbappend_locked(sb, m, flags); SOCKBUF_UNLOCK(sb); } diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index c33a2cf..cac698a 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -113,15 +113,6 @@ static int getpeername1(struct thread *td, struct getpeername_args *uap, counter_u64_t sfstat[sizeof(struct sfstat) / sizeof(uint64_t)]; -/* - * sendfile(2)-related variables and associated sysctls - */ -static SYSCTL_NODE(_kern_ipc, OID_AUTO, sendfile, CTLFLAG_RW, 0, - "sendfile(2) tunables"); -static int sfreadahead = 1; -SYSCTL_INT(_kern_ipc_sendfile, OID_AUTO, readahead, CTLFLAG_RW, - &sfreadahead, 0, "Number of sendfile(2) read-ahead MAXBSIZE blocks"); - static void sfstat_init(const void *unused) { @@ -1858,13 +1849,12 @@ sf_ext_free(void *arg1, void *arg2) sf_buf_free(sf); vm_page_lock(pg); - vm_page_unwire(pg, PQ_INACTIVE); /* * Check for the object going away on us. This can * happen since we don't hold a reference to it. * If so, we're responsible for freeing the page. */ - if (pg->wire_count == 0 && pg->object == NULL) + if (vm_page_unwire(pg, PQ_INACTIVE) && pg->object == NULL) vm_page_free(pg); vm_page_unlock(pg); @@ -1878,6 +1868,43 @@ sf_ext_free(void *arg1, void *arg2) } /* + * Same as above, but forces the page to be detached from the object + * and go into free pool. + */ +void +sf_ext_free_nocache(void *arg1, void *arg2) +{ + struct sf_buf *sf = arg1; + struct sendfile_sync *sfs = arg2; + vm_page_t pg = sf_buf_page(sf); + + sf_buf_free(sf); + + vm_page_lock(pg); + if (vm_page_unwire(pg, PQ_NONE)) { + vm_object_t obj; + + /* Try to free the page, but only if it is cheap to. */ + if ((obj = pg->object) == NULL) + vm_page_free(pg); + else if (!vm_page_xbusied(pg) && VM_OBJECT_TRYWLOCK(obj)) { + vm_page_free(pg); + VM_OBJECT_WUNLOCK(obj); + } else + vm_page_deactivate(pg); + } + vm_page_unlock(pg); + + if (sfs != NULL) { + mtx_lock(&sfs->mtx); + KASSERT(sfs->count > 0, ("Sendfile sync botchup count == 0")); + if (--sfs->count == 0) + cv_signal(&sfs->cv); + mtx_unlock(&sfs->mtx); + } +} + +/* * sendfile(2) * * int sendfile(int fd, int s, off_t offset, size_t nbytes, @@ -1974,103 +2001,252 @@ freebsd4_sendfile(struct thread *td, struct freebsd4_sendfile_args *uap) } #endif /* COMPAT_FREEBSD4 */ + /* + * How much data to put into page i of n. + * Only first and last pages are special. + */ +static inline off_t +xfsize(int i, int n, off_t off, off_t len) +{ + + if (i == 0) + return (omin(PAGE_SIZE - (off & PAGE_MASK), len)); + + if (i == n - 1 && ((off + len) & PAGE_MASK) > 0) + return ((off + len) & PAGE_MASK); + + return (PAGE_SIZE); +} + +/* + * Offset within object for i page. + */ +static inline vm_offset_t +vmoff(int i, off_t off) +{ + + if (i == 0) + return ((vm_offset_t)off); + + return (trunc_page(off + i * PAGE_SIZE)); +} + +/* + * Pretend as if we don't have enough space, subtract xfsize() of + * all pages that failed. + */ +static inline void +fixspace(int old, int new, off_t off, int *space) +{ + + KASSERT(old > new, ("%s: old %d new %d", __func__, old, new)); + + /* Subtract last one. */ + *space -= xfsize(old - 1, old, off, *space); + old--; + + if (new == old) + /* There was only one page. */ + return; + + /* Subtract first one. */ + if (new == 0) { + *space -= xfsize(0, old, off, *space); + new++; + } + + /* Rest of pages are full sized. */ + *space -= (old - new) * PAGE_SIZE; + + KASSERT(*space >= 0, ("%s: space went backwards", __func__)); +} + +/* + * Structure describing a single sendfile(2) I/O, which may consist of + * several underlying pager I/Os. + * + * The syscall context allocates the structure and initializes 'nios' + * to 1. As sendfile_swapin() runs through pages and starts asynchronous + * paging operations, it increments 'nios'. + * + * Every I/O completion calls sf_iodone(), which decrements the 'nios', and + * the syscall also calls sf_iodone() after allocating all mbufs, linking them + * and sending to socket. Whoever reaches zero 'nios' is responsible to + * call pru_ready on the socket, to notify it of readyness of the data. + */ +struct sf_io { + volatile u_int nios; + u_int error; + int npages; + struct file *sock_fp; + struct mbuf *m; + vm_page_t pa[]; +}; + +static void +sf_iodone(void *arg, vm_page_t *pg, int count, int error) +{ + struct sf_io *sfio = arg; + struct socket *so; + + for (int i = 0; i < count; i++) + vm_page_xunbusy(pg[i]); + + if (error) + sfio->error = error; + + if (!refcount_release(&sfio->nios)) + return; + + so = sfio->sock_fp->f_data; + + if (sfio->error) { + struct mbuf *m; + + /* + * I/O operation failed. The state of data in the socket + * is now inconsistent, and all what we can do is to tear + * it down. Protocol abort method would tear down protocol + * state, free all ready mbufs and detach not ready ones. + * We will free the mbufs corresponding to this I/O manually. + * + * The socket would be marked with EIO and made available + * for read, so that application receives EIO on next + * syscall and eventually closes the socket. + */ + so->so_proto->pr_usrreqs->pru_abort(so); + so->so_error = EIO; + + m = sfio->m; + for (int i = 0; i < sfio->npages; i++) + m = m_free(m); + } else { + CURVNET_SET(so->so_vnet); + (void )(so->so_proto->pr_usrreqs->pru_ready)(so, sfio->m, + sfio->npages); + CURVNET_RESTORE(); + } + + /* XXXGL: curthread */ + fdrop(sfio->sock_fp, curthread); + free(sfio, M_TEMP); +} + +/* + * Iterate through pages vector and request paging for non-valid pages. + */ static int -sendfile_readpage(vm_object_t obj, struct vnode *vp, int nd, - off_t off, int xfsize, int bsize, struct thread *td, vm_page_t *res) +sendfile_swapin(vm_object_t obj, struct sf_io *sfio, off_t off, off_t len, + int npages, int rhpages, int flags) { - vm_page_t m; - vm_pindex_t pindex; - ssize_t resid; - int error, readahead, rv; + vm_page_t *pa = sfio->pa; + int nios; - pindex = OFF_TO_IDX(off); - VM_OBJECT_WLOCK(obj); - m = vm_page_grab(obj, pindex, (vp != NULL ? VM_ALLOC_NOBUSY | - VM_ALLOC_IGN_SBUSY : 0) | VM_ALLOC_WIRED | VM_ALLOC_NORMAL); + nios = 0; + flags = (flags & SF_NODISKIO) ? VM_ALLOC_NOWAIT : 0; /* - * Check if page is valid for what we need, otherwise initiate I/O. - * - * The non-zero nd argument prevents disk I/O, instead we - * return the caller what he specified in nd. In particular, - * if we already turned some pages into mbufs, nd == EAGAIN - * and the main function send them the pages before we come - * here again and block. + * First grab all the pages and wire them. Note that we grab + * only required pages. Readahead pages are dealt with later. */ - if (m->valid != 0 && vm_page_is_valid(m, off & PAGE_MASK, xfsize)) { - if (vp == NULL) - vm_page_xunbusy(m); - VM_OBJECT_WUNLOCK(obj); - *res = m; - return (0); - } else if (nd != 0) { - if (vp == NULL) - vm_page_xunbusy(m); - error = nd; - goto free_page; + VM_OBJECT_WLOCK(obj); + for (int i = 0; i < npages; i++) { + pa[i] = vm_page_grab(obj, OFF_TO_IDX(vmoff(i, off)), + VM_ALLOC_WIRED | VM_ALLOC_NORMAL | flags); + if (pa[i] == NULL) { + npages = i; + rhpages = 0; + break; + } } - /* - * Get the page from backing store. - */ - error = 0; - if (vp != NULL) { - VM_OBJECT_WUNLOCK(obj); - readahead = sfreadahead * MAXBSIZE; + for (int i = 0; i < npages;) { + int j, a, count, rv; + + /* Skip valid pages. */ + if (vm_page_is_valid(pa[i], vmoff(i, off) & PAGE_MASK, + xfsize(i, npages, off, len))) { + vm_page_xunbusy(pa[i]); + SFSTAT_INC(sf_pages_valid); + i++; + continue; + } /* - * Use vn_rdwr() instead of the pager interface for - * the vnode, to allow the read-ahead. - * - * XXXMAC: Because we don't have fp->f_cred here, we - * pass in NOCRED. This is probably wrong, but is - * consistent with our original implementation. + * Now 'i' points to first invalid page, iterate further + * to make 'j' point at first valid after a bunch of + * invalid ones. */ - error = vn_rdwr(UIO_READ, vp, NULL, readahead, trunc_page(off), - UIO_NOCOPY, IO_NODELOCKED | IO_VMIO | ((readahead / - bsize) << IO_SEQSHIFT), td->td_ucred, NOCRED, &resid, td); - SFSTAT_INC(sf_iocnt); - VM_OBJECT_WLOCK(obj); - } else { - if (vm_pager_has_page(obj, pindex, NULL, NULL)) { - rv = vm_pager_get_pages(obj, &m, 1, NULL, NULL); - SFSTAT_INC(sf_iocnt); - if (rv != VM_PAGER_OK) { - vm_page_lock(m); - vm_page_free(m); - vm_page_unlock(m); - m = NULL; - error = EIO; + for (j = i + 1; j < npages; j++) + if (vm_page_is_valid(pa[j], vmoff(j, off) & PAGE_MASK, + xfsize(j, npages, off, len))) { + SFSTAT_INC(sf_pages_valid); + break; } - } else { - pmap_zero_page(m); - m->valid = VM_PAGE_BITS_ALL; - m->dirty = 0; + + /* + * Now we got region of invalid pages between 'i' and 'j'. + * Check that they belong to pager. They may not be there, + * which is a regular situation for shmem pager. For vnode + * pager this happens only in case of sparse file. + * + * Important feature of vm_pager_has_page() is the hint + * stored in 'a', about how many pages we can pagein after + * this page in a single I/O. + */ + while (!vm_pager_has_page(obj, OFF_TO_IDX(vmoff(i, off)), + NULL, &a) && i < j) { + pmap_zero_page(pa[i]); + pa[i]->valid = VM_PAGE_BITS_ALL; + pa[i]->dirty = 0; + vm_page_xunbusy(pa[i]); + i++; } - if (m != NULL) - vm_page_xunbusy(m); - } - if (error == 0) { - *res = m; - } else if (m != NULL) { -free_page: - vm_page_lock(m); - vm_page_unwire(m, PQ_INACTIVE); + if (i == j) + continue; /* - * See if anyone else might know about this page. If - * not and it is not valid, then free it. + * We want to pagein as many pages as possible, limited only + * by the 'a' hint and actual request. + * + * We should not pagein into already valid page, thus if + * 'j' didn't reach last page, trim by that page. + * + * When the pagein fulfils the request, also specify readahead. */ - if (m->wire_count == 0 && m->valid == 0 && !vm_page_busied(m)) - vm_page_free(m); - vm_page_unlock(m); - } - KASSERT(error != 0 || (m->wire_count > 0 && - vm_page_is_valid(m, off & PAGE_MASK, xfsize)), - ("wrong page state m %p off %#jx xfsize %d", m, (uintmax_t)off, - xfsize)); + if (j < npages) + a = min(a, j - i - 1); + count = min(a + 1, npages - i); + + refcount_acquire(&sfio->nios); + rv = vm_pager_get_pages_async(obj, pa + i, count, NULL, + i + count == npages ? &rhpages : NULL, + &sf_iodone, sfio); + KASSERT(rv == VM_PAGER_OK, ("%s: pager fail obj %p page %p", + __func__, obj, pa[i])); + + SFSTAT_INC(sf_iocnt); + SFSTAT_ADD(sf_pages_read, count); + if (i + count == npages) + SFSTAT_ADD(sf_rhpages_read, rhpages); + +#ifdef INVARIANTS + for (j = i; j < i + count && j < npages; j++) + KASSERT(pa[j] == vm_page_lookup(obj, + OFF_TO_IDX(vmoff(j, off))), + ("pa[j] %p lookup %p\n", pa[j], + vm_page_lookup(obj, OFF_TO_IDX(vmoff(j, off))))); +#endif + i += count; + nios++; + } + VM_OBJECT_WUNLOCK(obj); - return (error); + + if (nios == 0 && npages != 0) + SFSTAT_INC(sf_noiocnt); + + return (nios); } static int @@ -2178,42 +2354,37 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio, struct vnode *vp; struct vm_object *obj; struct socket *so; - struct mbuf *m; + struct mbuf *m, *mh, *mhtail; struct sf_buf *sf; - struct vm_page *pg; struct shmfd *shmfd; struct sendfile_sync *sfs; struct vattr va; - off_t off, xfsize, fsbytes, sbytes, rem, obj_size; - int error, bsize, nd, hdrlen, mnw; + off_t off, sbytes, rem, obj_size; + int error, softerr, bsize, hdrlen; - pg = NULL; obj = NULL; so = NULL; - m = NULL; + m = mh = NULL; sfs = NULL; - fsbytes = sbytes = 0; - hdrlen = mnw = 0; - rem = nbytes; - obj_size = 0; + sbytes = 0; + softerr = 0; error = sendfile_getobj(td, fp, &obj, &vp, &shmfd, &obj_size, &bsize); if (error != 0) return (error); - if (rem == 0) - rem = obj_size; error = kern_sendfile_getsock(td, sockfd, &sock_fp, &so); if (error != 0) goto out; - /* - * Do not wait on memory allocations but return ENOMEM for - * caller to retry later. - * XXX: Experimental. - */ - if (flags & SF_MNOWAIT) - mnw = 1; +#ifdef MAC + error = mac_socket_check_send(td->td_ucred, so); + if (error != 0) + goto out; +#endif + + SFSTAT_INC(sf_syscalls); + SFSTAT_ADD(sf_rhpages_requested, SF_READAHEAD(flags)); if (flags & SF_SYNC) { sfs = malloc(sizeof *sfs, M_TEMP, M_WAITOK | M_ZERO); @@ -2221,37 +2392,27 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio, cv_init(&sfs->cv, "sendfile"); } -#ifdef MAC - error = mac_socket_check_send(td->td_ucred, so); - if (error != 0) - goto out; -#endif - /* If headers are specified copy them into mbufs. */ - if (hdr_uio != NULL) { + if (hdr_uio != NULL && hdr_uio->uio_resid > 0) { hdr_uio->uio_td = td; hdr_uio->uio_rw = UIO_WRITE; - if (hdr_uio->uio_resid > 0) { - /* - * In FBSD < 5.0 the nbytes to send also included - * the header. If compat is specified subtract the - * header size from nbytes. - */ - if (kflags & SFK_COMPAT) { - if (nbytes > hdr_uio->uio_resid) - nbytes -= hdr_uio->uio_resid; - else - nbytes = 0; - } - m = m_uiotombuf(hdr_uio, (mnw ? M_NOWAIT : M_WAITOK), - 0, 0, 0); - if (m == NULL) { - error = mnw ? EAGAIN : ENOBUFS; - goto out; - } - hdrlen = m_length(m, NULL); + /* + * In FBSD < 5.0 the nbytes to send also included + * the header. If compat is specified subtract the + * header size from nbytes. + */ + if (kflags & SFK_COMPAT) { + if (nbytes > hdr_uio->uio_resid) + nbytes -= hdr_uio->uio_resid; + else + nbytes = 0; } - } + mh = m_uiotombuf(hdr_uio, M_WAITOK, 0, 0, 0); + hdrlen = m_length(mh, &mhtail); + } else + hdrlen = 0; + + rem = nbytes ? omin(nbytes, obj_size - offset) : obj_size - offset; /* * Protect against multiple writers to the socket. @@ -2272,21 +2433,13 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio, * The outer loop checks the state and available space of the socket * and takes care of the overall progress. */ - for (off = offset; ; ) { + for (off = offset; rem > 0; ) { + struct sf_io *sfio; + vm_page_t *pa; struct mbuf *mtail; - int loopbytes; - int space; - int done; - - if ((nbytes != 0 && nbytes == fsbytes) || - (nbytes == 0 && obj_size == fsbytes)) - break; + int nios, space, npages, rhpages; mtail = NULL; - loopbytes = 0; - space = 0; - done = 0; - /* * Check the socket state for ongoing connection, * no errors and space in socket buffer. @@ -2362,49 +2515,58 @@ retry_space: VOP_UNLOCK(vp, 0); goto done; } - obj_size = va.va_size; + if (va.va_size != obj_size) { + if (nbytes == 0) + rem += va.va_size - obj_size; + else if (offset + nbytes > va.va_size) + rem -= (offset + nbytes - va.va_size); + obj_size = va.va_size; + } } + if (space > rem) + space = rem; + + npages = howmany(space + (off & PAGE_MASK), PAGE_SIZE); + + /* + * Calculate maximum allowed number of pages for readahead + * at this iteration. First, we allow readahead up to "rem". + * If application wants more, let it be, but there is no + * reason to go above MAXPHYS. Also check against "obj_size", + * since vm_pager_has_page() can hint beyond EOF. + */ + rhpages = howmany(rem + (off & PAGE_MASK), PAGE_SIZE) - npages; + rhpages += SF_READAHEAD(flags); + rhpages = min(howmany(MAXPHYS, PAGE_SIZE), rhpages); + rhpages = min(howmany(obj_size - trunc_page(off), PAGE_SIZE) - + npages, rhpages); + + sfio = malloc(sizeof(struct sf_io) + + npages * sizeof(vm_page_t), M_TEMP, M_WAITOK); + refcount_init(&sfio->nios, 1); + sfio->error = 0; + + nios = sendfile_swapin(obj, sfio, off, space, npages, rhpages, + flags); + /* * Loop and construct maximum sized mbuf chain to be bulk * dumped into socket buffer. */ - while (space > loopbytes) { - vm_offset_t pgoff; + pa = sfio->pa; + for (int i = 0; i < npages; i++) { struct mbuf *m0; /* - * Calculate the amount to transfer. - * Not to exceed a page, the EOF, - * or the passed in nbytes. + * If a page wasn't grabbed successfully, then + * trim the array. Can happen only with SF_NODISKIO. */ - pgoff = (vm_offset_t)(off & PAGE_MASK); - rem = obj_size - offset; - if (nbytes != 0) - rem = omin(rem, nbytes); - rem -= fsbytes + loopbytes; - xfsize = omin(PAGE_SIZE - pgoff, rem); - xfsize = omin(space - loopbytes, xfsize); - if (xfsize <= 0) { - done = 1; /* all data sent */ - break; - } - - /* - * Attempt to look up the page. Allocate - * if not found or wait and loop if busy. - */ - if (m != NULL) - nd = EAGAIN; /* send what we already got */ - else if ((flags & SF_NODISKIO) != 0) - nd = EBUSY; - else - nd = 0; - error = sendfile_readpage(obj, vp, nd, off, - xfsize, bsize, td, &pg); - if (error != 0) { - if (error == EAGAIN) - error = 0; /* not a real error */ + if (pa[i] == NULL) { + SFSTAT_INC(sf_busy); + fixspace(npages, i, off, &space); + npages = i; + softerr = EBUSY; break; } @@ -2417,56 +2579,59 @@ retry_space: * threads might exhaust the buffers and then * deadlock. */ - sf = sf_buf_alloc(pg, (mnw || m != NULL) ? SFB_NOWAIT : - SFB_CATCH); + sf = sf_buf_alloc(pa[i], + m != NULL ? SFB_NOWAIT : SFB_CATCH); if (sf == NULL) { SFSTAT_INC(sf_allocfail); - vm_page_lock(pg); - vm_page_unwire(pg, PQ_INACTIVE); - KASSERT(pg->object != NULL, - ("%s: object disappeared", __func__)); - vm_page_unlock(pg); + for (int j = i; j < npages; j++) { + vm_page_lock(pa[j]); + vm_page_unwire(pa[j], PQ_INACTIVE); + vm_page_unlock(pa[j]); + } if (m == NULL) - error = (mnw ? EAGAIN : EINTR); + softerr = ENOBUFS; + fixspace(npages, i, off, &space); + npages = i; break; } - /* - * Get an mbuf and set it up as having - * external storage. - */ - m0 = m_get((mnw ? M_NOWAIT : M_WAITOK), MT_DATA); - if (m0 == NULL) { - error = (mnw ? EAGAIN : ENOBUFS); - sf_ext_free(sf, NULL); - break; - } - /* - * Attach EXT_SFBUF external storage. - */ - m0->m_ext.ext_buf = (caddr_t )sf_buf_kva(sf); + m0 = m_get(M_WAITOK, MT_DATA); + m0->m_ext.ext_buf = (char *)sf_buf_kva(sf); m0->m_ext.ext_size = PAGE_SIZE; m0->m_ext.ext_arg1 = sf; m0->m_ext.ext_arg2 = sfs; - m0->m_ext.ext_type = EXT_SFBUF; + /* + * SF_NOCACHE sets the page as being freed upon send. + * However, we ignore it for the last page in 'space', + * if the page is truncated, and we got more data to + * send (rem > space), or if we have readahead + * configured (rhpages > 0). + */ + if ((flags & SF_NOCACHE) == 0 || + (i == npages - 1 && + ((off + space) & PAGE_MASK) && + (rem > space || rhpages > 0))) + m0->m_ext.ext_type = EXT_SFBUF; + else + m0->m_ext.ext_type = EXT_SFBUF_NOCACHE; m0->m_ext.ext_flags = 0; - m0->m_flags |= (M_EXT|M_RDONLY); - m0->m_data = (char *)sf_buf_kva(sf) + pgoff; - m0->m_len = xfsize; + m0->m_flags |= (M_EXT | M_RDONLY); + if (nios) + m0->m_flags |= M_NOTREADY; + m0->m_data = (char *)sf_buf_kva(sf) + + (vmoff(i, off) & PAGE_MASK); + m0->m_len = xfsize(i, npages, off, space); + + if (i == 0) + sfio->m = m0; /* Append to mbuf chain. */ if (mtail != NULL) mtail->m_next = m0; - else if (m != NULL) - m_last(m)->m_next = m0; else m = m0; mtail = m0; - /* Keep track of bits processed. */ - loopbytes += xfsize; - off += xfsize; - if (sfs != NULL) { mtx_lock(&sfs->mtx); sfs->count++; @@ -2477,49 +2642,60 @@ retry_space: if (vp != NULL) VOP_UNLOCK(vp, 0); + /* Keep track of bytes processed. */ + off += space; + rem -= space; + + /* Prepend header, if any. */ + if (hdrlen) { + mhtail->m_next = m; + m = mh; + mh = NULL; + } + + if (m == NULL) { + KASSERT(softerr, ("%s: m NULL, no error", __func__)); + error = softerr; + free(sfio, M_TEMP); + goto done; + } + /* Add the buffer chain to the socket buffer. */ - if (m != NULL) { - int mlen, err; + KASSERT(m_length(m, NULL) == space + hdrlen, + ("%s: mlen %u space %d hdrlen %d", + __func__, m_length(m, NULL), space, hdrlen)); - mlen = m_length(m, NULL); - SOCKBUF_LOCK(&so->so_snd); - if (so->so_snd.sb_state & SBS_CANTSENDMORE) { - error = EPIPE; - SOCKBUF_UNLOCK(&so->so_snd); - goto done; - } - SOCKBUF_UNLOCK(&so->so_snd); - CURVNET_SET(so->so_vnet); - /* Avoid error aliasing. */ - err = (*so->so_proto->pr_usrreqs->pru_send) - (so, 0, m, NULL, NULL, td); - CURVNET_RESTORE(); - if (err == 0) { - /* - * We need two counters to get the - * file offset and nbytes to send - * right: - * - sbytes contains the total amount - * of bytes sent, including headers. - * - fsbytes contains the total amount - * of bytes sent from the file. - */ - sbytes += mlen; - fsbytes += mlen; - if (hdrlen) { - fsbytes -= hdrlen; - hdrlen = 0; - } - } else if (error == 0) - error = err; - m = NULL; /* pru_send always consumes */ + CURVNET_SET(so->so_vnet); + if (nios == 0) { + /* + * If sendfile_swapin() didn't initiate any I/Os, + * which happens if all data is cached in VM, then + * we can send data right now without the + * PRUS_NOTREADY flag. + */ + free(sfio, M_TEMP); + error = (*so->so_proto->pr_usrreqs->pru_send) + (so, 0, m, NULL, NULL, td); + } else { + sfio->sock_fp = sock_fp; + sfio->npages = npages; + fhold(sock_fp); + error = (*so->so_proto->pr_usrreqs->pru_send) + (so, PRUS_NOTREADY, m, NULL, NULL, td); + sf_iodone(sfio, NULL, 0, 0); } + CURVNET_RESTORE(); - /* Quit outer loop on error or when we're done. */ - if (done) - break; - if (error != 0) + m = NULL; /* pru_send always consumes */ + if (error) goto done; + sbytes += space + hdrlen; + if (hdrlen) + hdrlen = 0; + if (softerr) { + error = softerr; + goto done; + } } /* @@ -2552,6 +2728,8 @@ out: fdrop(sock_fp, td); if (m) m_freem(m); + if (mh) + m_freem(mh); if (sfs != NULL) { mtx_lock(&sfs->mtx); diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index efed37b..e455b10 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -981,7 +981,7 @@ uipc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, control)) control = NULL; } else - sbappend_locked(&so2->so_rcv, m); + sbappend_locked(&so2->so_rcv, m, flags); break; case SOCK_SEQPACKET: { diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index ff3736d..f1bd821 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -288,7 +288,7 @@ static u_long nummiss; STATNODE(CTLFLAG_RD, nummiss, &nummiss, "Number of cache misses"); static u_long nummisszap; STATNODE(CTLFLAG_RD, nummisszap, &nummisszap, "Number of cache misses we do not want to cache"); -static u_long numposzaps; STATNODE(CTLFLAG_RD, numposzaps, &numposzaps, +static u_long numposzaps; STATNODE(CTLFLAG_RD, numposzaps, &numposzaps, "Number of cache hits (positive) we do not want to cache"); static u_long numposhits; STATNODE(CTLFLAG_RD, numposhits, &numposhits, "Number of cache hits (positive)"); @@ -303,8 +303,6 @@ SYSCTL_OPAQUE(_vfs_cache, OID_AUTO, nchstats, CTLFLAG_RD | CTLFLAG_MPSAFE, &nchstats, sizeof(nchstats), "LU", "VFS cache effectiveness statistics"); - - static void cache_zap(struct namecache *ncp); static int vn_vptocnp_locked(struct vnode **vp, struct ucred *cred, char *buf, u_int *buflen); @@ -410,8 +408,7 @@ SYSCTL_PROC(_debug_hashstat, OID_AUTO, nchash, CTLTYPE_INT|CTLFLAG_RD| * pointer to a vnode or if it is just a negative cache entry. */ static void -cache_zap(ncp) - struct namecache *ncp; +cache_zap(struct namecache *ncp) { struct vnode *vp; @@ -446,7 +443,7 @@ cache_zap(ncp) } numcache--; cache_free(ncp); - if (vp) + if (vp != NULL) vdrop(vp); } @@ -468,12 +465,8 @@ cache_zap(ncp) */ int -cache_lookup(dvp, vpp, cnp, tsp, ticksp) - struct vnode *dvp; - struct vnode **vpp; - struct componentname *cnp; - struct timespec *tsp; - int *ticksp; +cache_lookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, + struct timespec *tsp, int *ticksp) { struct namecache *ncp; uint32_t hash; @@ -701,12 +694,8 @@ unlock: * Add an entry to the cache. */ void -cache_enter_time(dvp, vp, cnp, tsp, dtsp) - struct vnode *dvp; - struct vnode *vp; - struct componentname *cnp; - struct timespec *tsp; - struct timespec *dtsp; +cache_enter_time(struct vnode *dvp, struct vnode *vp, struct componentname *cnp, + struct timespec *tsp, struct timespec *dtsp) { struct namecache *ncp, *n2; struct namecache_ts *n3; @@ -836,9 +825,9 @@ cache_enter_time(dvp, vp, cnp, tsp, dtsp) * has populated v_cache_dd pointer already. */ if (dvp->v_cache_dd != NULL) { - CACHE_WUNLOCK(); - cache_free(ncp); - return; + CACHE_WUNLOCK(); + cache_free(ncp); + return; } KASSERT(vp == NULL || vp->v_type == VDIR, ("wrong vnode type %p", vp)); @@ -846,7 +835,7 @@ cache_enter_time(dvp, vp, cnp, tsp, dtsp) } numcache++; - if (!vp) { + if (vp == NULL) { numneg++; if (cnp->cn_flags & ISWHITEOUT) ncp->nc_flag |= NCF_WHITE; @@ -884,7 +873,7 @@ cache_enter_time(dvp, vp, cnp, tsp, dtsp) * "negative" cache queue, otherwise, we place it into the * destination vnode's cache entries queue. */ - if (vp) { + if (vp != NULL) { TAILQ_INSERT_HEAD(&vp->v_cache_dst, ncp, nc_dst); SDT_PROBE3(vfs, namecache, enter, done, dvp, nc_get_name(ncp), vp); @@ -975,8 +964,7 @@ cache_changesize(int newmaxvnodes) * Invalidate all entries to a particular vnode. */ void -cache_purge(vp) - struct vnode *vp; +cache_purge(struct vnode *vp) { CTR1(KTR_VFS, "cache_purge(%p)", vp); @@ -999,8 +987,7 @@ cache_purge(vp) * Invalidate all negative entries for a particular directory vnode. */ void -cache_purge_negative(vp) - struct vnode *vp; +cache_purge_negative(struct vnode *vp) { struct namecache *cp, *ncp; @@ -1018,8 +1005,7 @@ cache_purge_negative(vp) * Flush all entries referencing a particular filesystem. */ void -cache_purgevfs(mp) - struct mount *mp; +cache_purgevfs(struct mount *mp) { struct nchashhead *ncpp; struct namecache *ncp, *nnp; @@ -1042,12 +1028,7 @@ cache_purgevfs(mp) */ int -vfs_cache_lookup(ap) - struct vop_lookup_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - } */ *ap; +vfs_cache_lookup(struct vop_lookup_args *ap) { struct vnode *dvp; int error; @@ -1088,9 +1069,7 @@ SYSCTL_INT(_debug, OID_AUTO, disablecwd, CTLFLAG_RW, &disablecwd, 0, /* Implementation of the getcwd syscall. */ int -sys___getcwd(td, uap) - struct thread *td; - struct __getcwd_args *uap; +sys___getcwd(struct thread *td, struct __getcwd_args *uap) { return (kern___getcwd(td, uap->buf, UIO_USERSPACE, uap->buflen, diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index fd83f87..3da8618 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -1080,15 +1080,9 @@ vop_stdadvise(struct vop_advise_args *ap) bsize = vp->v_bufobj.bo_bsize; startn = ap->a_start / bsize; endn = ap->a_end / bsize; - for (;;) { - error = bnoreuselist(&bo->bo_clean, bo, startn, endn); - if (error == EAGAIN) - continue; + error = bnoreuselist(&bo->bo_clean, bo, startn, endn); + if (error == 0) error = bnoreuselist(&bo->bo_dirty, bo, startn, endn); - if (error == EAGAIN) - continue; - break; - } BO_RUNLOCK(bo); VOP_UNLOCK(vp, 0); break; diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index ace97e8..5542541 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1669,7 +1669,8 @@ bnoreuselist(struct bufv *bufv, struct bufobj *bo, daddr_t startn, daddr_t endn) ASSERT_BO_LOCKED(bo); - for (lblkno = startn;; lblkno++) { + for (lblkno = startn;;) { +again: bp = BUF_PCTRIE_LOOKUP_GE(&bufv->bv_root, lblkno); if (bp == NULL || bp->b_lblkno >= endn) break; @@ -1677,11 +1678,14 @@ bnoreuselist(struct bufv *bufv, struct bufobj *bo, daddr_t startn, daddr_t endn) LK_INTERLOCK, BO_LOCKPTR(bo), "brlsfl", 0, 0); if (error != 0) { BO_RLOCK(bo); - return (error != ENOLCK ? error : EAGAIN); + if (error == ENOLCK) + goto again; + return (error); } KASSERT(bp->b_bufobj == bo, ("bp %p wrong b_bufobj %p should be %p", bp, bp->b_bufobj, bo)); + lblkno = bp->b_lblkno + 1; if ((bp->b_flags & B_MANAGED) == 0) bremfree(bp); bp->b_flags |= B_RELBUF; diff --git a/sys/kgssapi/gss_impl.c b/sys/kgssapi/gss_impl.c index ab6e55b..3a427a5 100644 --- a/sys/kgssapi/gss_impl.c +++ b/sys/kgssapi/gss_impl.c @@ -105,14 +105,17 @@ sys_gssd_syscall(struct thread *td, struct gssd_syscall_args *uap) if (error) return (error); - sun.sun_family = AF_LOCAL; - strcpy(sun.sun_path, path); - sun.sun_len = SUN_LEN(&sun); - - nconf = getnetconfigent("local"); - cl = clnt_reconnect_create(nconf, - (struct sockaddr *) &sun, GSSD, GSSDVERS, - RPC_MAXDATASIZE, RPC_MAXDATASIZE); + if (path[0] != '\0') { + sun.sun_family = AF_LOCAL; + strcpy(sun.sun_path, path); + sun.sun_len = SUN_LEN(&sun); + + nconf = getnetconfigent("local"); + cl = clnt_reconnect_create(nconf, + (struct sockaddr *) &sun, GSSD, GSSDVERS, + RPC_MAXDATASIZE, RPC_MAXDATASIZE); + } else + cl = NULL; mtx_lock(&kgss_gssd_lock); oldcl = kgss_gssd_handle; diff --git a/sys/mips/beri/beri_machdep.c b/sys/mips/beri/beri_machdep.c index 758083f..54f61ab 100644 --- a/sys/mips/beri/beri_machdep.c +++ b/sys/mips/beri/beri_machdep.c @@ -273,7 +273,7 @@ platform_start(__register_t a0, __register_t a1, __register_t a2, * Configure more boot-time parameters passed in by loader. */ boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int); - kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); + init_static_kenv(MD_FETCH(kmdp, MODINFOMD_ENVP, char *), 0); /* * Get bootargs from FDT if specified. diff --git a/sys/mips/mips/elf_machdep.c b/sys/mips/mips/elf_machdep.c index 2b50015..b332bf3 100644 --- a/sys/mips/mips/elf_machdep.c +++ b/sys/mips/mips/elf_machdep.c @@ -81,6 +81,7 @@ struct sysentvec elf64_freebsd_sysvec = { .sv_syscallnames = syscallnames, .sv_schedtail = NULL, .sv_thread_detach = NULL, + .sv_trap = NULL, }; static Elf64_Brandinfo freebsd_brand_info = { @@ -135,6 +136,7 @@ struct sysentvec elf32_freebsd_sysvec = { .sv_syscallnames = syscallnames, .sv_schedtail = NULL, .sv_thread_detach = NULL, + .sv_trap = NULL, }; static Elf32_Brandinfo freebsd_brand_info = { diff --git a/sys/mips/mips/freebsd32_machdep.c b/sys/mips/mips/freebsd32_machdep.c index 7726ecd..f4ace04 100644 --- a/sys/mips/mips/freebsd32_machdep.c +++ b/sys/mips/mips/freebsd32_machdep.c @@ -104,6 +104,7 @@ struct sysentvec elf32_freebsd_sysvec = { .sv_syscallnames = freebsd32_syscallnames, .sv_schedtail = NULL, .sv_thread_detach = NULL, + .sv_trap = NULL, }; INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec); diff --git a/sys/modules/Makefile b/sys/modules/Makefile index 1b3b7eb..76a12d3 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -311,6 +311,8 @@ SUBDIR= \ re \ reiserfs \ rl \ + rtwn \ + ${_rtwnfw} \ ${_s3} \ ${_safe} \ ${_sbni} \ @@ -482,6 +484,7 @@ _fxp= fxp _ispfw= ispfw _mwlfw= mwlfw _ralfw= ralfw +_rtwnfw= rtwnfw _sf= sf _ti= ti _txp= txp diff --git a/sys/modules/geom/geom_eli/Makefile b/sys/modules/geom/geom_eli/Makefile index 51d821a..c42ccf1 100644 --- a/sys/modules/geom/geom_eli/Makefile +++ b/sys/modules/geom/geom_eli/Makefile @@ -6,6 +6,7 @@ KMOD= geom_eli SRCS= g_eli.c SRCS+= g_eli_crypto.c SRCS+= g_eli_ctl.c +SRCS+= g_eli_hmac.c SRCS+= g_eli_integrity.c SRCS+= g_eli_key.c SRCS+= g_eli_key_cache.c diff --git a/sys/modules/rtwn/Makefile b/sys/modules/rtwn/Makefile new file mode 100644 index 0000000..f5d230c --- /dev/null +++ b/sys/modules/rtwn/Makefile @@ -0,0 +1,8 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../dev/rtwn + +KMOD = if_rtwn +SRCS = if_rtwn.c device_if.h bus_if.h pci_if.h + +.include <bsd.kmod.mk> diff --git a/sys/modules/rtwnfw/Makefile b/sys/modules/rtwnfw/Makefile new file mode 100644 index 0000000..7a679df --- /dev/null +++ b/sys/modules/rtwnfw/Makefile @@ -0,0 +1,5 @@ +# $FreeBSD$ + +SUBDIR= rtwnrtl8192cU rtwnrtl8192cUB + +.include <bsd.subdir.mk> diff --git a/sys/modules/rtwnfw/Makefile.inc b/sys/modules/rtwnfw/Makefile.inc new file mode 100644 index 0000000..ce5bcee --- /dev/null +++ b/sys/modules/rtwnfw/Makefile.inc @@ -0,0 +1,15 @@ +# $FreeBSD$ +# +# Common rules for building firmware. Note this gets auto-included +# by the subdir Makefile's as a consequence of included bsd.kmod.mk. + +_FIRM= ${IMG}.fw + +CLEANFILES+= ${_FIRM} + +FIRMWS= ${_FIRM}:${KMOD}:111 + +FIRMWARE_LICENSE= realtek + +${_FIRM}: ${.CURDIR}/../../../contrib/dev/rtwn/${_FIRM}.uu + uudecode -p $? > ${.TARGET} diff --git a/sys/modules/rtwnfw/rtwnrtl8192cU/Makefile b/sys/modules/rtwnfw/rtwnrtl8192cU/Makefile new file mode 100644 index 0000000..643a30f --- /dev/null +++ b/sys/modules/rtwnfw/rtwnrtl8192cU/Makefile @@ -0,0 +1,6 @@ +# $FreeBSD$ + +KMOD= rtwn-rtl8192cfwU +IMG= rtwn-rtl8192cfwU + +.include <bsd.kmod.mk> diff --git a/sys/modules/rtwnfw/rtwnrtl8192cUB/Makefile b/sys/modules/rtwnfw/rtwnrtl8192cUB/Makefile new file mode 100644 index 0000000..eb878d4 --- /dev/null +++ b/sys/modules/rtwnfw/rtwnrtl8192cUB/Makefile @@ -0,0 +1,6 @@ +# $FreeBSD$ + +KMOD= rtwn-rtl8192cfwU_B +IMG= rtwn-rtl8192cfwU_B + +.include <bsd.kmod.mk> diff --git a/sys/modules/sfxge/Makefile b/sys/modules/sfxge/Makefile index b2116d8..54d0af1 100644 --- a/sys/modules/sfxge/Makefile +++ b/sys/modules/sfxge/Makefile @@ -29,11 +29,16 @@ SRCS+= siena_mac.c siena_mcdi.c siena_nic.c siena_nvram.c siena_phy.c SRCS+= siena_sram.c siena_vpd.c SRCS+= siena_flash.h siena_impl.h +SRCS+= ef10_impl.h + SRCS+= hunt_ev.c hunt_intr.c hunt_mac.c hunt_mcdi.c hunt_nic.c SRCS+= hunt_nvram.c hunt_rx.c hunt_phy.c hunt_sram.c hunt_tx.c hunt_vpd.c SRCS+= hunt_filter.c SRCS+= hunt_impl.h +SRCS+= medford_nic.c +SRCS+= medford_impl.h + # Extra debug checks #CFLAGS += -DDEBUG=1 diff --git a/sys/modules/syscons/Makefile b/sys/modules/syscons/Makefile index b047845..85e513d 100644 --- a/sys/modules/syscons/Makefile +++ b/sys/modules/syscons/Makefile @@ -9,6 +9,7 @@ SUBDIR= ${_apm} \ ${_fire} \ green \ ${_logo} \ + ${_plasma} \ ${_rain} \ ${_snake} \ ${_star} \ @@ -25,6 +26,7 @@ _daemon= daemon _dragon= dragon _fire= fire _logo= logo +_plasma= plasma _rain= rain _snake= snake _star= star diff --git a/sys/modules/syscons/plasma/Makefile b/sys/modules/syscons/plasma/Makefile new file mode 100644 index 0000000..c71c864 --- /dev/null +++ b/sys/modules/syscons/plasma/Makefile @@ -0,0 +1,8 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../../dev/syscons/plasma + +KMOD= plasma_saver +SRCS= fp16.c plasma_saver.c + +.include <bsd.kmod.mk> diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c index 4944e97..16adba4 100644 --- a/sys/net/if_arcsubr.c +++ b/sys/net/if_arcsubr.c @@ -113,9 +113,8 @@ arc_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, error = 0; #if defined(INET) || defined(INET6) - if (ro != NULL && ro->ro_rt != NULL && - (ro->ro_rt->rt_flags & RTF_GATEWAY) != 0) - is_gw = 1; + if (ro != NULL) + is_gw = (ro->ro_flags & RT_HAS_GW) != 0; #endif switch (dst->sa_family) { diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 5186406..2d652ad 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -202,7 +202,6 @@ ether_resolve_addr(struct ifnet *ifp, struct mbuf *m, uint32_t *pflags) { struct ether_header *eh; - struct rtentry *rt; uint32_t lleflags = 0; int error = 0; #if defined(INET) || defined(INET6) @@ -253,8 +252,7 @@ ether_resolve_addr(struct ifnet *ifp, struct mbuf *m, } if (error == EHOSTDOWN) { - rt = (ro != NULL) ? ro->ro_rt : NULL; - if (rt != NULL && (rt->rt_flags & RTF_GATEWAY) != 0) + if (ro != NULL && (ro->ro_flags & RT_HAS_GW) != 0) error = EHOSTUNREACH; } @@ -324,6 +322,10 @@ ether_output(struct ifnet *ifp, struct mbuf *m, /* * Add local net header. If no space in first mbuf, * allocate another. + * + * Note that we do prepend regardless of RT_HAS_HEADER flag. + * This is done because BPF code shifts m_data pointer + * to the end of ethernet header prior to calling if_output(). */ M_PREPEND(m, hlen, M_NOWAIT); if (m == NULL) diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c index 81b65a63..84ee669 100644 --- a/sys/net/if_fddisubr.c +++ b/sys/net/if_fddisubr.c @@ -119,9 +119,8 @@ fddi_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, getmicrotime(&ifp->if_lastchange); #if defined(INET) || defined(INET6) - if (ro != NULL && ro->ro_rt != NULL && - (ro->ro_rt->rt_flags & RTF_GATEWAY) != 0) - is_gw = 1; + if (ro != NULL) + is_gw = (ro->ro_flags & RT_HAS_GW) != 0; #endif switch (dst->sa_family) { diff --git a/sys/net/if_fwsubr.c b/sys/net/if_fwsubr.c index 626b1cb..a070f61 100644 --- a/sys/net/if_fwsubr.c +++ b/sys/net/if_fwsubr.c @@ -106,9 +106,8 @@ firewire_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, } #if defined(INET) || defined(INET6) - if (ro != NULL && ro->ro_rt != NULL && - (ro->ro_rt->rt_flags & RTF_GATEWAY) != 0) - is_gw = 1; + if (ro != NULL) + is_gw = (ro->ro_flags & RT_HAS_GW) != 0; #endif /* * For unicast, we make a tag to store the lladdr of the @@ -145,10 +144,6 @@ firewire_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, * doesn't fit into the arp model. */ if (unicast) { - is_gw = 0; - if (ro != NULL && ro->ro_rt != NULL && - (ro->ro_rt->rt_flags & RTF_GATEWAY) != 0) - is_gw = 1; error = arpresolve(ifp, is_gw, m, dst, (u_char *) destfw, NULL); if (error) return (error == EWOULDBLOCK ? 0 : error); diff --git a/sys/net/if_iso88025subr.c b/sys/net/if_iso88025subr.c index 7192998..466784f 100644 --- a/sys/net/if_iso88025subr.c +++ b/sys/net/if_iso88025subr.c @@ -214,12 +214,8 @@ iso88025_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, struct rtentry *rt0 = NULL; int is_gw = 0; - if (ro != NULL) { - rt0 = ro->ro_rt; - if (rt0 != NULL && (rt0->rt_flags & RTF_GATEWAY) != 0) - is_gw = 1; - } - + if (ro != NULL) + is_gw = (ro->ro_flags & RT_HAS_GW) != 0; #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); if (error) diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index f4ac8b4..1291f7b 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -202,15 +202,12 @@ looutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, struct route *ro) { u_int32_t af; - struct rtentry *rt = NULL; #ifdef MAC int error; #endif M_ASSERTPKTHDR(m); /* check if we have the packet header */ - if (ro != NULL) - rt = ro->ro_rt; #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); if (error) { @@ -219,10 +216,9 @@ looutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, } #endif - if (rt && rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) { + if (ro != NULL && ro->ro_flags & (RT_REJECT|RT_BLACKHOLE)) { m_freem(m); - return (rt->rt_flags & RTF_BLACKHOLE ? 0 : - rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH); + return (ro->ro_flags & RT_BLACKHOLE ? 0 : EHOSTUNREACH); } if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); diff --git a/sys/net/radix_mpath.c b/sys/net/radix_mpath.c index 82c0add..5657400 100644 --- a/sys/net/radix_mpath.c +++ b/sys/net/radix_mpath.c @@ -197,14 +197,49 @@ rt_mpath_conflict(struct radix_node_head *rnh, struct rtentry *rt, return (0); } -void -rtalloc_mpath_fib(struct route *ro, uint32_t hash, u_int fibnum) +static struct rtentry * +rt_mpath_selectrte(struct rtentry *rte, uint32_t hash) { struct radix_node *rn0, *rn; u_int32_t n; struct rtentry *rt; int64_t weight; + /* beyond here, we use rn as the master copy */ + rn0 = rn = (struct radix_node *)rte; + n = rn_mpath_count(rn0); + + /* gw selection by Modulo-N Hash (RFC2991) XXX need improvement? */ + hash += hashjitter; + hash %= n; + for (weight = abs((int32_t)hash), rt = rte; + weight >= rt->rt_weight && rn; + weight -= rt->rt_weight) { + + /* stay within the multipath routes */ + if (rn->rn_dupedkey && rn->rn_mask != rn->rn_dupedkey->rn_mask) + break; + rn = rn->rn_dupedkey; + rt = (struct rtentry *)rn; + } + + return (rt); +} + +struct rtentry * +rt_mpath_select(struct rtentry *rte, uint32_t hash) +{ + if (rn_mpath_next((struct radix_node *)rte) == NULL) + return (rte); + + return (rt_mpath_selectrte(rte, hash)); +} + +void +rtalloc_mpath_fib(struct route *ro, uint32_t hash, u_int fibnum) +{ + struct rtentry *rt; + /* * XXX we don't attempt to lookup cached route again; what should * be done for sendto(3) case? @@ -222,34 +257,18 @@ rtalloc_mpath_fib(struct route *ro, uint32_t hash, u_int fibnum) return; } - /* beyond here, we use rn as the master copy */ - rn0 = rn = (struct radix_node *)ro->ro_rt; - n = rn_mpath_count(rn0); - - /* gw selection by Modulo-N Hash (RFC2991) XXX need improvement? */ - hash += hashjitter; - hash %= n; - for (weight = abs((int32_t)hash), rt = ro->ro_rt; - weight >= rt->rt_weight && rn; - weight -= rt->rt_weight) { - - /* stay within the multipath routes */ - if (rn->rn_dupedkey && rn->rn_mask != rn->rn_dupedkey->rn_mask) - break; - rn = rn->rn_dupedkey; - rt = (struct rtentry *)rn; - } + rt = rt_mpath_selectrte(ro->ro_rt, hash); /* XXX try filling rt_gwroute and avoid unreachable gw */ /* gw selection has failed - there must be only zero weight routes */ - if (!rn) { + if (!rt) { RT_UNLOCK(ro->ro_rt); ro->ro_rt = NULL; return; } if (ro->ro_rt != rt) { RTFREE_LOCKED(ro->ro_rt); - ro->ro_rt = (struct rtentry *)rn; + ro->ro_rt = rt; RT_LOCK(ro->ro_rt); RT_ADDREF(ro->ro_rt); diff --git a/sys/net/radix_mpath.h b/sys/net/radix_mpath.h index bcb210e..fc6f777 100644 --- a/sys/net/radix_mpath.h +++ b/sys/net/radix_mpath.h @@ -52,6 +52,7 @@ int rt_mpath_conflict(struct radix_node_head *, struct rtentry *, struct sockaddr *); void rtalloc_mpath_fib(struct route *, u_int32_t, u_int); #define rtalloc_mpath(_route, _hash) rtalloc_mpath_fib((_route), (_hash), 0) +struct rtentry *rt_mpath_select(struct rtentry *, uint32_t); struct radix_node *rn_mpath_lookup(void *, void *, struct radix_node_head *); int rt_mpath_deldup(struct rtentry *, struct rtentry *); diff --git a/sys/net/route.c b/sys/net/route.c index 86f99ee..9698dd3 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -147,6 +147,8 @@ static void rt_notifydelete(struct rtentry *rt, struct rt_addrinfo *info); static struct radix_node *rt_mpath_unlink(struct radix_node_head *rnh, struct rt_addrinfo *info, struct rtentry *rto, int *perror); #endif +static int rt_exportinfo(struct rtentry *rt, struct rt_addrinfo *info, + int flags); struct if_mtuinfo { @@ -566,7 +568,7 @@ rtredirect_fib(struct sockaddr *dst, struct sockaddr *src, u_int fibnum) { - struct rtentry *rt, *rt0 = NULL; + struct rtentry *rt; int error = 0; short *stat = NULL; struct rt_addrinfo info; @@ -625,7 +627,7 @@ rtredirect_fib(struct sockaddr *dst, * Create new route, rather than smashing route to net. */ create: - rt0 = rt; + RTFREE(rt); rt = NULL; flags |= RTF_DYNAMIC; @@ -635,21 +637,14 @@ rtredirect_fib(struct sockaddr *dst, info.rti_info[RTAX_NETMASK] = netmask; info.rti_ifa = ifa; info.rti_flags = flags; - if (rt0 != NULL) - RT_UNLOCK(rt0); /* drop lock to avoid LOR with RNH */ error = rtrequest1_fib(RTM_ADD, &info, &rt, fibnum); if (rt != NULL) { RT_LOCK(rt); - if (rt0 != NULL) - EVENTHANDLER_INVOKE(route_redirect_event, rt0, rt, dst); flags = rt->rt_flags; } - if (rt0 != NULL) - RTFREE(rt0); stat = &V_rtstat.rts_dynamic; } else { - struct rtentry *gwrt; /* * Smash the current notion of the gateway to @@ -667,11 +662,7 @@ rtredirect_fib(struct sockaddr *dst, RADIX_NODE_HEAD_LOCK(rnh); RT_LOCK(rt); rt_setgate(rt, rt_key(rt), gateway); - gwrt = rtalloc1(gateway, 1, RTF_RNH_LOCKED); RADIX_NODE_HEAD_UNLOCK(rnh); - EVENTHANDLER_INVOKE(route_redirect_event, rt, gwrt, dst); - if (gwrt) - RTFREE_LOCKED(gwrt); } } else error = EHOSTUNREACH; @@ -752,7 +743,7 @@ ifa_ifwithroute(int flags, const struct sockaddr *dst, struct sockaddr *gateway, if (ifa == NULL) ifa = ifa_ifwithnet(gateway, 0, fibnum); if (ifa == NULL) { - struct rtentry *rt = rtalloc1_fib(gateway, 0, RTF_RNH_LOCKED, fibnum); + struct rtentry *rt = rtalloc1_fib(gateway, 0, 0, fibnum); if (rt == NULL) return (NULL); /* @@ -832,6 +823,147 @@ rtrequest_fib(int req, /* + * Copy most of @rt data into @info. + * + * If @flags contains NHR_COPY, copies dst,netmask and gw to the + * pointers specified by @info structure. Assume such pointers + * are zeroed sockaddr-like structures with sa_len field initialized + * to reflect size of the provided buffer. if no NHR_COPY is specified, + * point dst,netmask and gw @info fields to appropriate @rt values. + * + * if @flags contains NHR_REF, do refcouting on rt_ifp. + * + * Returns 0 on success. + */ +int +rt_exportinfo(struct rtentry *rt, struct rt_addrinfo *info, int flags) +{ + struct rt_metrics *rmx; + struct sockaddr *src, *dst; + int sa_len; + + if (flags & NHR_COPY) { + /* Copy destination if dst is non-zero */ + src = rt_key(rt); + dst = info->rti_info[RTAX_DST]; + sa_len = src->sa_len; + if (dst != NULL) { + if (src->sa_len > dst->sa_len) + return (ENOMEM); + memcpy(dst, src, src->sa_len); + info->rti_addrs |= RTA_DST; + } + + /* Copy mask if set && dst is non-zero */ + src = rt_mask(rt); + dst = info->rti_info[RTAX_NETMASK]; + if (src != NULL && dst != NULL) { + + /* + * Radix stores different value in sa_len, + * assume rt_mask() to have the same length + * as rt_key() + */ + if (sa_len > dst->sa_len) + return (ENOMEM); + memcpy(dst, src, src->sa_len); + info->rti_addrs |= RTA_NETMASK; + } + + /* Copy gateway is set && dst is non-zero */ + src = rt->rt_gateway; + dst = info->rti_info[RTAX_GATEWAY]; + if ((rt->rt_flags & RTF_GATEWAY) && src != NULL && dst != NULL){ + if (src->sa_len > dst->sa_len) + return (ENOMEM); + memcpy(dst, src, src->sa_len); + info->rti_addrs |= RTA_GATEWAY; + } + } else { + info->rti_info[RTAX_DST] = rt_key(rt); + info->rti_addrs |= RTA_DST; + if (rt_mask(rt) != NULL) { + info->rti_info[RTAX_NETMASK] = rt_mask(rt); + info->rti_addrs |= RTA_NETMASK; + } + if (rt->rt_flags & RTF_GATEWAY) { + info->rti_info[RTAX_GATEWAY] = rt->rt_gateway; + info->rti_addrs |= RTA_GATEWAY; + } + } + + rmx = info->rti_rmx; + if (rmx != NULL) { + info->rti_mflags |= RTV_MTU; + rmx->rmx_mtu = rt->rt_mtu; + } + + info->rti_flags = rt->rt_flags; + info->rti_ifp = rt->rt_ifp; + info->rti_ifa = rt->rt_ifa; + + if (flags & NHR_REF) { + /* Do 'traditional' refcouting */ + if_ref(info->rti_ifp); + } + + return (0); +} + +/* + * Lookups up route entry for @dst in RIB database for fib @fibnum. + * Exports entry data to @info using rt_exportinfo(). + * + * if @flags contains NHR_REF, refcouting is performed on rt_ifp. + * All references can be released later by calling rib_free_info() + * + * Returns 0 on success. + * Returns ENOENT for lookup failure, ENOMEM for export failure. + */ +int +rib_lookup_info(uint32_t fibnum, const struct sockaddr *dst, uint32_t flags, + uint32_t flowid, struct rt_addrinfo *info) +{ + struct radix_node_head *rh; + struct radix_node *rn; + struct rtentry *rt; + int error; + + KASSERT((fibnum < rt_numfibs), ("rib_lookup_rte: bad fibnum")); + rh = rt_tables_get_rnh(fibnum, dst->sa_family); + if (rh == NULL) + return (ENOENT); + + RADIX_NODE_HEAD_RLOCK(rh); + rn = rh->rnh_matchaddr(__DECONST(void *, dst), rh); + if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) { + rt = RNTORT(rn); + /* Ensure route & ifp is UP */ + if (RT_LINK_IS_UP(rt->rt_ifp)) { + flags = (flags & NHR_REF) | NHR_COPY; + error = rt_exportinfo(rt, info, flags); + RADIX_NODE_HEAD_RUNLOCK(rh); + + return (error); + } + } + RADIX_NODE_HEAD_RUNLOCK(rh); + + return (ENOENT); +} + +/* + * Releases all references acquired by rib_lookup_info() when + * called with NHR_REF flags. + */ +void +rib_free_info(struct rt_addrinfo *info) +{ + + if_rele(info->rti_ifp); +} + +/* * Iterates over all existing fibs in system calling * @setwa_f function prior to traversing each fib. * Calls @wa_f function for each element in current fib. @@ -1432,7 +1564,7 @@ int rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt, u_int fibnum) { - int error = 0, needlock = 0; + int error = 0; struct rtentry *rt, *rt_old; #ifdef FLOWTABLE struct rtentry *rt0; @@ -1442,9 +1574,9 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt, struct ifaddr *ifa; struct sockaddr *ndst; struct sockaddr_storage mdst; -#define senderr(x) { error = x ; goto bad; } KASSERT((fibnum < rt_numfibs), ("rtrequest1_fib: bad fibnum")); + KASSERT((flags & RTF_RNH_LOCKED) == 0, ("rtrequest1_fib: locked")); switch (dst->sa_family) { case AF_INET6: case AF_INET: @@ -1461,12 +1593,7 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt, rnh = rt_tables_get_rnh(fibnum, dst->sa_family); if (rnh == NULL) return (EAFNOSUPPORT); - needlock = ((flags & RTF_RNH_LOCKED) == 0); - flags &= ~RTF_RNH_LOCKED; - if (needlock) - RADIX_NODE_HEAD_LOCK(rnh); - else - RADIX_NODE_HEAD_LOCK_ASSERT(rnh); + /* * If we are adding a host route then we don't want to put * a netmask in the tree, nor do we want to clone it. @@ -1481,9 +1608,11 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt, dst = (struct sockaddr *)&mdst; } + RADIX_NODE_HEAD_LOCK(rnh); rt = rt_unlinkrte(rnh, info, &error); + RADIX_NODE_HEAD_UNLOCK(rnh); if (error != 0) - goto bad; + return (error); rt_notifydelete(rt, info); @@ -1506,33 +1635,32 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt, break; case RTM_ADD: if ((flags & RTF_GATEWAY) && !gateway) - senderr(EINVAL); + return (EINVAL); if (dst && gateway && (dst->sa_family != gateway->sa_family) && (gateway->sa_family != AF_UNSPEC) && (gateway->sa_family != AF_LINK)) - senderr(EINVAL); + return (EINVAL); if (info->rti_ifa == NULL) { error = rt_getifa_fib(info, fibnum); if (error) - senderr(error); + return (error); } else ifa_ref(info->rti_ifa); ifa = info->rti_ifa; rt = uma_zalloc(V_rtzone, M_NOWAIT); if (rt == NULL) { ifa_free(ifa); - senderr(ENOBUFS); + return (ENOBUFS); } rt->rt_flags = RTF_UP | flags; rt->rt_fibnum = fibnum; /* * Add the gateway. Possibly re-malloc-ing the storage for it. */ - RT_LOCK(rt); if ((error = rt_setgate(rt, dst, gateway)) != 0) { ifa_free(ifa); uma_zfree(V_rtzone, rt); - senderr(error); + return (error); } /* @@ -1559,14 +1687,18 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt, rt_setmetrics(info, rt); + RADIX_NODE_HEAD_LOCK(rnh); + RT_LOCK(rt); #ifdef RADIX_MPATH /* do not permit exactly the same dst/mask/gw pair */ if (rn_mpath_capable(rnh) && rt_mpath_conflict(rnh, rt, netmask)) { + RADIX_NODE_HEAD_UNLOCK(rnh); + ifa_free(rt->rt_ifa); R_Free(rt_key(rt)); uma_zfree(V_rtzone, rt); - senderr(EEXIST); + return (EEXIST); } #endif @@ -1595,6 +1727,7 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt, rn = rnh->rnh_addaddr(ndst, netmask, rnh, rt->rt_nodes); } + RADIX_NODE_HEAD_UNLOCK(rnh); if (rt_old != NULL) RT_UNLOCK(rt_old); @@ -1611,7 +1744,7 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt, if (rt0 != NULL) RTFREE(rt0); #endif - senderr(EEXIST); + return (EEXIST); } #ifdef FLOWTABLE else if (rt0 != NULL) { @@ -1643,16 +1776,15 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt, RT_UNLOCK(rt); break; case RTM_CHANGE: + RADIX_NODE_HEAD_LOCK(rnh); error = rtrequest1_fib_change(rnh, info, ret_nrt, fibnum); + RADIX_NODE_HEAD_UNLOCK(rnh); break; default: error = EOPNOTSUPP; } -bad: - if (needlock) - RADIX_NODE_HEAD_UNLOCK(rnh); + return (error); -#undef senderr } #undef dst @@ -1802,15 +1934,7 @@ rt_setgate(struct rtentry *rt, struct sockaddr *dst, struct sockaddr *gate) { /* XXX dst may be overwritten, can we move this to below */ int dlen = SA_SIZE(dst), glen = SA_SIZE(gate); -#ifdef INVARIANTS - struct radix_node_head *rnh; - - rnh = rt_tables_get_rnh(rt->rt_fibnum, dst->sa_family); -#endif - RT_LOCK_ASSERT(rt); - RADIX_NODE_HEAD_LOCK_ASSERT(rnh); - /* * Prepare to store the gateway in rt->rt_gateway. * Both dst and gateway are stored one after the other in the same diff --git a/sys/net/route.h b/sys/net/route.h index 743c830..f30a72f 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -44,16 +44,17 @@ */ /* - * A route consists of a destination address, a reference - * to a routing entry, and a reference to an llentry. - * These are often held by protocols in their control - * blocks, e.g. inpcb. + * Struct route consiste of a destination address, + * a route entry pointer, link-layer prepend data pointer along + * with its length. */ struct route { struct rtentry *ro_rt; char *ro_prepend; uint16_t ro_plen; uint16_t ro_flags; + uint16_t ro_mtu; /* saved ro_rt mtu */ + uint16_t spare; struct sockaddr ro_dst; }; @@ -63,9 +64,13 @@ struct route { #define RT_CACHING_CONTEXT 0x1 /* XXX: not used anywhere */ #define RT_NORTREF 0x2 /* doesn't hold reference on ro_rt */ -#define RT_L2_ME (1 << RT_L2_ME_BIT) -#define RT_MAY_LOOP (1 << RT_MAY_LOOP_BIT) -#define RT_HAS_HEADER (1 << RT_HAS_HEADER_BIT) +#define RT_L2_ME (1 << RT_L2_ME_BIT) /* 0x0004 */ +#define RT_MAY_LOOP (1 << RT_MAY_LOOP_BIT) /* 0x0008 */ +#define RT_HAS_HEADER (1 << RT_HAS_HEADER_BIT) /* 0x0010 */ + +#define RT_REJECT 0x0020 /* Destination is reject */ +#define RT_BLACKHOLE 0x0040 /* Destination is blackhole */ +#define RT_HAS_GW 0x0080 /* Destination has GW */ struct rt_metrics { u_long rmx_locks; /* Kernel must leave these values alone */ @@ -196,6 +201,9 @@ struct rtentry { #define NHR_IFAIF 0x01 /* Return ifa_ifp interface */ #define NHR_REF 0x02 /* For future use */ +/* Control plane route request flags */ +#define NHR_COPY 0x100 /* Copy rte data */ + /* rte<>nhop translation */ static inline uint16_t fib_rte_to_nh_flags(int rt_flags) @@ -211,6 +219,21 @@ fib_rte_to_nh_flags(int rt_flags) return (res); } +#ifdef _KERNEL +/* rte<>ro_flags translation */ +static inline void +rt_update_ro_flags(struct route *ro) +{ + int rt_flags = ro->ro_rt->rt_flags; + + ro->ro_flags &= ~ (RT_REJECT|RT_BLACKHOLE|RT_HAS_GW); + + ro->ro_flags |= (rt_flags & RTF_REJECT) ? RT_REJECT : 0; + ro->ro_flags |= (rt_flags & RTF_BLACKHOLE) ? RT_BLACKHOLE : 0; + ro->ro_flags |= (rt_flags & RTF_GATEWAY) ? RT_HAS_GW : 0; +} +#endif + /* * Routing statistics. */ @@ -459,10 +482,10 @@ void rtredirect_fib(struct sockaddr *, struct sockaddr *, int rtrequest_fib(int, struct sockaddr *, struct sockaddr *, struct sockaddr *, int, struct rtentry **, u_int); int rtrequest1_fib(int, struct rt_addrinfo *, struct rtentry **, u_int); +int rib_lookup_info(uint32_t, const struct sockaddr *, uint32_t, uint32_t, + struct rt_addrinfo *); +void rib_free_info(struct rt_addrinfo *info); -#include <sys/eventhandler.h> -typedef void (*rtevent_redirect_fn)(void *, struct rtentry *, struct rtentry *, struct sockaddr *); -EVENTHANDLER_DECLARE(route_redirect_event, rtevent_redirect_fn); #endif #endif diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 6fcbbc6..a5ca9fa 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -614,11 +614,16 @@ route_output(struct mbuf *m, struct socket *so, ...) */ if (info.rti_info[RTAX_GATEWAY] != NULL && info.rti_info[RTAX_GATEWAY]->sa_family != AF_LINK) { - struct route gw_ro; + struct rt_addrinfo ginfo; + struct sockaddr *gdst; + + bzero(&ginfo, sizeof(ginfo)); + bzero(&ss, sizeof(ss)); + ss.ss_len = sizeof(ss); + + ginfo.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&ss; + gdst = info.rti_info[RTAX_GATEWAY]; - bzero(&gw_ro, sizeof(gw_ro)); - gw_ro.ro_dst = *info.rti_info[RTAX_GATEWAY]; - rtalloc_ign_fib(&gw_ro, 0, fibnum); /* * A host route through the loopback interface is * installed for each interface adddress. In pre 8.0 @@ -629,14 +634,14 @@ route_output(struct mbuf *m, struct socket *so, ...) * AF_LINK sa_family type of the rt_gateway, and the * rt_ifp has the IFF_LOOPBACK flag set. */ - if (gw_ro.ro_rt != NULL && - gw_ro.ro_rt->rt_gateway->sa_family == AF_LINK && - gw_ro.ro_rt->rt_ifp->if_flags & IFF_LOOPBACK) { - info.rti_flags &= ~RTF_GATEWAY; - info.rti_flags |= RTF_GWFLAG_COMPAT; + if (rib_lookup_info(fibnum, gdst, NHR_REF, 0, &ginfo) == 0) { + if (ss.ss_family == AF_LINK && + ginfo.rti_ifp->if_flags & IFF_LOOPBACK) { + info.rti_flags &= ~RTF_GATEWAY; + info.rti_flags |= RTF_GWFLAG_COMPAT; + } + rib_free_info(&ginfo); } - if (gw_ro.ro_rt != NULL) - RTFREE(gw_ro.ro_rt); } switch (rtm->rtm_type) { diff --git a/sys/net80211/ieee80211_freebsd.c b/sys/net80211/ieee80211_freebsd.c index 7f2eae5..0ccf378 100644 --- a/sys/net80211/ieee80211_freebsd.c +++ b/sys/net80211/ieee80211_freebsd.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/kernel.h> #include <sys/systm.h> +#include <sys/eventhandler.h> #include <sys/linker.h> #include <sys/mbuf.h> #include <sys/module.h> diff --git a/sys/net80211/ieee80211_freebsd.h b/sys/net80211/ieee80211_freebsd.h index f660c17..6d47ccd 100644 --- a/sys/net80211/ieee80211_freebsd.h +++ b/sys/net80211/ieee80211_freebsd.h @@ -246,9 +246,11 @@ void ieee80211_vap_destroy(struct ieee80211vap *); (((_ifp)->if_flags & IFF_UP) && \ ((_ifp)->if_drv_flags & IFF_DRV_RUNNING)) +/* XXX TODO: cap these at 1, as hz may not be 1000 */ #define msecs_to_ticks(ms) (((ms)*hz)/1000) #define ticks_to_msecs(t) (1000*(t) / hz) #define ticks_to_secs(t) ((t) / hz) + #define time_after(a,b) ((long)(b) - (long)(a) < 0) #define time_before(a,b) time_after(b,a) #define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0) diff --git a/sys/net80211/ieee80211_scan_sw.c b/sys/net80211/ieee80211_scan_sw.c index eb58386..53e4520 100644 --- a/sys/net80211/ieee80211_scan_sw.c +++ b/sys/net80211/ieee80211_scan_sw.c @@ -359,7 +359,7 @@ ieee80211_swscan_bg_scan(const struct ieee80211_scanner *scan, duration = IEEE80211_SCAN_OFFCHANNEL; IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN, - "%s: %s scan, ticks %u duration %lu\n", __func__, + "%s: %s scan, ticks %u duration %u\n", __func__, ss->ss_flags & IEEE80211_SCAN_ACTIVE ? "active" : "passive", ticks, duration); @@ -641,7 +641,7 @@ scan_task(void *arg, int pending) * XXX Should use M_TXCB mechanism to eliminate this. */ cv_timedwait(&SCAN_PRIVATE(ss)->ss_scan_cv, - IEEE80211_LOCK_OBJ(ic), hz / 1000); + IEEE80211_LOCK_OBJ(ic), msecs_to_ticks(1)); if (SCAN_PRIVATE(ss)->ss_iflags & ISCAN_ABORT) goto done; } diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index cd27ead..1dd57ee 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -84,6 +84,7 @@ #define IEEE80211_MS_TO_TU(x) (((x) * 1000) / 1024) #define IEEE80211_TU_TO_MS(x) (((x) * 1024) / 1000) +/* XXX TODO: cap this at 1, in case hz is not 1000 */ #define IEEE80211_TU_TO_TICKS(x)(((x) * 1024 * hz) / (1000 * 1000)) /* diff --git a/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c b/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c index f0cd01e..68c5975 100644 --- a/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c +++ b/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c @@ -972,7 +972,7 @@ ng_btsocket_rfcomm_send(struct socket *so, int flags, struct mbuf *m, } /* Put the packet on the socket's send queue and wakeup RFCOMM task */ - sbappend(&pcb->so->so_snd, m); + sbappend(&pcb->so->so_snd, m, flags); m = NULL; if (!(pcb->flags & NG_BTSOCKET_RFCOMM_DLC_SENDING)) { @@ -2396,7 +2396,7 @@ ng_btsocket_rfcomm_receive_uih(ng_btsocket_rfcomm_session_p s, int dlci, error = ENOBUFS; } else { /* Append packet to the socket receive queue */ - sbappend(&pcb->so->so_rcv, m0); + sbappend(&pcb->so->so_rcv, m0, 0); m0 = NULL; sorwakeup(pcb->so); diff --git a/sys/netgraph/netflow/netflow.c b/sys/netgraph/netflow/netflow.c index 7422fbd..87ff189 100644 --- a/sys/netgraph/netflow/netflow.c +++ b/sys/netgraph/netflow/netflow.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <sys/counter.h> #include <sys/kernel.h> +#include <sys/ktr.h> #include <sys/limits.h> #include <sys/mbuf.h> #include <sys/syslog.h> @@ -395,9 +396,8 @@ hash6_insert(priv_p priv, struct flow_hash_entry *hsh6, struct flow6_rec *r, int plen, uint8_t flags, uint8_t tcp_flags) { struct flow6_entry *fle6; - struct sockaddr_in6 *src, *dst; + struct sockaddr_in6 sin6; struct rtentry *rt; - struct route_in6 rin6; mtx_assert(&hsh6->mtx, MA_OWNED); @@ -425,16 +425,14 @@ hash6_insert(priv_p priv, struct flow_hash_entry *hsh6, struct flow6_rec *r, * fill in out_ifx, dst_mask, nexthop, and dst_as in future releases. */ if ((flags & NG_NETFLOW_CONF_NODSTLOOKUP) == 0) { - bzero(&rin6, sizeof(struct route_in6)); - dst = (struct sockaddr_in6 *)&rin6.ro_dst; - dst->sin6_len = sizeof(struct sockaddr_in6); - dst->sin6_family = AF_INET6; - dst->sin6_addr = r->dst.r_dst6; + bzero(&sin6, sizeof(struct sockaddr_in6)); + sin6.sin6_len = sizeof(struct sockaddr_in6); + sin6.sin6_family = AF_INET6; + sin6.sin6_addr = r->dst.r_dst6; - rin6.ro_rt = rtalloc1_fib((struct sockaddr *)dst, 0, 0, r->fib); + rt = rtalloc1_fib((struct sockaddr *)&sin6, 0, 0, r->fib); - if (rin6.ro_rt != NULL) { - rt = rin6.ro_rt; + if (rt != NULL) { fle6->f.fle_o_ifx = rt->rt_ifp->if_index; if (rt->rt_flags & RTF_GATEWAY && @@ -451,19 +449,16 @@ hash6_insert(priv_p priv, struct flow_hash_entry *hsh6, struct flow6_rec *r, } } - if ((flags & NG_NETFLOW_CONF_NODSTLOOKUP) == 0) { + if ((flags & NG_NETFLOW_CONF_NOSRCLOOKUP) == 0) { /* Do route lookup on source address, to fill in src_mask. */ - bzero(&rin6, sizeof(struct route_in6)); - src = (struct sockaddr_in6 *)&rin6.ro_dst; - src->sin6_len = sizeof(struct sockaddr_in6); - src->sin6_family = AF_INET6; - src->sin6_addr = r->src.r_src6; + bzero(&sin6, sizeof(struct sockaddr_in6)); + sin6.sin6_len = sizeof(struct sockaddr_in6); + sin6.sin6_family = AF_INET6; + sin6.sin6_addr = r->src.r_src6; - rin6.ro_rt = rtalloc1_fib((struct sockaddr *)src, 0, 0, r->fib); - - if (rin6.ro_rt != NULL) { - rt = rin6.ro_rt; + rt = rtalloc1_fib((struct sockaddr *)&sin6, 0, 0, r->fib); + if (rt != NULL) { if (rt_mask(rt)) fle6->f.src_mask = RT_MASK6(rt); else diff --git a/sys/netgraph/netflow/netflow_v9.c b/sys/netgraph/netflow/netflow_v9.c index fe85f42..2fc700d 100644 --- a/sys/netgraph/netflow/netflow_v9.c +++ b/sys/netgraph/netflow/netflow_v9.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <sys/counter.h> #include <sys/kernel.h> +#include <sys/ktr.h> #include <sys/limits.h> #include <sys/mbuf.h> #include <sys/syslog.h> diff --git a/sys/netgraph/netflow/ng_netflow.c b/sys/netgraph/netflow/ng_netflow.c index b5a82a4..b524ca5 100644 --- a/sys/netgraph/netflow/ng_netflow.c +++ b/sys/netgraph/netflow/ng_netflow.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <sys/counter.h> #include <sys/kernel.h> +#include <sys/ktr.h> #include <sys/limits.h> #include <sys/mbuf.h> #include <sys/socket.h> diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index 0bf5cec..7a06bea 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -1334,8 +1334,5 @@ arp_init(void) if (IS_DEFAULT_VNET(curvnet)) iflladdr_tag = EVENTHANDLER_REGISTER(iflladdr_event, arp_iflladdr, NULL, EVENTHANDLER_PRI_ANY); - if (IS_DEFAULT_VNET(curvnet)) - iflladdr_tag = EVENTHANDLER_REGISTER(iflladdr_event, - arp_iflladdr, NULL, EVENTHANDLER_PRI_ANY); } SYSINIT(arp, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY, arp_init, 0); diff --git a/sys/netinet/in.c b/sys/netinet/in.c index c30c1f3..80b1448 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1106,34 +1106,48 @@ in_lltable_free_entry(struct lltable *llt, struct llentry *lle) static int in_lltable_rtcheck(struct ifnet *ifp, u_int flags, const struct sockaddr *l3addr) { - struct rtentry *rt; + struct rt_addrinfo info; + struct sockaddr_in rt_key, rt_mask; + struct sockaddr rt_gateway; + int rt_flags; KASSERT(l3addr->sa_family == AF_INET, ("sin_family %d", l3addr->sa_family)); - /* XXX rtalloc1_fib should take a const param */ - rt = rtalloc1_fib(__DECONST(struct sockaddr *, l3addr), 0, 0, - ifp->if_fib); + bzero(&rt_key, sizeof(rt_key)); + rt_key.sin_len = sizeof(rt_key); + bzero(&rt_mask, sizeof(rt_mask)); + rt_mask.sin_len = sizeof(rt_mask); + bzero(&rt_gateway, sizeof(rt_gateway)); + rt_gateway.sa_len = sizeof(rt_gateway); - if (rt == NULL) + bzero(&info, sizeof(info)); + info.rti_info[RTAX_DST] = (struct sockaddr *)&rt_key; + info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&rt_mask; + info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&rt_gateway; + + if (rib_lookup_info(ifp->if_fib, l3addr, NHR_REF, 0, &info) != 0) return (EINVAL); + rt_flags = info.rti_flags; + /* * If the gateway for an existing host route matches the target L3 * address, which is a special route inserted by some implementation * such as MANET, and the interface is of the correct type, then * allow for ARP to proceed. */ - if (rt->rt_flags & RTF_GATEWAY) { - if (!(rt->rt_flags & RTF_HOST) || !rt->rt_ifp || - rt->rt_ifp->if_type != IFT_ETHER || - (rt->rt_ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) != 0 || - memcmp(rt->rt_gateway->sa_data, l3addr->sa_data, + if (rt_flags & RTF_GATEWAY) { + if (!(rt_flags & RTF_HOST) || !info.rti_ifp || + info.rti_ifp->if_type != IFT_ETHER || + (info.rti_ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) != 0 || + memcmp(rt_gateway.sa_data, l3addr->sa_data, sizeof(in_addr_t)) != 0) { - RTFREE_LOCKED(rt); + rib_free_info(&info); return (EINVAL); } } + rib_free_info(&info); /* * Make sure that at least the destination address is covered @@ -1142,21 +1156,19 @@ in_lltable_rtcheck(struct ifnet *ifp, u_int flags, const struct sockaddr *l3addr * on one interface and the corresponding outgoing packet leaves * another interface. */ - if (!(rt->rt_flags & RTF_HOST) && rt->rt_ifp != ifp) { + if (!(rt_flags & RTF_HOST) && info.rti_ifp != ifp) { const char *sa, *mask, *addr, *lim; int len; - mask = (const char *)rt_mask(rt); + mask = (const char *)&rt_mask; /* * Just being extra cautious to avoid some custom * code getting into trouble. */ - if (mask == NULL) { - RTFREE_LOCKED(rt); + if ((info.rti_addrs & RTA_NETMASK) == 0) return (EINVAL); - } - sa = (const char *)rt_key(rt); + sa = (const char *)&rt_key; addr = (const char *)l3addr; len = ((const struct sockaddr_in *)l3addr)->sin_len; lim = addr + len; @@ -1167,13 +1179,11 @@ in_lltable_rtcheck(struct ifnet *ifp, u_int flags, const struct sockaddr *l3addr log(LOG_INFO, "IPv4 address: \"%s\" is not on the network\n", inet_ntoa(((const struct sockaddr_in *)l3addr)->sin_addr)); #endif - RTFREE_LOCKED(rt); return (EINVAL); } } } - RTFREE_LOCKED(rt); return (0); } diff --git a/sys/netinet/in_fib.c b/sys/netinet/in_fib.c index b4101b6..352c6d0 100644 --- a/sys/netinet/in_fib.c +++ b/sys/netinet/in_fib.c @@ -97,7 +97,10 @@ fib4_rte_to_nh_extended(struct rtentry *rte, struct in_addr dst, struct sockaddr_in *gw; struct in_ifaddr *ia; - pnh4->nh_ifp = rte->rt_ifa->ifa_ifp; + if ((flags & NHR_IFAIF) != 0) + pnh4->nh_ifp = rte->rt_ifa->ifa_ifp; + else + pnh4->nh_ifp = rte->rt_ifp; pnh4->nh_mtu = min(rte->rt_mtu, rte->rt_ifp->if_mtu); if (rte->rt_flags & RTF_GATEWAY) { gw = (struct sockaddr_in *)rte->rt_gateway; @@ -175,8 +178,8 @@ fib4_lookup_nh_basic(uint32_t fibnum, struct in_addr dst, uint32_t flags, * - howewer mtu from "transmit" interface will be returned. */ int -fib4_lookup_nh_ext(uint32_t fibnum, struct in_addr dst, uint32_t flowid, - uint32_t flags, struct nhop4_extended *pnh4) +fib4_lookup_nh_ext(uint32_t fibnum, struct in_addr dst, uint32_t flags, + uint32_t flowid, struct nhop4_extended *pnh4) { struct radix_node_head *rh; struct radix_node *rn; @@ -197,6 +200,13 @@ fib4_lookup_nh_ext(uint32_t fibnum, struct in_addr dst, uint32_t flowid, rn = rh->rnh_matchaddr((void *)&sin, rh); if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) { rte = RNTORT(rn); +#ifdef RADIX_MPATH + rte = rt_mpath_select(rte, flowid); + if (rte == NULL) { + RADIX_NODE_HEAD_RUNLOCK(rh); + return (ENOENT); + } +#endif /* Ensure route & ifp is UP */ if (RT_LINK_IS_UP(rte->rt_ifp)) { fib4_rte_to_nh_extended(rte, dst, flags, pnh4); diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 9454426..ec42e67 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include <sys/malloc.h> #include <sys/mbuf.h> #include <sys/callout.h> +#include <sys/eventhandler.h> #include <sys/domain.h> #include <sys/protosw.h> #include <sys/rmlock.h> diff --git a/sys/netinet/ip_encap.c b/sys/netinet/ip_encap.c index d3d0116..f186fe2 100644 --- a/sys/netinet/ip_encap.c +++ b/sys/netinet/ip_encap.c @@ -65,6 +65,8 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/systm.h> +#include <sys/lock.h> +#include <sys/mutex.h> #include <sys/socket.h> #include <sys/sockio.h> #include <sys/mbuf.h> diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index ffa88ae..9b762d6 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -77,6 +77,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/kernel.h> #include <sys/stddef.h> +#include <sys/eventhandler.h> #include <sys/lock.h> #include <sys/ktr.h> #include <sys/malloc.h> diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 7ad43a2..fa225fc 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -376,6 +376,7 @@ again: ia = ifatoia(rte->rt_ifa); ifp = rte->rt_ifp; counter_u64_add(rte->rt_pksent, 1); + rt_update_ro_flags(ro); if (rte->rt_flags & RTF_GATEWAY) gw = (struct sockaddr_in *)rte->rt_gateway; if (rte->rt_flags & RTF_HOST) diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 4e9feda..2eecb95 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/jail.h> #include <sys/kernel.h> +#include <sys/eventhandler.h> #include <sys/lock.h> #include <sys/malloc.h> #include <sys/mbuf.h> diff --git a/sys/netinet/sctp_structs.h b/sys/netinet/sctp_structs.h index eda99fe..8756650 100644 --- a/sys/netinet/sctp_structs.h +++ b/sys/netinet/sctp_structs.h @@ -189,9 +189,11 @@ struct iterator_control { struct sctp_net_route { sctp_rtentry_t *ro_rt; - void *ro_lle; - void *ro_ia; - int ro_flags; + char *ro_prepend; + uint16_t ro_plen; + uint16_t ro_flags; + uint16_t ro_mtu; + uint16_t spare; union sctp_sockstore _l_addr; /* remote peer addr */ struct sctp_ifa *_s_addr; /* our selected src addr */ }; diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index a763e46..3a979a0 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -290,7 +290,7 @@ cc_ack_received(struct tcpcb *tp, struct tcphdr *th, uint16_t type) if (type == CC_ACK) { if (tp->snd_cwnd > tp->snd_ssthresh) { tp->t_bytes_acked += min(tp->ccv->bytes_this_ack, - V_tcp_abc_l_var * tp->t_maxseg); + V_tcp_abc_l_var * tcp_maxseg(tp)); if (tp->t_bytes_acked >= tp->snd_cwnd) { tp->t_bytes_acked -= tp->snd_cwnd; tp->ccv->flags |= CCF_ABC_SENTAWND; @@ -313,11 +313,13 @@ cc_conn_init(struct tcpcb *tp) { struct hc_metrics_lite metrics; struct inpcb *inp = tp->t_inpcb; + u_int maxseg; int rtt; INP_WLOCK_ASSERT(tp->t_inpcb); tcp_hc_get(&inp->inp_inc, &metrics); + maxseg = tcp_maxseg(tp); if (tp->t_srtt == 0 && (rtt = metrics.rmx_rtt)) { tp->t_srtt = rtt; @@ -342,7 +344,7 @@ cc_conn_init(struct tcpcb *tp) * the slow start threshhold, but set the * threshold to no less than 2*mss. */ - tp->snd_ssthresh = max(2 * tp->t_maxseg, metrics.rmx_ssthresh); + tp->snd_ssthresh = max(2 * maxseg, metrics.rmx_ssthresh); TCPSTAT_INC(tcps_usedssthresh); } @@ -359,21 +361,20 @@ cc_conn_init(struct tcpcb *tp) * requiring us to be cautious. */ if (tp->snd_cwnd == 1) - tp->snd_cwnd = tp->t_maxseg; /* SYN(-ACK) lost */ + tp->snd_cwnd = maxseg; /* SYN(-ACK) lost */ else if (V_tcp_initcwnd_segments) - tp->snd_cwnd = min(V_tcp_initcwnd_segments * tp->t_maxseg, - max(2 * tp->t_maxseg, V_tcp_initcwnd_segments * 1460)); + tp->snd_cwnd = min(V_tcp_initcwnd_segments * maxseg, + max(2 * maxseg, V_tcp_initcwnd_segments * 1460)); else if (V_tcp_do_rfc3390) - tp->snd_cwnd = min(4 * tp->t_maxseg, - max(2 * tp->t_maxseg, 4380)); + tp->snd_cwnd = min(4 * maxseg, max(2 * maxseg, 4380)); else { /* Per RFC5681 Section 3.1 */ - if (tp->t_maxseg > 2190) - tp->snd_cwnd = 2 * tp->t_maxseg; - else if (tp->t_maxseg > 1095) - tp->snd_cwnd = 3 * tp->t_maxseg; + if (maxseg > 2190) + tp->snd_cwnd = 2 * maxseg; + else if (maxseg > 1095) + tp->snd_cwnd = 3 * maxseg; else - tp->snd_cwnd = 4 * tp->t_maxseg; + tp->snd_cwnd = 4 * maxseg; } if (CC_ALGO(tp)->conn_init != NULL) @@ -383,6 +384,8 @@ cc_conn_init(struct tcpcb *tp) void inline cc_cong_signal(struct tcpcb *tp, struct tcphdr *th, uint32_t type) { + u_int maxseg; + INP_WLOCK_ASSERT(tp->t_inpcb); switch(type) { @@ -402,12 +405,13 @@ cc_cong_signal(struct tcpcb *tp, struct tcphdr *th, uint32_t type) } break; case CC_RTO: + maxseg = tcp_maxseg(tp); tp->t_dupacks = 0; tp->t_bytes_acked = 0; EXIT_RECOVERY(tp->t_flags); tp->snd_ssthresh = max(2, min(tp->snd_wnd, tp->snd_cwnd) / 2 / - tp->t_maxseg) * tp->t_maxseg; - tp->snd_cwnd = tp->t_maxseg; + maxseg) * maxseg; + tp->snd_cwnd = maxseg; break; case CC_RTO_ERR: TCPSTAT_INC(tcps_sndrexmitbad); @@ -469,13 +473,11 @@ tcp_signature_verify_input(struct mbuf *m, int off0, int tlen, int optlen, * the ack that opens up a 0-sized window. * - LRO wasn't used for this segment. We make sure by checking that the * segment size is not larger than the MSS. - * - Delayed acks are enabled or this is a half-synchronized T/TCP - * connection. */ #define DELAY_ACK(tp, tlen) \ ((!tcp_timer_active(tp, TT_DELACK) && \ (tp->t_flags & TF_RXWIN0SENT) == 0) && \ - (tlen <= tp->t_maxopd) && \ + (tlen <= tp->t_maxseg) && \ (V_tcp_delack_enabled || (tp->t_flags & TF_NEEDSYN))) static void inline @@ -2481,6 +2483,9 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, hhook_run_tcp_est_in(tp, th, &to); if (SEQ_LEQ(th->th_ack, tp->snd_una)) { + u_int maxseg; + + maxseg = tcp_maxseg(tp); if (tlen == 0 && (tiwin == tp->snd_wnd || (tp->t_flags & TF_SACK_PERMIT))) { @@ -2560,12 +2565,12 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, tp->sackhint.sack_bytes_rexmit; if (awnd < tp->snd_ssthresh) { - tp->snd_cwnd += tp->t_maxseg; + tp->snd_cwnd += maxseg; if (tp->snd_cwnd > tp->snd_ssthresh) tp->snd_cwnd = tp->snd_ssthresh; } } else - tp->snd_cwnd += tp->t_maxseg; + tp->snd_cwnd += maxseg; (void) tp->t_fb->tfb_tcp_output(tp); goto drop; } else if (tp->t_dupacks == tcprexmtthresh) { @@ -2599,18 +2604,18 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, TCPSTAT_INC( tcps_sack_recovery_episode); tp->sack_newdata = tp->snd_nxt; - tp->snd_cwnd = tp->t_maxseg; + tp->snd_cwnd = maxseg; (void) tp->t_fb->tfb_tcp_output(tp); goto drop; } tp->snd_nxt = th->th_ack; - tp->snd_cwnd = tp->t_maxseg; + tp->snd_cwnd = maxseg; (void) tp->t_fb->tfb_tcp_output(tp); KASSERT(tp->snd_limited <= 2, ("%s: tp->snd_limited too big", __func__)); tp->snd_cwnd = tp->snd_ssthresh + - tp->t_maxseg * + maxseg * (tp->t_dupacks - tp->snd_limited); if (SEQ_GT(onxt, tp->snd_nxt)) tp->snd_nxt = onxt; @@ -2641,7 +2646,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, tp->snd_cwnd = (tp->snd_nxt - tp->snd_una) + (tp->t_dupacks - tp->snd_limited) * - tp->t_maxseg; + maxseg; /* * Only call tcp_output when there * is new data available to be sent. @@ -2654,10 +2659,10 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, if (avail > 0) (void) tp->t_fb->tfb_tcp_output(tp); sent = tp->snd_max - oldsndmax; - if (sent > tp->t_maxseg) { + if (sent > maxseg) { KASSERT((tp->t_dupacks == 2 && tp->snd_limited == 0) || - (sent == tp->t_maxseg + 1 && + (sent == maxseg + 1 && tp->t_flags & TF_SENTFIN), ("%s: sent too much", __func__)); @@ -3510,11 +3515,9 @@ tcp_xmit_timer(struct tcpcb *tp, int rtt) * While looking at the routing entry, we also initialize other path-dependent * parameters from pre-set or cached values in the routing entry. * - * Also take into account the space needed for options that we - * send regularly. Make maxseg shorter by that amount to assure - * that we can send maxseg amount of data even when the options - * are present. Store the upper limit of the length of options plus - * data in maxopd. + * NOTE that resulting t_maxseg doesn't include space for TCP options or + * IP options, e.g. IPSEC data, since length of this data may vary, and + * thus it is calculated for every segment separately in tcp_output(). * * NOTE that this routine is only called when we process an incoming * segment, or an ICMP need fragmentation datagram. Outgoing SYN/ACK MSS @@ -3528,7 +3531,6 @@ tcp_mss_update(struct tcpcb *tp, int offer, int mtuoffer, u_long maxmtu = 0; struct inpcb *inp = tp->t_inpcb; struct hc_metrics_lite metrics; - int origoffer; #ifdef INET6 int isipv6 = ((inp->inp_vflag & INP_IPV6) != 0) ? 1 : 0; size_t min_protoh = isipv6 ? @@ -3544,13 +3546,12 @@ tcp_mss_update(struct tcpcb *tp, int offer, int mtuoffer, KASSERT(offer == -1, ("%s: conflict", __func__)); offer = mtuoffer - min_protoh; } - origoffer = offer; /* Initialize. */ #ifdef INET6 if (isipv6) { maxmtu = tcp_maxmtu6(&inp->inp_inc, cap); - tp->t_maxopd = tp->t_maxseg = V_tcp_v6mssdflt; + tp->t_maxseg = V_tcp_v6mssdflt; } #endif #if defined(INET) && defined(INET6) @@ -3559,7 +3560,7 @@ tcp_mss_update(struct tcpcb *tp, int offer, int mtuoffer, #ifdef INET { maxmtu = tcp_maxmtu(&inp->inp_inc, cap); - tp->t_maxopd = tp->t_maxseg = V_tcp_mssdflt; + tp->t_maxseg = V_tcp_mssdflt; } #endif @@ -3583,9 +3584,9 @@ tcp_mss_update(struct tcpcb *tp, int offer, int mtuoffer, /* * Offer == 0 means that there was no MSS on the SYN * segment, in this case we use tcp_mssdflt as - * already assigned to t_maxopd above. + * already assigned to t_maxseg above. */ - offer = tp->t_maxopd; + offer = tp->t_maxseg; break; case -1: @@ -3657,31 +3658,15 @@ tcp_mss_update(struct tcpcb *tp, int offer, int mtuoffer, mss = min(mss, offer); /* - * Sanity check: make sure that maxopd will be large + * Sanity check: make sure that maxseg will be large * enough to allow some data on segments even if the * all the option space is used (40bytes). Otherwise * funny things may happen in tcp_output. + * + * XXXGL: shouldn't we reserve space for IP/IPv6 options? */ mss = max(mss, 64); - /* - * maxopd stores the maximum length of data AND options - * in a segment; maxseg is the amount of data in a normal - * segment. We need to store this value (maxopd) apart - * from maxseg, because now every segment carries options - * and thus we normally have somewhat less data in segments. - */ - tp->t_maxopd = mss; - - /* - * origoffer==-1 indicates that no segments were received yet. - * In this case we just guess. - */ - if ((tp->t_flags & (TF_REQ_TSTMP|TF_NOOPT)) == TF_REQ_TSTMP && - (origoffer == -1 || - (tp->t_flags & TF_RCVD_TSTMP) == TF_RCVD_TSTMP)) - mss -= TCPOLEN_TSTAMP_APPA; - tp->t_maxseg = mss; } @@ -3804,7 +3789,8 @@ void tcp_newreno_partial_ack(struct tcpcb *tp, struct tcphdr *th) { tcp_seq onxt = tp->snd_nxt; - u_long ocwnd = tp->snd_cwnd; + u_long ocwnd = tp->snd_cwnd; + u_int maxseg = tcp_maxseg(tp); INP_WLOCK_ASSERT(tp->t_inpcb); @@ -3815,7 +3801,7 @@ tcp_newreno_partial_ack(struct tcpcb *tp, struct tcphdr *th) * Set snd_cwnd to one segment beyond acknowledged offset. * (tp->snd_una has not yet been updated when this function is called.) */ - tp->snd_cwnd = tp->t_maxseg + BYTES_THIS_ACK(tp, th); + tp->snd_cwnd = maxseg + BYTES_THIS_ACK(tp, th); tp->t_flags |= TF_ACKNOW; (void) tp->t_fb->tfb_tcp_output(tp); tp->snd_cwnd = ocwnd; @@ -3829,7 +3815,7 @@ tcp_newreno_partial_ack(struct tcpcb *tp, struct tcphdr *th) tp->snd_cwnd -= BYTES_THIS_ACK(tp, th); else tp->snd_cwnd = 0; - tp->snd_cwnd += tp->t_maxseg; + tp->snd_cwnd += maxseg; } int diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index 482ead5..3c32d77 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -830,11 +830,11 @@ send: /* * Adjust data length if insertion of options will - * bump the packet length beyond the t_maxopd length. + * bump the packet length beyond the t_maxseg length. * Clear the FIN bit because we cut off the tail of * the segment. */ - if (len + optlen + ipoptlen > tp->t_maxopd) { + if (len + optlen + ipoptlen > tp->t_maxseg) { flags &= ~TH_FIN; if (tso) { @@ -937,7 +937,7 @@ send: * fractional unless the send sockbuf can be * emptied: */ - max_len = (tp->t_maxopd - optlen); + max_len = (tp->t_maxseg - optlen); if ((off + len) < sbavail(&so->so_snd)) { moff = len % max_len; if (moff != 0) { @@ -967,7 +967,7 @@ send: sendalot = 1; } else { - len = tp->t_maxopd - optlen - ipoptlen; + len = tp->t_maxseg - optlen - ipoptlen; sendalot = 1; } } else @@ -1277,10 +1277,10 @@ send: * The TCP pseudo header checksum is always provided. */ if (tso) { - KASSERT(len > tp->t_maxopd - optlen, + KASSERT(len > tp->t_maxseg - optlen, ("%s: len <= tso_segsz", __func__)); m->m_pkthdr.csum_flags |= CSUM_TSO; - m->m_pkthdr.tso_segsz = tp->t_maxopd - optlen; + m->m_pkthdr.tso_segsz = tp->t_maxseg - optlen; } #ifdef IPSEC @@ -1348,7 +1348,7 @@ send: */ ip6->ip6_plen = htons(m->m_pkthdr.len - sizeof(*ip6)); - if (V_path_mtu_discovery && tp->t_maxopd > V_tcp_minmss) + if (V_path_mtu_discovery && tp->t_maxseg > V_tcp_minmss) tp->t_flags2 |= TF2_PLPMTU_PMTUD; else tp->t_flags2 &= ~TF2_PLPMTU_PMTUD; @@ -1394,7 +1394,7 @@ send: * * NB: Don't set DF on small MTU/MSS to have a safe fallback. */ - if (V_path_mtu_discovery && tp->t_maxopd > V_tcp_minmss) { + if (V_path_mtu_discovery && tp->t_maxseg > V_tcp_minmss) { ip->ip_off |= htons(IP_DF); tp->t_flags2 |= TF2_PLPMTU_PMTUD; } else { diff --git a/sys/netinet/tcp_reass.c b/sys/netinet/tcp_reass.c index 4677154..a22fb30 100644 --- a/sys/netinet/tcp_reass.c +++ b/sys/netinet/tcp_reass.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/kernel.h> +#include <sys/eventhandler.h> #include <sys/malloc.h> #include <sys/mbuf.h> #include <sys/socket.h> diff --git a/sys/netinet/tcp_stacks/fastpath.c b/sys/netinet/tcp_stacks/fastpath.c index 85b24f6..a49f85b 100644 --- a/sys/netinet/tcp_stacks/fastpath.c +++ b/sys/netinet/tcp_stacks/fastpath.c @@ -158,13 +158,11 @@ static void tcp_do_segment_fastack(struct mbuf *, struct tcphdr *, * the ack that opens up a 0-sized window. * - LRO wasn't used for this segment. We make sure by checking that the * segment size is not larger than the MSS. - * - Delayed acks are enabled or this is a half-synchronized T/TCP - * connection. */ #define DELAY_ACK(tp, tlen) \ ((!tcp_timer_active(tp, TT_DELACK) && \ (tp->t_flags & TF_RXWIN0SENT) == 0) && \ - (tlen <= tp->t_maxopd) && \ + (tlen <= tp->t_maxseg) && \ (V_tcp_delack_enabled || (tp->t_flags & TF_NEEDSYN))) /* diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index c2e0696..d68a8a6 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/systm.h> #include <sys/callout.h> +#include <sys/eventhandler.h> #include <sys/hhook.h> #include <sys/kernel.h> #include <sys/khelp.h> @@ -1087,7 +1088,7 @@ tcp_newtcpcb(struct inpcb *inp) #endif tp->t_timers = &tm->tt; /* LIST_INIT(&tp->t_segq); */ /* XXX covered by M_ZERO */ - tp->t_maxseg = tp->t_maxopd = + tp->t_maxseg = #ifdef INET6 isipv6 ? V_tcp_v6mssdflt : #endif /* INET6 */ @@ -1901,7 +1902,7 @@ tcp_ctlinput(int cmd, struct sockaddr *sa, void *vip) * Only process the offered MTU if it * is smaller than the current one. */ - if (mtu < tp->t_maxopd + + if (mtu < tp->t_maxseg + sizeof(struct tcpiphdr)) { bzero(&inc, sizeof(inc)); inc.inc_faddr = faddr; @@ -2283,6 +2284,59 @@ tcp_maxmtu6(struct in_conninfo *inc, struct tcp_ifcap *cap) } #endif /* INET6 */ +/* + * Calculate effective SMSS per RFC5681 definition for a given TCP + * connection at its current state, taking into account SACK and etc. + */ +u_int +tcp_maxseg(const struct tcpcb *tp) +{ + u_int optlen; + + if (tp->t_flags & TF_NOOPT) + return (tp->t_maxseg); + + /* + * Here we have a simplified code from tcp_addoptions(), + * without a proper loop, and having most of paddings hardcoded. + * We might make mistakes with padding here in some edge cases, + * but this is harmless, since result of tcp_maxseg() is used + * only in cwnd and ssthresh estimations. + */ +#define PAD(len) ((((len) / 4) + !!((len) % 4)) * 4) + if (TCPS_HAVEESTABLISHED(tp->t_state)) { + if (tp->t_flags & TF_RCVD_TSTMP) + optlen = TCPOLEN_TSTAMP_APPA; + else + optlen = 0; +#ifdef TCP_SIGNATURE + if (tp->t_flags & TF_SIGNATURE) + optlen += PAD(TCPOLEN_SIGNATURE); +#endif + if ((tp->t_flags & TF_SACK_PERMIT) && tp->rcv_numsacks > 0) { + optlen += TCPOLEN_SACKHDR; + optlen += tp->rcv_numsacks * TCPOLEN_SACK; + optlen = PAD(optlen); + } + } else { + if (tp->t_flags & TF_REQ_TSTMP) + optlen = TCPOLEN_TSTAMP_APPA; + else + optlen = PAD(TCPOLEN_MAXSEG); + if (tp->t_flags & TF_REQ_SCALE) + optlen += PAD(TCPOLEN_WINDOW); +#ifdef TCP_SIGNATURE + if (tp->t_flags & TF_SIGNATURE) + optlen += PAD(TCPOLEN_SIGNATURE); +#endif + if (tp->t_flags & TF_SACK_PERMIT) + optlen += PAD(TCPOLEN_SACK_PERMITTED); + } +#undef PAD + optlen = min(optlen, TCP_MAXOLEN); + return (tp->t_maxseg - optlen); +} + #ifdef IPSEC /* compute ESP/AH header size for TCP, including outer IP header. */ size_t diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index 9767eb7..fb4ff11 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -660,7 +660,6 @@ tcp_timer_rexmt(void * xtp) */ if (V_tcp_pmtud_blackhole_detect && (((tp->t_state == TCPS_ESTABLISHED)) || (tp->t_state == TCPS_FIN_WAIT_1))) { - int optlen; #ifdef INET6 int isipv6; #endif @@ -684,8 +683,7 @@ tcp_timer_rexmt(void * xtp) tp->t_flags2 |= TF2_PLPMTU_BLACKHOLE; /* Keep track of previous MSS. */ - optlen = tp->t_maxopd - tp->t_maxseg; - tp->t_pmtud_saved_maxopd = tp->t_maxopd; + tp->t_pmtud_saved_maxseg = tp->t_maxseg; /* * Reduce the MSS to blackhole value or to the default @@ -694,13 +692,13 @@ tcp_timer_rexmt(void * xtp) #ifdef INET6 isipv6 = (tp->t_inpcb->inp_vflag & INP_IPV6) ? 1 : 0; if (isipv6 && - tp->t_maxopd > V_tcp_v6pmtud_blackhole_mss) { + tp->t_maxseg > V_tcp_v6pmtud_blackhole_mss) { /* Use the sysctl tuneable blackhole MSS. */ - tp->t_maxopd = V_tcp_v6pmtud_blackhole_mss; + tp->t_maxseg = V_tcp_v6pmtud_blackhole_mss; V_tcp_pmtud_blackhole_activated++; } else if (isipv6) { /* Use the default MSS. */ - tp->t_maxopd = V_tcp_v6mssdflt; + tp->t_maxseg = V_tcp_v6mssdflt; /* * Disable Path MTU Discovery when we switch to * minmss. @@ -713,13 +711,13 @@ tcp_timer_rexmt(void * xtp) else #endif #ifdef INET - if (tp->t_maxopd > V_tcp_pmtud_blackhole_mss) { + if (tp->t_maxseg > V_tcp_pmtud_blackhole_mss) { /* Use the sysctl tuneable blackhole MSS. */ - tp->t_maxopd = V_tcp_pmtud_blackhole_mss; + tp->t_maxseg = V_tcp_pmtud_blackhole_mss; V_tcp_pmtud_blackhole_activated++; } else { /* Use the default MSS. */ - tp->t_maxopd = V_tcp_mssdflt; + tp->t_maxseg = V_tcp_mssdflt; /* * Disable Path MTU Discovery when we switch to * minmss. @@ -728,7 +726,6 @@ tcp_timer_rexmt(void * xtp) V_tcp_pmtud_blackhole_activated_min_mss++; } #endif - tp->t_maxseg = tp->t_maxopd - optlen; /* * Reset the slow-start flight size * as it may depend on the new MSS. @@ -748,9 +745,7 @@ tcp_timer_rexmt(void * xtp) (tp->t_rxtshift > 6)) { tp->t_flags2 |= TF2_PLPMTU_PMTUD; tp->t_flags2 &= ~TF2_PLPMTU_BLACKHOLE; - optlen = tp->t_maxopd - tp->t_maxseg; - tp->t_maxopd = tp->t_pmtud_saved_maxopd; - tp->t_maxseg = tp->t_maxopd - optlen; + tp->t_maxseg = tp->t_pmtud_saved_maxseg; V_tcp_pmtud_blackhole_failed++; /* * Reset the slow-start flight size as it diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 3435668..76bc8aa 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -904,8 +904,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, /* * Do implied connect if not yet connected, * initialize window to default value, and - * initialize maxseg/maxopd using peer's cached - * MSS. + * initialize maxseg using peer's cached MSS. */ #ifdef INET6 if (isipv6) @@ -964,8 +963,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, /* * Do implied connect if not yet connected, * initialize window to default value, and - * initialize maxseg/maxopd using peer's cached - * MSS. + * initialize maxseg using peer's cached MSS. */ #ifdef INET6 if (isipv6) @@ -2208,8 +2206,8 @@ db_print_tcpcb(struct tcpcb *tp, const char *name, int indent) "0x%08x\n", tp->snd_ssthresh, tp->snd_recover); db_print_indent(indent); - db_printf("t_maxopd: %u t_rcvtime: %u t_startime: %u\n", - tp->t_maxopd, tp->t_rcvtime, tp->t_starttime); + db_printf("t_rcvtime: %u t_startime: %u\n", + tp->t_rcvtime, tp->t_starttime); db_print_indent(indent); db_printf("t_rttime: %u t_rtsq: 0x%08x\n", diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 8d76912..6cd4cf0 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -180,8 +180,6 @@ struct tcpcb { u_long snd_spare2; /* unused */ tcp_seq snd_recover; /* for use in NewReno Fast Recovery */ - u_int t_maxopd; /* mss plus options */ - u_int t_rcvtime; /* inactivity time */ u_int t_starttime; /* time connection was established */ u_int t_rtttime; /* RTT measurement start time */ @@ -192,6 +190,7 @@ struct tcpcb { int t_rxtcur; /* current retransmit value (ticks) */ u_int t_maxseg; /* maximum segment size */ + u_int t_pmtud_saved_maxseg; /* pre-blackhole MSS */ int t_srtt; /* smoothed round-trip time */ int t_rttvar; /* variance in round-trip time */ @@ -251,7 +250,6 @@ struct tcpcb { u_int t_tsomax; /* TSO total burst length limit in bytes */ u_int t_tsomaxsegcount; /* TSO maximum segment count */ u_int t_tsomaxsegsize; /* TSO maximum segment size in bytes */ - u_int t_pmtud_saved_maxopd; /* pre-blackhole MSS */ u_int t_flags2; /* More tcpcb flags storage */ #if defined(_KERNEL) && defined(TCP_RFC7413) uint32_t t_ispare[6]; /* 5 UTO, 1 TBD */ @@ -775,6 +773,7 @@ int tcp_default_ctloutput(struct socket *so, struct sockopt *sopt, struct inpcb u_long tcp_maxmtu(struct in_conninfo *, struct tcp_ifcap *); u_long tcp_maxmtu6(struct in_conninfo *, struct tcp_ifcap *); +u_int tcp_maxseg(const struct tcpcb *); void tcp_mss_update(struct tcpcb *, int, int, struct hc_metrics_lite *, struct tcp_ifcap *); void tcp_mss(struct tcpcb *, int); diff --git a/sys/netinet/toecore.c b/sys/netinet/toecore.c index 6ed8eb0..cfa77e7 100644 --- a/sys/netinet/toecore.c +++ b/sys/netinet/toecore.c @@ -70,7 +70,6 @@ static TAILQ_HEAD(, toedev) toedev_list; static eventhandler_tag listen_start_eh; static eventhandler_tag listen_stop_eh; static eventhandler_tag lle_event_eh; -static eventhandler_tag route_redirect_eh; static int toedev_connect(struct toedev *tod __unused, struct socket *so __unused, @@ -438,17 +437,6 @@ toe_lle_event(void *arg __unused, struct llentry *lle, int evt) } /* - * XXX: implement. - */ -static void -toe_route_redirect_event(void *arg __unused, struct rtentry *rt0, - struct rtentry *rt1, struct sockaddr *sa) -{ - - return; -} - -/* * Returns 0 or EWOULDBLOCK on success (any other value is an error). 0 means * lladdr and vtag are valid on return, EWOULDBLOCK means the TOE driver's * tod_l2_update will be called later, when the entry is resolved or times out. @@ -534,8 +522,6 @@ toecore_load(void) toe_listen_stop_event, NULL, EVENTHANDLER_PRI_ANY); lle_event_eh = EVENTHANDLER_REGISTER(lle_event, toe_lle_event, NULL, EVENTHANDLER_PRI_ANY); - route_redirect_eh = EVENTHANDLER_REGISTER(route_redirect_event, - toe_route_redirect_event, NULL, EVENTHANDLER_PRI_ANY); return (0); } @@ -553,7 +539,6 @@ toecore_unload(void) EVENTHANDLER_DEREGISTER(tcp_offload_listen_start, listen_start_eh); EVENTHANDLER_DEREGISTER(tcp_offload_listen_stop, listen_stop_eh); EVENTHANDLER_DEREGISTER(lle_event, lle_event_eh); - EVENTHANDLER_DEREGISTER(route_redirect_event, route_redirect_eh); mtx_unlock(&toedev_lock); mtx_destroy(&toedev_lock); diff --git a/sys/netinet6/frag6.c b/sys/netinet6/frag6.c index 2f2b869..a2f6635 100644 --- a/sys/netinet6/frag6.c +++ b/sys/netinet6/frag6.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include <sys/malloc.h> #include <sys/mbuf.h> #include <sys/domain.h> +#include <sys/eventhandler.h> #include <sys/protosw.h> #include <sys/socket.h> #include <sys/errno.h> diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index a7bbac0..dd77527 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -2114,13 +2114,13 @@ icmp6_rip6_input(struct mbuf **mp, int off) void icmp6_reflect(struct mbuf *m, size_t off) { - struct in6_addr src, *srcp = NULL; + struct in6_addr src6, *srcp; struct ip6_hdr *ip6; struct icmp6_hdr *icmp6; struct in6_ifaddr *ia = NULL; struct ifnet *outif = NULL; int plen; - int type, code; + int type, code, hlim; /* too short to reflect */ if (off < sizeof(struct ip6_hdr)) { @@ -2166,6 +2166,8 @@ icmp6_reflect(struct mbuf *m, size_t off) icmp6 = (struct icmp6_hdr *)(ip6 + 1); type = icmp6->icmp6_type; /* keep type for statistics */ code = icmp6->icmp6_code; /* ditto. */ + hlim = 0; + srcp = NULL; /* * If the incoming packet was addressed directly to us (i.e. unicast), @@ -2177,38 +2179,43 @@ icmp6_reflect(struct mbuf *m, size_t off) if (!IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) { ia = in6ifa_ifwithaddr(&ip6->ip6_dst, 0 /* XXX */); if (ia != NULL && !(ia->ia6_flags & - (IN6_IFF_ANYCAST|IN6_IFF_NOTREADY))) - srcp = &ia->ia_addr.sin6_addr; + (IN6_IFF_ANYCAST|IN6_IFF_NOTREADY))) { + src6 = ia->ia_addr.sin6_addr; + srcp = &src6; + + if (m->m_pkthdr.rcvif != NULL) { + /* XXX: This may not be the outgoing interface */ + hlim = ND_IFINFO(m->m_pkthdr.rcvif)->chlim; + } else + hlim = V_ip6_defhlim; + } + if (ia != NULL) + ifa_free(&ia->ia_ifa); } if (srcp == NULL) { - int e; - struct sockaddr_in6 sin6; - struct route_in6 ro; + int error; + struct in6_addr dst6; + uint32_t scopeid; /* * This case matches to multicasts, our anycast, or unicasts * that we do not own. Select a source address based on the * source address of the erroneous packet. */ - bzero(&sin6, sizeof(sin6)); - sin6.sin6_family = AF_INET6; - sin6.sin6_len = sizeof(sin6); - sin6.sin6_addr = ip6->ip6_dst; /* zone ID should be embedded */ - - bzero(&ro, sizeof(ro)); - e = in6_selectsrc(&sin6, NULL, NULL, &ro, NULL, &outif, &src); - if (ro.ro_rt) - RTFREE(ro.ro_rt); /* XXX: we could use this */ - if (e) { + in6_splitscope(&ip6->ip6_dst, &dst6, &scopeid); + error = in6_selectsrc_addr(RT_DEFAULT_FIB, &dst6, + scopeid, NULL, &src6, &hlim); + + if (error) { char ip6buf[INET6_ADDRSTRLEN]; nd6log((LOG_DEBUG, "icmp6_reflect: source can't be determined: " "dst=%s, error=%d\n", - ip6_sprintf(ip6buf, &sin6.sin6_addr), e)); + ip6_sprintf(ip6buf, &ip6->ip6_dst), error)); goto bad; } - srcp = &src; + srcp = &src6; } /* * ip6_input() drops a packet if its src is multicast. @@ -2220,13 +2227,7 @@ icmp6_reflect(struct mbuf *m, size_t off) ip6->ip6_vfc &= ~IPV6_VERSION_MASK; ip6->ip6_vfc |= IPV6_VERSION; ip6->ip6_nxt = IPPROTO_ICMPV6; - if (outif) - ip6->ip6_hlim = ND_IFINFO(outif)->chlim; - else if (m->m_pkthdr.rcvif) { - /* XXX: This may not be the outgoing interface */ - ip6->ip6_hlim = ND_IFINFO(m->m_pkthdr.rcvif)->chlim; - } else - ip6->ip6_hlim = V_ip6_defhlim; + ip6->ip6_hlim = hlim; icmp6->icmp6_cksum = 0; icmp6->icmp6_cksum = in6_cksum(m, IPPROTO_ICMPV6, @@ -2242,13 +2243,9 @@ icmp6_reflect(struct mbuf *m, size_t off) if (outif) icmp6_ifoutstat_inc(outif, type, code); - if (ia != NULL) - ifa_free(&ia->ia_ifa); return; bad: - if (ia != NULL) - ifa_free(&ia->ia_ifa); m_freem(m); return; } diff --git a/sys/netinet6/in6.h b/sys/netinet6/in6.h index 9bc142a..ae049f0 100644 --- a/sys/netinet6/in6.h +++ b/sys/netinet6/in6.h @@ -378,6 +378,8 @@ struct route_in6 { char *ro_prepend; uint16_t ro_plen; uint16_t ro_flags; + uint16_t ro_mtu; /* saved ro_rt mtu */ + uint16_t spare; struct sockaddr_in6 ro_dst; }; #endif diff --git a/sys/netinet6/in6_fib.c b/sys/netinet6/in6_fib.c index eba5b7c..96acfbb 100644 --- a/sys/netinet6/in6_fib.c +++ b/sys/netinet6/in6_fib.c @@ -241,6 +241,13 @@ fib6_lookup_nh_ext(uint32_t fibnum, const struct in6_addr *dst,uint32_t scopeid, rn = rh->rnh_matchaddr((void *)&sin6, rh); if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) { rte = RNTORT(rn); +#ifdef RADIX_MPATH + rte = rt_mpath_select(rte, flowid); + if (rte == NULL) { + RADIX_NODE_HEAD_RUNLOCK(rh); + return (ENOENT); + } +#endif /* Ensure route & ifp is UP */ if (RT_LINK_IS_UP(rte->rt_ifp)) { fib6_rte_to_nh_extended(rte, &sin6.sin6_addr, flags, diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 9f876a4..a779b8d 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -328,7 +328,6 @@ in6_pcbladdr(register struct inpcb *inp, struct sockaddr *nam, { register struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam; int error = 0; - struct ifnet *ifp = NULL; int scope_ambiguous = 0; struct in6_addr in6a; @@ -358,20 +357,15 @@ in6_pcbladdr(register struct inpcb *inp, struct sockaddr *nam, if ((error = prison_remote_ip6(inp->inp_cred, &sin6->sin6_addr)) != 0) return (error); - error = in6_selectsrc(sin6, inp->in6p_outputopts, - inp, NULL, inp->inp_cred, &ifp, &in6a); + error = in6_selectsrc_socket(sin6, inp->in6p_outputopts, + inp, inp->inp_cred, scope_ambiguous, &in6a, NULL); if (error) return (error); - if (ifp && scope_ambiguous && - (error = in6_setscope(&sin6->sin6_addr, ifp, NULL)) != 0) { - return(error); - } - /* * Do not update this earlier, in case we return with an error. * - * XXX: this in6_selectsrc result might replace the bound local + * XXX: this in6_selectsrc_socket result might replace the bound local * address with the address specified by setsockopt(IPV6_PKTINFO). * Is it the intended behavior? */ diff --git a/sys/netinet6/in6_rmx.c b/sys/netinet6/in6_rmx.c index 97e12162..93c786c 100644 --- a/sys/netinet6/in6_rmx.c +++ b/sys/netinet6/in6_rmx.c @@ -107,7 +107,6 @@ in6_addroute(void *v_arg, void *n_arg, struct radix_node_head *head, { struct rtentry *rt = (struct rtentry *)treenodes; struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)rt_key(rt); - struct radix_node *ret; RADIX_NODE_HEAD_WLOCK_ASSERT(head); if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) @@ -148,34 +147,7 @@ in6_addroute(void *v_arg, void *n_arg, struct radix_node_head *head, rt->rt_mtu = IN6_LINKMTU(rt->rt_ifp); } - ret = rn_addroute(v_arg, n_arg, head, treenodes); - if (ret == NULL) { - struct rtentry *rt2; - /* - * We are trying to add a net route, but can't. - * The following case should be allowed, so we'll make a - * special check for this: - * Two IPv6 addresses with the same prefix is assigned - * to a single interrface. - * # ifconfig if0 inet6 3ffe:0501::1 prefix 64 alias (*1) - * # ifconfig if0 inet6 3ffe:0501::2 prefix 64 alias (*2) - * In this case, (*1) and (*2) want to add the same - * net route entry, 3ffe:0501:: -> if0. - * This case should not raise an error. - */ - rt2 = in6_rtalloc1((struct sockaddr *)sin6, 0, RTF_RNH_LOCKED, - rt->rt_fibnum); - if (rt2) { - if (((rt2->rt_flags & (RTF_HOST|RTF_GATEWAY)) == 0) - && rt2->rt_gateway - && rt2->rt_gateway->sa_family == AF_LINK - && rt2->rt_ifp == rt->rt_ifp) { - ret = rt2->rt_nodes; - } - RTFREE_LOCKED(rt2); - } - } - return (ret); + return (rn_addroute(v_arg, n_arg, head, treenodes)); } /* diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c index c2e26f8f..4029402 100644 --- a/sys/netinet6/in6_src.c +++ b/sys/netinet6/in6_src.c @@ -134,8 +134,11 @@ static int selectroute(struct sockaddr_in6 *, struct ip6_pktopts *, struct ip6_moptions *, struct route_in6 *, struct ifnet **, struct rtentry **, int, u_int); static int in6_selectif(struct sockaddr_in6 *, struct ip6_pktopts *, - struct ip6_moptions *, struct route_in6 *ro, struct ifnet **, + struct ip6_moptions *, struct ifnet **, struct ifnet *, u_int); +static int in6_selectsrc(uint32_t, struct sockaddr_in6 *, + struct ip6_pktopts *, struct inpcb *, struct ucred *, + struct ifnet **, struct in6_addr *); static struct in6_addrpolicy *lookup_addrsel_policy(struct sockaddr_in6 *); @@ -175,9 +178,9 @@ static struct in6_addrpolicy *match_addrsel_policy(struct sockaddr_in6 *); goto out; /* XXX: we can't use 'break' here */ \ } while(0) -int -in6_selectsrc(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, - struct inpcb *inp, struct route_in6 *ro, struct ucred *cred, +static int +in6_selectsrc(uint32_t fibnum, struct sockaddr_in6 *dstsock, + struct ip6_pktopts *opts, struct inpcb *inp, struct ucred *cred, struct ifnet **ifpp, struct in6_addr *srcp) { struct rm_priotracker in6_ifa_tracker; @@ -227,8 +230,8 @@ in6_selectsrc(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, struct in6_ifaddr *ia6; /* get the outgoing interface */ - if ((error = in6_selectif(dstsock, opts, mopts, ro, &ifp, oifp, - (inp != NULL) ? inp->inp_inc.inc_fibnum : RT_DEFAULT_FIB)) + if ((error = in6_selectif(dstsock, opts, mopts, &ifp, oifp, + fibnum)) != 0) return (error); @@ -293,7 +296,7 @@ in6_selectsrc(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, * the outgoing interface and the destination address. */ /* get the outgoing interface */ - if ((error = in6_selectif(dstsock, opts, mopts, ro, &ifp, oifp, + if ((error = in6_selectif(dstsock, opts, mopts, &ifp, oifp, (inp != NULL) ? inp->inp_inc.inc_fibnum : RT_DEFAULT_FIB)) != 0) return (error); @@ -545,6 +548,79 @@ in6_selectsrc(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, } /* + * Select source address based on @inp, @dstsock and @opts. + * Stores selected address to @srcp. If @scope_ambiguous is set, + * embed scope from selected outgoing interface. If @hlim pointer + * is provided, stores calculated hop limit there. + * Returns 0 on success. + */ +int +in6_selectsrc_socket(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, + struct inpcb *inp, struct ucred *cred, int scope_ambiguous, + struct in6_addr *srcp, int *hlim) +{ + struct ifnet *retifp; + uint32_t fibnum; + int error; + + fibnum = (inp != NULL) ? inp->inp_inc.inc_fibnum : RT_DEFAULT_FIB; + retifp = NULL; + + error = in6_selectsrc(fibnum, dstsock, opts, inp, cred, &retifp, srcp); + if (error != 0) + return (error); + + if (hlim != NULL) + *hlim = in6_selecthlim(inp, retifp); + + if (retifp == NULL || scope_ambiguous == 0) + return (0); + + /* + * Application should provide a proper zone ID or the use of + * default zone IDs should be enabled. Unfortunately, some + * applications do not behave as it should, so we need a + * workaround. Even if an appropriate ID is not determined + * (when it's required), if we can determine the outgoing + * interface. determine the zone ID based on the interface. + */ + error = in6_setscope(&dstsock->sin6_addr, retifp, NULL); + + return (error); +} + +/* + * Select source address based on @fibnum, @dst and @scopeid. + * Stores selected address to @srcp. + * Returns 0 on success. + * + * Used by non-socket based consumers (ND code mostly) + */ +int +in6_selectsrc_addr(uint32_t fibnum, const struct in6_addr *dst, + uint32_t scopeid, struct ifnet *ifp, struct in6_addr *srcp, + int *hlim) +{ + struct ifnet *retifp; + struct sockaddr_in6 dst_sa; + int error; + + retifp = ifp; + bzero(&dst_sa, sizeof(dst_sa)); + dst_sa.sin6_family = AF_INET6; + dst_sa.sin6_len = sizeof(dst_sa); + dst_sa.sin6_addr = *dst; + dst_sa.sin6_scope_id = scopeid; + sa6_embedscope(&dst_sa, 0); + + error = in6_selectsrc(fibnum, &dst_sa, NULL, NULL, NULL, &retifp, srcp); + if (hlim != NULL) + *hlim = in6_selecthlim(NULL, retifp); + + return (error); +} + +/* * clone - meaningful only for bsdi and freebsd */ static int @@ -761,24 +837,27 @@ selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, static int in6_selectif(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, - struct ip6_moptions *mopts, struct route_in6 *ro, struct ifnet **retifp, + struct ip6_moptions *mopts, struct ifnet **retifp, struct ifnet *oifp, u_int fibnum) { int error; struct route_in6 sro; struct rtentry *rt = NULL; + int rt_flags; KASSERT(retifp != NULL, ("%s: retifp is NULL", __func__)); - if (ro == NULL) { - bzero(&sro, sizeof(sro)); - ro = &sro; - } + bzero(&sro, sizeof(sro)); + rt_flags = 0; + + error = selectroute(dstsock, opts, mopts, &sro, retifp, &rt, 1, fibnum); - if ((error = selectroute(dstsock, opts, mopts, ro, retifp, - &rt, 1, fibnum)) != 0) { - if (ro == &sro && rt && rt == sro.ro_rt) - RTFREE(rt); + if (rt) + rt_flags = rt->rt_flags; + if (rt && rt == sro.ro_rt) + RTFREE(rt); + + if (error != 0) { /* Help ND. See oifp comment in in6_selectsrc(). */ if (oifp != NULL && fibnum == RT_DEFAULT_FIB) { *retifp = oifp; @@ -804,16 +883,12 @@ in6_selectif(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, * Although this may not be very harmful, it should still be confusing. * We thus reject the case here. */ - if (rt && (rt->rt_flags & (RTF_REJECT | RTF_BLACKHOLE))) { - int flags = (rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH); - if (ro == &sro && rt && rt == sro.ro_rt) - RTFREE(rt); - return (flags); + if (rt_flags & (RTF_REJECT | RTF_BLACKHOLE)) { + error = (rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH); + return (error); } - if (ro == &sro && rt && rt == sro.ro_rt) - RTFREE(rt); return (0); } diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index af9fdba..ccbac7d 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -97,6 +97,7 @@ __FBSDID("$FreeBSD$"); #include <netinet/in.h> #include <netinet/in_var.h> #include <netinet/ip_var.h> +#include <netinet6/in6_fib.h> #include <netinet6/in6_var.h> #include <netinet/ip6.h> #include <netinet/icmp6.h> @@ -147,8 +148,11 @@ static int ip6_insertfraghdr(struct mbuf *, struct mbuf *, int, struct ip6_frag **); static int ip6_insert_jumboopt(struct ip6_exthdrs *, u_int32_t); static int ip6_splithdr(struct mbuf *, struct ip6_exthdrs *); -static int ip6_getpmtu(struct route_in6 *, struct route_in6 *, +static int ip6_getpmtu(struct route_in6 *, int, struct ifnet *, struct in6_addr *, u_long *, int *, u_int); +static int ip6_calcmtu(struct ifnet *, const struct in6_addr *, u_long, + u_long *, int *); +static int ip6_getpmtu_ctl(u_int, struct in6_addr *, u_long *); static int copypktopts(struct ip6_pktopts *, struct ip6_pktopts *, int); @@ -712,7 +716,7 @@ again: *ifpp = ifp; /* Determine path MTU. */ - if ((error = ip6_getpmtu(ro_pmtu, ro, ifp, &finaldst, &mtu, + if ((error = ip6_getpmtu(ro_pmtu, ro != ro_pmtu, ifp, &finaldst, &mtu, &alwaysfrag, fibnum)) != 0) goto bad; @@ -1045,8 +1049,6 @@ sendorfree: done: if (ro == &ip6route) RO_RTFREE(ro); - if (ro_pmtu == &ip6route) - RO_RTFREE(ro_pmtu); return (error); freehdrs: @@ -1215,35 +1217,105 @@ ip6_insertfraghdr(struct mbuf *m0, struct mbuf *m, int hlen, return (0); } +/* + * Calculates IPv6 path mtu for destination @dst. + * Resulting MTU is stored in @mtup. + * + * Returns 0 on success. + */ +static int +ip6_getpmtu_ctl(u_int fibnum, struct in6_addr *dst, u_long *mtup) +{ + struct nhop6_extended nh6; + struct in6_addr kdst; + uint32_t scopeid; + struct ifnet *ifp; + u_long mtu; + int error; + + in6_splitscope(dst, &kdst, &scopeid); + if (fib6_lookup_nh_ext(fibnum, &kdst, scopeid, NHR_REF, 0, &nh6) != 0) + return (EHOSTUNREACH); + + ifp = nh6.nh_ifp; + mtu = nh6.nh_mtu; + + error = ip6_calcmtu(ifp, dst, mtu, mtup, NULL); + fib6_free_nh_ext(fibnum, &nh6); + + return (error); +} + +/* + * Calculates IPv6 path MTU for @dst based on transmit @ifp, + * and cached data in @ro_pmtu. + * MTU from (successful) route lookup is saved (along with dst) + * inside @ro_pmtu to avoid subsequent route lookups after packet + * filter processing. + * + * Stores mtu and always-frag value into @mtup and @alwaysfragp. + * Returns 0 on success. + */ static int -ip6_getpmtu(struct route_in6 *ro_pmtu, struct route_in6 *ro, +ip6_getpmtu(struct route_in6 *ro_pmtu, int do_lookup, struct ifnet *ifp, struct in6_addr *dst, u_long *mtup, int *alwaysfragp, u_int fibnum) { - u_int32_t mtu = 0; - int alwaysfrag = 0; - int error = 0; + struct nhop6_basic nh6; + struct in6_addr kdst; + uint32_t scopeid; + struct sockaddr_in6 *sa6_dst; + u_long mtu; - if (ro_pmtu != ro) { - /* The first hop and the final destination may differ. */ - struct sockaddr_in6 *sa6_dst = - (struct sockaddr_in6 *)&ro_pmtu->ro_dst; - if (ro_pmtu->ro_rt && - ((ro_pmtu->ro_rt->rt_flags & RTF_UP) == 0 || - !IN6_ARE_ADDR_EQUAL(&sa6_dst->sin6_addr, dst))) { - RTFREE(ro_pmtu->ro_rt); - ro_pmtu->ro_rt = (struct rtentry *)NULL; - } - if (ro_pmtu->ro_rt == NULL) { + mtu = 0; + if (do_lookup) { + + /* + * Here ro_pmtu has final destination address, while + * ro might represent immediate destination. + * Use ro_pmtu destination since mtu might differ. + */ + sa6_dst = (struct sockaddr_in6 *)&ro_pmtu->ro_dst; + if (!IN6_ARE_ADDR_EQUAL(&sa6_dst->sin6_addr, dst)) + ro_pmtu->ro_mtu = 0; + + if (ro_pmtu->ro_mtu == 0) { bzero(sa6_dst, sizeof(*sa6_dst)); sa6_dst->sin6_family = AF_INET6; sa6_dst->sin6_len = sizeof(struct sockaddr_in6); sa6_dst->sin6_addr = *dst; - in6_rtalloc(ro_pmtu, fibnum); + in6_splitscope(dst, &kdst, &scopeid); + if (fib6_lookup_nh_basic(fibnum, &kdst, scopeid, 0, 0, + &nh6) == 0) + ro_pmtu->ro_mtu = nh6.nh_mtu; } + + mtu = ro_pmtu->ro_mtu; } - if (ro_pmtu->ro_rt) { + + if (ro_pmtu->ro_rt) + mtu = ro_pmtu->ro_rt->rt_mtu; + + return (ip6_calcmtu(ifp, dst, mtu, mtup, alwaysfragp)); +} + +/* + * Calculate MTU based on transmit @ifp, route mtu @rt_mtu and + * hostcache data for @dst. + * Stores mtu and always-frag value into @mtup and @alwaysfragp. + * + * Returns 0 on success. + */ +static int +ip6_calcmtu(struct ifnet *ifp, const struct in6_addr *dst, u_long rt_mtu, + u_long *mtup, int *alwaysfragp) +{ + u_long mtu = 0; + int alwaysfrag = 0; + int error = 0; + + if (rt_mtu > 0) { u_int32_t ifmtu; struct in_conninfo inc; @@ -1251,14 +1323,12 @@ ip6_getpmtu(struct route_in6 *ro_pmtu, struct route_in6 *ro, inc.inc_flags |= INC_ISIPV6; inc.inc6_faddr = *dst; - if (ifp == NULL) - ifp = ro_pmtu->ro_rt->rt_ifp; ifmtu = IN6_LINKMTU(ifp); mtu = tcp_hc_getmtu(&inc); if (mtu) - mtu = min(mtu, ro_pmtu->ro_rt->rt_mtu); + mtu = min(mtu, rt_mtu); else - mtu = ro_pmtu->ro_rt->rt_mtu; + mtu = rt_mtu; if (mtu == 0) mtu = ifmtu; else if (mtu < IPV6_MMTU) { @@ -1936,9 +2006,6 @@ do { \ { u_long pmtu = 0; struct ip6_mtuinfo mtuinfo; - struct route_in6 sro; - - bzero(&sro, sizeof(sro)); if (!(so->so_state & SS_ISCONNECTED)) return (ENOTCONN); @@ -1947,11 +2014,8 @@ do { \ * routing, or optional information to specify * the outgoing interface. */ - error = ip6_getpmtu(&sro, NULL, NULL, - &in6p->in6p_faddr, &pmtu, NULL, - so->so_fibnum); - if (sro.ro_rt) - RTFREE(sro.ro_rt); + error = ip6_getpmtu_ctl(so->so_fibnum, + &in6p->in6p_faddr, &pmtu); if (error) break; if (pmtu > IPV6_MAXPACKET) diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h index 2159f29..ef86eca 100644 --- a/sys/netinet6/ip6_var.h +++ b/sys/netinet6/ip6_var.h @@ -418,9 +418,10 @@ int rip6_usrreq(struct socket *, int dest6_input(struct mbuf **, int *, int); int none_input(struct mbuf **, int *, int); -int in6_selectsrc(struct sockaddr_in6 *, struct ip6_pktopts *, - struct inpcb *inp, struct route_in6 *, struct ucred *cred, - struct ifnet **, struct in6_addr *); +int in6_selectsrc_socket(struct sockaddr_in6 *, struct ip6_pktopts *, + struct inpcb *, struct ucred *, int, struct in6_addr *, int *); +int in6_selectsrc_addr(uint32_t, const struct in6_addr *, + uint32_t, struct ifnet *, struct in6_addr *, int *); int in6_selectroute(struct sockaddr_in6 *, struct ip6_pktopts *, struct ip6_moptions *, struct route_in6 *, struct ifnet **, struct rtentry **); diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index fbbf421..4371a02 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1210,6 +1210,10 @@ nd6_is_new_addr_neighbor(const struct sockaddr_in6 *addr, struct ifnet *ifp) { struct nd_prefix *pr; struct ifaddr *dstaddr; + struct rt_addrinfo info; + struct sockaddr_in6 rt_key; + struct sockaddr *dst6; + int fibnum; /* * A link-local address is always a neighbor. @@ -1234,6 +1238,13 @@ nd6_is_new_addr_neighbor(const struct sockaddr_in6 *addr, struct ifnet *ifp) return (0); } + bzero(&rt_key, sizeof(rt_key)); + bzero(&info, sizeof(info)); + info.rti_info[RTAX_DST] = (struct sockaddr *)&rt_key; + + /* Always use the default FIB here. XXME - why? */ + fibnum = RT_DEFAULT_FIB; + /* * If the address matches one of our addresses, * it should be a neighbor. @@ -1245,12 +1256,13 @@ nd6_is_new_addr_neighbor(const struct sockaddr_in6 *addr, struct ifnet *ifp) continue; if (!(pr->ndpr_stateflags & NDPRF_ONLINK)) { - struct rtentry *rt; /* Always use the default FIB here. */ - rt = in6_rtalloc1((struct sockaddr *)&pr->ndpr_prefix, - 0, 0, RT_DEFAULT_FIB); - if (rt == NULL) + dst6 = (struct sockaddr *)&pr->ndpr_prefix; + + /* Restore length field before retrying lookup */ + rt_key.sin6_len = sizeof(rt_key); + if (rib_lookup_info(fibnum, dst6, 0, 0, &info) != 0) continue; /* * This is the case where multiple interfaces @@ -1263,11 +1275,8 @@ nd6_is_new_addr_neighbor(const struct sockaddr_in6 *addr, struct ifnet *ifp) * differ. */ if (!IN6_ARE_ADDR_EQUAL(&pr->ndpr_prefix.sin6_addr, - &((struct sockaddr_in6 *)rt_key(rt))->sin6_addr)) { - RTFREE_LOCKED(rt); + &rt_key.sin6_addr)) continue; - } - RTFREE_LOCKED(rt); } if (IN6_ARE_MASKED_ADDR_EQUAL(&pr->ndpr_prefix.sin6_addr, diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c index a5ce2ec..3a4e8a0 100644 --- a/sys/netinet6/nd6_nbr.c +++ b/sys/netinet6/nd6_nbr.c @@ -248,37 +248,35 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len) /* (2) check. */ if (ifa == NULL) { - struct route_in6 ro; - int need_proxy; + struct sockaddr_dl rt_gateway; + struct rt_addrinfo info; + struct sockaddr_in6 dst6; - bzero(&ro, sizeof(ro)); - ro.ro_dst.sin6_len = sizeof(struct sockaddr_in6); - ro.ro_dst.sin6_family = AF_INET6; - ro.ro_dst.sin6_addr = taddr6; + bzero(&dst6, sizeof(dst6)); + dst6.sin6_len = sizeof(struct sockaddr_in6); + dst6.sin6_family = AF_INET6; + dst6.sin6_addr = taddr6; + + bzero(&rt_gateway, sizeof(rt_gateway)); + rt_gateway.sdl_len = sizeof(rt_gateway); + bzero(&info, sizeof(info)); + info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&rt_gateway; /* Always use the default FIB. */ -#ifdef RADIX_MPATH - rtalloc_mpath_fib((struct route *)&ro, ntohl(taddr6.s6_addr32[3]), - RT_DEFAULT_FIB); -#else - in6_rtalloc(&ro, RT_DEFAULT_FIB); -#endif - need_proxy = (ro.ro_rt && - (ro.ro_rt->rt_flags & RTF_ANNOUNCE) != 0 && - ro.ro_rt->rt_gateway->sa_family == AF_LINK); - if (ro.ro_rt != NULL) { - if (need_proxy) - proxydl = *SDL(ro.ro_rt->rt_gateway); - RTFREE(ro.ro_rt); - } - if (need_proxy) { - /* - * proxy NDP for single entry - */ - ifa = (struct ifaddr *)in6ifa_ifpforlinklocal(ifp, - IN6_IFF_NOTREADY|IN6_IFF_ANYCAST); - if (ifa) - proxy = 1; + if (rib_lookup_info(RT_DEFAULT_FIB, (struct sockaddr *)&dst6, + 0, 0, &info) == 0) { + if ((info.rti_flags & RTF_ANNOUNCE) != 0 && + rt_gateway.sdl_family == AF_LINK) { + + /* + * proxy NDP for single entry + */ + proxydl = *SDL(&rt_gateway); + ifa = (struct ifaddr *)in6ifa_ifpforlinklocal( + ifp, IN6_IFF_NOTREADY|IN6_IFF_ANYCAST); + if (ifa) + proxy = 1; + } } } if (ifa == NULL) { @@ -408,7 +406,6 @@ nd6_ns_output_fib(struct ifnet *ifp, const struct in6_addr *saddr6, int icmp6len; int maxlen; caddr_t mac; - struct route_in6 ro; if (IN6_IS_ADDR_MULTICAST(taddr6)) return; @@ -428,8 +425,6 @@ nd6_ns_output_fib(struct ifnet *ifp, const struct in6_addr *saddr6, return; M_SETFIB(m, fibnum); - bzero(&ro, sizeof(ro)); - if (daddr6 == NULL || IN6_IS_ADDR_MULTICAST(daddr6)) { m->m_flags |= M_MCAST; im6o.im6o_multicast_ifp = ifp; @@ -486,27 +481,21 @@ nd6_ns_output_fib(struct ifnet *ifp, const struct in6_addr *saddr6, ifa_free(ifa); } else { int error; - struct sockaddr_in6 dst_sa; - struct in6_addr src_in; - struct ifnet *oifp; - - bzero(&dst_sa, sizeof(dst_sa)); - dst_sa.sin6_family = AF_INET6; - dst_sa.sin6_len = sizeof(dst_sa); - dst_sa.sin6_addr = ip6->ip6_dst; - - oifp = ifp; - error = in6_selectsrc(&dst_sa, NULL, - NULL, &ro, NULL, &oifp, &src_in); + struct in6_addr dst6, src6; + uint32_t scopeid; + + in6_splitscope(&ip6->ip6_dst, &dst6, &scopeid); + error = in6_selectsrc_addr(RT_DEFAULT_FIB, &dst6, + scopeid, ifp, &src6, NULL); if (error) { char ip6buf[INET6_ADDRSTRLEN]; nd6log((LOG_DEBUG, "%s: source can't be " "determined: dst=%s, error=%d\n", __func__, - ip6_sprintf(ip6buf, &dst_sa.sin6_addr), + ip6_sprintf(ip6buf, &dst6), error)); goto bad; } - ip6->ip6_src = src_in; + ip6->ip6_src = src6; } } else { /* @@ -585,21 +574,15 @@ nd6_ns_output_fib(struct ifnet *ifp, const struct in6_addr *saddr6, m_tag_prepend(m, mtag); } - ip6_output(m, NULL, &ro, (nonce != NULL) ? IPV6_UNSPECSRC : 0, + ip6_output(m, NULL, NULL, (nonce != NULL) ? IPV6_UNSPECSRC : 0, &im6o, NULL, NULL); icmp6_ifstat_inc(ifp, ifs6_out_msg); icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); ICMP6STAT_INC(icp6s_outhist[ND_NEIGHBOR_SOLICIT]); - /* We don't cache this route. */ - RO_RTFREE(&ro); - return; bad: - if (ro.ro_rt) { - RTFREE(ro.ro_rt); - } m_freem(m); return; } @@ -877,6 +860,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len) */ struct nd_defrouter *dr; struct in6_addr *in6; + struct ifnet *nd6_ifp; in6 = &ln->r_l3addr.addr6; @@ -886,10 +870,11 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len) * is only called under the network software interrupt * context. However, we keep it just for safety. */ - dr = defrouter_lookup(in6, ln->lle_tbl->llt_ifp); + nd6_ifp = lltable_get_ifp(ln->lle_tbl); + dr = defrouter_lookup(in6, nd6_ifp); if (dr) defrtrlist_del(dr); - else if (ND_IFINFO(ln->lle_tbl->llt_ifp)->flags & + else if (ND_IFINFO(nd6_ifp)->flags & ND6_IFF_ACCEPT_RTADV) { /* * Even if the neighbor is not in the default @@ -950,17 +935,14 @@ nd6_na_output_fib(struct ifnet *ifp, const struct in6_addr *daddr6_0, { struct mbuf *m; struct m_tag *mtag; - struct ifnet *oifp; struct ip6_hdr *ip6; struct nd_neighbor_advert *nd_na; struct ip6_moptions im6o; - struct in6_addr src, daddr6; - struct sockaddr_in6 dst_sa; + struct in6_addr daddr6, dst6, src6; + uint32_t scopeid; + int icmp6len, maxlen, error; caddr_t mac = NULL; - struct route_in6 ro; - - bzero(&ro, sizeof(ro)); daddr6 = *daddr6_0; /* make a local copy for modification */ @@ -1010,25 +992,21 @@ nd6_na_output_fib(struct ifnet *ifp, const struct in6_addr *daddr6_0, flags &= ~ND_NA_FLAG_SOLICITED; } ip6->ip6_dst = daddr6; - bzero(&dst_sa, sizeof(struct sockaddr_in6)); - dst_sa.sin6_family = AF_INET6; - dst_sa.sin6_len = sizeof(struct sockaddr_in6); - dst_sa.sin6_addr = daddr6; /* * Select a source whose scope is the same as that of the dest. */ - bcopy(&dst_sa, &ro.ro_dst, sizeof(dst_sa)); - oifp = ifp; - error = in6_selectsrc(&dst_sa, NULL, NULL, &ro, NULL, &oifp, &src); + in6_splitscope(&daddr6, &dst6, &scopeid); + error = in6_selectsrc_addr(RT_DEFAULT_FIB, &dst6, + scopeid, ifp, &src6, NULL); if (error) { char ip6buf[INET6_ADDRSTRLEN]; nd6log((LOG_DEBUG, "nd6_na_output: source can't be " "determined: dst=%s, error=%d\n", - ip6_sprintf(ip6buf, &dst_sa.sin6_addr), error)); + ip6_sprintf(ip6buf, &daddr6), error)); goto bad; } - ip6->ip6_src = src; + ip6->ip6_src = src6; nd_na = (struct nd_neighbor_advert *)(ip6 + 1); nd_na->nd_na_type = ND_NEIGHBOR_ADVERT; nd_na->nd_na_code = 0; @@ -1091,20 +1069,14 @@ nd6_na_output_fib(struct ifnet *ifp, const struct in6_addr *daddr6_0, m_tag_prepend(m, mtag); } - ip6_output(m, NULL, &ro, 0, &im6o, NULL, NULL); + ip6_output(m, NULL, NULL, 0, &im6o, NULL, NULL); icmp6_ifstat_inc(ifp, ifs6_out_msg); icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); ICMP6STAT_INC(icp6s_outhist[ND_NEIGHBOR_ADVERT]); - /* We don't cache this route. */ - RO_RTFREE(&ro); - return; bad: - if (ro.ro_rt) { - RTFREE(ro.ro_rt); - } m_freem(m); return; } diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index 3901944..972eb9f 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -397,6 +397,7 @@ rip6_output(struct mbuf *m, struct socket *so, ...) int type = 0, code = 0; /* for ICMPv6 output statistics only */ int scope_ambiguous = 0; int use_defzone = 0; + int hlim = 0; struct in6_addr in6a; va_list ap; @@ -460,8 +461,9 @@ rip6_output(struct mbuf *m, struct socket *so, ...) /* * Source address selection. */ - error = in6_selectsrc(dstsock, optp, in6p, NULL, so->so_cred, - &oifp, &in6a); + error = in6_selectsrc_socket(dstsock, optp, in6p, so->so_cred, + scope_ambiguous, &in6a, &hlim); + if (error) goto bad; error = prison_check_ip6(in6p->inp_cred, &in6a); @@ -469,19 +471,6 @@ rip6_output(struct mbuf *m, struct socket *so, ...) goto bad; ip6->ip6_src = in6a; - if (oifp && scope_ambiguous) { - /* - * Application should provide a proper zone ID or the use of - * default zone IDs should be enabled. Unfortunately, some - * applications do not behave as it should, so we need a - * workaround. Even if an appropriate ID is not determined - * (when it's required), if we can determine the outgoing - * interface. determine the zone ID based on the interface. - */ - error = in6_setscope(&dstsock->sin6_addr, oifp, NULL); - if (error != 0) - goto bad; - } ip6->ip6_dst = dstsock->sin6_addr; /* @@ -496,7 +485,7 @@ rip6_output(struct mbuf *m, struct socket *so, ...) * ip6_plen will be filled in ip6_output, so not fill it here. */ ip6->ip6_nxt = in6p->inp_ip_p; - ip6->ip6_hlim = in6_selecthlim(in6p, oifp); + ip6->ip6_hlim = hlim; if (so->so_proto->pr_protocol == IPPROTO_ICMPV6 || in6p->in6p_cksum != -1) { @@ -784,7 +773,6 @@ rip6_connect(struct socket *so, struct sockaddr *nam, struct thread *td) struct inpcb *inp; struct sockaddr_in6 *addr = (struct sockaddr_in6 *)nam; struct in6_addr in6a; - struct ifnet *ifp = NULL; int error = 0, scope_ambiguous = 0; inp = sotoinpcb(so); @@ -813,21 +801,14 @@ rip6_connect(struct socket *so, struct sockaddr *nam, struct thread *td) INP_INFO_WLOCK(&V_ripcbinfo); INP_WLOCK(inp); /* Source address selection. XXX: need pcblookup? */ - error = in6_selectsrc(addr, inp->in6p_outputopts, - inp, NULL, so->so_cred, &ifp, &in6a); + error = in6_selectsrc_socket(addr, inp->in6p_outputopts, + inp, so->so_cred, scope_ambiguous, &in6a, NULL); if (error) { INP_WUNLOCK(inp); INP_INFO_WUNLOCK(&V_ripcbinfo); return (error); } - /* XXX: see above */ - if (ifp && scope_ambiguous && - (error = in6_setscope(&addr->sin6_addr, ifp, NULL)) != 0) { - INP_WUNLOCK(inp); - INP_INFO_WUNLOCK(&V_ripcbinfo); - return (error); - } inp->in6p_faddr = addr->sin6_addr; inp->in6p_laddr = in6a; soisconnected(so); diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 375c00d..9768df5 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -631,7 +631,6 @@ udp6_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr6, struct udphdr *udp6; struct in6_addr *laddr, *faddr, in6a; struct sockaddr_in6 *sin6 = NULL; - struct ifnet *oifp = NULL; int cscov_partial = 0; int scope_ambiguous = 0; u_short fport; @@ -731,15 +730,10 @@ udp6_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr6, } if (!IN6_IS_ADDR_V4MAPPED(faddr)) { - error = in6_selectsrc(sin6, optp, inp, NULL, - td->td_ucred, &oifp, &in6a); + error = in6_selectsrc_socket(sin6, optp, inp, + td->td_ucred, scope_ambiguous, &in6a, NULL); if (error) goto release; - if (oifp && scope_ambiguous && - (error = in6_setscope(&sin6->sin6_addr, - oifp, NULL))) { - goto release; - } laddr = &in6a; } else laddr = &inp->in6p_laddr; /* XXX */ diff --git a/sys/netpfil/ipfw/ip_fw_table.c b/sys/netpfil/ipfw/ip_fw_table.c index 71c96b2..a1ee5dd 100644 --- a/sys/netpfil/ipfw/ip_fw_table.c +++ b/sys/netpfil/ipfw/ip_fw_table.c @@ -2097,7 +2097,7 @@ export_table_info(struct ip_fw_chain *ch, struct table_config *tc, i->count = table_get_count(ch, tc); i->limit = tc->limit; i->flags |= (tc->locked != 0) ? IPFW_TGFLAGS_LOCKED : 0; - i->size = tc->count * sizeof(ipfw_obj_tentry); + i->size = i->count * sizeof(ipfw_obj_tentry); i->size += sizeof(ipfw_obj_header) + sizeof(ipfw_xtable_info); strlcpy(i->tablename, tc->tablename, sizeof(i->tablename)); ti = KIDX_TO_TI(ch, tc->no.kidx); diff --git a/sys/netpfil/ipfw/ip_fw_table_algo.c b/sys/netpfil/ipfw/ip_fw_table_algo.c index 06a4641..2ce550e 100644 --- a/sys/netpfil/ipfw/ip_fw_table_algo.c +++ b/sys/netpfil/ipfw/ip_fw_table_algo.c @@ -53,8 +53,10 @@ __FBSDID("$FreeBSD$"); #include <net/route.h> #include <netinet/in.h> +#include <netinet/in_fib.h> #include <netinet/ip_var.h> /* struct ipfw_rule_ref */ #include <netinet/ip_fw.h> +#include <netinet6/in6_fib.h> #include <netpfil/ipfw/ip_fw_private.h> #include <netpfil/ipfw/ip_fw_table.h> @@ -3778,7 +3780,6 @@ struct table_algo flow_hash = { * */ -static struct rtentry *lookup_kfib(void *key, int keylen, int fib); static int ta_lookup_kfib(struct table_info *ti, void *key, uint32_t keylen, uint32_t *val); static int kfib_parse_opts(int *pfib, char *data); @@ -3792,46 +3793,45 @@ static void ta_dump_kfib_tinfo(void *ta_state, struct table_info *ti, static int contigmask(uint8_t *p, int len); static int ta_dump_kfib_tentry(void *ta_state, struct table_info *ti, void *e, ipfw_obj_tentry *tent); +static int ta_dump_kfib_tentry_int(struct sockaddr *paddr, + struct sockaddr *pmask, ipfw_obj_tentry *tent); static int ta_find_kfib_tentry(void *ta_state, struct table_info *ti, ipfw_obj_tentry *tent); static void ta_foreach_kfib(void *ta_state, struct table_info *ti, ta_foreach_f *f, void *arg); -static struct rtentry * -lookup_kfib(void *key, int keylen, int fib) -{ - struct sockaddr *s; - - if (keylen == 4) { - struct sockaddr_in sin; - bzero(&sin, sizeof(sin)); - sin.sin_len = sizeof(struct sockaddr_in); - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = *(in_addr_t *)key; - s = (struct sockaddr *)&sin; - } else { - struct sockaddr_in6 sin6; - bzero(&sin6, sizeof(sin6)); - sin6.sin6_len = sizeof(struct sockaddr_in6); - sin6.sin6_family = AF_INET6; - sin6.sin6_addr = *(struct in6_addr *)key; - s = (struct sockaddr *)&sin6; - } - - return (rtalloc1_fib(s, 0, 0, fib)); -} static int ta_lookup_kfib(struct table_info *ti, void *key, uint32_t keylen, uint32_t *val) { - struct rtentry *rte; +#ifdef INET + struct nhop4_basic nh4; + struct in_addr in; +#endif +#ifdef INET6 + struct nhop6_basic nh6; +#endif + int error; + + error = ENOENT; +#ifdef INET + if (keylen == 4) { + in.s_addr = *(in_addr_t *)key; + error = fib4_lookup_nh_basic(ti->data, + in, 0, 0, &nh4); + } +#endif +#ifdef INET6 + if (keylen == 6) + error = fib6_lookup_nh_basic(ti->data, + (struct in6_addr *)key, 0, 0, 0, &nh6); +#endif - if ((rte = lookup_kfib(key, keylen, ti->data)) == NULL) + if (error != 0) return (0); *val = 0; - RTFREE_LOCKED(rte); return (1); } @@ -3940,6 +3940,16 @@ ta_dump_kfib_tentry(void *ta_state, struct table_info *ti, void *e, ipfw_obj_tentry *tent) { struct rtentry *rte; + + rte = (struct rtentry *)e; + + return ta_dump_kfib_tentry_int(rt_key(rte), rt_mask(rte), tent); +} + +static int +ta_dump_kfib_tentry_int(struct sockaddr *paddr, struct sockaddr *pmask, + ipfw_obj_tentry *tent) +{ #ifdef INET struct sockaddr_in *addr, *mask; #endif @@ -3948,14 +3958,13 @@ ta_dump_kfib_tentry(void *ta_state, struct table_info *ti, void *e, #endif int len; - rte = (struct rtentry *)e; - addr = (struct sockaddr_in *)rt_key(rte); - mask = (struct sockaddr_in *)rt_mask(rte); len = 0; /* Guess IPv4/IPv6 radix by sockaddr family */ #ifdef INET - if (addr->sin_family == AF_INET) { + if (paddr->sa_family == AF_INET) { + addr = (struct sockaddr_in *)paddr; + mask = (struct sockaddr_in *)pmask; tent->k.addr.s_addr = addr->sin_addr.s_addr; len = 32; if (mask != NULL) @@ -3968,9 +3977,9 @@ ta_dump_kfib_tentry(void *ta_state, struct table_info *ti, void *e, } #endif #ifdef INET6 - if (addr->sin_family == AF_INET6) { - addr6 = (struct sockaddr_in6 *)addr; - mask6 = (struct sockaddr_in6 *)mask; + if (paddr->sa_family == AF_INET6) { + addr6 = (struct sockaddr_in6 *)paddr; + mask6 = (struct sockaddr_in6 *)pmask; memcpy(&tent->k, &addr6->sin6_addr, sizeof(struct in6_addr)); len = 128; if (mask6 != NULL) @@ -3990,28 +3999,43 @@ static int ta_find_kfib_tentry(void *ta_state, struct table_info *ti, ipfw_obj_tentry *tent) { - struct rtentry *rte; - void *key; - int keylen; + struct rt_addrinfo info; + struct sockaddr_in6 key6, dst6, mask6; + struct sockaddr *dst, *key, *mask; + + /* Prepare sockaddr for prefix/mask and info */ + bzero(&dst6, sizeof(dst6)); + dst6.sin6_len = sizeof(dst6); + dst = (struct sockaddr *)&dst6; + bzero(&mask6, sizeof(mask6)); + mask6.sin6_len = sizeof(mask6); + mask = (struct sockaddr *)&mask6; + + bzero(&info, sizeof(info)); + info.rti_info[RTAX_DST] = dst; + info.rti_info[RTAX_NETMASK] = mask; + + /* Prepare the lookup key */ + bzero(&key6, sizeof(key6)); + key6.sin6_family = tent->subtype; + key = (struct sockaddr *)&key6; if (tent->subtype == AF_INET) { - key = &tent->k.addr; - keylen = sizeof(struct in_addr); + ((struct sockaddr_in *)&key6)->sin_addr = tent->k.addr; + key6.sin6_len = sizeof(struct sockaddr_in); } else { - key = &tent->k.addr6; - keylen = sizeof(struct in6_addr); + key6.sin6_addr = tent->k.addr6; + key6.sin6_len = sizeof(struct sockaddr_in6); } - if ((rte = lookup_kfib(key, keylen, ti->data)) == NULL) - return (0); + if (rib_lookup_info(ti->data, key, 0, 0, &info) != 0) + return (ENOENT); + if ((info.rti_addrs & RTA_NETMASK) == 0) + mask = NULL; - if (rte != NULL) { - ta_dump_kfib_tentry(ta_state, ti, rte, tent); - RTFREE_LOCKED(rte); - return (0); - } + ta_dump_kfib_tentry_int(dst, mask, tent); - return (ENOENT); + return (0); } static void diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 57e78e8..1b77153 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$"); #include <netinet/in_pcb.h> #include <netinet/in_var.h> +#include <netinet/in_fib.h> #include <netinet/ip.h> #include <netinet/ip_fw.h> #include <netinet/ip_icmp.h> @@ -94,6 +95,8 @@ __FBSDID("$FreeBSD$"); #include <netinet6/nd6.h> #include <netinet6/ip6_var.h> #include <netinet6/in6_pcb.h> +#include <netinet6/in6_fib.h> +#include <netinet6/scope6_var.h> #endif /* INET6 */ #include <machine/in_cksum.h> @@ -2985,49 +2988,35 @@ static u_int16_t pf_calc_mss(struct pf_addr *addr, sa_family_t af, int rtableid, u_int16_t offer) { #ifdef INET - struct sockaddr_in *dst; - struct route ro; + struct nhop4_basic nh4; #endif /* INET */ #ifdef INET6 - struct sockaddr_in6 *dst6; - struct route_in6 ro6; + struct nhop6_basic nh6; + struct in6_addr dst6; + uint32_t scopeid; #endif /* INET6 */ - struct rtentry *rt = NULL; int hlen = 0; - u_int16_t mss = V_tcp_mssdflt; + uint16_t mss = 0; switch (af) { #ifdef INET case AF_INET: hlen = sizeof(struct ip); - bzero(&ro, sizeof(ro)); - dst = (struct sockaddr_in *)&ro.ro_dst; - dst->sin_family = AF_INET; - dst->sin_len = sizeof(*dst); - dst->sin_addr = addr->v4; - in_rtalloc_ign(&ro, 0, rtableid); - rt = ro.ro_rt; + if (fib4_lookup_nh_basic(rtableid, addr->v4, 0, 0, &nh4) == 0) + mss = nh4.nh_mtu - hlen - sizeof(struct tcphdr); break; #endif /* INET */ #ifdef INET6 case AF_INET6: hlen = sizeof(struct ip6_hdr); - bzero(&ro6, sizeof(ro6)); - dst6 = (struct sockaddr_in6 *)&ro6.ro_dst; - dst6->sin6_family = AF_INET6; - dst6->sin6_len = sizeof(*dst6); - dst6->sin6_addr = addr->v6; - in6_rtalloc_ign(&ro6, 0, rtableid); - rt = ro6.ro_rt; + in6_splitscope(&addr->v6, &dst6, &scopeid); + if (fib6_lookup_nh_basic(rtableid, &dst6, scopeid, 0,0,&nh6)==0) + mss = nh6.nh_mtu - hlen - sizeof(struct tcphdr); break; #endif /* INET6 */ } - if (rt && rt->rt_ifp) { - mss = rt->rt_ifp->if_mtu - hlen - sizeof(struct tcphdr); - mss = max(V_tcp_mssdflt, mss); - RTFREE(rt); - } + mss = max(V_tcp_mssdflt, mss); mss = min(mss, offer); mss = max(mss, 64); /* sanity - at least max opt space */ return (mss); @@ -5194,13 +5183,12 @@ pf_pull_hdr(struct mbuf *m, int off, void *p, int len, return (p); } -int -pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *kif, +#ifdef RADIX_MPATH +static int +pf_routable_oldmpath(struct pf_addr *addr, sa_family_t af, struct pfi_kif *kif, int rtableid) { -#ifdef RADIX_MPATH struct radix_node_head *rnh; -#endif struct sockaddr_in *dst; int ret = 1; int check_mpath; @@ -5215,12 +5203,10 @@ pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *kif, struct ifnet *ifp; check_mpath = 0; -#ifdef RADIX_MPATH /* XXX: stick to table 0 for now */ rnh = rt_tables_get_rnh(0, af); if (rnh != NULL && rn_mpath_capable(rnh)) check_mpath = 1; -#endif bzero(&ro, sizeof(ro)); switch (af) { case AF_INET: @@ -5283,9 +5269,7 @@ pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *kif, if (kif->pfik_ifp == ifp) ret = 1; -#ifdef RADIX_MPATH rn = rn_mpath_next(rn); -#endif } while (check_mpath == 1 && rn != NULL && ret == 0); } else ret = 0; @@ -5294,6 +5278,72 @@ out: RTFREE(ro.ro_rt); return (ret); } +#endif + +int +pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *kif, + int rtableid) +{ +#ifdef INET + struct nhop4_basic nh4; +#endif +#ifdef INET6 + struct nhop6_basic nh6; +#endif + struct ifnet *ifp; +#ifdef RADIX_MPATH + struct radix_node_head *rnh; + + /* XXX: stick to table 0 for now */ + rnh = rt_tables_get_rnh(0, af); + if (rnh != NULL && rn_mpath_capable(rnh)) + return (pf_routable_oldmpath(addr, af, kif, rtableid)); +#endif + /* + * Skip check for addresses with embedded interface scope, + * as they would always match anyway. + */ + if (af == AF_INET6 && IN6_IS_SCOPE_EMBED(&addr->v6)) + return (1); + + if (af != AF_INET && af != AF_INET6) + return (0); + + /* Skip checks for ipsec interfaces */ + if (kif != NULL && kif->pfik_ifp->if_type == IFT_ENC) + return (1); + + ifp = NULL; + + switch (af) { +#ifdef INET6 + case AF_INET6: + if (fib6_lookup_nh_basic(rtableid, &addr->v6, 0, 0, 0, &nh6)!=0) + return (0); + ifp = nh6.nh_ifp; + break; +#endif +#ifdef INET + case AF_INET: + if (fib4_lookup_nh_basic(rtableid, addr->v4, 0, 0, &nh4) != 0) + return (0); + ifp = nh4.nh_ifp; + break; +#endif + } + + /* No interface given, this is a no-route check */ + if (kif == NULL) + return (1); + + if (kif->pfik_ifp == NULL) + return (0); + + /* Perform uRPF check if passed input interface */ + if (kif->pfik_ifp == ifp) + return (1); + return (0); +} #ifdef INET static void @@ -5344,23 +5394,20 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp, dst.sin_addr = ip->ip_dst; if (r->rt == PF_FASTROUTE) { - struct rtentry *rt; + struct nhop4_basic nh4; if (s) PF_STATE_UNLOCK(s); - rt = rtalloc1_fib(sintosa(&dst), 0, 0, M_GETFIB(m0)); - if (rt == NULL) { + + if (fib4_lookup_nh_basic(M_GETFIB(m0), ip->ip_dst, 0, + m0->m_pkthdr.flowid, &nh4) != 0) { KMOD_IPSTAT_INC(ips_noroute); error = EHOSTUNREACH; goto bad; } - ifp = rt->rt_ifp; - counter_u64_add(rt->rt_pksent, 1); - - if (rt->rt_flags & RTF_GATEWAY) - bcopy(satosin(rt->rt_gateway), &dst, sizeof(dst)); - RTFREE_LOCKED(rt); + ifp = nh4.nh_ifp; + dst.sin_addr = nh4.nh_addr; } else { if (TAILQ_EMPTY(&r->rpool.list)) { DPFPRINTF(PF_DEBUG_URGENT, diff --git a/sys/netpfil/pf/pf_if.c b/sys/netpfil/pf/pf_if.c index a2c9c7e..6b25f5f 100644 --- a/sys/netpfil/pf/pf_if.c +++ b/sys/netpfil/pf/pf_if.c @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/kernel.h> +#include <sys/eventhandler.h> #include <sys/lock.h> #include <sys/mbuf.h> #include <sys/rwlock.h> diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c index e1f2dc0..6326bd2 100644 --- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -1260,16 +1260,12 @@ ipoib_output(struct ifnet *ifp, struct mbuf *m, #if defined(INET) || defined(INET6) struct llentry *lle = NULL; #endif - struct rtentry *rt0 = NULL; struct ipoib_header *eh; int error = 0, is_gw = 0; short type; - if (ro != NULL) { - rt0 = ro->ro_rt; - if (rt0 != NULL && (rt0->rt_flags & RTF_GATEWAY) != 0) - is_gw = 1; - } + if (ro != NULL) + is_gw = (ro->ro_flags & RT_HAS_GW) != 0; #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); if (error) diff --git a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c index 0b78212..7c6f6cb 100644 --- a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c +++ b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c @@ -242,7 +242,7 @@ sdp_sock_queue_rcv_mb(struct socket *sk, struct mbuf *mb) SOCKBUF_LOCK(&sk->so_rcv); if (unlikely(h->flags & SDP_OOB_PRES)) sdp_urg(ssk, mb); - sbappend_locked(&sk->so_rcv, mb); + sbappend_locked(&sk->so_rcv, mb, 0); sorwakeup_locked(sk); return mb; } diff --git a/sys/ofed/include/rdma/Kbuild b/sys/ofed/include/rdma/Kbuild deleted file mode 100644 index e7c0432..0000000 --- a/sys/ofed/include/rdma/Kbuild +++ /dev/null @@ -1 +0,0 @@ -header-y += ib_user_mad.h diff --git a/sys/powerpc/aim/aim_machdep.c b/sys/powerpc/aim/aim_machdep.c index ab09ab6..835783f 100644 --- a/sys/powerpc/aim/aim_machdep.c +++ b/sys/powerpc/aim/aim_machdep.c @@ -179,6 +179,17 @@ aim_cpu_init(vm_offset_t toc) trap_offset = 0; cacheline_warn = 0; + #ifdef __powerpc64__ + /* + * Switch to 64-bit mode, if the bootloader didn't, before we start + * using memory beyond what the bootloader might have set up. + * Guaranteed not to cause an implicit branch since we either (a) + * started with a 32-bit bootloader below 4 GB or (b) were already in + * 64-bit mode, making this a no-op. + */ + mtmsrd(mfmsr() | PSL_SF); + #endif + /* Various very early CPU fix ups */ switch (mfpvr() >> 16) { /* diff --git a/sys/powerpc/aim/locore32.S b/sys/powerpc/aim/locore32.S index 477ae88..b14215c 100644 --- a/sys/powerpc/aim/locore32.S +++ b/sys/powerpc/aim/locore32.S @@ -1,8 +1,7 @@ /* $FreeBSD$ */ -/* $NetBSD: locore.S,v 1.24 2000/05/31 05:09:17 thorpej Exp $ */ /*- - * Copyright (C) 2001 Benno Rice + * Copyright (C) 2010-2016 Nathan Whitehorn * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -14,37 +13,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/*- - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, @@ -95,15 +64,7 @@ GLOBAL(tmpstk) btext: /* - * This symbol is here for the benefit of kvm_mkdb, and is supposed to - * mark the start of kernel text. - */ - .globl kernel_text -kernel_text: - -/* - * Startup entry. Note, this must be the first thing in the text - * segment! + * Main kernel entry point. */ .text .globl __start @@ -148,29 +109,7 @@ __start: stw %r3, 0(%r1) bl mi_startup - /* If mi_startup somehow returns, exit. This would be bad. */ - b OF_exit - -/* - * int setfault() - * - * Similar to setjmp to setup for handling faults on accesses to user memory. - * Any routine using this may only call bcopy, either the form below, - * or the (currently used) C code optimized, so it doesn't use any non-volatile - * registers. - */ - .globl setfault -setfault: - mflr 0 - mfcr 12 - mfsprg 4,0 - lwz 4,TD_PCB(2) /* curthread = r2 */ - stw 3,PCB_ONFAULT(4) - stw 0,0(3) - stw 1,4(3) - stw 2,8(3) - stmw 12,12(3) - xor 3,3,3 - blr + /* mi_startup() does not return */ + b . #include <powerpc/aim/trap_subr32.S> diff --git a/sys/powerpc/aim/locore64.S b/sys/powerpc/aim/locore64.S index fc2fa8d..cd64b5f 100644 --- a/sys/powerpc/aim/locore64.S +++ b/sys/powerpc/aim/locore64.S @@ -1,8 +1,7 @@ /* $FreeBSD$ */ -/* $NetBSD: locore.S,v 1.24 2000/05/31 05:09:17 thorpej Exp $ */ /*- - * Copyright (C) 2001 Benno Rice + * Copyright (C) 2010-2016 Nathan Whitehorn * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -14,7 +13,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, @@ -24,36 +23,8 @@ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/*- - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * $FreeBSD$ */ #include "assym.s" @@ -69,13 +40,6 @@ .abiversion _CALL_ELF #endif -/* Locate the per-CPU data structure */ -#define GET_CPUINFO(r) \ - mfsprg0 r -#define GET_TOCBASE(r) \ - li r,TRAP_TOCBASE; /* Magic address for TOC */ \ - ld r,0(r) - /* Glue for linker script */ .globl kernbase .set kernbase, KERNBASE @@ -102,15 +66,7 @@ TOC_ENTRY(tmpstk) btext: /* - * This symbol is here for the benefit of kvm_mkdb, and is supposed to - * mark the start of kernel text. - */ - .globl kernel_text -kernel_text: - -/* - * Startup entry. Note, this must be the first thing in the text - * segment! + * Main kernel entry point. * * Calling convention: * r3: Flattened Device Tree pointer (or zero) @@ -157,13 +113,6 @@ ASENTRY_NOPROF(__start) ld %r5,64(%r1) ld %r6,72(%r1) - /* Switch to 64-bit mode */ - mfmsr %r9 - li %r8,1 - insrdi %r9,%r8,1,0 - mtmsrd %r9 - isync - /* Begin CPU init */ mr %r4,%r2 /* Replace ignored r4 with tocbase for trap handlers */ bl powerpc_init @@ -176,50 +125,7 @@ ASENTRY_NOPROF(__start) bl mi_startup nop - /* If this returns (it won't), go back to firmware */ - b OF_exit - nop - -/* - * int setfault() - * - * Similar to setjmp to setup for handling faults on accesses to user memory. - * Any routine using this may only call bcopy, either the form below, - * or the (currently used) C code optimized, so it doesn't use any non-volatile - * registers. - */ -ASENTRY_NOPROF(setfault) - mflr 0 - mfcr 12 - mfsprg 4,0 - ld 4,TD_PCB(13) /* curthread = r13 */ - std 3,PCB_ONFAULT(4) - std 0,0(3) - std 1,8(3) - std 2,16(3) - - std %r12,24(%r3) /* Save the non-volatile GP regs. */ - std %r13,24+1*8(%r3) - std %r14,24+2*8(%r3) - std %r15,24+3*8(%r3) - std %r16,24+4*8(%r3) - std %r17,24+5*8(%r3) - std %r18,24+6*8(%r3) - std %r19,24+7*8(%r3) - std %r20,24+8*8(%r3) - std %r21,24+9*8(%r3) - std %r22,24+10*8(%r3) - std %r23,24+11*8(%r3) - std %r24,24+12*8(%r3) - std %r25,24+13*8(%r3) - std %r26,24+14*8(%r3) - std %r27,24+15*8(%r3) - std %r28,24+16*8(%r3) - std %r29,24+17*8(%r3) - std %r30,24+18*8(%r3) - std %r31,24+19*8(%r3) - - xor 3,3,3 - blr + /* Unreachable */ + b . #include <powerpc/aim/trap_subr64.S> diff --git a/sys/powerpc/aim/mp_cpudep.c b/sys/powerpc/aim/mp_cpudep.c index 59a24e2..cedf53b 100644 --- a/sys/powerpc/aim/mp_cpudep.c +++ b/sys/powerpc/aim/mp_cpudep.c @@ -77,10 +77,10 @@ cpudep_ap_early_bootstrap(void) #else __asm __volatile("ld %0, 16(%2); sync; isync; \ mtspr %1, %0; sync; isync;" - : "=r"(reg) : "K"(SPR_HID4), "r"(bsp_state)); + : "=r"(reg) : "K"(SPR_HID4), "b"(bsp_state)); __asm __volatile("ld %0, 24(%2); sync; isync; \ mtspr %1, %0; sync; isync;" - : "=r"(reg) : "K"(SPR_HID5), "r"(bsp_state)); + : "=r"(reg) : "K"(SPR_HID5), "b"(bsp_state)); #endif powerpc_sync(); break; @@ -324,10 +324,10 @@ cpudep_ap_setup() mfspr %0, %1; mfspr %0, %1; mfspr %0, %1; \ mfspr %0, %1; mfspr %0, %1; mfspr %0, %1; \ sync; isync" - : "=r"(reg) : "K"(SPR_HID0), "r"(bsp_state)); + : "=r"(reg) : "K"(SPR_HID0), "b"(bsp_state)); __asm __volatile("ld %0, 8(%2); sync; isync; \ mtspr %1, %0; mtspr %1, %0; sync; isync" - : "=r"(reg) : "K"(SPR_HID1), "r"(bsp_state)); + : "=r"(reg) : "K"(SPR_HID1), "b"(bsp_state)); #endif powerpc_sync(); diff --git a/sys/powerpc/aim/trap_subr64.S b/sys/powerpc/aim/trap_subr64.S index 7ad0a70..587086e 100644 --- a/sys/powerpc/aim/trap_subr64.S +++ b/sys/powerpc/aim/trap_subr64.S @@ -39,9 +39,12 @@ * #include <powerpc/aim/trap_subr.S> */ -/* - * Save/restore segment registers - */ +/* Locate the per-CPU data structure */ +#define GET_CPUINFO(r) \ + mfsprg0 r +#define GET_TOCBASE(r) \ + li r,TRAP_TOCBASE; /* Magic address for TOC */ \ + ld r,0(r) /* * Restore SRs for a pmap diff --git a/sys/powerpc/booke/booke_machdep.c b/sys/powerpc/booke/booke_machdep.c index f102677..78ca12f 100644 --- a/sys/powerpc/booke/booke_machdep.c +++ b/sys/powerpc/booke/booke_machdep.c @@ -156,7 +156,6 @@ __FBSDID("$FreeBSD$"); #define debugf(fmt, args...) #endif -extern unsigned char kernel_text[]; extern unsigned char _etext[]; extern unsigned char _edata[]; extern unsigned char __bss_start[]; @@ -173,7 +172,7 @@ uint32_t *bootinfo; void print_kernel_section_addr(void); void print_kenv(void); -uintptr_t booke_init(uint32_t, uint32_t); +uintptr_t booke_init(u_long, u_long); void ivor_setup(void); extern void *interrupt_vector_base; @@ -211,6 +210,8 @@ void booke_cpu_init(void) { + cpu_features |= PPC_FEATURE_BOOKE; + pmap_mmu_install(MMU_TYPE_BOOKE, BUS_PROBE_GENERIC); } @@ -266,7 +267,7 @@ booke_check_for_fdt(uint32_t arg1, vm_offset_t *dtbp) } uintptr_t -booke_init(uint32_t arg1, uint32_t arg2) +booke_init(u_long arg1, u_long arg2) { uintptr_t ret; void *mdp; @@ -309,13 +310,11 @@ booke_init(uint32_t arg1, uint32_t arg2) end += fdt_totalsize((void *)dtbp); __endkernel = end; mdp = NULL; - } else if (arg1 > (uintptr_t)kernel_text) /* FreeBSD loader */ + } else if (arg1 > (uintptr_t)btext) /* FreeBSD loader */ mdp = (void *)arg1; else /* U-Boot */ mdp = NULL; - ret = powerpc_init(dtbp, 0, 0, mdp); - /* Default to 32 byte cache line size. */ switch ((mfpvr()) >> 16) { case FSL_E500mc: @@ -325,6 +324,8 @@ booke_init(uint32_t arg1, uint32_t arg2) break; } + ret = powerpc_init(dtbp, 0, 0, mdp); + /* Enable caches */ booke_enable_l1_cache(); booke_enable_l2_cache(); diff --git a/sys/powerpc/booke/locore.S b/sys/powerpc/booke/locore.S index 2d6c66d..a49d796 100644 --- a/sys/powerpc/booke/locore.S +++ b/sys/powerpc/booke/locore.S @@ -837,29 +837,6 @@ ENTRY(dataloss_erratum_access) blr -/* - * int setfault() - * - * Similar to setjmp to setup for handling faults on accesses to user memory. - * Any routine using this may only call bcopy, either the form below, - * or the (currently used) C code optimized, so it doesn't use any non-volatile - * registers. - */ - .globl setfault -setfault: - mflr %r0 - mfsprg0 %r4 - lwz %r4, TD_PCB(%r2) - stw %r3, PCB_ONFAULT(%r4) - mfcr %r4 - stw %r0, 0(%r3) - stw %r1, 4(%r3) - stw %r2, 8(%r3) - stw %r4, 12(%r3) - stmw %r13, 16(%r3) /* store CR, CTR, XER, [r13 .. r31] */ - li %r3, 0 /* return FALSE */ - blr - /************************************************************************/ /* Data section */ /************************************************************************/ diff --git a/sys/powerpc/include/cpu.h b/sys/powerpc/include/cpu.h index ba45eb0..fffb2b4 100644 --- a/sys/powerpc/include/cpu.h +++ b/sys/powerpc/include/cpu.h @@ -48,19 +48,32 @@ */ extern int cpu_features; +extern int cpu_features2; #define PPC_FEATURE_32 0x80000000 /* Always true */ #define PPC_FEATURE_64 0x40000000 /* Defined on a 64-bit CPU */ #define PPC_FEATURE_HAS_ALTIVEC 0x10000000 #define PPC_FEATURE_HAS_FPU 0x08000000 #define PPC_FEATURE_HAS_MMU 0x04000000 -#define PPC_FEATURE_UNIFIED_CACHE 0x01000000 -#define PPC_FEATURE_HAS_VSX 0x00000080 +#define PPC_FEATURE_UNIFIED_CACHE 0x01000000 +#define PPC_FEATURE_BOOKE 0x00008000 +#define PPC_FEATURE_SMT 0x00004000 +#define PPC_FEATURE_ARCH_2_05 0x00001000 +#define PPC_FEATURE_HAS_DFP 0x00000400 +#define PPC_FEATURE_ARCH_2_06 0x00000100 +#define PPC_FEATURE_HAS_VSX 0x00000080 + +#define PPC_FEATURE2_ARCH_2_07 0x80000000 +#define PPC_FEATURE2_HAS_HTM 0x40000000 +#define PPC_FEATURE2_HAS_VCRYPTO 0x02000000 #define PPC_FEATURE_BITMASK \ "\20" \ "\040PPC32\037PPC64\035ALTIVEC\034FPU\033MMU\031UNIFIEDCACHE" \ - "\010VSX" + "\020BOOKE\017SMT\015ARCH205\013DFP\011ARCH206\010VSX" +#define PPC_FEATURE2_BITMASK \ + "\20" \ + "\040ARCH207\037HTM\032VCRYPTO" #define TRAPF_USERMODE(frame) (((frame)->srr1 & PSL_PR) != 0) #define TRAPF_PC(frame) ((frame)->srr0) diff --git a/sys/powerpc/include/intr_machdep.h b/sys/powerpc/include/intr_machdep.h index c2529d5..32a94be 100644 --- a/sys/powerpc/include/intr_machdep.h +++ b/sys/powerpc/include/intr_machdep.h @@ -30,7 +30,7 @@ #define INTR_VECTORS 256 -#define MAX_PICS 5 +#define MAX_PICS 16 #define MAP_IRQ(node, pin) powerpc_get_irq(node, pin) /* diff --git a/sys/powerpc/include/pcb.h b/sys/powerpc/include/pcb.h index 6caf5d2..094949e 100644 --- a/sys/powerpc/include/pcb.h +++ b/sys/powerpc/include/pcb.h @@ -35,7 +35,7 @@ #ifndef _MACHINE_PCB_H_ #define _MACHINE_PCB_H_ -typedef register_t faultbuf[25]; +#include <machine/setjmp.h> struct pcb { register_t pcb_context[20]; /* non-volatile r14-r31 */ @@ -44,7 +44,7 @@ struct pcb { register_t pcb_toc; /* toc pointer */ register_t pcb_lr; /* link register */ struct pmap *pcb_pm; /* pmap of our vmspace */ - faultbuf *pcb_onfault; /* For use during + jmp_buf *pcb_onfault; /* For use during copyin/copyout */ int pcb_flags; #define PCB_FPU 1 /* Process uses FPU */ diff --git a/sys/powerpc/include/platform.h b/sys/powerpc/include/platform.h index 28f83cc..8c92e26 100644 --- a/sys/powerpc/include/platform.h +++ b/sys/powerpc/include/platform.h @@ -57,6 +57,8 @@ void platform_smp_ap_init(void); const char *installed_platform(void); void platform_probe_and_attach(void); +void platform_cpu_idle(int); + void platform_sleep(void); #endif /* _MACHINE_PLATFORM_H_ */ diff --git a/sys/powerpc/include/setjmp.h b/sys/powerpc/include/setjmp.h index e453044..b95a111 100644 --- a/sys/powerpc/include/setjmp.h +++ b/sys/powerpc/include/setjmp.h @@ -8,7 +8,11 @@ #include <sys/cdefs.h> +#ifdef _KERNEL +#define _JBLEN 25 /* Kernel doesn't save FP and Altivec regs */ +#else #define _JBLEN 100 +#endif /* * jmp_buf and sigjmp_buf are encapsulated in different structs to force diff --git a/sys/powerpc/mpc85xx/lbc.c b/sys/powerpc/mpc85xx/lbc.c index 62b56c3..8bb92b2 100644 --- a/sys/powerpc/mpc85xx/lbc.c +++ b/sys/powerpc/mpc85xx/lbc.c @@ -126,11 +126,11 @@ lbc_address_mask(uint32_t size) { int n = 15; - if (size == ~0UL) + if (size == ~0) return (0); while (n < 32) { - if (size == (1UL << n)) + if (size == (1U << n)) break; n++; } @@ -267,7 +267,7 @@ lbc_banks_map(struct lbc_softc *sc) static int lbc_banks_enable(struct lbc_softc *sc) { - u_long size; + uint32_t size; uint32_t regval; int error, i; diff --git a/sys/powerpc/mpc85xx/mpc85xx.h b/sys/powerpc/mpc85xx/mpc85xx.h index ac8b8ff..e806225 100644 --- a/sys/powerpc/mpc85xx/mpc85xx.h +++ b/sys/powerpc/mpc85xx/mpc85xx.h @@ -132,6 +132,12 @@ extern vm_offset_t ccsrbar_va; #define OCP85XX_RSTCR (CCSRBAR_VA + 0xe00b0) /* + * Run Control/Power Management Registers. + */ +#define OCP85XX_RCPM_CDOZSR (CCSRBAR_VA + 0xe2004) +#define OCP85XX_RCPM_CDOZCR (CCSRBAR_VA + 0xe200c) + +/* * Prototypes. */ uint32_t ccsr_read4(uintptr_t addr); diff --git a/sys/powerpc/mpc85xx/pci_mpc85xx.c b/sys/powerpc/mpc85xx/pci_mpc85xx.c index 3c34c87..4397ac0 100644 --- a/sys/powerpc/mpc85xx/pci_mpc85xx.c +++ b/sys/powerpc/mpc85xx/pci_mpc85xx.c @@ -94,6 +94,29 @@ __FBSDID("$FreeBSD$"); #define REG_PEX_ERR_DR 0x0e00 #define REG_PEX_ERR_EN 0x0e08 +#define REG_PEX_ERR_DR 0x0e00 +#define REG_PEX_ERR_DR_ME 0x80000000 +#define REG_PEX_ERR_DR_PCT 0x800000 +#define REG_PEX_ERR_DR_PAT 0x400000 +#define REG_PEX_ERR_DR_PCAC 0x200000 +#define REG_PEX_ERR_DR_PNM 0x100000 +#define REG_PEX_ERR_DR_CDNSC 0x80000 +#define REG_PEX_ERR_DR_CRSNC 0x40000 +#define REG_PEX_ERR_DR_ICCA 0x20000 +#define REG_PEX_ERR_DR_IACA 0x10000 +#define REG_PEX_ERR_DR_CRST 0x8000 +#define REG_PEX_ERR_DR_MIS 0x4000 +#define REG_PEX_ERR_DR_IOIS 0x2000 +#define REG_PEX_ERR_DR_CIS 0x1000 +#define REG_PEX_ERR_DR_CIEP 0x800 +#define REG_PEX_ERR_DR_IOIEP 0x400 +#define REG_PEX_ERR_DR_OAC 0x200 +#define REG_PEX_ERR_DR_IOIA 0x100 +#define REG_PEX_ERR_DR_IMBA 0x80 +#define REG_PEX_ERR_DR_IIOBA 0x40 +#define REG_PEX_ERR_DR_LDDE 0x20 +#define REG_PEX_ERR_EN 0x0e08 + #define PCIR_LTSSM 0x404 #define LTSSM_STAT_L0 0x16 @@ -113,6 +136,9 @@ struct fsl_pcib_softc { bus_space_tag_t sc_bst; int sc_rid; + struct resource *sc_irq_res; + void *sc_ih; + int sc_busnr; int sc_pcie; uint8_t sc_pcie_capreg; /* PCI-E Capability Reg Set */ @@ -122,6 +148,34 @@ struct fsl_pcib_softc { int sc_devfn_via_ide; }; +struct fsl_pcib_err_dr { + const char *msg; + uint32_t err_dr_mask; +}; + +static const struct fsl_pcib_err_dr pci_err[] = { + {"ME", REG_PEX_ERR_DR_ME}, + {"PCT", REG_PEX_ERR_DR_PCT}, + {"PAT", REG_PEX_ERR_DR_PAT}, + {"PCAC", REG_PEX_ERR_DR_PCAC}, + {"PNM", REG_PEX_ERR_DR_PNM}, + {"CDNSC", REG_PEX_ERR_DR_CDNSC}, + {"CRSNC", REG_PEX_ERR_DR_CRSNC}, + {"ICCA", REG_PEX_ERR_DR_ICCA}, + {"IACA", REG_PEX_ERR_DR_IACA}, + {"CRST", REG_PEX_ERR_DR_CRST}, + {"MIS", REG_PEX_ERR_DR_MIS}, + {"IOIS", REG_PEX_ERR_DR_IOIS}, + {"CIS", REG_PEX_ERR_DR_CIS}, + {"CIEP", REG_PEX_ERR_DR_CIEP}, + {"IOIEP", REG_PEX_ERR_DR_IOIEP}, + {"OAC", REG_PEX_ERR_DR_OAC}, + {"IOIA", REG_PEX_ERR_DR_IOIA}, + {"IMBA", REG_PEX_ERR_DR_IMBA}, + {"IIOBA", REG_PEX_ERR_DR_IIOBA}, + {"LDDE", REG_PEX_ERR_DR_LDDE} +}; + /* Local forward declerations. */ static uint32_t fsl_pcib_cfgread(struct fsl_pcib_softc *, u_int, u_int, u_int, u_int, int); @@ -173,6 +227,35 @@ DEFINE_CLASS_1(pcib, fsl_pcib_driver, fsl_pcib_methods, DRIVER_MODULE(pcib, ofwbus, fsl_pcib_driver, fsl_pcib_devclass, 0, 0); static int +fsl_pcib_err_intr(void *v) +{ + struct fsl_pcib_softc *sc; + device_t dev; + uint32_t err_reg, clear_reg; + uint8_t i; + + dev = (device_t)v; + sc = device_get_softc(dev); + + clear_reg = 0; + err_reg = bus_space_read_4(sc->sc_bst, sc->sc_bsh, REG_PEX_ERR_DR); + + /* Check which one error occurred */ + for (i = 0; i < sizeof(pci_err)/sizeof(struct fsl_pcib_err_dr); i++) { + if (err_reg & pci_err[i].err_dr_mask) { + device_printf(dev, "PCI %d: report %s error\n", + device_get_unit(dev), pci_err[i].msg); + clear_reg |= pci_err[i].err_dr_mask; + } + } + + /* Clear pending errors */ + bus_space_write_4(sc->sc_bst, sc->sc_bsh, REG_PEX_ERR_DR, clear_reg); + + return (0); +} + +static int fsl_pcib_probe(device_t dev) { @@ -198,7 +281,7 @@ fsl_pcib_attach(device_t dev) struct fsl_pcib_softc *sc; phandle_t node; uint32_t cfgreg; - int maxslot, error; + int error, maxslot, rid; uint8_t ltssm, capptr; sc = device_get_softc(dev); @@ -279,6 +362,35 @@ fsl_pcib_attach(device_t dev) } } + /* Allocate irq */ + rid = 0; + sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, + RF_ACTIVE | RF_SHAREABLE); + if (sc->sc_irq_res == NULL) { + error = fsl_pcib_detach(dev); + if (error != 0) { + device_printf(dev, + "Detach of the driver failed with error %d\n", + error); + } + return (ENXIO); + } + + /* Setup interrupt handler */ + error = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_MISC | INTR_MPSAFE, + NULL, (driver_intr_t *)fsl_pcib_err_intr, dev, &sc->sc_ih); + if (error != 0) { + device_printf(dev, "Could not setup irq, %d\n", error); + sc->sc_ih = NULL; + error = fsl_pcib_detach(dev); + if (error != 0) { + device_printf(dev, + "Detach of the driver failed with error %d\n", + error); + } + return (ENXIO); + } + fsl_pcib_err_init(dev); return (ofw_pci_attach(dev)); diff --git a/sys/powerpc/mpc85xx/platform_mpc85xx.c b/sys/powerpc/mpc85xx/platform_mpc85xx.c index c84561d..3a36e6d 100644 --- a/sys/powerpc/mpc85xx/platform_mpc85xx.c +++ b/sys/powerpc/mpc85xx/platform_mpc85xx.c @@ -80,6 +80,8 @@ static int mpc85xx_smp_first_cpu(platform_t, struct cpuref *cpuref); static int mpc85xx_smp_next_cpu(platform_t, struct cpuref *cpuref); static int mpc85xx_smp_get_bsp(platform_t, struct cpuref *cpuref); static int mpc85xx_smp_start_cpu(platform_t, struct pcpu *cpu); +static void mpc85xx_idle(platform_t, int cpu); +static int mpc85xx_idle_wakeup(platform_t plat, int cpu); static void mpc85xx_reset(platform_t); @@ -95,6 +97,8 @@ static platform_method_t mpc85xx_methods[] = { PLATFORMMETHOD(platform_smp_start_cpu, mpc85xx_smp_start_cpu), PLATFORMMETHOD(platform_reset, mpc85xx_reset), + PLATFORMMETHOD(platform_idle, mpc85xx_idle), + PLATFORMMETHOD(platform_idle_wakeup, mpc85xx_idle_wakeup), PLATFORMMETHOD_END }; @@ -478,3 +482,36 @@ mpc85xx_reset(platform_t plat) ; } +static void +mpc85xx_idle(platform_t plat, int cpu) +{ +#ifdef QORIQ_DPAA + uint32_t reg; + + reg = ccsr_read4(OCP85XX_RCPM_CDOZCR); + ccsr_write4(OCP85XX_RCPM_CDOZCR, reg | (1 << cpu)); + ccsr_read4(OCP85XX_RCPM_CDOZCR); +#else + register_t msr; + + msr = mfmsr(); + /* Freescale E500 core RM section 6.4.1. */ + __asm __volatile("msync; mtmsr %0; isync" :: + "r" (msr | PSL_WE)); +#endif +} + +static int +mpc85xx_idle_wakeup(platform_t plat, int cpu) +{ +#ifdef QORIQ_DPAA + uint32_t reg; + + reg = ccsr_read4(OCP85XX_RCPM_CDOZCR); + ccsr_write4(OCP85XX_RCPM_CDOZCR, reg & ~(1 << cpu)); + ccsr_read4(OCP85XX_RCPM_CDOZCR); + + return (1); +#endif + return (0); +} diff --git a/sys/powerpc/ofw/rtas.c b/sys/powerpc/ofw/rtas.c index 15cb58e..5dff8ef 100644 --- a/sys/powerpc/ofw/rtas.c +++ b/sys/powerpc/ofw/rtas.c @@ -62,8 +62,6 @@ int rtascall(vm_offset_t callbuffer, uintptr_t rtas_privdat); extern uintptr_t rtas_entry; extern register_t rtasmsr; -int setfault(faultbuf); /* defined in locore.S */ - /* * After the VM is up, allocate RTAS memory and instantiate it */ @@ -203,7 +201,7 @@ int rtas_call_method(cell_t token, int nargs, int nreturns, ...) { vm_offset_t argsptr; - faultbuf env, *oldfaultbuf; + jmp_buf env, *oldfaultbuf; va_list ap; struct { cell_t token; @@ -233,7 +231,8 @@ rtas_call_method(cell_t token, int nargs, int nreturns, ...) /* Get rid of any stale machine checks that have been waiting. */ __asm __volatile ("sync; isync"); oldfaultbuf = curthread->td_pcb->pcb_onfault; - if (!setfault(env)) { + curthread->td_pcb->pcb_onfault = &env; + if (!setjmp(env)) { __asm __volatile ("sync"); result = rtascall(argsptr, rtas_private_data); __asm __volatile ("sync; isync"); diff --git a/sys/powerpc/powermac/grackle.c b/sys/powerpc/powermac/grackle.c index b4a8a3b..95d59a1 100644 --- a/sys/powerpc/powermac/grackle.c +++ b/sys/powerpc/powermac/grackle.c @@ -82,8 +82,6 @@ static int grackle_enable_config(struct grackle_softc *, u_int, static void grackle_disable_config(struct grackle_softc *); static int badaddr(void *, size_t); -int setfault(faultbuf); /* defined in locore.S */ - /* * Driver methods. */ @@ -244,7 +242,7 @@ static int badaddr(void *addr, size_t size) { struct thread *td; - faultbuf env, *oldfaultbuf; + jmp_buf env, *oldfaultbuf; int x; /* Get rid of any stale machine checks that have been waiting. */ @@ -253,7 +251,8 @@ badaddr(void *addr, size_t size) td = curthread; oldfaultbuf = td->td_pcb->pcb_onfault; - if (setfault(env)) { + td->td_pcb->pcb_onfault = &env; + if (setjmp(env)) { td->td_pcb->pcb_onfault = oldfaultbuf; __asm __volatile ("sync"); return 1; diff --git a/sys/powerpc/powerpc/copyinout.c b/sys/powerpc/powerpc/copyinout.c index fdee51d..29c4561 100644 --- a/sys/powerpc/powerpc/copyinout.c +++ b/sys/powerpc/powerpc/copyinout.c @@ -71,8 +71,6 @@ __FBSDID("$FreeBSD$"); #include <machine/slb.h> #include <machine/vmparam.h> -int setfault(faultbuf); /* defined in locore.S */ - #ifdef AIM /* * Makes sure that the right segment of userspace is mapped in. @@ -176,7 +174,7 @@ copyout(const void *kaddr, void *udaddr, size_t len) { struct thread *td; pmap_t pm; - faultbuf env; + jmp_buf env; const char *kp; char *up, *p; size_t l; @@ -184,7 +182,8 @@ copyout(const void *kaddr, void *udaddr, size_t len) td = curthread; pm = &td->td_proc->p_vmspace->vm_pmap; - if (setfault(env)) { + td->td_pcb->pcb_onfault = &env; + if (setjmp(env)) { td->td_pcb->pcb_onfault = NULL; return (EFAULT); } @@ -214,7 +213,7 @@ copyin(const void *udaddr, void *kaddr, size_t len) { struct thread *td; pmap_t pm; - faultbuf env; + jmp_buf env; const char *up; char *kp, *p; size_t l; @@ -222,7 +221,8 @@ copyin(const void *udaddr, void *kaddr, size_t len) td = curthread; pm = &td->td_proc->p_vmspace->vm_pmap; - if (setfault(env)) { + td->td_pcb->pcb_onfault = &env; + if (setjmp(env)) { td->td_pcb->pcb_onfault = NULL; return (EFAULT); } @@ -285,13 +285,14 @@ subyte(volatile void *addr, int byte) { struct thread *td; pmap_t pm; - faultbuf env; + jmp_buf env; char *p; td = curthread; pm = &td->td_proc->p_vmspace->vm_pmap; - if (setfault(env)) { + td->td_pcb->pcb_onfault = &env; + if (setjmp(env)) { td->td_pcb->pcb_onfault = NULL; return (-1); } @@ -313,13 +314,14 @@ suword32(volatile void *addr, int word) { struct thread *td; pmap_t pm; - faultbuf env; + jmp_buf env; int *p; td = curthread; pm = &td->td_proc->p_vmspace->vm_pmap; - if (setfault(env)) { + td->td_pcb->pcb_onfault = &env; + if (setjmp(env)) { td->td_pcb->pcb_onfault = NULL; return (-1); } @@ -341,13 +343,14 @@ suword(volatile void *addr, long word) { struct thread *td; pmap_t pm; - faultbuf env; + jmp_buf env; long *p; td = curthread; pm = &td->td_proc->p_vmspace->vm_pmap; - if (setfault(env)) { + td->td_pcb->pcb_onfault = &env; + if (setjmp(env)) { td->td_pcb->pcb_onfault = NULL; return (-1); } @@ -382,14 +385,15 @@ fubyte(volatile const void *addr) { struct thread *td; pmap_t pm; - faultbuf env; + jmp_buf env; u_char *p; int val; td = curthread; pm = &td->td_proc->p_vmspace->vm_pmap; - if (setfault(env)) { + td->td_pcb->pcb_onfault = &env; + if (setjmp(env)) { td->td_pcb->pcb_onfault = NULL; return (-1); } @@ -410,13 +414,14 @@ fuword16(volatile const void *addr) { struct thread *td; pmap_t pm; - faultbuf env; + jmp_buf env; uint16_t *p, val; td = curthread; pm = &td->td_proc->p_vmspace->vm_pmap; - if (setfault(env)) { + td->td_pcb->pcb_onfault = &env; + if (setjmp(env)) { td->td_pcb->pcb_onfault = NULL; return (-1); } @@ -437,13 +442,14 @@ fueword32(volatile const void *addr, int32_t *val) { struct thread *td; pmap_t pm; - faultbuf env; + jmp_buf env; int32_t *p; td = curthread; pm = &td->td_proc->p_vmspace->vm_pmap; - if (setfault(env)) { + td->td_pcb->pcb_onfault = &env; + if (setjmp(env)) { td->td_pcb->pcb_onfault = NULL; return (-1); } @@ -465,13 +471,14 @@ fueword64(volatile const void *addr, int64_t *val) { struct thread *td; pmap_t pm; - faultbuf env; + jmp_buf env; int64_t *p; td = curthread; pm = &td->td_proc->p_vmspace->vm_pmap; - if (setfault(env)) { + td->td_pcb->pcb_onfault = &env; + if (setjmp(env)) { td->td_pcb->pcb_onfault = NULL; return (-1); } @@ -493,13 +500,14 @@ fueword(volatile const void *addr, long *val) { struct thread *td; pmap_t pm; - faultbuf env; + jmp_buf env; long *p; td = curthread; pm = &td->td_proc->p_vmspace->vm_pmap; - if (setfault(env)) { + td->td_pcb->pcb_onfault = &env; + if (setjmp(env)) { td->td_pcb->pcb_onfault = NULL; return (-1); } @@ -521,13 +529,14 @@ casueword32(volatile uint32_t *addr, uint32_t old, uint32_t *oldvalp, { struct thread *td; pmap_t pm; - faultbuf env; + jmp_buf env; uint32_t *p, val; td = curthread; pm = &td->td_proc->p_vmspace->vm_pmap; - if (setfault(env)) { + td->td_pcb->pcb_onfault = &env; + if (setjmp(env)) { td->td_pcb->pcb_onfault = NULL; return (-1); } @@ -572,13 +581,14 @@ casueword(volatile u_long *addr, u_long old, u_long *oldvalp, u_long new) { struct thread *td; pmap_t pm; - faultbuf env; + jmp_buf env; u_long *p, val; td = curthread; pm = &td->td_proc->p_vmspace->vm_pmap; - if (setfault(env)) { + td->td_pcb->pcb_onfault = &env; + if (setjmp(env)) { td->td_pcb->pcb_onfault = NULL; return (-1); } diff --git a/sys/powerpc/powerpc/cpu.c b/sys/powerpc/powerpc/cpu.c index 43190ae..8892417 100644 --- a/sys/powerpc/powerpc/cpu.c +++ b/sys/powerpc/powerpc/cpu.c @@ -91,6 +91,7 @@ struct cputab { uint16_t revfmt; int features; /* Do not include PPC_FEATURE_32 or * PPC_FEATURE_HAS_MMU */ + int features2; void (*cpu_setup)(int cpuid, uint16_t vers); }; #define REVFMT_MAJMIN 1 /* %u.%u */ @@ -98,93 +99,102 @@ struct cputab { #define REVFMT_DEC 3 /* %u */ static const struct cputab models[] = { { "Motorola PowerPC 601", MPC601, REVFMT_DEC, - PPC_FEATURE_HAS_FPU | PPC_FEATURE_UNIFIED_CACHE, cpu_6xx_setup }, + PPC_FEATURE_HAS_FPU | PPC_FEATURE_UNIFIED_CACHE, 0, cpu_6xx_setup }, { "Motorola PowerPC 602", MPC602, REVFMT_DEC, - PPC_FEATURE_HAS_FPU, cpu_6xx_setup }, + PPC_FEATURE_HAS_FPU, 0, cpu_6xx_setup }, { "Motorola PowerPC 603", MPC603, REVFMT_MAJMIN, - PPC_FEATURE_HAS_FPU, cpu_6xx_setup }, + PPC_FEATURE_HAS_FPU, 0, cpu_6xx_setup }, { "Motorola PowerPC 603e", MPC603e, REVFMT_MAJMIN, - PPC_FEATURE_HAS_FPU, cpu_6xx_setup }, + PPC_FEATURE_HAS_FPU, 0, cpu_6xx_setup }, { "Motorola PowerPC 603ev", MPC603ev, REVFMT_MAJMIN, - PPC_FEATURE_HAS_FPU, cpu_6xx_setup }, + PPC_FEATURE_HAS_FPU, 0, cpu_6xx_setup }, { "Motorola PowerPC 604", MPC604, REVFMT_MAJMIN, - PPC_FEATURE_HAS_FPU, cpu_6xx_setup }, + PPC_FEATURE_HAS_FPU, 0, cpu_6xx_setup }, { "Motorola PowerPC 604ev", MPC604ev, REVFMT_MAJMIN, - PPC_FEATURE_HAS_FPU, cpu_6xx_setup }, + PPC_FEATURE_HAS_FPU, 0, cpu_6xx_setup }, { "Motorola PowerPC 620", MPC620, REVFMT_HEX, - PPC_FEATURE_64 | PPC_FEATURE_HAS_FPU, NULL }, + PPC_FEATURE_64 | PPC_FEATURE_HAS_FPU, 0, NULL }, { "Motorola PowerPC 750", MPC750, REVFMT_MAJMIN, - PPC_FEATURE_HAS_FPU, cpu_6xx_setup }, + PPC_FEATURE_HAS_FPU, 0, cpu_6xx_setup }, { "IBM PowerPC 750FX", IBM750FX, REVFMT_MAJMIN, - PPC_FEATURE_HAS_FPU, cpu_6xx_setup }, + PPC_FEATURE_HAS_FPU, 0, cpu_6xx_setup }, { "IBM PowerPC 970", IBM970, REVFMT_MAJMIN, PPC_FEATURE_64 | PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, - cpu_970_setup }, + 0, cpu_970_setup }, { "IBM PowerPC 970FX", IBM970FX, REVFMT_MAJMIN, PPC_FEATURE_64 | PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, - cpu_970_setup }, + 0, cpu_970_setup }, { "IBM PowerPC 970GX", IBM970GX, REVFMT_MAJMIN, PPC_FEATURE_64 | PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, - cpu_970_setup }, + 0, cpu_970_setup }, { "IBM PowerPC 970MP", IBM970MP, REVFMT_MAJMIN, PPC_FEATURE_64 | PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, - cpu_970_setup }, + 0, cpu_970_setup }, { "IBM POWER4", IBMPOWER4, REVFMT_MAJMIN, - PPC_FEATURE_64 | PPC_FEATURE_HAS_FPU, NULL }, + PPC_FEATURE_64 | PPC_FEATURE_HAS_FPU, 0, NULL }, { "IBM POWER4+", IBMPOWER4PLUS, REVFMT_MAJMIN, - PPC_FEATURE_64 | PPC_FEATURE_HAS_FPU, NULL }, + PPC_FEATURE_64 | PPC_FEATURE_HAS_FPU, 0, NULL }, { "IBM POWER5", IBMPOWER5, REVFMT_MAJMIN, - PPC_FEATURE_64 | PPC_FEATURE_HAS_FPU, NULL }, + PPC_FEATURE_64 | PPC_FEATURE_HAS_FPU | PPC_FEATURE_SMT, 0, NULL }, { "IBM POWER5+", IBMPOWER5PLUS, REVFMT_MAJMIN, - PPC_FEATURE_64 | PPC_FEATURE_HAS_FPU, NULL }, + PPC_FEATURE_64 | PPC_FEATURE_HAS_FPU | PPC_FEATURE_SMT, 0, NULL }, { "IBM POWER6", IBMPOWER6, REVFMT_MAJMIN, - PPC_FEATURE_64 | PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, - NULL }, + PPC_FEATURE_64 | PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU | + PPC_FEATURE_SMT | PPC_FEATURE_ARCH_2_05, 0, NULL }, { "IBM POWER7", IBMPOWER7, REVFMT_MAJMIN, PPC_FEATURE_64 | PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU | - PPC_FEATURE_HAS_VSX, NULL }, + PPC_FEATURE_SMT | PPC_FEATURE_ARCH_2_05 | PPC_FEATURE_ARCH_2_06 | + PPC_FEATURE_HAS_VSX, 0, NULL }, { "IBM POWER7+", IBMPOWER7PLUS, REVFMT_MAJMIN, PPC_FEATURE_64 | PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU | - PPC_FEATURE_HAS_VSX, NULL }, + PPC_FEATURE_SMT | PPC_FEATURE_ARCH_2_05 | PPC_FEATURE_ARCH_2_06 | + PPC_FEATURE_HAS_VSX, 0, NULL }, { "IBM POWER8E", IBMPOWER8E, REVFMT_MAJMIN, PPC_FEATURE_64 | PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU | - PPC_FEATURE_HAS_VSX, NULL }, + PPC_FEATURE_SMT | PPC_FEATURE_ARCH_2_05 | PPC_FEATURE_ARCH_2_06 | + PPC_FEATURE_HAS_VSX, + PPC_FEATURE2_ARCH_2_07 | PPC_FEATURE2_HAS_HTM | + PPC_FEATURE2_HAS_VCRYPTO, NULL }, { "IBM POWER8", IBMPOWER8, REVFMT_MAJMIN, PPC_FEATURE_64 | PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU | - PPC_FEATURE_HAS_VSX, NULL }, + PPC_FEATURE_SMT | PPC_FEATURE_ARCH_2_05 | PPC_FEATURE_ARCH_2_06 | + PPC_FEATURE_HAS_VSX, + PPC_FEATURE2_ARCH_2_07 | PPC_FEATURE2_HAS_HTM | + PPC_FEATURE2_HAS_VCRYPTO, NULL }, { "Motorola PowerPC 7400", MPC7400, REVFMT_MAJMIN, - PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, cpu_6xx_setup }, + PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, 0, cpu_6xx_setup }, { "Motorola PowerPC 7410", MPC7410, REVFMT_MAJMIN, - PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, cpu_6xx_setup }, + PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, 0, cpu_6xx_setup }, { "Motorola PowerPC 7450", MPC7450, REVFMT_MAJMIN, - PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, cpu_6xx_setup }, + PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, 0, cpu_6xx_setup }, { "Motorola PowerPC 7455", MPC7455, REVFMT_MAJMIN, - PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, cpu_6xx_setup }, + PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, 0, cpu_6xx_setup }, { "Motorola PowerPC 7457", MPC7457, REVFMT_MAJMIN, - PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, cpu_6xx_setup }, + PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, 0, cpu_6xx_setup }, { "Motorola PowerPC 7447A", MPC7447A, REVFMT_MAJMIN, - PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, cpu_6xx_setup }, + PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, 0, cpu_6xx_setup }, { "Motorola PowerPC 7448", MPC7448, REVFMT_MAJMIN, - PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, cpu_6xx_setup }, + PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, 0, cpu_6xx_setup }, { "Motorola PowerPC 8240", MPC8240, REVFMT_MAJMIN, - PPC_FEATURE_HAS_FPU, cpu_6xx_setup }, + PPC_FEATURE_HAS_FPU, 0, cpu_6xx_setup }, { "Motorola PowerPC 8245", MPC8245, REVFMT_MAJMIN, - PPC_FEATURE_HAS_FPU, cpu_6xx_setup }, + PPC_FEATURE_HAS_FPU, 0, cpu_6xx_setup }, { "Freescale e500v1 core", FSL_E500v1, REVFMT_MAJMIN, - 0, cpu_booke_setup }, + PPC_FEATURE_BOOKE, 0, cpu_booke_setup }, { "Freescale e500v2 core", FSL_E500v2, REVFMT_MAJMIN, - 0, cpu_booke_setup }, + PPC_FEATURE_BOOKE, 0, cpu_booke_setup }, { "Freescale e500mc core", FSL_E500mc, REVFMT_MAJMIN, - PPC_FEATURE_HAS_FPU, cpu_booke_setup }, + PPC_FEATURE_BOOKE | PPC_FEATURE_HAS_FPU, 0, cpu_booke_setup }, { "Freescale e5500 core", FSL_E5500, REVFMT_MAJMIN, - PPC_FEATURE_64 | PPC_FEATURE_HAS_FPU, cpu_booke_setup }, - { "Freescale e6500 core", FSL_E6500, REVFMT_MAJMIN, - PPC_FEATURE_64 | PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, + PPC_FEATURE_BOOKE | PPC_FEATURE_64 | PPC_FEATURE_HAS_FPU, 0, cpu_booke_setup }, + { "Freescale e6500 core", FSL_E6500, REVFMT_MAJMIN, + PPC_FEATURE_BOOKE | PPC_FEATURE_64 | PPC_FEATURE_HAS_ALTIVEC | + PPC_FEATURE_HAS_FPU, 0, cpu_booke_setup }, { "IBM Cell Broadband Engine", IBMCELLBE, REVFMT_MAJMIN, - PPC_FEATURE_64 | PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU, - NULL}, - { "Unknown PowerPC CPU", 0, REVFMT_HEX, 0, NULL }, + PPC_FEATURE_64 | PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU | + PPC_FEATURE_SMT, 0, NULL}, + { "Unknown PowerPC CPU", 0, REVFMT_HEX, 0, 0, NULL }, }; static void cpu_6xx_print_cacheinfo(u_int, uint16_t); @@ -194,8 +204,11 @@ static char model[64]; SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD, model, 0, ""); int cpu_features = PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU; +int cpu_features2 = 0; SYSCTL_OPAQUE(_hw, OID_AUTO, cpu_features, CTLFLAG_RD, &cpu_features, sizeof(cpu_features), "IX", "PowerPC CPU features"); +SYSCTL_OPAQUE(_hw, OID_AUTO, cpu_features2, CTLFLAG_RD, + &cpu_features2, sizeof(cpu_features2), "IX", "PowerPC CPU features 2"); /* Provide some user-friendly aliases for bits in cpu_features */ SYSCTL_PROC(_hw, OID_AUTO, floatingpoint, CTLTYPE_INT | CTLFLAG_RD, @@ -265,8 +278,12 @@ cpu_setup(u_int cpuid) printf("\n"); cpu_features |= cp->features; + cpu_features2 |= cp->features2; printf("cpu%d: Features %b\n", cpuid, cpu_features, PPC_FEATURE_BITMASK); + if (cpu_features2 != 0) + printf("cpu%d: Features2 %b\n", cpuid, cpu_features2, + PPC_FEATURE2_BITMASK); /* * Configure CPU @@ -607,12 +624,6 @@ cpu_idle(int busy) busy, curcpu); } -int -cpu_idle_wakeup(int cpu) -{ - return (0); -} - static void cpu_idle_60x(sbintime_t sbt) { @@ -651,14 +662,9 @@ cpu_idle_60x(sbintime_t sbt) static void cpu_idle_booke(sbintime_t sbt) { - register_t msr; - - msr = mfmsr(); #ifdef E500 - /* Freescale E500 core RM section 6.4.1. */ - __asm __volatile("msync; mtmsr %0; isync" :: - "r" (msr | PSL_WE)); + platform_cpu_idle(PCPU_GET(cpuid)); #endif } diff --git a/sys/powerpc/powerpc/elf32_machdep.c b/sys/powerpc/powerpc/elf32_machdep.c index 027105d..eed76c9 100644 --- a/sys/powerpc/powerpc/elf32_machdep.c +++ b/sys/powerpc/powerpc/elf32_machdep.c @@ -106,6 +106,7 @@ struct sysentvec elf32_freebsd_sysvec = { .sv_shared_page_len = PAGE_SIZE, .sv_schedtail = NULL, .sv_thread_detach = NULL, + .sv_trap = NULL, }; INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec); diff --git a/sys/powerpc/powerpc/elf64_machdep.c b/sys/powerpc/powerpc/elf64_machdep.c index 261660a..032728c 100644 --- a/sys/powerpc/powerpc/elf64_machdep.c +++ b/sys/powerpc/powerpc/elf64_machdep.c @@ -85,6 +85,7 @@ struct sysentvec elf64_freebsd_sysvec_v1 = { .sv_shared_page_len = PAGE_SIZE, .sv_schedtail = NULL, .sv_thread_detach = NULL, + .sv_trap = NULL, }; INIT_SYSENTVEC(elf64_sysvec_v1, &elf64_freebsd_sysvec_v1); diff --git a/sys/powerpc/powerpc/intr_machdep.c b/sys/powerpc/powerpc/intr_machdep.c index b481279..a17d9ff 100644 --- a/sys/powerpc/powerpc/intr_machdep.c +++ b/sys/powerpc/powerpc/intr_machdep.c @@ -352,6 +352,9 @@ powerpc_register_pic(device_t dev, uint32_t node, u_int irqs, u_int ipis, npics++; } + KASSERT(npics < MAX_PICS, + ("Number of PICs exceeds maximum (%d)", MAX_PICS)); + mtx_unlock(&intr_table_lock); } @@ -385,6 +388,9 @@ powerpc_get_irq(uint32_t node, u_int pin) nirqs += 128; npics++; + KASSERT(npics < MAX_PICS, + ("Number of PICs exceeds maximum (%d)", MAX_PICS)); + mtx_unlock(&intr_table_lock); return (piclist[idx].base + pin); diff --git a/sys/powerpc/powerpc/machdep.c b/sys/powerpc/powerpc/machdep.c index dea3461..0913a60 100644 --- a/sys/powerpc/powerpc/machdep.c +++ b/sys/powerpc/powerpc/machdep.c @@ -261,7 +261,8 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp) kmdp = preload_search_by_type("elf kernel"); if (kmdp != NULL) { boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int); - kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); + init_static_kenv(MD_FETCH(kmdp, MODINFOMD_ENVP, char *), + 0); endkernel = ulmax(endkernel, MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t)); #ifdef DDB diff --git a/sys/powerpc/powerpc/mp_machdep.c b/sys/powerpc/powerpc/mp_machdep.c index 9d26e95..2f20b71 100644 --- a/sys/powerpc/powerpc/mp_machdep.c +++ b/sys/powerpc/powerpc/mp_machdep.c @@ -67,7 +67,6 @@ volatile static u_quad_t ap_timebase; static u_int ipi_msg_cnt[32]; static struct mtx ap_boot_mtx; struct pcb stoppcbs[MAXCPU]; -int longfault(faultbuf, int); void machdep_ap_bootstrap(void) diff --git a/sys/powerpc/powerpc/platform.c b/sys/powerpc/powerpc/platform.c index 8168758..b29ad92 100644 --- a/sys/powerpc/powerpc/platform.c +++ b/sys/powerpc/powerpc/platform.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include <sys/lock.h> #include <sys/ktr.h> #include <sys/mutex.h> +#include <sys/proc.h> #include <sys/systm.h> #include <sys/smp.h> #include <sys/sysctl.h> @@ -252,6 +253,19 @@ cpu_reset() PLATFORM_RESET(plat_obj); } +int +cpu_idle_wakeup(int cpu) +{ + return (PLATFORM_IDLE_WAKEUP(plat_obj, cpu)); +} + +void +platform_cpu_idle(int cpu) +{ + + PLATFORM_IDLE(plat_obj, cpu); +} + /* * Platform install routines. Highest priority wins, using the same * algorithm as bus attachment. diff --git a/sys/powerpc/powerpc/platform_if.m b/sys/powerpc/powerpc/platform_if.m index dfa2be1..a562b32 100644 --- a/sys/powerpc/powerpc/platform_if.m +++ b/sys/powerpc/powerpc/platform_if.m @@ -84,6 +84,14 @@ CODE { { return; } + static void platform_null_idle(platform_t plat, int cpu) + { + return; + } + static int platform_null_idle_wakeup(platform_t plat, int cpu) + { + return (0); + } }; /** @@ -211,6 +219,22 @@ METHOD void reset { }; /** + * @brief Idle a CPU + */ +METHOD void idle { + platform_t _plat; + int _cpu; +} DEFAULT platform_null_idle; + +/** + * @brief Wake up an idle CPU + */ +METHOD int idle_wakeup { + platform_t _plat; + int _cpu; +} DEFAULT platform_null_idle_wakeup; + +/** * @brief Suspend the CPU */ METHOD void sleep { diff --git a/sys/powerpc/powerpc/setjmp.S b/sys/powerpc/powerpc/setjmp.S index 3884b11..910f58b 100644 --- a/sys/powerpc/powerpc/setjmp.S +++ b/sys/powerpc/powerpc/setjmp.S @@ -40,7 +40,6 @@ #define JMP_cr 22*REGWIDTH #define JMP_ctr 23*REGWIDTH #define JMP_xer 24*REGWIDTH -#define JMP_sig 25*REGWIDTH ASENTRY_NOPROF(setjmp) ST_REG 31, JMP_r31(3) diff --git a/sys/powerpc/powerpc/trap.c b/sys/powerpc/powerpc/trap.c index 4c9735a..d4dac2e 100644 --- a/sys/powerpc/powerpc/trap.c +++ b/sys/powerpc/powerpc/trap.c @@ -74,11 +74,12 @@ __FBSDID("$FreeBSD$"); #include <machine/spr.h> #include <machine/sr.h> -#define FAULTBUF_LR 0 +/* Below matches setjmp.S */ +#define FAULTBUF_LR 21 #define FAULTBUF_R1 1 #define FAULTBUF_R2 2 -#define FAULTBUF_CR 3 -#define FAULTBUF_R13 4 +#define FAULTBUF_CR 22 +#define FAULTBUF_R14 3 static void trap_fatal(struct trapframe *frame); static void printtrap(u_int vector, struct trapframe *frame, int isfatal, @@ -462,18 +463,19 @@ static int handle_onfault(struct trapframe *frame) { struct thread *td; - faultbuf *fb; + jmp_buf *fb; td = curthread; fb = td->td_pcb->pcb_onfault; if (fb != NULL) { - frame->srr0 = (*fb)[FAULTBUF_LR]; - frame->fixreg[1] = (*fb)[FAULTBUF_R1]; - frame->fixreg[2] = (*fb)[FAULTBUF_R2]; + frame->srr0 = (*fb)->_jb[FAULTBUF_LR]; + frame->fixreg[1] = (*fb)->_jb[FAULTBUF_R1]; + frame->fixreg[2] = (*fb)->_jb[FAULTBUF_R2]; frame->fixreg[3] = 1; - frame->cr = (*fb)[FAULTBUF_CR]; - bcopy(&(*fb)[FAULTBUF_R13], &frame->fixreg[13], - 19 * sizeof(register_t)); + frame->cr = (*fb)->_jb[FAULTBUF_CR]; + bcopy(&(*fb)->_jb[FAULTBUF_R14], &frame->fixreg[14], + 18 * sizeof(register_t)); + td->td_pcb->pcb_onfault = NULL; /* Returns twice, not thrice */ return (1); } return (0); diff --git a/sys/sparc64/include/ofw_machdep.h b/sys/sparc64/include/ofw_machdep.h index bc69b3b..fcacc10 100644 --- a/sys/sparc64/include/ofw_machdep.h +++ b/sys/sparc64/include/ofw_machdep.h @@ -34,6 +34,9 @@ typedef uint64_t cell_t; +/* sparc64 doesn't use the interrupt parent #address-cells in interrupt maps */ +#define OFW_IMAP_NO_IPARENT_ADDR_CELLS + int OF_decode_addr(phandle_t, int, int *, bus_addr_t *); void OF_getetheraddr(device_t, u_char *); u_int OF_getscsinitid(device_t); diff --git a/sys/sparc64/sparc64/elf_machdep.c b/sys/sparc64/sparc64/elf_machdep.c index eea21a2..c2b0d26 100644 --- a/sys/sparc64/sparc64/elf_machdep.c +++ b/sys/sparc64/sparc64/elf_machdep.c @@ -85,6 +85,7 @@ static struct sysentvec elf64_freebsd_sysvec = { .sv_syscallnames = syscallnames, .sv_schedtail = NULL, .sv_thread_detach = NULL, + .sv_trap = NULL, }; static Elf64_Brandinfo freebsd_brand_info = { diff --git a/sys/sparc64/sparc64/machdep.c b/sys/sparc64/sparc64/machdep.c index 95b10e3..d3cd7a2 100644 --- a/sys/sparc64/sparc64/machdep.c +++ b/sys/sparc64/sparc64/machdep.c @@ -379,7 +379,8 @@ sparc64_init(caddr_t mdp, u_long o1, u_long o2, u_long o3, ofw_vec_t *vec) kmdp = preload_search_by_type("elf kernel"); if (kmdp != NULL) { boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int); - kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); + init_static_kenv(MD_FETCH(kmdp, MODINFOMD_ENVP, char *), + 0); end = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t); kernel_tlb_slots = MD_FETCH(kmdp, MODINFOMD_DTLB_SLOTS, int); diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 4681acd..a0dbc72 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -226,6 +226,28 @@ void clone_cleanup(struct clonedevs **); #define CLONE_FLAG0 (CLONE_UNITMASK + 1) int clone_create(struct clonedevs **, struct cdevsw *, int *unit, struct cdev **dev, int extra); +#define MAKEDEV_REF 0x01 +#define MAKEDEV_WHTOUT 0x02 +#define MAKEDEV_NOWAIT 0x04 +#define MAKEDEV_WAITOK 0x08 +#define MAKEDEV_ETERNAL 0x10 +#define MAKEDEV_CHECKNAME 0x20 +struct make_dev_args { + size_t mda_size; + int mda_flags; + struct cdevsw *mda_devsw; + struct ucred *mda_cr; + uid_t mda_uid; + gid_t mda_gid; + int mda_mode; + int mda_unit; + void *mda_si_drv1; + void *mda_si_drv2; +}; +void make_dev_args_init_impl(struct make_dev_args *_args, size_t _sz); +#define make_dev_args_init(a) \ + make_dev_args_init_impl((a), sizeof(struct make_dev_args)) + int count_dev(struct cdev *_dev); void delist_dev(struct cdev *_dev); void destroy_dev(struct cdev *_dev); @@ -245,12 +267,6 @@ struct cdev *make_dev(struct cdevsw *_devsw, int _unit, uid_t _uid, gid_t _gid, struct cdev *make_dev_cred(struct cdevsw *_devsw, int _unit, struct ucred *_cr, uid_t _uid, gid_t _gid, int _perms, const char *_fmt, ...) __printflike(7, 8); -#define MAKEDEV_REF 0x01 -#define MAKEDEV_WHTOUT 0x02 -#define MAKEDEV_NOWAIT 0x04 -#define MAKEDEV_WAITOK 0x08 -#define MAKEDEV_ETERNAL 0x10 -#define MAKEDEV_CHECKNAME 0x20 struct cdev *make_dev_credf(int _flags, struct cdevsw *_devsw, int _unit, struct ucred *_cr, uid_t _uid, gid_t _gid, int _mode, @@ -258,6 +274,8 @@ struct cdev *make_dev_credf(int _flags, int make_dev_p(int _flags, struct cdev **_cdev, struct cdevsw *_devsw, struct ucred *_cr, uid_t _uid, gid_t _gid, int _mode, const char *_fmt, ...) __printflike(8, 9); +int make_dev_s(struct make_dev_args *_args, struct cdev **_cdev, + const char *_fmt, ...) __printflike(3, 4); struct cdev *make_dev_alias(struct cdev *_pdev, const char *_fmt, ...) __printflike(2, 3); int make_dev_alias_p(int _flags, struct cdev **_cdev, struct cdev *_pdev, diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 8509a6c..91dd895 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -343,12 +343,13 @@ struct mbuf { * External mbuf storage buffer types. */ #define EXT_CLUSTER 1 /* mbuf cluster */ -#define EXT_SFBUF 2 /* sendfile(2)'s sf_bufs */ +#define EXT_SFBUF 2 /* sendfile(2)'s sf_buf */ #define EXT_JUMBOP 3 /* jumbo cluster page sized */ #define EXT_JUMBO9 4 /* jumbo cluster 9216 bytes */ #define EXT_JUMBO16 5 /* jumbo cluster 16184 bytes */ #define EXT_PACKET 6 /* mbuf+cluster from packet zone */ #define EXT_MBUF 7 /* external mbuf reference (M_IOVEC) */ +#define EXT_SFBUF_NOCACHE 8 /* sendfile(2)'s sf_buf not to be cached */ #define EXT_VENDOR1 224 /* for vendor-internal use */ #define EXT_VENDOR2 225 /* for vendor-internal use */ @@ -397,6 +398,7 @@ struct mbuf { */ void sf_ext_ref(void *, void *); void sf_ext_free(void *, void *); +void sf_ext_free_nocache(void *, void *); /* * Flags indicating checksum, segmentation and other offload work to be diff --git a/sys/sys/nv.h b/sys/sys/nv.h index a985b6d..fcea2b3 100644 --- a/sys/sys/nv.h +++ b/sys/sys/nv.h @@ -146,7 +146,7 @@ void nvlist_add_bool(nvlist_t *nvl, const char *name, bool value); void nvlist_add_number(nvlist_t *nvl, const char *name, uint64_t value); void nvlist_add_string(nvlist_t *nvl, const char *name, const char *value); void nvlist_add_stringf(nvlist_t *nvl, const char *name, const char *valuefmt, ...) __printflike(3, 4); -#ifdef _VA_LIST_DECLARED +#if !defined(_KERNEL) || defined(_VA_LIST_DECLARED) void nvlist_add_stringv(nvlist_t *nvl, const char *name, const char *valuefmt, va_list valueap) __printflike(3, 0); #endif void nvlist_add_nvlist(nvlist_t *nvl, const char *name, const nvlist_t *value); diff --git a/sys/sys/sf_buf.h b/sys/sys/sf_buf.h index d3bb037..b5970d9 100644 --- a/sys/sys/sf_buf.h +++ b/sys/sys/sf_buf.h @@ -31,7 +31,14 @@ #define _SYS_SF_BUF_H_ struct sfstat { /* sendfile statistics */ + uint64_t sf_syscalls; /* times sendfile was called */ + uint64_t sf_noiocnt; /* times sendfile didn't require I/O */ uint64_t sf_iocnt; /* times sendfile had to do disk I/O */ + uint64_t sf_pages_read; /* pages read as part of a request */ + uint64_t sf_pages_valid; /* pages were valid for a request */ + uint64_t sf_rhpages_requested; /* readahead pages requested */ + uint64_t sf_rhpages_read; /* readahead pages read */ + uint64_t sf_busy; /* times aborted on a busy page */ uint64_t sf_allocfail; /* times sfbuf allocation failed */ uint64_t sf_allocwait; /* times sfbuf allocation had to wait */ }; diff --git a/sys/sys/sockbuf.h b/sys/sys/sockbuf.h index 0e3e172..c6904f6 100644 --- a/sys/sys/sockbuf.h +++ b/sys/sys/sockbuf.h @@ -129,8 +129,8 @@ struct sockbuf { #define M_BLOCKED M_PROTO2 /* M_NOTREADY in front of m */ #define M_NOTAVAIL (M_NOTREADY | M_BLOCKED) -void sbappend(struct sockbuf *sb, struct mbuf *m); -void sbappend_locked(struct sockbuf *sb, struct mbuf *m); +void sbappend(struct sockbuf *sb, struct mbuf *m, int flags); +void sbappend_locked(struct sockbuf *sb, struct mbuf *m, int flags); void sbappendstream(struct sockbuf *sb, struct mbuf *m, int flags); void sbappendstream_locked(struct sockbuf *sb, struct mbuf *m, int flags); int sbappendaddr(struct sockbuf *sb, const struct sockaddr *asa, diff --git a/sys/sys/socket.h b/sys/sys/socket.h index 18e2de1..ee621d9 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -587,11 +587,14 @@ struct sf_hdtr { * Sendfile-specific flag(s) */ #define SF_NODISKIO 0x00000001 -#define SF_MNOWAIT 0x00000002 +#define SF_MNOWAIT 0x00000002 /* obsolete */ #define SF_SYNC 0x00000004 +#define SF_NOCACHE 0x00000010 +#define SF_FLAGS(rh, flags) (((rh) << 16) | (flags)) #ifdef _KERNEL #define SFK_COMPAT 0x00000001 +#define SF_READAHEAD(flags) ((flags) >> 16) #endif /* _KERNEL */ #endif /* __BSD_VISIBLE */ diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h index d5b88eb..a79ff04 100644 --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -129,6 +129,7 @@ struct sysentvec { void *sv_shared_page_obj; void (*sv_schedtail)(struct thread *); void (*sv_thread_detach)(struct thread *); + int (*sv_trap)(struct thread *); }; #define SV_ILP32 0x000100 /* 32-bit executable. */ diff --git a/sys/vm/vm_domain.c b/sys/vm/vm_domain.c index 83814d5..c042aa7 100644 --- a/sys/vm/vm_domain.c +++ b/sys/vm/vm_domain.c @@ -62,7 +62,7 @@ __FBSDID("$FreeBSD$"); #include <vm/vm_domain.h> static __inline int -vm_domain_rr_selectdomain(void) +vm_domain_rr_selectdomain(int skip_domain) { #if MAXMEMDOM > 1 struct thread *td; @@ -71,6 +71,16 @@ vm_domain_rr_selectdomain(void) td->td_dom_rr_idx++; td->td_dom_rr_idx %= vm_ndomains; + + /* + * If skip_domain is provided then skip over that + * domain. This is intended for round robin variants + * which first try a fixed domain. + */ + if ((skip_domain > -1) && (td->td_dom_rr_idx == skip_domain)) { + td->td_dom_rr_idx++; + td->td_dom_rr_idx %= vm_ndomains; + } return (td->td_dom_rr_idx); #else return (0); @@ -339,12 +349,12 @@ vm_domain_iterator_run(struct vm_domain_iterator *vi, int *domain) if (vi->n == vm_ndomains) *domain = vi->domain; else - *domain = vm_domain_rr_selectdomain(); + *domain = vm_domain_rr_selectdomain(vi->domain); vi->n--; break; case VM_POLICY_ROUND_ROBIN: default: - *domain = vm_domain_rr_selectdomain(); + *domain = vm_domain_rr_selectdomain(-1); vi->n--; break; } diff --git a/sys/x86/include/metadata.h b/sys/x86/include/metadata.h new file mode 100644 index 0000000..e13eba0 --- /dev/null +++ b/sys/x86/include/metadata.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2003 Peter Wemm <peter@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_METADATA_H_ +#define _MACHINE_METADATA_H_ + +#define MODINFOMD_SMAP 0x1001 +#define MODINFOMD_SMAP_XATTR 0x1002 +#define MODINFOMD_DTBP 0x1003 +#define MODINFOMD_EFI_MAP 0x1004 +#define MODINFOMD_EFI_FB 0x1005 +#define MODINFOMD_MODULEP 0x1006 + +struct efi_map_header { + uint64_t memory_size; + uint64_t descriptor_size; + uint32_t descriptor_version; +}; + +struct efi_fb { + uint64_t fb_addr; + uint64_t fb_size; + uint32_t fb_height; + uint32_t fb_width; + uint32_t fb_stride; + uint32_t fb_mask_red; + uint32_t fb_mask_green; + uint32_t fb_mask_blue; + uint32_t fb_mask_reserved; +}; + +#endif /* !_MACHINE_METADATA_H_ */ diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c index 58eb736..1cea294 100644 --- a/sys/x86/xen/pv.c +++ b/sys/x86/xen/pv.c @@ -296,7 +296,7 @@ xen_pv_set_env(void) for (cmd_line_next = cmd_line; strsep(&cmd_line_next, ",") != NULL;) ; - init_static_kenv(cmd_line, env_size); + init_static_kenv(cmd_line, 0); } static void @@ -382,6 +382,7 @@ xen_pv_parse_preload_data(u_int64_t modulep) caddr_t kmdp; vm_ooffset_t off; vm_paddr_t metadata; + char *envp; if (HYPERVISOR_start_info->mod_start != 0) { preload_metadata = (caddr_t)(HYPERVISOR_start_info->mod_start); @@ -404,8 +405,10 @@ xen_pv_parse_preload_data(u_int64_t modulep) preload_bootstrap_relocate(off); boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int); - kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); - kern_envp += off; + envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); + if (envp != NULL) + envp += off; + init_static_kenv(envp, 0); } else { /* Parse the extra boot information given by Xen */ xen_pv_set_env(); diff --git a/targets/pseudo/userland/lib/Makefile.depend b/targets/pseudo/userland/lib/Makefile.depend index c5e2407..e57164a 100644 --- a/targets/pseudo/userland/lib/Makefile.depend +++ b/targets/pseudo/userland/lib/Makefile.depend @@ -136,6 +136,7 @@ DIRDEPS = \ lib/libstand \ lib/libstdbuf \ lib/libstdthreads \ + lib/libsysdecode \ lib/libtacplus \ lib/libtelnet \ lib/libthr \ diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index cb51987..37f624e 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -2834,6 +2834,13 @@ OLD_FILES+=usr/share/man/man8/traceroute6.8.gz OLD_FILES+=rescue/ping6 .endif +.if ${MK_INETD} == no +OLD_FILES+=etc/rc.d/inetd +OLD_FILES+=usr/sbin/inetd +OLD_FILES+=usr/share/man/man5/inetd.conf.5.gz +OLD_FILES+=usr/share/man/man8/inetd.8.gz +.endif + .if ${MK_IPFILTER} == no OLD_FILES+=etc/periodic/security/510.ipfdenied OLD_FILES+=etc/periodic/security/610.ipf6denied diff --git a/tools/build/options/WITHOUT_LLVM_LIBUNWIND b/tools/build/options/WITHOUT_LLVM_LIBUNWIND new file mode 100644 index 0000000..63a9042 --- /dev/null +++ b/tools/build/options/WITHOUT_LLVM_LIBUNWIND @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Set to use GCC's stack unwinder (instead of LLVM's libunwind). diff --git a/tools/build/options/WITH_LLVM_LIBUNWIND b/tools/build/options/WITH_LLVM_LIBUNWIND new file mode 100644 index 0000000..ff63884 --- /dev/null +++ b/tools/build/options/WITH_LLVM_LIBUNWIND @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Set to use LLVM's libunwind stack unwinder (instead of GCC's unwinder). diff --git a/tools/tools/nanobsd/defaults.sh b/tools/tools/nanobsd/defaults.sh index 9bc1779..3534ba2 100755 --- a/tools/tools/nanobsd/defaults.sh +++ b/tools/tools/nanobsd/defaults.sh @@ -500,10 +500,9 @@ fixup_before_diskimage ( ) ( if [ -n "${NANO_METALOG}" ]; then pprint 2 "Fixing metalog" cp ${NANO_METALOG} ${NANO_METALOG}.pre - (echo "/set uname=${NANO_DEF_UNAME} gname=${NANO_DEF_GNAME}" && - cat ${NANO_METALOG}.pre) | \ - ${NANO_TOOLS}/mtree-dedup.awk | \ - sed -e 's/ size=[0-9][0-9]*//' | sort > ${NANO_METALOG} + echo "/set uname=${NANO_DEF_UNAME} gname=${NANO_DEF_GNAME}" > ${NANO_METALOG} + cat ${NANO_METALOG}.pre | ${NANO_TOOLS}/mtree-dedup.awk | \ + sed -e 's/ size=[0-9][0-9]*//' | sort >> ${NANO_METALOG} fi ) diff --git a/tools/tools/nanobsd/embedded/common b/tools/tools/nanobsd/embedded/common index 6347911..a1d401a 100644 --- a/tools/tools/nanobsd/embedded/common +++ b/tools/tools/nanobsd/embedded/common @@ -449,6 +449,28 @@ typical_embedded ( ) ( ) customize_cmd typical_embedded +fix_pkg ( ) ( + chdir ${NANO_WORLDDIR} + mkdir -p pkg + mkdir -p pkg/db + mkdir -p pkg/cache + mkdir -p pkg/tmp # Needed for pkg bootstrap + mkdir -p usr/local/etc # Will get moved to local/etc + ( + echo 'PKG_DBDIR = "/pkg/db"' + echo 'PKG_CACHEDIR = "/pkg/cache"' + echo 'DEFAULT_ALWAYS_YES = "yes"' + echo 'ASSUME_ALWAYS_YES = "yes"' + ) >> usr/local/etc/pkg.conf + [ -z ${NANO_NOPRIV_BUILD} ] || ( + echo "./pkg type=dir uname=root gname=wheel mode=0755" + echo "./pkg/cache type=dir uname=root gname=wheel mode=0755" + echo "./pkg/db type=dir uname=root gname=wheel mode=0755" + echo "./pkg/tmp type=dir uname=root gname=wheel mode=0755" + ) >> ${NANO_METALOG} +) +customize_cmd fix_pkg + save_build ( ) ( VERSION_FILE=${NANO_WORLDDIR}/etc/version if [ "${SVNREVISION}" = "${REVISION}" ]; then diff --git a/usr.bin/cap_mkdb/cap_mkdb.c b/usr.bin/cap_mkdb/cap_mkdb.c index 2f8bd96..bbcedd5 100644 --- a/usr.bin/cap_mkdb/cap_mkdb.c +++ b/usr.bin/cap_mkdb/cap_mkdb.c @@ -119,7 +119,7 @@ main(int argc, char *argv[]) (void)snprintf(buf, sizeof(buf), "%s.db", capname ? capname : *argv); if ((capname = strdup(buf)) == NULL) errx(1, "strdup failed"); - if ((capdbp = dbopen(capname, O_CREAT | O_TRUNC | O_RDWR, + if ((capdbp = dbopen(capname, O_CREAT | O_TRUNC | O_RDWR | O_SYNC, DEFFILEMODE, DB_HASH, &openinfo)) == NULL) err(1, "%s", buf); diff --git a/usr.bin/kdump/Makefile.depend b/usr.bin/kdump/Makefile.depend index f86656e..83a2492 100644 --- a/usr.bin/kdump/Makefile.depend +++ b/usr.bin/kdump/Makefile.depend @@ -6,7 +6,6 @@ DIRDEPS = \ gnu/lib/libgcc \ include \ include/arpa \ - include/rpc \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ @@ -20,8 +19,6 @@ DIRDEPS = \ .if ${DEP_RELDIR} == ${_DEP_RELDIR} # local dependencies - needed for -jN in clean tree -ioctl.o: ioctl.c -ioctl.po: ioctl.c kdump.o: kdump_subr.h kdump.o: linux32_syscalls.c kdump.o: linux_syscalls.c diff --git a/usr.bin/less/defines.h b/usr.bin/less/defines.h index 27b73ce..9b0f5c9 100644 --- a/usr.bin/less/defines.h +++ b/usr.bin/less/defines.h @@ -418,6 +418,11 @@ /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ #define TIME_WITH_SYS_TIME 1 +/* Enable large inode numbers on Mac OS X 10.5. */ +#ifndef _DARWIN_USE_64_BIT_INODE +# define _DARWIN_USE_64_BIT_INODE 1 +#endif + /* Number of bits in a file offset, on hosts where this is settable. */ /* #undef _FILE_OFFSET_BITS */ diff --git a/usr.bin/netstat/mbuf.c b/usr.bin/netstat/mbuf.c index baf7a65..8b95ddd 100644 --- a/usr.bin/netstat/mbuf.c +++ b/usr.bin/netstat/mbuf.c @@ -326,13 +326,33 @@ mbpr(void *kvmd, u_long mbaddr) kread_counters) != 0) goto out; + xo_emit("{:sendfile-syscalls/%ju} {N:sendfile syscalls}\n", + (uintmax_t)sfstat.sf_syscalls); + xo_emit("{:sendfile-no-io/%ju} " + "{N:sendfile syscalls completed without I\\/O request}\n", + (uintmax_t)sfstat.sf_noiocnt); + xo_emit("{:sendfile-io-count/%ju} " + "{N:requests for I\\/O initiated by sendfile}\n", + (uintmax_t)sfstat.sf_iocnt); + xo_emit("{:sendfile-pages-sent/%ju} " + "{N:pages read by sendfile as part of a request}\n", + (uintmax_t)sfstat.sf_pages_read); + xo_emit("{:sendfile-pages-valid/%ju} " + "{N:pages were valid at time of a sendfile request}\n", + (uintmax_t)sfstat.sf_pages_valid); + xo_emit("{:sendfile-requested-readahead/%ju} " + "{N:pages were requested for read ahead by applications}\n", + (uintmax_t)sfstat.sf_rhpages_requested); + xo_emit("{:sendfile-readahead/%ju} " + "{N:pages were read ahead by sendfile}\n", + (uintmax_t)sfstat.sf_rhpages_read); + xo_emit("{:sendfile-busy-encounters/%ju} " + "{N:times sendfile encountered an already busy page}\n", + (uintmax_t)sfstat.sf_busy); xo_emit("{:sfbufs-alloc-failed/%ju} {N:requests for sfbufs denied}\n", (uintmax_t)sfstat.sf_allocfail); xo_emit("{:sfbufs-alloc-wait/%ju} {N:requests for sfbufs delayed}\n", (uintmax_t)sfstat.sf_allocwait); - xo_emit("{:sfbufs-io-count/%ju} " - "{N:requests for I\\/O initiated by sendfile}\n", - (uintmax_t)sfstat.sf_iocnt); out: xo_close_container("mbuf-statistics"); memstat_mtl_free(mtlp); diff --git a/usr.bin/nfsstat/Makefile.depend b/usr.bin/nfsstat/Makefile.depend index 34582cd..3646e2e 100644 --- a/usr.bin/nfsstat/Makefile.depend +++ b/usr.bin/nfsstat/Makefile.depend @@ -9,8 +9,6 @@ DIRDEPS = \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ - lib/libelf \ - lib/libkvm \ .include <dirdeps.mk> diff --git a/usr.bin/truss/Makefile.depend.amd64 b/usr.bin/truss/Makefile.depend.amd64 index ad9c8b3..334bb3a 100644 --- a/usr.bin/truss/Makefile.depend.amd64 +++ b/usr.bin/truss/Makefile.depend.amd64 @@ -6,7 +6,6 @@ DIRDEPS = \ gnu/lib/libgcc \ include \ include/arpa \ - include/rpc \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ @@ -26,6 +25,4 @@ amd64-freebsd32.o: freebsd32_syscalls.h amd64-freebsd32.po: freebsd32_syscalls.h amd64-linux32.o: amd64-linux32_syscalls.h amd64-linux32.po: amd64-linux32_syscalls.h -ioctl.o: ioctl.c -ioctl.po: ioctl.c .endif diff --git a/usr.sbin/bhyve/pci_virtio_net.c b/usr.sbin/bhyve/pci_virtio_net.c index aa9b581..6f264a7 100644 --- a/usr.sbin/bhyve/pci_virtio_net.c +++ b/usr.sbin/bhyve/pci_virtio_net.c @@ -36,6 +36,10 @@ __FBSDID("$FreeBSD$"); #include <sys/ioctl.h> #include <machine/atomic.h> #include <net/ethernet.h> +#ifndef NETMAP_WITH_LIBS +#define NETMAP_WITH_LIBS +#endif +#include <net/netmap_user.h> #include <errno.h> #include <fcntl.h> @@ -133,6 +137,8 @@ struct pci_vtnet_softc { struct mevent *vsc_mevp; int vsc_tapfd; + struct nm_desc *vsc_nmd; + int vsc_rx_ready; volatile int resetting; /* set and checked outside lock */ @@ -149,6 +155,10 @@ struct pci_vtnet_softc { pthread_mutex_t tx_mtx; pthread_cond_t tx_cond; int tx_in_progress; + + void (*pci_vtnet_rx)(struct pci_vtnet_softc *sc); + void (*pci_vtnet_tx)(struct pci_vtnet_softc *sc, struct iovec *iov, + int iovcnt, int len); }; static void pci_vtnet_reset(void *); @@ -371,14 +381,208 @@ pci_vtnet_tap_rx(struct pci_vtnet_softc *sc) vq_endchains(vq, 1); } +static int +pci_vtnet_netmap_writev(struct nm_desc *nmd, struct iovec *iov, int iovcnt) +{ + int r, i; + int len = 0; + + for (r = nmd->cur_tx_ring; ; ) { + struct netmap_ring *ring = NETMAP_TXRING(nmd->nifp, r); + uint32_t cur, idx; + char *buf; + + if (nm_ring_empty(ring)) { + r++; + if (r > nmd->last_tx_ring) + r = nmd->first_tx_ring; + if (r == nmd->cur_rx_ring) + break; + continue; + } + cur = ring->cur; + idx = ring->slot[cur].buf_idx; + buf = NETMAP_BUF(ring, idx); + + for (i = 0; i < iovcnt; i++) { + memcpy(&buf[len], iov[i].iov_base, iov[i].iov_len); + len += iov[i].iov_len; + } + ring->slot[cur].len = len; + ring->head = ring->cur = nm_ring_next(ring, cur); + nmd->cur_tx_ring = r; + ioctl(nmd->fd, NIOCTXSYNC, NULL); + break; + } + + return (len); +} + +static inline int +pci_vtnet_netmap_readv(struct nm_desc *nmd, struct iovec *iov, int iovcnt) +{ + int len = 0; + int i = 0; + int r; + + for (r = nmd->cur_rx_ring; ; ) { + struct netmap_ring *ring = NETMAP_RXRING(nmd->nifp, r); + uint32_t cur, idx; + char *buf; + size_t left; + + if (nm_ring_empty(ring)) { + r++; + if (r > nmd->last_rx_ring) + r = nmd->first_rx_ring; + if (r == nmd->cur_rx_ring) + break; + continue; + } + cur = ring->cur; + idx = ring->slot[cur].buf_idx; + buf = NETMAP_BUF(ring, idx); + left = ring->slot[cur].len; + + for (i = 0; i < iovcnt && left > 0; i++) { + if (iov[i].iov_len > left) + iov[i].iov_len = left; + memcpy(iov[i].iov_base, &buf[len], iov[i].iov_len); + len += iov[i].iov_len; + left -= iov[i].iov_len; + } + ring->head = ring->cur = nm_ring_next(ring, cur); + nmd->cur_rx_ring = r; + ioctl(nmd->fd, NIOCRXSYNC, NULL); + break; + } + for (; i < iovcnt; i++) + iov[i].iov_len = 0; + + return (len); +} + +/* + * Called to send a buffer chain out to the vale port + */ +static void +pci_vtnet_netmap_tx(struct pci_vtnet_softc *sc, struct iovec *iov, int iovcnt, + int len) +{ + static char pad[60]; /* all zero bytes */ + + if (sc->vsc_nmd == NULL) + return; + + /* + * If the length is < 60, pad out to that and add the + * extra zero'd segment to the iov. It is guaranteed that + * there is always an extra iov available by the caller. + */ + if (len < 60) { + iov[iovcnt].iov_base = pad; + iov[iovcnt].iov_len = 60 - len; + iovcnt++; + } + (void) pci_vtnet_netmap_writev(sc->vsc_nmd, iov, iovcnt); +} + static void -pci_vtnet_tap_callback(int fd, enum ev_type type, void *param) +pci_vtnet_netmap_rx(struct pci_vtnet_softc *sc) +{ + struct iovec iov[VTNET_MAXSEGS], *riov; + struct vqueue_info *vq; + void *vrx; + int len, n; + uint16_t idx; + + /* + * Should never be called without a valid netmap descriptor + */ + assert(sc->vsc_nmd != NULL); + + /* + * But, will be called when the rx ring hasn't yet + * been set up or the guest is resetting the device. + */ + if (!sc->vsc_rx_ready || sc->resetting) { + /* + * Drop the packet and try later. + */ + (void) nm_nextpkt(sc->vsc_nmd, (void *)dummybuf); + return; + } + + /* + * Check for available rx buffers + */ + vq = &sc->vsc_queues[VTNET_RXQ]; + if (!vq_has_descs(vq)) { + /* + * Drop the packet and try later. Interrupt on + * empty, if that's negotiated. + */ + (void) nm_nextpkt(sc->vsc_nmd, (void *)dummybuf); + vq_endchains(vq, 1); + return; + } + + do { + /* + * Get descriptor chain. + */ + n = vq_getchain(vq, &idx, iov, VTNET_MAXSEGS, NULL); + assert(n >= 1 && n <= VTNET_MAXSEGS); + + /* + * Get a pointer to the rx header, and use the + * data immediately following it for the packet buffer. + */ + vrx = iov[0].iov_base; + riov = rx_iov_trim(iov, &n, sc->rx_vhdrlen); + + len = pci_vtnet_netmap_readv(sc->vsc_nmd, riov, n); + + if (len == 0) { + /* + * No more packets, but still some avail ring + * entries. Interrupt if needed/appropriate. + */ + vq_endchains(vq, 0); + return; + } + + /* + * The only valid field in the rx packet header is the + * number of buffers if merged rx bufs were negotiated. + */ + memset(vrx, 0, sc->rx_vhdrlen); + + if (sc->rx_merge) { + struct virtio_net_rxhdr *vrxh; + + vrxh = vrx; + vrxh->vrh_bufs = 1; + } + + /* + * Release this chain and handle more chains. + */ + vq_relchain(vq, idx, len + sc->rx_vhdrlen); + } while (vq_has_descs(vq)); + + /* Interrupt if needed, including for NOTIFY_ON_EMPTY. */ + vq_endchains(vq, 1); +} + +static void +pci_vtnet_rx_callback(int fd, enum ev_type type, void *param) { struct pci_vtnet_softc *sc = param; pthread_mutex_lock(&sc->rx_mtx); sc->rx_in_progress = 1; - pci_vtnet_tap_rx(sc); + sc->pci_vtnet_rx(sc); sc->rx_in_progress = 0; pthread_mutex_unlock(&sc->rx_mtx); @@ -421,7 +625,7 @@ pci_vtnet_proctx(struct pci_vtnet_softc *sc, struct vqueue_info *vq) } DPRINTF(("virtio: packet send, %d bytes, %d segs\n\r", plen, n)); - pci_vtnet_tap_tx(sc, &iov[1], n - 1, plen); + sc->pci_vtnet_tx(sc, &iov[1], n - 1, plen); /* chain is processed, release it and set tlen */ vq_relchain(vq, idx, tlen); @@ -532,6 +736,67 @@ pci_vtnet_parsemac(char *mac_str, uint8_t *mac_addr) return (0); } +static void +pci_vtnet_tap_setup(struct pci_vtnet_softc *sc, char *devname) +{ + char tbuf[80]; + + strcpy(tbuf, "/dev/"); + strlcat(tbuf, devname, sizeof(tbuf)); + + sc->pci_vtnet_rx = pci_vtnet_tap_rx; + sc->pci_vtnet_tx = pci_vtnet_tap_tx; + + sc->vsc_tapfd = open(tbuf, O_RDWR); + if (sc->vsc_tapfd == -1) { + WPRINTF(("open of tap device %s failed\n", tbuf)); + return; + } + + /* + * Set non-blocking and register for read + * notifications with the event loop + */ + int opt = 1; + if (ioctl(sc->vsc_tapfd, FIONBIO, &opt) < 0) { + WPRINTF(("tap device O_NONBLOCK failed\n")); + close(sc->vsc_tapfd); + sc->vsc_tapfd = -1; + } + + sc->vsc_mevp = mevent_add(sc->vsc_tapfd, + EVF_READ, + pci_vtnet_rx_callback, + sc); + if (sc->vsc_mevp == NULL) { + WPRINTF(("Could not register event\n")); + close(sc->vsc_tapfd); + sc->vsc_tapfd = -1; + } +} + +static void +pci_vtnet_netmap_setup(struct pci_vtnet_softc *sc, char *ifname) +{ + sc->pci_vtnet_rx = pci_vtnet_netmap_rx; + sc->pci_vtnet_tx = pci_vtnet_netmap_tx; + + sc->vsc_nmd = nm_open(ifname, NULL, 0, 0); + if (sc->vsc_nmd == NULL) { + WPRINTF(("open of netmap device %s failed\n", ifname)); + return; + } + + sc->vsc_mevp = mevent_add(sc->vsc_nmd->fd, + EVF_READ, + pci_vtnet_rx_callback, + sc); + if (sc->vsc_mevp == NULL) { + WPRINTF(("Could not register event\n")); + nm_close(sc->vsc_nmd); + sc->vsc_nmd = NULL; + } +} static int pci_vtnet_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) @@ -567,8 +832,8 @@ pci_vtnet_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) */ mac_provided = 0; sc->vsc_tapfd = -1; + sc->vsc_nmd = NULL; if (opts != NULL) { - char tbuf[80]; int err; devname = vtopts = strdup(opts); @@ -583,36 +848,13 @@ pci_vtnet_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) mac_provided = 1; } - strcpy(tbuf, "/dev/"); - strlcat(tbuf, devname, sizeof(tbuf)); + if (strncmp(devname, "vale", 4) == 0) + pci_vtnet_netmap_setup(sc, devname); + if (strncmp(devname, "tap", 3) == 0 || + strncmp(devname, "vmnet", 5) == 0) + pci_vtnet_tap_setup(sc, devname); free(devname); - - sc->vsc_tapfd = open(tbuf, O_RDWR); - if (sc->vsc_tapfd == -1) { - WPRINTF(("open of tap device %s failed\n", tbuf)); - } else { - /* - * Set non-blocking and register for read - * notifications with the event loop - */ - int opt = 1; - if (ioctl(sc->vsc_tapfd, FIONBIO, &opt) < 0) { - WPRINTF(("tap device O_NONBLOCK failed\n")); - close(sc->vsc_tapfd); - sc->vsc_tapfd = -1; - } - - sc->vsc_mevp = mevent_add(sc->vsc_tapfd, - EVF_READ, - pci_vtnet_tap_callback, - sc); - if (sc->vsc_mevp == NULL) { - WPRINTF(("Could not register event\n")); - close(sc->vsc_tapfd); - sc->vsc_tapfd = -1; - } - } } /* diff --git a/usr.sbin/bhyvectl/Makefile b/usr.sbin/bhyvectl/Makefile index 4a33dee..fe8f1d3 100644 --- a/usr.sbin/bhyvectl/Makefile +++ b/usr.sbin/bhyvectl/Makefile @@ -5,7 +5,7 @@ PROG= bhyvectl SRCS= bhyvectl.c -MAN= +MAN= bhyvectl.8 LIBADD= vmmapi util diff --git a/usr.sbin/bhyvectl/bhyvectl.8 b/usr.sbin/bhyvectl/bhyvectl.8 new file mode 100644 index 0000000..d72a795 --- /dev/null +++ b/usr.sbin/bhyvectl/bhyvectl.8 @@ -0,0 +1,97 @@ +.\" Copyright (c) 2015 Christian Brueffer +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd January 12, 2016 +.Dt BHYVECTL 8 +.Os +.Sh NAME +.Nm bhyvectl +.Nd "control utility for bhyve instances" +.Sh SYNOPSIS +.Nm +.Fl -vm= Ns Ar <vmname> +.Op Fl -create +.Op Fl -destroy +.Op Fl -get-stats +.Op Fl -inject-nmi +.Op Fl -force-reset +.Op Fl -force-poweroff +.Sh DESCRIPTION +The +.Nm +command is a control utility for active +.Xr bhyve 8 +virtual machine instances. +.Pp +.Em Note : +Most +.Nm +flags are intended for querying and setting the state of an active instance. +These commands are intended for development purposes, and are not documented here. +A complete list can be obtained by executing +.Nm +without any arguments. +.Pp +The user-facing options are as follows: +.Bl -tag -width ".Fl d Ar argument" +.It Fl -vm= Ns Ar <vmname> +Operate on the virtual machine +.Ar <vmname> . +.It Fl -create +Create the specified VM. +.It Fl -destroy +Destroy the specified VM. +.It Fl -get-state +Retrieve statistics for the specified VM. +.It Fl -inject-nmi +Inject a non-maskable interrupt (NMI) into the VM. +.It Fl -force-reset +Force the VM to reset. +.It Fl -force-poweroff +Force the VM to power off. +.El +.Sh EXIT STATUS +.Ex -std +.Sh EXAMPLES +Destroy the VM called fbsd10: +.Pp +.Dl "bhyvectl --vm=fbsd10 --destroy" +.Sh SEE ALSO +.Xr bhyve 8 , +.Xr bhyveload 8 +.Sh HISTORY +The +.Nm +command first appeared in +.Fx 10.1 . +.Sh AUTHORS +.An -nosplit +The +.Nm +utility was written by +.An Peter Grehan +and +.An Neel Natu . diff --git a/usr.sbin/bsdconfig/share/dialog.subr b/usr.sbin/bsdconfig/share/dialog.subr index d7c2d2c..1e63aec 100644 --- a/usr.sbin/bsdconfig/share/dialog.subr +++ b/usr.sbin/bsdconfig/share/dialog.subr @@ -1605,7 +1605,6 @@ f_dialog_pause() $height $width else [ $duration -gt 0 ] && duration=$(( $duration - 1 )) - [ $duration -gt 1 ] && duration=$(( $duration - 1 )) height=$(( $height + 3 )) # Add height for progress bar $DIALOG \ --title "$DIALOG_TITLE" \ diff --git a/usr.sbin/bsdinstall/scripts/auto b/usr.sbin/bsdinstall/scripts/auto index 5ac16cd..c681a12 100755 --- a/usr.sbin/bsdinstall/scripts/auto +++ b/usr.sbin/bsdinstall/scripts/auto @@ -115,7 +115,8 @@ bsdinstall hostname || error "Set hostname failed" export DISTRIBUTIONS="base.txz kernel.txz" if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then - DISTMENU=`awk -F'\t' '!/^(kernel|base)/{print $4,$5,$6}' $BSDINSTALL_DISTDIR/MANIFEST` + DISTMENU=`awk -F'\t' '!/^(kernel\.txz|base\.txz)/{print $1,$5,$6}' $BSDINSTALL_DISTDIR/MANIFEST` + DISTMENU="$(echo ${DISTMENU} | sed -E 's/\.txz//g')" exec 3>&1 EXTRA_DISTS=$( eval dialog \ @@ -129,16 +130,20 @@ if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then done fi +LOCAL_DISTRIBUTIONS="MANIFEST" FETCH_DISTRIBUTIONS="" for dist in $DISTRIBUTIONS; do if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist" + else + LOCAL_DISTRIBUTIONS="$LOCAL_DISTRIBUTIONS $dist" fi done +LOCAL_DISTRIBUTIONS=`echo $LOCAL_DISTRIBUTIONS` # Trim white space FETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space if [ -n "$FETCH_DISTRIBUTIONS" -a -n "$BSDINSTALL_CONFIGCURRENT" ]; then - dialog --backtitle "FreeBSD Installer" --title "Network Installation" --msgbox "No installation files were found on the boot volume. The next few screens will allow you to configure networking so that they can be downloaded from the Internet." 0 0 + dialog --backtitle "FreeBSD Installer" --title "Network Installation" --msgbox "Some installation files were not found on the boot volume. The next few screens will allow you to configure networking so that they can be downloaded from the Internet." 0 0 bsdinstall netconfig || error NETCONFIG_DONE=yes fi @@ -299,6 +304,7 @@ esac if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then ALL_DISTRIBUTIONS="$DISTRIBUTIONS" + WANT_DEBUG= # Download to a directory in the new system as scratch space BSDINSTALL_FETCHDEST="$BSDINSTALL_CHROOT/usr/freebsd-dist" @@ -310,15 +316,65 @@ if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then DISTDIR_IS_UNIONFS=1 mount_nullfs -o union "$BSDINSTALL_FETCHDEST" "$BSDINSTALL_DISTDIR" else - export DISTRIBUTIONS="$ALL_DISTRIBUTIONS" + export DISTRIBUTIONS="$FETCH_DISTRIBUTIONS" export BSDINSTALL_DISTDIR="$BSDINSTALL_FETCHDEST" fi export FTP_PASSIVE_MODE=YES - bsdinstall distfetch || error "Failed to fetch distribution" + # Iterate through the distribution list and set a flag if debugging + # distributions have been selected. + for _DISTRIBUTION in $DISTRIBUTIONS; do + case $_DISTRIBUTION in + *-dbg.*) + [ -e $BSDINSTALL_DISTDIR/$_DISTRIBUTION ] \ + && continue + WANT_DEBUG=1 + DEBUG_LIST="\n$DEBUG_LIST\n$_DISTRIBUTION" + ;; + *) + ;; + esac + done + + # Fetch the distributions. + bsdinstall distfetch + rc=$? + + if [ $rc -ne 0 ]; then + # If unable to fetch the remote distributions, recommend + # deselecting the debugging distributions, and retrying the + # installation, since failure to fetch *-dbg.txz should not + # be considered a fatal installation error. + msg="Failed to fetch remote distribution" + if [ ! -z "$WANT_DEBUG" ]; then + # Trim leading and trailing newlines. + DEBUG_LIST="${DEBUG_LIST%%\n}" + DEBUG_LIST="${DEBUG_LIST##\n}" + msg="$msg\n\nPlease deselect the following distributions" + msg="$msg and retry the installation:" + msg="$msg\n$DEBUG_LIST" + fi + error "$msg" + fi export DISTRIBUTIONS="$ALL_DISTRIBUTIONS" fi +if [ ! -z "$LOCAL_DISTRIBUTIONS" ]; then + # Download to a directory in the new system as scratch space + BSDINSTALL_FETCHDEST="$BSDINSTALL_CHROOT/usr/freebsd-dist" + mkdir -p "$BSDINSTALL_FETCHDEST" || error "Could not create directory $BSDINSTALL_FETCHDEST" + # Try to use any existing distfiles + if [ -d $BSDINSTALL_DISTDIR ]; then + DISTDIR_IS_UNIONFS=1 + mount_nullfs -o union "$BSDINSTALL_FETCHDEST" "$BSDINSTALL_DISTDIR" + export BSDINSTALL_DISTDIR="$BSDINSTALL_FETCHDEST" + fi + env DISTRIBUTIONS="$LOCAL_DISTRIBUTIONS" \ + BSDINSTALL_DISTSITE="file:///usr/freebsd-dist" \ + bsdinstall distfetch || \ + error "Failed to fetch distribution from local media" +fi + bsdinstall checksum || error "Distribution checksum failed" bsdinstall distextract || error "Distribution extract failed" bsdinstall rootpass || error "Could not set root password" diff --git a/usr.sbin/cron/crontab/crontab.5 b/usr.sbin/cron/crontab/crontab.5 index 5222d2d..acd6cb5 100644 --- a/usr.sbin/cron/crontab/crontab.5 +++ b/usr.sbin/cron/crontab/crontab.5 @@ -17,7 +17,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 28, 2012 +.Dd January 5, 2016 .Dt CRONTAB 5 .Os .Sh NAME @@ -74,7 +74,7 @@ is set to .Pa /bin/sh , .Ev PATH is set to -.Pa /usr/bin:/bin , +.Pa /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin , and .Ev LOGNAME and diff --git a/usr.sbin/gssd/gssd.c b/usr.sbin/gssd/gssd.c index e85dfd7..f3e5ce9 100644 --- a/usr.sbin/gssd/gssd.c +++ b/usr.sbin/gssd/gssd.c @@ -254,6 +254,7 @@ main(int argc, char **argv) gssd_syscall(_PATH_GSSDSOCK); svc_run(); + gssd_syscall(""); return (0); } @@ -1285,6 +1286,7 @@ void gssd_terminate(int sig __unused) if (hostbased_initiator_cred != 0) unlink(GSSD_CREDENTIAL_CACHE_FILE); #endif + gssd_syscall(""); exit(0); } diff --git a/usr.sbin/jls/Makefile.depend b/usr.sbin/jls/Makefile.depend index 4131fa7..50e6f23 100644 --- a/usr.sbin/jls/Makefile.depend +++ b/usr.sbin/jls/Makefile.depend @@ -11,6 +11,8 @@ DIRDEPS = \ lib/libc \ lib/libcompiler_rt \ lib/libjail \ + lib/libutil \ + lib/libxo \ .include <dirdeps.mk> diff --git a/usr.sbin/kbdcontrol/kbdmap.5 b/usr.sbin/kbdcontrol/kbdmap.5 index c7f437a..fda2ada 100644 --- a/usr.sbin/kbdcontrol/kbdmap.5 +++ b/usr.sbin/kbdcontrol/kbdmap.5 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 29, 2008 +.Dd January 2, 2016 .Dt KBDMAP 5 .Os .Sh NAME @@ -111,9 +111,9 @@ ack, bel, bs, ht, -nl, +lf, vt, -np, +ff, cr, so, si, @@ -132,10 +132,16 @@ esc, fs, gs, rs, -ns, us, sp, del. +.It Ar control-alias +One of the historical aliases for certain +.Tn ASCII +control characters: +nl, +np, +ns. .It Ar accentname By giving one of the accent names, the next key pressed will produce diff --git a/usr.sbin/mountd/exports.5 b/usr.sbin/mountd/exports.5 index 88e2219..018a865 100644 --- a/usr.sbin/mountd/exports.5 +++ b/usr.sbin/mountd/exports.5 @@ -131,6 +131,7 @@ The credential includes all the groups to which the user is a member on the local machine (see .Xr id 1 ) . The user may be specified by name or number. +The user string may be quoted, or use backslash escaping. .Pp .Sm off .Fl maproot Li = Sy user:group1:group2:... @@ -140,6 +141,7 @@ to be used for remote access by root. The elements of the list may be either names or numbers. Note that user: should be used to distinguish a credential containing no groups from a complete credential for that user. +The group names may be quoted, or use backslash escaping. .Pp .Sm off .Fl mapall Li = Sy user diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c index 535a3f7..d6da2bc 100644 --- a/usr.sbin/mountd/mountd.c +++ b/usr.sbin/mountd/mountd.c @@ -174,6 +174,7 @@ static int check_options(struct dirlist *); static int checkmask(struct sockaddr *sa); static int chk_host(struct dirlist *, struct sockaddr *, int *, int *, int *, int **); +static char *strsep_quote(char **stringp, const char *delim); static int create_service(struct netconfig *nconf); static void complete_service(struct netconfig *nconf, char *port_str); static void clearout_service(void); @@ -278,6 +279,73 @@ static int debug = 0; #endif /* + * Similar to strsep(), but it allows for quoted strings + * and escaped characters. + * + * It returns the string (or NULL, if *stringp is NULL), + * which is a de-quoted version of the string if necessary. + * + * It modifies *stringp in place. + */ +static char * +strsep_quote(char **stringp, const char *delim) +{ + char *srcptr, *dstptr, *retval; + char quot = 0; + + if (stringp == NULL || *stringp == NULL) + return (NULL); + + srcptr = dstptr = retval = *stringp; + + while (*srcptr) { + /* + * We're looking for several edge cases here. + * First: if we're in quote state (quot != 0), + * then we ignore the delim characters, but otherwise + * process as normal, unless it is the quote character. + * Second: if the current character is a backslash, + * we take the next character as-is, without checking + * for delim, quote, or backslash. Exception: if the + * next character is a NUL, that's the end of the string. + * Third: if the character is a quote character, we toggle + * quote state. + * Otherwise: check the current character for NUL, or + * being in delim, and end the string if either is true. + */ + if (*srcptr == '\\') { + srcptr++; + /* + * The edge case here is if the next character + * is NUL, we want to stop processing. But if + * it's not NUL, then we simply want to copy it. + */ + if (*srcptr) { + *dstptr++ = *srcptr++; + } + continue; + } + if (quot == 0 && (*srcptr == '\'' || *srcptr == '"')) { + quot = *srcptr++; + continue; + } + if (quot && *srcptr == quot) { + /* End of the quoted part */ + quot = 0; + srcptr++; + continue; + } + if (!quot && strchr(delim, *srcptr)) + break; + *dstptr++ = *srcptr++; + } + + *dstptr = 0; /* Terminate the string */ + *stringp = (*srcptr == '\0') ? NULL : srcptr + 1; + return (retval); +} + +/* * Mountd server for NFS mount protocol as described in: * NFS: Network File System Protocol Specification, RFC1094, Appendix A * The optional arguments are the exports file name @@ -2831,8 +2899,9 @@ parsecred(char *namelist, struct xucred *cr) /* * Get the user's password table entry. */ - names = strsep(&namelist, " \t\n"); + names = strsep_quote(&namelist, " \t\n"); name = strsep(&names, ":"); + /* Bug? name could be NULL here */ if (isdigit(*name) || *name == '-') pw = getpwuid(atoi(name)); else diff --git a/usr.sbin/ntp/config.h b/usr.sbin/ntp/config.h index 5a51e0a..73f83a3 100644 --- a/usr.sbin/ntp/config.h +++ b/usr.sbin/ntp/config.h @@ -335,6 +335,9 @@ /* Define to 1 if you have the <arpa/nameser.h> header file. */ #define HAVE_ARPA_NAMESER_H 1 +/* Define to 1 if you have the `atomic_thread_fence' function. */ +/* #undef HAVE_ATOMIC_THREAD_FENCE */ + /* Do we have audio support? */ #define HAVE_AUDIO /**/ @@ -388,6 +391,9 @@ /* Define to 1 if you have the <errno.h> header file. */ #define HAVE_ERRNO_H 1 +/* Define to 1 if you have the `EVP_MD_do_all_sorted' function. */ +#define HAVE_EVP_MD_DO_ALL_SORTED 1 + /* Define to 1 if you have the `fchmod' function. */ #define HAVE_FCHMOD 1 @@ -613,6 +619,9 @@ /* Define to 1 if you have the <net/if.h> header file. */ #define HAVE_NET_IF_H 1 +/* Define to 1 if you have the <net/if_var.h> header file. */ +#define HAVE_NET_IF_VAR_H 1 + /* Define to 1 if you have the <net/route.h> header file. */ #define HAVE_NET_ROUTE_H 1 @@ -820,6 +829,9 @@ /* Define to 1 if you have the <stdarg.h> header file. */ #define HAVE_STDARG_H 1 +/* Define to 1 if you have the <stdatomic.h> header file. */ +#define HAVE_STDATOMIC_H 1 + /* Define to 1 if you have the <stdbool.h> header file. */ #define HAVE_STDBOOL_H 1 @@ -1132,7 +1144,7 @@ /* #undef HAVE_UNIXWARE_SIGWAIT */ /* Define to 1 if the system has the type `unsigned long long int'. */ -/* #undef HAVE_UNSIGNED_LONG_LONG_INT */ +#define HAVE_UNSIGNED_LONG_LONG_INT 1 /* Define to 1 if you have the `updwtmp' function. */ /* #undef HAVE_UPDWTMP */ @@ -1314,6 +1326,9 @@ /* define to 1 if library is thread safe */ #define LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE 1 +/* leap smear mechanism */ +/* #undef LEAP_SMEAR */ + /* Define to any value to include libseccomp sandboxing. */ /* #undef LIBSECCOMP */ @@ -1330,6 +1345,10 @@ /* Should we recommend a minimum value for tickadj? */ /* #undef MIN_REC_TICKADJ */ +/* Define to 1 if the compiler does not support C99's structure + initialization. */ +/* #undef MISSING_C99_STRUCT_INIT */ + /* Do we need HPUX adjtime() library support? */ /* #undef NEED_HPUX_ADJTIME */ @@ -1418,7 +1437,7 @@ #define PACKAGE_NAME "ntp" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "ntp 4.2.8p4" +#define PACKAGE_STRING "ntp 4.2.8p5" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "ntp" @@ -1427,13 +1446,13 @@ #define PACKAGE_URL "http://www.ntp.org./" /* Define to the version of this package. */ -#define PACKAGE_VERSION "4.2.8p4" +#define PACKAGE_VERSION "4.2.8p5" /* data dir */ #define PERLLIBDIR "/usr/local/share/ntp/lib" /* define to a working POSIX compliant shell */ -#define POSIX_SHELL "/bin/bash" +#define POSIX_SHELL "/bin/sh" /* PARSE kernel PLL PPS support */ /* #undef PPS_SYNC */ @@ -1608,7 +1627,7 @@ typedef unsigned int uintptr_t; /* #undef USE_UDP_SIGPOLL */ /* Version number of package */ -#define VERSION "4.2.8p4" +#define VERSION "4.2.8p5" /* vsnprintf expands "%m" to strerror(errno) */ /* #undef VSNPRINTF_PERCENT_M */ @@ -1785,5 +1804,5 @@ typedef union mpinfou { /* * FreeBSD specific: Explicitly specify date/time for reproducible build. */ -#define MKREPRO_DATE "Oct 22 2015" -#define MKREPRO_TIME "17:58:31" +#define MKREPRO_DATE "Jan 8 2016" +#define MKREPRO_TIME "12:37:48" diff --git a/usr.sbin/ntp/doc/ntp-keygen.8 b/usr.sbin/ntp/doc/ntp-keygen.8 index 197adbf..a0c0954 100644 --- a/usr.sbin/ntp/doc/ntp-keygen.8 +++ b/usr.sbin/ntp/doc/ntp-keygen.8 @@ -1,11 +1,11 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTP_KEYGEN 8 User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntp-keygen-opts.mdoc) .\" .\" $FreeBSD$ .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:40:10 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:32:43 PM by AutoGen 5.18.5 .\" From the definitions ntp-keygen-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/usr.sbin/ntp/doc/ntp.conf.5 b/usr.sbin/ntp/doc/ntp.conf.5 index c7af12d..3f075a1 100644 --- a/usr.sbin/ntp/doc/ntp.conf.5 +++ b/usr.sbin/ntp/doc/ntp.conf.5 @@ -1,11 +1,11 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTP_CONF 5 File Formats .Os .\" EDIT THIS FILE WITH CAUTION (ntp.mdoc) .\" .\" $FreeBSD$ .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:24 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:30:57 PM by AutoGen 5.18.5 .\" From the definitions ntp.conf.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/usr.sbin/ntp/doc/ntp.keys.5 b/usr.sbin/ntp/doc/ntp.keys.5 index b1bcb3c..04dfbcd 100644 --- a/usr.sbin/ntp/doc/ntp.keys.5 +++ b/usr.sbin/ntp/doc/ntp.keys.5 @@ -1,11 +1,11 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTP_KEYS 5 File Formats .Os SunOS 5.10 .\" EDIT THIS FILE WITH CAUTION (ntp.mdoc) .\" .\" $FreeBSD$ .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:28 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:31:00 PM by AutoGen 5.18.5 .\" From the definitions ntp.keys.def .\" and the template file agmdoc-file.tpl .Sh NAME diff --git a/usr.sbin/ntp/doc/ntpd.8 b/usr.sbin/ntp/doc/ntpd.8 index 243f96d..70ab88e 100644 --- a/usr.sbin/ntp/doc/ntpd.8 +++ b/usr.sbin/ntp/doc/ntpd.8 @@ -1,11 +1,11 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTPD 8 User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntpd-opts.mdoc) .\" .\" $FreeBSD$ .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:30 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:31:02 PM by AutoGen 5.18.5 .\" From the definitions ntpd-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/usr.sbin/ntp/doc/ntpdc.8 b/usr.sbin/ntp/doc/ntpdc.8 index 74129c4..3561f2a 100644 --- a/usr.sbin/ntp/doc/ntpdc.8 +++ b/usr.sbin/ntp/doc/ntpdc.8 @@ -1,11 +1,11 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTPDC 8 User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntpdc-opts.mdoc) .\" .\" $FreeBSD$ .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:38:57 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:31:29 PM by AutoGen 5.18.5 .\" From the definitions ntpdc-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/usr.sbin/ntp/doc/ntpq.8 b/usr.sbin/ntp/doc/ntpq.8 index bcd1fba..e71a84b 100644 --- a/usr.sbin/ntp/doc/ntpq.8 +++ b/usr.sbin/ntp/doc/ntpq.8 @@ -1,11 +1,11 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt NTPQ 8 User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntpq-opts.mdoc) .\" .\" $FreeBSD$ .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:39:29 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:32:02 PM by AutoGen 5.18.5 .\" From the definitions ntpq-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/usr.sbin/ntp/doc/sntp.8 b/usr.sbin/ntp/doc/sntp.8 index 9bcc78d..0d2dd64 100644 --- a/usr.sbin/ntp/doc/sntp.8 +++ b/usr.sbin/ntp/doc/sntp.8 @@ -1,11 +1,11 @@ -.Dd October 21 2015 +.Dd January 7 2016 .Dt SNTP 8 User Commands .Os .\" EDIT THIS FILE WITH CAUTION (sntp-opts.mdoc) .\" .\" $FreeBSD$ .\" -.\" It has been AutoGen-ed October 21, 2015 at 12:30:59 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed January 7, 2016 at 11:23:27 PM by AutoGen 5.18.5 .\" From the definitions sntp-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/usr.sbin/ntp/scripts/mkver b/usr.sbin/ntp/scripts/mkver index 2bc36b5..6a99756 100755 --- a/usr.sbin/ntp/scripts/mkver +++ b/usr.sbin/ntp/scripts/mkver @@ -6,7 +6,7 @@ PROG=${1-UNKNOWN} ConfStr="$PROG" -ConfStr="$ConfStr 4.2.8p4" +ConfStr="$ConfStr 4.2.8p5" case "$CSET" in '') ;; diff --git a/usr.sbin/rpcbind/Makefile b/usr.sbin/rpcbind/Makefile index 2b679f4..b328260 100644 --- a/usr.sbin/rpcbind/Makefile +++ b/usr.sbin/rpcbind/Makefile @@ -14,6 +14,10 @@ CFLAGS+= -DPORTMAP -DLIBWRAP CFLAGS+= -DINET6 .endif +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif + WARNS?= 1 LIBADD= wrap diff --git a/usr.sbin/rpcbind/check_bound.c b/usr.sbin/rpcbind/check_bound.c index 3691f5f..64b73c7 100644 --- a/usr.sbin/rpcbind/check_bound.c +++ b/usr.sbin/rpcbind/check_bound.c @@ -50,6 +50,7 @@ static char sccsid[] = "@(#)check_bound.c 1.11 89/04/21 Copyr 1989 Sun Micro"; #include <sys/types.h> #include <sys/socket.h> #include <rpc/rpc.h> +#include <rpc/svc_dg.h> #include <stdio.h> #include <netconfig.h> #include <syslog.h> @@ -159,6 +160,7 @@ char * mergeaddr(SVCXPRT *xprt, char *netid, char *uaddr, char *saddr) { struct fdlist *fdl; + struct svc_dg_data *dg_data; char *c_uaddr, *s_uaddr, *m_uaddr, *allocated_uaddr = NULL; for (fdl = fdhead; fdl; fdl = fdl->next) @@ -170,11 +172,20 @@ mergeaddr(SVCXPRT *xprt, char *netid, char *uaddr, char *saddr) /* that server died */ return (nullstring); /* + * Try to determine the local address on which the client contacted us, + * so we can send a reply from the same address. If it's unknown, then + * try to determine which address the client used, and pick a nearby + * local address. + * * If saddr is not NULL, the remote client may have included the * address by which it contacted us. Use that for the "client" uaddr, * otherwise use the info from the SVCXPRT. */ - if (saddr != NULL) { + dg_data = (struct svc_dg_data*)xprt->xp_p2; + if (dg_data != NULL && dg_data->su_srcaddr.buf != NULL) { + c_uaddr = taddr2uaddr(fdl->nconf, &dg_data->su_srcaddr); + } + else if (saddr != NULL) { c_uaddr = saddr; } else { c_uaddr = taddr2uaddr(fdl->nconf, svc_getrpccaller(xprt)); @@ -217,7 +228,7 @@ mergeaddr(SVCXPRT *xprt, char *netid, char *uaddr, char *saddr) * structure should not be freed. */ struct netconfig * -rpcbind_get_conf(char *netid) +rpcbind_get_conf(const char *netid) { struct fdlist *fdl; diff --git a/usr.sbin/rpcbind/rpcbind.h b/usr.sbin/rpcbind/rpcbind.h index 4aba420..309bc0b 100644 --- a/usr.sbin/rpcbind/rpcbind.h +++ b/usr.sbin/rpcbind/rpcbind.h @@ -85,7 +85,7 @@ extern char *tcp_uaddr; /* Universal TCP address */ int add_bndlist(struct netconfig *, struct netbuf *); bool_t is_bound(char *, char *); char *mergeaddr(SVCXPRT *, char *, char *, char *); -struct netconfig *rpcbind_get_conf(char *); +struct netconfig *rpcbind_get_conf(const char *); void rpcbs_init(void); void rpcbs_procinfo(rpcvers_t, rpcproc_t); @@ -134,8 +134,8 @@ extern void pmap_service(struct svc_req *, SVCXPRT *); void write_warmstart(void); void read_warmstart(void); -char *addrmerge(struct netbuf *caller, char *serv_uaddr, char *clnt_uaddr, - char *netid); +char *addrmerge(struct netbuf *caller, const char *serv_uaddr, + const char *clnt_uaddr, char const *netid); int listen_addr(const struct sockaddr *sa); void network_init(void); struct sockaddr *local_sa(int); diff --git a/usr.sbin/rpcbind/tests/Makefile b/usr.sbin/rpcbind/tests/Makefile new file mode 100644 index 0000000..4b0cf15 --- /dev/null +++ b/usr.sbin/rpcbind/tests/Makefile @@ -0,0 +1,17 @@ +# $FreeBSD$ + +.include <src.opts.mk> + +.PATH: ${.CURDIR}/.. + +ATF_TESTS_C= addrmerge_test +CFLAGS+= -I${.CURDIR}/.. -Wno-cast-qual +SRCS.addrmerge_test= addrmerge_test.c util.c + +.if ${MK_INET6_SUPPORT} != "no" +CFLAGS+= -DINET6 +.endif + +WARNS?= 3 + +.include <bsd.test.mk> diff --git a/usr.sbin/rpcbind/tests/addrmerge_test.c b/usr.sbin/rpcbind/tests/addrmerge_test.c new file mode 100644 index 0000000..357354a --- /dev/null +++ b/usr.sbin/rpcbind/tests/addrmerge_test.c @@ -0,0 +1,849 @@ +/*- + * Copyright (c) 2014 Spectra Logic Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + * + * $FreeBSD$ + */ + +#include <rpc/rpc.h> +#include <sys/types.h> +#include <sys/socket.h> + +#include <net/if.h> +#include <netinet/in.h> +#include <arpa/inet.h> + +#include <ifaddrs.h> +#include <stdlib.h> +#include <stdio.h> + +#include <atf-c.h> + +#include "rpcbind.h" + +#define MAX_IFADDRS 16 + +int debugging = false; + +/* Data for mocking getifaddrs */ +struct ifaddr_storage { + struct ifaddrs ifaddr; + struct sockaddr_storage addr; + struct sockaddr_storage mask; + struct sockaddr_storage bcast; +} mock_ifaddr_storage[MAX_IFADDRS]; +struct ifaddrs *mock_ifaddrs = NULL; +int ifaddr_count = 0; + +/* Data for mocking listen_addr */ +int bind_address_count = 0; +struct sockaddr* bind_addresses[MAX_IFADDRS]; + +/* Stub library functions */ +void +freeifaddrs(struct ifaddrs *ifp __unused) +{ + return ; +} + +int +getifaddrs(struct ifaddrs **ifap) +{ + *ifap = mock_ifaddrs; + return (0); +} + +static void +mock_ifaddr4(const char* name, const char* addr, const char* mask, + const char* bcast, unsigned int flags, bool bind) +{ + struct ifaddrs *ifaddr = &mock_ifaddr_storage[ifaddr_count].ifaddr; + struct sockaddr_in *in = (struct sockaddr_in*) + &mock_ifaddr_storage[ifaddr_count].addr; + struct sockaddr_in *mask_in = (struct sockaddr_in*) + &mock_ifaddr_storage[ifaddr_count].mask; + struct sockaddr_in *bcast_in = (struct sockaddr_in*) + &mock_ifaddr_storage[ifaddr_count].bcast; + + in->sin_family = AF_INET; + in->sin_port = 0; + in->sin_len = sizeof(in); + in->sin_addr.s_addr = inet_addr(addr); + mask_in->sin_family = AF_INET; + mask_in->sin_port = 0; + mask_in->sin_len = sizeof(mask_in); + mask_in->sin_addr.s_addr = inet_addr(mask); + bcast_in->sin_family = AF_INET; + bcast_in->sin_port = 0; + bcast_in->sin_len = sizeof(bcast_in); + bcast_in->sin_addr.s_addr = inet_addr(bcast); + *ifaddr = (struct ifaddrs) { + .ifa_next = NULL, + .ifa_name = (char*) name, + .ifa_flags = flags, + .ifa_addr = (struct sockaddr*) in, + .ifa_netmask = (struct sockaddr*) mask_in, + .ifa_broadaddr = (struct sockaddr*) bcast_in, + .ifa_data = NULL, /* addrmerge doesn't care*/ + }; + + if (ifaddr_count > 0) + mock_ifaddr_storage[ifaddr_count - 1].ifaddr.ifa_next = ifaddr; + ifaddr_count++; + mock_ifaddrs = &mock_ifaddr_storage[0].ifaddr; + + /* Optionally simulate binding an ip ala "rpcbind -h foo" */ + if (bind) { + bind_addresses[bind_address_count] = (struct sockaddr*)in; + bind_address_count++; + } +} + +#ifdef INET6 +static void +mock_ifaddr6(const char* name, const char* addr, const char* mask, + const char* bcast, unsigned int flags, uint32_t scope_id, bool bind) +{ + struct ifaddrs *ifaddr = &mock_ifaddr_storage[ifaddr_count].ifaddr; + struct sockaddr_in6 *in6 = (struct sockaddr_in6*) + &mock_ifaddr_storage[ifaddr_count].addr; + struct sockaddr_in6 *mask_in6 = (struct sockaddr_in6*) + &mock_ifaddr_storage[ifaddr_count].mask; + struct sockaddr_in6 *bcast_in6 = (struct sockaddr_in6*) + &mock_ifaddr_storage[ifaddr_count].bcast; + + in6->sin6_family = AF_INET6; + in6->sin6_port = 0; + in6->sin6_len = sizeof(*in6); + in6->sin6_scope_id = scope_id; + ATF_REQUIRE_EQ(1, inet_pton(AF_INET6, addr, (void*)&in6->sin6_addr)); + mask_in6->sin6_family = AF_INET6; + mask_in6->sin6_port = 0; + mask_in6->sin6_len = sizeof(*mask_in6); + mask_in6->sin6_scope_id = scope_id; + ATF_REQUIRE_EQ(1, inet_pton(AF_INET6, mask, + (void*)&mask_in6->sin6_addr)); + bcast_in6->sin6_family = AF_INET6; + bcast_in6->sin6_port = 0; + bcast_in6->sin6_len = sizeof(*bcast_in6); + bcast_in6->sin6_scope_id = scope_id; + ATF_REQUIRE_EQ(1, inet_pton(AF_INET6, bcast, + (void*)&bcast_in6->sin6_addr)); + *ifaddr = (struct ifaddrs) { + .ifa_next = NULL, + .ifa_name = (char*) name, + .ifa_flags = flags, + .ifa_addr = (struct sockaddr*) in6, + .ifa_netmask = (struct sockaddr*) mask_in6, + .ifa_broadaddr = (struct sockaddr*) bcast_in6, + .ifa_data = NULL, /* addrmerge doesn't care*/ + }; + + if (ifaddr_count > 0) + mock_ifaddr_storage[ifaddr_count - 1].ifaddr.ifa_next = ifaddr; + ifaddr_count++; + mock_ifaddrs = &mock_ifaddr_storage[0].ifaddr; + + /* Optionally simulate binding an ip ala "rpcbind -h foo" */ + if (bind) { + bind_addresses[bind_address_count] = (struct sockaddr*)in6; + bind_address_count++; + } +} +#else +static void +mock_ifaddr6(const char* name __unused, const char* addr __unused, + const char* mask __unused, const char* bcast __unused, + unsigned int flags __unused, uint32_t scope_id __unused, bool bind __unused) +{ +} +#endif /*INET6 */ + +static void +mock_lo0(void) +{ + /* + * This broadcast address looks wrong, but it's what getifaddrs(2) + * actually returns. It's invalid because IFF_BROADCAST is not set + */ + mock_ifaddr4("lo0", "127.0.0.1", "255.0.0.0", "127.0.0.1", + IFF_LOOPBACK | IFF_UP | IFF_RUNNING | IFF_MULTICAST, false); + mock_ifaddr6("lo0", "::1", "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", + "::1", + IFF_LOOPBACK | IFF_UP | IFF_RUNNING | IFF_MULTICAST, 0, false); +} + +static void +mock_igb0(void) +{ + mock_ifaddr4("igb0", "192.0.2.2", "255.255.255.128", "192.0.2.127", + IFF_UP | IFF_BROADCAST | IFF_RUNNING | IFF_SIMPLEX | IFF_MULTICAST, + false); + mock_ifaddr6("igb0", "2001:db8::2", "ffff:ffff:ffff:ffff::", + "2001:db8::ffff:ffff:ffff:ffff", + IFF_UP | IFF_BROADCAST | IFF_RUNNING | IFF_SIMPLEX | IFF_MULTICAST, + 0, false); + /* Link local address */ + mock_ifaddr6("igb0", "fe80::2", "ffff:ffff:ffff:ffff::", + "fe80::ffff:ffff:ffff:ffff", + IFF_UP | IFF_BROADCAST | IFF_RUNNING | IFF_SIMPLEX | IFF_MULTICAST, + 2, false); +} + +/* On the same subnet as igb0 */ +static void +mock_igb1(bool bind) +{ + mock_ifaddr4("igb1", "192.0.2.3", "255.255.255.128", "192.0.2.127", + IFF_UP | IFF_BROADCAST | IFF_RUNNING | IFF_SIMPLEX | IFF_MULTICAST, + bind); + mock_ifaddr6("igb1", "2001:db8::3", "ffff:ffff:ffff:ffff::", + "2001:db8::ffff:ffff:ffff:ffff", + IFF_UP | IFF_BROADCAST | IFF_RUNNING | IFF_SIMPLEX | IFF_MULTICAST, + 0, bind); + /* Link local address */ + mock_ifaddr6("igb1", "fe80::3", "ffff:ffff:ffff:ffff::", + "fe80::ffff:ffff:ffff:ffff", + IFF_UP | IFF_BROADCAST | IFF_RUNNING | IFF_SIMPLEX | IFF_MULTICAST, + 3, bind); +} + +/* igb2 is on a different subnet than igb0 */ +static void +mock_igb2(void) +{ + mock_ifaddr4("igb2", "192.0.2.130", "255.255.255.128", "192.0.2.255", + IFF_UP | IFF_BROADCAST | IFF_RUNNING | IFF_SIMPLEX | IFF_MULTICAST, + false); + mock_ifaddr6("igb2", "2001:db8:1::2", "ffff:ffff:ffff:ffff::", + "2001:db8:1:0:ffff:ffff:ffff:ffff", + IFF_UP | IFF_BROADCAST | IFF_RUNNING | IFF_SIMPLEX | IFF_MULTICAST, + 0, false); +} + +/* tun0 is a P2P interface */ +static void +mock_tun0(void) +{ + mock_ifaddr4("tun0", "192.0.2.5", "255.255.255.255", "192.0.2.6", + IFF_UP | IFF_RUNNING | IFF_POINTOPOINT | IFF_MULTICAST, false); + mock_ifaddr6("tun0", "2001:db8::5", + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", + "2001:db8::6", + IFF_UP | IFF_RUNNING | IFF_POINTOPOINT | IFF_MULTICAST, 0, false); +} + + +/* Stub rpcbind functions */ +int +listen_addr(const struct sockaddr *sa) +{ + int i; + + if (bind_address_count == 0) + return (1); + + for (i = 0; i < bind_address_count; i++) { + if (bind_addresses[i]->sa_family != sa->sa_family) + continue; + + if (0 == memcmp(bind_addresses[i]->sa_data, sa->sa_data, + sa->sa_len)) + return (1); + } + return (0); +} + +struct netconfig* +rpcbind_get_conf(const char* netid __unused) +{ + /* Use static variables so we can return pointers to them */ + static char* lookups = NULL; + static struct netconfig nconf_udp; +#ifdef INET6 + static struct netconfig nconf_udp6; +#endif /* INET6 */ + + nconf_udp.nc_netid = "udp"; //netid_storage; + nconf_udp.nc_semantics = NC_TPI_CLTS; + nconf_udp.nc_flag = NC_VISIBLE; + nconf_udp.nc_protofmly = (char*)"inet"; + nconf_udp.nc_proto = (char*)"udp"; + nconf_udp.nc_device = (char*)"-"; + nconf_udp.nc_nlookups = 0; + nconf_udp.nc_lookups = &lookups; + +#ifdef INET6 + nconf_udp6.nc_netid = "udp6"; //netid_storage; + nconf_udp6.nc_semantics = NC_TPI_CLTS; + nconf_udp6.nc_flag = NC_VISIBLE; + nconf_udp6.nc_protofmly = (char*)"inet6"; + nconf_udp6.nc_proto = (char*)"udp6"; + nconf_udp6.nc_device = (char*)"-"; + nconf_udp6.nc_nlookups = 0; + nconf_udp6.nc_lookups = &lookups; +#endif /* INET6 */ + + if (0 == strncmp("udp", netid, sizeof("udp"))) + return (&nconf_udp); +#ifdef INET6 + else if (0 == strncmp("udp6", netid, sizeof("udp6"))) + return (&nconf_udp6); +#endif /* INET6 */ + else + return (NULL); +} + +/* + * Helper function used by most test cases + * param recvdstaddr If non-null, the uaddr on which the request was received + */ +static char* +do_addrmerge4(const char* recvdstaddr) +{ + struct netbuf caller; + struct sockaddr_in caller_in; + const char *serv_uaddr, *clnt_uaddr, *netid; + + /* caller contains the client's IP address */ + caller.maxlen = sizeof(struct sockaddr_storage); + caller.len = sizeof(caller_in); + caller_in.sin_family = AF_INET; + caller_in.sin_len = sizeof(caller_in); + caller_in.sin_port = 1234; + caller_in.sin_addr.s_addr = inet_addr("192.0.2.1"); + caller.buf = (void*)&caller_in; + if (recvdstaddr != NULL) + clnt_uaddr = recvdstaddr; + else + clnt_uaddr = "192.0.2.1.3.46"; + + /* assume server is bound in INADDR_ANY port 814 */ + serv_uaddr = "0.0.0.0.3.46"; + + netid = "udp"; + return (addrmerge(&caller, serv_uaddr, clnt_uaddr, netid)); +} + +#ifdef INET6 +/* + * Variant of do_addrmerge4 where the caller has an IPv6 address + * param recvdstaddr If non-null, the uaddr on which the request was received + */ +static char* +do_addrmerge6(const char* recvdstaddr) +{ + struct netbuf caller; + struct sockaddr_in6 caller_in6; + const char *serv_uaddr, *clnt_uaddr, *netid; + + /* caller contains the client's IP address */ + caller.maxlen = sizeof(struct sockaddr_storage); + caller.len = sizeof(caller_in6); + caller_in6.sin6_family = AF_INET6; + caller_in6.sin6_len = sizeof(caller_in6); + caller_in6.sin6_port = 1234; + ATF_REQUIRE_EQ(1, inet_pton(AF_INET6, "2001:db8::1", + (void*)&caller_in6.sin6_addr)); + caller.buf = (void*)&caller_in6; + if (recvdstaddr != NULL) + clnt_uaddr = recvdstaddr; + else + clnt_uaddr = "2001:db8::1.3.46"; + + /* assume server is bound in INADDR_ANY port 814 */ + serv_uaddr = "::1.3.46"; + + netid = "udp6"; + return (addrmerge(&caller, serv_uaddr, clnt_uaddr, netid)); +} + +/* Variant of do_addrmerge6 where the caller uses a link local address */ +static char* +do_addrmerge6_ll(void) +{ + struct netbuf caller; + struct sockaddr_in6 caller_in6; + const char *serv_uaddr, *clnt_uaddr, *netid; + + /* caller contains the client's IP address */ + caller.maxlen = sizeof(struct sockaddr_storage); + caller.len = sizeof(caller_in6); + caller_in6.sin6_family = AF_INET6; + caller_in6.sin6_len = sizeof(caller_in6); + caller_in6.sin6_port = 1234; + caller_in6.sin6_scope_id = 2; /* same as igb0 */ + ATF_REQUIRE_EQ(1, inet_pton(AF_INET6, "fe80::beef", + (void*)&caller_in6.sin6_addr)); + caller.buf = (void*)&caller_in6; + clnt_uaddr = "fe80::beef.3.46"; + + /* assume server is bound in INADDR_ANY port 814 */ + serv_uaddr = "::1.3.46"; + + netid = "udp6"; + return (addrmerge(&caller, serv_uaddr, clnt_uaddr, netid)); +} +#endif /* INET6 */ + +ATF_TC_WITHOUT_HEAD(addrmerge_noifaddrs); +ATF_TC_BODY(addrmerge_noifaddrs, tc) +{ + char* maddr; + + maddr = do_addrmerge4(NULL); + + /* Since getifaddrs returns null, addrmerge must too */ + ATF_CHECK_EQ(NULL, maddr); +} + +ATF_TC_WITHOUT_HEAD(addrmerge_localhost_only); +ATF_TC_BODY(addrmerge_localhost_only, tc) +{ + char *maddr; + + /* getifaddrs will return localhost only */ + mock_lo0(); + + maddr = do_addrmerge4(NULL); + + /* We must return localhost if there is nothing better */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("127.0.0.1.3.46", maddr); +} + +ATF_TC_WITHOUT_HEAD(addrmerge_singlehomed); +ATF_TC_BODY(addrmerge_singlehomed, tc) +{ + char *maddr; + + /* getifaddrs will return one public address */ + mock_lo0(); + mock_igb0(); + + maddr = do_addrmerge4(NULL); + + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("192.0.2.2.3.46", maddr); +} + +ATF_TC_WITHOUT_HEAD(addrmerge_one_addr_on_each_subnet); +ATF_TC_BODY(addrmerge_one_addr_on_each_subnet, tc) +{ + char *maddr; + + mock_lo0(); + mock_igb0(); + mock_igb2(); + + maddr = do_addrmerge4(NULL); + + /* We must return the address on the caller's subnet */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("192.0.2.2.3.46", maddr); +} + + +/* + * Like addrmerge_one_addr_on_each_subnet, but getifaddrs returns a different + * order + */ +ATF_TC_WITHOUT_HEAD(addrmerge_one_addr_on_each_subnet_rev); +ATF_TC_BODY(addrmerge_one_addr_on_each_subnet_rev, tc) +{ + char *maddr; + + /* getifaddrs will return one public address on each of two subnets */ + mock_igb2(); + mock_igb0(); + mock_lo0(); + + maddr = do_addrmerge4(NULL); + + /* We must return the address on the caller's subnet */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("192.0.2.2.3.46", maddr); +} + +ATF_TC_WITHOUT_HEAD(addrmerge_point2point); +ATF_TC_BODY(addrmerge_point2point, tc) +{ + char *maddr; + + /* getifaddrs will return one normal and one p2p address */ + mock_lo0(); + mock_igb2(); + mock_tun0(); + + maddr = do_addrmerge4(NULL); + + /* addrmerge should disprefer P2P interfaces */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("192.0.2.130.3.46", maddr); +} + +/* Like addrerge_point2point, but getifaddrs returns a different order */ +ATF_TC_WITHOUT_HEAD(addrmerge_point2point_rev); +ATF_TC_BODY(addrmerge_point2point_rev, tc) +{ + char *maddr; + + /* getifaddrs will return one normal and one p2p address */ + mock_tun0(); + mock_igb2(); + mock_lo0(); + + maddr = do_addrmerge4(NULL); + + /* addrmerge should disprefer P2P interfaces */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("192.0.2.130.3.46", maddr); +} + +/* + * Simulate using rpcbind -h to select just one ip when the subnet has + * multiple + */ +ATF_TC_WITHOUT_HEAD(addrmerge_bindip); +ATF_TC_BODY(addrmerge_bindip, tc) +{ + char *maddr; + + /* getifaddrs will return one public address on each of two subnets */ + mock_lo0(); + mock_igb0(); + mock_igb1(true); + + maddr = do_addrmerge4(NULL); + + /* We must return the address to which we are bound */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("192.0.2.3.3.46", maddr); +} + +/* Like addrmerge_bindip, but getifaddrs returns a different order */ +ATF_TC_WITHOUT_HEAD(addrmerge_bindip_rev); +ATF_TC_BODY(addrmerge_bindip_rev, tc) +{ + char *maddr; + + /* getifaddrs will return one public address on each of two subnets */ + mock_igb1(true); + mock_igb0(); + mock_lo0(); + + maddr = do_addrmerge4(NULL); + + /* We must return the address to which we are bound */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("192.0.2.3.3.46", maddr); +} + +/* + * The address on which the request was received is known, and is provided as + * the hint. + */ +ATF_TC_WITHOUT_HEAD(addrmerge_recvdstaddr); +ATF_TC_BODY(addrmerge_recvdstaddr, tc) +{ + char *maddr; + + mock_lo0(); + mock_igb0(); + mock_igb1(false); + + maddr = do_addrmerge4("192.0.2.2.3.46"); + + /* We must return the address on which the request was received */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("192.0.2.2.3.46", maddr); +} + +ATF_TC_WITHOUT_HEAD(addrmerge_recvdstaddr_rev); +ATF_TC_BODY(addrmerge_recvdstaddr_rev, tc) +{ + char *maddr; + + mock_igb1(false); + mock_igb0(); + mock_lo0(); + + maddr = do_addrmerge4("192.0.2.2.3.46"); + + /* We must return the address on which the request was received */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("192.0.2.2.3.46", maddr); +} + +#ifdef INET6 +ATF_TC_WITHOUT_HEAD(addrmerge_localhost_only6); +ATF_TC_BODY(addrmerge_localhost_only6, tc) +{ + char *maddr; + + /* getifaddrs will return localhost only */ + mock_lo0(); + + maddr = do_addrmerge6(NULL); + + /* We must return localhost if there is nothing better */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("::1.3.46", maddr); +} + +ATF_TC_WITHOUT_HEAD(addrmerge_singlehomed6); +ATF_TC_BODY(addrmerge_singlehomed6, tc) +{ + char *maddr; + + /* getifaddrs will return one public address */ + mock_lo0(); + mock_igb0(); + + maddr = do_addrmerge6(NULL); + + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("2001:db8::2.3.46", maddr); +} + +ATF_TC_WITHOUT_HEAD(addrmerge_one_addr_on_each_subnet6); +ATF_TC_BODY(addrmerge_one_addr_on_each_subnet6, tc) +{ + char *maddr; + + mock_lo0(); + mock_igb0(); + mock_igb2(); + + maddr = do_addrmerge6(NULL); + + /* We must return the address on the caller's subnet */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("2001:db8::2.3.46", maddr); +} + + +/* + * Like addrmerge_one_addr_on_each_subnet6, but getifaddrs returns a different + * order + */ +ATF_TC_WITHOUT_HEAD(addrmerge_one_addr_on_each_subnet6_rev); +ATF_TC_BODY(addrmerge_one_addr_on_each_subnet6_rev, tc) +{ + char *maddr; + + /* getifaddrs will return one public address on each of two subnets */ + mock_igb2(); + mock_igb0(); + mock_lo0(); + + maddr = do_addrmerge6(NULL); + + /* We must return the address on the caller's subnet */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("2001:db8::2.3.46", maddr); +} + +ATF_TC_WITHOUT_HEAD(addrmerge_point2point6); +ATF_TC_BODY(addrmerge_point2point6, tc) +{ + char *maddr; + + /* getifaddrs will return one normal and one p2p address */ + mock_lo0(); + mock_igb2(); + mock_tun0(); + + maddr = do_addrmerge6(NULL); + + /* addrmerge should disprefer P2P interfaces */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("2001:db8:1::2.3.46", maddr); +} + +/* Like addrerge_point2point, but getifaddrs returns a different order */ +ATF_TC_WITHOUT_HEAD(addrmerge_point2point6_rev); +ATF_TC_BODY(addrmerge_point2point6_rev, tc) +{ + char *maddr; + + /* getifaddrs will return one normal and one p2p address */ + mock_tun0(); + mock_igb2(); + mock_lo0(); + + maddr = do_addrmerge6(NULL); + + /* addrmerge should disprefer P2P interfaces */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("2001:db8:1::2.3.46", maddr); +} + +ATF_TC_WITHOUT_HEAD(addrmerge_bindip6); +ATF_TC_BODY(addrmerge_bindip6, tc) +{ + char *maddr; + + /* getifaddrs will return one public address on each of two subnets */ + mock_lo0(); + mock_igb0(); + mock_igb1(true); + + maddr = do_addrmerge6(NULL); + + /* We must return the address to which we are bound */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("2001:db8::3.3.46", maddr); +} + +/* Like addrerge_bindip, but getifaddrs returns a different order */ +ATF_TC_WITHOUT_HEAD(addrmerge_bindip6_rev); +ATF_TC_BODY(addrmerge_bindip6_rev, tc) +{ + char *maddr; + + /* getifaddrs will return one public address on each of two subnets */ + mock_igb1(true); + mock_igb0(); + mock_lo0(); + + maddr = do_addrmerge6(NULL); + + /* We must return the address to which we are bound */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("2001:db8::3.3.46", maddr); +} + +/* + * IPv6 Link Local addresses with the same scope id as the caller, if the caller + * is also a link local address, should be preferred + */ +ATF_TC_WITHOUT_HEAD(addrmerge_ipv6_linklocal); +ATF_TC_BODY(addrmerge_ipv6_linklocal, tc) +{ + char *maddr; + + /* + * getifaddrs will return two link local addresses with the same netmask + * and prefix but different scope IDs + */ + mock_igb1(false); + mock_igb0(); + mock_lo0(); + + maddr = do_addrmerge6_ll(); + + /* We must return the address to which we are bound */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("fe80::2.3.46", maddr); +} + +ATF_TC_WITHOUT_HEAD(addrmerge_ipv6_linklocal_rev); +ATF_TC_BODY(addrmerge_ipv6_linklocal_rev, tc) +{ + char *maddr; + + /* + * getifaddrs will return two link local addresses with the same netmask + * and prefix but different scope IDs + */ + mock_lo0(); + mock_igb0(); + mock_igb1(false); + + maddr = do_addrmerge6_ll(); + + /* We must return the address to which we are bound */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("fe80::2.3.46", maddr); +} + +ATF_TC_WITHOUT_HEAD(addrmerge_recvdstaddr6); +ATF_TC_BODY(addrmerge_recvdstaddr6, tc) +{ + char *maddr; + + mock_lo0(); + mock_igb0(); + mock_igb1(false); + + maddr = do_addrmerge6("2001:db8::2.3.46"); + + /* We must return the address on which the request was received */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("2001:db8::2.3.46", maddr); +} + +ATF_TC_WITHOUT_HEAD(addrmerge_recvdstaddr6_rev); +ATF_TC_BODY(addrmerge_recvdstaddr6_rev, tc) +{ + char *maddr; + + mock_igb1(false); + mock_igb0(); + mock_lo0(); + + maddr = do_addrmerge6("2001:db8::2.3.46"); + + /* We must return the address on which the request was received */ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("2001:db8::2.3.46", maddr); +} +#endif /* INET6 */ + + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, addrmerge_noifaddrs); + ATF_TP_ADD_TC(tp, addrmerge_localhost_only); + ATF_TP_ADD_TC(tp, addrmerge_singlehomed); + ATF_TP_ADD_TC(tp, addrmerge_one_addr_on_each_subnet); + ATF_TP_ADD_TC(tp, addrmerge_one_addr_on_each_subnet_rev); + ATF_TP_ADD_TC(tp, addrmerge_point2point); + ATF_TP_ADD_TC(tp, addrmerge_point2point_rev); + ATF_TP_ADD_TC(tp, addrmerge_bindip); + ATF_TP_ADD_TC(tp, addrmerge_bindip_rev); + ATF_TP_ADD_TC(tp, addrmerge_recvdstaddr); + ATF_TP_ADD_TC(tp, addrmerge_recvdstaddr_rev); +#ifdef INET6 + ATF_TP_ADD_TC(tp, addrmerge_localhost_only6); + ATF_TP_ADD_TC(tp, addrmerge_singlehomed6); + ATF_TP_ADD_TC(tp, addrmerge_one_addr_on_each_subnet6); + ATF_TP_ADD_TC(tp, addrmerge_one_addr_on_each_subnet6_rev); + ATF_TP_ADD_TC(tp, addrmerge_point2point6); + ATF_TP_ADD_TC(tp, addrmerge_point2point6_rev); + ATF_TP_ADD_TC(tp, addrmerge_bindip6); + ATF_TP_ADD_TC(tp, addrmerge_bindip6_rev); + ATF_TP_ADD_TC(tp, addrmerge_ipv6_linklocal); + ATF_TP_ADD_TC(tp, addrmerge_ipv6_linklocal_rev); + ATF_TP_ADD_TC(tp, addrmerge_recvdstaddr6); + ATF_TP_ADD_TC(tp, addrmerge_recvdstaddr6_rev); +#endif + + return (atf_no_error()); +} diff --git a/usr.sbin/rpcbind/util.c b/usr.sbin/rpcbind/util.c index 8ddb13e..da6a5ab 100644 --- a/usr.sbin/rpcbind/util.c +++ b/usr.sbin/rpcbind/util.c @@ -56,7 +56,7 @@ static struct sockaddr_in *local_in4; static struct sockaddr_in6 *local_in6; #endif -static int bitmaskcmp(void *, void *, void *, int); +static int bitmaskcmp(struct sockaddr *, struct sockaddr *, struct sockaddr *); /* * For all bits set in "mask", compare the corresponding bits in @@ -64,10 +64,34 @@ static int bitmaskcmp(void *, void *, void *, int); * match. */ static int -bitmaskcmp(void *dst, void *src, void *mask, int bytelen) +bitmaskcmp(struct sockaddr *dst, struct sockaddr *src, struct sockaddr *mask) { int i; - u_int8_t *p1 = dst, *p2 = src, *netmask = mask; + u_int8_t *p1, *p2, *netmask; + int bytelen; + + if (dst->sa_family != src->sa_family || + dst->sa_family != mask->sa_family) + return (1); + + switch (dst->sa_family) { + case AF_INET: + p1 = (uint8_t*) &SA2SINADDR(dst); + p2 = (uint8_t*) &SA2SINADDR(src); + netmask = (uint8_t*) &SA2SINADDR(mask); + bytelen = sizeof(struct in_addr); + break; +#ifdef INET6 + case AF_INET6: + p1 = (uint8_t*) &SA2SIN6ADDR(dst); + p2 = (uint8_t*) &SA2SIN6ADDR(src); + netmask = (uint8_t*) &SA2SIN6ADDR(mask); + bytelen = sizeof(struct in6_addr); + break; +#endif + default: + return (1); + } for (i = 0; i < bytelen; i++) if ((p1[i] & netmask[i]) != (p2[i] & netmask[i])) @@ -86,16 +110,18 @@ bitmaskcmp(void *dst, void *src, void *mask, int bytelen) * string which should be freed by the caller. On error, returns NULL. */ char * -addrmerge(struct netbuf *caller, char *serv_uaddr, char *clnt_uaddr, - char *netid) +addrmerge(struct netbuf *caller, const char *serv_uaddr, const char *clnt_uaddr, + const char *netid) { struct ifaddrs *ifap, *ifp = NULL, *bestif; struct netbuf *serv_nbp = NULL, *hint_nbp = NULL, tbuf; struct sockaddr *caller_sa, *hint_sa, *ifsa, *ifmasksa, *serv_sa; struct sockaddr_storage ss; struct netconfig *nconf; - char *caller_uaddr = NULL, *hint_uaddr = NULL; + char *caller_uaddr = NULL; + const char *hint_uaddr = NULL; char *ret = NULL; + int bestif_goodness; #ifdef ND_DEBUG if (debugging) @@ -139,19 +165,29 @@ addrmerge(struct netbuf *caller, char *serv_uaddr, char *clnt_uaddr, goto freeit; /* - * Loop through all interfaces. For each interface, see if it - * is either the loopback interface (which we always listen - * on) or is one of the addresses the program bound to (the - * wildcard by default, or a subset if -h is specified) and - * the network portion of its address is equal to that of the - * client. If so, we have found the interface that we want to - * use. + * Loop through all interface addresses. We are listening to an address + * if any of the following are true: + * a) It's a loopback address + * b) It was specified with the -h command line option + * c) There were no -h command line options. + * + * Among addresses on which we are listening, choose in order of + * preference an address that is: + * + * a) Equal to the hint + * b) A link local address with the same scope ID as the client's + * address, if the client's address is also link local + * c) An address on the same subnet as the client's address + * d) A non-localhost, non-p2p address + * e) Any usable address */ bestif = NULL; + bestif_goodness = 0; for (ifap = ifp; ifap != NULL; ifap = ifap->ifa_next) { ifsa = ifap->ifa_addr; ifmasksa = ifap->ifa_netmask; + /* Skip addresses where we don't listen */ if (ifsa == NULL || ifsa->sa_family != hint_sa->sa_family || !(ifap->ifa_flags & IFF_UP)) continue; @@ -159,21 +195,29 @@ addrmerge(struct netbuf *caller, char *serv_uaddr, char *clnt_uaddr, if (!(ifap->ifa_flags & IFF_LOOPBACK) && !listen_addr(ifsa)) continue; - switch (hint_sa->sa_family) { - case AF_INET: - /* - * If the hint address matches this interface - * address/netmask, then we're done. - */ - if (!bitmaskcmp(&SA2SINADDR(ifsa), - &SA2SINADDR(hint_sa), &SA2SINADDR(ifmasksa), - sizeof(struct in_addr))) { - bestif = ifap; - goto found; - } - break; + if ((hint_sa->sa_family == AF_INET) && + ((((struct sockaddr_in*)hint_sa)->sin_addr.s_addr == + ((struct sockaddr_in*)ifsa)->sin_addr.s_addr))) { + const int goodness = 4; + + bestif_goodness = goodness; + bestif = ifap; + goto found; + } #ifdef INET6 - case AF_INET6: + if ((hint_sa->sa_family == AF_INET6) && + (0 == memcmp(&((struct sockaddr_in6*)hint_sa)->sin6_addr, + &((struct sockaddr_in6*)ifsa)->sin6_addr, + sizeof(struct in6_addr))) && + (((struct sockaddr_in6*)hint_sa)->sin6_scope_id == + (((struct sockaddr_in6*)ifsa)->sin6_scope_id))) { + const int goodness = 4; + + bestif_goodness = goodness; + bestif = ifap; + goto found; + } + if (hint_sa->sa_family == AF_INET6) { /* * For v6 link local addresses, if the caller is on * a link-local address then use the scope id to see @@ -184,28 +228,33 @@ addrmerge(struct netbuf *caller, char *serv_uaddr, char *clnt_uaddr, IN6_IS_ADDR_LINKLOCAL(&SA2SIN6ADDR(hint_sa))) { if (SA2SIN6(ifsa)->sin6_scope_id == SA2SIN6(caller_sa)->sin6_scope_id) { - bestif = ifap; - goto found; + const int goodness = 3; + + if (bestif_goodness < goodness) { + bestif = ifap; + bestif_goodness = goodness; + } } - } else if (!bitmaskcmp(&SA2SIN6ADDR(ifsa), - &SA2SIN6ADDR(hint_sa), &SA2SIN6ADDR(ifmasksa), - sizeof(struct in6_addr))) { + } + } +#endif /* INET6 */ + if (0 == bitmaskcmp(hint_sa, ifsa, ifmasksa)) { + const int goodness = 2; + + if (bestif_goodness < goodness) { bestif = ifap; - goto found; + bestif_goodness = goodness; } - break; -#endif - default: - continue; } + if (!(ifap->ifa_flags & (IFF_LOOPBACK | IFF_POINTOPOINT))) { + const int goodness = 1; - /* - * Remember the first possibly useful interface, preferring - * "normal" to point-to-point and loopback ones. - */ - if (bestif == NULL || - (!(ifap->ifa_flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) && - (bestif->ifa_flags & (IFF_LOOPBACK | IFF_POINTOPOINT)))) + if (bestif_goodness < goodness) { + bestif = ifap; + bestif_goodness = goodness; + } + } + if (bestif == NULL) bestif = ifap; } if (bestif == NULL) diff --git a/usr.sbin/services_mkdb/services_mkdb.c b/usr.sbin/services_mkdb/services_mkdb.c index a91340e..9ea66de 100644 --- a/usr.sbin/services_mkdb/services_mkdb.c +++ b/usr.sbin/services_mkdb/services_mkdb.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <libgen.h> #include <libutil.h> #include <ctype.h> #include <errno.h> @@ -91,6 +92,8 @@ main(int argc, char *argv[]) size_t cnt = 0; StringList *sl, ***svc; size_t port, proto; + char *dbname_dir; + int dbname_dir_fd = -1; setprogname(argv[0]); @@ -138,7 +141,7 @@ main(int argc, char *argv[]) err(1, "Cannot install exit handler"); (void)snprintf(tname, sizeof(tname), "%s.tmp", dbname); - db = dbopen(tname, O_RDWR | O_CREAT | O_EXCL, + db = dbopen(tname, O_RDWR | O_CREAT | O_EXCL | O_SYNC, (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH), DB_HASH, &hinfo); if (!db) err(1, "Error opening temporary database `%s'", tname); @@ -164,8 +167,21 @@ main(int argc, char *argv[]) if ((db->close)(db)) err(1, "Error closing temporary database `%s'", tname); - if (rename(tname, dbname) == -1) + /* + * Make sure file is safe on disk. To improve performance we will call + * fsync() to the directory where file lies + */ + if (rename(tname, dbname) == -1 || + (dbname_dir = dirname(dbname)) == NULL || + (dbname_dir_fd = open(dbname_dir, O_RDONLY|O_DIRECTORY)) == -1 || + fsync(dbname_dir_fd) != 0) { + if (dbname_dir_fd != -1) + close(dbname_dir_fd); err(1, "Cannot rename `%s' to `%s'", tname, dbname); + } + + if (dbname_dir_fd != -1) + close(dbname_dir_fd); return 0; } diff --git a/usr.sbin/sesutil/Makefile.depend b/usr.sbin/sesutil/Makefile.depend index 3646e2e..6002005 100644 --- a/usr.sbin/sesutil/Makefile.depend +++ b/usr.sbin/sesutil/Makefile.depend @@ -9,6 +9,7 @@ DIRDEPS = \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ + lib/libsbuf \ .include <dirdeps.mk> diff --git a/usr.sbin/ypldap/yp.c b/usr.sbin/ypldap/yp.c index e461136..3676245 100644 --- a/usr.sbin/ypldap/yp.c +++ b/usr.sbin/ypldap/yp.c @@ -83,10 +83,10 @@ void yp_enable_events(void) { int i; - extern fd_set svc_fdset; + extern fd_set svc_fdset; struct yp_event *ye; - for (i = 0; i < getdtablesize(); i++) { + for (i = 0; i < FD_SETSIZE; i++) { if (FD_ISSET(i, &svc_fdset)) { if ((ye = calloc(1, sizeof(*ye))) == NULL) fatal(NULL); diff --git a/usr.sbin/ypldap/ypldap.conf.5 b/usr.sbin/ypldap/ypldap.conf.5 index 5c22b3b..5c936a9 100644 --- a/usr.sbin/ypldap/ypldap.conf.5 +++ b/usr.sbin/ypldap/ypldap.conf.5 @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: April 30 2012 $ +.Dd $Mdocdate: January 13 2016 $ .Dt YPLDAP.CONF 5 .Os .Sh NAME @@ -155,6 +155,9 @@ Use the supplied LDAP filter to retrieve password entries. .It Pa /etc/ypldap.conf .Xr ypldap 8 configuration file. +.It Pa /usr/share/example/ypldap/ypldap.conf +.Xr ypldap 8 +configuration file example. .El .Sh SEE ALSO .Xr ypbind 8 , |