Re: usbdevs: logitech: cleanup and new ids
On 1/23/17, Jonathan Graywrote: > On Mon, Jan 23, 2017 at 01:56:20AM -0500, James Hastings wrote: >> Hello @tech >> >> Recently found a pile of old Logitech webcams to test with uvideo(4). >> s/QUICKCAM/QKCAM. >> shorten device strings. >> Add many new Logitech device ids. >> >> dev/usb/usbdevs >> dev/usb/uaudio.c >> dev/usb/uvideo.c > > USB devices normally have their own strings. usbdevs entries are added > for non usb-class drivers and if there is a common device without a > string. Do any of the devices not have their own strings? > One example: uaudio0 at uhub2 port 1 configuration 1 interface 1 "Logitech product 0x08dd" rev 1.10/1.00 addr 2 uaudio0: audio rev 1.00, 3 mixer controls audio1 at uaudio0 ugen0 at uhub2 port 1 configuration 1 "Logitech product 0x08dd" rev 1.10/1.00 addr 2 lsusb -v: Bus 002 Device 002: ID 046d:08dd Logitech, Inc. QuickCam for Notebooks Device Descriptor: bLength18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0x046d Logitech, Inc. idProduct 0x08dd QuickCam for Notebooks bcdDevice1.00 iManufacturer 0 iProduct0 iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 336 bNumInterfaces 3 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber0 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass255 Vendor Specific Subclass bInterfaceProtocol255 Vendor Specific Protocol iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes1 Transfer TypeIsochronous Synch Type None Usage Type Data wMaxPacketSize 0x 1x 0 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes3 Transfer TypeInterrupt Synch Type None Usage Type Data wMaxPacketSize 0x0008 1x 8 bytes bInterval 10 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber0 bAlternateSetting 1 bNumEndpoints 2 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass255 Vendor Specific Subclass bInterfaceProtocol255 Vendor Specific Protocol iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes1 Transfer TypeIsochronous Synch Type None Usage Type Data wMaxPacketSize 0x0080 1x 128 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes3 Transfer TypeInterrupt Synch Type None Usage Type Data wMaxPacketSize 0x0008 1x 8 bytes bInterval 10 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber0 bAlternateSetting 2 bNumEndpoints 2 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass255 Vendor Specific Subclass bInterfaceProtocol255 Vendor Specific Protocol iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes1 Transfer TypeIsochronous Synch Type None Usage Type Data wMaxPacketSize 0x00c0 1x 192 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes3 Transfer TypeInterrupt Synch Type
Re: usbdevs: logitech: cleanup and new ids
On Mon, Jan 23, 2017 at 01:56:20AM -0500, James Hastings wrote: > Hello @tech > > Recently found a pile of old Logitech webcams to test with uvideo(4). > s/QUICKCAM/QKCAM. > shorten device strings. > Add many new Logitech device ids. > > dev/usb/usbdevs > dev/usb/uaudio.c > dev/usb/uvideo.c USB devices normally have their own strings. usbdevs entries are added for non usb-class drivers and if there is a common device without a string. Do any of the devices not have their own strings?
usbdevs: logitech: cleanup and new ids
Hello @tech Recently found a pile of old Logitech webcams to test with uvideo(4). s/QUICKCAM/QKCAM. shorten device strings. Add many new Logitech device ids. dev/usb/usbdevs dev/usb/uaudio.c dev/usb/uvideo.c Index: dev/usb/uaudio.c === RCS file: /cvs/src/sys/dev/usb/uaudio.c,v retrieving revision 1.122 diff -u -p -r1.122 uaudio.c --- dev/usb/uaudio.c3 Jan 2017 06:45:58 - 1.122 +++ dev/usb/uaudio.c22 Jan 2017 22:35:43 - @@ -214,13 +214,13 @@ struct uaudio_devs { UAUDIO_FLAG_DEPENDENT }, { { USB_VENDOR_DALLAS, USB_PRODUCT_DALLAS_J6502 }, UAUDIO_FLAG_NO_XU | UAUDIO_FLAG_BAD_ADC }, - { { USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_QUICKCAMNBDLX }, + { { USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_QKCAMNBDX_1 }, UAUDIO_FLAG_BAD_AUDIO }, - { { USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_QUICKCAMPRONB }, + { { USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_QKCAMNBPRO_4 }, UAUDIO_FLAG_BAD_AUDIO }, - { { USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_QUICKCAMPRO4K }, + { { USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_QKCAMPRO4K }, UAUDIO_FLAG_BAD_AUDIO }, - { { USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_QUICKCAMZOOM }, + { { USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_QKCAMZOOM }, UAUDIO_FLAG_BAD_AUDIO }, { { USB_VENDOR_TELEX, USB_PRODUCT_TELEX_MIC1 }, UAUDIO_FLAG_NO_FRAC } Index: dev/usb/usbdevs === RCS file: /cvs/src/sys/dev/usb/usbdevs,v retrieving revision 1.673 diff -u -p -r1.673 usbdevs --- dev/usb/usbdevs 15 Dec 2016 15:42:05 - 1.673 +++ dev/usb/usbdevs 22 Jan 2017 22:35:47 - @@ -2553,37 +2553,85 @@ product LOGITEC LANW300NU2S 0x0169 LAN-W product LOGITECH M2452 0x0203 M2452 keyboard product LOGITECH M4848 0x0301 M4848 mouse product LOGITECH PAGESCAN 0x040f PageScan -product LOGITECH QUICKCAMWEB 0x0801 QuickCam Web -product LOGITECH WEBCAMC2000x0802 Webcam C200 -product LOGITECH WEBCAMC5000x0807 Webcam C500 -product LOGITECH QUICKCAMPRO 0x0810 QuickCam Pro -product LOGITECH WEBCAMC3100x081b Webcam C310 +product LOGITECH QKCAMWEB_10x0801 QuickCam Web +product LOGITECH WEBCAM200 0x0802 Webcam 200 +product LOGITECH WEBCAM250 0x0804 Webcam 250 +product LOGITECH WEBCAM300 0x0805 Webcam 300 +product LOGITECH WEBCAM500 0x0807 Webcam 500 +product LOGITECH WEBCAM600 0x0808 Webcam 600 +product LOGITECH WEBCAMPRO9K 0x0809 Webcam Pro 9000 +product LOGITECH WEBCAM905 0x080a Webcam 905 +product LOGITECH WEBCAM120 0x080f Webcam 120 +product LOGITECH QKCAMPRO_10x0810 QuickCam Pro +product LOGITECH WEBCAMC1000x0817 Webcam C100 +product LOGITECH WEBCAMC2100x0819 Webcam C210 +product LOGITECH WEBCAMC2600x081a Webcam C260 +product LOGITECH HDCAMC310 0x081b HD Webcam C310 +product LOGITECH HDCAMC510 0x081d HD Webcam C510 +product LOGITECH QKCAMVC 0x0820 QuickCam VC product LOGITECH HDPROC910 0x0821 HD Pro Webcam C910 -product LOGITECH QUICKCAMEXP 0x0840 QuickCam Express -product LOGITECH QUICKCAM 0x0850 QuickCam -product LOGITECH QUICKCAMNBDLX 0x08a9 QuickCam Notebook Deluxe -product LOGITECH QUICKCAMPRO3K 0x08b0 QuickCam Pro 3000 -product LOGITECH QUICKCAMNBPRO_1 0x08b1QuickCam Notebook Pro -product LOGITECH QUICKCAMPRO4K 0x08b2 QuickCam Pro 4000 -product LOGITECH QUICKCAMZOOM 0x08b3 QuickCam Zoom -product LOGITECH QUICKCAMFUSION_1 0x08c1 QuickCam Fusion -product LOGITECH QUICKCAMORBITMP_1 0x08c2 QuickCam Orbit MP -product LOGITECH QUICKCAMNBPRO 0x08c3 QuickCam Notebook Pro -product LOGITECH QUICKCAMPRO5K_1 0x08c5QuickCam Pro 5000 -product LOGITECH QUICKCAMOEM_1 0x08c6 QuickCam OEM -product LOGITECH QUICKCAMOEM_2 0x08c7 QuickCam OEM -product LOGITECH QUICKCAMULTVIS0x08c9 QuickCam Ultra Vision -product LOGITECH QUICKCAMFUSION_2 0x08ca QuickCam Fusion -product LOGITECH QUICKCAMNBPRO_2 0x08cbQuickCam Notebook Pro -product LOGITECH QUICKCAMORBITMP_2 0x08cc QuickCam Orbit MP -product LOGITECH QUICKCAMPRO5K_2 0x08ceQuickCam Pro 5000 -product LOGITECH QUICKCAMPRO9K 0x0990 QuickCam Pro 9000 -product LOGITECH QUICKCAMPRONB 0x0991 QuickCam Pro Notebook -product LOGITECH QUICKCAMCOMMDLX 0x0992QuickCam Communicate Deluxe -product LOGITECH QUICKCAMORBITAF 0x0994 QuickCam Orbit AF -product LOGITECH QUICKCAMCOMMMP0x09a1 QuickCam Communicate MP -product LOGITECH QUICKCAME3500P0x09a4 QuickCam E 3500 Plus -product LOGITECH QUICKCAMDLXNB 0x09c1 QuickCam Deluxe Notebook +product LOGITECH HDCAMB910 0x0823 HD Webcam B910 +product LOGITECH WEBCAMC1600x0824 Webcam C160 +product LOGITECH WEBCAMC2700x0825 Webcam C270 +product LOGITECH HDCAMC525 0x0826 HD Webcam C525 +product LOGITECH
Re: add support for multiple transmit queues on interfaces
hrvoje popovski hit a problem where the kernel would panic under load. i mistakenly called an interfaces qstart routine directly from if_enqueue rather than via the ifq serializer. this meant that txeof routines on network cards calling ifq_restart would cause the start routine to run concurrently, therefore causing corruption of the ring state. this diff fixes that. On Mon, Jan 23, 2017 at 01:09:57PM +1000, David Gwynne wrote: > the short explanation is that this lets interfaces allocate multiple > ifq structures that can be mapped to their transmit rings. the > mechanism for this is a driver calling if_attach_queues() after > theyve called if_attach(). > > the long version is that this has if_enqueue access an array of > ifqueues on the interface instead of if_snd directly. the ifq is > picked by asking the queue discipline (priq or hfsc) to map an mbuf > to a slot in the if_ifqs array. > > to notify the driver that a particular queue needs to start ive > added a new function pointer to ifnet called if_qstart. if_qstart > takes an ifqueue * as an argument instead of an ifnet *, thereby > getting past the implicit behaviour that interfaces only have a > single ring. > > our drivers all have if_start routines that take ifnet pointers > though, so there's compatability for those where a default if_qstart > implementation calls if_start for those drivers. in the future > if_start will be replaced with if_qstart and we can rename it back > to if_start. until then, there's compat. > > drivers that provide their own if_qstart instead of an if_start > function notify the stack by setting IFXF_MPSAFE. a chunk of this > diff is changing the IFXF_MPSAFE drivers to set if_qstart instead > of if_start. note that this is a mechanical change, it does not add > multiple tx queues to these drivers. > > most of this is straightforward except for the hfsc handling. hfsc > needs to track all flows going over an interface, which means all > flows have to be serialised through hfsc. the mechanism in use > before this change was to swap the priq backend on if_snd with the > hfsc backend. the trick with this diff is that we still do that, > ie, we only change the first ifqueue on an interface over to hfsc. > this works because we use the ifqops on the first ifq to map packets > to any of them. because the hfsc map function unconditionally maps > packets to the first ifq, all packets end up going through the one > hfsc structure we set up. the rest of the ifqs remain set up as > priq, but dont get used for sending packets after hfsc has been > enabled. if we ever add another ifqops backend, this will have to > be rethought. until then this is an elegant hack. > > a consequence of this change is that we the ifnet if_start function > should not be called anymore. this isnt true at the moment because > of things like net80211 and ppp. they both queue management packets > onto a separate queue, but those separate queues are dequeued and > processed in the interfaces start routine. if we want to mark wifi > and ppp drivers as mpsafe (or get rid of separate if_start and > if_qstart routines) this will have to change. > > the guts of this change are in if_enqueue and if_attach_queues. > > ok? > Index: arch/octeon/dev/if_cnmac.c === RCS file: /cvs/src/sys/arch/octeon/dev/if_cnmac.c,v retrieving revision 1.61 diff -u -p -r1.61 if_cnmac.c --- arch/octeon/dev/if_cnmac.c 5 Nov 2016 05:14:18 - 1.61 +++ arch/octeon/dev/if_cnmac.c 23 Jan 2017 06:32:59 - @@ -138,7 +138,7 @@ int octeon_eth_ioctl(struct ifnet *, u_l void octeon_eth_watchdog(struct ifnet *); intocteon_eth_init(struct ifnet *); intocteon_eth_stop(struct ifnet *, int); -void octeon_eth_start(struct ifnet *); +void octeon_eth_start(struct ifqueue *); intocteon_eth_send_cmd(struct octeon_eth_softc *, uint64_t, uint64_t); uint64_t octeon_eth_send_makecmd_w1(int, paddr_t); @@ -303,7 +303,7 @@ octeon_eth_attach(struct device *parent, ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_xflags = IFXF_MPSAFE; ifp->if_ioctl = octeon_eth_ioctl; - ifp->if_start = octeon_eth_start; + ifp->if_qstart = octeon_eth_start; ifp->if_watchdog = octeon_eth_watchdog; ifp->if_hardmtu = OCTEON_ETH_MAX_MTU; IFQ_SET_MAXLEN(>if_snd, max(GATHER_QUEUE_SIZE, IFQ_MAXLEN)); @@ -704,8 +704,6 @@ octeon_eth_ioctl(struct ifnet *ifp, u_lo error = 0; } - if_start(ifp); - splx(s); return (error); } @@ -923,13 +921,14 @@ done: } void -octeon_eth_start(struct ifnet *ifp) +octeon_eth_start(struct ifqueue *ifq) { + struct ifnet *ifp = ifq->ifq_if; struct octeon_eth_softc *sc = ifp->if_softc; struct mbuf *m; if (__predict_false(!cn30xxgmx_link_status(sc->sc_gmx_port))) { - ifq_purge(>if_snd); + ifq_purge(ifq);
Special casing fd's opened before pledge(2)
There has been developer pressure to permit an increasing number of ioctl's to pledged programs. The problem is that providing a specific ioctl under a promise to one program, means it becomes supplied to all other programs that make that promise. There is no discrete method to differentiate further, until now. This proposal annotates file descriptors allocated before the first pledge(2) call in a process, with a marker. Such file descriptors can be dup'd; the mark is retained. They can fdpassed, which also retains the mark in the receiver (therefore, a non-pledged process can feed a pledged process). Execve clears this flag. That is the proposed semantic. There are still a few glitches. Once that mark exists, I feel more comfortable adding additional ioctl's which demand early-open fd's. Specifically in privsep daemons. 5 programs have been discovered in the tree which needed small changes (csh, ksh, less, tmux, dhclient). less and tmux fixes are not commited, be cautious about tmux. Index: sys/sys/filedesc.h === RCS file: /cvs/src/sys/sys/filedesc.h,v retrieving revision 1.30 diff -u -p -u -r1.30 filedesc.h --- sys/sys/filedesc.h 6 May 2015 08:52:17 - 1.30 +++ sys/sys/filedesc.h 21 Jan 2017 17:48:41 - @@ -105,6 +105,7 @@ struct filedesc0 { * Per-process open flags. */ #defineUF_EXCLOSE 0x01/* auto-close on exec */ +#defineUF_PREPLEDGE0x02/* opened previous to pledge */ /* * Flags on the file descriptor table. Index: sys/sys/pledge.h === RCS file: /cvs/src/sys/sys/pledge.h,v retrieving revision 1.30 diff -u -p -u -r1.30 pledge.h --- sys/sys/pledge.h23 Jan 2017 04:25:05 - 1.30 +++ sys/sys/pledge.h23 Jan 2017 11:40:58 - @@ -126,7 +126,7 @@ int pledge_adjtime(struct proc *p, const intpledge_sendit(struct proc *p, const void *to); intpledge_sockopt(struct proc *p, int set, int level, int optname); intpledge_socket(struct proc *p, int domain, int state); -intpledge_ioctl(struct proc *p, long com, struct file *); +intpledge_ioctl(struct proc *p, long com, struct file *, int, int); intpledge_ioctl_drm(struct proc *p, long com, dev_t device); intpledge_ioctl_vmm(struct proc *p, long com); intpledge_flock(struct proc *p); Index: sys/sys/unpcb.h === RCS file: /cvs/src/sys/sys/unpcb.h,v retrieving revision 1.12 diff -u -p -u -r1.12 unpcb.h --- sys/sys/unpcb.h 28 Aug 2015 04:38:47 - 1.12 +++ sys/sys/unpcb.h 22 Jan 2017 09:19:54 - @@ -86,17 +86,22 @@ struct unpcb { #definesotounpcb(so) ((struct unpcb *)((so)->so_pcb)) #ifdef _KERNEL +struct fdpass { + struct file *fp; + int flags; +}; + intunp_attach(struct socket *); intunp_bind(struct unpcb *, struct mbuf *, struct proc *); intunp_connect(struct socket *, struct mbuf *, struct proc *); intunp_connect2(struct socket *, struct socket *); void unp_detach(struct unpcb *); -void unp_discard(struct file **, int); +void unp_discard(struct fdpass *, int); void unp_disconnect(struct unpcb *); void unp_drop(struct unpcb *, int); void unp_gc(void *); -void unp_mark(struct file **, int); -void unp_scan(struct mbuf *, void (*)(struct file **, int)); +void unp_mark(struct fdpass *, int); +void unp_scan(struct mbuf *, void (*)(struct fdpass *, int)); void unp_shutdown(struct unpcb *); intunp_externalize(struct mbuf *, socklen_t, int); intunp_internalize(struct mbuf *, struct proc *); Index: sys/kern/kern_descrip.c === RCS file: /cvs/src/sys/kern/kern_descrip.c,v retrieving revision 1.136 diff -u -p -u -r1.136 kern_descrip.c --- sys/kern/kern_descrip.c 24 Sep 2016 18:39:17 - 1.136 +++ sys/kern/kern_descrip.c 23 Jan 2017 07:03:23 - @@ -1307,9 +1307,11 @@ fdcloseexec(struct proc *p) int fd; fdplock(fdp); - for (fd = 0; fd <= fdp->fd_lastfile; fd++) + for (fd = 0; fd <= fdp->fd_lastfile; fd++) { + fdp->fd_ofileflags[fd] &= ~UF_PREPLEDGE; if (fdp->fd_ofileflags[fd] & UF_EXCLOSE) (void) fdrelease(p, fd); + } fdpunlock(fdp); } Index: sys/kern/kern_pledge.c === RCS file: /cvs/src/sys/kern/kern_pledge.c,v retrieving revision 1.191 diff -u -p -u -r1.191 kern_pledge.c --- sys/kern/kern_pledge.c 23 Jan 2017 04:25:05 - 1.191 +++ sys/kern/kern_pledge.c 23 Jan 2017 11:41:49 - @@ -400,8 +400,9 @@ sys_pledge(struct proc *p, void *v, regi syscallarg(const char **)paths; } */*uap = v; struct process *pr = p->p_p; + struct filedesc
Re: split pledge "ioctl" into "bpf" and "tape"
> From: Theo de Raadt> Date: Sun, 22 Jan 2017 20:52:14 -0700 > > Early during pledge development the "ioctl" promise was a kitchen > sink of options until we could differentiate use cases, identify > common patterns, and then create domain-specific promises. > > only 4 cases remain of "ioctl" remain: > > - pax/tar/cpio experience great difficulty finding tape drives quite > late, so they need a few MTIO ioctls. this is not easily fixable > in the program, let's create a "tape" promise. > - tcpdump and pflogd need a single bpf ioctl to collect status information > at termination > - httpd wants SIOCGIFGROUP during the config file parser, but kernel code > indicates this is a pretty safe piece of code, so let's serve it with > the "inet" promise. > > So let's just split these cases out. "ioctl"'s number gets reused for > tape, and a new "bpf" promise is added.. That paves the way for a > more complex diff coming in a few hours. ok kettenis@ > Index: sys/sys/pledge.h > === > RCS file: /cvs/src/sys/sys/pledge.h,v > retrieving revision 1.29 > diff -u -p -u -r1.29 pledge.h > --- sys/sys/pledge.h 3 Jul 2016 04:36:08 - 1.29 > +++ sys/sys/pledge.h 23 Jan 2017 03:22:23 - > @@ -36,7 +36,7 @@ > #define PLEDGE_FLOCK 0x0080ULL /* file locking */ > #define PLEDGE_UNIX 0x0100ULL /* AF_UNIX sockets */ > #define PLEDGE_ID0x0200ULL /* allow setuid, setgid, etc */ > -#define PLEDGE_IOCTL 0x0400ULL /* Select ioctl */ > +#define PLEDGE_TAPE 0x0400ULL /* Tape ioctl */ > #define PLEDGE_GETPW 0x0800ULL /* YP enables if ypbind.lock */ > #define PLEDGE_PROC 0x1000ULL /* fork, waitpid, etc */ > #define PLEDGE_SETTIME 0x2000ULL /* able to set/adj > time/freq */ > @@ -58,6 +58,7 @@ > #define PLEDGE_VMM 0x4000ULL /* vmm ioctls */ > #define PLEDGE_CHOWN 0x8000ULL /* chown(2) family */ > #define PLEDGE_CHOWNUID 0x0001ULL /* allow owner/group > changes */ > +#define PLEDGE_BPF 0x0002ULL /* bpf ioctl */ > > /* > * Bits outside PLEDGE_USERSET are used by the kernel itself > @@ -82,7 +83,7 @@ static struct { > { PLEDGE_FLOCK, "flock" }, > { PLEDGE_UNIX, "unix" }, > { PLEDGE_ID,"id" }, > - { PLEDGE_IOCTL, "ioctl" }, > + { PLEDGE_TAPE, "tape" }, > { PLEDGE_GETPW, "getpw" }, > { PLEDGE_PROC, "proc" }, > { PLEDGE_SETTIME, "settime" }, > @@ -103,6 +104,7 @@ static struct { > { PLEDGE_DRM, "drm" }, > { PLEDGE_VMM, "vmm" }, > { PLEDGE_CHOWNUID, "chown" }, > + { PLEDGE_BPF, "bpf" }, > { 0, NULL }, > }; > #endif > Index: sys/kern/kern_pledge.c > === > RCS file: /cvs/src/sys/kern/kern_pledge.c,v > retrieving revision 1.190 > diff -u -p -u -r1.190 kern_pledge.c > --- sys/kern/kern_pledge.c23 Jan 2017 03:17:55 - 1.190 > +++ sys/kern/kern_pledge.c23 Jan 2017 03:28:08 - > @@ -235,8 +235,7 @@ const uint64_t pledge_syscalls[SYS_MAXSY > > /* >* FIONREAD/FIONBIO for "stdio" > - * A few non-tty ioctl available using "ioctl" > - * tty-centric ioctl available using "tty" > + * Other ioctl are selectively allowed based upon other pledges. >*/ > [SYS_ioctl] = PLEDGE_STDIO, > > @@ -360,6 +359,7 @@ static const struct { > uint64_t flags; > } pledgereq[] = { > { "audio", PLEDGE_AUDIO }, > + { "bpf",PLEDGE_BPF }, > { "chown", PLEDGE_CHOWN | PLEDGE_CHOWNUID }, > { "cpath", PLEDGE_CPATH }, > { "disklabel", PLEDGE_DISKLABEL }, > @@ -372,7 +372,6 @@ static const struct { > { "getpw", PLEDGE_GETPW }, > { "id", PLEDGE_ID }, > { "inet", PLEDGE_INET }, > - { "ioctl", PLEDGE_IOCTL }, > { "mcast", PLEDGE_MCAST }, > { "pf", PLEDGE_PF }, > { "proc", PLEDGE_PROC }, > @@ -384,6 +383,7 @@ static const struct { > { "sendfd", PLEDGE_SENDFD }, > { "settime",PLEDGE_SETTIME }, > { "stdio", PLEDGE_STDIO }, > + { "tape", PLEDGE_TAPE }, > { "tmppath",PLEDGE_TMPPATH }, > { "tty",PLEDGE_TTY }, > { "unix", PLEDGE_UNIX }, > @@ -1127,23 +1127,27 @@ pledge_ioctl(struct proc *p, long com, s > return (ENOTTY); > } > > - /* > - * Further sets of ioctl become available, but are checked a > - * bit more carefully against the vnode. > - */ > - if
less
This change causes less(1) to open /dev/tty slightly earlier, or fallback to stderr. As a result the TIOCGWINSZ operation can be done against the most likely tty descriptor. As a side effect, that tty descriptor will be opened before the first pledge call. Anyone see a downside? Index: usr.bin/less/main.c === RCS file: /cvs/src/usr.bin/less/main.c,v retrieving revision 1.35 diff -u -p -u -r1.35 main.c --- usr.bin/less/main.c 17 Sep 2016 15:06:41 - 1.35 +++ usr.bin/less/main.c 21 Jan 2017 06:10:53 - @@ -90,6 +90,8 @@ main(int argc, char *argv[]) if (s != NULL && *s != '\0') secure = 1; + open_getchr(); + if (secure) { if (pledge("stdio rpath wpath tty", NULL) == -1) { perror("pledge"); @@ -225,7 +227,6 @@ main(int argc, char *argv[]) if (missing_cap && !know_dumb) error("WARNING: terminal is not fully functional", NULL); init_mark(); - open_getchr(); if (secure) if (pledge("stdio rpath tty", NULL) == -1) { Index: usr.bin/less/screen.c === RCS file: /cvs/src/usr.bin/less/screen.c,v retrieving revision 1.24 diff -u -p -u -r1.24 screen.c --- usr.bin/less/screen.c 8 Jul 2016 15:23:44 - 1.24 +++ usr.bin/less/screen.c 21 Jan 2017 12:06:22 - @@ -181,7 +181,7 @@ scrsize(void) #defineDEF_SC_WIDTH80 #defineDEF_SC_HEIGHT 24 - if (ioctl(2, TIOCGWINSZ, ) == 0) { + if (ioctl(tty, TIOCGWINSZ, ) == 0) { if (w.ws_row > 0) sys_height = w.ws_row; if (w.ws_col > 0)
split pledge "ioctl" into "bpf" and "tape"
Early during pledge development the "ioctl" promise was a kitchen sink of options until we could differentiate use cases, identify common patterns, and then create domain-specific promises. only 4 cases remain of "ioctl" remain: - pax/tar/cpio experience great difficulty finding tape drives quite late, so they need a few MTIO ioctls. this is not easily fixable in the program, let's create a "tape" promise. - tcpdump and pflogd need a single bpf ioctl to collect status information at termination - httpd wants SIOCGIFGROUP during the config file parser, but kernel code indicates this is a pretty safe piece of code, so let's serve it with the "inet" promise. So let's just split these cases out. "ioctl"'s number gets reused for tape, and a new "bpf" promise is added.. That paves the way for a more complex diff coming in a few hours. Index: sys/sys/pledge.h === RCS file: /cvs/src/sys/sys/pledge.h,v retrieving revision 1.29 diff -u -p -u -r1.29 pledge.h --- sys/sys/pledge.h3 Jul 2016 04:36:08 - 1.29 +++ sys/sys/pledge.h23 Jan 2017 03:22:23 - @@ -36,7 +36,7 @@ #define PLEDGE_FLOCK 0x0080ULL /* file locking */ #define PLEDGE_UNIX0x0100ULL /* AF_UNIX sockets */ #define PLEDGE_ID 0x0200ULL /* allow setuid, setgid, etc */ -#define PLEDGE_IOCTL 0x0400ULL /* Select ioctl */ +#define PLEDGE_TAPE0x0400ULL /* Tape ioctl */ #define PLEDGE_GETPW 0x0800ULL /* YP enables if ypbind.lock */ #define PLEDGE_PROC0x1000ULL /* fork, waitpid, etc */ #define PLEDGE_SETTIME 0x2000ULL /* able to set/adj time/freq */ @@ -58,6 +58,7 @@ #define PLEDGE_VMM 0x4000ULL /* vmm ioctls */ #define PLEDGE_CHOWN 0x8000ULL /* chown(2) family */ #define PLEDGE_CHOWNUID0x0001ULL /* allow owner/group changes */ +#define PLEDGE_BPF 0x0002ULL /* bpf ioctl */ /* * Bits outside PLEDGE_USERSET are used by the kernel itself @@ -82,7 +83,7 @@ static struct { { PLEDGE_FLOCK, "flock" }, { PLEDGE_UNIX, "unix" }, { PLEDGE_ID,"id" }, - { PLEDGE_IOCTL, "ioctl" }, + { PLEDGE_TAPE, "tape" }, { PLEDGE_GETPW, "getpw" }, { PLEDGE_PROC, "proc" }, { PLEDGE_SETTIME, "settime" }, @@ -103,6 +104,7 @@ static struct { { PLEDGE_DRM, "drm" }, { PLEDGE_VMM, "vmm" }, { PLEDGE_CHOWNUID, "chown" }, + { PLEDGE_BPF, "bpf" }, { 0, NULL }, }; #endif Index: sys/kern/kern_pledge.c === RCS file: /cvs/src/sys/kern/kern_pledge.c,v retrieving revision 1.190 diff -u -p -u -r1.190 kern_pledge.c --- sys/kern/kern_pledge.c 23 Jan 2017 03:17:55 - 1.190 +++ sys/kern/kern_pledge.c 23 Jan 2017 03:28:08 - @@ -235,8 +235,7 @@ const uint64_t pledge_syscalls[SYS_MAXSY /* * FIONREAD/FIONBIO for "stdio" -* A few non-tty ioctl available using "ioctl" -* tty-centric ioctl available using "tty" +* Other ioctl are selectively allowed based upon other pledges. */ [SYS_ioctl] = PLEDGE_STDIO, @@ -360,6 +359,7 @@ static const struct { uint64_t flags; } pledgereq[] = { { "audio", PLEDGE_AUDIO }, + { "bpf",PLEDGE_BPF }, { "chown", PLEDGE_CHOWN | PLEDGE_CHOWNUID }, { "cpath", PLEDGE_CPATH }, { "disklabel", PLEDGE_DISKLABEL }, @@ -372,7 +372,6 @@ static const struct { { "getpw", PLEDGE_GETPW }, { "id", PLEDGE_ID }, { "inet", PLEDGE_INET }, - { "ioctl", PLEDGE_IOCTL }, { "mcast", PLEDGE_MCAST }, { "pf", PLEDGE_PF }, { "proc", PLEDGE_PROC }, @@ -384,6 +383,7 @@ static const struct { { "sendfd", PLEDGE_SENDFD }, { "settime",PLEDGE_SETTIME }, { "stdio", PLEDGE_STDIO }, + { "tape", PLEDGE_TAPE }, { "tmppath",PLEDGE_TMPPATH }, { "tty",PLEDGE_TTY }, { "unix", PLEDGE_UNIX }, @@ -1127,23 +1127,27 @@ pledge_ioctl(struct proc *p, long com, s return (ENOTTY); } - /* -* Further sets of ioctl become available, but are checked a -* bit more carefully against the vnode. -*/ - if ((p->p_p->ps_pledge & PLEDGE_IOCTL)) { + if ((p->p_p->ps_pledge & PLEDGE_INET)) { switch (com) { - case TIOCGETA: - case TIOCGPGRP: - case TIOCGWINSZ:
add support for multiple transmit queues on interfaces
the short explanation is that this lets interfaces allocate multiple ifq structures that can be mapped to their transmit rings. the mechanism for this is a driver calling if_attach_queues() after theyve called if_attach(). the long version is that this has if_enqueue access an array of ifqueues on the interface instead of if_snd directly. the ifq is picked by asking the queue discipline (priq or hfsc) to map an mbuf to a slot in the if_ifqs array. to notify the driver that a particular queue needs to start ive added a new function pointer to ifnet called if_qstart. if_qstart takes an ifqueue * as an argument instead of an ifnet *, thereby getting past the implicit behaviour that interfaces only have a single ring. our drivers all have if_start routines that take ifnet pointers though, so there's compatability for those where a default if_qstart implementation calls if_start for those drivers. in the future if_start will be replaced with if_qstart and we can rename it back to if_start. until then, there's compat. drivers that provide their own if_qstart instead of an if_start function notify the stack by setting IFXF_MPSAFE. a chunk of this diff is changing the IFXF_MPSAFE drivers to set if_qstart instead of if_start. note that this is a mechanical change, it does not add multiple tx queues to these drivers. most of this is straightforward except for the hfsc handling. hfsc needs to track all flows going over an interface, which means all flows have to be serialised through hfsc. the mechanism in use before this change was to swap the priq backend on if_snd with the hfsc backend. the trick with this diff is that we still do that, ie, we only change the first ifqueue on an interface over to hfsc. this works because we use the ifqops on the first ifq to map packets to any of them. because the hfsc map function unconditionally maps packets to the first ifq, all packets end up going through the one hfsc structure we set up. the rest of the ifqs remain set up as priq, but dont get used for sending packets after hfsc has been enabled. if we ever add another ifqops backend, this will have to be rethought. until then this is an elegant hack. a consequence of this change is that we the ifnet if_start function should not be called anymore. this isnt true at the moment because of things like net80211 and ppp. they both queue management packets onto a separate queue, but those separate queues are dequeued and processed in the interfaces start routine. if we want to mark wifi and ppp drivers as mpsafe (or get rid of separate if_start and if_qstart routines) this will have to change. the guts of this change are in if_enqueue and if_attach_queues. ok? Index: arch/octeon/dev/if_cnmac.c === RCS file: /cvs/src/sys/arch/octeon/dev/if_cnmac.c,v retrieving revision 1.61 diff -u -p -r1.61 if_cnmac.c --- arch/octeon/dev/if_cnmac.c 5 Nov 2016 05:14:18 - 1.61 +++ arch/octeon/dev/if_cnmac.c 23 Jan 2017 02:00:53 - @@ -138,7 +138,7 @@ int octeon_eth_ioctl(struct ifnet *, u_l void octeon_eth_watchdog(struct ifnet *); intocteon_eth_init(struct ifnet *); intocteon_eth_stop(struct ifnet *, int); -void octeon_eth_start(struct ifnet *); +void octeon_eth_start(struct ifqueue *); intocteon_eth_send_cmd(struct octeon_eth_softc *, uint64_t, uint64_t); uint64_t octeon_eth_send_makecmd_w1(int, paddr_t); @@ -303,7 +303,7 @@ octeon_eth_attach(struct device *parent, ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_xflags = IFXF_MPSAFE; ifp->if_ioctl = octeon_eth_ioctl; - ifp->if_start = octeon_eth_start; + ifp->if_qstart = octeon_eth_start; ifp->if_watchdog = octeon_eth_watchdog; ifp->if_hardmtu = OCTEON_ETH_MAX_MTU; IFQ_SET_MAXLEN(>if_snd, max(GATHER_QUEUE_SIZE, IFQ_MAXLEN)); @@ -704,8 +704,6 @@ octeon_eth_ioctl(struct ifnet *ifp, u_lo error = 0; } - if_start(ifp); - splx(s); return (error); } @@ -923,13 +921,14 @@ done: } void -octeon_eth_start(struct ifnet *ifp) +octeon_eth_start(struct ifqueue *ifq) { + struct ifnet *ifp = ifq->ifq_if; struct octeon_eth_softc *sc = ifp->if_softc; struct mbuf *m; if (__predict_false(!cn30xxgmx_link_status(sc->sc_gmx_port))) { - ifq_purge(>if_snd); + ifq_purge(ifq); return; } @@ -948,12 +947,12 @@ octeon_eth_start(struct ifnet *ifp) * and bail out. */ if (octeon_eth_send_queue_is_full(sc)) { - ifq_set_oactive(>if_snd); + ifq_set_oactive(ifq); timeout_add(>sc_tick_free_ch, 1); return; } - m = ifq_dequeue(>if_snd); + m = ifq_dequeue(ifq); if (m == NULL) return;
arm64: distrib for ramdisk kernel
Hi, this diff provides the infrastructure to compile a ramdisk kernel for arm64. It's been copied from armv7 and stripped from u-boots, device trees and mkuboot. ok? Patrick diff --git a/distrib/arm64/Makefile b/distrib/arm64/Makefile new file mode 100644 index 000..bb5d606b329 --- /dev/null +++ b/distrib/arm64/Makefile @@ -0,0 +1,5 @@ +# $OpenBSD: Makefile,v 1.1 2013/09/04 20:00:21 patrick Exp $ + +SUBDIR= ramdisk + +.include diff --git a/distrib/arm64/ramdisk/Makefile b/distrib/arm64/ramdisk/Makefile new file mode 100644 index 000..178e40352aa --- /dev/null +++ b/distrib/arm64/ramdisk/Makefile @@ -0,0 +1,78 @@ +# $OpenBSD: Makefile,v 1.16 2016/11/30 15:46:45 natano Exp $ + +REV= ${OSrev} + +TOP= ${.CURDIR}/.. + +BSD_RD=bsd.rd +IMAGE= mr.fs +CBIN?= instbin +CRUNCHCONF?= ${CBIN}.conf +CRUNCHCONFS?= ${.CURDIR}/../common/crunch.conf +LISTS= ${.CURDIR}/list +UTILS?=${.CURDIR}/../../miniroot + +MTREE= ${UTILS}/mtree.conf + +DISKTYPE= rdroot +MAKEFSARGS_RD= -o disklabel=${DISKTYPE},minfree=0,density=4096 + +.ifndef DESTDIR +all ${IMAGE}: + @echo setenv DESTDIR before making a ramdisk! + @false +.else + +ALLBSD=bsd +ALLBSDRD= ${BSD_RD} +all: ${ALLBSDRD} + +bsd: + cd ${TOP}/../../sys/arch/arm64/compile/RAMDISK && \ + su ${BUILDUSER} -c '${MAKE} config && ${MAKE} clean && exec ${MAKE}' + cp -p ${TOP}/../../sys/arch/arm64/compile/RAMDISK/obj/bsd bsd + +${BSD_RD}: ${IMAGE} bsd rdsetroot + cp bsd ${BSD_RD} + ${.OBJDIR}/rdsetroot ${BSD_RD} ${IMAGE} + +${IMAGE}: ${CBIN} + rm -rf $@.d + install -d -o root -g wheel $@.d + mtree -def ${MTREE} -p $@.d -u + TOPDIR=${TOP} CURDIR=${.CURDIR} OBJDIR=${.OBJDIR} REV=${REV} \ + TARGDIR=$@.d UTILS=${UTILS} RELEASEDIR=${RELEASEDIR} \ + sh ${UTILS}/runlist.sh ${LISTS} + rm $@.d/${CBIN} + makefs ${MAKEFSARGS_RD} $@ $@.d + +.endif + +rdsetroot: ${TOP}/../common/elfrdsetroot.c + ${HOSTCC} ${HOSTCFLAGS} -o rdsetroot \ + ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ + ${TOP}/../common/elf64.c + +${CBIN}.mk ${CBIN}.cache ${CBIN}.c: ${CRUNCHCONF} + crunchgen -E -D ${.CURDIR}/../../.. -L ${DESTDIR}/usr/lib ${.ALLSRC} + +${CBIN}: ${CBIN}.mk ${CBIN}.cache ${CBIN}.c + ${MAKE} -f ${CBIN}.mk SRCLIBDIR=${.CURDIR}/../../../lib all + +${CRUNCHCONF}: ${LISTS} + awk -f ${UTILS}/makeconf.awk CBIN=${CBIN} ${LISTS} > ${CBIN}.conf + +clean cleandir: + /bin/rm -f *.core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}.cache \ + lib*.a lib*.olist ${CBIN}.map \ + *.o *.lo *.c ${ALLBSD} ${ALLBSDRD} rdsetroot + rm -f instbin.conf + rm -rf cd-dir ${IMAGE}.d + +.ifdef RELEASEDIR +install: + cp ${ALLBSDRD} ${RELEASEDIR} +.endif # RELEASEDIR + +.include +.include diff --git a/distrib/arm64/ramdisk/Makefile.inc b/distrib/arm64/ramdisk/Makefile.inc new file mode 100644 index 000..4b23e5f9958 --- /dev/null +++ b/distrib/arm64/ramdisk/Makefile.inc @@ -0,0 +1,4 @@ +# $OpenBSD: Makefile.inc,v 1.1 2013/09/04 20:00:23 patrick Exp $ + +CRUNCHGENOPTS= -E + diff --git a/distrib/arm64/ramdisk/install.md b/distrib/arm64/ramdisk/install.md new file mode 100644 index 000..b3d2d87eefb --- /dev/null +++ b/distrib/arm64/ramdisk/install.md @@ -0,0 +1,130 @@ +# $OpenBSD: install.md,v 1.43 2017/01/19 06:55:58 jsg Exp $ +# +# +# Copyright (c) 1996 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Jason R. Thorpe. +# +# 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 NETBSD FOUNDATION, INC. 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 REGENTS 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.
Re: ipsec_common_input() & splsoftnet()
ok Martin Pieuchot(m...@openbsd.org) on 2017.01.23 10:44:59 +1000: > This function is only called by udp_input() so at IPL_SOFTNET. Assert > that and get rid of a recursive splsoftnet()/splx() dance. > > ok? > > Index: netinet/ipsec_input.c > === > RCS file: /cvs/src/sys/netinet/ipsec_input.c,v > retrieving revision 1.137 > diff -u -p -r1.137 ipsec_input.c > --- netinet/ipsec_input.c 20 Jan 2017 04:22:58 - 1.137 > +++ netinet/ipsec_input.c 23 Jan 2017 00:43:03 - > @@ -123,11 +123,13 @@ ipsec_common_input(struct mbuf *m, int s > struct ifnet *encif; > u_int32_t spi; > u_int16_t cpi; > - int s, error; > + int error; > #ifdef ENCDEBUG > char buf[INET6_ADDRSTRLEN]; > #endif > > + splsoftassert(IPL_SOFTNET); > + > IPSEC_ISTAT(espstat.esps_input, ahstat.ahs_input, > ipcompstat.ipcomps_input); > > @@ -227,11 +229,9 @@ ipsec_common_input(struct mbuf *m, int s > return EPFNOSUPPORT; > } > > - s = splsoftnet(); > tdbp = gettdb(rtable_l2(m->m_pkthdr.ph_rtableid), > spi, _address, sproto); > if (tdbp == NULL) { > - splx(s); > DPRINTF(("ipsec_common_input(): could not find SA for " > "packet to %s, spi %08x\n", > ipsp_address(_address, buf, sizeof(buf)), ntohl(spi))); > @@ -242,7 +242,6 @@ ipsec_common_input(struct mbuf *m, int s > } > > if (tdbp->tdb_flags & TDBF_INVALID) { > - splx(s); > DPRINTF(("ipsec_common_input(): attempted to use invalid " > "SA %s/%08x/%u\n", ipsp_address(_address, buf, > sizeof(buf)), ntohl(spi), tdbp->tdb_sproto)); > @@ -253,7 +252,6 @@ ipsec_common_input(struct mbuf *m, int s > } > > if (udpencap && !(tdbp->tdb_flags & TDBF_UDPENCAP)) { > - splx(s); > DPRINTF(("ipsec_common_input(): attempted to use non-udpencap " > "SA %s/%08x/%u\n", ipsp_address(_address, buf, > sizeof(buf)), ntohl(spi), tdbp->tdb_sproto)); > @@ -263,7 +261,6 @@ ipsec_common_input(struct mbuf *m, int s > } > > if (!udpencap && (tdbp->tdb_flags & TDBF_UDPENCAP)) { > - splx(s); > DPRINTF(("ipsec_common_input(): attempted to use udpencap " > "SA %s/%08x/%u\n", ipsp_address(_address, buf, > sizeof(buf)), ntohl(spi), tdbp->tdb_sproto)); > @@ -273,7 +270,6 @@ ipsec_common_input(struct mbuf *m, int s > } > > if (tdbp->tdb_xform == NULL) { > - splx(s); > DPRINTF(("ipsec_common_input(): attempted to use uninitialized " > "SA %s/%08x/%u\n", ipsp_address(_address, buf, > sizeof(buf)), ntohl(spi), tdbp->tdb_sproto)); > @@ -286,7 +282,6 @@ ipsec_common_input(struct mbuf *m, int s > if (sproto != IPPROTO_IPCOMP) { > if ((encif = enc_getif(tdbp->tdb_rdomain, > tdbp->tdb_tap)) == NULL) { > - splx(s); > DPRINTF(("ipsec_common_input(): " > "no enc%u interface for SA %s/%08x/%u\n", > tdbp->tdb_tap, ipsp_address(_address, buf, > @@ -319,7 +314,6 @@ ipsec_common_input(struct mbuf *m, int s >* everything else. >*/ > error = (*(tdbp->tdb_xform->xf_input))(m, tdbp, skip, protoff); > - splx(s); > return error; > } > >
ipsec_common_input() & splsoftnet()
This function is only called by udp_input() so at IPL_SOFTNET. Assert that and get rid of a recursive splsoftnet()/splx() dance. ok? Index: netinet/ipsec_input.c === RCS file: /cvs/src/sys/netinet/ipsec_input.c,v retrieving revision 1.137 diff -u -p -r1.137 ipsec_input.c --- netinet/ipsec_input.c 20 Jan 2017 04:22:58 - 1.137 +++ netinet/ipsec_input.c 23 Jan 2017 00:43:03 - @@ -123,11 +123,13 @@ ipsec_common_input(struct mbuf *m, int s struct ifnet *encif; u_int32_t spi; u_int16_t cpi; - int s, error; + int error; #ifdef ENCDEBUG char buf[INET6_ADDRSTRLEN]; #endif + splsoftassert(IPL_SOFTNET); + IPSEC_ISTAT(espstat.esps_input, ahstat.ahs_input, ipcompstat.ipcomps_input); @@ -227,11 +229,9 @@ ipsec_common_input(struct mbuf *m, int s return EPFNOSUPPORT; } - s = splsoftnet(); tdbp = gettdb(rtable_l2(m->m_pkthdr.ph_rtableid), spi, _address, sproto); if (tdbp == NULL) { - splx(s); DPRINTF(("ipsec_common_input(): could not find SA for " "packet to %s, spi %08x\n", ipsp_address(_address, buf, sizeof(buf)), ntohl(spi))); @@ -242,7 +242,6 @@ ipsec_common_input(struct mbuf *m, int s } if (tdbp->tdb_flags & TDBF_INVALID) { - splx(s); DPRINTF(("ipsec_common_input(): attempted to use invalid " "SA %s/%08x/%u\n", ipsp_address(_address, buf, sizeof(buf)), ntohl(spi), tdbp->tdb_sproto)); @@ -253,7 +252,6 @@ ipsec_common_input(struct mbuf *m, int s } if (udpencap && !(tdbp->tdb_flags & TDBF_UDPENCAP)) { - splx(s); DPRINTF(("ipsec_common_input(): attempted to use non-udpencap " "SA %s/%08x/%u\n", ipsp_address(_address, buf, sizeof(buf)), ntohl(spi), tdbp->tdb_sproto)); @@ -263,7 +261,6 @@ ipsec_common_input(struct mbuf *m, int s } if (!udpencap && (tdbp->tdb_flags & TDBF_UDPENCAP)) { - splx(s); DPRINTF(("ipsec_common_input(): attempted to use udpencap " "SA %s/%08x/%u\n", ipsp_address(_address, buf, sizeof(buf)), ntohl(spi), tdbp->tdb_sproto)); @@ -273,7 +270,6 @@ ipsec_common_input(struct mbuf *m, int s } if (tdbp->tdb_xform == NULL) { - splx(s); DPRINTF(("ipsec_common_input(): attempted to use uninitialized " "SA %s/%08x/%u\n", ipsp_address(_address, buf, sizeof(buf)), ntohl(spi), tdbp->tdb_sproto)); @@ -286,7 +282,6 @@ ipsec_common_input(struct mbuf *m, int s if (sproto != IPPROTO_IPCOMP) { if ((encif = enc_getif(tdbp->tdb_rdomain, tdbp->tdb_tap)) == NULL) { - splx(s); DPRINTF(("ipsec_common_input(): " "no enc%u interface for SA %s/%08x/%u\n", tdbp->tdb_tap, ipsp_address(_address, buf, @@ -319,7 +314,6 @@ ipsec_common_input(struct mbuf *m, int s * everything else. */ error = (*(tdbp->tdb_xform->xf_input))(m, tdbp, skip, protoff); - splx(s); return error; }
arm64: distrib/special installboot
Hi, this makes installboot compile for arm64 at the RAMDISK build. ok? Patrick diff --git a/distrib/special/installboot/Makefile b/distrib/special/installboot/Makefile index 760daf0e44e..bfff63b11e4 100644 --- a/distrib/special/installboot/Makefile +++ b/distrib/special/installboot/Makefile @@ -20,6 +20,10 @@ SRCS += i386_nlist.c SRCS += i386_softraid.c .endif +.if ${MACHINE} == "arm64" +SRCS += stubs.c +.endif + .if ${MACHINE} == "armv7" SRCS += stubs.c .endif
Re: use ifqueue packet statistics
On Mon, Jan 23, 2017 at 10:10:23AM +1000, Martin Pieuchot wrote: > On 22/01/17(Sun) 20:38, David Gwynne wrote: > > ifqueues count packets, therefore if_enqueue doesnt have to. > > > > this adds reading of the ifq counters into the if_data values so > > userland still looks right. > > > > this is another step toward multiple tx queues. > > I like it, some comments below. > > > > @@ -1799,10 +1790,13 @@ ifioctl(struct socket *so, u_long cmd, c > > ifr->ifr_hardmtu = ifp->if_hardmtu; > > break; > > > > - case SIOCGIFDATA: > > - error = copyout((caddr_t)>if_data, ifr->ifr_data, > > + case SIOCGIFDATA: { > > + struct if_data data; > > I'd use ifdata that would avoid shadowing the 'data' pointer. ok. > > + error = copyout((caddr_t)>if_data, , > > sizeof(ifp->if_data)); > > Shouldn't this be: > > copyout(, ifr->ifr_data, sizeof(data)) yes. > > +void > > +if_data(struct if_data *data, struct ifnet *ifp) > > Could you pass ``ifp'' as first argument to keep coherency with the rest > of if.c? i can. i thought of it as a memcpy like function, so dst src. fixed. > > + /* it's ugly reaching into an ifq like this */ > > What's ugly? I'm not sure this comment help. if.c doesnt know much about ifq internals, except for this bit. Index: if.c === RCS file: /cvs/src/sys/net/if.c,v retrieving revision 1.475 diff -u -p -r1.475 if.c --- if.c22 Jan 2017 10:17:39 - 1.475 +++ if.c23 Jan 2017 00:32:53 - @@ -583,8 +583,7 @@ if_start_locked(struct ifnet *ifp) int if_enqueue(struct ifnet *ifp, struct mbuf *m) { - int length, error = 0; - unsigned short mflags; + int error = 0; #if NBRIDGE > 0 if (ifp->if_bridgeport && (m->m_flags & M_PROTO1) == 0) { @@ -595,9 +594,6 @@ if_enqueue(struct ifnet *ifp, struct mbu } #endif - length = m->m_pkthdr.len; - mflags = m->m_flags; - #if NPF > 0 pf_pkt_unlink_state_key(m); #endif /* NPF > 0 */ @@ -610,11 +606,6 @@ if_enqueue(struct ifnet *ifp, struct mbu if (error) return (error); - ifp->if_opackets++; - ifp->if_obytes += length; - if (mflags & M_MCAST) - ifp->if_omcasts++; - if_start(ifp); return (0); @@ -1799,10 +1790,12 @@ ifioctl(struct socket *so, u_long cmd, c ifr->ifr_hardmtu = ifp->if_hardmtu; break; - case SIOCGIFDATA: - error = copyout((caddr_t)>if_data, ifr->ifr_data, - sizeof(ifp->if_data)); + case SIOCGIFDATA: { + struct if_data ifdata; + if_data(ifp, ); + error = copyout(, >ifr_data, sizeof(ifdata)); break; + } case SIOCSIFFLAGS: if ((error = suser(p, 0)) != 0) @@ -2167,6 +2160,33 @@ ifconf(u_long cmd, caddr_t data) } ifc->ifc_len -= space; return (error); +} + +void +if_data(struct ifnet *ifp, struct if_data *data) +{ + struct ifqueue *ifq; + uint64_t opackets = 0; + uint64_t obytes = 0; + uint64_t omcasts = 0; + uint64_t oqdrops = 0; + + ifq = >if_snd; + + mtx_enter(>ifq_mtx); + opackets += ifq->ifq_packets; + obytes += ifq->ifq_bytes; + oqdrops += ifq->ifq_qdrops; + omcasts += ifq->ifq_mcasts; + /* ifq->ifq_errors */ + mtx_leave(>ifq_mtx); + + *data = ifp->if_data; + data->ifi_opackets += opackets; + data->ifi_obytes += obytes; + data->ifi_oqdrops += oqdrops; + data->ifi_omcasts += omcasts; + /* ifp->if_data.ifi_oerrors */ } /* Index: if.h === RCS file: /cvs/src/sys/net/if.h,v retrieving revision 1.181 diff -u -p -r1.181 if.h --- if.h12 Dec 2016 09:51:30 - 1.181 +++ if.h23 Jan 2017 00:32:53 - @@ -469,6 +469,7 @@ voidif_downall(void); void if_link_state_change(struct ifnet *); void if_up(struct ifnet *); intifconf(u_long, caddr_t); +void if_data(struct ifnet *, struct if_data *); void ifinit(void); intifioctl(struct socket *, u_long, caddr_t, struct proc *); intifpromisc(struct ifnet *, int); Index: rtsock.c === RCS file: /cvs/src/sys/net/rtsock.c,v retrieving revision 1.216 diff -u -p -r1.216 rtsock.c --- rtsock.c22 Jan 2017 04:31:02 - 1.216 +++ rtsock.c23 Jan 2017 00:32:53 - @@ -1268,7 +1268,7 @@ rt_ifmsg(struct ifnet *ifp) ifm->ifm_tableid = ifp->if_rdomain; ifm->ifm_flags = ifp->if_flags; ifm->ifm_xflags = ifp->if_xflags; - ifm->ifm_data = ifp->if_data; + if_data(ifp, >ifm_data); ifm->ifm_addrs = 0; route_input(m, AF_UNSPEC); } @@ -1473,7 +1473,7 @@ sysctl_iflist(int af,
Re: uvm: guard unused function for RAMDISK kernel
On Mon, Jan 23, 2017 at 10:20:39AM +1000, Patrick Wildt wrote: > Hi, > > on a RAMDISK kernel this function is not used, thus clang complains. > Simply guard it with SMALL_KERNEL, like the rest of that part of the > code. > > ok? > > Patrick > As requested by deraadt@, simply move the function down into the ifndef. ok? Patrick diff --git a/sys/uvm/uvm_addr.c b/sys/uvm/uvm_addr.c index af33700273b..1308a4ac446 100644 --- a/sys/uvm/uvm_addr.c +++ b/sys/uvm/uvm_addr.c @@ -82,19 +82,6 @@ struct uaddr_pivot_state { struct uaddr_pivot up_pivots[NUM_PIVOTS]; }; -/* - * Free space comparison. - * Compares smaller free-space before larger free-space. - */ -static inline int -uvm_mapent_fspace_cmp(const struct vm_map_entry *e1, -const struct vm_map_entry *e2) -{ - if (e1->fspace != e2->fspace) - return (e1->fspace < e2->fspace ? -1 : 1); - return (e1->start < e2->start ? -1 : e1->start > e2->start); -} - /* Forward declaration (see below). */ extern const struct uvm_addr_functions uaddr_kernel_functions; struct uvm_addr_state uaddr_kbootstrap; @@ -1435,6 +1422,19 @@ uaddr_stack_brk_create(vaddr_t minaddr, vaddr_t maxaddr) #ifndef SMALL_KERNEL +/* + * Free space comparison. + * Compares smaller free-space before larger free-space. + */ +static inline int +uvm_mapent_fspace_cmp(const struct vm_map_entry *e1, +const struct vm_map_entry *e2) +{ + if (e1->fspace != e2->fspace) + return (e1->fspace < e2->fspace ? -1 : 1); + return (e1->start < e2->start ? -1 : e1->start > e2->start); +} + RBT_GENERATE(uaddr_free_rbtree, vm_map_entry, dfree.rbtree, uvm_mapent_fspace_cmp); #endif /* !SMALL_KERNEL */
uvm: guard unused function for RAMDISK kernel
Hi, on a RAMDISK kernel this function is not used, thus clang complains. Simply guard it with SMALL_KERNEL, like the rest of that part of the code. ok? Patrick diff --git a/sys/uvm/uvm_addr.c b/sys/uvm/uvm_addr.c index af33700273b..4527e1fda78 100644 --- a/sys/uvm/uvm_addr.c +++ b/sys/uvm/uvm_addr.c @@ -82,6 +82,7 @@ struct uaddr_pivot_state { struct uaddr_pivot up_pivots[NUM_PIVOTS]; }; +#ifndef SMALL_KERNEL /* * Free space comparison. * Compares smaller free-space before larger free-space. @@ -94,6 +95,7 @@ uvm_mapent_fspace_cmp(const struct vm_map_entry *e1, return (e1->fspace < e2->fspace ? -1 : 1); return (e1->start < e2->start ? -1 : e1->start > e2->start); } +#endif /* !SMALL_KERNEL */ /* Forward declaration (see below). */ extern const struct uvm_addr_functions uaddr_kernel_functions;
Re: rtsock refactoring
On Sat, Jan 21, 2017 at 07:31:20AM +0100, Claudio Jeker wrote: > On Sat, Jan 21, 2017 at 01:28:02AM +0100, Claudio Jeker wrote: > > On Fri, Jan 20, 2017 at 02:51:52AM +0100, Claudio Jeker wrote: > > > I sent this diff out some time ago and would really like to get this in. > > > This is one step on makeing rtsock.c less of a hornets nest. > > > This reduces the side effects in route_output and simplifies some other > > > bits as well. For example route_input is less variadic and simpler. > > > > > > > Here is just the route_input change. Which should be easier to OK. > > Changed a few things based on input from bluhm@ > > > > Next piece of the puzzle. Cleanup the error handling a bit. > If the route message is not valid (syntactically or also because it > references bad things) fail without broadcasting this message to all > listeners. So make sure that until the info struct has been checked we only > use goto fail instead of goto flush. > While there remove some redundant checks which are not needed. > Last bit for now. This is changing the reporting madness. It moves it in its own function which is called after the big switch statement. If you hit a bad error in the switch the code should eiter goto fail or flush. The new function rt_report is actually constructing the rt message out of a rtentry. It does not magically update the message that was passed in from userland. I think this is much safer and works better. The diff is maybe hard to read because big chunks of code got moved around. With this the side effects happening in route_output are mostly gone I think. -- :wq Claudio Index: net/rtsock.c === RCS file: /cvs/src/sys/net/rtsock.c,v retrieving revision 1.216 diff -u -p -r1.216 rtsock.c --- net/rtsock.c22 Jan 2017 04:31:02 - 1.216 +++ net/rtsock.c22 Jan 2017 05:02:42 - @@ -459,30 +459,94 @@ route_input(struct mbuf *m0, sa_family_t m_freem(m); } +struct rt_msghdr * +rt_report(struct rtentry *rt, u_char type, int seq, int tableid) +{ + struct rt_msghdr*rtm; + struct rt_addrinfo info; + struct sockaddr_rtlabel sa_rl; + struct sockaddr_in6 sa_mask; +#ifdef BFD + struct sockaddr_bfd sa_bfd; +#endif +#ifdef MPLS + struct sockaddr_mpls sa_mpls; +#endif + struct ifnet*ifp = NULL; + int len; + + bzero(, sizeof(info)); + info.rti_info[RTAX_DST] = rt_key(rt); + info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; + info.rti_info[RTAX_NETMASK] = rt_plen2mask(rt, _mask); + info.rti_info[RTAX_LABEL] = rtlabel_id2sa(rt->rt_labelid, _rl); +#ifdef BFD + if (rt->rt_flags & RTF_BFD) + info.rti_info[RTAX_BFD] = bfd2sa(rt, _bfd); +#endif +#ifdef MPLS + if (rt->rt_flags & RTF_MPLS) { + bzero(_mpls, sizeof(sa_mpls)); + sa_mpls.smpls_family = AF_MPLS; + sa_mpls.smpls_len = sizeof(sa_mpls); + sa_mpls.smpls_label = ((struct rt_mpls *) + rt->rt_llinfo)->mpls_label; + info.rti_info[RTAX_SRC] = (struct sockaddr *)_mpls; + info.rti_mpls = ((struct rt_mpls *) + rt->rt_llinfo)->mpls_operation; + } +#endif + ifp = if_get(rt->rt_ifidx); + if (ifp != NULL) { + info.rti_info[RTAX_IFP] = sdltosa(ifp->if_sadl); + info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; + if (ifp->if_flags & IFF_POINTOPOINT) + info.rti_info[RTAX_BRD] = rt->rt_ifa->ifa_dstaddr; + } + if_put(ifp); + /* RTAX_GENMASK, RTAX_AUTHOR, RTAX_SRCMASK ignored */ + + /* build new route message */ + len = rt_msg2(type, RTM_VERSION, , NULL, NULL); + /* XXX why can't we wait? Should be process context... */ + rtm = malloc(len, M_RTABLE, M_NOWAIT | M_ZERO); + if (rtm == NULL) + return NULL; + + rt_msg2(type, RTM_VERSION, , (caddr_t)rtm, NULL); + rtm->rtm_type = type; + rtm->rtm_index = rt->rt_ifidx; + rtm->rtm_tableid = tableid; + rtm->rtm_priority = rt->rt_priority & RTP_MASK; + rtm->rtm_flags = rt->rt_flags; + rtm->rtm_pid = curproc->p_p->ps_pid; + rtm->rtm_seq = seq; + rt_getmetrics(>rt_rmx, >rtm_rmx); + rtm->rtm_addrs = info.rti_addrs; +#ifdef MPLS + rtm->rtm_mpls = info.rti_mpls; +#endif + return rtm; +} + int route_output(struct mbuf *m, ...) { struct rt_msghdr*rtm = NULL; struct rtentry *rt = NULL; - struct rtentry *saved_nrt = NULL; struct rt_addrinfo info; - int plen, len, newgate = 0, error = 0; + int plen, len, seq, newgate = 0, error = 0; struct ifnet*ifp = NULL; struct ifaddr *ifa = NULL; struct
Re: use ifqueue packet statistics
On 22/01/17(Sun) 20:38, David Gwynne wrote: > ifqueues count packets, therefore if_enqueue doesnt have to. > > this adds reading of the ifq counters into the if_data values so > userland still looks right. > > this is another step toward multiple tx queues. I like it, some comments below. > @@ -1799,10 +1790,13 @@ ifioctl(struct socket *so, u_long cmd, c > ifr->ifr_hardmtu = ifp->if_hardmtu; > break; > > - case SIOCGIFDATA: > - error = copyout((caddr_t)>if_data, ifr->ifr_data, > + case SIOCGIFDATA: { > + struct if_data data; I'd use ifdata that would avoid shadowing the 'data' pointer. > + if_data(, ifp); > + error = copyout((caddr_t)>if_data, , > sizeof(ifp->if_data)); Shouldn't this be: copyout(, ifr->ifr_data, sizeof(data)) > break; > + } > > case SIOCSIFFLAGS: > if ((error = suser(p, 0)) != 0) > @@ -2167,6 +2161,34 @@ ifconf(u_long cmd, caddr_t data) > } > ifc->ifc_len -= space; > return (error); > +} > + > +void > +if_data(struct if_data *data, struct ifnet *ifp) Could you pass ``ifp'' as first argument to keep coherency with the rest of if.c? > +{ > + struct ifqueue *ifq; > + uint64_t opackets = 0; > + uint64_t obytes = 0; > + uint64_t omcasts = 0; > + uint64_t oqdrops = 0; > + > + ifq = >if_snd; > + > + /* it's ugly reaching into an ifq like this */ What's ugly? I'm not sure this comment help. > + mtx_enter(>ifq_mtx); > + opackets += ifq->ifq_packets; > + obytes += ifq->ifq_bytes; > + oqdrops += ifq->ifq_qdrops; > + omcasts += ifq->ifq_mcasts; > + /* ifq->ifq_errors */ > + mtx_leave(>ifq_mtx); > + > + *data = ifp->if_data; > + data->ifi_opackets += opackets; > + data->ifi_obytes += obytes; > + data->ifi_oqdrops += oqdrops; > + data->ifi_omcasts += omcasts; > + /* ifp->if_data.ifi_oerrors */ > } > > /* > Index: if.h > === > RCS file: /cvs/src/sys/net/if.h,v > retrieving revision 1.181 > diff -u -p -r1.181 if.h > --- if.h 12 Dec 2016 09:51:30 - 1.181 > +++ if.h 22 Jan 2017 10:35:30 - > @@ -469,6 +469,7 @@ void if_downall(void); > void if_link_state_change(struct ifnet *); > void if_up(struct ifnet *); > int ifconf(u_long, caddr_t); > +void if_data(struct if_data *, struct ifnet *); > void ifinit(void); > int ifioctl(struct socket *, u_long, caddr_t, struct proc *); > int ifpromisc(struct ifnet *, int); > Index: rtsock.c > === > RCS file: /cvs/src/sys/net/rtsock.c,v > retrieving revision 1.216 > diff -u -p -r1.216 rtsock.c > --- rtsock.c 22 Jan 2017 04:31:02 - 1.216 > +++ rtsock.c 22 Jan 2017 10:35:30 - > @@ -1268,7 +1268,7 @@ rt_ifmsg(struct ifnet *ifp) > ifm->ifm_tableid = ifp->if_rdomain; > ifm->ifm_flags = ifp->if_flags; > ifm->ifm_xflags = ifp->if_xflags; > - ifm->ifm_data = ifp->if_data; > + if_data(>ifm_data, ifp); > ifm->ifm_addrs = 0; > route_input(m, AF_UNSPEC); > } > @@ -1473,7 +1473,7 @@ sysctl_iflist(int af, struct walkarg *w) > ifm->ifm_index = ifp->if_index; > ifm->ifm_tableid = ifp->if_rdomain; > ifm->ifm_flags = ifp->if_flags; > - ifm->ifm_data = ifp->if_data; > + if_data(>ifm_data, ifp); > ifm->ifm_addrs = info.rti_addrs; > error = copyout(ifm, w->w_where, len); > if (error) >
Re: rtwn: fix iq calibration
Stefan Sperlingwrites: > FreeBSD committed a couple of interesting things in r307529 > https://svnweb.freebsd.org/base?view=revision=r307529 > Unfortunately the commit is a giant patch bomb which makes > it hard to pick out individual fixes :-( > > This patch extracts what I believe "fix IQ calibration bug" refers to. > The current code is only ever setting bits but not clearing bits which > should be cleared. > > My diff looks very different because FreeBSD made a lot of style > changes in their driver (e.g. they have an rtwn_bb_setbits() function > which we don't have). We could think about porting these over but > for now I'd like to focus on fixing bugs instead of style. Appears to work fine with urtwn0 at uhub0 port 1 configuration 1 interface 0 "vendor 0x0bda ALFA AWUS036NHR" rev 2.00/2.00 addr 2 urtwn0: MAC/BB RTL8188RU, RF 6052 1T1R, address 00:c0:ca:xx:xx:xx -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
define pvbus in conf/files
Hi, when fixing my virtio config breakage, I found the following comment in sys/conf/files, followed by a few bus defines: ---snip--- # Attributes which machine-independent bus support can be attached to. # These should be defined here, because some of these busses can have # devices which provide these attributes, and we'd like to avoid hairy # ordering constraints on inclusion of the busses' "files" files. ---snap--- I think we should follow this rule for pvbus(4) as well. diff below tested with config GENERIC on all archs. OK? Reyk Index: sys/conf/files === RCS file: /cvs/src/sys/conf/files,v retrieving revision 1.638 diff -u -p -u -p -r1.638 files --- sys/conf/files 22 Jan 2017 20:08:10 - 1.638 +++ sys/conf/files 22 Jan 2017 20:11:11 - @@ -444,6 +444,7 @@ define sdmmcbus {} # SD/MMC attachment define btbus {}# Bluetooth host controller define agpbus {} # AGP bridge device virtio {} # VirtIO +define pvbus {}# paravirtual device tree # UHCI USB controller device uhci: usbus Index: sys/dev/pv/files.pv === RCS file: /cvs/src/sys/dev/pv/files.pv,v retrieving revision 1.12 diff -u -p -u -p -r1.12 files.pv --- sys/dev/pv/files.pv 22 Jan 2017 20:08:10 - 1.12 +++ sys/dev/pv/files.pv 22 Jan 2017 20:11:11 - @@ -3,7 +3,6 @@ # Config file and device description for paravirtual devices. # Included by ports that need it. -define pvbus {} device pvbus attach pvbus at mainbus file dev/pv/pvbus.c pvbus needs-flag
rtwn: fix iq calibration
FreeBSD committed a couple of interesting things in r307529 https://svnweb.freebsd.org/base?view=revision=r307529 Unfortunately the commit is a giant patch bomb which makes it hard to pick out individual fixes :-( This patch extracts what I believe "fix IQ calibration bug" refers to. The current code is only ever setting bits but not clearing bits which should be cleared. My diff looks very different because FreeBSD made a lot of style changes in their driver (e.g. they have an rtwn_bb_setbits() function which we don't have). We could think about porting these over but for now I'd like to focus on fixing bugs instead of style. Index: rtwn.c === RCS file: /cvs/src/sys/dev/ic/rtwn.c,v retrieving revision 1.11 diff -u -p -r1.11 rtwn.c --- rtwn.c 8 Jan 2017 05:48:27 - 1.11 +++ rtwn.c 22 Jan 2017 17:50:37 - @@ -2272,9 +2272,10 @@ rtwn_iq_calib_write_results(struct rtwn_ 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); + if (x & 0x0200) + x |= 0xfc00; + reg &= ~0x3ff; + reg |= (((x * val) >> 8) & 0x3ff); rtwn_bb_write(sc, R92C_OFDM0_TXIQIMBALANCE(chain), reg); reg = rtwn_bb_read(sc, R92C_OFDM0_ECCATHRESHOLD); @@ -2289,11 +2290,13 @@ rtwn_iq_calib_write_results(struct rtwn_ y |= 0xfc00; tx_c = (y * val) >> 8; reg = rtwn_bb_read(sc, R92C_OFDM0_TXAFE(chain)); - reg |= tx_c & 0x3c0) >> 6) << 24) & 0xf000); + reg &= ~0xf000; + reg |= ((tx_c & 0x3c0) << 22); rtwn_bb_write(sc, R92C_OFDM0_TXAFE(chain), reg); reg = rtwn_bb_read(sc, R92C_OFDM0_TXIQIMBALANCE(chain)); - reg |= (((tx_c & 0x3f) << 16) & 0x003F); + reg &= ~0x003f; + reg |= ((tx_c & 0x3f) << 16); rtwn_bb_write(sc, R92C_OFDM0_TXIQIMBALANCE(chain), reg); reg = rtwn_bb_read(sc, R92C_OFDM0_ECCATHRESHOLD); @@ -2307,18 +2310,23 @@ rtwn_iq_calib_write_results(struct rtwn_ return; reg = rtwn_bb_read(sc, R92C_OFDM0_RXIQIMBALANCE(chain)); + reg &= ~0x3ff; reg |= (rx[0] & 0x3ff); rtwn_bb_write(sc, R92C_OFDM0_RXIQIMBALANCE(chain), reg); - reg |= (((rx[1] & 0x03f) << 8) & 0xFC00); + + reg &= ~0xfc00; + reg |= ((rx[1] & 0x03f) << 10); 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); + reg &= ~0xf000; + reg |= ((rx[1] & 0x3c0) << 22); rtwn_bb_write(sc, R92C_OFDM0_RXIQEXTANTA, reg); } else { reg = rtwn_bb_read(sc, R92C_OFDM0_AGCRSSITABLE); - reg |= rx[1] & 0xf) >> 6) << 12) & 0xf000); + reg &= ~0xf000; + reg |= ((rx[1] & 0x3c0) << 6); rtwn_bb_write(sc, R92C_OFDM0_AGCRSSITABLE, reg); } }
use ifqueue packet statistics
ifqueues count packets, therefore if_enqueue doesnt have to. this adds reading of the ifq counters into the if_data values so userland still looks right. this is another step toward multiple tx queues. ok? Index: if.c === RCS file: /cvs/src/sys/net/if.c,v retrieving revision 1.475 diff -u -p -r1.475 if.c --- if.c22 Jan 2017 10:17:39 - 1.475 +++ if.c22 Jan 2017 10:35:30 - @@ -583,8 +583,7 @@ if_start_locked(struct ifnet *ifp) int if_enqueue(struct ifnet *ifp, struct mbuf *m) { - int length, error = 0; - unsigned short mflags; + int error = 0; #if NBRIDGE > 0 if (ifp->if_bridgeport && (m->m_flags & M_PROTO1) == 0) { @@ -595,9 +594,6 @@ if_enqueue(struct ifnet *ifp, struct mbu } #endif - length = m->m_pkthdr.len; - mflags = m->m_flags; - #if NPF > 0 pf_pkt_unlink_state_key(m); #endif /* NPF > 0 */ @@ -610,11 +606,6 @@ if_enqueue(struct ifnet *ifp, struct mbu if (error) return (error); - ifp->if_opackets++; - ifp->if_obytes += length; - if (mflags & M_MCAST) - ifp->if_omcasts++; - if_start(ifp); return (0); @@ -1799,10 +1790,13 @@ ifioctl(struct socket *so, u_long cmd, c ifr->ifr_hardmtu = ifp->if_hardmtu; break; - case SIOCGIFDATA: - error = copyout((caddr_t)>if_data, ifr->ifr_data, + case SIOCGIFDATA: { + struct if_data data; + if_data(, ifp); + error = copyout((caddr_t)>if_data, , sizeof(ifp->if_data)); break; + } case SIOCSIFFLAGS: if ((error = suser(p, 0)) != 0) @@ -2167,6 +2161,34 @@ ifconf(u_long cmd, caddr_t data) } ifc->ifc_len -= space; return (error); +} + +void +if_data(struct if_data *data, struct ifnet *ifp) +{ + struct ifqueue *ifq; + uint64_t opackets = 0; + uint64_t obytes = 0; + uint64_t omcasts = 0; + uint64_t oqdrops = 0; + + ifq = >if_snd; + + /* it's ugly reaching into an ifq like this */ + mtx_enter(>ifq_mtx); + opackets += ifq->ifq_packets; + obytes += ifq->ifq_bytes; + oqdrops += ifq->ifq_qdrops; + omcasts += ifq->ifq_mcasts; + /* ifq->ifq_errors */ + mtx_leave(>ifq_mtx); + + *data = ifp->if_data; + data->ifi_opackets += opackets; + data->ifi_obytes += obytes; + data->ifi_oqdrops += oqdrops; + data->ifi_omcasts += omcasts; + /* ifp->if_data.ifi_oerrors */ } /* Index: if.h === RCS file: /cvs/src/sys/net/if.h,v retrieving revision 1.181 diff -u -p -r1.181 if.h --- if.h12 Dec 2016 09:51:30 - 1.181 +++ if.h22 Jan 2017 10:35:30 - @@ -469,6 +469,7 @@ voidif_downall(void); void if_link_state_change(struct ifnet *); void if_up(struct ifnet *); intifconf(u_long, caddr_t); +void if_data(struct if_data *, struct ifnet *); void ifinit(void); intifioctl(struct socket *, u_long, caddr_t, struct proc *); intifpromisc(struct ifnet *, int); Index: rtsock.c === RCS file: /cvs/src/sys/net/rtsock.c,v retrieving revision 1.216 diff -u -p -r1.216 rtsock.c --- rtsock.c22 Jan 2017 04:31:02 - 1.216 +++ rtsock.c22 Jan 2017 10:35:30 - @@ -1268,7 +1268,7 @@ rt_ifmsg(struct ifnet *ifp) ifm->ifm_tableid = ifp->if_rdomain; ifm->ifm_flags = ifp->if_flags; ifm->ifm_xflags = ifp->if_xflags; - ifm->ifm_data = ifp->if_data; + if_data(>ifm_data, ifp); ifm->ifm_addrs = 0; route_input(m, AF_UNSPEC); } @@ -1473,7 +1473,7 @@ sysctl_iflist(int af, struct walkarg *w) ifm->ifm_index = ifp->if_index; ifm->ifm_tableid = ifp->if_rdomain; ifm->ifm_flags = ifp->if_flags; - ifm->ifm_data = ifp->if_data; + if_data(>ifm_data, ifp); ifm->ifm_addrs = info.rti_addrs; error = copyout(ifm, w->w_where, len); if (error)