Re: wscons: free size
Yes the queue is always that size. Anton Lindqvist wrote: > Comments? OK? > > Index: dev/wscons/wsevent.c > === > RCS file: /cvs/src/sys/dev/wscons/wsevent.c,v > retrieving revision 1.18 > diff -u -p -r1.18 wsevent.c > --- dev/wscons/wsevent.c 19 Nov 2018 19:19:24 - 1.18 > +++ dev/wscons/wsevent.c 1 Feb 2019 07:16:03 - > @@ -127,7 +127,7 @@ wsevent_fini(struct wseventvar *ev) > #endif > return; > } > - free(ev->q, M_DEVBUF, 0); > + free(ev->q, M_DEVBUF, WSEVENT_QSIZE * sizeof(struct wscons_event)); > ev->q = NULL; > > sigio_free(>sigio); >
wscons: free size
Comments? OK? Index: dev/wscons/wsevent.c === RCS file: /cvs/src/sys/dev/wscons/wsevent.c,v retrieving revision 1.18 diff -u -p -r1.18 wsevent.c --- dev/wscons/wsevent.c19 Nov 2018 19:19:24 - 1.18 +++ dev/wscons/wsevent.c1 Feb 2019 07:16:03 - @@ -127,7 +127,7 @@ wsevent_fini(struct wseventvar *ev) #endif return; } - free(ev->q, M_DEVBUF, 0); + free(ev->q, M_DEVBUF, WSEVENT_QSIZE * sizeof(struct wscons_event)); ev->q = NULL; sigio_free(>sigio);
Man page/doc/slides/books/specs re OpenBSD memory model or memory order?
Hi, This is not to suggest that the following would be relevant or needed: Is there any any man page, or documents, slides, books or standards specification documents regarding OpenBSD's memory model or memory order considerations? A marc.info misc@ or tech@ or Google search for query gives no results. C and C++ got memory models as of C11 and C++11, ref. https://en.wikipedia.org/wiki/Memory_model_(programming), http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf section 7.17. For another system there is a discussion at https://www.kernel.org/doc/Documentation/memory-barriers.txt . Thanks, Joseph (Feel free to move to misc@ )
Re: fsync(2) and I/O errors
On Thu, Jan 31, 2019 at 04:26:45PM -0500, Ted Unangst wrote: > Instead, we note that the write failed and mark a flag in the vnode. Future > calls to fsync will then return EIO when this flag is set. We clear the flag > when the vnode is released. Sounds reasonable. OK bluhm@ > Index: kern/vfs_bio.c > === > RCS file: /home/cvs/src/sys/kern/vfs_bio.c,v > retrieving revision 1.187 > diff -u -p -r1.187 vfs_bio.c > --- kern/vfs_bio.c21 Nov 2018 16:14:43 - 1.187 > +++ kern/vfs_bio.c31 Jan 2019 21:19:36 - > @@ -867,6 +867,11 @@ brelse(struct buf *bp) > /* If it's not cacheable, or an error, mark it invalid. */ > if (ISSET(bp->b_flags, (B_NOCACHE|B_ERROR))) > SET(bp->b_flags, B_INVAL); > + /* If it's a write error, also mark the vnode as damaged. */ > + if (ISSET(bp->b_flags, B_ERROR) && !ISSET(bp->b_flags, B_READ)) { > + if (bp->b_vp && bp->b_vp->v_type == VREG) > + SET(bp->b_vp->v_bioflag, VBIOERROR); > + } > > if (ISSET(bp->b_flags, B_INVAL)) { > /* > Index: kern/vfs_subr.c > === > RCS file: /home/cvs/src/sys/kern/vfs_subr.c,v > retrieving revision 1.285 > diff -u -p -r1.285 vfs_subr.c > --- kern/vfs_subr.c 21 Jan 2019 18:09:21 - 1.285 > +++ kern/vfs_subr.c 31 Jan 2019 21:09:22 - > @@ -712,6 +712,7 @@ vputonfreelist(struct vnode *vp) > #endif > > vp->v_bioflag |= VBIOONFREELIST; > + vp->v_bioflag &= ~VBIOERROR; > > if (vp->v_holdcnt > 0) > lst = _hold_list; > Index: kern/vfs_vops.c > === > RCS file: /home/cvs/src/sys/kern/vfs_vops.c,v > retrieving revision 1.19 > diff -u -p -r1.19 vfs_vops.c > --- kern/vfs_vops.c 21 Jun 2018 14:17:23 - 1.19 > +++ kern/vfs_vops.c 31 Jan 2019 21:04:43 - > @@ -336,7 +336,7 @@ int > VOP_FSYNC(struct vnode *vp, struct ucred *cred, int waitfor, > struct proc *p) > { > - int r; > + int r, s; > struct vop_fsync_args a; > a.a_vp = vp; > a.a_cred = cred; > @@ -351,6 +351,10 @@ VOP_FSYNC(struct vnode *vp, struct ucred > vp->v_inflight++; > r = (vp->v_op->vop_fsync)(); > vp->v_inflight--; > + s = splbio(); > + if (r == 0 && vp->v_bioflag & VBIOERROR) > + r = EIO; > + splx(s); > return r; > } > > Index: sys/vnode.h > === > RCS file: /home/cvs/src/sys/sys/vnode.h,v > retrieving revision 1.149 > diff -u -p -r1.149 vnode.h > --- sys/vnode.h 23 Dec 2018 10:46:51 - 1.149 > +++ sys/vnode.h 31 Jan 2019 20:52:37 - > @@ -149,6 +149,7 @@ struct vnode { > #define VBIOWAIT0x0001 /* waiting for output to complete */ > #define VBIOONSYNCLIST 0x0002 /* Vnode is on syncer worklist */ > #define VBIOONFREELIST 0x0004 /* Vnode is on a free list */ > +#define VBIOERROR0x0008 /* A write failed */ > > /* > * Vnode attributes. A field value of VNOVAL represents a field whose value
Re: athn(4) noisefloor calibration
On Thu, Jan 31, 2019 at 11:02:05PM +0100, Juan Francisco Cantero Hurtado wrote: > Works for me with an AR9271. I don't see differences. Same here on AR9287 in a busy network with lots of clients, fwiw. Resume/suspend, up/down, etc. all works as expected as without the diff.
Re: sysctl(2): KERN_CACHEPCT is capped at ~3GB
Alex Holst wrote: > Quoting Mark Kettenis (mark.kette...@xs4all.nl): > > An accurate description would be that the percentage is actually the > > percentage of "DMA-reachable" physical memory the buffer cache may > > use. The minimum percentage is 5% and the maximum is 90%. > > > > But documenting it like that needs an explanation of what > > "DMA-reachable" memory is. > > In practice, my amd64 systems with 32GB memory and > kern.bufcachepercent=90 has the cache capped around 3GB. > > This surprised me greatly, so I'm all ears if anyone else has ideas on > how we can document this. It would be better to fix the underlying issue. Coincidentally, I have a diff in progress, but I'm not quite done with it yet.
Re: sysctl(2): KERN_CACHEPCT is capped at ~3GB
Quoting Mark Kettenis (mark.kette...@xs4all.nl): > An accurate description would be that the percentage is actually the > percentage of "DMA-reachable" physical memory the buffer cache may > use. The minimum percentage is 5% and the maximum is 90%. > > But documenting it like that needs an explanation of what > "DMA-reachable" memory is. In practice, my amd64 systems with 32GB memory and kern.bufcachepercent=90 has the cache capped around 3GB. This surprised me greatly, so I'm all ears if anyone else has ideas on how we can document this.
Re: athn(4) noisefloor calibration
On Thu, Jan 31, 2019 at 04:30:30PM +0100, Stefan Sperling wrote: > On Thu, Jan 31, 2019 at 03:32:05PM +0100, Stefan Sperling wrote: > > This diff completes noisefloor calibration code in our athn(4) driver. > > Update default/min/max noisefloor values to those used by Linux. > > > > Tested on AR9280 on 2GHz and 5Ghz. Further tests are appreciated. > > jmc@ found out the hard way that my previous diff broke association > to other APs. Fixed in this version. Works for me with an AR9271. I don't see differences. -- Juan Francisco Cantero Hurtado http://juanfra.info
Re: fsync(2) and I/O errors
Ted Unangst wrote: > > Keeping a buf with an error in the delayed write list would probably have > > some > > serious consequences. When would we ever remove it? > > Thought about this some more. The best approach may be to set a flag in > the vnode that there was an IO error, and return that for any following fsync. > > Userland can retry by closing the file and opening again, which will clear the > flag. Annoying, but I don't what else to do. The kernel can't know what the > application wants to do. I believe that will be posix compliant as well. I think this works, but I don't have an easy way to test it. FreeBSD redirties the buf in this case, but I don't want to go down that path. There's a lot of code that seems to assume a buf that makes it here will be clean. Trying to fix up the buf to be dirty again seems very likely to triger some assertion or panic elsewhere. Instead, we note that the write failed and mark a flag in the vnode. Future calls to fsync will then return EIO when this flag is set. We clear the flag when the vnode is released. Index: kern/vfs_bio.c === RCS file: /home/cvs/src/sys/kern/vfs_bio.c,v retrieving revision 1.187 diff -u -p -r1.187 vfs_bio.c --- kern/vfs_bio.c 21 Nov 2018 16:14:43 - 1.187 +++ kern/vfs_bio.c 31 Jan 2019 21:19:36 - @@ -867,6 +867,11 @@ brelse(struct buf *bp) /* If it's not cacheable, or an error, mark it invalid. */ if (ISSET(bp->b_flags, (B_NOCACHE|B_ERROR))) SET(bp->b_flags, B_INVAL); + /* If it's a write error, also mark the vnode as damaged. */ + if (ISSET(bp->b_flags, B_ERROR) && !ISSET(bp->b_flags, B_READ)) { + if (bp->b_vp && bp->b_vp->v_type == VREG) + SET(bp->b_vp->v_bioflag, VBIOERROR); + } if (ISSET(bp->b_flags, B_INVAL)) { /* Index: kern/vfs_subr.c === RCS file: /home/cvs/src/sys/kern/vfs_subr.c,v retrieving revision 1.285 diff -u -p -r1.285 vfs_subr.c --- kern/vfs_subr.c 21 Jan 2019 18:09:21 - 1.285 +++ kern/vfs_subr.c 31 Jan 2019 21:09:22 - @@ -712,6 +712,7 @@ vputonfreelist(struct vnode *vp) #endif vp->v_bioflag |= VBIOONFREELIST; + vp->v_bioflag &= ~VBIOERROR; if (vp->v_holdcnt > 0) lst = _hold_list; Index: kern/vfs_vops.c === RCS file: /home/cvs/src/sys/kern/vfs_vops.c,v retrieving revision 1.19 diff -u -p -r1.19 vfs_vops.c --- kern/vfs_vops.c 21 Jun 2018 14:17:23 - 1.19 +++ kern/vfs_vops.c 31 Jan 2019 21:04:43 - @@ -336,7 +336,7 @@ int VOP_FSYNC(struct vnode *vp, struct ucred *cred, int waitfor, struct proc *p) { - int r; + int r, s; struct vop_fsync_args a; a.a_vp = vp; a.a_cred = cred; @@ -351,6 +351,10 @@ VOP_FSYNC(struct vnode *vp, struct ucred vp->v_inflight++; r = (vp->v_op->vop_fsync)(); vp->v_inflight--; + s = splbio(); + if (r == 0 && vp->v_bioflag & VBIOERROR) + r = EIO; + splx(s); return r; } Index: sys/vnode.h === RCS file: /home/cvs/src/sys/sys/vnode.h,v retrieving revision 1.149 diff -u -p -r1.149 vnode.h --- sys/vnode.h 23 Dec 2018 10:46:51 - 1.149 +++ sys/vnode.h 31 Jan 2019 20:52:37 - @@ -149,6 +149,7 @@ struct vnode { #defineVBIOWAIT0x0001 /* waiting for output to complete */ #define VBIOONSYNCLIST 0x0002 /* Vnode is on syncer worklist */ #define VBIOONFREELIST 0x0004 /* Vnode is on a free list */ +#define VBIOERROR 0x0008 /* A write failed */ /* * Vnode attributes. A field value of VNOVAL represents a field whose value
Re: archaic quotes in calendar
On Thu, Jan 31, 2019 at 01:30:18PM -0500, Ted Unangst wrote: > Anthony J. Bentley wrote: > > Jason McIntyre writes: > > > in the man page you have used Sq. that will make it mark up the same as > > > it already does: > > > > > > (`*') > > fwiw there was already an existing sq in the man page. I only fixed the one > using literal single quotes. > yes, fair enough. > > There's a difference: Ted uses a UTF-8 locale where Sq shows up as > > pretty Unicode quotes. Literally typing `' doesn't (not in the terminal, > > anyway). > > > > mandoc should render Sq as ' ' in ASCII mode. We fixed Dq the same way > > in both mandoc and groff a couple of years ago (`` '' to " "). > > I would be happy with this. > me too. ingo is on it. jmc
Re: archaic quotes in calendar
Anthony J. Bentley wrote: > Jason McIntyre writes: > > in the man page you have used Sq. that will make it mark up the same as > > it already does: > > > > (`*') fwiw there was already an existing sq in the man page. I only fixed the one using literal single quotes. > There's a difference: Ted uses a UTF-8 locale where Sq shows up as > pretty Unicode quotes. Literally typing `' doesn't (not in the terminal, > anyway). > > mandoc should render Sq as ' ' in ASCII mode. We fixed Dq the same way > in both mandoc and groff a couple of years ago (`` '' to " "). I would be happy with this.
Re: pfctl: make divert-packet port accept any port specification
On Wed, Jan 30, 2019 at 10:39:11PM +0100, Klemens Nanni wrote: > OK? OK bluhm@ > Index: parse.y > === > RCS file: /cvs/src/sbin/pfctl/parse.y,v > retrieving revision 1.689 > diff -u -p -r1.689 parse.y > --- parse.y 11 Jan 2019 01:56:54 - 1.689 > +++ parse.y 30 Jan 2019 21:20:32 - > @@ -1990,7 +1990,7 @@ filter_opt : USER uids { > } > filter_opts.divert.type = PF_DIVERT_REPLY; > } > - | DIVERTPACKET PORT number { > + | DIVERTPACKET PORT portplain { > if (filter_opts.divert.type != PF_DIVERT_NONE) { > yyerror("more than one divert option"); > YYERROR; > @@ -2003,11 +2003,11 @@ filter_opt: USER uids { > if (pf->reassemble & PF_REASS_ENABLED) > filter_opts.marker |= FOM_SCRUB_TCP; > > - if ($3 < 1 || $3 > 65535) { > - yyerror("invalid divert port"); > + filter_opts.divert.port = $3.a; > + if (!filter_opts.divert.port) { > + yyerror("invalid divert port: %u", ntohs($3.a)); > YYERROR; > } > - filter_opts.divert.port = htons($3); > } > | SCRUB '(' scrub_opts ')' { > filter_opts.nodf = $3.nodf; > @@ -5755,6 +5755,7 @@ parseport(char *port, struct range *r, i > r->t = PF_OP_RRG; > return (0); > } > + yyerror("port is invalid: %s", port); > return (-1); > } >
Re: athn(4) noisefloor calibration
On Thu, Jan 31, 2019 at 03:32:05PM +0100, Stefan Sperling wrote: > This diff completes noisefloor calibration code in our athn(4) driver. > Update default/min/max noisefloor values to those used by Linux. > > Tested on AR9280 on 2GHz and 5Ghz. Further tests are appreciated. jmc@ found out the hard way that my previous diff broke association to other APs. Fixed in this version. Index: ar5008.c === RCS file: /cvs/src/sys/dev/ic/ar5008.c,v retrieving revision 1.46 diff -u -p -r1.46 ar5008.c --- ar5008.c28 Nov 2017 04:35:39 - 1.46 +++ ar5008.c31 Jan 2019 15:17:00 - @@ -98,10 +98,11 @@ voidar5008_init_chains(struct athn_soft void ar5008_set_rxchains(struct athn_softc *); void ar5008_read_noisefloor(struct athn_softc *, int16_t *, int16_t *); void ar5008_write_noisefloor(struct athn_softc *, int16_t *, int16_t *); -void ar5008_get_noisefloor(struct athn_softc *, struct ieee80211_channel *); +intar5008_get_noisefloor(struct athn_softc *); +void ar5008_apply_noisefloor(struct athn_softc *); void ar5008_bb_load_noisefloor(struct athn_softc *); -void ar5008_noisefloor_calib(struct athn_softc *); void ar5008_do_noisefloor_calib(struct athn_softc *); +void ar5008_init_noisefloor_calib(struct athn_softc *); void ar5008_do_calib(struct athn_softc *); void ar5008_next_calib(struct athn_softc *); void ar5008_calib_iq(struct athn_softc *); @@ -176,6 +177,9 @@ ar5008_attach(struct athn_softc *sc) ops->disable_phy = ar5008_disable_phy; ops->set_rxchains = ar5008_set_rxchains; ops->noisefloor_calib = ar5008_do_noisefloor_calib; + ops->init_noisefloor_calib = ar5008_init_noisefloor_calib; + ops->get_noisefloor = ar5008_get_noisefloor; + ops->apply_noisefloor = ar5008_apply_noisefloor; ops->do_calib = ar5008_do_calib; ops->next_calib = ar5008_next_calib; ops->hw_init = ar5008_hw_init; @@ -1876,15 +1880,15 @@ ar5008_write_noisefloor(struct athn_soft AR_WRITE_BARRIER(sc); } -void -ar5008_get_noisefloor(struct athn_softc *sc, struct ieee80211_channel *c) +int +ar5008_get_noisefloor(struct athn_softc *sc) { int16_t nf[AR_MAX_CHAINS], nf_ext[AR_MAX_CHAINS]; int i; if (AR_READ(sc, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF) { /* Noisefloor calibration not finished. */ - return; + return 0; } /* Noisefloor calibration is finished. */ ar5008_read_noisefloor(sc, nf, nf_ext); @@ -1896,6 +1900,7 @@ ar5008_get_noisefloor(struct athn_softc } if (++sc->nf_hist_cur >= ATHN_NF_CAL_HIST_MAX) sc->nf_hist_cur = 0; + return 1; } void @@ -1926,14 +1931,41 @@ ar5008_bb_load_noisefloor(struct athn_so return; } - /* Restore noisefloor values to initial (max) values. */ + /* +* Restore noisefloor values to initial (max) values. These will +* be used as initial values during the next NF calibration. +*/ for (i = 0; i < AR_MAX_CHAINS; i++) nf[i] = nf_ext[i] = AR_DEFAULT_NOISE_FLOOR; ar5008_write_noisefloor(sc, nf, nf_ext); } void -ar5008_noisefloor_calib(struct athn_softc *sc) +ar5008_apply_noisefloor(struct athn_softc *sc) +{ + uint32_t agc_nfcal; + + agc_nfcal = AR_READ(sc, AR_PHY_AGC_CONTROL) & + (AR_PHY_AGC_CONTROL_NF | AR_PHY_AGC_CONTROL_ENABLE_NF | + AR_PHY_AGC_CONTROL_NO_UPDATE_NF); + + if (agc_nfcal & AR_PHY_AGC_CONTROL_NF) { + /* Pause running NF calibration while values are updated. */ + AR_CLRBITS(sc, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF); + AR_WRITE_BARRIER(sc); + } + + ar5008_bb_load_noisefloor(sc); + + if (agc_nfcal & AR_PHY_AGC_CONTROL_NF) { + /* Restart interrupted NF calibration. */ + AR_SETBITS(sc, AR_PHY_AGC_CONTROL, agc_nfcal); + AR_WRITE_BARRIER(sc); + } +} + +void +ar5008_do_noisefloor_calib(struct athn_softc *sc) { AR_SETBITS(sc, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_ENABLE_NF); AR_SETBITS(sc, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NO_UPDATE_NF); @@ -1942,7 +1974,7 @@ ar5008_noisefloor_calib(struct athn_soft } void -ar5008_do_noisefloor_calib(struct athn_softc *sc) +ar5008_init_noisefloor_calib(struct athn_softc *sc) { AR_SETBITS(sc, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF); AR_WRITE_BARRIER(sc); Index: ar5416.c === RCS file: /cvs/src/sys/dev/ic/ar5416.c,v retrieving revision 1.20 diff -u -p -r1.20 ar5416.c --- ar5416.c12 Jan 2017 16:32:28 - 1.20 +++ ar5416.c31 Jan 2019 12:13:37 - @@ -112,7 +112,6 @@ ar5416_attach(struct athn_softc *sc) { sc->eep_base = AR5416_EEP_START_LOC; sc->eep_size = sizeof(struct
Re: pfctl: make divert-packet port accept any port specification
On Wed, Jan 30, 2019 at 10:39:11PM +0100, Klemens Nanni wrote: > Contrary to other rules accepting a single port, this one only works > with unquoted numerical values. Quoted numbers are accepted, I mixed it up when writing this mail. > - | DIVERTPACKET PORT number { > + | DIVERTPACKET PORT portplain { NB: This removes one of the two `number' users which I plan to remove. It uses the hand-rolled atoul() function which I want to remove from the parser code in favour of simpler and stricter strtonum(3) calls.
pfctl: make divert-packet port accept any port specification
Contrary to other rules accepting a single port, this one only works with unquoted numerical values. Fix this by simply using the proper grammar; the impact is limited to `divert-packet port $port' and easy to test: $ printf 'pass divert-packet port %s\n' 80 '"443"' ftp '"domain"' | > pfctl -vnf- stdin:3: ftp is not a number stdin:4: domain is not a number $ printf 'pass divert-packet port %s\n' 80 '"443"' ftp '"domain"' | > ./obj/pfctl -vnf- pass all flags S/SA scrub (reassemble tcp) divert-packet port 80 pass all flags S/SA scrub (reassemble tcp) divert-packet port 443 pass all flags S/SA scrub (reassemble tcp) divert-packet port 21 pass all flags S/SA scrub (reassemble tcp) divert-packet port 53 Port ranges are not accepted, but an error message on a range without start is missing in general, so add it while here: $ printf 'pass divert-to ::1 port :80\n' | pfctl -vnf- $ printf 'pass divert-to ::1 port :80\n' | ./obj/pfctl -vnf- stdin:1: port is invalid: :80 OK? Index: parse.y === RCS file: /cvs/src/sbin/pfctl/parse.y,v retrieving revision 1.689 diff -u -p -r1.689 parse.y --- parse.y 11 Jan 2019 01:56:54 - 1.689 +++ parse.y 30 Jan 2019 21:20:32 - @@ -1990,7 +1990,7 @@ filter_opt: USER uids { } filter_opts.divert.type = PF_DIVERT_REPLY; } - | DIVERTPACKET PORT number { + | DIVERTPACKET PORT portplain { if (filter_opts.divert.type != PF_DIVERT_NONE) { yyerror("more than one divert option"); YYERROR; @@ -2003,11 +2003,11 @@ filter_opt : USER uids { if (pf->reassemble & PF_REASS_ENABLED) filter_opts.marker |= FOM_SCRUB_TCP; - if ($3 < 1 || $3 > 65535) { - yyerror("invalid divert port"); + filter_opts.divert.port = $3.a; + if (!filter_opts.divert.port) { + yyerror("invalid divert port: %u", ntohs($3.a)); YYERROR; } - filter_opts.divert.port = htons($3); } | SCRUB '(' scrub_opts ')' { filter_opts.nodf = $3.nodf; @@ -5755,6 +5755,7 @@ parseport(char *port, struct range *r, i r->t = PF_OP_RRG; return (0); } + yyerror("port is invalid: %s", port); return (-1); }
athn(4) noisefloor calibration
This diff completes noisefloor calibration code in our athn(4) driver. Update default/min/max noisefloor values to those used by Linux. Tested on AR9280 on 2GHz and 5Ghz. Further tests are appreciated. Index: ar5008.c === RCS file: /cvs/src/sys/dev/ic/ar5008.c,v retrieving revision 1.46 diff -u -p -r1.46 ar5008.c --- ar5008.c28 Nov 2017 04:35:39 - 1.46 +++ ar5008.c31 Jan 2019 13:39:55 - @@ -98,9 +98,9 @@ void ar5008_init_chains(struct athn_soft void ar5008_set_rxchains(struct athn_softc *); void ar5008_read_noisefloor(struct athn_softc *, int16_t *, int16_t *); void ar5008_write_noisefloor(struct athn_softc *, int16_t *, int16_t *); -void ar5008_get_noisefloor(struct athn_softc *, struct ieee80211_channel *); +intar5008_get_noisefloor(struct athn_softc *); +void ar5008_apply_noisefloor(struct athn_softc *); void ar5008_bb_load_noisefloor(struct athn_softc *); -void ar5008_noisefloor_calib(struct athn_softc *); void ar5008_do_noisefloor_calib(struct athn_softc *); void ar5008_do_calib(struct athn_softc *); void ar5008_next_calib(struct athn_softc *); @@ -176,6 +176,8 @@ ar5008_attach(struct athn_softc *sc) ops->disable_phy = ar5008_disable_phy; ops->set_rxchains = ar5008_set_rxchains; ops->noisefloor_calib = ar5008_do_noisefloor_calib; + ops->get_noisefloor = ar5008_get_noisefloor; + ops->apply_noisefloor = ar5008_apply_noisefloor; ops->do_calib = ar5008_do_calib; ops->next_calib = ar5008_next_calib; ops->hw_init = ar5008_hw_init; @@ -1876,15 +1878,15 @@ ar5008_write_noisefloor(struct athn_soft AR_WRITE_BARRIER(sc); } -void -ar5008_get_noisefloor(struct athn_softc *sc, struct ieee80211_channel *c) +int +ar5008_get_noisefloor(struct athn_softc *sc) { int16_t nf[AR_MAX_CHAINS], nf_ext[AR_MAX_CHAINS]; int i; if (AR_READ(sc, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF) { /* Noisefloor calibration not finished. */ - return; + return 0; } /* Noisefloor calibration is finished. */ ar5008_read_noisefloor(sc, nf, nf_ext); @@ -1896,6 +1898,7 @@ ar5008_get_noisefloor(struct athn_softc } if (++sc->nf_hist_cur >= ATHN_NF_CAL_HIST_MAX) sc->nf_hist_cur = 0; + return 1; } void @@ -1926,24 +1929,44 @@ ar5008_bb_load_noisefloor(struct athn_so return; } - /* Restore noisefloor values to initial (max) values. */ + /* +* Restore noisefloor values to initial (max) values. These will +* be used as initial values during the next NF calibration. +*/ for (i = 0; i < AR_MAX_CHAINS; i++) nf[i] = nf_ext[i] = AR_DEFAULT_NOISE_FLOOR; ar5008_write_noisefloor(sc, nf, nf_ext); } void -ar5008_noisefloor_calib(struct athn_softc *sc) +ar5008_apply_noisefloor(struct athn_softc *sc) { - AR_SETBITS(sc, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_ENABLE_NF); - AR_SETBITS(sc, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NO_UPDATE_NF); - AR_SETBITS(sc, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF); - AR_WRITE_BARRIER(sc); + uint32_t agc_nfcal; + + agc_nfcal = AR_READ(sc, AR_PHY_AGC_CONTROL) & + (AR_PHY_AGC_CONTROL_NF | AR_PHY_AGC_CONTROL_ENABLE_NF | + AR_PHY_AGC_CONTROL_NO_UPDATE_NF); + + if (agc_nfcal & AR_PHY_AGC_CONTROL_NF) { + /* Pause running NF calibration while values are updated. */ + AR_CLRBITS(sc, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF); + AR_WRITE_BARRIER(sc); + } + + ar5008_bb_load_noisefloor(sc); + + if (agc_nfcal & AR_PHY_AGC_CONTROL_NF) { + /* Restart interrupted NF calibration. */ + AR_SETBITS(sc, AR_PHY_AGC_CONTROL, agc_nfcal); + AR_WRITE_BARRIER(sc); + } } void ar5008_do_noisefloor_calib(struct athn_softc *sc) { + AR_SETBITS(sc, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_ENABLE_NF); + AR_SETBITS(sc, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NO_UPDATE_NF); AR_SETBITS(sc, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF); AR_WRITE_BARRIER(sc); } Index: ar5416.c === RCS file: /cvs/src/sys/dev/ic/ar5416.c,v retrieving revision 1.20 diff -u -p -r1.20 ar5416.c --- ar5416.c12 Jan 2017 16:32:28 - 1.20 +++ ar5416.c31 Jan 2019 12:13:37 - @@ -112,7 +112,6 @@ ar5416_attach(struct athn_softc *sc) { sc->eep_base = AR5416_EEP_START_LOC; sc->eep_size = sizeof(struct ar5416_eeprom); - sc->def_nf = AR5416_PHY_CCA_MAX_GOOD_VALUE; sc->ngpiopins = 14; sc->led_pin = 1; sc->workaround = AR5416_WA_DEFAULT; @@ -123,6 +122,10 @@ ar5416_attach(struct athn_softc *sc) sc->ops.set_synth = ar5416_set_synth;
Re: grep: convert fgetln to getline
On Thu, Jan 31, 2019 at 03:10:53PM +0200, Lauri Tirkkonen wrote: > On Wed, Jan 30 2019 20:32:50 -0500, Ted Unangst wrote: > > Thanks for digging into this. I went ahead and committed your diff. > > Thanks for committing it. > > You know, having seen fgetln's allocation strategy and its usage of the > stdio internals, I couldn't help but wonder if it's something that could > be eventually removed entirely. It's used in a bunch of places in-tree > for sure, but not too many to convert, I think; and I've already done a > few... > > It's not exactly a serious suggestion at this point; I realize there > probably is third-party software too that uses this function (Linuxes > provide compat for it in libbsd; there must be a reason for that). I'm > speaking as someone who's been removing a bunch of crap from that other > OS I mentioned, so that's my reason for this line of thinking slash > pipe-dreaming ;) > quite amazing to watch tedu talk to another tedu :-| -- Gilles Chehade @poolpOrg https://www.poolp.org tip me: https://paypal.me/poolpOrg
Re: grep: convert fgetln to getline
On Wed, Jan 30 2019 20:32:50 -0500, Ted Unangst wrote: > Thanks for digging into this. I went ahead and committed your diff. Thanks for committing it. You know, having seen fgetln's allocation strategy and its usage of the stdio internals, I couldn't help but wonder if it's something that could be eventually removed entirely. It's used in a bunch of places in-tree for sure, but not too many to convert, I think; and I've already done a few... It's not exactly a serious suggestion at this point; I realize there probably is third-party software too that uses this function (Linuxes provide compat for it in libbsd; there must be a reason for that). I'm speaking as someone who's been removing a bunch of crap from that other OS I mentioned, so that's my reason for this line of thinking slash pipe-dreaming ;) -- Lauri Tirkkonen | lotheac @ IRCnet
Re: arm64: softraid boot
> Date: Wed, 30 Jan 2019 22:31:31 +0100 > From: Patrick Wildt > > Hi, > > to boot a pinebook with softraid crypto there are three parts that need > to be implemented, which this diff hopefully does well enough. > > First, our EFI bootloader so far only supports one disk, so we need to > extend this so we can see all connected block devices. The second part > is adding the softraid code, which probes for softraid partitions on the > block devices and "spawns" its own block device. At last, we need to > push the softraid uuid and key up to the kernel. > > Pushing the informaton to the kernel is the easiest part. We can add > another openbsd-specific property in the device tree which we read out > early on, so that we can zero the space in the device tree so it can not > be read by anyone else. > > For the other part there's a bit more to do. Very early on efiboot > looks for the boot device. While doing that, we create a list of block > devices. While there, already try to read the disklabel because after > this the softraid probing needs to know the partition table. > > We then call srprobe() which will go over the disklist to look for a > disk that contains RAID volumes, but calling the disk's diskio and > strategy function to read from the device. This creates the sr_volumes > list of softraid volumes. The MI boot code will then look for the boot > device name by calling devboot(). If we don't have the device path for > the boot device, it's a PXE boot. Otherwise we will find it in either > the disklist or sr_volumes list. > > The next part is the MI code opening the device, looking for a file- > system. The boot device name now is e.g. sr0a, which will then be > looked up in the devsw[] array. From there it's straight forward. > Softraid maps the unit number to a volume, the volume already has a > pointer to the diskinfo structure from the actual device and then > calls the IO functions of that device. > > softraid_arm64.[ch] is copied from amd64 and adjusted a little bit > for arm64, including adding the small devsw[] abstraction. > > With this I can successfully boot from softraid crypto on bluhm@'s > Pinebook. > > Feedback? Apart from the property names, this looks good to me. So feel free to go ahead once you changed those properties. > diff --git sys/arch/arm64/arm64/machdep.c sys/arch/arm64/arm64/machdep.c > index 45f6451066a..03bc8464f3a 100644 > --- sys/arch/arm64/arm64/machdep.c > +++ sys/arch/arm64/arm64/machdep.c > @@ -30,6 +30,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -49,6 +50,11 @@ > > #include > > +#include "softraid.h" > +#if NSOFTRAID > 0 > +#include > +#endif > + > char *boot_args = NULL; > char *boot_file = ""; > > @@ -826,6 +832,22 @@ initarm(struct arm64_bootparams *abp) > bootmac = lladdr; > } > > + len = fdt_node_property(node, "openbsd,bootsr-uuid", ); > +#if NSOFTRAID > 0 > + if (len == sizeof(sr_bootuuid)) > + memcpy(_bootuuid, prop, sizeof(sr_bootuuid)); > +#endif > + if (len > 0) > + explicit_bzero(prop, len); > + > + len = fdt_node_property(node, "openbsd,bootsr-maskkey", ); > +#if NSOFTRAID > 0 > + if (len == sizeof(sr_bootkey)) > + memcpy(_bootkey, prop, sizeof(sr_bootkey)); > +#endif > + if (len > 0) > + explicit_bzero(prop, len); > + > len = fdt_node_property(node, "openbsd,uefi-mmap-start", ); > if (len == sizeof(mmap_start)) > mmap_start = bemtoh64((uint64_t *)prop); > diff --git sys/arch/arm64/stand/efiboot/Makefile > sys/arch/arm64/stand/efiboot/Makefile > index 36eecd6ca9c..d0ec46662ee 100644 > --- sys/arch/arm64/stand/efiboot/Makefile > +++ sys/arch/arm64/stand/efiboot/Makefile > @@ -10,6 +10,7 @@ INSTALL_STRIP= > BINDIR= /usr/mdec > SRCS=start.S self_reloc.c efiboot.c conf.c exec.c efiacpi.c > SRCS+= efidev.c efipxe.c efirng.c fdt.c dt_blob.S > +SRCS+= softraid_arm64.c > > S= ${.CURDIR}/../../../.. > EFIDIR= ${S}/stand/efi > @@ -31,6 +32,8 @@ SRCS+= close.c closeall.c cons.c cread.c dev.c > disklabel.c dkcksum.c fstat.c \ > SRCS+= loadfile.c > SRCS+= ufs.c > SRCS+= arp.c ether.c globals.c in_cksum.c net.c netif.c netudp.c tftp.c > +SRCS+= aes_xts.c bcrypt_pbkdf.c blowfish.c explicit_bzero.c > hmac_sha1.c \ > + pkcs5_pbkdf2.c rijndael.c sha1.c sha2.c softraid.c > > .PATH: ${S}/lib/libkern/arch/arm64 ${S}/lib/libkern > SRCS+= divdi3.c moddi3.c qdivrem.c strlcpy.c strlen.c > diff --git sys/arch/arm64/stand/efiboot/conf.c > sys/arch/arm64/stand/efiboot/conf.c > index 5e8fd5fa0e7..be301b4a9d4 100644 > --- sys/arch/arm64/stand/efiboot/conf.c > +++ sys/arch/arm64/stand/efiboot/conf.c > @@ -27,14 +27,23 @@ >
Re: fork rt_ifa_{add,del} for mpls local input routes
On Wed, Jan 30, 2019 at 11:48:10AM +1000, David Gwynne wrote: > mpls uses AF_MPLS routes with RTF_LOCAL set on them to know which tags > are used as input for the mpe and mpw interfaces. setting this up > currently goes through rt_ifa_add, but that has a couple of features > that are undesirable for mpls. > > Firstly, rt_ifa_add unconditionally sets RTF_MPATH on the routes it > adds, which means multiple mpe and mpw interfaces can "own" the same > input tag. mpe tries to work around this by maintaining a global list of > mpe interfaces, and iterates over them when a new label is added. That's > ok (sort of) for mpe, but it doesnt take the tags used by mpw into > account. > > Secondly, I'd like to start pulling apart the restriction on the use of > mpls only in rdomain 1. rt_ifa_add doesn't help this situation because > it assumes that we're adding a route inside the rdomain the interface is > in, rather than the one it tunnels in. Changing this assumption means > forking rt_ifa_add, and oh look, that's what I've started here. > > So, if I have the following: > > mpe2: flags=51 rdomain 2 mtu 1500 > index 6 priority 0 llprio 3 > mpls label 1000 > groups: mpe > inet 192.168.0.25 --> 0.0.0.0 netmask 0x > mpw0: flags=8843 mtu 1500 > lladdr fe:e1:ba:d0:93:1a > index 7 priority 0 llprio 3 > encapsulation-type ethernet, control-word > mpls label: local 16 remote 16 > neighbor: 192.168.0.27 > groups: mpw > inet 100.64.100.2 netmask 0xff00 broadcast 100.64.100.255 > > The following now does what's expected: > > dlg@cpe0 sys$ sudo ifconfig mpe3 create > dlg@cpe0 sys$ sudo ifconfig mpe3 mplslabel 16 > ifconfig: SIOCSETLABEL: File exists > > ok? Looks OK. I think mpls_ifa_add/del should send a route message but that can be added later. Having routing table changes that are not reflected on the route socket are a big no no. Guess you will remove the MPLS ifdef in rt_ifa_add/del in a 2nd step since those should no longer be needed. > Index: net/if_mpe.c > === > RCS file: /cvs/src/sys/net/if_mpe.c,v > retrieving revision 1.76 > diff -u -p -r1.76 if_mpe.c > --- net/if_mpe.c 30 Jan 2019 01:09:36 - 1.76 > +++ net/if_mpe.c 30 Jan 2019 01:40:47 - > @@ -132,10 +132,8 @@ mpe_clone_destroy(struct ifnet *ifp) > > LIST_REMOVE(sc, sc_list); > > - if (sc->sc_smpls.smpls_label) { > - rt_ifa_del(>sc_ifa, RTF_MPLS, > - smplstosa(>sc_smpls)); > - } > + if (sc->sc_smpls.smpls_label) > + mpls_ifa_del(>sc_ifa, >sc_smpls); > > if_detach(ifp); > free(sc, M_DEVBUF, sizeof *sc); > @@ -331,13 +329,11 @@ mpe_ioctl(struct ifnet *ifp, u_long cmd, > ifm = ifp->if_softc; > if (ifm->sc_smpls.smpls_label) { > /* remove old MPLS route */ > - rt_ifa_del(>sc_ifa, RTF_MPLS, > - smplstosa(>sc_smpls)); > + mpls_ifa_del(>sc_ifa, >sc_smpls); > } > /* add new MPLS route */ > ifm->sc_smpls.smpls_label = shim.shim_label; > - error = rt_ifa_add(>sc_ifa, RTF_MPLS|RTF_LOCAL, > - smplstosa(>sc_smpls)); > + error = mpls_ifa_add(>sc_ifa, >sc_smpls); > if (error) { > ifm->sc_smpls.smpls_label = 0; > break; > @@ -348,10 +344,8 @@ mpe_ioctl(struct ifnet *ifp, u_long cmd, > /* XXX does not make sense, the MPLS route is on rtable 0 */ > ifm = ifp->if_softc; > if (ifr->ifr_rdomainid != ifp->if_rdomain) { > - if (ifm->sc_smpls.smpls_label) { > - rt_ifa_add(>sc_ifa, RTF_MPLS, > - smplstosa(>sc_smpls)); > - } > + if (ifm->sc_smpls.smpls_label) > + mpls_ifa_add(>sc_ifa, >sc_smpls); > } > /* return with ENOTTY so that the parent handler finishes */ > return (ENOTTY); > Index: net/if_mpw.c > === > RCS file: /cvs/src/sys/net/if_mpw.c,v > retrieving revision 1.31 > diff -u -p -r1.31 if_mpw.c > --- net/if_mpw.c 30 Jan 2019 01:09:36 - 1.31 > +++ net/if_mpw.c 30 Jan 2019 01:40:47 - > @@ -116,8 +116,7 @@ mpw_clone_destroy(struct ifnet *ifp) > ifp->if_flags &= ~IFF_RUNNING; > > if (sc->sc_smpls.smpls_label) { > - rt_ifa_del(>sc_ifa, RTF_MPLS, > - smplstosa(>sc_smpls)); > + mpls_ifa_del(>sc_ifa, >sc_smpls); > } > > ether_ifdetach(ifp); > @@ -162,9 +161,8 @@ mpw_ioctl(struct ifnet *ifp, u_long cmd, > /* Teardown all configuration if got no nexthop */ > sin =
Re: make.1: add missing dependency to example
On Wed, Jan 30, 2019 at 01:56:04PM -0600, Scott Cheloha wrote: > We need to tell ${CC} about b.o explicitly. > > ok? > > -Scott > > P.S. How was BSD $> or GNU $^ or an equivalent *not* standardized as > an automatic variable? I get that it isn't a silver bullet, but in > the relatively common "let's take several and make a " case it > is extremely useful and totally missing from the portable syntax. Well, it's not standardized. As far as adding extensions to bsd tools, it's always a bit annoying, because we then foster making things *less* portable to other environments that don't have it. So generally, it's more a question of knowing when it's wide-spread enough (e.g., sed -i). make is *very* sneaky in that regard... :( In general, the portable way to do things properly is that as soon as you have two objects files, you got thru a variable, which is good practice anyway. > Index: make.1 > === > RCS file: /cvs/src/usr.bin/make/make.1,v > retrieving revision 1.127 > diff -u -p -r1.127 make.1 > --- make.14 Jul 2018 14:11:49 - 1.127 > +++ make.130 Jan 2019 19:45:15 - > @@ -464,7 +464,7 @@ from sources a.c and b.c, with header fi > ${CC} ${CFLAGS} -c $< > > prog: a.o b.o > - ${CC} ${CFLAGS} -o $@ a.o > + ${CC} ${CFLAGS} -o $@ a.o b.o > > a.o b.o: a.h > Yep, okay