Re: opensmtpd faq commands

2017-01-30 Thread Gilles Chehade
On Mon, Jan 30, 2017 at 07:00:18PM -0500, Daniel Jakots wrote:
> On Mon, 30 Jan 2017 18:38:12 -0500, Daniel Jakots 
> wrote:
> 
> > Hi,
> > 
> > When following the example from the OpenSMTPD faq [0], first thing is
> > to create a new user with:
> > 
> > useradd -g =uid -c "Virtual Mail" -d /var/vmail -s /sbin/nologin vmail
> > 
> > which raises
> >   warnx("Warning: home directory `%s' doesn't exist, and -m was"
> >   " not specified", home);
> > 
> > I don't think giving a command that produces a warning is a good thing
> > in an official documentation. Also solving this problem make other
> > commands useless so it's a bit shorter.
> > 
> > [0]: https://opensmtpd.org/faq/example1.html
> 
> While checking that my diff wasn't mangled, I noticed that it doesn't
> follow html syntax from OpenBSD faq, so let's be consistent:
> 

ok


> Index: opensmtpd/faq/example1.html
> ===
> RCS file: /cvs/www/opensmtpd/faq/example1.html,v
> retrieving revision 1.12
> diff -u -p -r1.12 example1.html
> --- opensmtpd/faq/example1.html   31 Oct 2016 20:52:22 -  1.12
> +++ opensmtpd/faq/example1.html   30 Jan 2017 23:58:39 -
> @@ -90,9 +90,7 @@ virtual users.
>  This user needs to be created:
>  
>  
> -# useradd -g =uid -c "Virtual Mail" -d /var/vmail -s /sbin/nologin 
> vmail
> -# mkdir /var/vmail
> -# chown vmail:vmail /var/vmail
> +# useradd -m -g =uid -c "Virtual Mail" -d /var/vmail -s /sbin/nologin 
> vmail
>  
>  
>  Afterwards, the /etc/passwd file will contain an entry like
> @@ -199,9 +197,9 @@ maildir folder are mapped to the single 
>  In this example, Dovecot is used as an IMAP server.
>  
>  
> -# export 
> PKG_PATH=http://your.local.mirror/pub/OpenBSD/%c/packages/%a
> -# pkg_add dovecot
> -# rcctl enable dovecot
> +# export PKG_PATH=http://your.local.mirror/pub/OpenBSD/%c/packages/%a
> +# pkg_add dovecot
> +# rcctl enable dovecot
>  
>  
>  Virtual users access and read their mails via IMAP.
> 

-- 
Gilles Chehade

https://www.poolp.org  @poolpOrg



Re: 11n support for athn(4)

2017-01-30 Thread Timo Myyrä
Stefan Sperling  writes:

> On Sun, Jan 29, 2017 at 07:49:56AM +0200, Timo Myyrä wrote:
>> Hmm, I've been running the 11n for a while and it seems to be a lot slower 
>> than
>> 11g for me. Just did quick benchmark using tcpbench between OpenBSD hostAP 
>> (athn) and
>> laptop (iwn). It looks when my athn is in 11n mode I get around ~3 Mbps:
>
> Which direction did you measure? Client->AP or AP->Client?
> Have you measured both directions? I expect client->AP to be faster if a
> non-OpenBSD client is used. Such clients will likely use Tx aggregation.
> But OpenBSD does not (yet).
>

Initially I just measured Client->AP. I did another measurement yesterday
looking at traffic in both ways and got pretty poor results. The AP->Client when
in 11n mode had throughput between 0-2 Mbps. I did test it during evening so
there might have been a bit more interference but still, that wasn't very
promising result.

But good news is that I noticed your commits to athn and did a new benchmarks
with those changes:
11g: Client->AP: ~15Mbps, AP->Client: ~5Mbps
11n: Client->AP: ~3Mbps, AP->Client: ~5Mbps

So it seems to improved the AP->Client traffic somewhat or its just that I get
full bandwidth to myself in the mornings. 


>> Quickly looking it seems the 11g is 3x faster than 11n which seems a bit odd.
>> I'd assume they should be roughly the same.
>> 
>> Any idea what could explain the difference?
>
> It might be due to RTS/CTS.
> https://en.wikipedia.org/wiki/IEEE_802.11_RTS/CTS
>
> Without TX aggregation, RTS/CTS causes up to 77% overhead on a 20MHz
> channel and a 1500 byte MTU. See Figure 10 in
> http://www.nle.com/literature/Airmagnet_impact_of_legacy_devices_on_80211n.pdf
> Perhaps this overhead is making the difference?
>

Perhaps, I need to take a moment to digest the document.

> You could take a look at what is happening at the wifi frame layer and
> compare 11n and 11g. To do so, get an iwn(4) device and put it in monitor
> mode on the same channel, and use tcpdump's -y IEEE802_11_RADIO option.
> This will show control frames such as rts/cts (but only with iwn(4)
> because most other drivers unfortunately filter these frames).
>
> You'll see RTS/CTS being exchanged for every frame with an OpenBSD 11n hostap.
> This is because OpenBSD 11n hostap forces "HT protection" on. This forces
> clients (and the AP) to reserve the medium with an RTS frame before sending
> a data frame to avoid collisions from legacy 11a/b/g clients. This is the
> simplest way of being standard compliant in any environment.
>
> HT protection could be switched off if only 11n clients exist on the channel
> (not just on the same AP), and with good commercial APs you'll see this
> behaviour. But OpenBSD's wifi stack does not yet monitor the channel in
> a way that allows a decision to be made about turning HT protection off.
>
> In any case, this will likely get better once OpenBSD supports Tx aggregation.
> Then it will send multiple frames after reserving the medium with RTS/CTS
> and the overhead is reduced.

Ok, good to know. if I find a good moment I'll try to mess around with tcpdump a
bit to see if anything pops up.

>
>> There are 8 other wireless networks in range but all of those are on 
>> different channels.
>
> Are they on overlapping channels? See here for a good illustration:
> https://en.wikipedia.org/wiki/IEEE_802.11#/media/File:2.4_GHz_Wi-Fi_channels_(802.11b,g_WLAN).svg
>

Seems they are overlapping a bit. Will try to find clearer channel for my wifi.

> If no other networks overlap, or all other networks use 11n only, then
> you don't need HT protection. The crude patch below should disable it
> and might make 11n and 11g perform equally in your environment.
> Obviously this patch is not a real fix and I don't intend to commit it.
>
> Index: ieee80211_node.c
> ===
> RCS file: /cvs/src/sys/net80211/ieee80211_node.c,v
> retrieving revision 1.112
> diff -u -p -r1.112 ieee80211_node.c
> --- ieee80211_node.c  16 Jan 2017 09:35:43 -  1.112
> +++ ieee80211_node.c  29 Jan 2017 08:37:47 -
> @@ -364,8 +364,12 @@ ieee80211_create_ibss(struct ieee80211co
>* beacons from other networks) which proves that only HT
>* STAs are on the air.
>*/
> +#if 0
>   ni->ni_htop1 = IEEE80211_HTPROT_NONMEMBER;
>   ic->ic_protmode = IEEE80211_PROT_RTSCTS;
> +#else
> + ni->ni_htop1 = IEEE80211_HTPROT_NONE;
> +#endif
>  
>   /* Configure QoS EDCA parameters. */
>   for (aci = 0; aci < EDCA_NUM_AC; aci++) {
> @@ -1476,9 +1480,11 @@ ieee80211_node_join_ht(struct ieee80211c
>   /* Update HT protection setting. */
>   if ((ni->ni_flags & IEEE80211_NODE_HT) == 0) {
>   ic->ic_nonhtsta++;
> +#if 0
>   ic->ic_bss->ni_htop1 = IEEE80211_HTPROT_NONHT_MIXED;
>   if (ic->ic_update_htprot)
>   

Re: percpu counters: replace KASSERT with CTASSERT

2017-01-30 Thread David Gwynne
ok.

> On 31 Jan 2017, at 10:41, Jeremie Courreges-Anglas  wrote:
> 
> 
> CTASSERT is more useful when the result of the test is known at compile
> time.  Build-tested on amd64 and armv7, ok?
> 
> 
> Index: net/rtsock.c
> ===
> RCS file: /d/cvs/src/sys/net/rtsock.c,v
> retrieving revision 1.220
> diff -u -p -r1.220 rtsock.c
> --- net/rtsock.c  24 Jan 2017 00:17:14 -  1.220
> +++ net/rtsock.c  30 Jan 2017 22:57:35 -
> @@ -1640,7 +1640,7 @@ sysctl_rtable_rtstat(void *oldp, size_t 
>   uint32_t *words = (uint32_t *)
>   int i;
> 
> - KASSERT(sizeof(rtstat) == (nitems(counters) * sizeof(uint32_t)));
> + CTASSERT(sizeof(rtstat) == (nitems(counters) * sizeof(uint32_t)));
> 
>   counters_read(rtcounters, counters, nitems(counters));
> 
> Index: netinet/igmp.c
> ===
> RCS file: /d/cvs/src/sys/netinet/igmp.c,v
> retrieving revision 1.62
> diff -u -p -r1.62 igmp.c
> --- netinet/igmp.c29 Jan 2017 19:58:47 -  1.62
> +++ netinet/igmp.c30 Jan 2017 22:57:56 -
> @@ -706,7 +706,7 @@ igmp_sysctl_igmpstat(void *oldp, size_t 
>   u_long *words = (u_long *)
>   int i;
> 
> - KASSERT(sizeof(igmpstat) == (nitems(counters) * sizeof(u_long)));
> + CTASSERT(sizeof(igmpstat) == (nitems(counters) * sizeof(u_long)));
> 
>   counters_read(igmpcounters, counters, nitems(counters));
> 
> Index: netinet/ip_input.c
> ===
> RCS file: /d/cvs/src/sys/netinet/ip_input.c,v
> retrieving revision 1.293
> diff -u -p -r1.293 ip_input.c
> --- netinet/ip_input.c29 Jan 2017 19:58:47 -  1.293
> +++ netinet/ip_input.c30 Jan 2017 22:58:09 -
> @@ -1654,7 +1654,7 @@ ip_sysctl_ipstat(void *oldp, size_t *old
>   u_long *words = (u_long *)
>   int i;
> 
> - KASSERT(sizeof(ipstat) == (nitems(counters) * sizeof(u_long)));
> + CTASSERT(sizeof(ipstat) == (nitems(counters) * sizeof(u_long)));
> 
>   counters_read(ipcounters, counters, nitems(counters));
> 
> Index: netinet/udp_usrreq.c
> ===
> RCS file: /d/cvs/src/sys/netinet/udp_usrreq.c,v
> retrieving revision 1.229
> diff -u -p -r1.229 udp_usrreq.c
> --- netinet/udp_usrreq.c  29 Jan 2017 19:58:47 -  1.229
> +++ netinet/udp_usrreq.c  30 Jan 2017 22:58:27 -
> @@ -1352,7 +1352,7 @@ udp_sysctl_udpstat(void *oldp, size_t *o
>   u_long *words = (u_long *)
>   int i;
> 
> - KASSERT(sizeof(udpstat) == (nitems(counters) * sizeof(u_long)));
> + CTASSERT(sizeof(udpstat) == (nitems(counters) * sizeof(u_long)));
> 
>   counters_read(udpcounters, counters, nitems(counters));
> 
> 
> 
> -- 
> jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE
> 



percpu counters: replace KASSERT with CTASSERT

2017-01-30 Thread Jeremie Courreges-Anglas

CTASSERT is more useful when the result of the test is known at compile
time.  Build-tested on amd64 and armv7, ok?


Index: net/rtsock.c
===
RCS file: /d/cvs/src/sys/net/rtsock.c,v
retrieving revision 1.220
diff -u -p -r1.220 rtsock.c
--- net/rtsock.c24 Jan 2017 00:17:14 -  1.220
+++ net/rtsock.c30 Jan 2017 22:57:35 -
@@ -1640,7 +1640,7 @@ sysctl_rtable_rtstat(void *oldp, size_t 
uint32_t *words = (uint32_t *)
int i;
 
-   KASSERT(sizeof(rtstat) == (nitems(counters) * sizeof(uint32_t)));
+   CTASSERT(sizeof(rtstat) == (nitems(counters) * sizeof(uint32_t)));
 
counters_read(rtcounters, counters, nitems(counters));
 
Index: netinet/igmp.c
===
RCS file: /d/cvs/src/sys/netinet/igmp.c,v
retrieving revision 1.62
diff -u -p -r1.62 igmp.c
--- netinet/igmp.c  29 Jan 2017 19:58:47 -  1.62
+++ netinet/igmp.c  30 Jan 2017 22:57:56 -
@@ -706,7 +706,7 @@ igmp_sysctl_igmpstat(void *oldp, size_t 
u_long *words = (u_long *)
int i;
 
-   KASSERT(sizeof(igmpstat) == (nitems(counters) * sizeof(u_long)));
+   CTASSERT(sizeof(igmpstat) == (nitems(counters) * sizeof(u_long)));
 
counters_read(igmpcounters, counters, nitems(counters));
 
Index: netinet/ip_input.c
===
RCS file: /d/cvs/src/sys/netinet/ip_input.c,v
retrieving revision 1.293
diff -u -p -r1.293 ip_input.c
--- netinet/ip_input.c  29 Jan 2017 19:58:47 -  1.293
+++ netinet/ip_input.c  30 Jan 2017 22:58:09 -
@@ -1654,7 +1654,7 @@ ip_sysctl_ipstat(void *oldp, size_t *old
u_long *words = (u_long *)
int i;
 
-   KASSERT(sizeof(ipstat) == (nitems(counters) * sizeof(u_long)));
+   CTASSERT(sizeof(ipstat) == (nitems(counters) * sizeof(u_long)));
 
counters_read(ipcounters, counters, nitems(counters));
 
Index: netinet/udp_usrreq.c
===
RCS file: /d/cvs/src/sys/netinet/udp_usrreq.c,v
retrieving revision 1.229
diff -u -p -r1.229 udp_usrreq.c
--- netinet/udp_usrreq.c29 Jan 2017 19:58:47 -  1.229
+++ netinet/udp_usrreq.c30 Jan 2017 22:58:27 -
@@ -1352,7 +1352,7 @@ udp_sysctl_udpstat(void *oldp, size_t *o
u_long *words = (u_long *)
int i;
 
-   KASSERT(sizeof(udpstat) == (nitems(counters) * sizeof(u_long)));
+   CTASSERT(sizeof(udpstat) == (nitems(counters) * sizeof(u_long)));
 
counters_read(udpcounters, counters, nitems(counters));
 


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: opensmtpd faq commands

2017-01-30 Thread Daniel Jakots
On Mon, 30 Jan 2017 18:38:12 -0500, Daniel Jakots 
wrote:

> Hi,
> 
> When following the example from the OpenSMTPD faq [0], first thing is
> to create a new user with:
> 
> useradd -g =uid -c "Virtual Mail" -d /var/vmail -s /sbin/nologin vmail
> 
> which raises
>   warnx("Warning: home directory `%s' doesn't exist, and -m was"
>   " not specified", home);
> 
> I don't think giving a command that produces a warning is a good thing
> in an official documentation. Also solving this problem make other
> commands useless so it's a bit shorter.
> 
> [0]: https://opensmtpd.org/faq/example1.html

While checking that my diff wasn't mangled, I noticed that it doesn't
follow html syntax from OpenBSD faq, so let's be consistent:

Index: opensmtpd/faq/example1.html
===
RCS file: /cvs/www/opensmtpd/faq/example1.html,v
retrieving revision 1.12
diff -u -p -r1.12 example1.html
--- opensmtpd/faq/example1.html 31 Oct 2016 20:52:22 -  1.12
+++ opensmtpd/faq/example1.html 30 Jan 2017 23:58:39 -
@@ -90,9 +90,7 @@ virtual users.
 This user needs to be created:
 
 
-# useradd -g =uid -c "Virtual Mail" -d /var/vmail -s /sbin/nologin 
vmail
-# mkdir /var/vmail
-# chown vmail:vmail /var/vmail
+# useradd -m -g =uid -c "Virtual Mail" -d /var/vmail -s /sbin/nologin 
vmail
 
 
 Afterwards, the /etc/passwd file will contain an entry like
@@ -199,9 +197,9 @@ maildir folder are mapped to the single 
 In this example, Dovecot is used as an IMAP server.
 
 
-# export 
PKG_PATH=http://your.local.mirror/pub/OpenBSD/%c/packages/%a
-# pkg_add dovecot
-# rcctl enable dovecot
+# export PKG_PATH=http://your.local.mirror/pub/OpenBSD/%c/packages/%a
+# pkg_add dovecot
+# rcctl enable dovecot
 
 
 Virtual users access and read their mails via IMAP.



opensmtpd faq commands

2017-01-30 Thread Daniel Jakots
Hi,

When following the example from the OpenSMTPD faq [0], first thing is to
create a new user with:

useradd -g =uid -c "Virtual Mail" -d /var/vmail -s /sbin/nologin vmail

which raises
  warnx("Warning: home directory `%s' doesn't exist, and -m was"
  " not specified", home);

I don't think giving a command that produces a warning is a good thing
in an official documentation. Also solving this problem make other
commands useless so it's a bit shorter.

[0]: https://opensmtpd.org/faq/example1.html

Cheers,
Daniel

Index: opensmtpd/faq/example1.html
===
RCS file: /cvs/www/opensmtpd/faq/example1.html,v
retrieving revision 1.12
diff -u -p -r1.12 example1.html
--- opensmtpd/faq/example1.html 31 Oct 2016 20:52:22 -  1.12
+++ opensmtpd/faq/example1.html 30 Jan 2017 23:35:54 -
@@ -90,9 +90,7 @@ virtual users.
 This user needs to be created:
 
 
-# useradd -g =uid -c "Virtual Mail" -d /var/vmail -s /sbin/nologin 
vmail
-# mkdir /var/vmail
-# chown vmail:vmail /var/vmail
+# useradd -m -g =uid -c "Virtual Mail" -d /var/vmail -s /sbin/nologin 
vmail
 
 
 Afterwards, the /etc/passwd file will contain an entry like



Re: Help with the NET_LOCK()

2017-01-30 Thread Pedro Caetano
Hi, I've also ran into this.
Reported here [1] (a new email with some more stack traces should be
landing soon).


BR,
Pedro Caetano

[1] https://marc.info/?l=openbsd-bugs=148581520804370=2

On Mon, Jan 30, 2017 at 11:12 PM, Hrvoje Popovski  wrote:

> On 25.1.2017. 7:32, Martin Pieuchot wrote:
> > I just enabled the NET_LOCK() again and I'm looking for test reports.
> > Please go build a kernel from sources or wait for the next snapshot,
> > run it and report back.
> >
> > If you're looking for some small coding tasks related to the NET_LOCK()
> > just do:
> >
> >   # sysctl kern.splassert=2
> >   # sysctl kern.pool_debug=2
> >
> > Then watch for the traces on your console.
>
>
>
> source is fetched half an hour ago and i think that this one is new
>
>
> splassert: yield: want 0 have 1
> Starting stack trace...
> yield() at yield+0xac
> pool_get() at pool_get+0x1ca
> pf_osfp_add() at pf_osfp_add+0x145
> pfioctl() at pfioctl+0x13f8
> VOP_IOCTL() at VOP_IOCTL+0x44
> vn_ioctl() at vn_ioctl+0x77
> sys_ioctl() at sys_ioctl+0x1b1
> syscall() at syscall+0x27b
> --- syscall (number 54) ---
> end of kernel
> end trace frame: 0x2, count: 249
> 0xd71fb72f43a:
> End of stack trace.
>
>


Re: Help with the NET_LOCK()

2017-01-30 Thread Hrvoje Popovski
On 25.1.2017. 7:32, Martin Pieuchot wrote:
> I just enabled the NET_LOCK() again and I'm looking for test reports.
> Please go build a kernel from sources or wait for the next snapshot,
> run it and report back.
> 
> If you're looking for some small coding tasks related to the NET_LOCK()
> just do:
> 
>   # sysctl kern.splassert=2
>   # sysctl kern.pool_debug=2
>   
> Then watch for the traces on your console.



source is fetched half an hour ago and i think that this one is new


splassert: yield: want 0 have 1
Starting stack trace...
yield() at yield+0xac
pool_get() at pool_get+0x1ca
pf_osfp_add() at pf_osfp_add+0x145
pfioctl() at pfioctl+0x13f8
VOP_IOCTL() at VOP_IOCTL+0x44
vn_ioctl() at vn_ioctl+0x77
sys_ioctl() at sys_ioctl+0x1b1
syscall() at syscall+0x27b
--- syscall (number 54) ---
end of kernel
end trace frame: 0x2, count: 249
0xd71fb72f43a:
End of stack trace.



uvm: free sizes diff

2017-01-30 Thread David Hill
Hello -

The following diff adds free sizes to free() calls in uvm/.  Only one
remaining in uvm/.

Index: uvm/uvm_amap.c
===
RCS file: /cvs/src/sys/uvm/uvm_amap.c,v
retrieving revision 1.78
diff -u -p -r1.78 uvm_amap.c
--- uvm/uvm_amap.c  8 Oct 2016 16:19:44 -   1.78
+++ uvm/uvm_amap.c  30 Jan 2017 21:17:22 -
@@ -368,7 +368,7 @@ amap_alloc1(int slots, int waitf, int la
return(amap);
 
 fail1:
-   free(amap->am_buckets, M_UVMAMAP, 0);
+   free(amap->am_buckets, M_UVMAMAP, buckets * sizeof(*amap->am_buckets));
TAILQ_FOREACH_SAFE(chunk, >am_chunks, ac_list, tmp)
pool_put(_amap_chunk_pool, chunk);
pool_put(_amap_pool, amap);
@@ -414,7 +414,7 @@ amap_free(struct vm_amap *amap)
 
 #ifdef UVM_AMAP_PPREF
if (amap->am_ppref && amap->am_ppref != PPREF_NONE)
-   free(amap->am_ppref, M_UVMAMAP, 0);
+   free(amap->am_ppref, M_UVMAMAP, amap->am_nslot * sizeof(int));
 #endif
 
if (UVM_AMAP_SMALL(amap))
Index: uvm/uvm_aobj.c
===
RCS file: /cvs/src/sys/uvm/uvm_aobj.c,v
retrieving revision 1.84
diff -u -p -r1.84 uvm_aobj.c
--- uvm/uvm_aobj.c  24 Sep 2016 18:40:29 -  1.84
+++ uvm/uvm_aobj.c  30 Jan 2017 21:17:22 -
@@ -403,7 +403,7 @@ uao_free(struct uvm_aobj *aobj)
uvmexp.swpgonly--;
}
}
-   free(aobj->u_swslots, M_UVMAOBJ, 0);
+   free(aobj->u_swslots, M_UVMAOBJ, aobj->u_pages * sizeof(int));
}
 
/* finally free the aobj itself */
@@ -532,7 +532,7 @@ uao_shrink_array(struct uvm_object *uobj
for (i = 0; i < pages; i++)
new_swslots[i] = aobj->u_swslots[i];
 
-   free(aobj->u_swslots, M_UVMAOBJ, 0);
+   free(aobj->u_swslots, M_UVMAOBJ, aobj->u_pages * sizeof(int));
 
aobj->u_swslots = new_swslots;
aobj->u_pages = pages;
@@ -585,7 +585,7 @@ uao_grow_array(struct uvm_object *uobj, 
for (i = 0; i < aobj->u_pages; i++)
new_swslots[i] = aobj->u_swslots[i];
 
-   free(aobj->u_swslots, M_UVMAOBJ, 0);
+   free(aobj->u_swslots, M_UVMAOBJ, aobj->u_pages * sizeof(int));
 
aobj->u_swslots = new_swslots;
aobj->u_pages = pages;
@@ -664,7 +664,7 @@ uao_grow_convert(struct uvm_object *uobj
}
}
 
-   free(old_swslots, M_UVMAOBJ, 0);
+   free(old_swslots, M_UVMAOBJ, aobj->u_pages * sizeof(int));
aobj->u_pages = pages;
 
return 0;



ip6stat percpu counters

2017-01-30 Thread Jeremie Courreges-Anglas

Very lightly tested.  I used the existing percpu counters as examples.

I don't like the hardcoding of "32" in ip6_input() but I am not sure how
to solve it nicely; the easiest way would be to just kill those
ipv6-specific mbuf stats.  Would anyone miss them?

Mbuf statistics:
299 one mbufs
two or more mbuf:
vether0 = 2
12 one ext mbufs
0 two or more ext mbufs

Thoughts?

Other netinet6/* counters will follow.


Index: net/if_bridge.c
===
RCS file: /d/cvs/src/sys/net/if_bridge.c,v
retrieving revision 1.293
diff -u -p -r1.293 if_bridge.c
--- net/if_bridge.c 24 Jan 2017 10:08:30 -  1.293
+++ net/if_bridge.c 30 Jan 2017 21:02:30 -
@@ -1692,7 +1692,7 @@ bridge_ip(struct bridge_softc *sc, int d
if (m->m_len < sizeof(struct ip6_hdr)) {
if ((m = m_pullup(m, sizeof(struct ip6_hdr)))
== NULL) {
-   ip6stat.ip6s_toosmall++;
+   ip6stat_inc(ip6s_toosmall);
return (NULL);
}
}
@@ -1700,7 +1700,7 @@ bridge_ip(struct bridge_softc *sc, int d
ip6 = mtod(m, struct ip6_hdr *);
 
if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) {
-   ip6stat.ip6s_badvers++;
+   ip6stat_inc(ip6s_badvers);
goto dropit;
}
 
Index: net/pf.c
===
RCS file: /d/cvs/src/sys/net/pf.c,v
retrieving revision 1.1011
diff -u -p -r1.1011 pf.c
--- net/pf.c25 Jan 2017 06:15:50 -  1.1011
+++ net/pf.c30 Jan 2017 21:02:30 -
@@ -5998,7 +5998,7 @@ pf_route6(struct pf_pdesc *pd, struct pf
 
rt = rtalloc(sin6tosa(dst), RT_RESOLVE, rtableid);
if (!rtisvalid(rt)) {
-   ip6stat.ip6s_noroute++;
+   ip6stat_inc(ip6s_noroute);
goto bad;
}
 
Index: netinet/ipsec_input.c
===
RCS file: /d/cvs/src/sys/netinet/ipsec_input.c,v
retrieving revision 1.141
diff -u -p -r1.141 ipsec_input.c
--- netinet/ipsec_input.c   29 Jan 2017 19:58:47 -  1.141
+++ netinet/ipsec_input.c   30 Jan 2017 21:02:30 -
@@ -985,7 +985,7 @@ ah6_input_cb(struct mbuf *m, int off, in
 */
while (nxt != IPPROTO_DONE) {
if (ip6_hdrnestlimit && (++nest > ip6_hdrnestlimit)) {
-   ip6stat.ip6s_toomanyhdr++;
+   ip6stat_inc(ip6s_toomanyhdr);
goto bad;
}
 
@@ -994,7 +994,7 @@ ah6_input_cb(struct mbuf *m, int off, in
 * more sanity checks in header chain processing.
 */
if (m->m_pkthdr.len < off) {
-   ip6stat.ip6s_tooshort++;
+   ip6stat_inc(ip6s_tooshort);
goto bad;
}
nxt = (*inet6sw[ip6_protox[nxt]].pr_input)(, , nxt);
Index: netinet6/dest6.c
===
RCS file: /d/cvs/src/sys/netinet6/dest6.c,v
retrieving revision 1.15
diff -u -p -r1.15 dest6.c
--- netinet6/dest6.c14 Mar 2015 03:38:52 -  1.15
+++ netinet6/dest6.c30 Jan 2017 21:02:30 -
@@ -73,7 +73,7 @@ dest6_input(struct mbuf **mp, int *offp,
for (optlen = 0; dstoptlen > 0; dstoptlen -= optlen, opt += optlen) {
if (*opt != IP6OPT_PAD1 &&
(dstoptlen < IP6OPT_MINLEN || *(opt + 1) + 2 > dstoptlen)) {
-   ip6stat.ip6s_toosmall++;
+   ip6stat_inc(ip6s_toosmall);
goto bad;
}
 
Index: netinet6/frag6.c
===
RCS file: /d/cvs/src/sys/netinet6/frag6.c,v
retrieving revision 1.71
diff -u -p -r1.71 frag6.c
--- netinet6/frag6.c28 Nov 2016 11:12:45 -  1.71
+++ netinet6/frag6.c30 Jan 2017 21:02:30 -
@@ -190,7 +190,7 @@ frag6_input(struct mbuf **mp, int *offp,
return IPPROTO_DONE;
}
 
-   ip6stat.ip6s_fragments++;
+   ip6stat_inc(ip6s_fragments);
 
/* offset now points to data portion */
offset += sizeof(struct ip6_frag);
@@ -203,7 +203,7 @@ frag6_input(struct mbuf **mp, int *offp,
 */
fragoff = ntohs(ip6f->ip6f_offlg & IP6F_OFF_MASK);
if (fragoff == 0 && !(ip6f->ip6f_offlg & IP6F_MORE_FRAG)) {
-   ip6stat.ip6s_reassembled++;
+   ip6stat_inc(ip6s_reassembled);
*offp = offset;
return ip6f->ip6f_nxt;
}
@@ -496,7 +496,7 @@ frag6_input(struct mbuf **mp, int *offp,
m->m_pkthdr.len = plen;
  

rtwn: clean up edca code

2017-01-30 Thread Stefan Sperling
This cleans up the code which handles EDCA parameters in rtwn/urtwn.

The driver now gets its EDCA params from net80211 instead of hardcoding them.
There's a bit of a layer violation since the driver writes to ic->ic_edca_ac
because net80211 does not fill it in yet.
I think net80211 should do that, but this can be fixed later on.

Enable hardware management of EDCA AC queues. Not sure if this brings any
benefit but this is worth trying and does not cause harm in my testing.

Handling of frame collisions with EDCA involves random backoffs.
I found a register that looks like a seed for the pseudo-RNG involved in
computing backoffs. After a cold boot (or hotplug in case of USB) this
register always has the value 0x11e21051 on all my devices.
The register can be written and will retain its most recent value until
the next reboot/hotplug. Feed it with arc4random() during initialization.
Linux does not do anything with this register unfortunately so it is
hard to know if this really does anything. The magic value 0x11e21051
does not show up in Linux rtlwifi sources.

Add a comment to hint at the meaning of numbers written to SIFS registers,
and rename some SIFS registers to better names found in Linux. For some
bizarre reason Linux is using a mix of both the old and new register
names seen in this diff.
(SIFS means "short interface space", the time period within which important
frames such as ACKs may be sent when the medium becomes available after the
previous frame was transmitted).

Tested on:
8188CE (PCI)
8192CU (USB)
8188EU (USB)
8188CUS (USB)

Index: ic/r92creg.h
===
RCS file: /cvs/src/sys/dev/ic/r92creg.h,v
retrieving revision 1.4
diff -u -p -r1.4 r92creg.h
--- ic/r92creg.h8 Jan 2017 05:48:27 -   1.4
+++ ic/r92creg.h30 Jan 2017 19:07:38 -
@@ -218,8 +218,8 @@
 #define R92C_BSSID 0x618
 #define R92C_MAR   0x620
 #define R92C_MAC_SPEC_SIFS 0x63a
-#define R92C_R2T_SIFS  0x63c
-#define R92C_T2T_SIFS  0x63e
+#define R92C_RESP_SIFS_CCK 0x63c
+#define R92C_RESP_SIFS_OFDM0x63e
 #define R92C_ACKTO 0x640
 #define R92C_CAMCMD0x670
 #define R92C_CAMWRITE  0x674
@@ -505,6 +505,15 @@
 #define R92C_EDCA_PARAM_ECWMAX_S   12
 #define R92C_EDCA_PARAM_TXOP_M 0x
 #define R92C_EDCA_PARAM_TXOP_S 16
+
+/* Bits for R92C_ACMHWCTRL */
+#define R92C_ACMHW_HWEN0x01
+#define R92C_ACMHW_BEQEN   0x02
+#define R92C_ACMHW_VIQEN   0x04
+#define R92C_ACMHW_VOQEN   0x08
+#define R92C_ACMHW_BEQSTATUS   0x10
+#define R92C_ACMHW_VIQSTATUS   0x20
+#define R92C_ACMHW_VOQSTATUS   0x40
 
 /* Bits for R92C_TXPAUSE. */
 #define R92C_TXPAUSE_AC_VO 0x01
Index: ic/rtwn.c
===
RCS file: /cvs/src/sys/dev/ic/rtwn.c,v
retrieving revision 1.14
diff -u -p -r1.14 rtwn.c
--- ic/rtwn.c   30 Jan 2017 17:48:26 -  1.14
+++ ic/rtwn.c   30 Jan 2017 19:50:55 -
@@ -903,10 +903,7 @@ rtwn_newstate(struct ieee80211com *ic, e
R92C_BCN_CTRL_DIS_TSF_UDT0);
 
/* Reset EDCA parameters. */
-   rtwn_write_4(sc, R92C_EDCA_VO_PARAM, 0x002f3217);
-   rtwn_write_4(sc, R92C_EDCA_VI_PARAM, 0x005e4317);
-   rtwn_write_4(sc, R92C_EDCA_BE_PARAM, 0x00105320);
-   rtwn_write_4(sc, R92C_EDCA_BK_PARAM, 0xa444);
+   rtwn_edca_init(sc);
 
rtwn_updateslot(ic);
rtwn_update_short_preamble(ic);
@@ -1012,15 +1009,9 @@ rtwn_newstate(struct ieee80211com *ic, e
/* Enable TSF synchronization. */
rtwn_tsf_sync_enable(sc);
 
-   rtwn_write_1(sc, R92C_SIFS_CCK + 1, 10);
-   rtwn_write_1(sc, R92C_SIFS_OFDM + 1, 10);
-   rtwn_write_1(sc, R92C_SPEC_SIFS + 1, 10);
-   rtwn_write_1(sc, R92C_MAC_SPEC_SIFS + 1, 10);
-   rtwn_write_1(sc, R92C_R2T_SIFS + 1, 10);
-   rtwn_write_1(sc, R92C_T2T_SIFS + 1, 10);
-
/* Intialize rate adaptation. */
rtwn_ra_init(sc);
+
/* Turn link LED on. */
rtwn_set_led(sc, RTWN_LED_LINK, 1);
 
@@ -1080,12 +1071,15 @@ rtwn_updateedca(struct ieee80211com *ic)
struct ieee80211_edca_ac_params *ac;
int s, aci, aifs, slottime;
 
+   if (ic->ic_flags & IEEE80211_F_SHSLOT)
+   slottime = 9; /* XXX needs a macro in ieee80211.h */
+   else
+   slottime = IEEE80211_DUR_DS_SLOT;
s = splnet();
-   slottime = (ic->ic_flags & IEEE80211_F_SHSLOT) ? 9 : 20;
for (aci = 0; aci < EDCA_NUM_AC; aci++) {
ac = >ic_edca_ac[aci];
/* AIFS[AC] = AIFSN[AC] * aSlotTime + 

Re: clang and -Werror vs -Wpointer-sign

2017-01-30 Thread Stefan Kempf
Jonathan Gray wrote:
> Base gcc4 changes the defaults to set -Wno-pointer-sign.
> Base clang does not, I'm not sure where in the llvm code to do so.
> Base gcc3 does not handle -Wno-pointer-sign.
 
I think this should turn off -Wpointer-sign off by default.
Passing -Wpointer-sign on the command line enables it.
Not suitable for upstreaming though.

Index: gnu/llvm/tools/clang//include/clang/Basic/DiagnosticSemaKinds.td
===
RCS file: 
/cvs/src/gnu/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 DiagnosticSemaKinds.td
--- gnu/llvm/tools/clang//include/clang/Basic/DiagnosticSemaKinds.td14 Jan 
2017 19:55:48 -  1.1.1.2
+++ gnu/llvm/tools/clang//include/clang/Basic/DiagnosticSemaKinds.td30 Jan 
2017 18:22:22 -
@@ -6332,7 +6332,7 @@ def ext_typecheck_convert_incompatible_p
   "sending to parameter of different type}0,1"
   "|%diff{casting $ to type $|casting between types}0,1}2"
   " converts between pointers to integer types with different sign">,
-  InGroup>;
+  InGroup>, DefaultIgnore;
 def ext_typecheck_convert_incompatible_pointer : ExtWarn<
   "incompatible pointer types "
   "%select{%diff{assigning to $ from $|assigning to different types}0,1"
 
> Below is a patch to add -Wno-pointer-sign to places that use use
> -Werror and trigger -Wpointer-sign warnings which breaks the build
> when building with clang.  Based on an earlier patch from patrick@
> 
> Though really the default gcc4 and clang behaviour should be the
> same one way or the other.
>
> Index: lib/libcrypto/Makefile
> ===
> RCS file: /cvs/src/lib/libcrypto/Makefile,v
> retrieving revision 1.14
> diff -u -p -r1.14 Makefile
> --- lib/libcrypto/Makefile21 Jan 2017 09:38:58 -  1.14
> +++ lib/libcrypto/Makefile29 Jan 2017 05:10:50 -
> @@ -14,6 +14,9 @@ CLEANFILES=${PC_FILES} ${VERSION_SCRIPT}
>  LCRYPTO_SRC= ${.CURDIR}
>  
>  CFLAGS+= -Wall -Wundef -Werror
> +.if ${COMPILER_VERSION:L} != "gcc3"
> +CFLAGS+= -Wno-pointer-sign
> +.endif
>  
>  .if !defined(NOPIC)
>  CFLAGS+= -DDSO_DLFCN -DHAVE_DLFCN_H -DHAVE_FUNOPEN
> Index: lib/librthread/Makefile
> ===
> RCS file: /cvs/src/lib/librthread/Makefile,v
> retrieving revision 1.43
> diff -u -p -r1.43 Makefile
> --- lib/librthread/Makefile   1 Jun 2016 04:34:18 -   1.43
> +++ lib/librthread/Makefile   29 Jan 2017 05:27:29 -
> @@ -1,11 +1,16 @@
>  #$OpenBSD: Makefile,v 1.43 2016/06/01 04:34:18 tedu Exp $
>  
> +.include 
> +
>  LIB=pthread
>  LIBCSRCDIR=  ${.CURDIR}/../libc
>  
>  CFLAGS+=-Wall -g -Werror -Wshadow
>  CFLAGS+=-Werror-implicit-function-declaration
>  CFLAGS+=-Wsign-compare
> +.if ${COMPILER_VERSION:L} != "gcc3"
> +CFLAGS+= -Wno-pointer-sign
> +.endif
>  CFLAGS+=-I${.CURDIR} -include namespace.h \
>   -I${LIBCSRCDIR}/arch/${MACHINE_CPU} -I${LIBCSRCDIR}/include
>  CDIAGFLAGS=
> Index: lib/libtls/Makefile
> ===
> RCS file: /cvs/src/lib/libtls/Makefile,v
> retrieving revision 1.30
> diff -u -p -r1.30 Makefile
> --- lib/libtls/Makefile   25 Jan 2017 23:53:18 -  1.30
> +++ lib/libtls/Makefile   29 Jan 2017 05:32:43 -
> @@ -6,6 +6,9 @@ SUBDIR=   man
>  .endif
>  
>  CFLAGS+= -Wall -Werror -Wimplicit
> +.if ${COMPILER_VERSION:L} != "gcc3"
> +CFLAGS+= -Wno-pointer-sign
> +.endif
>  CFLAGS+= -DLIBRESSL_INTERNAL
>  
>  CLEANFILES= ${VERSION_SCRIPT}
> Index: usr.sbin/ocspcheck/Makefile
> ===
> RCS file: /cvs/src/usr.sbin/ocspcheck/Makefile,v
> retrieving revision 1.2
> diff -u -p -r1.2 Makefile
> --- usr.sbin/ocspcheck/Makefile   24 Jan 2017 09:25:27 -  1.2
> +++ usr.sbin/ocspcheck/Makefile   29 Jan 2017 05:27:10 -
> @@ -1,5 +1,7 @@
>  #$OpenBSD: Makefile,v 1.2 2017/01/24 09:25:27 deraadt Exp $
>  
> +.include 
> +
>  PROG=ocspcheck
>  MAN= ocspcheck.8
>  
> @@ -15,6 +17,9 @@ CFLAGS+= -Wshadow
>  CFLAGS+= -Wtrigraphs
>  CFLAGS+= -Wuninitialized
>  CFLAGS+= -Wunused
> +.if ${COMPILER_VERSION:L} != "gcc3"
> +CFLAGS+= -Wno-pointer-sign
> +.endif
>  
>  CFLAGS+= -DLIBRESSL_INTERNAL
>  
> 



net80211: expose edca table

2017-01-30 Thread Stefan Sperling
EDCA ("Enhanced distributed channel access") was first introduced
in 802.11e and is also part of 802.11n.

Essentially, these parameters define how frame transmissions are timed.
They are not necessary to operate in pure 11a/b/g networks, but 11n clients
will typically pass these parameters to firmware.
Parameter values can, within certain boundaries, be configured by the AP.
Thus 11n APs always pass these parameters to clients during association.

Two tables we have in ieee80211_output.c define the set of default
values for all of 11a/b/g/n. There is one parameter set for clients,
and one set for APs. The AP set was already enabled for 11n hostap.

At the moment, some of our drivers use hardcoded values (e.g. rtwn(4)).
This diff enables the client EDCA parameter set, which will allow
getting rid of the hardcoded values in driver code.

ok?

Index: ieee80211_output.c
===
RCS file: /cvs/src/sys/net80211/ieee80211_output.c,v
retrieving revision 1.114
diff -u -p -r1.114 ieee80211_output.c
--- ieee80211_output.c  9 Jan 2017 16:24:20 -   1.114
+++ ieee80211_output.c  30 Jan 2017 17:12:41 -
@@ -275,8 +275,7 @@ ieee80211_mgmt_output(struct ifnet *ifp,
  * 11G 15* 1023(*) aCWmin(1)
  * 11N 15  1023
  */
-#if 0
-static const struct ieee80211_edca_ac_params
+const struct ieee80211_edca_ac_params
 ieee80211_edca_table[IEEE80211_MODE_MAX][EDCA_NUM_AC] = {
[IEEE80211_MODE_11B] = {
[EDCA_AC_BK] = { 5, 10, 7,   0 },
@@ -303,7 +302,6 @@ static const struct ieee80211_edca_ac_pa
[EDCA_AC_VO] = { 2,  3, 2,  47 }
},
 };
-#endif
 
 #ifndef IEEE80211_STA_ONLY
 const struct ieee80211_edca_ac_params
Index: ieee80211_var.h
===
RCS file: /cvs/src/sys/net80211/ieee80211_var.h,v
retrieving revision 1.75
diff -u -p -r1.75 ieee80211_var.h
--- ieee80211_var.h 9 Jan 2017 16:24:20 -   1.75
+++ ieee80211_var.h 30 Jan 2017 17:12:41 -
@@ -161,6 +161,8 @@ struct ieee80211_edca_ac_params {
 };
 
 extern const struct ieee80211_edca_ac_params
+   ieee80211_edca_table[IEEE80211_MODE_MAX][EDCA_NUM_AC];
+extern const struct ieee80211_edca_ac_params
ieee80211_qap_edca_table[IEEE80211_MODE_MAX][EDCA_NUM_AC];
 
 #define IEEE80211_DEFRAG_SIZE  3   /* must be >= 3 according to spec */



rtwn: configure short slot time and short preamble

2017-01-30 Thread Stefan Sperling
The rtwn driver never tells hardware about the short slot time
and short preamble features enabled by most APs (since 11g).

Not sure if not doing so hurts but the linux driver does it.

Tested on:
8188CE (PCI)
8192CU (USB)
8188EU (USB)
8188CUS (USB)

ok?

Index: rtwn.c
===
RCS file: /cvs/src/sys/dev/ic/rtwn.c,v
retrieving revision 1.13
diff -u -p -r1.13 rtwn.c
--- rtwn.c  30 Jan 2017 16:25:50 -  1.13
+++ rtwn.c  30 Jan 2017 16:52:32 -
@@ -89,6 +89,8 @@ int   rtwn_r88e_ra_init(struct rtwn_softc
int, uint32_t, int);
 void   rtwn_tsf_sync_enable(struct rtwn_softc *);
 void   rtwn_set_led(struct rtwn_softc *, int, int);
+void   rtwn_update_short_preamble(struct ieee80211com *);
+void   rtwn_updateslot(struct ieee80211com *);
 void   rtwn_updateedca(struct ieee80211com *);
 void   rtwn_update_avgrssi(struct rtwn_softc *, int, int8_t);
 int8_t rtwn_r88e_get_rssi(struct rtwn_softc *, int, void *);
@@ -238,6 +240,7 @@ rtwn_attach(struct device *pdev, struct 
 
if_attach(ifp);
ieee80211_ifattach(ifp);
+   ic->ic_updateslot = rtwn_updateslot;
ic->ic_updateedca = rtwn_updateedca;
 #ifdef notyet
ic->ic_set_key = rtwn_set_key;
@@ -905,6 +908,9 @@ rtwn_newstate(struct ieee80211com *ic, e
rtwn_write_4(sc, R92C_EDCA_BE_PARAM, 0x00105320);
rtwn_write_4(sc, R92C_EDCA_BK_PARAM, 0xa444);
 
+   rtwn_updateslot(ic);
+   rtwn_update_short_preamble(ic);
+
/* Disable 11b-only AP workaround (see rtwn_r88e_ra_init). */
sc->sc_flags &= ~RTWN_FLAG_FORCE_RAID_11B;
}
@@ -986,6 +992,9 @@ rtwn_newstate(struct ieee80211com *ic, e
else/* 802.11b/g */
rtwn_write_1(sc, R92C_INIRTS_RATE_SEL, 3);
 
+   rtwn_updateslot(ic);
+   rtwn_update_short_preamble(ic);
+
/* Enable Rx of data frames. */
rtwn_write_2(sc, R92C_RXFLTMAP2, 0x);
 
@@ -1028,6 +1037,34 @@ rtwn_newstate(struct ieee80211com *ic, e
splx(s);
  
return (error);
+}
+
+void
+rtwn_update_short_preamble(struct ieee80211com *ic)
+{
+   struct rtwn_softc *sc = ic->ic_softc;
+   uint32_t reg;
+
+   reg = rtwn_read_4(sc, R92C_RRSR);
+   if (ic->ic_flags & IEEE80211_F_SHPREAMBLE)
+   reg |= R92C_RRSR_SHORT;
+   else
+   reg &= ~R92C_RRSR_SHORT;
+   rtwn_write_4(sc, R92C_RRSR, reg);
+}
+
+void
+rtwn_updateslot(struct ieee80211com *ic)
+{
+   struct rtwn_softc *sc = ic->ic_softc;
+   int s;
+   
+   s = splnet();
+   if (ic->ic_flags & IEEE80211_F_SHSLOT)
+   rtwn_write_1(sc, R92C_SLOT, 9);
+   else
+   rtwn_write_1(sc, R92C_SLOT, IEEE80211_DUR_DS_SLOT);
+   splx(s);
 }
 
 void



Re: rtwn: correct free size

2017-01-30 Thread Stefan Sperling
On Mon, Jan 30, 2017 at 03:28:21PM +0100, Jeremie Courreges-Anglas wrote:
> 
> If fw_loadpage fails, the size passed to free(9) is bogus.  Always pass
> the size returned by load_firmware instead.  I hit this a few days ago,
> ok?

ok stsp@
 
> Index: rtwn.c
> ===
> RCS file: /d/cvs/src/sys/dev/ic/rtwn.c,v
> retrieving revision 1.12
> diff -u -p -p -u -r1.12 rtwn.c
> --- rtwn.c26 Jan 2017 10:57:37 -  1.12
> +++ rtwn.c30 Jan 2017 12:08:56 -
> @@ -1439,14 +1439,15 @@ rtwn_load_firmware(struct rtwn_softc *sc
>  {
>   const struct r92c_fw_hdr *hdr;
>   u_char *fw, *ptr;
> - size_t len;
> + size_t len0, len;
>   uint32_t reg;
>   int mlen, ntries, page, error;
>  
>   /* Read firmware image from the filesystem. */
> - error = sc->sc_ops.load_firmware(sc->sc_ops.cookie, , );
> + error = sc->sc_ops.load_firmware(sc->sc_ops.cookie, , );
>   if (error)
>   return (error);
> + len = len0;
>   if (len < sizeof(*hdr)) {
>   printf("%s: firmware too short\n", sc->sc_pdev->dv_xname);
>   error = EINVAL;
> @@ -1537,7 +1538,7 @@ rtwn_load_firmware(struct rtwn_softc *sc
>   goto fail;
>   }
>   fail:
> - free(fw, M_DEVBUF, len);
> + free(fw, M_DEVBUF, len0);
>   return (error);
>  }
>  
> 
> -- 
> jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE
> 



Re: Sync sys/videoio.h with recent Linux kernel

2017-01-30 Thread Christian Weisgerber
On 2017-01-29, Christian Weisgerber  wrote:

>>> which allows us to fully comply with the V4L2 API. The attached diff
>>> implements this and syncs with videodev2.h from the Linux kernel version
>>> 4.10-rc5 at the same time
>>
>> This needs to go in a bulk since most users of this API are ports.
>
> I have started an amd64 test build with this.

... and it finished without any problems (related to this).

-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



rtwn: correct free size

2017-01-30 Thread Jeremie Courreges-Anglas

If fw_loadpage fails, the size passed to free(9) is bogus.  Always pass
the size returned by load_firmware instead.  I hit this a few days ago,
ok?


Index: rtwn.c
===
RCS file: /d/cvs/src/sys/dev/ic/rtwn.c,v
retrieving revision 1.12
diff -u -p -p -u -r1.12 rtwn.c
--- rtwn.c  26 Jan 2017 10:57:37 -  1.12
+++ rtwn.c  30 Jan 2017 12:08:56 -
@@ -1439,14 +1439,15 @@ rtwn_load_firmware(struct rtwn_softc *sc
 {
const struct r92c_fw_hdr *hdr;
u_char *fw, *ptr;
-   size_t len;
+   size_t len0, len;
uint32_t reg;
int mlen, ntries, page, error;
 
/* Read firmware image from the filesystem. */
-   error = sc->sc_ops.load_firmware(sc->sc_ops.cookie, , );
+   error = sc->sc_ops.load_firmware(sc->sc_ops.cookie, , );
if (error)
return (error);
+   len = len0;
if (len < sizeof(*hdr)) {
printf("%s: firmware too short\n", sc->sc_pdev->dv_xname);
error = EINVAL;
@@ -1537,7 +1538,7 @@ rtwn_load_firmware(struct rtwn_softc *sc
goto fail;
}
  fail:
-   free(fw, M_DEVBUF, len);
+   free(fw, M_DEVBUF, len0);
return (error);
 }
 

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



provide libc++abi as shared library as well

2017-01-30 Thread Patrick Wildt
Hi,

when I first imported the new C++ stack with libc++, libc++abi and
libunwind I wanted to find out if we really needed libc++abi as a
shared library or not.  Thus so far only libc++ is a shared object,
while libc++abi is only provided as .a.  My reasoning was that the
ABI should never change, while the standard C++ library, which sits
on top of the ABI, can. It turns out that libc++ (well, who would
have thought) depends on libc++abi bits that are not linked in when
using LLD.  That probably is because libc++ does not do DT_NEEDED on
libc++abi.  Considering that our clang is configured to always link
with -lc++ and -lc++abi I thought this should just work, but LLD seems
to be a bit stricter on the dependencies.

Now we could start to link libc++ to libc++abi, but I think we should
simply provide libc++abi as shared object as well.

Thoughts? ok?

Patrick

diff --git a/lib/libcxxabi/shlib_version b/lib/libcxxabi/shlib_version
new file mode 100644
index 000..97c9f92d6b8
--- /dev/null
+++ b/lib/libcxxabi/shlib_version
@@ -0,0 +1,2 @@
+major=0
+minor=0



Re: iwm(4): Update struct iwm_scan_results_notif. Remove a few old defines.

2017-01-30 Thread Imre Vadász
On 10:47 Sun 29 Jan , Stefan Sperling wrote:
> On Mon, Jan 16, 2017 at 05:26:05PM +0100, Imre Vadász wrote:
> > Hi,
> > This patch updates the struct iwm_scan_results_notif to FW Api version 3,
> > and removes the unused enum iwm_scan_complete_status status codes, as well
> > as the deprecated/unused struct iwm_scan_complete_notif.
> > 
> > This corresponds to the Linux iwlwifi commits
> > 1083fd7391e989be52022f0f338e9dadc048b063 and
> > 75118fdb63496e4611ab50380499ddd62b9de69f.
> > No functional change, since struct iwm_scan_results_notif isn't accessed
> > in iwm at the moment.
> 
> This patch does not apply cleanly. I applied your patches in the
> order they arrived in my inbox, so perhaps they're out of order.
> 
> Patching file if_iwmreg.h using Plan A...
> Hunk #1 succeeded at 4864 with fuzz 2 (offset -137 lines).
> Hunk #2 failed at 4879.
> 1 out of 2 hunks failed--saving rejects to if_iwmreg.h.rej
> Hmm...  Ignoring the trailing garbage.
> 
> Can you make a fresh patch against -current?
> 
> I have committed all other diffs you sent. Thanks!

Thanks, this patch was trying to remove the struct iwm_scan_complete_notif
definition that was already removed in one of the previous diffs.
fixed patch:

Update the struct iwm_scan_results_notif to FW Api version 3, and remove
the unused enum iwm_scan_complete_status status codes.

This corresponds to parts of the Linux iwlwifi commits
1083fd7391e989be52022f0f338e9dadc048b063 and
75118fdb63496e4611ab50380499ddd62b9de69f.
No functional change, since struct iwm_scan_results_notif isn't accessed
in iwm at the moment.


Index: sys/dev/pci/if_iwmreg.h
===
RCS file: /cvs/src/sys/dev/pci/if_iwmreg.h,v
retrieving revision 1.23
diff -u -r1.23 if_iwmreg.h
--- sys/dev/pci/if_iwmreg.h 29 Jan 2017 09:43:50 -  1.23
+++ sys/dev/pci/if_iwmreg.h 29 Jan 2017 17:52:50 -
@@ -4864,48 +4864,14 @@
uint32_t reserved;
 } __packed;
 
-/* How many statistics are gathered for each channel */
-#define IWM_SCAN_RESULTS_STATISTICS 1
-
 /**
- * status codes for scan complete notifications
- * @IWM_SCAN_COMP_STATUS_OK:  scan completed successfully
- * @IWM_SCAN_COMP_STATUS_ABORT: scan was aborted by user
- * @IWM_SCAN_COMP_STATUS_ERR_SLEEP: sending null sleep packet failed
- * @IWM_SCAN_COMP_STATUS_ERR_CHAN_TIMEOUT: timeout before channel is ready
- * @IWM_SCAN_COMP_STATUS_ERR_PROBE: sending probe request failed
- * @IWM_SCAN_COMP_STATUS_ERR_WAKEUP: sending null wakeup packet failed
- * @IWM_SCAN_COMP_STATUS_ERR_ANTENNAS: invalid antennas chosen at scan command
- * @IWM_SCAN_COMP_STATUS_ERR_INTERNAL: internal error caused scan abort
- * @IWM_SCAN_COMP_STATUS_ERR_COEX: medium was lost ot WiMax
- * @IWM_SCAN_COMP_STATUS_P2P_ACTION_OK: P2P public action frame TX was 
successful
- * (not an error!)
- * @IWM_SCAN_COMP_STATUS_ITERATION_END: indicates end of one repeatition the 
driver
- * asked for
- * @IWM_SCAN_COMP_STATUS_ERR_ALLOC_TE: scan could not allocate time events
-*/
-#define IWM_SCAN_COMP_STATUS_OK0x1
-#define IWM_SCAN_COMP_STATUS_ABORT 0x2
-#define IWM_SCAN_COMP_STATUS_ERR_SLEEP 0x3
-#define IWM_SCAN_COMP_STATUS_ERR_CHAN_TIMEOUT  0x4
-#define IWM_SCAN_COMP_STATUS_ERR_PROBE 0x5
-#define IWM_SCAN_COMP_STATUS_ERR_WAKEUP0x6
-#define IWM_SCAN_COMP_STATUS_ERR_ANTENNAS  0x7
-#define IWM_SCAN_COMP_STATUS_ERR_INTERNAL  0x8
-#define IWM_SCAN_COMP_STATUS_ERR_COEX  0x9
-#define IWM_SCAN_COMP_STATUS_P2P_ACTION_OK 0xA
-#define IWM_SCAN_COMP_STATUS_ITERATION_END 0x0B
-#define IWM_SCAN_COMP_STATUS_ERR_ALLOC_TE  0x0C
-
-/**
- * struct iwm_scan_results_notif - scan results for one channel
- * ( IWM_SCAN_RESULTS_NOTIFICATION = 0x83 )
+ * struct iwm_scan_results_notif - scan results for one channel -
+ *  SCAN_RESULT_NTF_API_S_VER_3
  * @channel: which channel the results are from
  * @band: 0 for 5.2 GHz, 1 for 2.4 GHz
  * @probe_status: IWM_SCAN_PROBE_STATUS_*, indicates success of probe request
  * @num_probe_not_sent: # of request that weren't sent due to not enough time
  * @duration: duration spent in channel, in usecs
- * @statistics: statistics gathered for this channel
  */
 struct iwm_scan_results_notif {
uint8_t channel;
@@ -4913,8 +4879,7 @@
uint8_t probe_status;
uint8_t num_probe_not_sent;
uint32_t duration;
-   uint32_t statistics[IWM_SCAN_RESULTS_STATISTICS];
-} __packed; /* IWM_SCAN_RESULT_NTF_API_S_VER_2 */
+} __packed;
 
 #define IWM_SCAN_CLIENT_SCHED_SCAN (1 << 0)
 #define IWM_SCAN_CLIENT_NETDETECT  (1 << 1)



athn rts fix for 11a/b/g clients

2017-01-30 Thread Stefan Sperling
An 11n athn hostap will currently apply HT protection (RTS) even when
sending frames to a non-11n client which does not need such protection.
This is causing unnecessary overhead.

It happens because the wrong flag is checked by the driver:
IEEE80211_F_HTON tells us if 11n is supported by the driver and enabled.
IEEE80211_NODE_HT tells us if 11n is being used with a particular peer.

RTS will still be used for frames larger than the RTS threshold, which
is another, and separate, indicator for enabling RTS.

Index: ar5008.c
===
RCS file: /cvs/src/sys/dev/ic/ar5008.c,v
retrieving revision 1.40
diff -u -p -r1.40 ar5008.c
--- ar5008.c30 Jan 2017 09:42:14 -  1.40
+++ ar5008.c30 Jan 2017 10:22:27 -
@@ -1511,7 +1511,7 @@ ar5008_tx(struct athn_softc *sc, struct 
ds->ds_ctl0 |= AR_TXC0_RTS_ENABLE;
} else if (((ic->ic_flags & IEEE80211_F_USEPROT) &&
athn_rates[ridx[0]].phy == IEEE80211_T_OFDM) ||
-   ((ic->ic_flags & IEEE80211_F_HTON) &&
+   ((ni->ni_flags & IEEE80211_NODE_HT) &&
htprot != IEEE80211_HTPROT_NONE)) {
if (ic->ic_protmode == IEEE80211_PROT_RTSCTS)
ds->ds_ctl0 |= AR_TXC0_RTS_ENABLE;