Re: initial 11ac support for iwm(4)
On 2022/03/16 23:17, Stefan Sperling wrote: > On Wed, Mar 16, 2022 at 04:11:41PM +0100, Stefan Sperling wrote: > > This patch adds initial 11ac support to the iwm(4) driver. > > It allows use of 80 MHz channels and VHT MCS. > > Updated patch. Fixes a fatal firmware error on devices which > do not support MIMO, such as the 3160. Running with this on my X1Y4, seems OK so far but only been running for a short while. I'll leave the ethernet cable out so it gets some more time running. iwm0 at pci0 dev 20 function 3 "Intel AC 9560" rev 0x11, msix iwm0: hw rev 0x310, fw ver 46.4e1ceb39.0, address 50:eb:71:7c:af:5b ifconfig is usually showing VHT-MCS5/6 with occasional blips of 9 $ while true; do ifconfig iwm|grep VHT; sleep .5;done media: IEEE802.11 autoselect (VHT-MCS5 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS6 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS5 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS6 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS5 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS5 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS5 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS5 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS9 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS5 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS6 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS5 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS6 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS6 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS5 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS6 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS6 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS6 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS9 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS6 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS5 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS5 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS5 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS6 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS6 mode 11ac) media: IEEE802.11 autoselect (VHT-MCS9 mode 11ac) ^C Here are the receiver stats, sender is capable of approx filling its Gb port: --- tcpbench server statistics --- 4011036968 bytes received over 132.909 seconds bandwidth min/avg/max/std-dev = 84.660/244.842/263.122/27.239 Mbps I didn't note the exact figures before the diff but it was in the region of 220Mb. AP is one of the mediatek-based unifis (nanohd) running the latest non-beta firmware (6.0.14.13634), about 1.5m away from the laptop, I'm running it with 40MHz chans. ifconfig scan shows: nwid chan 136 bssid 100% HT-MCS31 privacy,spectrum_mgmt,radio_measurement,wpa2 802.11 flags=0<>: beacon, timestamp 267615744056, interval 100, caps=10421, ssid (), rates 6M* 9M 12M* 18M 24M* 36M 48M 54M, ds (chan 136), tim 0x0103, power constraint 0dB, tpcreport 0x3f00, 195:3 0x011e1e, 70:5 0xf20001, 51:6 0x0a6870788088, rsn=, 4 stations, 0% utilization, admission capacity 976us/s, htcaps=<20/40MHz,LDPC,SGI@20MHz,SGI@40MHz,TXSTBC,RXSTBC 1 stream,A-MSDU 3839,A-MPDU max 65535,A-MPDU spacing 4.00us,RxMCS 0x0100>, htop=<40MHz chan 136:132,htprot none,non-greenfield STA,basic MCS set 0x>, 191:12 0xb109cb33aaff1806aaff1806, 192:5 0x00aaff, 127:8 0x0040, vendor 0x0050f202010103a427a442435e0062322f00, 40:6 0x00c81e001400, vendor 0x000c430700, vendor 0x000ce7bf0cb101c0332aff92042aff9204c005002affc303010202, vendor 0x00156d00010100010220ec810674acb915ede5,
Re: pcb mutex userland
On Thu, Mar 17, 2022 at 01:07:12AM +0100, Mark Kettenis wrote: > > Date: Thu, 17 Mar 2022 01:01:46 +0100 (CET) > > From: Mark Kettenis > > > > > Date: Thu, 17 Mar 2022 00:47:15 +0100 > > > From: Alexander Bluhm > > > > > > Hi, > > > > > > My previous atempt to add a mutex to in_pcb.h was reverted as it > > > broke userland build. > > > > > > Is the correct fix to include sys/mutex.h in every .c file that > > > includes netinet/in_pcb.h ? I made a release with it. > > > Or should I include sys/mutex.h in netinet/in_pcb.h ? > > > > Neither? > > > > It makes no sense to export the kernel mutex stuff to userland. Is > > there a way to avoid doing that by adding a bit for #ifdef _KERNEL? > ^ > a bit more My diff adds struct mutex to struct inpcbtable. My later plan is to add a mutex also to struct inpcb. tcpbench uses libkvm to extract information from struct inpcbtable. netstat does that for struct inpcb. Also post mortem analysis from a kernel core dump is possible. I don't understand why userland must not know the size of struct mutex when tools where written to analyze these structs. Is there something special about struct mutex that should not shown to userland? Do you like this? Different structs for kernel and userland. I think this is confusing when used with libkvm. struct inpcbtable { TAILQ_HEAD(inpthead, inpcb) inpt_queue; /* [t] inet PCB queue */ struct inpcbhead *inpt_hashtbl;/* [t] local and foreign hash */ struct inpcbhead *inpt_lhashtbl; /* [t] local port hash */ SIPHASH_KEY inpt_key, inpt_lkey;/* [t] secrets for hashes */ u_long inpt_mask, inpt_lmask; /* [t] hash masks */ int inpt_count, inpt_size; /* [t] queue count, hash size */ #ifdef _KERNEL struct mutex inpt_mtx; /* protect queue and hash */ #endif }; And we have code like this in lib/libkvm/kvm_file2.c #define _KERNEL #include #include #undef _KERNEL Or can we include a minimal non kernel version of sys/mutex.h everywhere? (not tested yet) bluhm Index: netinet/in_pcb.h === RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/in_pcb.h,v retrieving revision 1.125 diff -u -p -r1.125 in_pcb.h --- netinet/in_pcb.h14 Mar 2022 22:38:43 - 1.125 +++ netinet/in_pcb.h17 Mar 2022 00:44:54 - @@ -65,6 +65,7 @@ #define _NETINET_IN_PCB_H_ #include +#include #include #include #include Index: sys/mutex.h === RCS file: /data/mirror/openbsd/cvs/src/sys/sys/mutex.h,v retrieving revision 1.18 diff -u -p -r1.18 mutex.h --- sys/mutex.h 23 Apr 2019 13:35:12 - 1.18 +++ sys/mutex.h 17 Mar 2022 00:44:23 - @@ -48,6 +48,8 @@ struct mutex { #endif }; +#ifdef _KERNEL + /* * To prevent lock ordering problems with the kernel lock, we need to * make sure we block all interrupts that can grab the kernel lock. @@ -148,7 +150,7 @@ void_mtx_init_flags(struct mutex *, int #endif /* WITNESS */ -#if defined(_KERNEL) && defined(DDB) +#ifdef DDB struct db_mutex { struct cpu_info *mtx_owner; @@ -160,6 +162,8 @@ struct db_mutex { void db_mtx_enter(struct db_mutex *); void db_mtx_leave(struct db_mutex *); -#endif /* _KERNEL && DDB */ +#endif /* DDB */ + +#endif /* _KERNEL */ #endif
Re: pcb mutex userland
> Date: Thu, 17 Mar 2022 01:01:46 +0100 (CET) > From: Mark Kettenis > > > Date: Thu, 17 Mar 2022 00:47:15 +0100 > > From: Alexander Bluhm > > > > Hi, > > > > My previous atempt to add a mutex to in_pcb.h was reverted as it > > broke userland build. > > > > Is the correct fix to include sys/mutex.h in every .c file that > > includes netinet/in_pcb.h ? I made a release with it. > > Or should I include sys/mutex.h in netinet/in_pcb.h ? > > Neither? > > It makes no sense to export the kernel mutex stuff to userland. Is > there a way to avoid doing that by adding a bit for #ifdef _KERNEL? ^ a bit more > > Index: lib/libkvm/kvm_file2.c > > === > > RCS file: /data/mirror/openbsd/cvs/src/lib/libkvm/kvm_file2.c,v > > retrieving revision 1.57 > > diff -u -p -r1.57 kvm_file2.c > > --- lib/libkvm/kvm_file2.c 22 Feb 2022 17:35:01 - 1.57 > > +++ lib/libkvm/kvm_file2.c 16 Mar 2022 16:42:15 - > > @@ -74,6 +74,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > Index: sbin/sysctl/sysctl.c > > === > > RCS file: /data/mirror/openbsd/cvs/src/sbin/sysctl/sysctl.c,v > > retrieving revision 1.258 > > diff -u -p -r1.258 sysctl.c > > --- sbin/sysctl/sysctl.c12 Jul 2021 15:09:19 - 1.258 > > +++ sbin/sysctl/sysctl.c15 Mar 2022 09:18:31 - > > @@ -42,9 +42,11 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > + > > #include > > #include > > > > Index: usr.bin/netstat/inet.c > > === > > RCS file: /data/mirror/openbsd/cvs/src/usr.bin/netstat/inet.c,v > > retrieving revision 1.173 > > diff -u -p -r1.173 inet.c > > --- usr.bin/netstat/inet.c 5 Dec 2021 22:36:19 - 1.173 > > +++ usr.bin/netstat/inet.c 16 Mar 2022 16:44:32 - > > @@ -34,6 +34,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #define _KERNEL > > @@ -41,6 +42,7 @@ > > #undef _KERNEL > > > > #include > > + > > #include > > #include > > #include > > Index: usr.bin/tcpbench/tcpbench.c > > === > > RCS file: /data/mirror/openbsd/cvs/src/usr.bin/tcpbench/tcpbench.c,v > > retrieving revision 1.65 > > diff -u -p -r1.65 tcpbench.c > > --- usr.bin/tcpbench/tcpbench.c 12 Jul 2021 15:09:20 - 1.65 > > +++ usr.bin/tcpbench/tcpbench.c 16 Mar 2022 16:44:55 - > > @@ -21,6 +21,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > Index: usr.sbin/trpt/trpt.c > > === > > RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/trpt/trpt.c,v > > retrieving revision 1.39 > > diff -u -p -r1.39 trpt.c > > --- usr.sbin/trpt/trpt.c2 Dec 2019 21:47:54 - 1.39 > > +++ usr.sbin/trpt/trpt.c16 Mar 2022 16:45:23 - > > @@ -62,6 +62,7 @@ > > #include > > #include > > #include > > +#include > > #define PRUREQUESTS > > #include > > #define _KERNEL > > > > > >
Re: pcb mutex userland
> Date: Thu, 17 Mar 2022 00:47:15 +0100 > From: Alexander Bluhm > > Hi, > > My previous atempt to add a mutex to in_pcb.h was reverted as it > broke userland build. > > Is the correct fix to include sys/mutex.h in every .c file that > includes netinet/in_pcb.h ? I made a release with it. > Or should I include sys/mutex.h in netinet/in_pcb.h ? Neither? It makes no sense to export the kernel mutex stuff to userland. Is there a way to avoid doing that by adding a bit for #ifdef _KERNEL? > Index: lib/libkvm/kvm_file2.c > === > RCS file: /data/mirror/openbsd/cvs/src/lib/libkvm/kvm_file2.c,v > retrieving revision 1.57 > diff -u -p -r1.57 kvm_file2.c > --- lib/libkvm/kvm_file2.c22 Feb 2022 17:35:01 - 1.57 > +++ lib/libkvm/kvm_file2.c16 Mar 2022 16:42:15 - > @@ -74,6 +74,7 @@ > #include > #include > #include > +#include > #include > #include > #include > Index: sbin/sysctl/sysctl.c > === > RCS file: /data/mirror/openbsd/cvs/src/sbin/sysctl/sysctl.c,v > retrieving revision 1.258 > diff -u -p -r1.258 sysctl.c > --- sbin/sysctl/sysctl.c 12 Jul 2021 15:09:19 - 1.258 > +++ sbin/sysctl/sysctl.c 15 Mar 2022 09:18:31 - > @@ -42,9 +42,11 @@ > #include > #include > #include > +#include > #include > #include > #include > + > #include > #include > > Index: usr.bin/netstat/inet.c > === > RCS file: /data/mirror/openbsd/cvs/src/usr.bin/netstat/inet.c,v > retrieving revision 1.173 > diff -u -p -r1.173 inet.c > --- usr.bin/netstat/inet.c5 Dec 2021 22:36:19 - 1.173 > +++ usr.bin/netstat/inet.c16 Mar 2022 16:44:32 - > @@ -34,6 +34,7 @@ > #include > #include > #include > +#include > #include > #include > #define _KERNEL > @@ -41,6 +42,7 @@ > #undef _KERNEL > > #include > + > #include > #include > #include > Index: usr.bin/tcpbench/tcpbench.c > === > RCS file: /data/mirror/openbsd/cvs/src/usr.bin/tcpbench/tcpbench.c,v > retrieving revision 1.65 > diff -u -p -r1.65 tcpbench.c > --- usr.bin/tcpbench/tcpbench.c 12 Jul 2021 15:09:20 - 1.65 > +++ usr.bin/tcpbench/tcpbench.c 16 Mar 2022 16:44:55 - > @@ -21,6 +21,7 @@ > #include > #include > #include > +#include > #include > #include > #include > Index: usr.sbin/trpt/trpt.c > === > RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/trpt/trpt.c,v > retrieving revision 1.39 > diff -u -p -r1.39 trpt.c > --- usr.sbin/trpt/trpt.c 2 Dec 2019 21:47:54 - 1.39 > +++ usr.sbin/trpt/trpt.c 16 Mar 2022 16:45:23 - > @@ -62,6 +62,7 @@ > #include > #include > #include > +#include > #define PRUREQUESTS > #include > #define _KERNEL > >
pcb mutex userland
Hi, My previous atempt to add a mutex to in_pcb.h was reverted as it broke userland build. Is the correct fix to include sys/mutex.h in every .c file that includes netinet/in_pcb.h ? I made a release with it. Or should I include sys/mutex.h in netinet/in_pcb.h ? ok? bluhm Index: lib/libkvm/kvm_file2.c === RCS file: /data/mirror/openbsd/cvs/src/lib/libkvm/kvm_file2.c,v retrieving revision 1.57 diff -u -p -r1.57 kvm_file2.c --- lib/libkvm/kvm_file2.c 22 Feb 2022 17:35:01 - 1.57 +++ lib/libkvm/kvm_file2.c 16 Mar 2022 16:42:15 - @@ -74,6 +74,7 @@ #include #include #include +#include #include #include #include Index: sbin/sysctl/sysctl.c === RCS file: /data/mirror/openbsd/cvs/src/sbin/sysctl/sysctl.c,v retrieving revision 1.258 diff -u -p -r1.258 sysctl.c --- sbin/sysctl/sysctl.c12 Jul 2021 15:09:19 - 1.258 +++ sbin/sysctl/sysctl.c15 Mar 2022 09:18:31 - @@ -42,9 +42,11 @@ #include #include #include +#include #include #include #include + #include #include Index: usr.bin/netstat/inet.c === RCS file: /data/mirror/openbsd/cvs/src/usr.bin/netstat/inet.c,v retrieving revision 1.173 diff -u -p -r1.173 inet.c --- usr.bin/netstat/inet.c 5 Dec 2021 22:36:19 - 1.173 +++ usr.bin/netstat/inet.c 16 Mar 2022 16:44:32 - @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #define _KERNEL @@ -41,6 +42,7 @@ #undef _KERNEL #include + #include #include #include Index: usr.bin/tcpbench/tcpbench.c === RCS file: /data/mirror/openbsd/cvs/src/usr.bin/tcpbench/tcpbench.c,v retrieving revision 1.65 diff -u -p -r1.65 tcpbench.c --- usr.bin/tcpbench/tcpbench.c 12 Jul 2021 15:09:20 - 1.65 +++ usr.bin/tcpbench/tcpbench.c 16 Mar 2022 16:44:55 - @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include Index: usr.sbin/trpt/trpt.c === RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/trpt/trpt.c,v retrieving revision 1.39 diff -u -p -r1.39 trpt.c --- usr.sbin/trpt/trpt.c2 Dec 2019 21:47:54 - 1.39 +++ usr.sbin/trpt/trpt.c16 Mar 2022 16:45:23 - @@ -62,6 +62,7 @@ #include #include #include +#include #define PRUREQUESTS #include #define _KERNEL
refcount btrace
Hi, I would like to use btrace to debug refernce counting. The idea is to a a tracepoint for every type of refcnt we have. When it changes, print the actual object, the current counter and the change value. #!/usr/sbin/btrace tracepoint:refcnt:inpcb{ printf("%s %x %u %+d\n", probe, arg0, arg1, arg2) } It should look like this: tracepoint:refcnt:inpcb fd8078e31840 0 +1 tracepoint:refcnt:inpcb fd8078e31840 1 +1 tracepoint:refcnt:inpcb fd8078e31840 2 +1 tracepoint:refcnt:inpcb fd8078e31840 3 -1 tracepoint:refcnt:inpcb fd8078e31840 2 +1 tracepoint:refcnt:inpcb fd8078e31840 3 -1 tracepoint:refcnt:inpcb fd8078e31840 2 -1 tracepoint:refcnt:inpcb fd8078e31840 1 -1 Unfortunately btrace cannot deal with negative numbers right now. So it looks like this, but that can be fixed independently. tracepoint:refcnt:inpcb fd8078e31840 0 +1 tracepoint:refcnt:inpcb fd8078e31840 1 +1 tracepoint:refcnt:inpcb fd8078e31840 2 +1 tracepoint:refcnt:inpcb fd8078e31840 3 +4294967295 tracepoint:refcnt:inpcb fd8078e31840 2 +1 tracepoint:refcnt:inpcb fd8078e31840 3 +4294967295 tracepoint:refcnt:inpcb fd8078e31840 2 +4294967295 tracepoint:refcnt:inpcb fd8078e31840 1 +4294967295 To debug leaks, btrace can also print kernel stack trace. tracepoint:refcnt:inpcb fd8078e31840 0 +1 in_pcballoc+0x92 tcp_attach+0xd1 sonewconn+0x23d syn_cache_get+0x1bf tcp_input+0x885 ip_deliver+0xd3 ip6_input_if+0x762 ipv6_input+0x39 ether_input+0x3a2 if_input_process+0x6f ifiq_process+0x69 taskq_thread+0xdc proc_trampoline+0x17 kernel tracepoint:refcnt:inpcb fd8078e31840 1 +1 in_pcbref+0x29 pf_inp_link+0x4e tcp_input+0x8d2 ip_deliver+0xd3 ip6_input_if+0x762 ipv6_input+0x39 ether_input+0x3a2 if_input_process+0x6f ifiq_process+0x69 taskq_thread+0xdc proc_trampoline+0x17 kernel tracepoint:refcnt:inpcb fd8078e31840 2 +1 in_pcbref+0x29 pf_mbuf_link_inpcb+0x27 tcp_output+0x1455 tcp_usrreq+0x386 sosend+0x37c dofilewritev+0x14d sys_write+0x51 syscall+0x314 Xsyscall+0x128 kernel I register the tracepoint when initializing the refcnt. There exists a global array of possible refcnt types. I implemented it only for inpcb and tdb as a prove of concept. Do we want that feature? bluhm Index: dev/dt/dt_prov_static.c === RCS file: /data/mirror/openbsd/cvs/src/sys/dev/dt/dt_prov_static.c,v retrieving revision 1.12 diff -u -p -r1.12 dt_prov_static.c --- dev/dt/dt_prov_static.c 26 Jan 2022 06:31:31 - 1.12 +++ dev/dt/dt_prov_static.c 16 Mar 2022 23:22:34 - @@ -2,6 +2,7 @@ /* * Copyright (c) 2019 Martin Pieuchot + * Copyright (c) 2022 Alexander Bluhm * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -87,6 +88,12 @@ DT_STATIC_PROBE1(smr, barrier_exit, "int DT_STATIC_PROBE0(smr, wakeup); DT_STATIC_PROBE2(smr, thread, "uint64_t", "uint64_t"); +/* + * reference counting + */ +DT_STATIC_PROBE0(refcnt, none); +DT_STATIC_PROBE3(refcnt, inpcb, "void *", "int", "int"); +DT_STATIC_PROBE3(refcnt, tdb, "void *", "int", "int"); /* * List of all static probes @@ -127,15 +134,24 @@ struct dt_probe *dtps_static[] = { &_DT_STATIC_P(smr, barrier_exit), &_DT_STATIC_P(smr, wakeup), &_DT_STATIC_P(smr, thread), + /* refcnt */ + &_DT_STATIC_P(refcnt, none), + &_DT_STATIC_P(refcnt, inpcb), + &_DT_STATIC_P(refcnt, tdb), }; +struct dt_probe **dtps_index_refcnt; + int dt_prov_static_init(void) { int i; - for (i = 0; i < nitems(dtps_static); i++) + for (i = 0; i < nitems(dtps_static); i++) { + if (dtps_static[i] == &_DT_STATIC_P(refcnt, none)) + dtps_index_refcnt = &dtps_static[i]; dt_dev_register_probe(dtps_static[i]); + } return i; } Index: dev/dt/dtvar.h === RCS file: /data/mirror/openbsd/cvs/src/sys/dev/dt/dtvar.h,v retrieving revision 1.13 diff -u -p -r1.13 dtvar.h --- dev/dt/dtvar.h 27 Feb 2022 10:14:01 - 1.13 +++ dev/dt/dtvar.h 16 Mar 2022 23:22:34 - @@ -2,6 +2,7 @@ /* * Copyright (c) 2019 Martin Pieuchot + * Copyright (c) 2022 Alexander Bluhm * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -313,11 +314,29 @@ extern volatile uint32_t dt_tracing; /* #defineDT_STATIC_ENTER(func, name, args...) do { \ extern struct dt_probe _DT_STATIC_P(func, name);\ struct dt_probe *dtp = &_DT_STATIC_P(func, name); \ - struct dt_provider *dtpv = dtp->dtp_prov; \ \ if (__predict_false(dt_tracing
Re: initial 11ac support for iwm(4)
On Wed, Mar 16, 2022 at 04:11:41PM +0100, Stefan Sperling wrote: > This patch adds initial 11ac support to the iwm(4) driver. > It allows use of 80 MHz channels and VHT MCS. Updated patch. Fixes a fatal firmware error on devices which do not support MIMO, such as the 3160. diff refs/heads/master refs/heads/11ac blob - 7df604d4b6e3913ffeef8c16e7e47637c84af881 blob + 8ed3356b0144a014bece57fa7dcf734624be9fbb --- sys/conf/files +++ sys/conf/files @@ -847,6 +847,7 @@ file net80211/ieee80211_pae_input.c wlan file net80211/ieee80211_pae_output.c wlan file net80211/ieee80211_proto.cwlan file net80211/ieee80211_ra.c wlan +file net80211/ieee80211_ra_vht.c wlan file net80211/ieee80211_rssadapt.c wlan file net80211/ieee80211_regdomain.cwlan file netinet/if_ether.cether blob - 7e0e0f4841d3ba61fcf8335bc21c0df2fb416801 blob + ddb2d586ed0ed8c43da2c38d982d47685db940b3 --- sys/dev/pci/if_iwm.c +++ sys/dev/pci/if_iwm.c @@ -143,6 +143,7 @@ #include #include #include +#include #include #include /* for SEQ_LT */ #undef DPRINTF /* defined in ieee80211_priv.h */ @@ -222,7 +223,7 @@ const struct iwm_rate { #define IWM_RVAL_IS_OFDM(_i_) ((_i_) >= 12 && (_i_) != 22) /* Convert an MCS index into an iwm_rates[] index. */ -const int iwm_mcs2ridx[] = { +const int iwm_ht_mcs2ridx[] = { IWM_RATE_MCS_0_INDEX, IWM_RATE_MCS_1_INDEX, IWM_RATE_MCS_2_INDEX, @@ -247,7 +248,7 @@ struct iwm_nvm_section { }; intiwm_is_mimo_ht_plcp(uint8_t); -intiwm_is_mimo_mcs(int); +intiwm_is_mimo_ht_mcs(int); intiwm_store_cscheme(struct iwm_softc *, uint8_t *, size_t); intiwm_firmware_store_section(struct iwm_softc *, enum iwm_ucode_type, uint8_t *, size_t); @@ -334,6 +335,7 @@ voidiwm_init_channel_map(struct iwm_softc *, const ui const uint8_t *nvm_channels, int nchan); intiwm_mimo_enabled(struct iwm_softc *); void iwm_setup_ht_rates(struct iwm_softc *); +void iwm_setup_vht_rates(struct iwm_softc *); void iwm_mac_ctxt_task(void *); void iwm_phy_ctxt_task(void *); void iwm_updateprot(struct ieee80211com *); @@ -396,6 +398,8 @@ voidiwm_rx_frame(struct iwm_softc *, struct mbuf *, i uint32_t, struct ieee80211_rxinfo *, struct mbuf_list *); void iwm_ht_single_rate_control(struct iwm_softc *, struct ieee80211_node *, int, uint8_t, int); +void iwm_vht_single_rate_control(struct iwm_softc *, struct ieee80211_node *, + int, int, uint8_t, int); void iwm_rx_tx_cmd_single(struct iwm_softc *, struct iwm_rx_packet *, struct iwm_node *, int, int); void iwm_txd_done(struct iwm_softc *, struct iwm_tx_data *); @@ -409,14 +413,15 @@ void iwm_rx_compressed_ba(struct iwm_softc *, struct i void iwm_rx_bmiss(struct iwm_softc *, struct iwm_rx_packet *, struct iwm_rx_data *); intiwm_binding_cmd(struct iwm_softc *, struct iwm_node *, uint32_t); +uint8_tiwm_get_vht_ctrl_pos(struct ieee80211com *, struct ieee80211_channel *); intiwm_phy_ctxt_cmd_uhb(struct iwm_softc *, struct iwm_phy_ctxt *, uint8_t, - uint8_t, uint32_t, uint32_t, uint8_t); + uint8_t, uint32_t, uint32_t, uint8_t, uint8_t); void iwm_phy_ctxt_cmd_hdr(struct iwm_softc *, struct iwm_phy_ctxt *, struct iwm_phy_context_cmd *, uint32_t, uint32_t); void iwm_phy_ctxt_cmd_data(struct iwm_softc *, struct iwm_phy_context_cmd *, - struct ieee80211_channel *, uint8_t, uint8_t, uint8_t); + struct ieee80211_channel *, uint8_t, uint8_t, uint8_t, uint8_t); intiwm_phy_ctxt_cmd(struct iwm_softc *, struct iwm_phy_ctxt *, uint8_t, - uint8_t, uint32_t, uint32_t, uint8_t); + uint8_t, uint32_t, uint32_t, uint8_t, uint8_t); intiwm_send_cmd(struct iwm_softc *, struct iwm_host_cmd *); intiwm_send_cmd_pdu(struct iwm_softc *, uint32_t, uint32_t, uint16_t, const void *); @@ -428,7 +433,7 @@ voidiwm_free_resp(struct iwm_softc *, struct iwm_host void iwm_cmd_done(struct iwm_softc *, int, int, int); void iwm_update_sched(struct iwm_softc *, int, int, uint8_t, uint16_t); void iwm_reset_sched(struct iwm_softc *, int, int, uint8_t); -const struct iwm_rate *iwm_tx_fill_cmd(struct iwm_softc *, struct iwm_node *, +uint8_tiwm_tx_fill_cmd(struct iwm_softc *, struct iwm_node *, struct ieee80211_frame *, struct iwm_tx_cmd *); intiwm_tx(struct iwm_softc *, struct mbuf *, struct ieee80211_node *, int); intiwm_flush_tx_path(struct iwm_softc *, int); @@ -484,7 +489,8 @@ int iwm_umac_scan_abort(struct iwm_softc *); intiwm_lmac_scan_abort(struct iwm_softc *); intiwm_scan_abort(struct iwm_softc *); intiwm_phy_ctxt_update(struct iwm_softc *, struct iwm_phy_ctxt *, - struct ieee80211_channel *, uint8_t, uint8_t, uint32_t, uint8_t); + struct ieee80211_channel *, uint8_t, uint8_t, uint32_t, uint8_t,
Re: Remove data dependency barrier from atomic_load_*
On Tue, Mar 15, 2022 at 09:15:34AM +, Visa Hankala wrote: > However, some DEC Alpha CPUs have their data caches divided into cache > banks to improve bandwidth. These cache banks are relatively > independent. The system maintains coherency, but bus contention can > delay propagation of cache updates. If the loads spanned different cache > banks, the second load could deliver data which is older than the > initial load's value. The data dependency barrier causes an interlock > with cache updating, ensuring causal ordering.) The code with the membar is copied from READ_ONCE() which is copied from Linux. The membar_datadep_consumer() has an #ifdef __alpha__ in it. It is only used for that case. I don't know whether we want to support such CPU. But if that is the case, we need the membar. What do you need refcnt_read() for? Is it only for assert? Then a refcnt_assert() without membar or atomic_load might be better. bluhm > Index: sys/sys/atomic.h > === > RCS file: src/sys/sys/atomic.h,v > retrieving revision 1.8 > diff -u -p -r1.8 atomic.h > --- sys/sys/atomic.h 11 Mar 2022 19:02:15 - 1.8 > +++ sys/sys/atomic.h 15 Mar 2022 07:52:39 - > @@ -201,26 +201,16 @@ atomic_sub_long_nv(volatile unsigned lon > * atomic_load_* - read from memory > */ > > -static inline void membar_datadep_consumer(void); > - > static inline unsigned int > atomic_load_int(volatile unsigned int *p) > { > - unsigned int v; > - > - v = *p; > - membar_datadep_consumer(); > - return v; > + return *p; > } > > static inline unsigned long > atomic_load_long(volatile unsigned long *p) > { > - unsigned long v; > - > - v = *p; > - membar_datadep_consumer(); > - return v; > + return *p; > } > > /*
Re: fix multiple iwm/iwx interfaces
On Wed, Mar 16, 2022 at 08:46:01PM +0100, Jeremie Courreges-Anglas wrote: > On Mon, Mar 14 2022, Stefan Sperling wrote: > > It is currently impossible to use more than one iwm or iwx interface > > in a system because I don't understand C. > > > > Trying to bring up an uninitialized interface anyway results in a > > kernel panic ("bogus channel pointer" from net80211), so prevent > > the device from being used in case we never managed to initialize it. > > > > ok? > > I only tested iwm(4) 8265 but the change makes sense, ok jca@ I will need to revisit this later. Somehow it fails in bsd.rd. The interface remains unusable. Firmware load fails because of rootfs not being mounted yet (expected), and it still doesn't work once firmware becomes available (not expected).
Re: [External] : ipsec acquire mutex refcount
On Mon, Mar 14, 2022 at 11:09:48AM +0100, Alexandr Nedvedicky wrote: > 667 ipsec_delete_policy(struct ipsec_policy *ipo) > > 668 { > 669 struct ipsec_acquire *ipa; > 670 struct radix_node_head *rnh; > 671 struct radix_node *rn = (struct radix_node *)ipo; > > 672 > 673 NET_ASSERT_LOCKED(); > > 674 > 675 if (refcnt_rele(&ipo->ipo_refcnt) == 0) > > 676 return 0; > > 677 > 678 /* Delete from SPD. */ > 679 if ((rnh = spd_table_get(ipo->ipo_rdomain)) == NULL || > 680 rn_delete(&ipo->ipo_addr, &ipo->ipo_mask, rnh, rn) == NULL) > > 681 return (ESRCH); > > the suggestion is not related to your changes, but I think it's worth > to consider as a different diff. I think we should either panic() > at line 681 or we should at least log error. If I understand code > right we delete policy (ipo), which has been fully created so this > error should not happen here. Maybe. If you send a diff, I will test it. > > +ipsp_delete_acquire_locked(struct ipsec_acquire *ipa) > > +{ > > + if (timeout_del(&ipa->ipa_timeout) == 1) > > + refcnt_rele(&ipa->ipa_refcnt); >^^ > can we also put ASSERT/check into this branch > to verify we are no releasing the last > reference to ipa. I suspect we might be doing > an extra reference drop here. Later we call ipsp_unref_acquire_locked() and refcnt_rele() again. This will KASSERT(refcnt != ~0) in the case you describe. > I believe this ASSERT > would be hit if we will compile kernel without IPSEC. > we grab the extra reference iff are adding a timer. We release the extra reference only iff we delete the timer that was added before. > I think this whole ipsp_delete_acquire() logic should > be slightly different. We should call ipsp_unref_acquire_locked(), > when timeout_del() returns 1, because function managed to unschedule > the pending timer. If it returns zero, we should leave things as > they are because timer is running already, waiting for > ipsec_acquire_mtx. As soon as timer will grab mutex, it will > drop the reference for ipa. That's my understanding. > if we go this way then we should not need to grab extra > reference for timer. I copied this logic from tdb. We refcount the pending timers. By checking the return value of timeout_add() and timeout_del() the refcount is correct. And the running timer is counted as reference. At least this works fine with tdb. > > struct ipsec_acquire *ipa; > ^^^ > this needs to be initialized to NULL As mentioned earlier, TAILQ_FOREACH(ipa,...) always initializes ipa. > > - timeout_add_sec(&ipa->ipa_timeout, ipsec_expire_acquire); > > + if (timeout_add_sec(&ipa->ipa_timeout, ipsec_expire_acquire) == 1) > > refcnt_take(&ipa->ipa_refcnt); > ^^^ > line is too long Fixed before commit.
Re: Use refcnt API with struct ucred
On Wed, Mar 16, 2022 at 04:14:05PM +, Visa Hankala wrote: > Use the refcnt API with struct ucred. > > OK? OK bluhm@ > Index: nfs/nfs_socket.c > === > RCS file: src/sys/nfs/nfs_socket.c,v > retrieving revision 1.139 > diff -u -p -r1.139 nfs_socket.c > --- nfs/nfs_socket.c 22 Feb 2022 01:15:02 - 1.139 > +++ nfs/nfs_socket.c 16 Mar 2022 15:42:05 - > @@ -1493,7 +1493,7 @@ nfs_getreq(struct nfsrv_descript *nd, st > nfsm_adv(nfsm_rndup(len)); > nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED); > memset(&nd->nd_cr, 0, sizeof (struct ucred)); > - nd->nd_cr.cr_ref = 1; > + refcnt_init(&nd->nd_cr.cr_refcnt); > nd->nd_cr.cr_uid = fxdr_unsigned(uid_t, *tl++); > nd->nd_cr.cr_gid = fxdr_unsigned(gid_t, *tl++); > len = fxdr_unsigned(int, *tl); > Index: kern/kern_fork.c > === > RCS file: src/sys/kern/kern_fork.c,v > retrieving revision 1.238 > diff -u -p -r1.238 kern_fork.c > --- kern/kern_fork.c 10 Dec 2021 05:34:42 - 1.238 > +++ kern/kern_fork.c 16 Mar 2022 15:42:05 - > @@ -190,7 +190,8 @@ process_initialize(struct process *pr, s > /* give the process the same creds as the initial thread */ > pr->ps_ucred = p->p_ucred; > crhold(pr->ps_ucred); > - KASSERT(p->p_ucred->cr_ref >= 2); /* new thread and new process */ > + /* new thread and new process */ > + KASSERT(p->p_ucred->cr_refcnt.r_refs >= 2); > > LIST_INIT(&pr->ps_children); > LIST_INIT(&pr->ps_orphans); > Index: kern/kern_prot.c > === > RCS file: src/sys/kern/kern_prot.c,v > retrieving revision 1.78 > diff -u -p -r1.78 kern_prot.c > --- kern/kern_prot.c 24 Oct 2021 00:02:25 - 1.78 > +++ kern/kern_prot.c 16 Mar 2022 15:42:05 - > @@ -57,7 +57,7 @@ > inline void > crset(struct ucred *newcr, const struct ucred *cr) > { > - KASSERT(cr->cr_ref > 0); > + KASSERT(cr->cr_refcnt.r_refs > 0); > memcpy( > (char *)newcr+ offsetof(struct ucred, cr_startcopy), > (const char *)cr + offsetof(struct ucred, cr_startcopy), > @@ -945,7 +945,7 @@ crget(void) > struct ucred *cr; > > cr = pool_get(&ucred_pool, PR_WAITOK|PR_ZERO); > - cr->cr_ref = 1; > + refcnt_init(&cr->cr_refcnt); > return (cr); > } > > @@ -956,7 +956,7 @@ crget(void) > struct ucred * > crhold(struct ucred *cr) > { > - atomic_inc_int(&cr->cr_ref); > + refcnt_take(&cr->cr_refcnt); > return (cr); > } > > @@ -967,8 +967,7 @@ crhold(struct ucred *cr) > void > crfree(struct ucred *cr) > { > - > - if (atomic_dec_int_nv(&cr->cr_ref) == 0) > + if (refcnt_rele(&cr->cr_refcnt)) > pool_put(&ucred_pool, cr); > } > > @@ -980,12 +979,12 @@ crcopy(struct ucred *cr) > { > struct ucred *newcr; > > - if (cr->cr_ref == 1) > + if (!refcnt_shared(&cr->cr_refcnt)) > return (cr); > newcr = crget(); > *newcr = *cr; > crfree(cr); > - newcr->cr_ref = 1; > + refcnt_init(&newcr->cr_refcnt); > return (newcr); > } > > @@ -999,7 +998,7 @@ crdup(struct ucred *cr) > > newcr = crget(); > *newcr = *cr; > - newcr->cr_ref = 1; > + refcnt_init(&newcr->cr_refcnt); > return (newcr); > } > > @@ -1011,7 +1010,7 @@ crfromxucred(struct ucred *cr, const str > { > if (xcr->cr_ngroups < 0 || xcr->cr_ngroups > NGROUPS_MAX) > return (EINVAL); > - cr->cr_ref = 1; > + refcnt_init(&cr->cr_refcnt); > cr->cr_uid = xcr->cr_uid; > cr->cr_gid = xcr->cr_gid; > cr->cr_ngroups = xcr->cr_ngroups; > Index: sys/ucred.h > === > RCS file: src/sys/sys/ucred.h,v > retrieving revision 1.13 > diff -u -p -r1.13 ucred.h > --- sys/ucred.h 21 Jun 2018 13:58:21 - 1.13 > +++ sys/ucred.h 16 Mar 2022 15:42:05 - > @@ -35,13 +35,14 @@ > #ifndef _SYS_UCRED_H_ > #define _SYS_UCRED_H_ > > +#include > #include > > /* > * Credentials. > */ > struct ucred { > - u_int cr_ref; /* reference count */ > + struct refcnt cr_refcnt; /* reference count */ > > /* The following fields are all copied by crset() */ > #define cr_startcopycr_uid
Re: Use refcnt API in bpf
On Wed, Mar 16, 2022 at 04:11:43PM +, Visa Hankala wrote: > Use the refcnt API in bpf. > > OK? OK bluhm@ > Index: net/bpf.c > === > RCS file: src/sys/net/bpf.c,v > retrieving revision 1.215 > diff -u -p -r1.215 bpf.c > --- net/bpf.c 15 Feb 2022 08:43:50 - 1.215 > +++ net/bpf.c 16 Mar 2022 15:42:05 - > @@ -55,6 +55,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -398,7 +399,7 @@ bpfopen(dev_t dev, int flag, int mode, s > > bd->bd_rtout = 0; /* no timeout by default */ > > - bpf_get(bd); > + refcnt_init(&bd->bd_refcnt); > LIST_INSERT_HEAD(&bpf_d_list, bd, bd_list); > > return (0); > @@ -1645,7 +1646,7 @@ bpf_d_smr(void *smr) > void > bpf_get(struct bpf_d *bd) > { > - atomic_inc_int(&bd->bd_ref); > + refcnt_take(&bd->bd_refcnt); > } > > /* > @@ -1655,7 +1656,7 @@ bpf_get(struct bpf_d *bd) > void > bpf_put(struct bpf_d *bd) > { > - if (atomic_dec_int_nv(&bd->bd_ref) > 0) > + if (refcnt_rele(&bd->bd_refcnt) == 0) > return; > > smr_call(&bd->bd_smr, bpf_d_smr, bd); > Index: net/bpfdesc.h > === > RCS file: src/sys/net/bpfdesc.h,v > retrieving revision 1.45 > diff -u -p -r1.45 bpfdesc.h > --- net/bpfdesc.h 21 Jan 2021 12:33:14 - 1.45 > +++ net/bpfdesc.h 16 Mar 2022 15:42:05 - > @@ -98,7 +98,7 @@ struct bpf_d { > int bd_sig; /* signal to send upon packet reception > */ > struct sigio_ref > bd_sigio; /* async I/O registration */ > - u_int bd_ref; /* reference count */ > + struct refcnt bd_refcnt; /* reference count */ > struct selinfo bd_sel; /* bsd select info */ > int bd_unit;/* logical unit number */ > LIST_ENTRY(bpf_d) bd_list; /* descriptor list */
Re: fix multiple iwm/iwx interfaces
On Mon, Mar 14 2022, Stefan Sperling wrote: > It is currently impossible to use more than one iwm or iwx interface > in a system because I don't understand C. > > Trying to bring up an uninitialized interface anyway results in a > kernel panic ("bogus channel pointer" from net80211), so prevent > the device from being used in case we never managed to initialize it. > > ok? I only tested iwm(4) 8265 but the change makes sense, ok jca@ -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: initial 11ac support for iwm(4)
On Wed, Mar 16, 2022 at 04:11:41PM +0100, Stefan Sperling wrote: > This patch adds initial 11ac support to the iwm(4) driver. > It allows use of 80 MHz channels and VHT MCS. > In net80211 I added a new rate control module to support VHT rates, as > a new file called ieee80211_ra_vht.c, derived from ieee80211_ra.c which > we use in 11n mode. The task of this code is to determine the fastest > VHT rate that is usable. (This was not needed to add 11ac support to > iwx(4) because iwx(4) devices perform this task in firmware.) > Retries at lower rates must be handled by the driver. iwm(4) does this via > the "LQ" command which sends a table of Tx rates the firmware should use. > So far, I have tested this successfully on iwm(4) 8265. > In my testing performance peaks at around 250Mbit/s. > There is no device-specific code involved so I would expect this to > work on all cards supported by the driver. > I will test a few more devices I have here soon, but I don't have > access to all iwm(4) hardware variants at the moment. Testing on any > iwm(4) device would be appreciated. Please be precise about which model > of iwm(4) you are testing on when reporting results. Working great so far on the 9560 in my T490. I've been seeing VHT-MCS5 and VHT-MCS6. --Kurt > diff refs/heads/master refs/heads/11ac > blob - 7df604d4b6e3913ffeef8c16e7e47637c84af881 > blob + 8ed3356b0144a014bece57fa7dcf734624be9fbb > --- sys/conf/files > +++ sys/conf/files > @@ -847,6 +847,7 @@ file net80211/ieee80211_pae_input.c wlan > file net80211/ieee80211_pae_output.c wlan > file net80211/ieee80211_proto.c wlan > file net80211/ieee80211_ra.c wlan > +file net80211/ieee80211_ra_vht.c wlan > file net80211/ieee80211_rssadapt.c wlan > file net80211/ieee80211_regdomain.c wlan > file netinet/if_ether.c ether > blob - 7e0e0f4841d3ba61fcf8335bc21c0df2fb416801 > blob + ddb2d586ed0ed8c43da2c38d982d47685db940b3 > --- sys/dev/pci/if_iwm.c > +++ sys/dev/pci/if_iwm.c > @@ -143,6 +143,7 @@ > #include > #include > #include > +#include > #include > #include /* for SEQ_LT */ > #undef DPRINTF /* defined in ieee80211_priv.h */ > @@ -222,7 +223,7 @@ const struct iwm_rate { > #define IWM_RVAL_IS_OFDM(_i_) ((_i_) >= 12 && (_i_) != 22) > > /* Convert an MCS index into an iwm_rates[] index. */ > -const int iwm_mcs2ridx[] = { > +const int iwm_ht_mcs2ridx[] = { > IWM_RATE_MCS_0_INDEX, > IWM_RATE_MCS_1_INDEX, > IWM_RATE_MCS_2_INDEX, > @@ -247,7 +248,7 @@ struct iwm_nvm_section { > }; > > int iwm_is_mimo_ht_plcp(uint8_t); > -int iwm_is_mimo_mcs(int); > +int iwm_is_mimo_ht_mcs(int); > int iwm_store_cscheme(struct iwm_softc *, uint8_t *, size_t); > int iwm_firmware_store_section(struct iwm_softc *, enum iwm_ucode_type, > uint8_t *, size_t); > @@ -334,6 +335,7 @@ void iwm_init_channel_map(struct iwm_softc *, const > ui > const uint8_t *nvm_channels, int nchan); > int iwm_mimo_enabled(struct iwm_softc *); > void iwm_setup_ht_rates(struct iwm_softc *); > +void iwm_setup_vht_rates(struct iwm_softc *); > void iwm_mac_ctxt_task(void *); > void iwm_phy_ctxt_task(void *); > void iwm_updateprot(struct ieee80211com *); > @@ -396,6 +398,8 @@ void iwm_rx_frame(struct iwm_softc *, struct mbuf *, > i > uint32_t, struct ieee80211_rxinfo *, struct mbuf_list *); > void iwm_ht_single_rate_control(struct iwm_softc *, struct ieee80211_node *, > int, uint8_t, int); > +void iwm_vht_single_rate_control(struct iwm_softc *, struct ieee80211_node *, > + int, int, uint8_t, int); > void iwm_rx_tx_cmd_single(struct iwm_softc *, struct iwm_rx_packet *, > struct iwm_node *, int, int); > void iwm_txd_done(struct iwm_softc *, struct iwm_tx_data *); > @@ -409,14 +413,15 @@ voidiwm_rx_compressed_ba(struct iwm_softc *, struct > i > void iwm_rx_bmiss(struct iwm_softc *, struct iwm_rx_packet *, > struct iwm_rx_data *); > int iwm_binding_cmd(struct iwm_softc *, struct iwm_node *, uint32_t); > +uint8_t iwm_get_vht_ctrl_pos(struct ieee80211com *, struct > ieee80211_channel *); > int iwm_phy_ctxt_cmd_uhb(struct iwm_softc *, struct iwm_phy_ctxt *, uint8_t, > - uint8_t, uint32_t, uint32_t, uint8_t); > + uint8_t, uint32_t, uint32_t, uint8_t, uint8_t); > void iwm_phy_ctxt_cmd_hdr(struct iwm_softc *, struct iwm_phy_ctxt *, > struct iwm_phy_context_cmd *, uint32_t, uint32_t); > void iwm_phy_ctxt_cmd_data(struct iwm_softc *, struct iwm_phy_context_cmd *, > - struct ieee80211_channel *, uint8_t, uint8_t, uint8_t); > + struct ieee80211_channel *, uint8_t, uint8_t, uint8_t, uint8_t); > int iwm_phy_ctxt_cmd(struct iwm_softc *, struct iwm_phy_ctxt *, uint8_t, > - uint8_t, uint32_t, uint32_t, uint8_t); > + uint8_t, uint32_t, uint32_t, uint8_t, uint8_t); > int iwm_send_cmd(struct iwm_softc *, struct iwm_host_cmd *); > int iwm_send_cmd_pdu(struct iwm_soft
Re: initial 11ac support for iwm(4)
This works fine on iwm0 at pci1 dev 0 function 0 "Intel Dual Band Wireless-AC 9260" rev 0x29, msix iwm0: hw rev 0x320, fw ver 46.4e1ceb39.0 and iwm0 at pci2 dev 0 function 0 "Intel AC 7260" rev 0x83, msi iwm0: hw rev 0x140, fw ver 17.3216344376.0 against UniFi UAP-AC-SHD and UAP-AC-Pro. I have also tested roaming between the APs. There is no intereference on the channels by other APs but other devices get air time. server means tcpbench -s on the laptop, target is a VM that can handle gbit/s speeds. 9260 $ tail -1 tcpbench_11{n,ac}.log tcpbench_server_11{n,ac}.log ==> tcpbench_11n.log <== bandwidth min/avg/max/std-dev = 50.917/141.416/175.932/24.805 Mbps ==> tcpbench_11ac.log <== bandwidth min/avg/max/std-dev = 80.264/252.530/301.530/51.497 Mbps ==> tcpbench_server_11n.log <== bandwidth min/avg/max/std-dev = 25.797/79.505/146.893/26.857 Mbps ==> tcpbench_server_11ac.log <== bandwidth min/avg/max/std-dev = 70.532/235.260/316.520/61.451 Mbps 7260 $ tail -1 tcpbench_11{n,ac}.log tcpbench_server_11{n,ac}.log ==> tcpbench_11n.log <== bandwidth min/avg/max/std-dev = 42.412/179.054/201.801/32.961 Mbps ==> tcpbench_11ac.log <== bandwidth min/avg/max/std-dev = 90.708/237.702/311.002/50.290 Mbps ==> tcpbench_server_11n.log <== bandwidth min/avg/max/std-dev = 61.289/153.094/185.233/29.192 Mbps ==> tcpbench_server_11ac.log <== bandwidth min/avg/max/std-dev = 29.161/170.507/234.489/46.218 Mbps -- I'm not entirely sure you are real.
Re: initial 11ac support for iwm(4)
On Wed, Mar 16, 2022 at 04:11:41PM +0100, Stefan Sperling wrote: > This patch adds initial 11ac support to the iwm(4) driver. > It allows use of 80 MHz channels and VHT MCS. > > In net80211 I added a new rate control module to support VHT rates, as > a new file called ieee80211_ra_vht.c, derived from ieee80211_ra.c which > we use in 11n mode. The task of this code is to determine the fastest > VHT rate that is usable. (This was not needed to add 11ac support to > iwx(4) because iwx(4) devices perform this task in firmware.) > Retries at lower rates must be handled by the driver. iwm(4) does this via > the "LQ" command which sends a table of Tx rates the firmware should use. > > So far, I have tested this successfully on iwm(4) 8265. > In my testing performance peaks at around 250Mbit/s. > There is no device-specific code involved so I would expect this to > work on all cards supported by the driver. > > I will test a few more devices I have here soon, but I don't have > access to all iwm(4) hardware variants at the moment. Testing on any > iwm(4) device would be appreciated. Please be precise about which model > of iwm(4) you are testing on when reporting results. > No issues on my iwm(4) 8265 either. Seeing around 250Mbit/s here as well! Thanks for all the work on these devices. James
Re: [External] : Use refcnt API in bpf
On Wed, Mar 16, 2022 at 04:11:43PM +, Visa Hankala wrote: > Use the refcnt API in bpf. > > OK? Looks OK to me. sashan
Use refcnt API with struct ucred
Use the refcnt API with struct ucred. OK? Index: nfs/nfs_socket.c === RCS file: src/sys/nfs/nfs_socket.c,v retrieving revision 1.139 diff -u -p -r1.139 nfs_socket.c --- nfs/nfs_socket.c22 Feb 2022 01:15:02 - 1.139 +++ nfs/nfs_socket.c16 Mar 2022 15:42:05 - @@ -1493,7 +1493,7 @@ nfs_getreq(struct nfsrv_descript *nd, st nfsm_adv(nfsm_rndup(len)); nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED); memset(&nd->nd_cr, 0, sizeof (struct ucred)); - nd->nd_cr.cr_ref = 1; + refcnt_init(&nd->nd_cr.cr_refcnt); nd->nd_cr.cr_uid = fxdr_unsigned(uid_t, *tl++); nd->nd_cr.cr_gid = fxdr_unsigned(gid_t, *tl++); len = fxdr_unsigned(int, *tl); Index: kern/kern_fork.c === RCS file: src/sys/kern/kern_fork.c,v retrieving revision 1.238 diff -u -p -r1.238 kern_fork.c --- kern/kern_fork.c10 Dec 2021 05:34:42 - 1.238 +++ kern/kern_fork.c16 Mar 2022 15:42:05 - @@ -190,7 +190,8 @@ process_initialize(struct process *pr, s /* give the process the same creds as the initial thread */ pr->ps_ucred = p->p_ucred; crhold(pr->ps_ucred); - KASSERT(p->p_ucred->cr_ref >= 2); /* new thread and new process */ + /* new thread and new process */ + KASSERT(p->p_ucred->cr_refcnt.r_refs >= 2); LIST_INIT(&pr->ps_children); LIST_INIT(&pr->ps_orphans); Index: kern/kern_prot.c === RCS file: src/sys/kern/kern_prot.c,v retrieving revision 1.78 diff -u -p -r1.78 kern_prot.c --- kern/kern_prot.c24 Oct 2021 00:02:25 - 1.78 +++ kern/kern_prot.c16 Mar 2022 15:42:05 - @@ -57,7 +57,7 @@ inline void crset(struct ucred *newcr, const struct ucred *cr) { - KASSERT(cr->cr_ref > 0); + KASSERT(cr->cr_refcnt.r_refs > 0); memcpy( (char *)newcr+ offsetof(struct ucred, cr_startcopy), (const char *)cr + offsetof(struct ucred, cr_startcopy), @@ -945,7 +945,7 @@ crget(void) struct ucred *cr; cr = pool_get(&ucred_pool, PR_WAITOK|PR_ZERO); - cr->cr_ref = 1; + refcnt_init(&cr->cr_refcnt); return (cr); } @@ -956,7 +956,7 @@ crget(void) struct ucred * crhold(struct ucred *cr) { - atomic_inc_int(&cr->cr_ref); + refcnt_take(&cr->cr_refcnt); return (cr); } @@ -967,8 +967,7 @@ crhold(struct ucred *cr) void crfree(struct ucred *cr) { - - if (atomic_dec_int_nv(&cr->cr_ref) == 0) + if (refcnt_rele(&cr->cr_refcnt)) pool_put(&ucred_pool, cr); } @@ -980,12 +979,12 @@ crcopy(struct ucred *cr) { struct ucred *newcr; - if (cr->cr_ref == 1) + if (!refcnt_shared(&cr->cr_refcnt)) return (cr); newcr = crget(); *newcr = *cr; crfree(cr); - newcr->cr_ref = 1; + refcnt_init(&newcr->cr_refcnt); return (newcr); } @@ -999,7 +998,7 @@ crdup(struct ucred *cr) newcr = crget(); *newcr = *cr; - newcr->cr_ref = 1; + refcnt_init(&newcr->cr_refcnt); return (newcr); } @@ -1011,7 +1010,7 @@ crfromxucred(struct ucred *cr, const str { if (xcr->cr_ngroups < 0 || xcr->cr_ngroups > NGROUPS_MAX) return (EINVAL); - cr->cr_ref = 1; + refcnt_init(&cr->cr_refcnt); cr->cr_uid = xcr->cr_uid; cr->cr_gid = xcr->cr_gid; cr->cr_ngroups = xcr->cr_ngroups; Index: sys/ucred.h === RCS file: src/sys/sys/ucred.h,v retrieving revision 1.13 diff -u -p -r1.13 ucred.h --- sys/ucred.h 21 Jun 2018 13:58:21 - 1.13 +++ sys/ucred.h 16 Mar 2022 15:42:05 - @@ -35,13 +35,14 @@ #ifndef _SYS_UCRED_H_ #define_SYS_UCRED_H_ +#include #include /* * Credentials. */ struct ucred { - u_int cr_ref; /* reference count */ + struct refcnt cr_refcnt; /* reference count */ /* The following fields are all copied by crset() */ #definecr_startcopycr_uid
Use refcnt API in bpf
Use the refcnt API in bpf. OK? Index: net/bpf.c === RCS file: src/sys/net/bpf.c,v retrieving revision 1.215 diff -u -p -r1.215 bpf.c --- net/bpf.c 15 Feb 2022 08:43:50 - 1.215 +++ net/bpf.c 16 Mar 2022 15:42:05 - @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -398,7 +399,7 @@ bpfopen(dev_t dev, int flag, int mode, s bd->bd_rtout = 0; /* no timeout by default */ - bpf_get(bd); + refcnt_init(&bd->bd_refcnt); LIST_INSERT_HEAD(&bpf_d_list, bd, bd_list); return (0); @@ -1645,7 +1646,7 @@ bpf_d_smr(void *smr) void bpf_get(struct bpf_d *bd) { - atomic_inc_int(&bd->bd_ref); + refcnt_take(&bd->bd_refcnt); } /* @@ -1655,7 +1656,7 @@ bpf_get(struct bpf_d *bd) void bpf_put(struct bpf_d *bd) { - if (atomic_dec_int_nv(&bd->bd_ref) > 0) + if (refcnt_rele(&bd->bd_refcnt) == 0) return; smr_call(&bd->bd_smr, bpf_d_smr, bd); Index: net/bpfdesc.h === RCS file: src/sys/net/bpfdesc.h,v retrieving revision 1.45 diff -u -p -r1.45 bpfdesc.h --- net/bpfdesc.h 21 Jan 2021 12:33:14 - 1.45 +++ net/bpfdesc.h 16 Mar 2022 15:42:05 - @@ -98,7 +98,7 @@ struct bpf_d { int bd_sig; /* signal to send upon packet reception */ struct sigio_ref bd_sigio; /* async I/O registration */ - u_int bd_ref; /* reference count */ + struct refcnt bd_refcnt; /* reference count */ struct selinfo bd_sel; /* bsd select info */ int bd_unit;/* logical unit number */ LIST_ENTRY(bpf_d) bd_list; /* descriptor list */
initial 11ac support for iwm(4)
This patch adds initial 11ac support to the iwm(4) driver. It allows use of 80 MHz channels and VHT MCS. In net80211 I added a new rate control module to support VHT rates, as a new file called ieee80211_ra_vht.c, derived from ieee80211_ra.c which we use in 11n mode. The task of this code is to determine the fastest VHT rate that is usable. (This was not needed to add 11ac support to iwx(4) because iwx(4) devices perform this task in firmware.) Retries at lower rates must be handled by the driver. iwm(4) does this via the "LQ" command which sends a table of Tx rates the firmware should use. So far, I have tested this successfully on iwm(4) 8265. In my testing performance peaks at around 250Mbit/s. There is no device-specific code involved so I would expect this to work on all cards supported by the driver. I will test a few more devices I have here soon, but I don't have access to all iwm(4) hardware variants at the moment. Testing on any iwm(4) device would be appreciated. Please be precise about which model of iwm(4) you are testing on when reporting results. diff refs/heads/master refs/heads/11ac blob - 7df604d4b6e3913ffeef8c16e7e47637c84af881 blob + 8ed3356b0144a014bece57fa7dcf734624be9fbb --- sys/conf/files +++ sys/conf/files @@ -847,6 +847,7 @@ file net80211/ieee80211_pae_input.c wlan file net80211/ieee80211_pae_output.c wlan file net80211/ieee80211_proto.cwlan file net80211/ieee80211_ra.c wlan +file net80211/ieee80211_ra_vht.c wlan file net80211/ieee80211_rssadapt.c wlan file net80211/ieee80211_regdomain.cwlan file netinet/if_ether.cether blob - 7e0e0f4841d3ba61fcf8335bc21c0df2fb416801 blob + ddb2d586ed0ed8c43da2c38d982d47685db940b3 --- sys/dev/pci/if_iwm.c +++ sys/dev/pci/if_iwm.c @@ -143,6 +143,7 @@ #include #include #include +#include #include #include /* for SEQ_LT */ #undef DPRINTF /* defined in ieee80211_priv.h */ @@ -222,7 +223,7 @@ const struct iwm_rate { #define IWM_RVAL_IS_OFDM(_i_) ((_i_) >= 12 && (_i_) != 22) /* Convert an MCS index into an iwm_rates[] index. */ -const int iwm_mcs2ridx[] = { +const int iwm_ht_mcs2ridx[] = { IWM_RATE_MCS_0_INDEX, IWM_RATE_MCS_1_INDEX, IWM_RATE_MCS_2_INDEX, @@ -247,7 +248,7 @@ struct iwm_nvm_section { }; intiwm_is_mimo_ht_plcp(uint8_t); -intiwm_is_mimo_mcs(int); +intiwm_is_mimo_ht_mcs(int); intiwm_store_cscheme(struct iwm_softc *, uint8_t *, size_t); intiwm_firmware_store_section(struct iwm_softc *, enum iwm_ucode_type, uint8_t *, size_t); @@ -334,6 +335,7 @@ voidiwm_init_channel_map(struct iwm_softc *, const ui const uint8_t *nvm_channels, int nchan); intiwm_mimo_enabled(struct iwm_softc *); void iwm_setup_ht_rates(struct iwm_softc *); +void iwm_setup_vht_rates(struct iwm_softc *); void iwm_mac_ctxt_task(void *); void iwm_phy_ctxt_task(void *); void iwm_updateprot(struct ieee80211com *); @@ -396,6 +398,8 @@ voidiwm_rx_frame(struct iwm_softc *, struct mbuf *, i uint32_t, struct ieee80211_rxinfo *, struct mbuf_list *); void iwm_ht_single_rate_control(struct iwm_softc *, struct ieee80211_node *, int, uint8_t, int); +void iwm_vht_single_rate_control(struct iwm_softc *, struct ieee80211_node *, + int, int, uint8_t, int); void iwm_rx_tx_cmd_single(struct iwm_softc *, struct iwm_rx_packet *, struct iwm_node *, int, int); void iwm_txd_done(struct iwm_softc *, struct iwm_tx_data *); @@ -409,14 +413,15 @@ void iwm_rx_compressed_ba(struct iwm_softc *, struct i void iwm_rx_bmiss(struct iwm_softc *, struct iwm_rx_packet *, struct iwm_rx_data *); intiwm_binding_cmd(struct iwm_softc *, struct iwm_node *, uint32_t); +uint8_tiwm_get_vht_ctrl_pos(struct ieee80211com *, struct ieee80211_channel *); intiwm_phy_ctxt_cmd_uhb(struct iwm_softc *, struct iwm_phy_ctxt *, uint8_t, - uint8_t, uint32_t, uint32_t, uint8_t); + uint8_t, uint32_t, uint32_t, uint8_t, uint8_t); void iwm_phy_ctxt_cmd_hdr(struct iwm_softc *, struct iwm_phy_ctxt *, struct iwm_phy_context_cmd *, uint32_t, uint32_t); void iwm_phy_ctxt_cmd_data(struct iwm_softc *, struct iwm_phy_context_cmd *, - struct ieee80211_channel *, uint8_t, uint8_t, uint8_t); + struct ieee80211_channel *, uint8_t, uint8_t, uint8_t, uint8_t); intiwm_phy_ctxt_cmd(struct iwm_softc *, struct iwm_phy_ctxt *, uint8_t, - uint8_t, uint32_t, uint32_t, uint8_t); + uint8_t, uint32_t, uint32_t, uint8_t, uint8_t); intiwm_send_cmd(struct iwm_softc *, struct iwm_host_cmd *); intiwm_send_cmd_pdu(struct iwm_softc *, uint32_t, uint32_t, uint16_t, const void *); @@ -428,7 +433,7 @@ voidiwm_free_resp(struct iwm_softc *, struct iwm_host void iwm_cmd_done(struct iwm_softc *, int, int, int); void iwm_update_sched(struct iwm_softc *, int, int, uint8
Re: Use refcnt API in kqueue
On Tue, Mar 15, 2022 at 02:12:43PM +, Visa Hankala wrote: > Make kqueue use the refcnt API. > > OK? OK bluhm@ > Index: sys/kern/kern_event.c > === > RCS file: src/sys/kern/kern_event.c,v > retrieving revision 1.183 > diff -u -p -r1.183 kern_event.c > --- sys/kern/kern_event.c 22 Feb 2022 01:15:01 - 1.183 > +++ sys/kern/kern_event.c 15 Mar 2022 13:43:20 - > @@ -199,7 +199,7 @@ const struct filterops *const sysfilt_op > void > KQREF(struct kqueue *kq) > { > - atomic_inc_int(&kq->kq_refs); > + refcnt_take(&kq->kq_refcnt); > } > > void > @@ -207,7 +207,7 @@ KQRELE(struct kqueue *kq) > { > struct filedesc *fdp; > > - if (atomic_dec_int_nv(&kq->kq_refs) > 0) > + if (refcnt_rele(&kq->kq_refcnt) == 0) > return; > > fdp = kq->kq_fdp; > @@ -837,7 +837,7 @@ kqpoll_exit(void) > > kqueue_purge(p, p->p_kq); > kqueue_terminate(p, p->p_kq); > - KASSERT(p->p_kq->kq_refs == 1); > + KASSERT(p->p_kq->kq_refcnt.r_refs == 1); > KQRELE(p->p_kq); > p->p_kq = NULL; > } > @@ -848,7 +848,7 @@ kqueue_alloc(struct filedesc *fdp) > struct kqueue *kq; > > kq = pool_get(&kqueue_pool, PR_WAITOK | PR_ZERO); > - kq->kq_refs = 1; > + refcnt_init(&kq->kq_refcnt); > kq->kq_fdp = fdp; > TAILQ_INIT(&kq->kq_head); > mtx_init(&kq->kq_lock, IPL_HIGH); > Index: sys/sys/eventvar.h > === > RCS file: src/sys/sys/eventvar.h,v > retrieving revision 1.13 > diff -u -p -r1.13 eventvar.h > --- sys/sys/eventvar.h8 Feb 2022 08:56:41 - 1.13 > +++ sys/sys/eventvar.h15 Mar 2022 13:43:20 - > @@ -32,6 +32,7 @@ > #define _SYS_EVENTVAR_H_ > > #include > +#include > #include > > #define KQ_NEVENTS 8 /* minimize copy{in,out} calls */ > @@ -47,7 +48,7 @@ struct kqueue { > struct mutex kq_lock; /* lock for queue access */ > TAILQ_HEAD(, knote) kq_head;/* [q] list of pending event */ > int kq_count; /* [q] # of pending events */ > - u_int kq_refs;/* [a] # of references */ > + struct refcnt kq_refcnt; /* [a] # of references */ > struct selinfo kq_sel; > struct filedesc *kq_fdp; /* [I] fd table of this kq */ >
Re: PATCH: speed up pkg_add
I got a new slightly different one. Specifically, the old one has a "fun" failure mode in case an old package got broken and is missing files. The heuristics correctly deduces that the files are not there, so it extracts in-place... then pkg_delete promptly deletes what it believes to be files from the old package! so the broken install stays broken. The fix is fairly obvious: I store a hash of filenames not to delete in the current_set, instead of doing it only for tied objects (other objects we don't quite know where they live in the old plist, nor do we care all that much) (I could also probably check modes and owners for tied files since we do a stat anyway, but new files will have to get utime'd to the new ts, so I doubt I'll see any gain from that, and it gets way too complicated for its own good) Index: OpenBSD/Add.pm === RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/Add.pm,v retrieving revision 1.187 diff -u -p -r1.187 Add.pm --- OpenBSD/Add.pm 9 Mar 2022 12:27:51 - 1.187 +++ OpenBSD/Add.pm 16 Mar 2022 10:33:19 - @@ -466,6 +466,7 @@ sub find_safe_dir my $fullname = $self->fullname; my $filename = $state->{destdir}.$fullname; my $d = dirname($filename); + my $orig = $d; # we go back up until we find an existing directory. # hopefully this will be on the same file system. @@ -483,6 +484,12 @@ sub find_safe_dir if (!-e _ && !$state->{not}) { $state->make_path($d, $fullname); } + if ($state->{current_set}{simple_update} && + $d eq $orig && + !-e $filename) { + $self->{avoid_temp} = $filename; + } + return $d; } @@ -503,6 +510,18 @@ sub create_temp return ($fh, $tempname); } +sub may_create_temp +{ + my ($self, $d, $state) = @_; + if ($self->{avoid_temp}) { + if (open(my $fh, '>', $self->{avoid_temp})) { + return ($fh, $self->{avoid_temp}); + } + } + delete $self->{avoid_temp}; + return $self->create_temp($d, $state); +} + sub tie { my ($self, $state) = @_; @@ -513,14 +532,22 @@ sub tie $self->SUPER::extract($state); my $d = $self->find_safe_dir($state); + my $src = $self->{tieto}->realname($state); + my $dest = $self->realname($state); + if ($state->{current_set}{simple_update} && $src eq $dest) { + $state->say("No name change on tied file #1", $src) + if $state->verbose >= 3; + $state->{current_set}{dont_delete}{$dest} = 1; + $self->{avoid_temp} = 1; + return; + } if ($state->{not}) { $state->say("link #1 -> #2", $self->name, $d) if $state->verbose >= 3; } else { - my ($fh, $tempname) = $self->create_temp($d, $state); + my ($fh, $tempname) = $self->may_create_temp($d, $state); return if !defined $tempname; - my $src = $self->{tieto}->realname($state); unlink($tempname); $state->say("link #1 -> #2", $src, $tempname) if $state->verbose >= 3; @@ -528,6 +555,7 @@ sub tie } } + sub extract { my ($self, $state, $file) = @_; @@ -540,13 +568,16 @@ sub extract $self->name, $d) if $state->verbose >= 3; $state->{archive}->skip; } else { - my ($fh, $tempname) = $self->create_temp($d, $state); - if (!defined $tempname) { + my ($fh, $filename) = $self->may_create_temp($d, $state); + if (!defined $filename) { $state->{archive}->skip; return; } - $state->say("extract #1 -> #2", $self->name, $tempname) + if ($self->{avoid_temp}) { + $state->{current_set}{dont_delete}{$filename} = 1; + } + $state->say("extract #1 -> #2", $self->name, $filename) if $state->verbose >= 3; @@ -555,7 +586,7 @@ sub extract $self->stringize); } $file->extract_to_fh($fh); - $self->may_check_digest($tempname, $state); + $self->may_check_digest($filename, $state); } } @@ -576,17 +607,21 @@ sub install } elsif (defined $self->{symlink}) { symlink($self->{symlink}, $destdir.$fullname); } else { - if (!defined $self->{tempname}) { - return if $state->allow_nonroot($fullname); - $state->fatal("No tempname for #1", $fullname); - } - rename($self->{tempname}, $destdir.$fullname) or - $state->fatal("can't move #1 to #2: #3", -