Sync sys/videoio.h with recent Linux kernel

2017-01-28 Thread Ingo Feinerer
Hi,

in a previous commit
(http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/sys/videoio.h?rev=1.12=text/x-cvsweb-markup)
we updated our V4L2 API. However, one file (v4l2-common.h) could not be
inlined as it was only GPL2 licensed.

After discussion with the authors they agreed to dual license (GPL + BSD) this
file as well
(https://git.linuxtv.org/media_tree.git/commit/?id=80100fd9ebb9f2414892a1178d26a4253e6c0bcf)
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
(https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/include/uapi/linux/videodev2.h?id=refs/tags/v4.10-rc5).

(The sync with a recent Linux videodev2.h is a prerequisite for updating the
port multimedia/libv4l to 1.12.2.)

I compiled a current kernel on amd64. My camera still works fine (tested with
luvcview and baresip in combination with libv4l 1.12.2).

OK?

Best regards,
Ingo

Index: sys/sys/videoio.h
===
RCS file: /cvs/src/sys/sys/videoio.h,v
retrieving revision 1.14
diff -u -p -r1.14 videoio.h
--- sys/sys/videoio.h   27 Jan 2016 13:07:09 -  1.14
+++ sys/sys/videoio.h   28 Jan 2017 10:45:55 -
@@ -3,6 +3,8 @@
  *  Video for Linux Two header file
  *
  *  Copyright (C) 1999-2012 the contributors
+ *  Copyright (C) 2012 Nokia Corporation
+ *  Contact: Sakari Ailus 
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -47,7 +49,7 @@
  * All kernel-specific stuff were moved to media/v4l2-dev.h, so
  * no #if __KERNEL tests are allowed here
  *
- * See http://linuxtv.org for more info
+ * See https://linuxtv.org for more info
  *
  * Author: Bill Dirks 
  * Justin Schoeman
@@ -60,8 +62,84 @@
 #include 
 #include 
 #include 
-/* Ignore #include  as it is GPL2.
- * Inline #include 
+#ifndef __u8
+typedef u_int8_t __u8;
+#endif
+#ifndef __u16
+typedef u_int16_t __u16;
+#endif
+#ifndef __u32
+typedef u_int32_t __u32;
+#endif
+#ifndef __u64
+typedef u_int64_t __u64;
+#endif
+#ifndef __s32
+typedef int32_t __s32;
+#endif
+#ifndef __s64
+typedef int64_t __s64;
+#endif
+#ifndef __le32
+typedef __u32 __le32;
+#endif
+/* Inline #include 
+ * (v4l2-common.h was split off from videodev2.h and has the same BSD license.)
+ *
+ * Begin of v4l2-common.h
+ */
+/*
+ *
+ * Selection interface definitions
+ *
+ */
+
+/* Current cropping area */
+#define V4L2_SEL_TGT_CROP  0x
+/* Default cropping area */
+#define V4L2_SEL_TGT_CROP_DEFAULT  0x0001
+/* Cropping bounds */
+#define V4L2_SEL_TGT_CROP_BOUNDS   0x0002
+/* Native frame size */
+#define V4L2_SEL_TGT_NATIVE_SIZE   0x0003
+/* Current composing area */
+#define V4L2_SEL_TGT_COMPOSE   0x0100
+/* Default composing area */
+#define V4L2_SEL_TGT_COMPOSE_DEFAULT   0x0101
+/* Composing bounds */
+#define V4L2_SEL_TGT_COMPOSE_BOUNDS0x0102
+/* Current composing area plus all padding pixels */
+#define V4L2_SEL_TGT_COMPOSE_PADDED0x0103
+
+/* Backward compatibility target definitions --- to be removed. */
+#define V4L2_SEL_TGT_CROP_ACTIVE   V4L2_SEL_TGT_CROP
+#define V4L2_SEL_TGT_COMPOSE_ACTIVEV4L2_SEL_TGT_COMPOSE
+#define V4L2_SUBDEV_SEL_TGT_CROP_ACTUALV4L2_SEL_TGT_CROP
+#define V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTUAL V4L2_SEL_TGT_COMPOSE
+#define V4L2_SUBDEV_SEL_TGT_CROP_BOUNDSV4L2_SEL_TGT_CROP_BOUNDS
+#define V4L2_SUBDEV_SEL_TGT_COMPOSE_BOUNDS V4L2_SEL_TGT_COMPOSE_BOUNDS
+
+/* Selection flags */
+#define V4L2_SEL_FLAG_GE   (1 << 0)
+#define V4L2_SEL_FLAG_LE   (1 << 1)
+#define V4L2_SEL_FLAG_KEEP_CONFIG  (1 << 2)
+
+/* Backward compatibility flag definitions --- to be removed. */
+#define V4L2_SUBDEV_SEL_FLAG_SIZE_GE   V4L2_SEL_FLAG_GE
+#define V4L2_SUBDEV_SEL_FLAG_SIZE_LE   V4L2_SEL_FLAG_LE
+#define V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG V4L2_SEL_FLAG_KEEP_CONFIG
+
+struct v4l2_edid {
+   __u32 pad;
+   __u32 start_block;
+   __u32 blocks;
+   __u32 reserved[5];
+   __u8  *edid;
+};
+/*
+ * End of v4l2-common.h
+ */
+/* Inline #include 
  * (v4l2-controls.h was split off from videodev2.h and has the same BSD 
license.)
  *
  * Begin of v4l2-controls.h
@@ -175,8 +253,10 @@ enum v4l2_colorfx {
  * We reserve 16 controls for this driver. */
 #define V4L2_CID_USER_S2255_BASE   (V4L2_CID_USER_BASE + 0x1030)
 
-/* The base for the si476x driver controls. See include/media/si476x.h for the 
list
- * of controls. Total of 16 controls is reserved for this driver */
+/*
+ * The base for the si476x driver controls. See include/media/drv-intf/si476x.h
+ * for the list of controls. Total of 16 controls is reserved for this driver
+ */
 #define V4L2_CID_USER_SI476X_BASE  (V4L2_CID_USER_BASE + 0x1040)
 
 /* The base for the TI VPE driver 

Add quirks to support M-Audio FastTrack Pro (uaudio)

2017-01-28 Thread Christopher Zimmermann
Hi,

I needed to add some quirks to support the M-Audio FastTrack Pro USB
audio interface.

* The device needs to be switched to the configuration 2 to show all
  its capabilities. This is done by a new quirk in usb_subr.c
* It claims to consume little-endian samples, but actually expects
  big-endian samples.


OK?

Christopher


Index: uaudio.c
===
RCS file: /cvs/src/sys/dev/usb/uaudio.c,v
retrieving revision 1.122
diff -u -p -r1.122 uaudio.c
--- uaudio.c3 Jan 2017 06:45:58 -   1.122
+++ uaudio.c28 Jan 2017 11:53:17 -
@@ -172,6 +172,7 @@ struct chan {
 #define UAUDIO_FLAG_VENDOR_CLASS 0x0010/* claims vendor class but 
works */
 #define UAUDIO_FLAG_DEPENDENT   0x0020 /* play and record params must equal */
 #define UAUDIO_FLAG_EMU0202 0x0040
+#define UAUDIO_FLAG_FASTTRACKPRO 0x0080
 
 struct uaudio_devs {
struct usb_devno uv_dev;
@@ -223,7 +224,9 @@ struct uaudio_devs {
{ { USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_QUICKCAMZOOM },
UAUDIO_FLAG_BAD_AUDIO },
{ { USB_VENDOR_TELEX, USB_PRODUCT_TELEX_MIC1 },
-   UAUDIO_FLAG_NO_FRAC }
+   UAUDIO_FLAG_NO_FRAC },
+   { { USB_VENDOR_MIDIMAN, USB_PRODUCT_MIDIMAN_FASTTRACKPRO },
+   UAUDIO_FLAG_FASTTRACKPRO | UAUDIO_FLAG_DEPENDENT }
 };
 #define uaudio_lookup(v, p) \
((struct uaudio_devs *)usb_lookup(uaudio_devs, v, p))
@@ -531,8 +534,18 @@ uaudio_attach(struct device *parent, str
found = 1;
}
}
-   if (found)
+   if (found) {
usbd_claim_iface(sc->sc_udev, i);
+   if (sc->sc_quirks & UAUDIO_FLAG_FASTTRACKPRO) {
+   /* temporarily switch every iface to 24bit.
+* Causes the device to be big endian even
+* for 16bit samples.
+* using 16bits first will cause the device
+* to break when we later switch to 24bit. */
+   usbd_set_interface(sc->sc_alts[i].ifaceh, 2);
+   usbd_set_interface(sc->sc_alts[i].ifaceh, 0);
+   }
+   }
}
 
for (j = 0; j < sc->sc_nalts; j++) {
@@ -1662,7 +1675,10 @@ uaudio_process_as(struct uaudio_softc *s
} else if (prec == 24) {
sc->sc_altflags |= HAS_24;
}
-   enc = AUDIO_ENCODING_SLINEAR_LE;
+   if (sc->sc_quirks & UAUDIO_FLAG_FASTTRACKPRO)
+   enc = AUDIO_ENCODING_SLINEAR_BE;
+   else
+   enc = AUDIO_ENCODING_SLINEAR_LE;
format_str = "pcm";
break;
case UA_FMT_PCM8:
@@ -1687,9 +1703,13 @@ uaudio_process_as(struct uaudio_softc *s
return (USBD_NORMAL_COMPLETION);
}
 #ifdef UAUDIO_DEBUG
-   printf("%s: %s: %d-ch %d-bit %d-byte %s,", sc->sc_dev.dv_xname,
+   printf("%s: %s: alt %d(%d) for interface %d %d-ch %d-bit %d-byte %s enc 
%d,",
+  sc->sc_dev.dv_xname,
   dir == UE_DIR_IN ? "recording" : "playback",
-  chan, prec, bps, format_str);
+  id->bAlternateSetting,
+  sc->sc_nalts,
+  id->bInterfaceNumber,
+  chan, prec, bps, format_str, enc);
if (asf1d->bSamFreqType == UA_SAMP_CONTNUOUS) {
printf(" %d-%dHz\n", UA_SAMP_LO(asf1d), UA_SAMP_HI(asf1d));
} else {
@@ -3312,6 +3332,9 @@ uaudio_set_params(void *addr, int setmod
}
break;
}
+
+   if (sc->sc_quirks & UAUDIO_FLAG_FASTTRACKPRO)
+   p->encoding = AUDIO_ENCODING_SLINEAR_BE;
 
i = uaudio_match_alt(sc, p, mode);
if (i < 0) {
Index: usb_quirks.c
===
RCS file: /cvs/src/sys/dev/usb/usb_quirks.c,v
retrieving revision 1.74
diff -u -p -r1.74 usb_quirks.c
--- usb_quirks.c27 Nov 2015 10:59:32 -  1.74
+++ usb_quirks.c28 Jan 2017 11:53:17 -
@@ -67,6 +67,8 @@ const struct usbd_quirk_entry {
0x001, { UQ_ASSUME_CM_OVER_DATA }},
  { USB_VENDOR_EICON, USB_PRODUCT_EICON_DIVA852,
0x100, { UQ_ASSUME_CM_OVER_DATA }},
+ { USB_VENDOR_MIDIMAN, USB_PRODUCT_MIDIMAN_FASTTRACKPRO,
+   0x100, { 1 << UQ_CONFIG_SHIFT }},
  /* YAMAHA router's ucdDevice is the version of firmware and often changes. */
  { USB_VENDOR_YAMAHA, USB_PRODUCT_YAMAHA_RTA54I,
ANY, { UQ_ASSUME_CM_OVER_DATA }},
Index: usb_quirks.h
===
RCS file: /cvs/src/sys/dev/usb/usb_quirks.h,v
retrieving revision 1.16
diff -u -p -r1.16 usb_quirks.h
--- usb_quirks.h

Re: mira sfer overflow panic (was: Re: 11n support for athn(4))

2017-01-28 Thread Stefan Sperling
On Thu, Jan 26, 2017 at 10:38:44AM +0100, Stefan Sperling wrote:
> On Thu, Jan 26, 2017 at 06:36:06AM +, Peter Kay wrote:
> > sfer overflow
> 
> Interesting. This is the first time I've ever seen this panic trigger.
> 
> Can you apply this patch and try to trigger it again?

Peter, you can throw the diff below away and update your src tree.

I have just committed a better diff. These errors are recoverable so
there is no real reason to panic when they occur. To see the problem
with this new code, you'll need to run 'ifconfig athn0 debug'. This
will log what used to be the panic message to dmesg, including the
MAC address of the client which triggered it.

To also get the driver stats we need to debug the problem, please compile
a kernel with 'option MIRA_DEBUG' (or add a line '#define MIRA_DEBUG'
at the top of ieee80211_mira.c before compiling the kernel).
This will print the stats as well so we can see why sfer is overflowing.
MIRA_DEBUG will also cause some other noise (e.g. when mira selects a
new rate). You can ignore that.

> Index: ieee80211_mira.c
> ===
> RCS file: /cvs/src/sys/net80211/ieee80211_mira.c,v
> retrieving revision 1.8
> diff -u -p -r1.8 ieee80211_mira.c
> --- ieee80211_mira.c  12 Jan 2017 18:06:57 -  1.8
> +++ ieee80211_mira.c  26 Jan 2017 09:37:27 -
> @@ -427,8 +427,15 @@ ieee80211_mira_update_stats(struct ieee8
>  
>   /* Compute Sub-Frame Error Rate (see section 2.2 in MiRA paper). */
>   sfer = (mn->frames * mn->retries + mn->txfail);
> - if ((sfer >> MIRA_FP_SHIFT) != 0)
> + if ((sfer >> MIRA_FP_SHIFT) != 0) {
> + printf("%s: driver stats:\n", __func__);
> + printf("mn->frames = %u\n", mn->frames);
> + printf("mn->retries = %u\n", mn->retries);
> + printf("mn->txfail = %u\n", mn->txfail);
> + printf("mn->ampdu_size = %u\n", mn->ampdu_size);
> + printf("mn->agglen = %u\n", mn->agglen);
>   panic("sfer overflow"); /* bug in wifi driver */
> + }
>   sfer <<= MIRA_FP_SHIFT; /* convert to fixed-point */
>   sfer /= ((mn->retries + 1) * mn->frames);
>   if (sfer > MIRA_FP_1)
> 



sys/dev/uaudio.c: Fix broken links

2017-01-28 Thread Michael Reed

Index: uaudio.c
===
RCS file: /cvs/src/sys/dev/usb/uaudio.c,v
retrieving revision 1.122
diff -u -p -r1.122 uaudio.c
--- uaudio.c3 Jan 2017 06:45:58 -   1.122
+++ uaudio.c28 Jan 2017 15:57:12 -
@@ -32,9 +32,9 @@
  */
 
 /*

- * USB audio specs: http://www.usb.org/developers/devclass_docs/audio10.pdf
- *  http://www.usb.org/developers/devclass_docs/frmts10.pdf
- *  http://www.usb.org/developers/devclass_docs/termt10.pdf
+ * USB audio specs: 
http://www.usb.org/developers/docs/devclass_docs/audio10.pdf
+ *  
http://www.usb.org/developers/docs/devclass_docs/frmts10.pdf
+ *  
http://www.usb.org/developers/docs/devclass_docs/termt10.pdf
  */
 
 #include 




Re: iwn: Centrino Ultimate-N 6300 scans, doesn't dhcp?

2017-01-28 Thread Johnathan Foong
On Thu, 26 Jan 2017 at 5:35 PM, Stefan Sperling  wrote:

> On Wed, Jan 25, 2017 at 08:43:11PM -0600, Austin Bentley wrote:
> > Interesting. It seems that on OpenBSD the reception is quite weak.
> > I've connected, HOWEVER, I have to be in the same room as my router!
> > On Linux I can be anywhere in my house.
> >
> > I tried disabling powersave (-powersave), and still I have to be very
>
> I believe the powersave option is a no-op with iwn(4) so I am
> not surprised it doesn't change anything.
>
> > close to my router. My phone can connect to it no problem anywhere in
> > the house. Does anyone have any clue what's going on? Is it possible
> > that the driver is permanently set on a power save mode?
>
> Well, it seems something strange is going on since it works with Linux.
>
> It is not clear whether the problem is with sending or receiving.
> I would guess it is more likely that iwn(4) has some problem with
> sending data, rather than receiving it. Both have to work to associate
> successfully.
>
> You can enable some debug output like this:
>
>   ifconfig iwn0 debug
>
> Look in /var/log/messages. Any beacon received should be mentioned there,
> and in case a WPA handshare is attempted you should see this as well.
>
> Perhaps the problem has to do with regdomain settings? iwn(4) does not
> do anything about those -- it relies on hardware/firmware defaults.
> Does Linux print anything about regulatory domains in its dmesg?
>
> > On Wed, Jan 25, 2017 at 7:37 PM, Austin Bentley  wrote:
> > >  nwid MYSSID chan 6 bssid yy:yy:yy:yy:yy:yy -58dBm HT-MCS15
> > >  privacy,short_slottime,wpa1
>
> Do you also happen to have this AP on a 5GHz channel or is this
> AP on 2GHz only? If iwn(4) is trying to connect on 5GHz instead of 2,
> that would explain why it doesn't work well through walls.
>

I'm facing similar issues and assuming it was a router incompatibility
Issue that causes this to happen.

>
>


err with multiple TLS sites but one OCSP?

2017-01-28 Thread Bob Beck

Sooo.. 

Pretty sure mlucas has uncovered a problem with the ocsp interface. 

Basically I didn't attach it to the keypair, (yes Joel, I think you
told me so) so it only works with the master keypair.. OK, but the
problem is that it also returns the staple for other keypairs which is
wrong. 

This attaches the ocsp staple to the keypair, rather than the config. 

It does not yet add a way to change it for keypairs other than the
master - that will require an API change - but with this change
it should not return an incorrect ocsp staple for the non primary
keypair. I'll deal with the API change separately after pestering
joel about it a bit.

ok?

Index: tls_config.c
===
RCS file: /cvs/src/lib/libtls/tls_config.c,v
retrieving revision 1.34
diff -u -p -u -p -r1.34 tls_config.c
--- tls_config.c24 Jan 2017 01:48:05 -  1.34
+++ tls_config.c28 Jan 2017 21:40:14 -
@@ -101,6 +101,26 @@ tls_keypair_set_key_mem(struct tls_keypa
return set_mem(>key_mem, >key_len, key, len);
 }
 
+static int
+tls_keypair_set_ocsp_staple_file(struct tls_keypair *keypair,
+struct tls_error *error, const char *ocsp_file)
+{
+   if (keypair->ocsp_staple != NULL)
+   explicit_bzero(keypair->ocsp_staple, keypair->ocsp_staple_len);
+   return tls_config_load_file(error, "ocsp", ocsp_file,
+   >ocsp_staple, >ocsp_staple_len);
+}
+
+static int
+tls_keypair_set_ocsp_staple_mem(struct tls_keypair *keypair,
+const uint8_t *staple, size_t len)
+{
+   if (keypair->ocsp_staple != NULL)
+   explicit_bzero(keypair->ocsp_staple, keypair->ocsp_staple_len);
+   return set_mem(>ocsp_staple, >ocsp_staple_len, staple,
+   len);
+}
+
 static void
 tls_keypair_clear(struct tls_keypair *keypair)
 {
@@ -241,7 +261,6 @@ tls_config_free(struct tls_config *confi
free((char *)config->ca_mem);
free((char *)config->ca_path);
free((char *)config->ciphers);
-   free(config->ocsp_staple);
 
free(config);
 }
@@ -664,14 +683,14 @@ tls_config_verify_client_optional(struct
 int
 tls_config_set_ocsp_staple_file(struct tls_config *config, const char 
*staple_file)
 {
-   return tls_config_load_file(>error, "OCSP", staple_file,
-   >ocsp_staple, >ocsp_staple_len);
+   return tls_keypair_set_ocsp_staple_file(config->keypair, >error,
+   staple_file);
 }
 
 int
 tls_config_set_ocsp_staple_mem(struct tls_config *config, char *staple, size_t 
len)
 {
-   return set_mem(>ocsp_staple, >ocsp_staple_len, staple, 
len);
+   return tls_keypair_set_ocsp_staple_mem(config->keypair, staple, len);
 }
 
 int
Index: tls_internal.h
===
RCS file: /cvs/src/lib/libtls/tls_internal.h,v
retrieving revision 1.52
diff -u -p -u -p -r1.52 tls_internal.h
--- tls_internal.h  26 Jan 2017 12:56:37 -  1.52
+++ tls_internal.h  28 Jan 2017 21:07:25 -
@@ -51,6 +51,8 @@ struct tls_keypair {
size_t cert_len;
char *key_mem;
size_t key_len;
+   char *ocsp_staple;
+   size_t ocsp_staple_len;
 };
 
 #define TLS_MIN_SESSION_TIMEOUT (4)
@@ -83,8 +85,6 @@ struct tls_config {
int ecdhecurve;
struct tls_keypair *keypair;
int ocsp_require_stapling;
-   char *ocsp_staple;
-   size_t ocsp_staple_len;
uint32_t protocols;
unsigned char session_id[TLS_MAX_SESSION_ID_LENGTH];
int session_lifetime;
Index: tls_ocsp.c
===
RCS file: /cvs/src/lib/libtls/tls_ocsp.c,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 tls_ocsp.c
--- tls_ocsp.c  27 Jan 2017 07:03:27 -  1.10
+++ tls_ocsp.c  28 Jan 2017 21:42:22 -
@@ -332,17 +332,19 @@ tls_ocsp_stapling_cb(SSL *ssl, void *arg
if ((ctx = SSL_get_app_data(ssl)) == NULL)
goto err;
 
-   if (ctx->config->ocsp_staple == NULL ||
-   ctx->config->ocsp_staple_len == 0)
+   if (ctx->config->keypair->ocsp_staple == NULL ||
+   ctx->config->keypair->ocsp_staple == NULL ||
+   ctx->config->keypair->ocsp_staple_len == 0)
return SSL_TLSEXT_ERR_NOACK;
 
-   if ((ocsp_staple = malloc(ctx->config->ocsp_staple_len)) == NULL)
+   if ((ocsp_staple = malloc(ctx->config->keypair->ocsp_staple_len)) ==
+   NULL)
goto err;
 
-   memcpy(ocsp_staple, ctx->config->ocsp_staple,
-   ctx->config->ocsp_staple_len);
+   memcpy(ocsp_staple, ctx->config->keypair->ocsp_staple,
+   ctx->config->keypair->ocsp_staple_len);
if (SSL_set_tlsext_status_ocsp_resp(ctx->ssl_conn, ocsp_staple,
-   ctx->config->ocsp_staple_len) != 1)
+   ctx->config->keypair->ocsp_staple_len) != 1)
goto err;
 
ret = SSL_TLSEXT_ERR_OK;



Re: acme-client.1: fix broken example

2017-01-28 Thread Jason McIntyre
On Sat, Jan 28, 2017 at 11:17:19AM -0500, Michael Reed wrote:
> One of the examples is broken:
> 
>   $ acme-client -vN www.example.com
>   acme-client: unknown option -- N
>   usage: acme-client [-ADFnrv] [-f configfile] domain
> 
> This commit [0] makes me think that -D should be used instead, but
> I'm not sure.
> 

correct (at least, going by that log)

> P.s.: This man page also contains a reference to a non-existant Challenges
> section (".Sx Challenges"); I haven't included a patch as I don't know how
> best to address it.
> 

the Challenges section got removed in -r1.11, but the reference was
never updated, in a piece of sloppy editing by a developer who shall
remain nameless.

both issues fixed now. thanks for the mail.

jmc

> [0]: 
> https://github.com/openbsd/src/commit/2453e683be3ff3f89bf7f499869580fa120a059d
> 
> 
> 
> Index: acme-client.1
> ===
> RCS file: /cvs/src/usr.sbin/acme-client/acme-client.1,v
> retrieving revision 1.19
> diff -u -p -r1.19 acme-client.1
> --- acme-client.1   21 Jan 2017 15:53:15 -  1.19
> +++ acme-client.1   28 Jan 2017 16:11:39 -
> @@ -104,7 +104,7 @@ as in the
>  .Sx Challenges
>  section:
>  .Pp
> -.Dl # acme-client -vN www.example.com
> +.Dl # acme-client -vD www.example.com
>  .Pp
>  A daily
>  .Xr cron 8
> 



clang and -Werror vs -Wpointer-sign

2017-01-28 Thread Jonathan Gray
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.

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/Makefile  21 Jan 2017 09:38:58 -  1.14
+++ lib/libcrypto/Makefile  29 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
 



Re: 11n support for athn(4)

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

> This diff adds 11n support to the athn(4) driver.
> Requires -current net80211 code from today.
>
> Tested in hostap mode and client mode with:
> athn0 at pci1 dev 0 function 0 "Atheros AR9281" rev 0x01: apic 2 int 16
> athn0: AR9280 rev 2 (2T2R), ROM rev 22, adddress xx:xx:xx:xx:xx:xx
>
> And in client mode with:
> athn0 at uhub1 port 2 configuration 1 interface 0 "ATHEROS USB2.0 WLAN" rev 
> 2.00/1.08 addr 2
> athn0: AR9271 rev 1 (1T1R), ROM rev 13, address xx:xx:xx:xx:xx:xx
>
> Hostap performance is not perfect yet but should be no worse than
> 11a/b/g modes in the same environment.
>
> For Linux clients a fix for WME params is needed which I also posted to tech@.
>
> This diff does not modify the known-broken and disabled ar9003 code,
> apart from making sure it still builds.
>
> I'm looking for both tests and OKs.
>
> Index: dev/cardbus/if_athn_cardbus.c
> ===
> RCS file: /cvs/src/sys/dev/cardbus/if_athn_cardbus.c,v
> retrieving revision 1.14
> diff -u -p -r1.14 if_athn_cardbus.c
> --- dev/cardbus/if_athn_cardbus.c 24 Nov 2015 17:11:39 -  1.14
> +++ dev/cardbus/if_athn_cardbus.c 8 Jan 2017 09:31:28 -
> @@ -43,6 +43,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #include 
> Index: dev/ic/ar5008.c
> ===
> RCS file: /cvs/src/sys/dev/ic/ar5008.c,v
> retrieving revision 1.37
> diff -u -p -r1.37 ar5008.c
> --- dev/ic/ar5008.c   29 Nov 2016 10:22:30 -  1.37
> +++ dev/ic/ar5008.c   9 Jan 2017 10:14:41 -
> @@ -51,6 +51,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #include 
> @@ -217,7 +218,7 @@ ar5008_attach(struct athn_softc *sc)
>   sc->flags |= ATHN_FLAG_11A;
>   if (base->opCapFlags & AR_OPFLAGS_11G)
>   sc->flags |= ATHN_FLAG_11G;
> - if (base->opCapFlags & AR_OPFLAGS_11N)
> + if ((base->opCapFlags & AR_OPFLAGS_11N_DISABLED) == 0)
>   sc->flags |= ATHN_FLAG_11N;
>  
>   IEEE80211_ADDR_COPY(ic->ic_myaddr, base->macAddr);
> @@ -952,9 +953,11 @@ ar5008_tx_process(struct athn_softc *sc,
>   struct ifnet *ifp = >ic_if;
>   struct athn_txq *txq = >txq[qid];
>   struct athn_node *an;
> + struct ieee80211_node *ni;
>   struct athn_tx_buf *bf;
>   struct ar_tx_desc *ds;
>   uint8_t failcnt;
> + int txfail;
>  
>   bf = SIMPLEQ_FIRST(>head);
>   if (bf == NULL)
> @@ -970,13 +973,16 @@ ar5008_tx_process(struct athn_softc *sc,
>  
>   sc->sc_tx_timer = 0;
>  
> - if (ds->ds_status1 & AR_TXS1_EXCESSIVE_RETRIES)
> + txfail = (ds->ds_status1 & AR_TXS1_EXCESSIVE_RETRIES);
> + if (txfail)
>   ifp->if_oerrors++;
>  
>   if (ds->ds_status1 & AR_TXS1_UNDERRUN)
>   athn_inc_tx_trigger_level(sc);
>  
>   an = (struct athn_node *)bf->bf_ni;
> + ni = (struct ieee80211_node *)bf->bf_ni;
> +
>   /*
>* NB: the data fail count contains the number of un-acked tries
>* for the final series used.  We must add the number of tries for
> @@ -987,10 +993,27 @@ ar5008_tx_process(struct athn_softc *sc,
>   failcnt += MS(ds->ds_status9, AR_TXS9_FINAL_IDX) * 2;
>  
>   /* Update rate control statistics. */
> - an->amn.amn_txcnt++;
> - if (failcnt > 0)
> - an->amn.amn_retrycnt++;
> -
> + if (ni->ni_flags & IEEE80211_NODE_HT) {
> + an->mn.frames++;
> + an->mn.ampdu_size = bf->bf_m->m_pkthdr.len + IEEE80211_CRC_LEN;
> + an->mn.agglen = 1; /* XXX We do not yet support Tx agg. */
> + if (failcnt > 0)
> + an->mn.retries++;
> + if (txfail)
> + an->mn.txfail++;
> + if ((ic->ic_opmode == IEEE80211_M_STA &&
> + ic->ic_state == IEEE80211_S_RUN)
> +#ifndef IEEE80211_STA_ONLY
> + || (ic->ic_opmode == IEEE80211_M_HOSTAP &&
> + ni->ni_state == IEEE80211_STA_ASSOC)
> +#endif
> + )
> + ieee80211_mira_choose(>mn, ic, ni);
> + } else {
> + an->amn.amn_txcnt++;
> + if (failcnt > 0)
> + an->amn.amn_retrycnt++;
> + }
>   DPRINTFN(5, ("Tx done qid=%d status1=%d fail count=%d\n",
>   qid, ds->ds_status1, failcnt));
>  
> @@ -1110,7 +1133,7 @@ ar5008_swba_intr(struct athn_softc *sc)
>   ds->ds_ctl2 = SM(AR_TXC2_XMIT_DATA_TRIES0, 1);
>  
>   /* Write Tx rate. */
> - ridx = (ic->ic_curmode == IEEE80211_MODE_11A) ?
> + ridx = IEEE80211_IS_CHAN_5GHZ(ni->ni_chan) ?
>   ATHN_RIDX_OFDM6 : ATHN_RIDX_CCK1;
>   hwrate = athn_rates[ridx].hwrate;
>   ds->ds_ctl3 = SM(AR_TXC3_XMIT_RATE0, hwrate);
> @@ -1315,15 +1338,25 @@ ar5008_tx(struct athn_softc *sc, struct 
>   IEEE80211_FC0_TYPE_DATA) {
>   /* Use lowest rate for all tries. */
>