svn commit: r361240 - in stable/12: share/man/man4 sys/dev/rtwn/usb sys/dev/usb

2020-05-18 Thread Mark Johnston
Author: markj
Date: Tue May 19 03:24:45 2020
New Revision: 361240
URL: https://svnweb.freebsd.org/changeset/base/361240

Log:
  MFC r360966:
  rtwn: Add a USB ID for the TP-Link TL-WN727N.
  
  PR:   246417

Modified:
  stable/12/share/man/man4/rtwn_usb.4
  stable/12/sys/dev/rtwn/usb/rtwn_usb_attach.h
  stable/12/sys/dev/usb/usbdevs
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/share/man/man4/rtwn_usb.4
==
--- stable/12/share/man/man4/rtwn_usb.4 Tue May 19 03:19:01 2020
(r361239)
+++ stable/12/share/man/man4/rtwn_usb.4 Tue May 19 03:24:45 2020
(r361240)
@@ -29,7 +29,7 @@
 .\"
 .\" $FreeBSD$
 .\"/
-.Dd May 9, 2020
+.Dd May 12, 2020
 .Dt RTWN_USB 4
 .Os
 .Sh NAME
@@ -103,6 +103,7 @@ based USB wireless network adapters, including:
 .It "TP-Link TL-WN722N v2" Ta RTL8188EU Ta USB 2.0
 .It "TP-LINK TL-WN723N v3" Ta RTL8188EU Ta USB 2.0
 .It "TP-LINK TL-WN725N v2" Ta RTL8188EU Ta USB 2.0
+.It "TP-LINK TL-WN727N v5" Ta RTL8188EU Ta USB 2.0
 .It "TP-LINK TL-WN821N v4" Ta RTL8192CU Ta USB 2.0
 .It "TP-LINK TL-WN821N v5" Ta RTL8192EU Ta USB 2.0
 .It "TP-LINK TL-WN822N v4" Ta RTL8192EU Ta USB 2.0

Modified: stable/12/sys/dev/rtwn/usb/rtwn_usb_attach.h
==
--- stable/12/sys/dev/rtwn/usb/rtwn_usb_attach.hTue May 19 03:19:01 
2020(r361239)
+++ stable/12/sys/dev/rtwn/usb/rtwn_usb_attach.hTue May 19 03:24:45 
2020(r361240)
@@ -120,6 +120,7 @@ static const STRUCT_USB_HOST_ID rtwn_devs[] = {
RTWN_RTL8188EU_DEV(DLINK,   DWA125D1),
RTWN_RTL8188EU_DEV(ELECOM,  WDC150SU2M),
RTWN_RTL8188EU_DEV(TPLINK,  WN722NV2),
+   RTWN_RTL8188EU_DEV(TPLINK,  WN727NV5),
RTWN_RTL8188EU_DEV(REALTEK, RTL8188ETV),
RTWN_RTL8188EU_DEV(REALTEK, RTL8188EU),
 #undef RTWN_RTL8188EU_DEV

Modified: stable/12/sys/dev/usb/usbdevs
==
--- stable/12/sys/dev/usb/usbdevs   Tue May 19 03:19:01 2020
(r361239)
+++ stable/12/sys/dev/usb/usbdevs   Tue May 19 03:24:45 2020
(r361240)
@@ -4663,6 +4663,7 @@ product TPLINK WN821NV5   0x0107  TL-WN821N v5
 product TPLINK WN822NV40x0108  TL-WN822N v4
 product TPLINK WN823NV20x0109  TL-WN823N v2
 product TPLINK WN722NV20x010c  TL-WN722N v2
+product TPLINK WN727NV50x0111  TL-WN727N v5
 product TPLINK T4UV2   0x010d  Archer T4U ver 2
 product TPLINK T4UHV1  0x0103  Archer T4UH ver 1
 product TPLINK T4UHV2  0x010e  Archer T4UH ver 2
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361239 - head

2020-05-18 Thread Kyle Evans
Author: kevans
Date: Tue May 19 03:19:01 2020
New Revision: 361239
URL: https://svnweb.freebsd.org/changeset/base/361239

Log:
  Belated RELNOTES entry for r361238
  
  This may get revised later if the larger change lands, but we should note
  this.

Modified:
  head/RELNOTES

Modified: head/RELNOTES
==
--- head/RELNOTES   Tue May 19 02:41:05 2020(r361238)
+++ head/RELNOTES   Tue May 19 03:19:01 2020(r361239)
@@ -10,6 +10,9 @@ newline.  Entries should be separated by a newline.
 
 Changes to this file should not be MFCed.
 
+r361238:
+   ZFS will now reject read(2) of a dirfd with EISDIR.
+
 r360920,r360923,r360924,r360927,r360928,r360931,r360933,r360936:
Remove support for ARC4, Blowfish, Cast, DES, Triple DES, MD5,
MD5-KPDK, MD5-HMAC, SHA1-KPDK, and Skipjack algorithms from
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361238 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2020-05-18 Thread Kyle Evans
Author: kevans
Date: Tue May 19 02:41:05 2020
New Revision: 361238
URL: https://svnweb.freebsd.org/changeset/base/361238

Log:
  zfs: reject read(2) of a dirfd with EISDIR
  
  This is independent of the recently-discussed global change, which is still
  in review/discussion stage.
  
  This is effectively a measure for consistency in the ZFS world, where
  FreeBSD was the only platform (as far as I could find) that allowed this.
  What ZFS exposes is decidedly not useful for any real purposes, to
  paraphrase (hopefully faithfully) jhb's findings when exploring this:
  
  The size of a directory in ZFS is the number of directory entries within.
  When reading a directory, you would instead get the leading part of its raw
  contents; the amount you get being dictated by the "size," i.e. number of
  directory entries. There's decidedly (luckily) no stack disclosure happening
  here, though the behavior is bizarre and almost certainly a historical
  accident.
  
  This change has already been upstreamed to OpenZFS.
  
  MFC after:1 week

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Tue May 
19 02:07:08 2020(r361237)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Tue May 
19 02:41:05 2020(r361238)
@@ -646,6 +646,12 @@ zfs_read(vnode_t *vp, uio_t *uio, int ioflag, cred_t *
ZFS_ENTER(zfsvfs);
ZFS_VERIFY_ZP(zp);
 
+   /* We don't copy out anything useful for directories. */
+   if (vp->v_type == VDIR) {
+   ZFS_EXIT(zfsvfs);
+   return (SET_ERROR(EISDIR));
+   }
+
if (zp->z_pflags & ZFS_AV_QUARANTINED) {
ZFS_EXIT(zfsvfs);
return (SET_ERROR(EACCES));
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361237 - head/tests/sys/netinet

2020-05-18 Thread Li-Wen Hsu
Author: lwhsu
Date: Tue May 19 02:07:08 2020
New Revision: 361237
URL: https://svnweb.freebsd.org/changeset/base/361237

Log:
  Temporarily disable test case causes kernel panic in CI:
  
  - sys.netinet.so_reuseport_lb_test.basic_ipv6
  
  PR:   246560
  Sponsored by: The FreeBSD Foundation

Modified:
  head/tests/sys/netinet/so_reuseport_lb_test.c

Modified: head/tests/sys/netinet/so_reuseport_lb_test.c
==
--- head/tests/sys/netinet/so_reuseport_lb_test.c   Tue May 19 01:43:00 
2020(r361236)
+++ head/tests/sys/netinet/so_reuseport_lb_test.c   Tue May 19 02:07:08 
2020(r361237)
@@ -188,6 +188,9 @@ ATF_TC_BODY(basic_ipv6, tc)
int error, sds[16];
uint16_t port;
 
+   if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false))
+   atf_tc_skip("https://bugs.freebsd.org/246560;);
+
sds[0] = lb_listen_socket(PF_INET6, SOCK_NONBLOCK);
 
memset(, 0, sizeof(addr));
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361236 - in stable: 11/sys/fs/nfs 11/sys/fs/nfsclient 11/sys/fs/nfsserver 12/sys/fs/nfs 12/sys/fs/nfsclient 12/sys/fs/nfsserver

2020-05-18 Thread Ryan Moeller
Author: freqlabs
Date: Tue May 19 01:43:00 2020
New Revision: 361236
URL: https://svnweb.freebsd.org/changeset/base/361236

Log:
  MFC r360960:
  
  nfs: Remove APPLESTATIC macro
  
  It is no longer useful.
  
  Reviewed by:rmacklem
  Approved by:mav (mentor)
  Sponsored by:   iXsystems, Inc.
  Differential Revision:  https://reviews.freebsd.org/D24811

Modified:
  stable/12/sys/fs/nfs/nfs_commonacl.c
  stable/12/sys/fs/nfs/nfs_commonsubs.c
  stable/12/sys/fs/nfs/nfsport.h
  stable/12/sys/fs/nfsclient/nfs_clcomsubs.c
  stable/12/sys/fs/nfsclient/nfs_clport.c
  stable/12/sys/fs/nfsclient/nfs_clrpcops.c
  stable/12/sys/fs/nfsclient/nfs_clstate.c
  stable/12/sys/fs/nfsserver/nfs_nfsdcache.c
  stable/12/sys/fs/nfsserver/nfs_nfsdserv.c
  stable/12/sys/fs/nfsserver/nfs_nfsdsocket.c
  stable/12/sys/fs/nfsserver/nfs_nfsdstate.c
  stable/12/sys/fs/nfsserver/nfs_nfsdsubs.c
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/sys/fs/nfs/nfs_commonacl.c
  stable/11/sys/fs/nfs/nfs_commonsubs.c
  stable/11/sys/fs/nfs/nfsport.h
  stable/11/sys/fs/nfsclient/nfs_clcomsubs.c
  stable/11/sys/fs/nfsclient/nfs_clport.c
  stable/11/sys/fs/nfsclient/nfs_clrpcops.c
  stable/11/sys/fs/nfsclient/nfs_clstate.c
  stable/11/sys/fs/nfsserver/nfs_nfsdcache.c
  stable/11/sys/fs/nfsserver/nfs_nfsdserv.c
  stable/11/sys/fs/nfsserver/nfs_nfsdsocket.c
  stable/11/sys/fs/nfsserver/nfs_nfsdstate.c
  stable/11/sys/fs/nfsserver/nfs_nfsdsubs.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/sys/fs/nfs/nfs_commonacl.c
==
--- stable/12/sys/fs/nfs/nfs_commonacl.cTue May 19 01:40:45 2020
(r361235)
+++ stable/12/sys/fs/nfs/nfs_commonacl.cTue May 19 01:43:00 2020
(r361236)
@@ -40,7 +40,7 @@ static int nfsrv_acemasktoperm(u_int32_t acetype, u_in
 /*
  * Handle xdr for an ace.
  */
-APPLESTATIC int
+int
 nfsrv_dissectace(struct nfsrv_descript *nd, struct acl_entry *acep,
 int *aceerrp, int *acesizep, NFSPROC_T *p)
 {
@@ -388,7 +388,7 @@ nfsrv_buildace(struct nfsrv_descript *nd, u_char *name
 /*
  * Build an NFSv4 ACL.
  */
-APPLESTATIC int
+int
 nfsrv_buildacl(struct nfsrv_descript *nd, NFSACL_T *aclp, enum vtype type,
 NFSPROC_T *p)
 {
@@ -451,7 +451,7 @@ nfsrv_buildacl(struct nfsrv_descript *nd, NFSACL_T *ac
  * Compare two NFSv4 acls.
  * Return 0 if they are the same, 1 if not the same.
  */
-APPLESTATIC int
+int
 nfsrv_compareacl(NFSACL_T *aclp1, NFSACL_T *aclp2)
 {
int i;

Modified: stable/12/sys/fs/nfs/nfs_commonsubs.c
==
--- stable/12/sys/fs/nfs/nfs_commonsubs.c   Tue May 19 01:40:45 2020
(r361235)
+++ stable/12/sys/fs/nfs/nfs_commonsubs.c   Tue May 19 01:43:00 2020
(r361236)
@@ -282,7 +282,7 @@ static int nfs_bigrequest[NFSV41_NPROCS] = {
  * Start building a request. Mostly just put the first file handle in
  * place.
  */
-APPLESTATIC void
+void
 nfscl_reqstart(struct nfsrv_descript *nd, int procnum, struct nfsmount *nmp,
 u_int8_t *nfhp, int fhlen, u_int32_t **opcntpp, struct nfsclsession *sep,
 int vers, int minorvers)
@@ -415,7 +415,7 @@ nfscl_reqstart(struct nfsrv_descript *nd, int procnum,
 /*
  * Put a state Id in the mbuf list.
  */
-APPLESTATIC void
+void
 nfsm_stateidtom(struct nfsrv_descript *nd, nfsv4stateid_t *stateidp, int flag)
 {
nfsv4stateid_t *st;
@@ -651,7 +651,7 @@ out:
  * This is used by the macro NFSM_DISSECT for tough
  * cases.
  */
-APPLESTATIC void *
+void *
 nfsm_dissct(struct nfsrv_descript *nd, int siz, int how)
 {
mbuf_t mp2;
@@ -717,7 +717,7 @@ nfsm_dissct(struct nfsrv_descript *nd, int siz, int ho
  * here than check for offs > 0 for all calls to nfsm_advance.
  * If left == -1, it should be calculated here.
  */
-APPLESTATIC int
+int
 nfsm_advance(struct nfsrv_descript *nd, int offs, int left)
 {
int error = 0;
@@ -765,7 +765,7 @@ out:
  * Copy a string into mbuf(s).
  * Return the number of bytes output, including XDR overheads.
  */
-APPLESTATIC int
+int
 nfsm_strtom(struct nfsrv_descript *nd, const char *cp, int siz)
 {
mbuf_t m2;
@@ -822,7 +822,7 @@ nfsm_strtom(struct nfsrv_descript *nd, const char *cp,
 /*
  * Called once to initialize data structures...
  */
-APPLESTATIC void
+void
 newnfs_init(void)
 {
static int nfs_inited = 0;
@@ -852,7 +852,7 @@ newnfs_init(void)
  * set_true == 1 if there should be an newnfs_true prepended on the file 
handle.
  * Return the number of bytes output, including XDR overhead.
  */
-APPLESTATIC int
+int
 nfsm_fhtom(struct nfsrv_descript *nd, u_int8_t *fhp, int size, int set_true)
 {
u_int32_t *tl;
@@ -895,7 +895,7 @@ nfsm_fhtom(struct nfsrv_descript *nd, u_int8_t *fhp, i
  * The AF_INET family is handled as a special case so that address mbufs
  * don't need to be saved to store "struct 

svn commit: r361236 - in stable: 11/sys/fs/nfs 11/sys/fs/nfsclient 11/sys/fs/nfsserver 12/sys/fs/nfs 12/sys/fs/nfsclient 12/sys/fs/nfsserver

2020-05-18 Thread Ryan Moeller
Author: freqlabs
Date: Tue May 19 01:43:00 2020
New Revision: 361236
URL: https://svnweb.freebsd.org/changeset/base/361236

Log:
  MFC r360960:
  
  nfs: Remove APPLESTATIC macro
  
  It is no longer useful.
  
  Reviewed by:rmacklem
  Approved by:mav (mentor)
  Sponsored by:   iXsystems, Inc.
  Differential Revision:  https://reviews.freebsd.org/D24811

Modified:
  stable/11/sys/fs/nfs/nfs_commonacl.c
  stable/11/sys/fs/nfs/nfs_commonsubs.c
  stable/11/sys/fs/nfs/nfsport.h
  stable/11/sys/fs/nfsclient/nfs_clcomsubs.c
  stable/11/sys/fs/nfsclient/nfs_clport.c
  stable/11/sys/fs/nfsclient/nfs_clrpcops.c
  stable/11/sys/fs/nfsclient/nfs_clstate.c
  stable/11/sys/fs/nfsserver/nfs_nfsdcache.c
  stable/11/sys/fs/nfsserver/nfs_nfsdserv.c
  stable/11/sys/fs/nfsserver/nfs_nfsdsocket.c
  stable/11/sys/fs/nfsserver/nfs_nfsdstate.c
  stable/11/sys/fs/nfsserver/nfs_nfsdsubs.c
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/sys/fs/nfs/nfs_commonacl.c
  stable/12/sys/fs/nfs/nfs_commonsubs.c
  stable/12/sys/fs/nfs/nfsport.h
  stable/12/sys/fs/nfsclient/nfs_clcomsubs.c
  stable/12/sys/fs/nfsclient/nfs_clport.c
  stable/12/sys/fs/nfsclient/nfs_clrpcops.c
  stable/12/sys/fs/nfsclient/nfs_clstate.c
  stable/12/sys/fs/nfsserver/nfs_nfsdcache.c
  stable/12/sys/fs/nfsserver/nfs_nfsdserv.c
  stable/12/sys/fs/nfsserver/nfs_nfsdsocket.c
  stable/12/sys/fs/nfsserver/nfs_nfsdstate.c
  stable/12/sys/fs/nfsserver/nfs_nfsdsubs.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/sys/fs/nfs/nfs_commonacl.c
==
--- stable/11/sys/fs/nfs/nfs_commonacl.cTue May 19 01:40:45 2020
(r361235)
+++ stable/11/sys/fs/nfs/nfs_commonacl.cTue May 19 01:43:00 2020
(r361236)
@@ -38,7 +38,7 @@ static int nfsrv_acemasktoperm(u_int32_t acetype, u_in
 /*
  * Handle xdr for an ace.
  */
-APPLESTATIC int
+int
 nfsrv_dissectace(struct nfsrv_descript *nd, struct acl_entry *acep,
 int *aceerrp, int *acesizep, NFSPROC_T *p)
 {
@@ -386,7 +386,7 @@ nfsrv_buildace(struct nfsrv_descript *nd, u_char *name
 /*
  * Build an NFSv4 ACL.
  */
-APPLESTATIC int
+int
 nfsrv_buildacl(struct nfsrv_descript *nd, NFSACL_T *aclp, enum vtype type,
 NFSPROC_T *p)
 {
@@ -448,7 +448,7 @@ nfsrv_buildacl(struct nfsrv_descript *nd, NFSACL_T *ac
 /*
  * Set an NFSv4 acl.
  */
-APPLESTATIC int
+int
 nfsrv_setacl(vnode_t vp, NFSACL_T *aclp, struct ucred *cred,
 NFSPROC_T *p)
 {
@@ -479,7 +479,7 @@ out:
  * Compare two NFSv4 acls.
  * Return 0 if they are the same, 1 if not the same.
  */
-APPLESTATIC int
+int
 nfsrv_compareacl(NFSACL_T *aclp1, NFSACL_T *aclp2)
 {
int i;

Modified: stable/11/sys/fs/nfs/nfs_commonsubs.c
==
--- stable/11/sys/fs/nfs/nfs_commonsubs.c   Tue May 19 01:40:45 2020
(r361235)
+++ stable/11/sys/fs/nfs/nfs_commonsubs.c   Tue May 19 01:43:00 2020
(r361236)
@@ -286,7 +286,7 @@ out:
  * This is used by the macro NFSM_DISSECT for tough
  * cases.
  */
-APPLESTATIC void *
+void *
 nfsm_dissct(struct nfsrv_descript *nd, int siz, int how)
 {
mbuf_t mp2;
@@ -352,7 +352,7 @@ nfsm_dissct(struct nfsrv_descript *nd, int siz, int ho
  * here than check for offs > 0 for all calls to nfsm_advance.
  * If left == -1, it should be calculated here.
  */
-APPLESTATIC int
+int
 nfsm_advance(struct nfsrv_descript *nd, int offs, int left)
 {
int error = 0;
@@ -400,7 +400,7 @@ out:
  * Copy a string into mbuf(s).
  * Return the number of bytes output, including XDR overheads.
  */
-APPLESTATIC int
+int
 nfsm_strtom(struct nfsrv_descript *nd, const char *cp, int siz)
 {
mbuf_t m2;
@@ -457,7 +457,7 @@ nfsm_strtom(struct nfsrv_descript *nd, const char *cp,
 /*
  * Called once to initialize data structures...
  */
-APPLESTATIC void
+void
 newnfs_init(void)
 {
static int nfs_inited = 0;
@@ -487,7 +487,7 @@ newnfs_init(void)
  * set_true == 1 if there should be an newnfs_true prepended on the file 
handle.
  * Return the number of bytes output, including XDR overhead.
  */
-APPLESTATIC int
+int
 nfsm_fhtom(struct nfsrv_descript *nd, u_int8_t *fhp, int size, int set_true)
 {
u_int32_t *tl;
@@ -530,7 +530,7 @@ nfsm_fhtom(struct nfsrv_descript *nd, u_int8_t *fhp, i
  * The AF_INET family is handled as a special case so that address mbufs
  * don't need to be saved to store "struct in_addr", which is only 4 bytes.
  */
-APPLESTATIC int
+int
 nfsaddr_match(int family, union nethostaddr *haddr, NFSSOCKADDR_T nam)
 {
struct sockaddr_in *inetaddr;
@@ -563,7 +563,7 @@ nfsaddr_match(int family, union nethostaddr *haddr, NF
 /*
  * Similar to the above, but takes to NFSSOCKADDR_T args.
  */
-APPLESTATIC int
+int
 nfsaddr2_match(NFSSOCKADDR_T nam1, NFSSOCKADDR_T nam2)
 {
struct sockaddr_in *addr1, *addr2;
@@ -601,7 +601,7 @@ 

svn commit: r361235 - stable/12/libexec/rc/rc.d

2020-05-18 Thread Colin Percival
Author: cperciva
Date: Tue May 19 01:40:45 2020
New Revision: 361235
URL: https://svnweb.freebsd.org/changeset/base/361235

Log:
  MFC r361114:
  
Move the devmatch rc.d script before netif in the boot process.
  
Prior to this change, using lagg to aggregate wired and wireless networks
was broken in the (relatively common) case where wifi drivers + firmware
are loaded by devmatch, since the interface didn't exist at the time when
the lagg interface was being created.
  
  PR:   246506

Modified:
  stable/12/libexec/rc/rc.d/devmatch
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/libexec/rc/rc.d/devmatch
==
--- stable/12/libexec/rc/rc.d/devmatch  Tue May 19 01:39:37 2020
(r361234)
+++ stable/12/libexec/rc/rc.d/devmatch  Tue May 19 01:40:45 2020
(r361235)
@@ -27,6 +27,7 @@
 #
 # PROVIDE: devmatch
 # REQUIRE: kldxref
+# BEFORE: netif
 # KEYWORD: nojail
 
 . /etc/rc.subr
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361234 - stable/12/sys/dev/acpica

2020-05-18 Thread Colin Percival
Author: cperciva
Date: Tue May 19 01:39:37 2020
New Revision: 361234
URL: https://svnweb.freebsd.org/changeset/base/361234

Log:
  MFC r361097:
Send Lid status notification via devd from acpi_lid_status_update.
  
Some laptops don't send ACPI "lid status changed" notifications upon
opening the lid if the system was currently suspended.  In r358219
this was partially fixed, updating the "lid_status" variable upon
resume even if there is no "status changed" notification from ACPI.
  
Unfortunately the fix in r358219 did not include notifying userland
via devd; this causes problems on systems using upowerd (e.g. KDE),
since upowerd remembers the most recent devd notification about the
lid status rather than querying the sysctl to get the current status.
  
This showed up as two symptoms when KDE's "When laptop lid closed: Sleep"
option is set:
1. 50% of the time, closing the lid would not trigger S3 sleep.
2. 50% of the time, plugging/unplugging AC power would trigger S3 sleep.
  
  PR:   246477

Modified:
  stable/12/sys/dev/acpica/acpi_lid.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/acpica/acpi_lid.c
==
--- stable/12/sys/dev/acpica/acpi_lid.c Tue May 19 01:32:15 2020
(r361233)
+++ stable/12/sys/dev/acpica/acpi_lid.c Tue May 19 01:39:37 2020
(r361234)
@@ -113,6 +113,9 @@ acpi_lid_status_update(struct acpi_lid_softc *sc)
/* range check value */
sc->lid_status = lid_status ? 1 : 0;
 
+   /* Send notification via devd */
+   acpi_UserNotify("Lid", sc->lid_handle, sc->lid_status);
+
 #ifdef EVDEV_SUPPORT
/* Notify evdev about lid status */
evdev_push_sw(sc->lid_evdev, SW_LID, lid_status ? 0 : 1);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361232 - head/sys/powerpc/aim

2020-05-18 Thread Justin Hibbits
Author: jhibbits
Date: Tue May 19 01:06:31 2020
New Revision: 361232
URL: https://svnweb.freebsd.org/changeset/base/361232

Log:
  powerpc/mmu: Don't use the cache instructions to zero pages
  
  A page (even physmem) can be marked as cache-inhibited.  Attempting to use
  'dcbz' to zero a page mapped cache-inhibited triggers an alignment
  exception, which is fatal in kernel.  This was seen when testing hardware
  acceleration with X on POWER9.
  
  At some point in the future, this should be changed to a more straight
  forward zero loop instead of bzero(), and a similar change be made to the
  other pmaps.
  
  Reported by:  pkubaj@

Modified:
  head/sys/powerpc/aim/mmu_radix.c

Modified: head/sys/powerpc/aim/mmu_radix.c
==
--- head/sys/powerpc/aim/mmu_radix.cTue May 19 01:05:13 2020
(r361231)
+++ head/sys/powerpc/aim/mmu_radix.cTue May 19 01:06:31 2020
(r361232)
@@ -909,10 +909,8 @@ static void
 pagezero(vm_offset_t va)
 {
va = trunc_page(va);
-   int off;
 
-   for (off = 0; off < PAGE_SIZE; off += cacheline_size)
-   __asm __volatile("dcbz 0,%0" :: "r"(va + off));
+   bzero((void *)va, PAGE_SIZE);
 }
 
 static uint64_t
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361231 - head/sys/netinet

2020-05-18 Thread Mike Karels
Author: karels
Date: Tue May 19 01:05:13 2020
New Revision: 361231
URL: https://svnweb.freebsd.org/changeset/base/361231

Log:
  Fix NULL-pointer bug from r361228.
  
  Note that in_pcb_lport and in_pcb_lport_dest can be called with a NULL
  local address for IPv6 sockets; handle it.  Found by syzkaller.
  
  Reported by:  cem
  MFC after:1 month

Modified:
  head/sys/netinet/in_pcb.c

Modified: head/sys/netinet/in_pcb.c
==
--- head/sys/netinet/in_pcb.c   Tue May 19 00:15:19 2020(r361230)
+++ head/sys/netinet/in_pcb.c   Tue May 19 01:05:13 2020(r361231)
@@ -615,6 +615,7 @@ in_pcbbind(struct inpcb *inp, struct sockaddr *nam, st
  * Assign a local port like in_pcb_lport(), but also used with connect()
  * and a foreign address and port.  If fsa is non-NULL, choose a local port
  * that is unused with those, otherwise one that is completely unused.
+ * lsa can be NULL for IPv6.
  */
 int
 in_pcb_lport_dest(struct inpcb *inp, struct sockaddr *lsa, u_short *lportp,
@@ -692,14 +693,17 @@ in_pcb_lport_dest(struct inpcb *inp, struct sockaddr *
 #ifdef INET
laddr.s_addr = INADDR_ANY;
if ((inp->inp_vflag & (INP_IPV4|INP_IPV6)) == INP_IPV4) {
-   laddr = ((struct sockaddr_in *)lsa)->sin_addr;
+   if (lsa != NULL)
+   laddr = ((struct sockaddr_in *)lsa)->sin_addr;
if (fsa != NULL)
faddr = ((struct sockaddr_in *)fsa)->sin_addr;
}
 #endif
 #ifdef INET6
-   if (lsa->sa_family == AF_INET6) {
-   laddr6 = &((struct sockaddr_in6 *)lsa)->sin6_addr;
+   laddr6 = NULL;
+   if ((inp->inp_vflag & INP_IPV6) != 0) {
+   if (lsa != NULL)
+   laddr6 = &((struct sockaddr_in6 *)lsa)->sin6_addr;
if (fsa != NULL)
faddr6 = &((struct sockaddr_in6 *)fsa)->sin6_addr;
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361230 - head/contrib/blacklist/bin

2020-05-18 Thread Ed Maste
Author: emaste
Date: Tue May 19 00:15:19 2020
New Revision: 361230
URL: https://svnweb.freebsd.org/changeset/base/361230

Log:
  blacklistd.conf.5: typo/grammar fixes
  
  PR:   246467
  Submitted by: Mike Lempriere

Modified:
  head/contrib/blacklist/bin/blacklistd.conf.5

Modified: head/contrib/blacklist/bin/blacklistd.conf.5
==
--- head/contrib/blacklist/bin/blacklistd.conf.5Mon May 18 23:43:48 
2020(r361229)
+++ head/contrib/blacklist/bin/blacklistd.conf.5Tue May 19 00:15:19 
2020(r361230)
@@ -125,18 +125,18 @@ The second field is the socket
 .Dv dgram ,
 or numeric.
 The third field is the
-.Va prococol :
+.Va protocol :
 .Dv tcp ,
 .Dv udp ,
 .Dv tcp6 ,
 .Dv udp6 ,
 or numeric.
-The fourth file is the effective user
+The fourth field is the effective user
 .Va ( owner )
 of the daemon process reporting the event,
 either as a username or a userid.
 .Pp
-The rest of the fields are controlling the behavior of the filter.
+The rest of the fields control the behavior of the filter.
 .Pp
 The
 .Va name
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361229 - head/tests/sys/geom/class/multipath

2020-05-18 Thread Li-Wen Hsu
Author: lwhsu
Date: Mon May 18 23:43:48 2020
New Revision: 361229
URL: https://svnweb.freebsd.org/changeset/base/361229

Log:
  Revert 357780, `dtrace -c` has been fixed in head`
  
  PR:   244053
  Sponsored by: The FreeBSD Foundation

Modified:
  head/tests/sys/geom/class/multipath/failloop.sh

Modified: head/tests/sys/geom/class/multipath/failloop.sh
==
--- head/tests/sys/geom/class/multipath/failloop.sh Mon May 18 22:53:12 
2020(r361228)
+++ head/tests/sys/geom/class/multipath/failloop.sh Mon May 18 23:43:48 
2020(r361229)
@@ -36,10 +36,6 @@ failloop_head()
 }
 failloop_body()
 {
-   if [ "$(atf_config_get ci false)" = "true" ]; then
-   atf_skip "https://bugs.freebsd.org/244053;
-   fi
-
sysctl -n kern.geom.notaste > kern.geom.notaste.txt
load_gnop
load_gmultipath
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361228 - in head/sys: netinet netinet6

2020-05-18 Thread Mike Karels
Author: karels
Date: Mon May 18 22:53:12 2020
New Revision: 361228
URL: https://svnweb.freebsd.org/changeset/base/361228

Log:
  Allow TCP to reuse local port with different destinations
  
  Previously, tcp_connect() would bind a local port before connecting,
  forcing the local port to be unique across all outgoing TCP connections
  for the address family. Instead, choose a local port after selecting
  the destination and the local address, requiring only that the tuple
  is unique and does not match a wildcard binding.
  
  Reviewed by:  tuexen (rscheff, rrs previous version)
  MFC after:1 month
  Sponsored by: Forcepoint LLC
  Differential Revision:https://reviews.freebsd.org/D24781

Modified:
  head/sys/netinet/in_pcb.c
  head/sys/netinet/in_pcb.h
  head/sys/netinet/tcp_usrreq.c
  head/sys/netinet6/in6_pcb.c
  head/sys/netinet6/in6_pcb.h

Modified: head/sys/netinet/in_pcb.c
==
--- head/sys/netinet/in_pcb.c   Mon May 18 19:48:38 2020(r361227)
+++ head/sys/netinet/in_pcb.c   Mon May 18 22:53:12 2020(r361228)
@@ -610,13 +610,15 @@ in_pcbbind(struct inpcb *inp, struct sockaddr *nam, st
 }
 #endif
 
+#if defined(INET) || defined(INET6)
 /*
- * Select a local port (number) to use.
+ * Assign a local port like in_pcb_lport(), but also used with connect()
+ * and a foreign address and port.  If fsa is non-NULL, choose a local port
+ * that is unused with those, otherwise one that is completely unused.
  */
-#if defined(INET) || defined(INET6)
 int
-in_pcb_lport(struct inpcb *inp, struct in_addr *laddrp, u_short *lportp,
-struct ucred *cred, int lookupflags)
+in_pcb_lport_dest(struct inpcb *inp, struct sockaddr *lsa, u_short *lportp,
+struct sockaddr *fsa, u_short fport, struct ucred *cred, int lookupflags)
 {
struct inpcbinfo *pcbinfo;
struct inpcb *tmpinp;
@@ -624,8 +626,11 @@ in_pcb_lport(struct inpcb *inp, struct in_addr *laddrp
int count, dorandom, error;
u_short aux, first, last, lport;
 #ifdef INET
-   struct in_addr laddr;
+   struct in_addr laddr, faddr;
 #endif
+#ifdef INET6
+   struct in6_addr *laddr6, *faddr6;
+#endif
 
pcbinfo = inp->inp_pcbinfo;
 
@@ -685,15 +690,22 @@ in_pcb_lport(struct inpcb *inp, struct in_addr *laddrp
}
 
 #ifdef INET
-   /* Make the compiler happy. */
-   laddr.s_addr = 0;
+   laddr.s_addr = INADDR_ANY;
if ((inp->inp_vflag & (INP_IPV4|INP_IPV6)) == INP_IPV4) {
-   KASSERT(laddrp != NULL, ("%s: laddrp NULL for v4 inp %p",
-   __func__, inp));
-   laddr = *laddrp;
+   laddr = ((struct sockaddr_in *)lsa)->sin_addr;
+   if (fsa != NULL)
+   faddr = ((struct sockaddr_in *)fsa)->sin_addr;
}
 #endif
-   tmpinp = NULL;  /* Make compiler happy. */
+#ifdef INET6
+   if (lsa->sa_family == AF_INET6) {
+   laddr6 = &((struct sockaddr_in6 *)lsa)->sin6_addr;
+   if (fsa != NULL)
+   faddr6 = &((struct sockaddr_in6 *)fsa)->sin6_addr;
+   }
+#endif
+
+   tmpinp = NULL;
lport = *lportp;
 
if (dorandom)
@@ -709,30 +721,62 @@ in_pcb_lport(struct inpcb *inp, struct in_addr *laddrp
*lastport = first;
lport = htons(*lastport);
 
+   if (fsa != NULL) {
+
+#ifdef INET
+   if (lsa->sa_family == AF_INET) {
+   tmpinp = in_pcblookup_hash_locked(pcbinfo,
+   faddr, fport, laddr, lport, lookupflags,
+   NULL);
+   }
+#endif
 #ifdef INET6
-   if ((inp->inp_vflag & INP_IPV6) != 0)
-   tmpinp = in6_pcblookup_local(pcbinfo,
-   >in6p_laddr, lport, lookupflags, cred);
+   if (lsa->sa_family == AF_INET6) {
+   tmpinp = in6_pcblookup_hash_locked(pcbinfo,
+   faddr6, fport, laddr6, lport, lookupflags,
+   NULL);
+   }
 #endif
+   } else {
+#ifdef INET6
+   if ((inp->inp_vflag & INP_IPV6) != 0)
+   tmpinp = in6_pcblookup_local(pcbinfo,
+   >in6p_laddr, lport, lookupflags, cred);
+#endif
 #if defined(INET) && defined(INET6)
-   else
+   else
 #endif
 #ifdef INET
-   tmpinp = in_pcblookup_local(pcbinfo, laddr,
-   lport, lookupflags, cred);
+   tmpinp = in_pcblookup_local(pcbinfo, laddr,
+   lport, lookupflags, cred);
 #endif
+   }
} while (tmpinp != NULL);
 
-#ifdef INET
-   if ((inp->inp_vflag & (INP_IPV4|INP_IPV6)) == INP_IPV4)
-   

Re: svn commit: r361136 - head/sys/fs/ext2fs

2020-05-18 Thread Pedro Giffuni

...

On 17/05/2020 09:52, Fedor Uporov wrote:

Author: fsu
Date: Sun May 17 14:52:54 2020
New Revision: 361136
URL: https://svnweb.freebsd.org/changeset/base/361136

Log:
   Add BE architectures support.
   
   Author of most initial version: pfg (https://reviews.freebsd.org/D23259)
   
   Reviewed by:pfg

   MFC after:  3 months
   
   Differential Revision:https://reviews.freebsd.org/D24685


Thanks so much for finishing off my initial code and for testing in PPC!

Pedro.

___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r361209 - head/sys/netinet

2020-05-18 Thread Michael Tuexen
> On 18. May 2020, at 23:09, Ian Lepore  wrote:
> 
> On Mon, 2020-05-18 at 23:01 +0200, Michael Tuexen wrote:
>>> On 18. May 2020, at 22:48, Ian Lepore  wrote:
>>> 
>>> On Mon, 2020-05-18 at 22:43 +0200, Michael Tuexen wrote:
> Sure.  You can certainly ignore user reports corresponding to
> bogus
> flags, though, and encourage use of various flags.
 
 I could, but decided to improve the situation for some people,
 but
 wasn't realising that I made it worse for others. Sorry about
 that.
>>> 
>>> I'm trying to figure out why your original commit was a problem.  I
>>> understand why it was questioned, but once the answer came out,
>>> it's
>>> clear that the code you originally committed does what it's
>>> supposed to
>>> without any harmful side effects.  Sure, freebsd doesn't strictly
>>> need
>> 
>> I guess the point Conrad is making, that on FreeBSD the check is not
>> needed, since the call can not fail. So the FreeBSD code base would
>> not
>> be consistent: within the SCTP related code the return code is
>> checked,
>> in the other code it is not.
>>> it, but the code is shared among projects, so what's the harm in
>>> the
>>> extra check that helps other projects sharing the code?  It's
>>> certainly
>>> a lot less confusion and code clutter than any of the "remedies"
>>> that
>>> have been discussed.
>> 
>> Yepp, sharing code between platforms makes things harder. Running the
>> same
>> code in kernel land and userland does not make it simpler. Different
>> groups
>> have different opinions/styles/...
>> 
>> I'll revert the commit tomorrow and a variadic macros
>> SCTP_SNPRINTF(), which
>> will map on FreeBSD to snprintf() and on the other platforms will do
>> the check.
>> 
>> If the build problem comes up on FreeBSD userland (and I have no idea
>> if that
>> is the case, since I don't know how Firefox / Chrome are build on
>> FreeBSD),
>> I leave it up to the port maintainer of the application to deal with
>> it.
>> 
>> Best regards
>> Michael
>>> 
>>> -- Ian
>>> 
>> 
>> 
> 
> Well it seems to me you're being asked to do a lot of extra work that
> has the final result of making the code LESS clear and MORE complex,
> because of one person's opinion.  I'm actually a bit tempted to
Yes, it is one person. But it is one person who thinks the change
is bad enough that he needs to speak up. So I think this has to be
addressed.
> complain about the change, because to me it reduces rather than
> improves code quality.
Well, we have abstracted from FreeBSD specifics by using macros in
other cases as well.

Adding another macro will make reading a bit harder and you have
to lookup the platform specific implementation of the code to
figure out what is going on, but that way, I guess, people will
get a result they can live with.

Best regards
Michael
> 
> -- Ian
> 
> 

___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r361209 - head/sys/netinet

2020-05-18 Thread Ian Lepore
On Mon, 2020-05-18 at 23:01 +0200, Michael Tuexen wrote:
> > On 18. May 2020, at 22:48, Ian Lepore  wrote:
> > 
> > On Mon, 2020-05-18 at 22:43 +0200, Michael Tuexen wrote:
> > > > Sure.  You can certainly ignore user reports corresponding to
> > > > bogus
> > > > flags, though, and encourage use of various flags.
> > > 
> > > I could, but decided to improve the situation for some people,
> > > but
> > > wasn't realising that I made it worse for others. Sorry about
> > > that.
> > 
> > I'm trying to figure out why your original commit was a problem.  I
> > understand why it was questioned, but once the answer came out,
> > it's
> > clear that the code you originally committed does what it's
> > supposed to
> > without any harmful side effects.  Sure, freebsd doesn't strictly
> > need
> 
> I guess the point Conrad is making, that on FreeBSD the check is not
> needed, since the call can not fail. So the FreeBSD code base would
> not
> be consistent: within the SCTP related code the return code is
> checked,
> in the other code it is not.
> > it, but the code is shared among projects, so what's the harm in
> > the
> > extra check that helps other projects sharing the code?  It's
> > certainly
> > a lot less confusion and code clutter than any of the "remedies"
> > that
> > have been discussed.
> 
> Yepp, sharing code between platforms makes things harder. Running the
> same
> code in kernel land and userland does not make it simpler. Different
> groups
> have different opinions/styles/...
> 
> I'll revert the commit tomorrow and a variadic macros
> SCTP_SNPRINTF(), which
> will map on FreeBSD to snprintf() and on the other platforms will do
> the check.
> 
> If the build problem comes up on FreeBSD userland (and I have no idea
> if that
> is the case, since I don't know how Firefox / Chrome are build on
> FreeBSD),
> I leave it up to the port maintainer of the application to deal with
> it.
> 
> Best regards
> Michael
> > 
> > -- Ian
> > 
> 
> 

Well it seems to me you're being asked to do a lot of extra work that
has the final result of making the code LESS clear and MORE complex,
because of one person's opinion.  I'm actually a bit tempted to
complain about the change, because to me it reduces rather than
improves code quality.

-- Ian


___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r361209 - head/sys/netinet

2020-05-18 Thread Michael Tuexen
> On 18. May 2020, at 22:48, Ian Lepore  wrote:
> 
> On Mon, 2020-05-18 at 22:43 +0200, Michael Tuexen wrote:
>>> Sure.  You can certainly ignore user reports corresponding to bogus
>>> flags, though, and encourage use of various flags.
>> 
>> I could, but decided to improve the situation for some people, but
>> wasn't realising that I made it worse for others. Sorry about that.
> 
> I'm trying to figure out why your original commit was a problem.  I
> understand why it was questioned, but once the answer came out, it's
> clear that the code you originally committed does what it's supposed to
> without any harmful side effects.  Sure, freebsd doesn't strictly need
I guess the point Conrad is making, that on FreeBSD the check is not
needed, since the call can not fail. So the FreeBSD code base would not
be consistent: within the SCTP related code the return code is checked,
in the other code it is not.
> it, but the code is shared among projects, so what's the harm in the
> extra check that helps other projects sharing the code?  It's certainly
> a lot less confusion and code clutter than any of the "remedies" that
> have been discussed.
Yepp, sharing code between platforms makes things harder. Running the same
code in kernel land and userland does not make it simpler. Different groups
have different opinions/styles/...

I'll revert the commit tomorrow and a variadic macros SCTP_SNPRINTF(), which
will map on FreeBSD to snprintf() and on the other platforms will do the check.

If the build problem comes up on FreeBSD userland (and I have no idea if that
is the case, since I don't know how Firefox / Chrome are build on FreeBSD),
I leave it up to the port maintainer of the application to deal with it.

Best regards
Michael
> 
> -- Ian
> 

___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r361209 - head/sys/netinet

2020-05-18 Thread Ian Lepore
On Mon, 2020-05-18 at 22:43 +0200, Michael Tuexen wrote:
> > Sure.  You can certainly ignore user reports corresponding to bogus
> > flags, though, and encourage use of various flags.
> 
> I could, but decided to improve the situation for some people, but
> wasn't realising that I made it worse for others. Sorry about that.

I'm trying to figure out why your original commit was a problem.  I
understand why it was questioned, but once the answer came out, it's
clear that the code you originally committed does what it's supposed to
without any harmful side effects.  Sure, freebsd doesn't strictly need
it, but the code is shared among projects, so what's the harm in the
extra check that helps other projects sharing the code?  It's certainly
a lot less confusion and code clutter than any of the "remedies" that
have been discussed.

-- Ian

___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r361209 - head/sys/netinet

2020-05-18 Thread Michael Tuexen
> On 18. May 2020, at 22:17, Conrad Meyer  wrote:
> 
> Hi Michael,
> 
> On Mon, May 18, 2020 at 12:05 PM Michael Tuexen  wrote:
>> 
>>> On 18. May 2020, at 20:23, Conrad Meyer  wrote:
>> 
>>> If truncation is intended, the GCC warning is spurious.  Given how
>>> often snprintf is used in this way, I wonder if it would make sense to
>>> just disable it across the entire tree.  Regardless, IMO it makes
>> 
>> The issue wasn't reported against the kernel code, but running the code
>> in userland. I don't really control the flags people are using.
> 
> Sure.  You can certainly ignore user reports corresponding to bogus
> flags, though, and encourage use of various flags.
I could, but decided to improve the situation for some people, but
wasn't realising that I made it worse for others. Sorry about that.
> 
>> OK. I'll revert this change and replace it upstream by something like
>> 
>> #if defined(__FreeBSD_)
>>snprintf(msg, sizeof(msg), "Never sent serial number %8.8x", 
>> serial_num)
>> #else
>>if (snprintf(msg, sizeof(msg), "Never sent serial number %8.8x", 
>> serial_num) < 0) {
>>msg[0] = '\0';
>>}
>> #endif
> 
> This seems like a messy solution.  I'd suggest either putting
> unconditional "msg[0] = '\0';" before snprintf() invocations, or
That would assume that in case of an error the first byte is overwitten.
> defining an snprintf wrapper function for non-FreeBSD platforms and
> using it universally.
Yeah, one can use a Macro SCTP_SNPRINTF(). Let me see...
> 
>> I don't know if other platforms guarantee that snprintf() can't fail.
>> If it fails, the stack would send out un-initialized stack memory on
>> the network.
> 
> Sure, that's a good concern.  That said,
> 
> Glibc: 
> https://github.com/bminor/glibc/blob/5f72f9800b250410cad3abfeeb09469ef12b2438/libio/vsnprintf.c#L93-L114
> (always nul terminates)
> MS: 
> https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l?view=vs-2019
> ("The snprintf function always stores a terminating null character…")
> OpenBSD: 
> https://github.com/openbsd/src/blob/master/lib/libc/stdio/vsnprintf.c#L60-L63
> (always nul terminates)
> NetBSD: 
> https://github.com/NetBSD/src/blob/trunk/lib/libc/stdio/vsnprintf.c#L97-L101
> (always nul terminates)
> Linux (kernel):
> https://elixir.bootlin.com/linux/latest/source/lib/vsprintf.c#L2645
> (always nul terminates)
> 
> None of these are conditional on error status.
> 
> The only exception I found is musl libc, and in that it is a case you
> cannot encounter here (size > INT_MAX).  Arguably this is a bug in
> musl libc.  I did not dive deeper into musl and determine whether
> other errors were nul terminated or not.
> 
> Conrad
> 
> P.S., It seems dubious to be sending diagnostic formatted error
> messages out across the network.
It was and still is very helpful when debuging interop problems if you only 
have access
to a tracefile and can't change the running code. Like people asking you why is 
your
implementation sending back an ABORT when it sees this packet.

Best regards
Michael
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r361209 - head/sys/netinet

2020-05-18 Thread Conrad Meyer
Hi Michael,

On Mon, May 18, 2020 at 12:05 PM Michael Tuexen  wrote:
>
> > On 18. May 2020, at 20:23, Conrad Meyer  wrote:
>
> > If truncation is intended, the GCC warning is spurious.  Given how
> > often snprintf is used in this way, I wonder if it would make sense to
> > just disable it across the entire tree.  Regardless, IMO it makes
>
> The issue wasn't reported against the kernel code, but running the code
> in userland. I don't really control the flags people are using.

Sure.  You can certainly ignore user reports corresponding to bogus
flags, though, and encourage use of various flags.

> OK. I'll revert this change and replace it upstream by something like
>
> #if defined(__FreeBSD_)
> snprintf(msg, sizeof(msg), "Never sent serial number %8.8x", 
> serial_num)
> #else
> if (snprintf(msg, sizeof(msg), "Never sent serial number %8.8x", 
> serial_num) < 0) {
> msg[0] = '\0';
> }
> #endif

This seems like a messy solution.  I'd suggest either putting
unconditional "msg[0] = '\0';" before snprintf() invocations, or
defining an snprintf wrapper function for non-FreeBSD platforms and
using it universally.

> I don't know if other platforms guarantee that snprintf() can't fail.
> If it fails, the stack would send out un-initialized stack memory on
> the network.

Sure, that's a good concern.  That said,

Glibc: 
https://github.com/bminor/glibc/blob/5f72f9800b250410cad3abfeeb09469ef12b2438/libio/vsnprintf.c#L93-L114
(always nul terminates)
MS: 
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l?view=vs-2019
("The snprintf function always stores a terminating null character…")
OpenBSD: 
https://github.com/openbsd/src/blob/master/lib/libc/stdio/vsnprintf.c#L60-L63
(always nul terminates)
NetBSD: 
https://github.com/NetBSD/src/blob/trunk/lib/libc/stdio/vsnprintf.c#L97-L101
(always nul terminates)
Linux (kernel):
https://elixir.bootlin.com/linux/latest/source/lib/vsprintf.c#L2645
(always nul terminates)

None of these are conditional on error status.

The only exception I found is musl libc, and in that it is a case you
cannot encounter here (size > INT_MAX).  Arguably this is a bug in
musl libc.  I did not dive deeper into musl and determine whether
other errors were nul terminated or not.

Conrad

P.S., It seems dubious to be sending diagnostic formatted error
messages out across the network.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361227 - head/sys/netinet

2020-05-18 Thread Michael Tuexen
Author: tuexen
Date: Mon May 18 19:48:38 2020
New Revision: 361227
URL: https://svnweb.freebsd.org/changeset/base/361227

Log:
  Remove assignment without effect.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_auth.c

Modified: head/sys/netinet/sctp_auth.c
==
--- head/sys/netinet/sctp_auth.cMon May 18 19:35:46 2020
(r361226)
+++ head/sys/netinet/sctp_auth.cMon May 18 19:48:38 2020
(r361227)
@@ -658,7 +658,6 @@ sctp_free_hmaclist(sctp_hmaclist_t *list)
 {
if (list != NULL) {
SCTP_FREE(list, SCTP_M_AUTH_HL);
-   list = NULL;
}
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361226 - head/sys/netinet

2020-05-18 Thread Michael Tuexen
Author: tuexen
Date: Mon May 18 19:35:46 2020
New Revision: 361226
URL: https://svnweb.freebsd.org/changeset/base/361226

Log:
  Don't check an unsigned variable for being negative.
  
  MFC after:3 days.

Modified:
  head/sys/netinet/sctp_usrreq.c

Modified: head/sys/netinet/sctp_usrreq.c
==
--- head/sys/netinet/sctp_usrreq.c  Mon May 18 19:23:01 2020
(r361225)
+++ head/sys/netinet/sctp_usrreq.c  Mon May 18 19:35:46 2020
(r361226)
@@ -1042,7 +1042,7 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp,
struct sctp_vrf *vrf;
 
actual = 0;
-   if (limit <= 0)
+   if (limit == 0)
return (actual);
 
if (stcb) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361225 - head/sys/netinet

2020-05-18 Thread Michael Tuexen
Author: tuexen
Date: Mon May 18 19:23:01 2020
New Revision: 361225
URL: https://svnweb.freebsd.org/changeset/base/361225

Log:
  Remove redundant assignment.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctputil.c
==
--- head/sys/netinet/sctputil.c Mon May 18 18:42:43 2020(r361224)
+++ head/sys/netinet/sctputil.c Mon May 18 19:23:01 2020(r361225)
@@ -1144,7 +1144,6 @@ sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb
asoc->sctp_cmt_on_off = inp->sctp_cmt_on_off;
asoc->ecn_supported = inp->ecn_supported;
asoc->prsctp_supported = inp->prsctp_supported;
-   asoc->idata_supported = inp->idata_supported;
asoc->auth_supported = inp->auth_supported;
asoc->asconf_supported = inp->asconf_supported;
asoc->reconfig_supported = inp->reconfig_supported;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r361209 - head/sys/netinet

2020-05-18 Thread Michael Tuexen
> On 18. May 2020, at 20:23, Conrad Meyer  wrote:
> 
> On Mon, May 18, 2020 at 10:35 AM Michael Tuexen  wrote:
>> 
>>> On 18. May 2020, at 17:38, Conrad Meyer  wrote:
>>> 
>>> These changes are a bit odd.  The only reason a standards-compliant
>>> snprintf() would fail to nul-terminate a buffer is if the provided
>>> buffer had length zero.  Since this is not the case in any of these
>>> uses, I wonder why this revision was made?  Does a SCTP downstream
>> 
>> when compiling the code in userland with gcc 10, it warns that
>> the output might be truncated. That is true and intended.
>> So checking that the call doesn't fail silences this warning and
>> ensures the code works in case snprintf() returns an error. I don't
>> see in the POSIX specification a statement limiting the case where
>> it could fail.
>> 
>>> have a broken snprintf implementation, and if so, wouldn't it make
>>> more sense to create a standards-compliant portability shim for that
>>> platform instead of this more invasive change?
>> 
>> If you want, I can revert the change and use the code only on non-FreeBSD
>> platforms.
> 
> Hi Michael,
> 
> If truncation is intended, the GCC warning is spurious.  Given how
> often snprintf is used in this way, I wonder if it would make sense to
> just disable it across the entire tree.  Regardless, IMO it makes
The issue wasn't reported against the kernel code, but running the code
in userland. I don't really control the flags people are using.
> sense to disable the warning, rather than make these changes to check
> for errors that can't happen.  It does not even "fix" the thing GCC is
OK. I'll revert this change and replace it upstream by something like

#if defined(__FreeBSD_)
snprintf(msg, sizeof(msg), "Never sent serial number %8.8x", serial_num)
#else
if (snprintf(msg, sizeof(msg), "Never sent serial number %8.8x", 
serial_num) < 0) {
msg[0] = '\0';
}
#endif

I don't know if other platforms guarantee that snprintf() can't fail.
If it fails, the stack would send out un-initialized stack memory on
the network.
> warning about, since we aren't testing for truncation at all; it's
> just a warning defeat mechanism.  -Wno- is a better warning-defeat
> mechanism.
> 
> Re: documentation of snprintf nul-termination, I would look at this
> part of the FreeBSD manual page:
> 
> The snprintf() and vsnprintf() functions will write at most size-1 of the
> characters printed into the output string (the size'th character then
> gets the terminating ‘\0’); if the return value is greater than or equal
> to the size argument, the string was too short and some of the printed
> characters were discarded.  The output is always null-terminated, unless
> size is 0.
> 
> Note the last sentence especially.  As far as error conditions, those
> are canonically documented in the ERRORS section of the manual page
> rather than RETURN VALUES.  For whatever reason, mdoc(7) standard puts
> EXAMPLES between the two sections, and additionally snprintf.3 has a
> non-standard COMPATIBILITY section between the two, so they are not
> directly adjacent.  Here's that section, though:
> 
> ERRORS
> In addition to the errors documented for the write(2) system call, the
> printf() family of functions may fail if:
> 
> [EILSEQ]   An invalid wide character code was encountered.
> 
> [ENOMEM]   Insufficient storage space is available.
> 
> [EOVERFLOW]The size argument exceeds INT_MAX + 1, or the return
>value would be too large to be represented by an int.
> 
> The section is unfortunately generalized and non-specific; snprintf
> probably cannot fail with ENOMEM, for example, nor write(2) errors.
> But EOVERFLOW is well-documented.
> 
> Re: POSIX definition, POSIX is not the canonical definition of
> snprintf; the C standard is.  C (2018) reads:
> 
>> If n is zero, nothing shall be written and s may be a null pointer. 
>> Otherwise, output bytes beyond the n-1st shall be discarded instead of being 
>> written to the array, and a null byte is written at the end of the bytes 
>> actually written into the array.
> 
> Emphasis on the last clause.  (POSIX uses the exact same language.)
> As far as conditions where snprintf may fail, POSIX only defines a
> single case (covered in snprintf.3 above):
> 
>> The snprintf() function shall fail if: [EOVERFLOW], The value of n is 
>> greater than INT_MAX.
> 
> That is not the case in any of these invocations.
Just to be clear: My problem is NOT that the output is not zero terminated.
I use snprintf() in a way that it is, if it does not fail.

I was just adding protection code for the case it fails and leaves the
buffer uninitialized. since I don't want so sent out uninitialized stack memory.

I learnt that on FreeBSD this is not a problem and I'll remove that protection
code for this platform.

Best regards
Michael
> 
> Probably snprintf(9) should be specifically 

svn commit: r361224 - head/sys/netinet

2020-05-18 Thread Michael Tuexen
Author: tuexen
Date: Mon May 18 18:42:43 2020
New Revision: 361224
URL: https://svnweb.freebsd.org/changeset/base/361224

Log:
  Cleanup, no functional change intended.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_pcb.c

Modified: head/sys/netinet/sctp_pcb.c
==
--- head/sys/netinet/sctp_pcb.c Mon May 18 18:36:32 2020(r361223)
+++ head/sys/netinet/sctp_pcb.c Mon May 18 18:42:43 2020(r361224)
@@ -5203,16 +5203,12 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tc
SCTP_FREE_SHOULD_USE_GRACEFUL_CLOSE,
SCTP_CALLED_DIRECTLY_NOCMPSET);
SCTP_INP_DECR_REF(inp);
-   goto out_of;
} else {
/* The socket is still open. */
SCTP_INP_DECR_REF(inp);
+   SCTP_INP_RUNLOCK(inp);
}
}
-   if (from_inpcbfree == SCTP_NORMAL_PROC) {
-   SCTP_INP_RUNLOCK(inp);
-   }
-out_of:
/* destroyed the asoc */
 #ifdef SCTP_LOG_CLOSING
sctp_log_closing(inp, NULL, 11);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361223 - head/tests/sys/fs/fusefs

2020-05-18 Thread Alan Somers
Author: asomers
Date: Mon May 18 18:36:32 2020
New Revision: 361223
URL: https://svnweb.freebsd.org/changeset/base/361223

Log:
  fusefs: fix intermittency in some ENOENT tests
  
  When a FUSE operation other than LOOKUP returns ENOENT, the kernel will
  reclaim that vnode, resuling in a FUSE_FORGET being sent a short while
  later.  Many of the ENOENT tests weren't expecting those FUSE_FORGET
  operations.  They usually passed by luck since FUSE_FORGET is often delayed.
  This commit adds appropriate expectations.
  
  MFC after:2 weeks

Modified:
  head/tests/sys/fs/fusefs/getattr.cc
  head/tests/sys/fs/fusefs/open.cc
  head/tests/sys/fs/fusefs/opendir.cc

Modified: head/tests/sys/fs/fusefs/getattr.cc
==
--- head/tests/sys/fs/fusefs/getattr.cc Mon May 18 18:32:58 2020
(r361222)
+++ head/tests/sys/fs/fusefs/getattr.cc Mon May 18 18:36:32 2020
(r361223)
@@ -32,6 +32,8 @@
 
 extern "C" {
 #include 
+
+#include 
 }
 
 #include "mockfs.hh"
@@ -172,7 +174,10 @@ TEST_F(Getattr, enoent)
const char RELPATH[] = "some_file.txt";
struct stat sb;
const uint64_t ino = 42;
+   sem_t sem;
 
+   ASSERT_EQ(0, sem_init(, 0, 0)) << strerror(errno);
+
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1, 0, 0);
EXPECT_CALL(*m_mock, process(
ResultOf([](auto in) {
@@ -181,8 +186,15 @@ TEST_F(Getattr, enoent)
}, Eq(true)),
_)
).WillOnce(Invoke(ReturnErrno(ENOENT)));
+   // Since FUSE_GETATTR returns ENOENT, the kernel will reclaim the vnode
+   // and send a FUSE_FORGET
+   expect_forget(ino, 1, );
+
EXPECT_NE(0, stat(FULLPATH, ));
EXPECT_EQ(ENOENT, errno);
+
+   sem_wait();
+   sem_destroy();
 }
 
 TEST_F(Getattr, ok)

Modified: head/tests/sys/fs/fusefs/open.cc
==
--- head/tests/sys/fs/fusefs/open.ccMon May 18 18:32:58 2020
(r361222)
+++ head/tests/sys/fs/fusefs/open.ccMon May 18 18:36:32 2020
(r361223)
@@ -32,7 +32,9 @@
 
 extern "C" {
 #include 
+
 #include 
+#include 
 }
 
 #include "mockfs.hh"
@@ -105,7 +107,10 @@ TEST_F(Open, enoent)
const char FULLPATH[] = "mountpoint/some_file.txt";
const char RELPATH[] = "some_file.txt";
uint64_t ino = 42;
+   sem_t sem;
 
+   ASSERT_EQ(0, sem_init(, 0, 0)) << strerror(errno);
+
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
EXPECT_CALL(*m_mock, process(
ResultOf([=](auto in) {
@@ -114,8 +119,15 @@ TEST_F(Open, enoent)
}, Eq(true)),
_)
).WillOnce(Invoke(ReturnErrno(ENOENT)));
+   // Since FUSE_OPEN returns ENOENT, the kernel will reclaim the vnode
+   // and send a FUSE_FORGET
+   expect_forget(ino, 1, );
+
ASSERT_EQ(-1, open(FULLPATH, O_RDONLY));
EXPECT_EQ(ENOENT, errno);
+
+   sem_wait();
+   sem_destroy();
 }
 
 /* 

Modified: head/tests/sys/fs/fusefs/opendir.cc
==
--- head/tests/sys/fs/fusefs/opendir.cc Mon May 18 18:32:58 2020
(r361222)
+++ head/tests/sys/fs/fusefs/opendir.cc Mon May 18 18:36:32 2020
(r361223)
@@ -32,7 +32,9 @@
 
 extern "C" {
 #include 
+
 #include 
+#include 
 }
 
 #include "mockfs.hh"
@@ -82,12 +84,21 @@ TEST_F(Opendir, enoent)
const char FULLPATH[] = "mountpoint/some_dir";
const char RELPATH[] = "some_dir";
uint64_t ino = 42;
+   sem_t sem;
 
+   ASSERT_EQ(0, sem_init(, 0, 0)) << strerror(errno);
+
expect_lookup(RELPATH, ino);
expect_opendir(ino, O_RDONLY, ReturnErrno(ENOENT));
+   // Since FUSE_OPENDIR returns ENOENT, the kernel will reclaim the vnode
+   // and send a FUSE_FORGET
+   expect_forget(ino, 1, );
 
ASSERT_EQ(-1, open(FULLPATH, O_DIRECTORY));
EXPECT_EQ(ENOENT, errno);
+
+   sem_wait();
+   sem_destroy();
 }
 
 /* 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361222 - head/sys/netinet

2020-05-18 Thread Michael Tuexen
Author: tuexen
Date: Mon May 18 18:32:58 2020
New Revision: 361222
URL: https://svnweb.freebsd.org/changeset/base/361222

Log:
  Avoid an integer underflow.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_asconf.c

Modified: head/sys/netinet/sctp_asconf.c
==
--- head/sys/netinet/sctp_asconf.c  Mon May 18 18:27:10 2020
(r361221)
+++ head/sys/netinet/sctp_asconf.c  Mon May 18 18:32:58 2020
(r361222)
@@ -1797,9 +1797,9 @@ sctp_handle_asconf_ack(struct mbuf *m, int offset,
}   /* switch */
 
/* update remaining ASCONF-ACK message length to process */
-   ack_length -= SCTP_SIZE32(param_length);
-   if (ack_length <= 0) {
-   /* no more data in the mbuf chain */
+   if (ack_length > SCTP_SIZE32(param_length)) {
+   ack_length -= SCTP_SIZE32(param_length);
+   } else {
break;
}
offset += SCTP_SIZE32(param_length);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361221 - head/sys/netinet

2020-05-18 Thread Michael Tuexen
Author: tuexen
Date: Mon May 18 18:27:10 2020
New Revision: 361221
URL: https://svnweb.freebsd.org/changeset/base/361221

Log:
  Remove redundant check.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_asconf.c

Modified: head/sys/netinet/sctp_asconf.c
==
--- head/sys/netinet/sctp_asconf.c  Mon May 18 16:47:44 2020
(r361220)
+++ head/sys/netinet/sctp_asconf.c  Mon May 18 18:27:10 2020
(r361221)
@@ -3026,10 +3026,6 @@ sctp_check_address_list_ep(struct sctp_tcb *stcb, stru
"check_addr_list_ep: laddr->ifa is NULL");
continue;
}
-   if (laddr->ifa == NULL) {
-   SCTPDBG(SCTP_DEBUG_ASCONF1, "check_addr_list_ep: 
laddr->ifa->ifa_addr is NULL");
-   continue;
-   }
/* do i have it implicitly? */
if (sctp_cmpaddr(>ifa->address.sa, init_addr)) {
continue;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r361209 - head/sys/netinet

2020-05-18 Thread Conrad Meyer
On Mon, May 18, 2020 at 10:35 AM Michael Tuexen  wrote:
>
> > On 18. May 2020, at 17:38, Conrad Meyer  wrote:
> >
> > These changes are a bit odd.  The only reason a standards-compliant
> > snprintf() would fail to nul-terminate a buffer is if the provided
> > buffer had length zero.  Since this is not the case in any of these
> > uses, I wonder why this revision was made?  Does a SCTP downstream
>
> when compiling the code in userland with gcc 10, it warns that
> the output might be truncated. That is true and intended.
> So checking that the call doesn't fail silences this warning and
> ensures the code works in case snprintf() returns an error. I don't
> see in the POSIX specification a statement limiting the case where
> it could fail.
>
> > have a broken snprintf implementation, and if so, wouldn't it make
> > more sense to create a standards-compliant portability shim for that
> > platform instead of this more invasive change?
>
> If you want, I can revert the change and use the code only on non-FreeBSD
> platforms.

Hi Michael,

If truncation is intended, the GCC warning is spurious.  Given how
often snprintf is used in this way, I wonder if it would make sense to
just disable it across the entire tree.  Regardless, IMO it makes
sense to disable the warning, rather than make these changes to check
for errors that can't happen.  It does not even "fix" the thing GCC is
warning about, since we aren't testing for truncation at all; it's
just a warning defeat mechanism.  -Wno- is a better warning-defeat
mechanism.

Re: documentation of snprintf nul-termination, I would look at this
part of the FreeBSD manual page:

 The snprintf() and vsnprintf() functions will write at most size-1 of the
 characters printed into the output string (the size'th character then
 gets the terminating ‘\0’); if the return value is greater than or equal
 to the size argument, the string was too short and some of the printed
 characters were discarded.  The output is always null-terminated, unless
 size is 0.

Note the last sentence especially.  As far as error conditions, those
are canonically documented in the ERRORS section of the manual page
rather than RETURN VALUES.  For whatever reason, mdoc(7) standard puts
EXAMPLES between the two sections, and additionally snprintf.3 has a
non-standard COMPATIBILITY section between the two, so they are not
directly adjacent.  Here's that section, though:

ERRORS
 In addition to the errors documented for the write(2) system call, the
 printf() family of functions may fail if:

 [EILSEQ]   An invalid wide character code was encountered.

 [ENOMEM]   Insufficient storage space is available.

 [EOVERFLOW]The size argument exceeds INT_MAX + 1, or the return
value would be too large to be represented by an int.

The section is unfortunately generalized and non-specific; snprintf
probably cannot fail with ENOMEM, for example, nor write(2) errors.
But EOVERFLOW is well-documented.

Re: POSIX definition, POSIX is not the canonical definition of
snprintf; the C standard is.  C (2018) reads:

> If n is zero, nothing shall be written and s may be a null pointer. 
> Otherwise, output bytes beyond the n-1st shall be discarded instead of being 
> written to the array, and a null byte is written at the end of the bytes 
> actually written into the array.

Emphasis on the last clause.  (POSIX uses the exact same language.)
As far as conditions where snprintf may fail, POSIX only defines a
single case (covered in snprintf.3 above):

> The snprintf() function shall fail if: [EOVERFLOW], The value of n is greater 
> than INT_MAX.

That is not the case in any of these invocations.

Probably snprintf(9) should be specifically documented; printf(9) does
not cover it yet.  This is a documentation gap.  Additionally, the
COMPATIBILITY section of snprintf.3 should probably be moved to
STANDARDS (to help move ERRORS and RETURN VALUES closer together).
Finally, it might be nice to have kernel snprintf(9) _Static_assert
that the provided length is shorter than INT_MAX (when it is a
compiler constant, and detect non-constant cases at runtime).
Currently, snprintf(9) fails to detect buffers that would produce a
result which overflows.

Best regards,
Conrad
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r361209 - head/sys/netinet

2020-05-18 Thread Michael Tuexen
> On 18. May 2020, at 17:48, Conrad Meyer  wrote:
> 
> (In fact, I don't believe snprintf(9) can return a negative value at
> all.  And snprintf(3) will only do so in some special circumstances
> for features snprintf(9) does not support: buffer size or formatted
> result longer than INT_MAX; invalid *nn$ field width or precision
> specifiers.  I don't think either case applies to these strings,
> although I did not read all of them thoroughly.)
I have no problem to revert this change for FreeBSD if it is there
impossible (and hopefully gcc 10 knows about this in case someone
builds the userland stack with gcc 10 on FreeBSD). In the posix
specification I don't see this.

For FreeBSD, it would be great to update the man page, which currently
states

RETURN VALUES
 These functions return the number of characters printed (not including
 the trailing `\0' used to end output to strings), except for snprintf()
 and vsnprintf(), which return the number of characters that would have
 been printed if the size were unlimited (again, not including the final
 `\0').  These functions return a negative value if an error occurs.

So it would be great to be specific about when an error occurs in the
last sentence.

Best regards
Michael
> 
> On Mon, May 18, 2020 at 8:38 AM Conrad Meyer  wrote:
>> 
>> Hi Michael,
>> 
>> These changes are a bit odd.  The only reason a standards-compliant
>> snprintf() would fail to nul-terminate a buffer is if the provided
>> buffer had length zero.  Since this is not the case in any of these
>> uses, I wonder why this revision was made?  Does a SCTP downstream
>> have a broken snprintf implementation, and if so, wouldn't it make
>> more sense to create a standards-compliant portability shim for that
>> platform instead of this more invasive change?
>> 
>> FreeBSD's snprintf(9) does not have this bug, nor does its snprintf(3).
>> 
>> Best regards,
>> Conrad
>> 
>> On Mon, May 18, 2020 at 3:07 AM Michael Tuexen  wrote:
>>> 
>>> Author: tuexen
>>> Date: Mon May 18 10:07:01 2020
>>> New Revision: 361209
>>> URL: https://svnweb.freebsd.org/changeset/base/361209
>>> 
>>> Log:
>>>  Handle failures of snprintf().
>>> 
>>>  MFC after:3 days
>>> 
>>> Modified:
>>>  head/sys/netinet/sctp_asconf.c
>>>  head/sys/netinet/sctp_indata.c
>>>  head/sys/netinet/sctp_input.c
>>>  head/sys/netinet/sctp_output.c
>>>  head/sys/netinet/sctp_pcb.c
>>> 
>>> Modified: head/sys/netinet/sctp_asconf.c
>>> ==
>>> --- head/sys/netinet/sctp_asconf.c  Mon May 18 09:46:51 2020
>>> (r361208)
>>> +++ head/sys/netinet/sctp_asconf.c  Mon May 18 10:07:01 2020
>>> (r361209)
>>> @@ -1706,8 +1706,9 @@ sctp_handle_asconf_ack(struct mbuf *m, int offset,
>>>char msg[SCTP_DIAG_INFO_LEN];
>>> 
>>>SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf_ack: got 
>>> unexpected next serial number! Aborting asoc!\n");
>>> -   snprintf(msg, sizeof(msg), "Never sent serial number %8.8x",
>>> -   serial_num);
>>> +   if (snprintf(msg, sizeof(msg), "Never sent serial number 
>>> %8.8x", serial_num) < 0) {
>>> +   msg[0] = '\0';
>>> +   }
>>>op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, 
>>> msg);
>>>sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, 
>>> SCTP_SO_NOT_LOCKED);
>>>*abort_no_unlock = 1;
>>> 
>>> Modified: head/sys/netinet/sctp_indata.c
>>> ==
>>> --- head/sys/netinet/sctp_indata.c  Mon May 18 09:46:51 2020
>>> (r361208)
>>> +++ head/sys/netinet/sctp_indata.c  Mon May 18 10:07:01 2020
>>> (r361209)
>>> @@ -434,22 +434,26 @@ sctp_abort_in_reasm(struct sctp_tcb *stcb,
>>>struct mbuf *oper;
>>> 
>>>if (stcb->asoc.idata_supported) {
>>> -   snprintf(msg, sizeof(msg),
>>> +   if (snprintf(msg, sizeof(msg),
>>>"Reass %x,CF:%x,TSN=%8.8x,SID=%4.4x,FSN=%8.8x,MID:%8.8x",
>>>opspot,
>>>control->fsn_included,
>>>chk->rec.data.tsn,
>>>chk->rec.data.sid,
>>> -   chk->rec.data.fsn, chk->rec.data.mid);
>>> +   chk->rec.data.fsn, chk->rec.data.mid) < 0) {
>>> +   msg[0] = '\0';
>>> +   }
>>>} else {
>>> -   snprintf(msg, sizeof(msg),
>>> +   if (snprintf(msg, sizeof(msg),
>>>"Reass %x,CI:%x,TSN=%8.8x,SID=%4.4x,FSN=%4.4x,SSN:%4.4x",
>>>opspot,
>>>control->fsn_included,
>>>chk->rec.data.tsn,
>>>chk->rec.data.sid,
>>>chk->rec.data.fsn,
>>> -   (uint16_t)chk->rec.data.mid);
>>> +   

Re: svn commit: r361209 - head/sys/netinet

2020-05-18 Thread Michael Tuexen
> On 18. May 2020, at 17:38, Conrad Meyer  wrote:
> 
> Hi Michael,
> 
> These changes are a bit odd.  The only reason a standards-compliant
> snprintf() would fail to nul-terminate a buffer is if the provided
> buffer had length zero.  Since this is not the case in any of these
> uses, I wonder why this revision was made?  Does a SCTP downstream
Hi Conrad,

when compiling the code in userland with gcc 10, it warns that
the output might be truncated. That is true and intended.
So checking that the call doesn't fail silences this warning and
ensures the code works in case snprintf() returns an error. I don't
see in the POSIX specification a statement limiting the case where
it could fail.
> have a broken snprintf implementation, and if so, wouldn't it make
> more sense to create a standards-compliant portability shim for that
> platform instead of this more invasive change?
If you want, I can revert the change and use the code only on non-FreeBSD
platforms.

Best regards
Michael
> 
> FreeBSD's snprintf(9) does not have this bug, nor does its snprintf(3).
> 
> Best regards,
> Conrad
> 
> On Mon, May 18, 2020 at 3:07 AM Michael Tuexen  wrote:
>> 
>> Author: tuexen
>> Date: Mon May 18 10:07:01 2020
>> New Revision: 361209
>> URL: https://svnweb.freebsd.org/changeset/base/361209
>> 
>> Log:
>>  Handle failures of snprintf().
>> 
>>  MFC after:3 days
>> 
>> Modified:
>>  head/sys/netinet/sctp_asconf.c
>>  head/sys/netinet/sctp_indata.c
>>  head/sys/netinet/sctp_input.c
>>  head/sys/netinet/sctp_output.c
>>  head/sys/netinet/sctp_pcb.c
>> 
>> Modified: head/sys/netinet/sctp_asconf.c
>> ==
>> --- head/sys/netinet/sctp_asconf.c  Mon May 18 09:46:51 2020
>> (r361208)
>> +++ head/sys/netinet/sctp_asconf.c  Mon May 18 10:07:01 2020
>> (r361209)
>> @@ -1706,8 +1706,9 @@ sctp_handle_asconf_ack(struct mbuf *m, int offset,
>>char msg[SCTP_DIAG_INFO_LEN];
>> 
>>SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf_ack: got 
>> unexpected next serial number! Aborting asoc!\n");
>> -   snprintf(msg, sizeof(msg), "Never sent serial number %8.8x",
>> -   serial_num);
>> +   if (snprintf(msg, sizeof(msg), "Never sent serial number 
>> %8.8x", serial_num) < 0) {
>> +   msg[0] = '\0';
>> +   }
>>op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, 
>> msg);
>>sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, 
>> SCTP_SO_NOT_LOCKED);
>>*abort_no_unlock = 1;
>> 
>> Modified: head/sys/netinet/sctp_indata.c
>> ==
>> --- head/sys/netinet/sctp_indata.c  Mon May 18 09:46:51 2020
>> (r361208)
>> +++ head/sys/netinet/sctp_indata.c  Mon May 18 10:07:01 2020
>> (r361209)
>> @@ -434,22 +434,26 @@ sctp_abort_in_reasm(struct sctp_tcb *stcb,
>>struct mbuf *oper;
>> 
>>if (stcb->asoc.idata_supported) {
>> -   snprintf(msg, sizeof(msg),
>> +   if (snprintf(msg, sizeof(msg),
>>"Reass %x,CF:%x,TSN=%8.8x,SID=%4.4x,FSN=%8.8x,MID:%8.8x",
>>opspot,
>>control->fsn_included,
>>chk->rec.data.tsn,
>>chk->rec.data.sid,
>> -   chk->rec.data.fsn, chk->rec.data.mid);
>> +   chk->rec.data.fsn, chk->rec.data.mid) < 0) {
>> +   msg[0] = '\0';
>> +   }
>>} else {
>> -   snprintf(msg, sizeof(msg),
>> +   if (snprintf(msg, sizeof(msg),
>>"Reass %x,CI:%x,TSN=%8.8x,SID=%4.4x,FSN=%4.4x,SSN:%4.4x",
>>opspot,
>>control->fsn_included,
>>chk->rec.data.tsn,
>>chk->rec.data.sid,
>>chk->rec.data.fsn,
>> -   (uint16_t)chk->rec.data.mid);
>> +   (uint16_t)chk->rec.data.mid) < 0) {
>> +   msg[0] = '\0';
>> +   }
>>}
>>oper = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg);
>>sctp_m_freem(chk->data);
>> @@ -533,15 +537,19 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb,
>> */
>>TAILQ_INSERT_HEAD(>inqueue, control, next_instrm);
>>if (asoc->idata_supported) {
>> -   snprintf(msg, sizeof(msg), "Delivered MID=%8.8x, got 
>> TSN=%8.8x, SID=%4.4x, MID=%8.8x",
>> +   if (snprintf(msg, sizeof(msg), "Delivered MID=%8.8x, 
>> got TSN=%8.8x, SID=%4.4x, MID=%8.8x",
>>strm->last_mid_delivered, control->sinfo_tsn,
>> -   control->sinfo_stream, control->mid);
>> +   control->sinfo_stream, control->mid) < 0) {
>> +

svn commit: r361220 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2020-05-18 Thread John Baldwin
Author: jhb
Date: Mon May 18 16:47:44 2020
New Revision: 361220
URL: https://svnweb.freebsd.org/changeset/base/361220

Log:
  Correct the order of arguments to copyin() for Q_SETQUOTA.
  
  MFC after:2 weeks
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D24656

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.cMon May 
18 16:33:32 2020(r361219)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.cMon May 
18 16:47:44 2020(r361220)
@@ -267,7 +267,7 @@ zfs_quotactl(vfs_t *vfsp, int cmds, uid_t id, void *ar
vfs_unbusy(vfsp);
break;
case Q_SETQUOTA:
-   error = copyin(, arg, sizeof(dqblk));
+   error = copyin(arg, , sizeof(dqblk));
if (error == 0)
error = zfs_set_userquota(zfsvfs, quota_type,
  "", id, 
dbtob(dqblk.dqb_bhardlimit));
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361219 - releng/11.4/lib/libz

2020-05-18 Thread Xin LI
Author: delphij
Date: Mon May 18 16:33:32 2020
New Revision: 361219
URL: https://svnweb.freebsd.org/changeset/base/361219

Log:
  MFS r361069: MFC r360952: Generate zlib.pc from source.
  
  Approved by:  re (gjb)

Deleted:
  releng/11.4/lib/libz/zlib.pc
Modified:
  releng/11.4/lib/libz/Makefile
Directory Properties:
  releng/11.4/   (props changed)

Modified: releng/11.4/lib/libz/Makefile
==
--- releng/11.4/lib/libz/Makefile   Mon May 18 16:07:14 2020
(r361218)
+++ releng/11.4/lib/libz/Makefile   Mon May 18 16:33:32 2020
(r361219)
@@ -52,6 +52,17 @@ INCS=zconf.h zlib.h
 
 .PATH: ${ZLIBSRC}/test
 
+ZLIB_VERSION!= sed -n '/define.*ZLIB_VERSION/{s,[^0-9.],,gp;q;}' 
${ZLIBSRC}/zlib.h
+
+zlib.pc: zlib.pc.in
+   sed -e 's,@prefix@,/usr,g ; \
+   s,@exec_prefix@,$${prefix},g ; \
+   s,@libdir@,$${exec_prefix}/lib,g ; \
+   s,@sharedlibdir@,$${libdir},g ; \
+   s,@includedir@,$${prefix}/include,g ; \
+   s,@VERSION@,${ZLIB_VERSION},g ;' \
+   ${.ALLSRC} > ${.TARGET}
+
 minigzip:  all minigzip.o
$(CC) -o minigzip minigzip.o -L. -lz
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361218 - head/contrib/binutils/gas

2020-05-18 Thread Ed Maste
Author: emaste
Date: Mon May 18 16:07:14 2020
New Revision: 361218
URL: https://svnweb.freebsd.org/changeset/base/361218

Log:
  GNU as: move deprecation message after option parsing
  
  Some cmake test parses the output of the first line of as --version, and
  emits an error if it does not contain some expected strings:
  
  Checking whether the ASM compiler is GNU using "--version" did not match
  "(GNU assembler)|(GCC)|(Free Software Foundation)"
  
  Emit the deprecation message later, after parsing argv and thus --version.
  
  PR:   246540
  Reported by:  dch
  Sponsored by: The FreeBSD Foundation

Modified:
  head/contrib/binutils/gas/as.c

Modified: head/contrib/binutils/gas/as.c
==
--- head/contrib/binutils/gas/as.c  Mon May 18 15:59:17 2020
(r361217)
+++ head/contrib/binutils/gas/as.c  Mon May 18 16:07:14 2020
(r361218)
@@ -1089,7 +1089,6 @@ main (int argc, char ** argv)
   expandargv (, );
 
   START_PROGRESS (myname, 0);
-  fprintf (stderr, _("warning: as 2.17.50 is deprecated in FreeBSD and will be 
removed\n"));
 
 #ifndef OBJ_DEFAULT_OUTPUT_FILE_NAME
 #define OBJ_DEFAULT_OUTPUT_FILE_NAME "a.out"
@@ -1109,6 +1108,7 @@ main (int argc, char ** argv)
   /* Call parse_args before any of the init/begin functions
  so that switches like --hash-size can be honored.  */
   parse_args (, );
+  fprintf (stderr, _("warning: GNU as %s is deprecated and will be 
removed\n"), BFD_VERSION_STRING);
   symbol_begin ();
   frag_init ();
   subsegs_begin ();
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361217 - in releng/11.4: cddl/contrib/opensolaris/lib/libdtrace/common sys/cddl/contrib/opensolaris/uts/common/dtrace sys/cddl/contrib/opensolaris/uts/common/sys sys/cddl/dev/dtrace

2020-05-18 Thread Dimitry Andric
Author: dim
Date: Mon May 18 15:59:17 2020
New Revision: 361217
URL: https://svnweb.freebsd.org/changeset/base/361217

Log:
  MF11 r361088:
  
  Merge changes that enable DTrace-using ports to link correctly with lld
  10, avoiding "unknown relocation 8" and other errors.
  
  MFC r312658 (by markj):
  
  Remove the DTRACEHIOC_ADD ioctl.
  
  This ioctl has been considered legacy by upstream since the DTrace code
  was first imported, and is unused. The removal also allows some
  simplification of dtrace_helper_slurp().
  
  Also remove a bogus copyout in the DTRACEHIOC_ADDDOF handler. Due to a
  bug, it would overwrite an in-memory copy of the DOF header rather than
  the passed-in DOF helper. Moreover, DTRACEHIOC_ADDDOF already copies the
  helper back out automatically since its argument has the IOC_OUT attribute.
  
  MFC r313262 (by markj):
  
  Use PC-relative relocations for USDT probe sites on i386 and amd64.
  
  When recording probe site addresses in the output DOF file, dtrace -G
  needs to emit relocations for the .SUNW_dof section in order to obtain
  the addresses of functions containing probe sites. DTrace expects the
  addresses to be relative to the base address of the final ELF file,
  and the amd64 USDT implementation was relying on some unspecified and
  incorrect behaviour in the base system GNU ld to achieve this.
  
  This change reimplements the probe site relocation handling to allow
  USDT to be used with lld and newer GNU binutils. Specifically, it
  makes use of R_X86_64_PC64/R_386_PC32 relocations to obtain the
  probe site address relative to the DOF file address, and adds and uses a
  new DOF relocation type which computes the final probe site address using
  these relative offsets.
  
  Approved by:  re (gjb)
  Reported by and discussed with:   Rafael Esp?ndola
  Differential Revision:https://reviews.freebsd.org/D9374

Modified:
  releng/11.4/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c
  releng/11.4/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
  releng/11.4/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c
  releng/11.4/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
  releng/11.4/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h
  releng/11.4/sys/cddl/dev/dtrace/dtrace_ioctl.c
Directory Properties:
  releng/11.4/   (props changed)

Modified: releng/11.4/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c
==
--- releng/11.4/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c  Mon May 
18 15:05:59 2020(r361216)
+++ releng/11.4/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c  Mon May 
18 15:59:17 2020(r361217)
@@ -462,18 +462,8 @@ dof_add_probe(dt_idhash_t *dhp, dt_ident_t *idp, void 
dt_buf_write(dtp, >ddo_enoffs, pip->pi_enoffs,
pip->pi_nenoffs * sizeof (uint32_t), sizeof (uint32_t));
 
-   /*
-* If pi_rname isn't set, the relocation will be against the
-* function name. If it is, the relocation will be against
-* pi_rname. This will be used if the function is scoped
-* locally so an alternate symbol is added for the purpose
-* of this relocation.
-*/
-   if (pip->pi_rname == NULL)
-   dofr.dofr_name = dofpr.dofpr_func;
-   else
-   dofr.dofr_name = dof_add_string(ddo, pip->pi_rname);
-   dofr.dofr_type = DOF_RELO_SETX;
+   dofr.dofr_name = dof_add_string(ddo, pip->pi_rname);
+   dofr.dofr_type = DOF_RELO_DOFREL;
dofr.dofr_offset = dt_buf_len(>ddo_probes);
dofr.dofr_data = 0;
 

Modified: releng/11.4/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
==
--- releng/11.4/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Mon May 
18 15:05:59 2020(r361216)
+++ releng/11.4/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Mon May 
18 15:59:17 2020(r361217)
@@ -239,7 +239,7 @@ prepare_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof,
rel->r_offset = s->dofs_offset +
dofr[j].dofr_offset;
rel->r_info = ELF32_R_INFO(count + dep->de_global,
-   R_386_32);
+   R_386_PC32);
 #elif defined(__mips__)
 /* XXX */
printf("%s:%s(%d): MIPS not implemented\n",
@@ -257,15 +257,6 @@ prepare_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof,
 /* XXX */
printf("%s:%s(%d): RISC-V not implemented\n",
__FUNCTION__, __FILE__, __LINE__);
-#elif defined(__sparc)
-   /*
-* Add 4 bytes to hit the low half of this 64-bit
-  

Re: svn commit: r361209 - head/sys/netinet

2020-05-18 Thread Conrad Meyer
(In fact, I don't believe snprintf(9) can return a negative value at
all.  And snprintf(3) will only do so in some special circumstances
for features snprintf(9) does not support: buffer size or formatted
result longer than INT_MAX; invalid *nn$ field width or precision
specifiers.  I don't think either case applies to these strings,
although I did not read all of them thoroughly.)

On Mon, May 18, 2020 at 8:38 AM Conrad Meyer  wrote:
>
> Hi Michael,
>
> These changes are a bit odd.  The only reason a standards-compliant
> snprintf() would fail to nul-terminate a buffer is if the provided
> buffer had length zero.  Since this is not the case in any of these
> uses, I wonder why this revision was made?  Does a SCTP downstream
> have a broken snprintf implementation, and if so, wouldn't it make
> more sense to create a standards-compliant portability shim for that
> platform instead of this more invasive change?
>
> FreeBSD's snprintf(9) does not have this bug, nor does its snprintf(3).
>
> Best regards,
> Conrad
>
> On Mon, May 18, 2020 at 3:07 AM Michael Tuexen  wrote:
> >
> > Author: tuexen
> > Date: Mon May 18 10:07:01 2020
> > New Revision: 361209
> > URL: https://svnweb.freebsd.org/changeset/base/361209
> >
> > Log:
> >   Handle failures of snprintf().
> >
> >   MFC after:3 days
> >
> > Modified:
> >   head/sys/netinet/sctp_asconf.c
> >   head/sys/netinet/sctp_indata.c
> >   head/sys/netinet/sctp_input.c
> >   head/sys/netinet/sctp_output.c
> >   head/sys/netinet/sctp_pcb.c
> >
> > Modified: head/sys/netinet/sctp_asconf.c
> > ==
> > --- head/sys/netinet/sctp_asconf.c  Mon May 18 09:46:51 2020
> > (r361208)
> > +++ head/sys/netinet/sctp_asconf.c  Mon May 18 10:07:01 2020
> > (r361209)
> > @@ -1706,8 +1706,9 @@ sctp_handle_asconf_ack(struct mbuf *m, int offset,
> > char msg[SCTP_DIAG_INFO_LEN];
> >
> > SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf_ack: got 
> > unexpected next serial number! Aborting asoc!\n");
> > -   snprintf(msg, sizeof(msg), "Never sent serial number %8.8x",
> > -   serial_num);
> > +   if (snprintf(msg, sizeof(msg), "Never sent serial number 
> > %8.8x", serial_num) < 0) {
> > +   msg[0] = '\0';
> > +   }
> > op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, 
> > msg);
> > sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, 
> > SCTP_SO_NOT_LOCKED);
> > *abort_no_unlock = 1;
> >
> > Modified: head/sys/netinet/sctp_indata.c
> > ==
> > --- head/sys/netinet/sctp_indata.c  Mon May 18 09:46:51 2020
> > (r361208)
> > +++ head/sys/netinet/sctp_indata.c  Mon May 18 10:07:01 2020
> > (r361209)
> > @@ -434,22 +434,26 @@ sctp_abort_in_reasm(struct sctp_tcb *stcb,
> > struct mbuf *oper;
> >
> > if (stcb->asoc.idata_supported) {
> > -   snprintf(msg, sizeof(msg),
> > +   if (snprintf(msg, sizeof(msg),
> > "Reass 
> > %x,CF:%x,TSN=%8.8x,SID=%4.4x,FSN=%8.8x,MID:%8.8x",
> > opspot,
> > control->fsn_included,
> > chk->rec.data.tsn,
> > chk->rec.data.sid,
> > -   chk->rec.data.fsn, chk->rec.data.mid);
> > +   chk->rec.data.fsn, chk->rec.data.mid) < 0) {
> > +   msg[0] = '\0';
> > +   }
> > } else {
> > -   snprintf(msg, sizeof(msg),
> > +   if (snprintf(msg, sizeof(msg),
> > "Reass 
> > %x,CI:%x,TSN=%8.8x,SID=%4.4x,FSN=%4.4x,SSN:%4.4x",
> > opspot,
> > control->fsn_included,
> > chk->rec.data.tsn,
> > chk->rec.data.sid,
> > chk->rec.data.fsn,
> > -   (uint16_t)chk->rec.data.mid);
> > +   (uint16_t)chk->rec.data.mid) < 0) {
> > +   msg[0] = '\0';
> > +   }
> > }
> > oper = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg);
> > sctp_m_freem(chk->data);
> > @@ -533,15 +537,19 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb,
> >  */
> > TAILQ_INSERT_HEAD(>inqueue, control, next_instrm);
> > if (asoc->idata_supported) {
> > -   snprintf(msg, sizeof(msg), "Delivered MID=%8.8x, 
> > got TSN=%8.8x, SID=%4.4x, MID=%8.8x",
> > +   if (snprintf(msg, sizeof(msg), "Delivered 
> > MID=%8.8x, got TSN=%8.8x, SID=%4.4x, MID=%8.8x",
> > strm->last_mid_delivered, control->sinfo_tsn,
> > -   control->sinfo_stream, control->mid);
> > +   

Re: svn commit: r361209 - head/sys/netinet

2020-05-18 Thread Conrad Meyer
Hi Michael,

These changes are a bit odd.  The only reason a standards-compliant
snprintf() would fail to nul-terminate a buffer is if the provided
buffer had length zero.  Since this is not the case in any of these
uses, I wonder why this revision was made?  Does a SCTP downstream
have a broken snprintf implementation, and if so, wouldn't it make
more sense to create a standards-compliant portability shim for that
platform instead of this more invasive change?

FreeBSD's snprintf(9) does not have this bug, nor does its snprintf(3).

Best regards,
Conrad

On Mon, May 18, 2020 at 3:07 AM Michael Tuexen  wrote:
>
> Author: tuexen
> Date: Mon May 18 10:07:01 2020
> New Revision: 361209
> URL: https://svnweb.freebsd.org/changeset/base/361209
>
> Log:
>   Handle failures of snprintf().
>
>   MFC after:3 days
>
> Modified:
>   head/sys/netinet/sctp_asconf.c
>   head/sys/netinet/sctp_indata.c
>   head/sys/netinet/sctp_input.c
>   head/sys/netinet/sctp_output.c
>   head/sys/netinet/sctp_pcb.c
>
> Modified: head/sys/netinet/sctp_asconf.c
> ==
> --- head/sys/netinet/sctp_asconf.c  Mon May 18 09:46:51 2020
> (r361208)
> +++ head/sys/netinet/sctp_asconf.c  Mon May 18 10:07:01 2020
> (r361209)
> @@ -1706,8 +1706,9 @@ sctp_handle_asconf_ack(struct mbuf *m, int offset,
> char msg[SCTP_DIAG_INFO_LEN];
>
> SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf_ack: got 
> unexpected next serial number! Aborting asoc!\n");
> -   snprintf(msg, sizeof(msg), "Never sent serial number %8.8x",
> -   serial_num);
> +   if (snprintf(msg, sizeof(msg), "Never sent serial number 
> %8.8x", serial_num) < 0) {
> +   msg[0] = '\0';
> +   }
> op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, 
> msg);
> sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, 
> SCTP_SO_NOT_LOCKED);
> *abort_no_unlock = 1;
>
> Modified: head/sys/netinet/sctp_indata.c
> ==
> --- head/sys/netinet/sctp_indata.c  Mon May 18 09:46:51 2020
> (r361208)
> +++ head/sys/netinet/sctp_indata.c  Mon May 18 10:07:01 2020
> (r361209)
> @@ -434,22 +434,26 @@ sctp_abort_in_reasm(struct sctp_tcb *stcb,
> struct mbuf *oper;
>
> if (stcb->asoc.idata_supported) {
> -   snprintf(msg, sizeof(msg),
> +   if (snprintf(msg, sizeof(msg),
> "Reass %x,CF:%x,TSN=%8.8x,SID=%4.4x,FSN=%8.8x,MID:%8.8x",
> opspot,
> control->fsn_included,
> chk->rec.data.tsn,
> chk->rec.data.sid,
> -   chk->rec.data.fsn, chk->rec.data.mid);
> +   chk->rec.data.fsn, chk->rec.data.mid) < 0) {
> +   msg[0] = '\0';
> +   }
> } else {
> -   snprintf(msg, sizeof(msg),
> +   if (snprintf(msg, sizeof(msg),
> "Reass %x,CI:%x,TSN=%8.8x,SID=%4.4x,FSN=%4.4x,SSN:%4.4x",
> opspot,
> control->fsn_included,
> chk->rec.data.tsn,
> chk->rec.data.sid,
> chk->rec.data.fsn,
> -   (uint16_t)chk->rec.data.mid);
> +   (uint16_t)chk->rec.data.mid) < 0) {
> +   msg[0] = '\0';
> +   }
> }
> oper = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg);
> sctp_m_freem(chk->data);
> @@ -533,15 +537,19 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb,
>  */
> TAILQ_INSERT_HEAD(>inqueue, control, next_instrm);
> if (asoc->idata_supported) {
> -   snprintf(msg, sizeof(msg), "Delivered MID=%8.8x, got 
> TSN=%8.8x, SID=%4.4x, MID=%8.8x",
> +   if (snprintf(msg, sizeof(msg), "Delivered MID=%8.8x, 
> got TSN=%8.8x, SID=%4.4x, MID=%8.8x",
> strm->last_mid_delivered, control->sinfo_tsn,
> -   control->sinfo_stream, control->mid);
> +   control->sinfo_stream, control->mid) < 0) {
> +   msg[0] = '\0';
> +   }
> } else {
> -   snprintf(msg, sizeof(msg), "Delivered SSN=%4.4x, got 
> TSN=%8.8x, SID=%4.4x, SSN=%4.4x",
> +   if (snprintf(msg, sizeof(msg), "Delivered SSN=%4.4x, 
> got TSN=%8.8x, SID=%4.4x, SSN=%4.4x",
> (uint16_t)strm->last_mid_delivered,
> control->sinfo_tsn,
> control->sinfo_stream,
> -   (uint16_t)control->mid);
> +   (uint16_t)control->mid) < 0) 

svn commit: r361216 - head/usr.sbin/acpi/acpidump

2020-05-18 Thread Andrew Turner
Author: andrew
Date: Mon May 18 15:05:59 2020
New Revision: 361216
URL: https://svnweb.freebsd.org/changeset/base/361216

Log:
  Allow the FACS and XFACS to be zero in acpidump.
  
  These are allowed to be zero when the hardware reduced APCI flag is set
  
  Sponsored by: Innovate UK
  Differential Revision:https://reviews.freebsd.org/D23207

Modified:
  head/usr.sbin/acpi/acpidump/acpi.c

Modified: head/usr.sbin/acpi/acpidump/acpi.c
==
--- head/usr.sbin/acpi/acpidump/acpi.c  Mon May 18 15:03:52 2020
(r361215)
+++ head/usr.sbin/acpi/acpidump/acpi.c  Mon May 18 15:05:59 2020
(r361216)
@@ -245,6 +245,7 @@ acpi_handle_fadt(ACPI_TABLE_HEADER *sdp)
ACPI_TABLE_HEADER *dsdp;
ACPI_TABLE_FACS *facs;
ACPI_TABLE_FADT *fadt;
+   vm_offset_t addr;
int fadt_revision;
 
fadt = (ACPI_TABLE_FADT *)sdp;
@@ -252,12 +253,17 @@ acpi_handle_fadt(ACPI_TABLE_HEADER *sdp)
 
fadt_revision = acpi_get_fadt_revision(fadt);
if (fadt_revision == 1)
-   facs = (ACPI_TABLE_FACS *)acpi_map_sdt(fadt->Facs);
+   addr = fadt->Facs;
else
-   facs = (ACPI_TABLE_FACS *)acpi_map_sdt(fadt->XFacs);
-   if (memcmp(facs->Signature, ACPI_SIG_FACS, 4) != 0 || facs->Length < 64)
-   errx(1, "FACS is corrupt");
-   acpi_print_facs(facs);
+   addr = fadt->XFacs;
+   if (addr != 0) {
+   facs = (ACPI_TABLE_FACS *)acpi_map_sdt(addr);
+
+   if (memcmp(facs->Signature, ACPI_SIG_FACS, 4) != 0 ||
+   facs->Length < 64)
+   errx(1, "FACS is corrupt");
+   acpi_print_facs(facs);
+   }
 
if (fadt_revision == 1)
dsdp = (ACPI_TABLE_HEADER *)acpi_map_sdt(fadt->Dsdt);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361215 - head/usr.sbin/bhyve

2020-05-18 Thread Aleksandr Fedorov
Author: afedorov
Date: Mon May 18 15:03:52 2020
New Revision: 361215
URL: https://svnweb.freebsd.org/changeset/base/361215

Log:
  bhyve(8): Add the netgraph network backend decription to the manpage.
  
  Reviewed by:  vmaffione, bcr
  Approved by:  vmaffione (mentor)
  Sponsored by: vstack.com
  Differential Revision:https://reviews.freebsd.org/D24846

Modified:
  head/usr.sbin/bhyve/bhyve.8

Modified: head/usr.sbin/bhyve/bhyve.8
==
--- head/usr.sbin/bhyve/bhyve.8 Mon May 18 15:02:15 2020(r361214)
+++ head/usr.sbin/bhyve/bhyve.8 Mon May 18 15:03:52 2020(r361215)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 5, 2020
+.Dd May 18, 2020
 .Dt BHYVE 8
 .Os
 .Sh NAME
@@ -291,10 +291,11 @@ If
 is not specified, the device emulation has no backend and can be
 considered unconnected.
 .Pp
-Network devices:
+Network backends:
 .Bl -tag -width 10n
 .It Ar tapN Ns Oo , Ns Ar mac=xx:xx:xx:xx:xx:xx Oc Ns Oo , Ns Ar mtu=N Oc
 .It Ar vmnetN Ns Oo , Ns Ar mac=xx:xx:xx:xx:xx:xx Oc Ns Oo , Ns Ar mtu=N Oc
+.It Ar netgraph,path=ADDRESS,peerhook=HOOK Ns Oo , Ns Ar socket=NAME Oc Ns Oo 
, Ns Ar hook=HOOK Oc Ns Oo , Ns Ar mac=xx:xx:xx:xx:xx:xx Oc Ns Oo , Ns Ar mtu=N 
Oc
 .Pp
 If
 .Ar mac
@@ -310,6 +311,27 @@ With virtio-net devices, the
 .Ar mtu
 parameter can be specified to inform the guest about the largest MTU
 that should be allowed, expressed in bytes.
+.Pp
+With netgraph backend, the
+.Ar path
+and
+.Ar peerhook
+parameters must be specified to set the destination node and corresponding 
hook.
+The optional parameters
+.Ar socket
+and
+.Ar hook
+may be used to set the
+.Xr ng_socket 4
+node name and source hook.
+The
+.Ar ADDRESS ,
+.Ar HOOK
+and
+.Ar NAME
+must comply with
+.Xr netgraph 4
+addressing rules.
 .El
 .Pp
 Block storage devices:
@@ -670,6 +692,8 @@ bhyve -c 2 -m 4G -w -H \\
 .Ed
 .Sh SEE ALSO
 .Xr bhyve 4 ,
+.Xr netgraph 4 ,
+.Xr ng_socket 4 ,
 .Xr nmdm 4 ,
 .Xr vmm 4 ,
 .Xr ethers 5 ,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361214 - head/sys/netinet

2020-05-18 Thread Michael Tuexen
Author: tuexen
Date: Mon May 18 15:02:15 2020
New Revision: 361214
URL: https://svnweb.freebsd.org/changeset/base/361214

Log:
  Fix logical condition by looking at usecs.
  
  This issue was found by cpp-check running on the userland stack.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctputil.c
==
--- head/sys/netinet/sctputil.c Mon May 18 15:00:18 2020(r361213)
+++ head/sys/netinet/sctputil.c Mon May 18 15:02:15 2020(r361214)
@@ -2933,7 +2933,7 @@ sctp_calculate_rto(struct sctp_tcb *stcb,
(void)SCTP_GETTIME_TIMEVAL();
}
if ((old->tv_sec > now.tv_sec) ||
-   ((old->tv_sec == now.tv_sec) && (old->tv_sec > now.tv_sec))) {
+   ((old->tv_sec == now.tv_sec) && (old->tv_usec > now.tv_usec))) {
/* The starting point is in the future. */
return (0);
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361213 - head/sys/netinet

2020-05-18 Thread Michael Tuexen
Author: tuexen
Date: Mon May 18 15:00:18 2020
New Revision: 361213
URL: https://svnweb.freebsd.org/changeset/base/361213

Log:
  Whitespace change.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctputil.c
==
--- head/sys/netinet/sctputil.c Mon May 18 14:38:27 2020(r361212)
+++ head/sys/netinet/sctputil.c Mon May 18 15:00:18 2020(r361213)
@@ -1560,8 +1560,8 @@ select_a_new_ep:
iteration_count = 0;
}
KASSERT(it->inp == it->stcb->sctp_ep,
-   ("%s: stcb %p does not belong to inp %p, but inp %p",
-__func__, it->stcb, it->inp, it->stcb->sctp_ep));
+   ("%s: stcb %p does not belong to inp %p, but inp %p",
+   __func__, it->stcb, it->inp, it->stcb->sctp_ep));
 
/* run function on this one */
(*it->function_assoc) (it->inp, it->stcb, it->pointer, it->val);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361212 - stable/11/sys/kern

2020-05-18 Thread Konstantin Belousov
Author: kib
Date: Mon May 18 14:38:27 2020
New Revision: 361212
URL: https://svnweb.freebsd.org/changeset/base/361212

Log:
  MFC r361077, r361078, r361079:
  Improve comment for compat32 handling of sysctl hw.pagesizes.

Modified:
  stable/11/sys/kern/kern_mib.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/kern/kern_mib.c
==
--- stable/11/sys/kern/kern_mib.c   Mon May 18 14:37:10 2020
(r361211)
+++ stable/11/sys/kern/kern_mib.c   Mon May 18 14:38:27 2020
(r361212)
@@ -235,8 +235,9 @@ sysctl_hw_pagesizes(SYSCTL_HANDLER_ARGS)
 
if (req->flags & SCTL_MASK32) {
/*
-* Recreate the "pagesizes" array with 32-bit elements.  
Truncate
-* any page size greater than UINT32_MAX to zero.
+* Recreate the "pagesizes" array with 32-bit elements.
+* Truncate any page size greater than UINT32_MAX to zero,
+* which assumes that page sizes are powers of two.
 */
for (i = 0; i < MAXPAGESIZES; i++)
pagesizes32[i] = (uint32_t)pagesizes[i];
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361211 - stable/12/sys/kern

2020-05-18 Thread Konstantin Belousov
Author: kib
Date: Mon May 18 14:37:10 2020
New Revision: 361211
URL: https://svnweb.freebsd.org/changeset/base/361211

Log:
  MFC r361077, r361078, r361079:
  Improve comment for compat32 handling of sysctl hw.pagesizes.

Modified:
  stable/12/sys/kern/kern_mib.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/kern_mib.c
==
--- stable/12/sys/kern/kern_mib.c   Mon May 18 12:36:28 2020
(r361210)
+++ stable/12/sys/kern/kern_mib.c   Mon May 18 14:37:10 2020
(r361211)
@@ -240,8 +240,9 @@ sysctl_hw_pagesizes(SYSCTL_HANDLER_ARGS)
 
if (req->flags & SCTL_MASK32) {
/*
-* Recreate the "pagesizes" array with 32-bit elements.  
Truncate
-* any page size greater than UINT32_MAX to zero.
+* Recreate the "pagesizes" array with 32-bit elements.
+* Truncate any page size greater than UINT32_MAX to zero,
+* which assumes that page sizes are powers of two.
 */
for (i = 0; i < MAXPAGESIZES; i++)
pagesizes32[i] = (uint32_t)pagesizes[i];
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361210 - head/contrib/netbsd-tests/lib/libexecinfo

2020-05-18 Thread Li-Wen Hsu
Author: lwhsu
Date: Mon May 18 12:36:28 2020
New Revision: 361210
URL: https://svnweb.freebsd.org/changeset/base/361210

Log:
  Temporarily disable failing case in CI of amd64:
  
  - lib.libexecinfo.backtrace_test.backtrace_fmt_basic
  
  PR:   246537
  Sponsored by: The FreeBSD Foundation

Modified:
  head/contrib/netbsd-tests/lib/libexecinfo/t_backtrace.c

Modified: head/contrib/netbsd-tests/lib/libexecinfo/t_backtrace.c
==
--- head/contrib/netbsd-tests/lib/libexecinfo/t_backtrace.c Mon May 18 
10:07:01 2020(r361209)
+++ head/contrib/netbsd-tests/lib/libexecinfo/t_backtrace.c Mon May 18 
12:36:28 2020(r361210)
@@ -151,6 +151,11 @@ ATF_TC_HEAD(backtrace_fmt_basic, tc)
 
 ATF_TC_BODY(backtrace_fmt_basic, tc)
 {
+#if defined(__amd64__)
+   if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false))
+   atf_tc_skip("https://bugs.freebsd.org/246537;);
+#endif
+
myfunc(12);
 
if (prevent_inline)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361209 - head/sys/netinet

2020-05-18 Thread Michael Tuexen
Author: tuexen
Date: Mon May 18 10:07:01 2020
New Revision: 361209
URL: https://svnweb.freebsd.org/changeset/base/361209

Log:
  Handle failures of snprintf().
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_asconf.c
  head/sys/netinet/sctp_indata.c
  head/sys/netinet/sctp_input.c
  head/sys/netinet/sctp_output.c
  head/sys/netinet/sctp_pcb.c

Modified: head/sys/netinet/sctp_asconf.c
==
--- head/sys/netinet/sctp_asconf.c  Mon May 18 09:46:51 2020
(r361208)
+++ head/sys/netinet/sctp_asconf.c  Mon May 18 10:07:01 2020
(r361209)
@@ -1706,8 +1706,9 @@ sctp_handle_asconf_ack(struct mbuf *m, int offset,
char msg[SCTP_DIAG_INFO_LEN];
 
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf_ack: got unexpected 
next serial number! Aborting asoc!\n");
-   snprintf(msg, sizeof(msg), "Never sent serial number %8.8x",
-   serial_num);
+   if (snprintf(msg, sizeof(msg), "Never sent serial number 
%8.8x", serial_num) < 0) {
+   msg[0] = '\0';
+   }
op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, 
msg);
sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, 
SCTP_SO_NOT_LOCKED);
*abort_no_unlock = 1;

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Mon May 18 09:46:51 2020
(r361208)
+++ head/sys/netinet/sctp_indata.c  Mon May 18 10:07:01 2020
(r361209)
@@ -434,22 +434,26 @@ sctp_abort_in_reasm(struct sctp_tcb *stcb,
struct mbuf *oper;
 
if (stcb->asoc.idata_supported) {
-   snprintf(msg, sizeof(msg),
+   if (snprintf(msg, sizeof(msg),
"Reass %x,CF:%x,TSN=%8.8x,SID=%4.4x,FSN=%8.8x,MID:%8.8x",
opspot,
control->fsn_included,
chk->rec.data.tsn,
chk->rec.data.sid,
-   chk->rec.data.fsn, chk->rec.data.mid);
+   chk->rec.data.fsn, chk->rec.data.mid) < 0) {
+   msg[0] = '\0';
+   }
} else {
-   snprintf(msg, sizeof(msg),
+   if (snprintf(msg, sizeof(msg),
"Reass %x,CI:%x,TSN=%8.8x,SID=%4.4x,FSN=%4.4x,SSN:%4.4x",
opspot,
control->fsn_included,
chk->rec.data.tsn,
chk->rec.data.sid,
chk->rec.data.fsn,
-   (uint16_t)chk->rec.data.mid);
+   (uint16_t)chk->rec.data.mid) < 0) {
+   msg[0] = '\0';
+   }
}
oper = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg);
sctp_m_freem(chk->data);
@@ -533,15 +537,19 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb,
 */
TAILQ_INSERT_HEAD(>inqueue, control, next_instrm);
if (asoc->idata_supported) {
-   snprintf(msg, sizeof(msg), "Delivered MID=%8.8x, got 
TSN=%8.8x, SID=%4.4x, MID=%8.8x",
+   if (snprintf(msg, sizeof(msg), "Delivered MID=%8.8x, 
got TSN=%8.8x, SID=%4.4x, MID=%8.8x",
strm->last_mid_delivered, control->sinfo_tsn,
-   control->sinfo_stream, control->mid);
+   control->sinfo_stream, control->mid) < 0) {
+   msg[0] = '\0';
+   }
} else {
-   snprintf(msg, sizeof(msg), "Delivered SSN=%4.4x, got 
TSN=%8.8x, SID=%4.4x, SSN=%4.4x",
+   if (snprintf(msg, sizeof(msg), "Delivered SSN=%4.4x, 
got TSN=%8.8x, SID=%4.4x, SSN=%4.4x",
(uint16_t)strm->last_mid_delivered,
control->sinfo_tsn,
control->sinfo_stream,
-   (uint16_t)control->mid);
+   (uint16_t)control->mid) < 0) {
+   msg[0] = '\0';
+   }
}
op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, 
msg);
stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + 
SCTP_LOC_2;
@@ -648,9 +656,10 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb,
 * to put it on the queue.
 */
if (sctp_place_control_in_stream(strm, asoc, control)) {
-   snprintf(msg, sizeof(msg),
-   "Queue to str MID: %u duplicate",
-   control->mid);
+   if (snprintf(msg, sizeof(msg),
+   "Queue to str MID: %u duplicate", control->mid) < 
0) {
+   msg[0] = 

svn commit: r361208 - stable/11/sys/dev/usb

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:46:51 2020
New Revision: 361208
URL: https://svnweb.freebsd.org/changeset/base/361208

Log:
  MFC r360925:
  Refresh the USB device strings when a USB device is re-enumerated.
  
  Submitted by: Horse Ma 
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/dev/usb/usb_device.c
  stable/11/sys/dev/usb/usb_device.h
  stable/11/sys/dev/usb/usb_hub.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/usb/usb_device.c
==
--- stable/11/sys/dev/usb/usb_device.c  Mon May 18 09:45:59 2020
(r361207)
+++ stable/11/sys/dev/usb/usb_device.c  Mon May 18 09:46:51 2020
(r361208)
@@ -101,7 +101,6 @@ static void usb_suspend_resume_sub(struct usb_device *
uint8_t);
 static usb_proc_callback_t usbd_clear_stall_proc;
 static usb_error_t usb_config_parse(struct usb_device *, uint8_t, uint8_t);
-static voidusbd_set_device_strings(struct usb_device *);
 #if USB_HAVE_DEVCTL
 static voidusb_notify_addq(const char *type, struct usb_device *);
 #endif
@@ -1650,6 +1649,85 @@ usbd_clear_stall_proc(struct usb_proc_msg *_pm)
 }
 
 /**
+ *  usb_get_langid
+ *
+ * This function tries to figure out the USB string language to use.
+ **/
+void
+usb_get_langid(struct usb_device *udev)
+{
+   uint8_t *scratch_ptr;
+   uint8_t do_unlock;
+   int err;
+
+   /*
+* Workaround for buggy USB devices.
+*
+* It appears that some string-less USB chips will crash and
+* disappear if any attempts are made to read any string
+* descriptors.
+*
+* Try to detect such chips by checking the strings in the USB
+* device descriptor. If no strings are present there we
+* simply disable all USB strings.
+*/
+
+   /* Protect scratch area */
+   do_unlock = usbd_ctrl_lock(udev);
+
+   scratch_ptr = udev->scratch.data;
+
+   if (udev->flags.no_strings) {
+   err = USB_ERR_INVAL;
+   } else if (udev->ddesc.iManufacturer ||
+   udev->ddesc.iProduct ||
+   udev->ddesc.iSerialNumber) {
+   /* read out the language ID string */
+   err = usbd_req_get_string_desc(udev, NULL,
+   (char *)scratch_ptr, 4, 0, USB_LANGUAGE_TABLE);
+   } else {
+   err = USB_ERR_INVAL;
+   }
+
+   if (err || (scratch_ptr[0] < 4)) {
+   udev->flags.no_strings = 1;
+   } else {
+   uint16_t langid;
+   uint16_t pref;
+   uint16_t mask;
+   uint8_t x;
+
+   /* load preferred value and mask */
+   pref = usb_lang_id;
+   mask = usb_lang_mask;
+
+   /* align length correctly */
+   scratch_ptr[0] &= ~1U;
+
+   /* fix compiler warning */
+   langid = 0;
+
+   /* search for preferred language */
+   for (x = 2; x < scratch_ptr[0]; x += 2) {
+   langid = UGETW(scratch_ptr + x);
+   if ((langid & mask) == pref)
+   break;
+   }
+   if (x >= scratch_ptr[0]) {
+   /* pick the first language as the default */
+   DPRINTFN(1, "Using first language\n");
+   langid = UGETW(scratch_ptr + 2);
+   }
+
+   DPRINTFN(1, "Language selected: 0x%04x\n", langid);
+   udev->langid = langid;
+   }
+
+   if (do_unlock)
+   usbd_ctrl_unlock(udev);
+}
+
+/**
  * usb_alloc_device
  *
  * This function allocates a new USB device. This function is called
@@ -1670,13 +1748,11 @@ usb_alloc_device(device_t parent_dev, struct usb_bus *
struct usb_device *udev;
struct usb_device *adev;
struct usb_device *hub;
-   uint8_t *scratch_ptr;
usb_error_t err;
uint8_t device_index;
uint8_t config_index;
uint8_t config_quirk;
uint8_t set_config_failed;
-   uint8_t do_unlock;
 
DPRINTF("parent_dev=%p, bus=%p, parent_hub=%p, depth=%u, "
"port_index=%u, port_no=%u, speed=%u, usb_mode=%u\n",
@@ -1886,76 +1962,13 @@ usb_alloc_device(device_t parent_dev, struct usb_bus *
if (usb_test_quirk(, UQ_NO_STRINGS)) {
udev->flags.no_strings = 1;
}
-   /*
-* Workaround for buggy USB devices.
-*
-* It appears that some string-less USB chips will crash and
-* disappear if any attempts are made to read any string
-* descriptors.
-*
-* Try to detect such chips by checking the strings in 

svn commit: r361207 - stable/12/sys/dev/usb

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:45:59 2020
New Revision: 361207
URL: https://svnweb.freebsd.org/changeset/base/361207

Log:
  MFC r360925:
  Refresh the USB device strings when a USB device is re-enumerated.
  
  Submitted by: Horse Ma 
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/sys/dev/usb/usb_device.c
  stable/12/sys/dev/usb/usb_device.h
  stable/12/sys/dev/usb/usb_hub.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/usb/usb_device.c
==
--- stable/12/sys/dev/usb/usb_device.c  Mon May 18 09:45:13 2020
(r361206)
+++ stable/12/sys/dev/usb/usb_device.c  Mon May 18 09:45:59 2020
(r361207)
@@ -103,7 +103,6 @@ static void usb_suspend_resume_sub(struct usb_device *
uint8_t);
 static usb_proc_callback_t usbd_clear_stall_proc;
 static usb_error_t usb_config_parse(struct usb_device *, uint8_t, uint8_t);
-static voidusbd_set_device_strings(struct usb_device *);
 #if USB_HAVE_DEVCTL
 static voidusb_notify_addq(const char *type, struct usb_device *);
 #endif
@@ -1652,6 +1651,85 @@ usbd_clear_stall_proc(struct usb_proc_msg *_pm)
 }
 
 /**
+ *  usb_get_langid
+ *
+ * This function tries to figure out the USB string language to use.
+ **/
+void
+usb_get_langid(struct usb_device *udev)
+{
+   uint8_t *scratch_ptr;
+   uint8_t do_unlock;
+   int err;
+
+   /*
+* Workaround for buggy USB devices.
+*
+* It appears that some string-less USB chips will crash and
+* disappear if any attempts are made to read any string
+* descriptors.
+*
+* Try to detect such chips by checking the strings in the USB
+* device descriptor. If no strings are present there we
+* simply disable all USB strings.
+*/
+
+   /* Protect scratch area */
+   do_unlock = usbd_ctrl_lock(udev);
+
+   scratch_ptr = udev->scratch.data;
+
+   if (udev->flags.no_strings) {
+   err = USB_ERR_INVAL;
+   } else if (udev->ddesc.iManufacturer ||
+   udev->ddesc.iProduct ||
+   udev->ddesc.iSerialNumber) {
+   /* read out the language ID string */
+   err = usbd_req_get_string_desc(udev, NULL,
+   (char *)scratch_ptr, 4, 0, USB_LANGUAGE_TABLE);
+   } else {
+   err = USB_ERR_INVAL;
+   }
+
+   if (err || (scratch_ptr[0] < 4)) {
+   udev->flags.no_strings = 1;
+   } else {
+   uint16_t langid;
+   uint16_t pref;
+   uint16_t mask;
+   uint8_t x;
+
+   /* load preferred value and mask */
+   pref = usb_lang_id;
+   mask = usb_lang_mask;
+
+   /* align length correctly */
+   scratch_ptr[0] &= ~1U;
+
+   /* fix compiler warning */
+   langid = 0;
+
+   /* search for preferred language */
+   for (x = 2; x < scratch_ptr[0]; x += 2) {
+   langid = UGETW(scratch_ptr + x);
+   if ((langid & mask) == pref)
+   break;
+   }
+   if (x >= scratch_ptr[0]) {
+   /* pick the first language as the default */
+   DPRINTFN(1, "Using first language\n");
+   langid = UGETW(scratch_ptr + 2);
+   }
+
+   DPRINTFN(1, "Language selected: 0x%04x\n", langid);
+   udev->langid = langid;
+   }
+
+   if (do_unlock)
+   usbd_ctrl_unlock(udev);
+}
+
+/**
  * usb_alloc_device
  *
  * This function allocates a new USB device. This function is called
@@ -1672,13 +1750,11 @@ usb_alloc_device(device_t parent_dev, struct usb_bus *
struct usb_device *udev;
struct usb_device *adev;
struct usb_device *hub;
-   uint8_t *scratch_ptr;
usb_error_t err;
uint8_t device_index;
uint8_t config_index;
uint8_t config_quirk;
uint8_t set_config_failed;
-   uint8_t do_unlock;
 
DPRINTF("parent_dev=%p, bus=%p, parent_hub=%p, depth=%u, "
"port_index=%u, port_no=%u, speed=%u, usb_mode=%u\n",
@@ -1888,76 +1964,13 @@ usb_alloc_device(device_t parent_dev, struct usb_bus *
if (usb_test_quirk(, UQ_NO_STRINGS)) {
udev->flags.no_strings = 1;
}
-   /*
-* Workaround for buggy USB devices.
-*
-* It appears that some string-less USB chips will crash and
-* disappear if any attempts are made to read any string
-* descriptors.
-*
-* Try to detect such chips by checking the strings in 

svn commit: r361206 - stable/11/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:45:13 2020
New Revision: 361206
URL: https://svnweb.freebsd.org/changeset/base/361206

Log:
  MFC r360623:
  Optimise use of sg_page_count() in __sg_page_iter_next() in the LinuxKPI.
  No need to compute value twice.
  
  No functional change intended.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/scatterlist.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/scatterlist.h
==
--- stable/11/sys/compat/linuxkpi/common/include/linux/scatterlist.hMon May 
18 09:44:26 2020(r361205)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/scatterlist.hMon May 
18 09:45:13 2020(r361206)
@@ -414,6 +414,8 @@ sg_page_count(struct scatterlist *sg)
 static inline bool
 __sg_page_iter_next(struct sg_page_iter *piter)
 {
+   unsigned int pgcount;
+
if (piter->internal.nents == 0)
return (0);
if (piter->sg == NULL)
@@ -422,8 +424,11 @@ __sg_page_iter_next(struct sg_page_iter *piter)
piter->sg_pgoffset += piter->internal.pg_advance;
piter->internal.pg_advance = 1;
 
-   while (piter->sg_pgoffset >= sg_page_count(piter->sg)) {
-   piter->sg_pgoffset -= sg_page_count(piter->sg);
+   while (1) {
+   pgcount = sg_page_count(piter->sg);
+   if (likely(piter->sg_pgoffset < pgcount))
+   break;
+   piter->sg_pgoffset -= pgcount;
piter->sg = sg_next(piter->sg);
if (--piter->internal.nents == 0)
return (0);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361205 - stable/12/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:44:26 2020
New Revision: 361205
URL: https://svnweb.freebsd.org/changeset/base/361205

Log:
  MFC r360623:
  Optimise use of sg_page_count() in __sg_page_iter_next() in the LinuxKPI.
  No need to compute value twice.
  
  No functional change intended.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/sys/compat/linuxkpi/common/include/linux/scatterlist.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/scatterlist.h
==
--- stable/12/sys/compat/linuxkpi/common/include/linux/scatterlist.hMon May 
18 09:43:31 2020(r361204)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/scatterlist.hMon May 
18 09:44:26 2020(r361205)
@@ -416,6 +416,8 @@ sg_page_count(struct scatterlist *sg)
 static inline bool
 __sg_page_iter_next(struct sg_page_iter *piter)
 {
+   unsigned int pgcount;
+
if (piter->internal.nents == 0)
return (0);
if (piter->sg == NULL)
@@ -424,8 +426,11 @@ __sg_page_iter_next(struct sg_page_iter *piter)
piter->sg_pgoffset += piter->internal.pg_advance;
piter->internal.pg_advance = 1;
 
-   while (piter->sg_pgoffset >= sg_page_count(piter->sg)) {
-   piter->sg_pgoffset -= sg_page_count(piter->sg);
+   while (1) {
+   pgcount = sg_page_count(piter->sg);
+   if (likely(piter->sg_pgoffset < pgcount))
+   break;
+   piter->sg_pgoffset -= pgcount;
piter->sg = sg_next(piter->sg);
if (--piter->internal.nents == 0)
return (0);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361204 - stable/11/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:43:31 2020
New Revision: 361204
URL: https://svnweb.freebsd.org/changeset/base/361204

Log:
  MFC r360622:
  Implement more scatter and gather functions in the LinuxKPI.
  
  Differential Revision:https://reviews.freebsd.org/D24611
  Submitted by: ashafer_badland.io (Austin Shafer)
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/scatterlist.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/scatterlist.h
==
--- stable/11/sys/compat/linuxkpi/common/include/linux/scatterlist.hMon May 
18 09:37:02 2020(r361203)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/scatterlist.hMon May 
18 09:43:31 2020(r361204)
@@ -64,6 +64,10 @@ struct sg_page_iter {
} internal;
 };
 
+struct sg_dma_page_iter {
+   struct sg_page_iter base;
+};
+
 #defineSCATTERLIST_MAX_SEGMENT (-1U & ~(PAGE_SIZE - 1))
 
 #defineSG_MAX_SINGLE_ALLOC (PAGE_SIZE / sizeof(struct scatterlist))
@@ -83,6 +87,8 @@ struct sg_page_iter {
 #definefor_each_sg_page(sgl, iter, nents, pgoffset)
\
for (_sg_iter_init(sgl, iter, nents, pgoffset); \
 (iter)->sg; _sg_iter_next(iter))
+#definefor_each_sg_dma_page(sgl, iter, nents, pgoffset)
\
+   for_each_sg_page(sgl, &(iter)->base, nents, pgoffset)
 
 #definefor_each_sg(sglist, sg, sgmax, iter)
\
for (iter = 0, sg = (sglist); iter < (sgmax); iter++, sg = sg_next(sg))
@@ -402,6 +408,8 @@ sg_page_count(struct scatterlist *sg)
 {
return (PAGE_ALIGN(sg->offset + sg->length) >> PAGE_SHIFT);
 }
+#definesg_dma_page_count(sg) \
+   sg_page_count(sg)
 
 static inline bool
 __sg_page_iter_next(struct sg_page_iter *piter)
@@ -424,6 +432,8 @@ __sg_page_iter_next(struct sg_page_iter *piter)
}
return (1);
 }
+#define__sg_page_iter_dma_next(itr) \
+   __sg_page_iter_next(&(itr)->base)
 
 static inline void
 _sg_iter_init(struct scatterlist *sgl, struct sg_page_iter *iter,
@@ -441,11 +451,20 @@ _sg_iter_init(struct scatterlist *sgl, struct sg_page_
}
 }
 
-static inline dma_addr_t
-sg_page_iter_dma_address(struct sg_page_iter *spi)
-{
-   return (spi->sg->address + (spi->sg_pgoffset << PAGE_SHIFT));
-}
+/*
+ * sg_page_iter_dma_address() is implemented as a macro because it
+ * needs to accept two different and identical structure types. This
+ * allows both old and new code to co-exist. The compile time assert
+ * adds some safety, that the structure sizes match.
+ */
+#definesg_page_iter_dma_address(spi) ({\
+   struct sg_page_iter *__spi = (void *)(spi); \
+   dma_addr_t __dma_address;   \
+   CTASSERT(sizeof(*(spi)) == sizeof(*__spi)); \
+   __dma_address = __spi->sg->address +\
+   (__spi->sg_pgoffset << PAGE_SHIFT); \
+   __dma_address;  \
+})
 
 static inline struct page *
 sg_page_iter_page(struct sg_page_iter *piter)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361203 - stable/12/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:37:02 2020
New Revision: 361203
URL: https://svnweb.freebsd.org/changeset/base/361203

Log:
  MFC r360622:
  Implement more scatter and gather functions in the LinuxKPI.
  
  Differential Revision:https://reviews.freebsd.org/D24611
  Submitted by: ashafer_badland.io (Austin Shafer)
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/sys/compat/linuxkpi/common/include/linux/scatterlist.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/scatterlist.h
==
--- stable/12/sys/compat/linuxkpi/common/include/linux/scatterlist.hMon May 
18 09:36:14 2020(r361202)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/scatterlist.hMon May 
18 09:37:02 2020(r361203)
@@ -66,6 +66,10 @@ struct sg_page_iter {
} internal;
 };
 
+struct sg_dma_page_iter {
+   struct sg_page_iter base;
+};
+
 #defineSCATTERLIST_MAX_SEGMENT (-1U & ~(PAGE_SIZE - 1))
 
 #defineSG_MAX_SINGLE_ALLOC (PAGE_SIZE / sizeof(struct scatterlist))
@@ -85,6 +89,8 @@ struct sg_page_iter {
 #definefor_each_sg_page(sgl, iter, nents, pgoffset)
\
for (_sg_iter_init(sgl, iter, nents, pgoffset); \
 (iter)->sg; _sg_iter_next(iter))
+#definefor_each_sg_dma_page(sgl, iter, nents, pgoffset)
\
+   for_each_sg_page(sgl, &(iter)->base, nents, pgoffset)
 
 #definefor_each_sg(sglist, sg, sgmax, iter)
\
for (iter = 0, sg = (sglist); iter < (sgmax); iter++, sg = sg_next(sg))
@@ -404,6 +410,8 @@ sg_page_count(struct scatterlist *sg)
 {
return (PAGE_ALIGN(sg->offset + sg->length) >> PAGE_SHIFT);
 }
+#definesg_dma_page_count(sg) \
+   sg_page_count(sg)
 
 static inline bool
 __sg_page_iter_next(struct sg_page_iter *piter)
@@ -426,6 +434,8 @@ __sg_page_iter_next(struct sg_page_iter *piter)
}
return (1);
 }
+#define__sg_page_iter_dma_next(itr) \
+   __sg_page_iter_next(&(itr)->base)
 
 static inline void
 _sg_iter_init(struct scatterlist *sgl, struct sg_page_iter *iter,
@@ -443,11 +453,20 @@ _sg_iter_init(struct scatterlist *sgl, struct sg_page_
}
 }
 
-static inline dma_addr_t
-sg_page_iter_dma_address(struct sg_page_iter *spi)
-{
-   return (spi->sg->dma_address + (spi->sg_pgoffset << PAGE_SHIFT));
-}
+/*
+ * sg_page_iter_dma_address() is implemented as a macro because it
+ * needs to accept two different and identical structure types. This
+ * allows both old and new code to co-exist. The compile time assert
+ * adds some safety, that the structure sizes match.
+ */
+#definesg_page_iter_dma_address(spi) ({\
+   struct sg_page_iter *__spi = (void *)(spi); \
+   dma_addr_t __dma_address;   \
+   CTASSERT(sizeof(*(spi)) == sizeof(*__spi)); \
+   __dma_address = __spi->sg->dma_address +\
+   (__spi->sg_pgoffset << PAGE_SHIFT); \
+   __dma_address;  \
+})
 
 static inline struct page *
 sg_page_iter_page(struct sg_page_iter *piter)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361201 - stable/12/sys/compat/linuxkpi/common/src

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:35:42 2020
New Revision: 361201
URL: https://svnweb.freebsd.org/changeset/base/361201

Log:
  MFC r360621:
  Fix warning about sleeping with non-sleepable lock when allocating
  "current" from linux_cdev_pager_populate() in the LinuxKPI:
  
  Backtrace:
  witness_debugger()
  witness_warn()
  uma_zalloc_arg()
  malloc()
  linux_alloc_current()
  linux_cdev_pager_populate()
  vm_fault()
  vm_fault_trap()
  trap_pfault()
  trap()
  calltrap()
  
  Suggested by: avg@
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/sys/compat/linuxkpi/common/src/linux_compat.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linuxkpi/common/src/linux_compat.c
==
--- stable/12/sys/compat/linuxkpi/common/src/linux_compat.c Mon May 18 
09:34:41 2020(r361200)
+++ stable/12/sys/compat/linuxkpi/common/src/linux_compat.c Mon May 18 
09:35:42 2020(r361201)
@@ -528,14 +528,14 @@ linux_cdev_pager_populate(vm_object_t vm_obj, vm_pinde
struct vm_area_struct *vmap;
int err;
 
-   linux_set_current(curthread);
-
/* get VM area structure */
vmap = linux_cdev_handle_find(vm_obj->handle);
MPASS(vmap != NULL);
MPASS(vmap->vm_private_data == vm_obj->handle);
 
VM_OBJECT_WUNLOCK(vm_obj);
+
+   linux_set_current(curthread);
 
down_write(>vm_mm->mmap_sem);
if (unlikely(vmap->vm_ops == NULL)) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361202 - stable/11/sys/compat/linuxkpi/common/src

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:36:14 2020
New Revision: 361202
URL: https://svnweb.freebsd.org/changeset/base/361202

Log:
  MFC r360621:
  Fix warning about sleeping with non-sleepable lock when allocating
  "current" from linux_cdev_pager_populate() in the LinuxKPI:
  
  Backtrace:
  witness_debugger()
  witness_warn()
  uma_zalloc_arg()
  malloc()
  linux_alloc_current()
  linux_cdev_pager_populate()
  vm_fault()
  vm_fault_trap()
  trap_pfault()
  trap()
  calltrap()
  
  Suggested by: avg@
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/src/linux_compat.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/src/linux_compat.c
==
--- stable/11/sys/compat/linuxkpi/common/src/linux_compat.c Mon May 18 
09:35:42 2020(r361201)
+++ stable/11/sys/compat/linuxkpi/common/src/linux_compat.c Mon May 18 
09:36:14 2020(r361202)
@@ -528,14 +528,14 @@ linux_cdev_pager_populate(vm_object_t vm_obj, vm_pinde
struct vm_area_struct *vmap;
int err;
 
-   linux_set_current(curthread);
-
/* get VM area structure */
vmap = linux_cdev_handle_find(vm_obj->handle);
MPASS(vmap != NULL);
MPASS(vmap->vm_private_data == vm_obj->handle);
 
VM_OBJECT_WUNLOCK(vm_obj);
+
+   linux_set_current(curthread);
 
down_write(>vm_mm->mmap_sem);
if (unlikely(vmap->vm_ops == NULL)) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361200 - stable/11/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:34:41 2020
New Revision: 361200
URL: https://svnweb.freebsd.org/changeset/base/361200

Log:
  MFC r360532:
  Implement more PCI-express bandwidth functions in the LinuxKPI.
  
  Submitted by: ashafer_badland.io (Austin Shafer)
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/pci.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/pci.h
==
--- stable/11/sys/compat/linuxkpi/common/include/linux/pci.hMon May 18 
09:32:56 2020(r361199)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/pci.hMon May 18 
09:34:41 2020(r361200)
@@ -970,4 +970,45 @@ pcie_get_width_cap(struct pci_dev *dev)
return (PCIE_LNK_WIDTH_UNKNOWN);
 }
 
+static inline int
+pcie_get_mps(struct pci_dev *dev)
+{
+   return (pci_get_max_payload(dev->dev.bsddev));
+}
+
+static inline uint32_t
+PCIE_SPEED2MBS_ENC(enum pci_bus_speed spd)
+{
+
+   switch(spd) {
+   case PCIE_SPEED_16_0GT:
+   return (16000 * 128 / 130);
+   case PCIE_SPEED_8_0GT:
+   return (8000 * 128 / 130);
+   case PCIE_SPEED_5_0GT:
+   return (5000 * 8 / 10);
+   case PCIE_SPEED_2_5GT:
+   return (2500 * 8 / 10);
+   default:
+   return (0);
+   }
+}
+
+static inline uint32_t
+pcie_bandwidth_available(struct pci_dev *pdev,
+struct pci_dev **limiting,
+enum pci_bus_speed *speed,
+enum pcie_link_width *width)
+{
+   enum pci_bus_speed nspeed = pcie_get_speed_cap(pdev);
+   enum pcie_link_width nwidth = pcie_get_width_cap(pdev);
+
+   if (speed)
+   *speed = nspeed;
+   if (width)
+   *width = nwidth;
+
+   return (nwidth * PCIE_SPEED2MBS_ENC(nspeed));
+}
+
 #endif /* _LINUX_PCI_H_ */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361199 - stable/11/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:32:56 2020
New Revision: 361199
URL: https://svnweb.freebsd.org/changeset/base/361199

Log:
  MFC r345103:
  Implement more PCI speed related functions and macros in the LinuxKPI.
  
  Submitted by: Johannes Lundberg 
  Sponsored by: Limelight Networks
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/pci.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/pci.h
==
--- stable/11/sys/compat/linuxkpi/common/include/linux/pci.hMon May 18 
09:26:42 2020(r361198)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/pci.hMon May 18 
09:32:56 2020(r361199)
@@ -141,10 +141,13 @@ struct pci_device_id {
 #definePCI_EXP_TYPE_RC_EC  PCIEM_TYPE_ROOT_EC  /* Root 
Complex Event Collector */
 #definePCI_EXP_LNKCAP_SLS_2_5GB 0x01   /* Supported Link Speed 2.5GT/s 
*/
 #definePCI_EXP_LNKCAP_SLS_5_0GB 0x02   /* Supported Link Speed 5.0GT/s 
*/
+#definePCI_EXP_LNKCAP_SLS_8_0GB 0x04   /* Supported Link Speed 8.0GT/s 
*/
+#definePCI_EXP_LNKCAP_SLS_16_0GB 0x08  /* Supported Link Speed 
16.0GT/s */
 #definePCI_EXP_LNKCAP_MLW  0x03f0  /* Maximum Link Width */
 #definePCI_EXP_LNKCAP2_SLS_2_5GB 0x02  /* Supported Link Speed 2.5GT/s 
*/
 #definePCI_EXP_LNKCAP2_SLS_5_0GB 0x04  /* Supported Link Speed 5.0GT/s 
*/
 #definePCI_EXP_LNKCAP2_SLS_8_0GB 0x08  /* Supported Link Speed 8.0GT/s 
*/
+#definePCI_EXP_LNKCAP2_SLS_16_0GB 0x10 /* Supported Link Speed 
16.0GT/s */
 
 #define PCI_EXP_LNKCTL_HAWDPCIEM_LINK_CTL_HAWD
 #define PCI_EXP_LNKCAP_CLKPM   0x0004
@@ -159,10 +162,19 @@ enum pci_bus_speed {
PCIE_SPEED_2_5GT,
PCIE_SPEED_5_0GT,
PCIE_SPEED_8_0GT,
+   PCIE_SPEED_16_0GT,
 };
 
 enum pcie_link_width {
-   PCIE_LNK_WIDTH_UNKNOWN = 0xFF,
+   PCIE_LNK_WIDTH_RESRV= 0x00,
+   PCIE_LNK_X1 = 0x01,
+   PCIE_LNK_X2 = 0x02,
+   PCIE_LNK_X4 = 0x04,
+   PCIE_LNK_X8 = 0x08,
+   PCIE_LNK_X12= 0x0c,
+   PCIE_LNK_X16= 0x10,
+   PCIE_LNK_X32= 0x20,
+   PCIE_LNK_WIDTH_UNKNOWN  = 0xff,
 };
 
 typedef int pci_power_t;
@@ -895,6 +907,67 @@ static inline int
 pci_num_vf(struct pci_dev *dev)
 {
return (0);
+}
+
+static inline enum pci_bus_speed
+pcie_get_speed_cap(struct pci_dev *dev)
+{
+   device_t root;
+   uint32_t lnkcap, lnkcap2;
+   int error, pos;
+
+   root = device_get_parent(dev->dev.bsddev);
+   if (root == NULL)
+   return (PCI_SPEED_UNKNOWN);
+   root = device_get_parent(root);
+   if (root == NULL)
+   return (PCI_SPEED_UNKNOWN);
+   root = device_get_parent(root);
+   if (root == NULL)
+   return (PCI_SPEED_UNKNOWN);
+
+   if (pci_get_vendor(root) == PCI_VENDOR_ID_VIA ||
+   pci_get_vendor(root) == PCI_VENDOR_ID_SERVERWORKS)
+   return (PCI_SPEED_UNKNOWN);
+
+   if ((error = pci_find_cap(root, PCIY_EXPRESS, )) != 0)
+   return (PCI_SPEED_UNKNOWN);
+
+   lnkcap2 = pci_read_config(root, pos + PCIER_LINK_CAP2, 4);
+
+   if (lnkcap2) {  /* PCIe r3.0-compliant */
+   if (lnkcap2 & PCI_EXP_LNKCAP2_SLS_2_5GB)
+   return (PCIE_SPEED_2_5GT);
+   if (lnkcap2 & PCI_EXP_LNKCAP2_SLS_5_0GB)
+   return (PCIE_SPEED_5_0GT);
+   if (lnkcap2 & PCI_EXP_LNKCAP2_SLS_8_0GB)
+   return (PCIE_SPEED_8_0GT);
+   if (lnkcap2 & PCI_EXP_LNKCAP2_SLS_16_0GB)
+   return (PCIE_SPEED_16_0GT);
+   } else {/* pre-r3.0 */
+   lnkcap = pci_read_config(root, pos + PCIER_LINK_CAP, 4);
+   if (lnkcap & PCI_EXP_LNKCAP_SLS_2_5GB)
+   return (PCIE_SPEED_2_5GT);
+   if (lnkcap & PCI_EXP_LNKCAP_SLS_5_0GB)
+   return (PCIE_SPEED_5_0GT);
+   if (lnkcap & PCI_EXP_LNKCAP_SLS_8_0GB)
+   return (PCIE_SPEED_8_0GT);
+   if (lnkcap & PCI_EXP_LNKCAP_SLS_16_0GB)
+   return (PCIE_SPEED_16_0GT);
+   }
+   return (PCI_SPEED_UNKNOWN);
+}
+
+static inline enum pcie_link_width
+pcie_get_width_cap(struct pci_dev *dev)
+{
+   uint32_t lnkcap;
+
+   pcie_capability_read_dword(dev, PCI_EXP_LNKCAP, );
+   if (lnkcap)
+   return ((lnkcap & PCI_EXP_LNKCAP_MLW) >> 4);
+
+   return (PCIE_LNK_WIDTH_UNKNOWN);
 }
 
 #endif /* _LINUX_PCI_H_ */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361198 - stable/12/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:26:42 2020
New Revision: 361198
URL: https://svnweb.freebsd.org/changeset/base/361198

Log:
  MFC r360532:
  Implement more PCI-express bandwidth functions in the LinuxKPI.
  
  Submitted by: ashafer_badland.io (Austin Shafer)
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/sys/compat/linuxkpi/common/include/linux/pci.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/pci.h
==
--- stable/12/sys/compat/linuxkpi/common/include/linux/pci.hMon May 18 
09:25:55 2020(r361197)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/pci.hMon May 18 
09:26:42 2020(r361198)
@@ -954,6 +954,47 @@ pcie_get_width_cap(struct pci_dev *dev)
return (PCIE_LNK_WIDTH_UNKNOWN);
 }
 
+static inline int
+pcie_get_mps(struct pci_dev *dev)
+{
+   return (pci_get_max_payload(dev->dev.bsddev));
+}
+
+static inline uint32_t
+PCIE_SPEED2MBS_ENC(enum pci_bus_speed spd)
+{
+
+   switch(spd) {
+   case PCIE_SPEED_16_0GT:
+   return (16000 * 128 / 130);
+   case PCIE_SPEED_8_0GT:
+   return (8000 * 128 / 130);
+   case PCIE_SPEED_5_0GT:
+   return (5000 * 8 / 10);
+   case PCIE_SPEED_2_5GT:
+   return (2500 * 8 / 10);
+   default:
+   return (0);
+   }
+}
+
+static inline uint32_t
+pcie_bandwidth_available(struct pci_dev *pdev,
+struct pci_dev **limiting,
+enum pci_bus_speed *speed,
+enum pcie_link_width *width)
+{
+   enum pci_bus_speed nspeed = pcie_get_speed_cap(pdev);
+   enum pcie_link_width nwidth = pcie_get_width_cap(pdev);
+
+   if (speed)
+   *speed = nspeed;
+   if (width)
+   *width = nwidth;
+
+   return (nwidth * PCIE_SPEED2MBS_ENC(nspeed));
+}
+
 /*
  * The following functions can be used to attach/detach the LinuxKPI's
  * PCI device runtime. The pci_driver and pci_device_id pointer is
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361197 - stable/11/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:25:55 2020
New Revision: 361197
URL: https://svnweb.freebsd.org/changeset/base/361197

Log:
  MFC r360531:
  Implement mutex_lock_killable() in the LinuxKPI.
  
  Submitted by: ashafer_badland.io (Austin Shafer)
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/mutex.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/mutex.h
==
--- stable/11/sys/compat/linuxkpi/common/include/linux/mutex.h  Mon May 18 
09:25:23 2020(r361196)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/mutex.h  Mon May 18 
09:25:55 2020(r361197)
@@ -66,6 +66,18 @@ typedef struct mutex {
linux_mutex_lock_interruptible(_m); \
 })
 
+/*
+ * Reuse the interruptable method since the SX
+ * lock handles both signals and interrupts:
+ */
+#definemutex_lock_killable(_m) ({  \
+   MUTEX_SKIP() ? 0 :  \
+   linux_mutex_lock_interruptible(_m); \
+})
+
+#definemutex_lock_killable_nested(_m, _sub)\
+   mutex_lock_killable(_m)
+
 #definemutex_unlock(_m) do {   \
if (MUTEX_SKIP())   \
break;  \
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361196 - stable/12/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:25:23 2020
New Revision: 361196
URL: https://svnweb.freebsd.org/changeset/base/361196

Log:
  MFC r360531:
  Implement mutex_lock_killable() in the LinuxKPI.
  
  Submitted by: ashafer_badland.io (Austin Shafer)
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/sys/compat/linuxkpi/common/include/linux/mutex.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/mutex.h
==
--- stable/12/sys/compat/linuxkpi/common/include/linux/mutex.h  Mon May 18 
09:24:36 2020(r361195)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/mutex.h  Mon May 18 
09:25:23 2020(r361196)
@@ -66,6 +66,18 @@ typedef struct mutex {
linux_mutex_lock_interruptible(_m); \
 })
 
+/*
+ * Reuse the interruptable method since the SX
+ * lock handles both signals and interrupts:
+ */
+#definemutex_lock_killable(_m) ({  \
+   MUTEX_SKIP() ? 0 :  \
+   linux_mutex_lock_interruptible(_m); \
+})
+
+#definemutex_lock_killable_nested(_m, _sub)\
+   mutex_lock_killable(_m)
+
 #definemutex_unlock(_m) do {   \
if (MUTEX_SKIP())   \
break;  \
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361195 - stable/11/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:24:36 2020
New Revision: 361195
URL: https://svnweb.freebsd.org/changeset/base/361195

Log:
  MFC r360530:
  Implement DIV64_U64_ROUND_UP() in the LinuxKPI.
  
  Submitted by: ashafer_badland.io (Austin Shafer)
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/math64.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/math64.h
==
--- stable/11/sys/compat/linuxkpi/common/include/linux/math64.h Mon May 18 
09:24:05 2020(r361194)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/math64.h Mon May 18 
09:24:36 2020(r361195)
@@ -91,4 +91,13 @@ mul_u32_u32(uint32_t a, uint32_t b)
return ((uint64_t)a * b);
 }
 
+static inline uint64_t
+div64_u64_round_up(uint64_t dividend, uint64_t divisor)
+{
+   return ((dividend + divisor - 1) / divisor);
+}
+
+#defineDIV64_U64_ROUND_UP(...) \
+   div64_u64_round_up(__VA_ARGS__)
+
 #endif /* _LINUX_MATH64_H */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361194 - stable/12/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:24:05 2020
New Revision: 361194
URL: https://svnweb.freebsd.org/changeset/base/361194

Log:
  MFC r360530:
  Implement DIV64_U64_ROUND_UP() in the LinuxKPI.
  
  Submitted by: ashafer_badland.io (Austin Shafer)
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/sys/compat/linuxkpi/common/include/linux/math64.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/math64.h
==
--- stable/12/sys/compat/linuxkpi/common/include/linux/math64.h Mon May 18 
09:23:18 2020(r361193)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/math64.h Mon May 18 
09:24:05 2020(r361194)
@@ -91,4 +91,13 @@ mul_u32_u32(uint32_t a, uint32_t b)
return ((uint64_t)a * b);
 }
 
+static inline uint64_t
+div64_u64_round_up(uint64_t dividend, uint64_t divisor)
+{
+   return ((dividend + divisor - 1) / divisor);
+}
+
+#defineDIV64_U64_ROUND_UP(...) \
+   div64_u64_round_up(__VA_ARGS__)
+
 #endif /* _LINUX_MATH64_H */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361193 - stable/11/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:23:18 2020
New Revision: 361193
URL: https://svnweb.freebsd.org/changeset/base/361193

Log:
  MFC r360529:
  Implement more lockdep macros in the LinuxKPI.
  
  Submitted by: ashafer_badland.io (Austin Shafer)
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/lockdep.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/lockdep.h
==
--- stable/11/sys/compat/linuxkpi/common/include/linux/lockdep.hMon May 
18 09:22:47 2020(r361192)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/lockdep.hMon May 
18 09:23:18 2020(r361193)
@@ -36,6 +36,7 @@ struct lock_class_key {
 };
 
 #definelockdep_set_class(lock, key)
+#definelockdep_set_subclass(lock, sub)
 #definelockdep_set_class_and_name(lock, key, name)
 #definelockdep_set_current_reclaim_state(g) do { } while (0)
 #definelockdep_clear_current_reclaim_state() do { } while (0)
@@ -60,6 +61,7 @@ lockdep_is_held(void *__m)
__lock = __m;
return (LOCK_CLASS(__lock)->lc_owner(__lock, &__td) != 0);
 }
+#definelockdep_is_held_type(_m, _t) lockdep_is_held(_m)
 
 #else
 #definelockdep_assert_held(m) do { } while (0)
@@ -67,6 +69,7 @@ lockdep_is_held(void *__m)
 #definelockdep_assert_held_once(m) do { } while (0)
 
 #definelockdep_is_held(m)  1
+#definelockdep_is_held_type(_m, _t)1
 #endif
 
 #definemight_lock(m)   do { } while (0)
@@ -75,5 +78,8 @@ lockdep_is_held(void *__m)
 #definelock_acquire(...) do { } while (0)
 #definelock_release(...) do { } while (0)
 #definelock_acquire_shared_recursive(...) do { } while (0)
+
+#definemutex_acquire(...) do { } while (0)
+#definemutex_release(...) do { } while (0)
 
 #endif /* _LINUX_LOCKDEP_H_ */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361192 - stable/12/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:22:47 2020
New Revision: 361192
URL: https://svnweb.freebsd.org/changeset/base/361192

Log:
  MFC r360529:
  Implement more lockdep macros in the LinuxKPI.
  
  Submitted by: ashafer_badland.io (Austin Shafer)
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/sys/compat/linuxkpi/common/include/linux/lockdep.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/lockdep.h
==
--- stable/12/sys/compat/linuxkpi/common/include/linux/lockdep.hMon May 
18 09:22:17 2020(r361191)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/lockdep.hMon May 
18 09:22:47 2020(r361192)
@@ -36,6 +36,7 @@ struct lock_class_key {
 };
 
 #definelockdep_set_class(lock, key)
+#definelockdep_set_subclass(lock, sub)
 #definelockdep_set_class_and_name(lock, key, name)
 #definelockdep_set_current_reclaim_state(g) do { } while (0)
 #definelockdep_clear_current_reclaim_state() do { } while (0)
@@ -60,6 +61,7 @@ lockdep_is_held(void *__m)
__lock = __m;
return (LOCK_CLASS(__lock)->lc_owner(__lock, &__td) != 0);
 }
+#definelockdep_is_held_type(_m, _t) lockdep_is_held(_m)
 
 #else
 #definelockdep_assert_held(m) do { } while (0)
@@ -67,6 +69,7 @@ lockdep_is_held(void *__m)
 #definelockdep_assert_held_once(m) do { } while (0)
 
 #definelockdep_is_held(m)  1
+#definelockdep_is_held_type(_m, _t)1
 #endif
 
 #definemight_lock(m)   do { } while (0)
@@ -75,5 +78,8 @@ lockdep_is_held(void *__m)
 #definelock_acquire(...) do { } while (0)
 #definelock_release(...) do { } while (0)
 #definelock_acquire_shared_recursive(...) do { } while (0)
+
+#definemutex_acquire(...) do { } while (0)
+#definemutex_release(...) do { } while (0)
 
 #endif /* _LINUX_LOCKDEP_H_ */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361190 - stable/12/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:21:45 2020
New Revision: 361190
URL: https://svnweb.freebsd.org/changeset/base/361190

Log:
  MFC r351003:
  Fix build with DRM and INVARIANTS enabled.
  
  The DRM drivers use the lockdep assertion macros with spinlock_t locks
  which are backed by mutexes, not sx locks.  This causes compile
  failures since you can't use sx_assert with a mutex.  Instead, change
  the lockdep macros to use lock_class methods.  This works by assuming
  that each LinuxKPI locking primitive embeds a FreeBSD lock as its
  first structure and uses a cast to get to the underlying 'struct
  lock_object'.
  
  Reviewed by:  hselasky
  Differential Revision:https://reviews.freebsd.org/D20992

Modified:
  stable/12/sys/compat/linuxkpi/common/include/linux/lockdep.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/lockdep.h
==
--- stable/12/sys/compat/linuxkpi/common/include/linux/lockdep.hMon May 
18 09:17:38 2020(r361189)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/lockdep.hMon May 
18 09:21:45 2020(r361190)
@@ -40,13 +40,34 @@ struct lock_class_key {
 #definelockdep_set_current_reclaim_state(g) do { } while (0)
 #definelockdep_clear_current_reclaim_state() do { } while (0)
 
-#definelockdep_assert_held(m)  \
-   sx_assert(&(m)->sx, SA_XLOCKED)
+#ifdef INVARIANTS
+#definelockdep_assert_held(m) do { 
\
+   struct lock_object *__lock = (struct lock_object *)(m); \
+   LOCK_CLASS(__lock)->lc_assert(__lock, LA_LOCKED);   \
+} while (0)
 
-#definelockdep_assert_held_once(m) \
-   sx_assert(&(m)->sx, SA_XLOCKED | SA_NOTRECURSED)
+#definelockdep_assert_held_once(m) do {
\
+   struct lock_object *__lock = (struct lock_object *)(m); \
+   LOCK_CLASS(__lock)->lc_assert(__lock, LA_LOCKED | LA_NOTRECURSED); \
+} while (0)
 
-#definelockdep_is_held(m)  (sx_xholder(&(m)->sx) == curthread)
+static __inline bool
+lockdep_is_held(void *__m)
+{
+   struct lock_object *__lock;
+   struct thread *__td;
+
+   __lock = __m;
+   return (LOCK_CLASS(__lock)->lc_owner(__lock, &__td) != 0);
+}
+
+#else
+#definelockdep_assert_held(m) do { } while (0)
+
+#definelockdep_assert_held_once(m) do { } while (0)
+
+#definelockdep_is_held(m)  1
+#endif
 
 #definemight_lock(m)   do { } while (0)
 #definemight_lock_read(m) do { } while (0)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361191 - stable/11/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:22:17 2020
New Revision: 361191
URL: https://svnweb.freebsd.org/changeset/base/361191

Log:
  MFC r351003:
  Fix build with DRM and INVARIANTS enabled.
  
  The DRM drivers use the lockdep assertion macros with spinlock_t locks
  which are backed by mutexes, not sx locks.  This causes compile
  failures since you can't use sx_assert with a mutex.  Instead, change
  the lockdep macros to use lock_class methods.  This works by assuming
  that each LinuxKPI locking primitive embeds a FreeBSD lock as its
  first structure and uses a cast to get to the underlying 'struct
  lock_object'.
  
  Reviewed by:  hselasky
  Differential Revision:https://reviews.freebsd.org/D20992

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/lockdep.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/lockdep.h
==
--- stable/11/sys/compat/linuxkpi/common/include/linux/lockdep.hMon May 
18 09:21:45 2020(r361190)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/lockdep.hMon May 
18 09:22:17 2020(r361191)
@@ -40,13 +40,34 @@ struct lock_class_key {
 #definelockdep_set_current_reclaim_state(g) do { } while (0)
 #definelockdep_clear_current_reclaim_state() do { } while (0)
 
-#definelockdep_assert_held(m)  \
-   sx_assert(&(m)->sx, SA_XLOCKED)
+#ifdef INVARIANTS
+#definelockdep_assert_held(m) do { 
\
+   struct lock_object *__lock = (struct lock_object *)(m); \
+   LOCK_CLASS(__lock)->lc_assert(__lock, LA_LOCKED);   \
+} while (0)
 
-#definelockdep_assert_held_once(m) \
-   sx_assert(&(m)->sx, SA_XLOCKED | SA_NOTRECURSED)
+#definelockdep_assert_held_once(m) do {
\
+   struct lock_object *__lock = (struct lock_object *)(m); \
+   LOCK_CLASS(__lock)->lc_assert(__lock, LA_LOCKED | LA_NOTRECURSED); \
+} while (0)
 
-#definelockdep_is_held(m)  (sx_xholder(&(m)->sx) == curthread)
+static __inline bool
+lockdep_is_held(void *__m)
+{
+   struct lock_object *__lock;
+   struct thread *__td;
+
+   __lock = __m;
+   return (LOCK_CLASS(__lock)->lc_owner(__lock, &__td) != 0);
+}
+
+#else
+#definelockdep_assert_held(m) do { } while (0)
+
+#definelockdep_assert_held_once(m) do { } while (0)
+
+#definelockdep_is_held(m)  1
+#endif
 
 #definemight_lock(m)   do { } while (0)
 #definemight_lock_read(m) do { } while (0)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361189 - stable/11/usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:17:38 2020
New Revision: 361189
URL: https://svnweb.freebsd.org/changeset/base/361189

Log:
  MFC r360329:
  Properly update AD field length in hccontrol(8).
  
  While at it use strtol() instead of atoi() to support hexadecimal
  numbers aswell as 10-base numbers.
  
  Submitted by: Marc Veldman 
  PR:   245899
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/usr.sbin/bluetooth/hccontrol/le.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/bluetooth/hccontrol/le.c
==
--- stable/11/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 09:17:05 2020
(r361188)
+++ stable/11/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 09:17:38 2020
(r361189)
@@ -172,13 +172,13 @@ parse_param(int argc, char *argv[], char *buf, int *le
goto done;
curbuf[0] = 2;
curbuf[1] = 1;
-   curbuf[2] = atoi(optarg);
+   curbuf[2] = (uint8_t)strtol(optarg, NULL, 16);
curbuf += 3;
break;
case 'u':
-   lenpos = buf;
if ((buf+2) >= buflast)
goto done;
+   lenpos = curbuf;
curbuf[1] = 2;
*lenpos = 1;
curbuf += 2;
@@ -189,6 +189,7 @@ parse_param(int argc, char *argv[], char *buf, int *le
curbuf[0] = value &0xff;
curbuf[1] = (value>>8)&0xff;
curbuf += 2;
+   *lenpos += 2;
}

}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361188 - stable/12/usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:17:05 2020
New Revision: 361188
URL: https://svnweb.freebsd.org/changeset/base/361188

Log:
  MFC r360329:
  Properly update AD field length in hccontrol(8).
  
  While at it use strtol() instead of atoi() to support hexadecimal
  numbers aswell as 10-base numbers.
  
  Submitted by: Marc Veldman 
  PR:   245899
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/usr.sbin/bluetooth/hccontrol/le.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/bluetooth/hccontrol/le.c
==
--- stable/12/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 09:16:17 2020
(r361187)
+++ stable/12/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 09:17:05 2020
(r361188)
@@ -172,13 +172,13 @@ parse_param(int argc, char *argv[], char *buf, int *le
goto done;
curbuf[0] = 2;
curbuf[1] = 1;
-   curbuf[2] = atoi(optarg);
+   curbuf[2] = (uint8_t)strtol(optarg, NULL, 16);
curbuf += 3;
break;
case 'u':
-   lenpos = buf;
if ((buf+2) >= buflast)
goto done;
+   lenpos = curbuf;
curbuf[1] = 2;
*lenpos = 1;
curbuf += 2;
@@ -189,6 +189,7 @@ parse_param(int argc, char *argv[], char *buf, int *le
curbuf[0] = value &0xff;
curbuf[1] = (value>>8)&0xff;
curbuf += 2;
+   *lenpos += 2;
}

}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361186 - stable/12/usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:15:45 2020
New Revision: 361186
URL: https://svnweb.freebsd.org/changeset/base/361186

Log:
  MFC r360288:
  Put advertising data in correct place.
  
  Submitted by: Marc Veldman 
  PR:   245848
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/usr.sbin/bluetooth/hccontrol/le.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/bluetooth/hccontrol/le.c
==
--- stable/12/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 09:14:58 2020
(r361185)
+++ stable/12/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 09:15:45 2020
(r361186)
@@ -491,6 +491,7 @@ le_set_advertising_data(int s, int argc, char *argv[])
parse_param(argc, argv, buf, );
memset(cp.advertising_data, 0, sizeof(cp.advertising_data));
cp.advertising_data_length = len;
+   memcpy(cp.advertising_data, buf, len);
 
if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE,
NG_HCI_OCF_LE_SET_ADVERTISING_DATA), 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361187 - stable/11/usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:16:17 2020
New Revision: 361187
URL: https://svnweb.freebsd.org/changeset/base/361187

Log:
  MFC r360288:
  Put advertising data in correct place.
  
  Submitted by: Marc Veldman 
  PR:   245848
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/usr.sbin/bluetooth/hccontrol/le.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/bluetooth/hccontrol/le.c
==
--- stable/11/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 09:15:45 2020
(r361186)
+++ stable/11/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 09:16:17 2020
(r361187)
@@ -491,6 +491,7 @@ le_set_advertising_data(int s, int argc, char *argv[])
parse_param(argc, argv, buf, );
memset(cp.advertising_data, 0, sizeof(cp.advertising_data));
cp.advertising_data_length = len;
+   memcpy(cp.advertising_data, buf, len);
 
if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE,
NG_HCI_OCF_LE_SET_ADVERTISING_DATA), 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361185 - stable/11/usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:14:58 2020
New Revision: 361185
URL: https://svnweb.freebsd.org/changeset/base/361185

Log:
  MFC r360263:
  Rename two commands to match the Bluetooth specification in hccontrol(8).
  Fix some bad spelling while at it.
  
  Submitted by: Marc Veldman 
  PR:   245868
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c
==
--- stable/11/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c   Mon May 
18 09:14:24 2020(r361184)
+++ stable/11/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c   Mon May 
18 09:14:58 2020(r361185)
@@ -1491,7 +1491,7 @@ hci_write_page_scan_mode(int s, int argc, char **argv)
 } /* hci_write_page_scan_mode */
 
 static int
-hci_read_le_host_supported_command(int s, int argc, char **argv) 
+hci_read_le_host_support(int s, int argc, char **argv) 
 {
ng_hci_read_le_host_supported_rp rp;
int n;
@@ -1508,13 +1508,13 @@ hci_read_le_host_supported_command(int s, int argc, ch
}
 
fprintf(stdout, "LE Host support: %#02x\n", rp.le_supported_host);
-   fprintf(stdout, "Simulateneouse LE Host : %#02x\n", 
rp.simultaneous_le_host);
+   fprintf(stdout, "Simultaneous LE Host : %#02x\n", 
rp.simultaneous_le_host);
 
return (OK);

 }
 static int
-hci_write_le_host_supported_command(int s, int argc, char **argv) 
+hci_write_le_host_support(int s, int argc, char **argv) 
 {
ng_hci_write_le_host_supported_cp cp;
ng_hci_write_le_host_supported_rp rp;
@@ -1948,14 +1948,14 @@ struct hci_command  
host_controller_baseband_commands[]
 _write_page_scan_mode
 },
 {
-"read_le_host_supported_command",  \
-"Read if this host is in le supported mode and stimulatenouse le supported 
mode",
-_read_le_host_supported_command,
+"read_le_host_support",\
+"Read if this host is in LE supported mode and simultaneous LE supported mode",
+_read_le_host_support,
 },  
 {
-"write_le_host_supported_command", \
-"write_le_host_supported_command le_host[0|1] stimultajeous_le[0|1]",
-_write_le_host_supported_command,
+"write_le_host_support",   \
+"write_le_host_support le_host[0|1] simultaneous_le[0|1]",
+_write_le_host_support,
 },  
 
 { NULL, }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361184 - stable/12/usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:14:24 2020
New Revision: 361184
URL: https://svnweb.freebsd.org/changeset/base/361184

Log:
  MFC r360263:
  Rename two commands to match the Bluetooth specification in hccontrol(8).
  Fix some bad spelling while at it.
  
  Submitted by: Marc Veldman 
  PR:   245868
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c
==
--- stable/12/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c   Mon May 
18 09:13:34 2020(r361183)
+++ stable/12/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c   Mon May 
18 09:14:24 2020(r361184)
@@ -1491,7 +1491,7 @@ hci_write_page_scan_mode(int s, int argc, char **argv)
 } /* hci_write_page_scan_mode */
 
 static int
-hci_read_le_host_supported_command(int s, int argc, char **argv) 
+hci_read_le_host_support(int s, int argc, char **argv) 
 {
ng_hci_read_le_host_supported_rp rp;
int n;
@@ -1508,13 +1508,13 @@ hci_read_le_host_supported_command(int s, int argc, ch
}
 
fprintf(stdout, "LE Host support: %#02x\n", rp.le_supported_host);
-   fprintf(stdout, "Simulateneouse LE Host : %#02x\n", 
rp.simultaneous_le_host);
+   fprintf(stdout, "Simultaneous LE Host : %#02x\n", 
rp.simultaneous_le_host);
 
return (OK);

 }
 static int
-hci_write_le_host_supported_command(int s, int argc, char **argv) 
+hci_write_le_host_support(int s, int argc, char **argv) 
 {
ng_hci_write_le_host_supported_cp cp;
ng_hci_write_le_host_supported_rp rp;
@@ -1948,14 +1948,14 @@ struct hci_command  
host_controller_baseband_commands[]
 _write_page_scan_mode
 },
 {
-"read_le_host_supported_command",  \
-"Read if this host is in le supported mode and stimulatenouse le supported 
mode",
-_read_le_host_supported_command,
+"read_le_host_support",\
+"Read if this host is in LE supported mode and simultaneous LE supported mode",
+_read_le_host_support,
 },  
 {
-"write_le_host_supported_command", \
-"write_le_host_supported_command le_host[0|1] stimultajeous_le[0|1]",
-_write_le_host_supported_command,
+"write_le_host_support",   \
+"write_le_host_support le_host[0|1] simultaneous_le[0|1]",
+_write_le_host_support,
 },  
 
 { NULL, }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361183 - stable/11/usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:13:34 2020
New Revision: 361183
URL: https://svnweb.freebsd.org/changeset/base/361183

Log:
  MFC r360243:
  Add support for LE advertising to hccontrol(8).
  
  Submitted by: Marc Veldman 
  PR:   245848
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/usr.sbin/bluetooth/hccontrol/hccontrol.8
  stable/11/usr.sbin/bluetooth/hccontrol/le.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/bluetooth/hccontrol/hccontrol.8
==
--- stable/11/usr.sbin/bluetooth/hccontrol/hccontrol.8  Mon May 18 09:13:03 
2020(r361182)
+++ stable/11/usr.sbin/bluetooth/hccontrol/hccontrol.8  Mon May 18 09:13:34 
2020(r361183)
@@ -25,7 +25,7 @@
 .\" $Id: hccontrol.8,v 1.6 2003/08/06 21:26:38 max Exp $
 .\" $FreeBSD$
 .\"
-.Dd February 7, 2015
+.Dd April 24, 2020
 .Dt HCCONTROL 8
 .Os
 .Sh NAME
@@ -133,6 +133,8 @@ are:
 .It Cm Write_Page_Scan_Period_Mode
 .It Cm Read_Page_Scan_Mode
 .It Cm Write_Page_Scan_Mode
+.It Cm Read_LE_Host_Support
+.It Cm Write_LE_Host_Support
 .It Cm Read_Local_Version_Information
 .It Cm Read_Local_Supported_Commands
 .It Cm Read_Local_Supported_Features
@@ -143,6 +145,15 @@ are:
 .It Cm Reset_Failed_Contact_Counter
 .It Cm Get_Link_Quality
 .It Cm Read_RSSI
+.It Cm LE_Read_Local_Supported_Features
+.It Cm LE_Set_Advertising_Parameters 
+.It Cm LE_Read_Advertising_Physical_Channel_Tx_Power 
+.It Cm LE_Set_Advertising_Data
+.It Cm LE_Set_Scan_Response_Data
+.It Cm LE_Set_Advertising_Enable
+.It Cm LE_Set_Scan_Parameters
+.It Cm LE_Set_Scan_Enable
+.It Cm LE_Read_Supported_States
 .El
 .Pp
 The currently supported node commands in
@@ -170,6 +181,18 @@ are:
 .It Cm Write_Node_Role_Switch
 .It Cm Read_Node_List
 .El
+.Sh EXAMPLES
+Make the blutooth LE host, ubt0hci, scannable through
+.Xr hccontrol 8 commands:
+.Pp
+.Bd -literal -offset indent
+hccontrol -n ubt0hci le_set_advertising_enable disable
+hccontrol -n ubt0hci le_set_advertising_param
+hccontrol -n ubt0hci le_read_advertising_channel_tx_power
+hccontrol -n ubt0hci le_set_advertising_data
+hccontrol -n ubt0hci le_set_scan_response -n FBSD_Host
+hccontrol -n ubt0hci le_set_advertising_enable enable
+.Ed
 .Sh EXIT STATUS
 .Ex -std
 .Sh SEE ALSO

Modified: stable/11/usr.sbin/bluetooth/hccontrol/le.c
==
--- stable/11/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 09:13:03 2020
(r361182)
+++ stable/11/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 09:13:34 2020
(r361183)
@@ -57,6 +57,9 @@ static int le_read_local_supported_features(int s, int
 static int set_le_event_mask(int s, uint64_t mask);
 static int set_event_mask(int s, uint64_t mask);
 static int le_enable(int s, int argc, char *argv[]);
+static int le_set_advertising_enable(int s, int argc, char *argv[]);
+static int le_set_advertising_param(int s, int argc, char *argv[]);
+static int le_read_advertising_channel_tx_power(int s, int argc, char *argv[]);
 
 static int
 le_set_scan_param(int s, int argc, char *argv[])
@@ -339,6 +342,170 @@ int le_enable(int s, int argc, char *argv[])
return OK;
 }
 
+static int
+le_set_advertising_enable(int s, int argc, char *argv[])
+{
+   ng_hci_le_set_advertise_enable_cp cp;
+   ng_hci_le_set_advertise_enable_rp rp;
+   int n, enable = 0;
+
+   if (argc != 1)
+   return USAGE;
+ 
+   if (strcmp(argv[0], "enable") == 0)
+   enable = 1;
+   else if (strcmp(argv[0], "disable") != 0)
+   return USAGE;
+
+   n = sizeof(rp);
+   cp.advertising_enable = enable;
+   if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE,
+   NG_HCI_OCF_LE_SET_ADVERTISE_ENABLE), 
+   (void *), sizeof(cp), (void *), ) == ERROR)
+   return (ERROR);
+   
+   if (rp.status != 0x00) {
+   fprintf(stdout, "Status: %s [%#02x]\n", 
+   hci_status2str(rp.status), rp.status);
+   return (FAILED);
+   }
+fprintf(stdout, "LE Advertising %s\n", (enable ? "enabled" : 
"disabled"));
+
+   return (OK);
+}
+
+static int
+le_set_advertising_param(int s, int argc, char *argv[])
+{
+   ng_hci_le_set_advertising_parameters_cp cp;
+   ng_hci_le_set_advertising_parameters_rp rp;
+
+   int n, ch;
+
+   cp.advertising_interval_min = 0x800;
+   cp.advertising_interval_max = 0x800;
+   cp.advertising_type = 0;
+   cp.own_address_type = 0;
+   cp.direct_address_type = 0;
+
+   cp.advertising_channel_map = 7;
+   cp.advertising_filter_policy = 0;
+
+   optreset = 1;
+   optind = 0;
+   while ((ch = getopt(argc, argv , "m:M:t:o:p:a:c:f:")) != -1) {
+   switch(ch) {
+   case 'm':
+   cp.advertising_interval_min =
+   

svn commit: r361182 - stable/12/usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:13:03 2020
New Revision: 361182
URL: https://svnweb.freebsd.org/changeset/base/361182

Log:
  MFC r360243:
  Add support for LE advertising to hccontrol(8).
  
  Submitted by: Marc Veldman 
  PR:   245848
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/usr.sbin/bluetooth/hccontrol/hccontrol.8
  stable/12/usr.sbin/bluetooth/hccontrol/le.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/bluetooth/hccontrol/hccontrol.8
==
--- stable/12/usr.sbin/bluetooth/hccontrol/hccontrol.8  Mon May 18 09:12:13 
2020(r361181)
+++ stable/12/usr.sbin/bluetooth/hccontrol/hccontrol.8  Mon May 18 09:13:03 
2020(r361182)
@@ -25,7 +25,7 @@
 .\" $Id: hccontrol.8,v 1.6 2003/08/06 21:26:38 max Exp $
 .\" $FreeBSD$
 .\"
-.Dd February 7, 2015
+.Dd April 24, 2020
 .Dt HCCONTROL 8
 .Os
 .Sh NAME
@@ -133,6 +133,8 @@ are:
 .It Cm Write_Page_Scan_Period_Mode
 .It Cm Read_Page_Scan_Mode
 .It Cm Write_Page_Scan_Mode
+.It Cm Read_LE_Host_Support
+.It Cm Write_LE_Host_Support
 .It Cm Read_Local_Version_Information
 .It Cm Read_Local_Supported_Commands
 .It Cm Read_Local_Supported_Features
@@ -143,6 +145,15 @@ are:
 .It Cm Reset_Failed_Contact_Counter
 .It Cm Get_Link_Quality
 .It Cm Read_RSSI
+.It Cm LE_Read_Local_Supported_Features
+.It Cm LE_Set_Advertising_Parameters 
+.It Cm LE_Read_Advertising_Physical_Channel_Tx_Power 
+.It Cm LE_Set_Advertising_Data
+.It Cm LE_Set_Scan_Response_Data
+.It Cm LE_Set_Advertising_Enable
+.It Cm LE_Set_Scan_Parameters
+.It Cm LE_Set_Scan_Enable
+.It Cm LE_Read_Supported_States
 .El
 .Pp
 The currently supported node commands in
@@ -170,6 +181,18 @@ are:
 .It Cm Write_Node_Role_Switch
 .It Cm Read_Node_List
 .El
+.Sh EXAMPLES
+Make the blutooth LE host, ubt0hci, scannable through
+.Xr hccontrol 8 commands:
+.Pp
+.Bd -literal -offset indent
+hccontrol -n ubt0hci le_set_advertising_enable disable
+hccontrol -n ubt0hci le_set_advertising_param
+hccontrol -n ubt0hci le_read_advertising_channel_tx_power
+hccontrol -n ubt0hci le_set_advertising_data
+hccontrol -n ubt0hci le_set_scan_response -n FBSD_Host
+hccontrol -n ubt0hci le_set_advertising_enable enable
+.Ed
 .Sh EXIT STATUS
 .Ex -std
 .Sh SEE ALSO

Modified: stable/12/usr.sbin/bluetooth/hccontrol/le.c
==
--- stable/12/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 09:12:13 2020
(r361181)
+++ stable/12/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 09:13:03 2020
(r361182)
@@ -57,6 +57,9 @@ static int le_read_local_supported_features(int s, int
 static int set_le_event_mask(int s, uint64_t mask);
 static int set_event_mask(int s, uint64_t mask);
 static int le_enable(int s, int argc, char *argv[]);
+static int le_set_advertising_enable(int s, int argc, char *argv[]);
+static int le_set_advertising_param(int s, int argc, char *argv[]);
+static int le_read_advertising_channel_tx_power(int s, int argc, char *argv[]);
 
 static int
 le_set_scan_param(int s, int argc, char *argv[])
@@ -339,6 +342,170 @@ int le_enable(int s, int argc, char *argv[])
return OK;
 }
 
+static int
+le_set_advertising_enable(int s, int argc, char *argv[])
+{
+   ng_hci_le_set_advertise_enable_cp cp;
+   ng_hci_le_set_advertise_enable_rp rp;
+   int n, enable = 0;
+
+   if (argc != 1)
+   return USAGE;
+ 
+   if (strcmp(argv[0], "enable") == 0)
+   enable = 1;
+   else if (strcmp(argv[0], "disable") != 0)
+   return USAGE;
+
+   n = sizeof(rp);
+   cp.advertising_enable = enable;
+   if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE,
+   NG_HCI_OCF_LE_SET_ADVERTISE_ENABLE), 
+   (void *), sizeof(cp), (void *), ) == ERROR)
+   return (ERROR);
+   
+   if (rp.status != 0x00) {
+   fprintf(stdout, "Status: %s [%#02x]\n", 
+   hci_status2str(rp.status), rp.status);
+   return (FAILED);
+   }
+fprintf(stdout, "LE Advertising %s\n", (enable ? "enabled" : 
"disabled"));
+
+   return (OK);
+}
+
+static int
+le_set_advertising_param(int s, int argc, char *argv[])
+{
+   ng_hci_le_set_advertising_parameters_cp cp;
+   ng_hci_le_set_advertising_parameters_rp rp;
+
+   int n, ch;
+
+   cp.advertising_interval_min = 0x800;
+   cp.advertising_interval_max = 0x800;
+   cp.advertising_type = 0;
+   cp.own_address_type = 0;
+   cp.direct_address_type = 0;
+
+   cp.advertising_channel_map = 7;
+   cp.advertising_filter_policy = 0;
+
+   optreset = 1;
+   optind = 0;
+   while ((ch = getopt(argc, argv , "m:M:t:o:p:a:c:f:")) != -1) {
+   switch(ch) {
+   case 'm':
+   cp.advertising_interval_min =
+   

svn commit: r361181 - stable/11/sys/compat/linuxkpi/common/include/asm

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:12:13 2020
New Revision: 361181
URL: https://svnweb.freebsd.org/changeset/base/361181

Log:
  MFC r360127:
  Implement the atomic fetch add unless functions for the LinuxKPI.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/include/asm/atomic-long.h
  stable/11/sys/compat/linuxkpi/common/include/asm/atomic.h
  stable/11/sys/compat/linuxkpi/common/include/asm/atomic64.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/asm/atomic-long.h
==
--- stable/11/sys/compat/linuxkpi/common/include/asm/atomic-long.h  Mon May 
18 09:11:41 2020(r361180)
+++ stable/11/sys/compat/linuxkpi/common/include/asm/atomic-long.h  Mon May 
18 09:12:13 2020(r361181)
@@ -118,6 +118,20 @@ atomic_long_add_unless(atomic_long_t *v, long a, long 
 }
 
 static inline long
+atomic_long_fetch_add_unless(atomic_long_t *v, long a, long u)
+{
+   long c = atomic_long_read(v);
+
+   for (;;) {
+   if (unlikely(c == u))
+   break;
+   if (likely(atomic_fcmpset_long(>counter, , c + a)))
+   break;
+   }
+   return (c);
+}
+
+static inline long
 atomic_long_dec_and_test(atomic_long_t *v)
 {
long i = atomic_long_add(-1, v);

Modified: stable/11/sys/compat/linuxkpi/common/include/asm/atomic.h
==
--- stable/11/sys/compat/linuxkpi/common/include/asm/atomic.h   Mon May 18 
09:11:41 2020(r361180)
+++ stable/11/sys/compat/linuxkpi/common/include/asm/atomic.h   Mon May 18 
09:12:13 2020(r361181)
@@ -119,6 +119,20 @@ atomic_add_unless(atomic_t *v, int a, int u)
return (c != u);
 }
 
+static inline int
+atomic_fetch_add_unless(atomic_t *v, int a, int u)
+{
+   int c = atomic_read(v);
+
+   for (;;) {
+   if (unlikely(c == u))
+   break;
+   if (likely(atomic_fcmpset_int(>counter, , c + a)))
+   break;
+   }
+   return (c);
+}
+
 static inline void
 atomic_clear_mask(unsigned int mask, atomic_t *v)
 {

Modified: stable/11/sys/compat/linuxkpi/common/include/asm/atomic64.h
==
--- stable/11/sys/compat/linuxkpi/common/include/asm/atomic64.h Mon May 18 
09:11:41 2020(r361180)
+++ stable/11/sys/compat/linuxkpi/common/include/asm/atomic64.h Mon May 18 
09:12:13 2020(r361181)
@@ -104,6 +104,20 @@ atomic64_add_unless(atomic64_t *v, int64_t a, int64_t 
 }
 
 static inline int64_t
+atomic64_fetch_add_unless(atomic64_t *v, int64_t a, int64_t u)
+{
+   int64_t c = atomic64_read(v);
+
+   for (;;) {
+   if (unlikely(c == u))
+   break;
+   if (likely(atomic_fcmpset_64(>counter, , c + a)))
+   break;
+   }
+   return (c);
+}
+
+static inline int64_t
 atomic64_xchg(atomic64_t *v, int64_t i)
 {
 #if defined(__i386__) || defined(__amd64__) || \
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361180 - stable/12/sys/compat/linuxkpi/common/include/asm

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:11:41 2020
New Revision: 361180
URL: https://svnweb.freebsd.org/changeset/base/361180

Log:
  MFC r360127:
  Implement the atomic fetch add unless functions for the LinuxKPI.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/sys/compat/linuxkpi/common/include/asm/atomic-long.h
  stable/12/sys/compat/linuxkpi/common/include/asm/atomic.h
  stable/12/sys/compat/linuxkpi/common/include/asm/atomic64.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linuxkpi/common/include/asm/atomic-long.h
==
--- stable/12/sys/compat/linuxkpi/common/include/asm/atomic-long.h  Mon May 
18 09:10:52 2020(r361179)
+++ stable/12/sys/compat/linuxkpi/common/include/asm/atomic-long.h  Mon May 
18 09:11:41 2020(r361180)
@@ -119,6 +119,20 @@ atomic_long_add_unless(atomic_long_t *v, long a, long 
 }
 
 static inline long
+atomic_long_fetch_add_unless(atomic_long_t *v, long a, long u)
+{
+   long c = atomic_long_read(v);
+
+   for (;;) {
+   if (unlikely(c == u))
+   break;
+   if (likely(atomic_fcmpset_long(>counter, , c + a)))
+   break;
+   }
+   return (c);
+}
+
+static inline long
 atomic_long_dec_and_test(atomic_long_t *v)
 {
long i = atomic_long_add(-1, v);

Modified: stable/12/sys/compat/linuxkpi/common/include/asm/atomic.h
==
--- stable/12/sys/compat/linuxkpi/common/include/asm/atomic.h   Mon May 18 
09:10:52 2020(r361179)
+++ stable/12/sys/compat/linuxkpi/common/include/asm/atomic.h   Mon May 18 
09:11:41 2020(r361180)
@@ -119,6 +119,20 @@ atomic_add_unless(atomic_t *v, int a, int u)
return (c != u);
 }
 
+static inline int
+atomic_fetch_add_unless(atomic_t *v, int a, int u)
+{
+   int c = atomic_read(v);
+
+   for (;;) {
+   if (unlikely(c == u))
+   break;
+   if (likely(atomic_fcmpset_int(>counter, , c + a)))
+   break;
+   }
+   return (c);
+}
+
 static inline void
 atomic_clear_mask(unsigned int mask, atomic_t *v)
 {

Modified: stable/12/sys/compat/linuxkpi/common/include/asm/atomic64.h
==
--- stable/12/sys/compat/linuxkpi/common/include/asm/atomic64.h Mon May 18 
09:10:52 2020(r361179)
+++ stable/12/sys/compat/linuxkpi/common/include/asm/atomic64.h Mon May 18 
09:11:41 2020(r361180)
@@ -104,6 +104,20 @@ atomic64_add_unless(atomic64_t *v, int64_t a, int64_t 
 }
 
 static inline int64_t
+atomic64_fetch_add_unless(atomic64_t *v, int64_t a, int64_t u)
+{
+   int64_t c = atomic64_read(v);
+
+   for (;;) {
+   if (unlikely(c == u))
+   break;
+   if (likely(atomic_fcmpset_64(>counter, , c + a)))
+   break;
+   }
+   return (c);
+}
+
+static inline int64_t
 atomic64_xchg(atomic64_t *v, int64_t i)
 {
 #if !((defined(__mips__) && !(defined(__mips_n32) || defined(__mips_n64))) || \
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361179 - stable/11/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:10:52 2020
New Revision: 361179
URL: https://svnweb.freebsd.org/changeset/base/361179

Log:
  MFC r360119:
  Implement aligned LinuxKPI types for u16, u32 and u64.
  Makes a difference for 32-bit platforms mostly.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/types.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/types.h
==
--- stable/11/sys/compat/linuxkpi/common/include/linux/types.h  Mon May 18 
09:10:21 2020(r361178)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/types.h  Mon May 18 
09:10:52 2020(r361179)
@@ -53,6 +53,10 @@ typedef uint32_t __be32;
 typedef uint64_t __le64;
 typedef uint64_t __be64;
 
+typedef uint16_t __aligned_u16 __aligned(sizeof(uint16_t));
+typedef uint32_t __aligned_u32 __aligned(sizeof(uint32_t));
+typedef uint64_t __aligned_u64 __aligned(sizeof(uint64_t));
+
 typedef unsigned short ushort;
 typedef unsigned intuint;
 typedef unsigned long ulong;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361178 - stable/12/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:10:21 2020
New Revision: 361178
URL: https://svnweb.freebsd.org/changeset/base/361178

Log:
  MFC r360119:
  Implement aligned LinuxKPI types for u16, u32 and u64.
  Makes a difference for 32-bit platforms mostly.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/sys/compat/linuxkpi/common/include/linux/types.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/types.h
==
--- stable/12/sys/compat/linuxkpi/common/include/linux/types.h  Mon May 18 
09:09:34 2020(r361177)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/types.h  Mon May 18 
09:10:21 2020(r361178)
@@ -53,6 +53,10 @@ typedef uint32_t __be32;
 typedef uint64_t __le64;
 typedef uint64_t __be64;
 
+typedef uint16_t __aligned_u16 __aligned(sizeof(uint16_t));
+typedef uint32_t __aligned_u32 __aligned(sizeof(uint32_t));
+typedef uint64_t __aligned_u64 __aligned(sizeof(uint64_t));
+
 typedef unsigned short ushort;
 typedef unsigned intuint;
 typedef unsigned long ulong;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361177 - stable/11/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:09:34 2020
New Revision: 361177
URL: https://svnweb.freebsd.org/changeset/base/361177

Log:
  MFC r360118:
  Allow test_bit() in the LinuxKPI to accept a const pointer.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/bitops.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/bitops.h
==
--- stable/11/sys/compat/linuxkpi/common/include/linux/bitops.h Mon May 18 
09:09:03 2020(r361176)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/bitops.h Mon May 18 
09:09:34 2020(r361177)
@@ -273,7 +273,7 @@ find_next_zero_bit(const unsigned long *addr, unsigned
 atomic_clear_long(&((volatile unsigned long *)(a))[BIT_WORD(i)], 
BIT_MASK(i))
 
 #definetest_bit(i, a)  
\
-!!(READ_ONCE(((volatile unsigned long *)(a))[BIT_WORD(i)]) & BIT_MASK(i))
+!!(READ_ONCE(((volatile const unsigned long *)(a))[BIT_WORD(i)]) & 
BIT_MASK(i))
 
 static inline int
 test_and_clear_bit(long bit, volatile unsigned long *var)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361176 - stable/12/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:09:03 2020
New Revision: 361176
URL: https://svnweb.freebsd.org/changeset/base/361176

Log:
  MFC r360118:
  Allow test_bit() in the LinuxKPI to accept a const pointer.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/sys/compat/linuxkpi/common/include/linux/bitops.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/bitops.h
==
--- stable/12/sys/compat/linuxkpi/common/include/linux/bitops.h Mon May 18 
09:07:51 2020(r361175)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/bitops.h Mon May 18 
09:09:03 2020(r361176)
@@ -273,7 +273,7 @@ find_next_zero_bit(const unsigned long *addr, unsigned
 atomic_clear_long(&((volatile unsigned long *)(a))[BIT_WORD(i)], 
BIT_MASK(i))
 
 #definetest_bit(i, a)  
\
-!!(READ_ONCE(((volatile unsigned long *)(a))[BIT_WORD(i)]) & BIT_MASK(i))
+!!(READ_ONCE(((volatile const unsigned long *)(a))[BIT_WORD(i)]) & 
BIT_MASK(i))
 
 static inline int
 test_and_clear_bit(long bit, volatile unsigned long *var)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361175 - stable/11/sys/dev/sound/pcm

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:07:51 2020
New Revision: 361175
URL: https://svnweb.freebsd.org/changeset/base/361175

Log:
  MFC r360790:
  Set PCM_CAP_VIRTUAL for virtual DSP devices.
  
  Submitted by: Kevin Zheng 
  PR:   246206
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/dev/sound/pcm/dsp.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/sound/pcm/dsp.c
==
--- stable/11/sys/dev/sound/pcm/dsp.c   Mon May 18 09:07:14 2020
(r361174)
+++ stable/11/sys/dev/sound/pcm/dsp.c   Mon May 18 09:07:51 2020
(r361175)
@@ -1701,6 +1701,10 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg,
*arg_i = PCM_CAP_REALTIME | PCM_CAP_MMAP | PCM_CAP_TRIGGER;
if (rdch && wrch && !(dsp_get_flags(i_dev) & SD_F_SIMPLEX))
*arg_i |= PCM_CAP_DUPLEX;
+   if (rdch && (rdch->flags & CHN_F_VIRTUAL) != 0)
+   *arg_i |= PCM_CAP_VIRTUAL;
+   if (wrch && (wrch->flags & CHN_F_VIRTUAL) != 0)
+   *arg_i |= PCM_CAP_VIRTUAL;
PCM_UNLOCK(d);
break;
 
@@ -2648,6 +2652,7 @@ dsp_oss_audioinfo(struct cdev *i_dev, oss_audioinfo *a
 *   these in pcmchan::caps?
 */
ai->caps = PCM_CAP_REALTIME | PCM_CAP_MMAP | 
PCM_CAP_TRIGGER |
+   ((ch->flags & CHN_F_VIRTUAL) ? PCM_CAP_VIRTUAL : 0) 
|
((ch->direction == PCMDIR_PLAY) ? PCM_CAP_OUTPUT : 
PCM_CAP_INPUT);
 
/*
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361174 - stable/12/sys/dev/sound/pcm

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:07:14 2020
New Revision: 361174
URL: https://svnweb.freebsd.org/changeset/base/361174

Log:
  MFC r360790:
  Set PCM_CAP_VIRTUAL for virtual DSP devices.
  
  Submitted by: Kevin Zheng 
  PR:   246206
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/sys/dev/sound/pcm/dsp.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/sound/pcm/dsp.c
==
--- stable/12/sys/dev/sound/pcm/dsp.c   Mon May 18 09:06:09 2020
(r361173)
+++ stable/12/sys/dev/sound/pcm/dsp.c   Mon May 18 09:07:14 2020
(r361174)
@@ -1703,6 +1703,10 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg,
*arg_i = PCM_CAP_REALTIME | PCM_CAP_MMAP | PCM_CAP_TRIGGER;
if (rdch && wrch && !(dsp_get_flags(i_dev) & SD_F_SIMPLEX))
*arg_i |= PCM_CAP_DUPLEX;
+   if (rdch && (rdch->flags & CHN_F_VIRTUAL) != 0)
+   *arg_i |= PCM_CAP_VIRTUAL;
+   if (wrch && (wrch->flags & CHN_F_VIRTUAL) != 0)
+   *arg_i |= PCM_CAP_VIRTUAL;
PCM_UNLOCK(d);
break;
 
@@ -2653,6 +2657,7 @@ dsp_oss_audioinfo(struct cdev *i_dev, oss_audioinfo *a
 *   these in pcmchan::caps?
 */
ai->caps = PCM_CAP_REALTIME | PCM_CAP_MMAP | 
PCM_CAP_TRIGGER |
+   ((ch->flags & CHN_F_VIRTUAL) ? PCM_CAP_VIRTUAL : 0) 
|
((ch->direction == PCMDIR_PLAY) ? PCM_CAP_OUTPUT : 
PCM_CAP_INPUT);
 
/*
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361172 - stable/12/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:05:29 2020
New Revision: 361172
URL: https://svnweb.freebsd.org/changeset/base/361172

Log:
  MFC r360528:
  Implement kstrtou64() in the LinuxKPI.
  
  Submitted by: ashafer_badland.io (Austin Shafer)
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/sys/compat/linuxkpi/common/include/linux/kernel.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/kernel.h
==
--- stable/12/sys/compat/linuxkpi/common/include/linux/kernel.h Mon May 18 
09:04:24 2020(r361171)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/kernel.h Mon May 18 
09:05:29 2020(r361172)
@@ -390,6 +390,21 @@ kstrtou32(const char *cp, unsigned int base, u32 *res)
 }
 
 static inline int
+kstrtou64(const char *cp, unsigned int base, u64 *res)
+{
+   char *end;
+
+   *res = strtouq(cp, , base);
+
+   /* skip newline character, if any */
+   if (*end == '\n')
+   end++;
+   if (*cp == 0 || *end != 0)
+   return (-EINVAL);
+   return (0);
+}
+
+static inline int
 kstrtobool(const char *s, bool *res)
 {
int len;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361173 - stable/11/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:06:09 2020
New Revision: 361173
URL: https://svnweb.freebsd.org/changeset/base/361173

Log:
  MFC r360528:
  Implement kstrtou64() in the LinuxKPI.
  
  Submitted by: ashafer_badland.io (Austin Shafer)
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/kernel.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/kernel.h
==
--- stable/11/sys/compat/linuxkpi/common/include/linux/kernel.h Mon May 18 
09:05:29 2020(r361172)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/kernel.h Mon May 18 
09:06:09 2020(r361173)
@@ -385,6 +385,21 @@ kstrtou32(const char *cp, unsigned int base, u32 *res)
 }
 
 static inline int
+kstrtou64(const char *cp, unsigned int base, u64 *res)
+{
+   char *end;
+
+   *res = strtouq(cp, , base);
+
+   /* skip newline character, if any */
+   if (*end == '\n')
+   end++;
+   if (*cp == 0 || *end != 0)
+   return (-EINVAL);
+   return (0);
+}
+
+static inline int
 kstrtobool(const char *s, bool *res)
 {
int len;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361171 - in stable/11/sys/dev/mlx5: . mlx5_en

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:04:24 2020
New Revision: 361171
URL: https://svnweb.freebsd.org/changeset/base/361171

Log:
  MFC r360377:
  Add support for reading temperature in mlx5en(4).
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/dev/mlx5/mlx5_en/en.h
  stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
  stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
  stable/11/sys/dev/mlx5/mlx5_ifc.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/mlx5/mlx5_en/en.h
==
--- stable/11/sys/dev/mlx5/mlx5_en/en.h Mon May 18 09:03:12 2020
(r361170)
+++ stable/11/sys/dev/mlx5/mlx5_en/en.h Mon May 18 09:04:24 2020
(r361171)
@@ -723,6 +723,8 @@ struct mlx5e_params_ethtool {
u8  fec_avail_10x_25x[MLX5E_MAX_FEC_10X_25X];
u16 fec_avail_50x[MLX5E_MAX_FEC_50X];
u32 fec_mode_active;
+   s32 hw_val_temp[MLX5_MAX_TEMPERATURE];
+   u32 hw_num_temp;
 };
 
 struct mlx5e_cq {
@@ -1123,5 +1125,6 @@ void  mlx5e_update_sq_inline(struct mlx5e_sq *sq);
 void   mlx5e_refresh_sq_inline(struct mlx5e_priv *priv);
 intmlx5e_update_buf_lossy(struct mlx5e_priv *priv);
 intmlx5e_fec_update(struct mlx5e_priv *priv);
+intmlx5e_hw_temperature_update(struct mlx5e_priv *priv);
 
 #endif /* _MLX5_EN_H_ */

Modified: stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
==
--- stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.cMon May 18 09:03:12 
2020(r361170)
+++ stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.cMon May 18 09:04:24 
2020(r361171)
@@ -801,6 +801,65 @@ mlx5e_cable_length_handler(SYSCTL_HANDLER_ARGS)
return (error);
 }
 
+static int
+mlx5e_hw_temperature_handler(SYSCTL_HANDLER_ARGS)
+{
+   struct mlx5e_priv *priv = arg1;
+   int err;
+
+   PRIV_LOCK(priv);
+   err = SYSCTL_OUT(req, priv->params_ethtool.hw_val_temp,
+   sizeof(priv->params_ethtool.hw_val_temp[0]) *
+   priv->params_ethtool.hw_num_temp);
+   if (err == 0 && req->newptr != NULL)
+   err = EOPNOTSUPP;
+   PRIV_UNLOCK(priv);
+   return (err);
+}
+
+int
+mlx5e_hw_temperature_update(struct mlx5e_priv *priv)
+{
+   int err;
+   u32 x;
+
+   if (priv->params_ethtool.hw_num_temp == 0) {
+   u32 out_cap[MLX5_ST_SZ_DW(mtcap)] = {};
+   const int sz_cap = MLX5_ST_SZ_BYTES(mtcap);
+   u32 value;
+
+   err = -mlx5_core_access_reg(priv->mdev, NULL, 0, out_cap, 
sz_cap,
+   MLX5_ACCESS_REG_SUMMARY_CTRL_ID_MTCAP, 0, 0);
+   if (err)
+   goto done;
+   value = MLX5_GET(mtcap, out_cap, sensor_count);
+   if (value == 0)
+   return (0);
+   if (value > MLX5_MAX_TEMPERATURE)
+   value = MLX5_MAX_TEMPERATURE;
+   /* update number of temperature sensors */
+   priv->params_ethtool.hw_num_temp = value;
+   }
+
+   for (x = 0; x != priv->params_ethtool.hw_num_temp; x++) {
+   u32 out_sensor[MLX5_ST_SZ_DW(mtmp_reg)] = {};
+   const int sz_sensor = MLX5_ST_SZ_BYTES(mtmp_reg);
+
+   MLX5_SET(mtmp_reg, out_sensor, sensor_index, x);
+
+   err = -mlx5_core_access_reg(priv->mdev, out_sensor, sz_sensor,
+   out_sensor, sz_sensor,
+   MLX5_ACCESS_REG_SUMMARY_CTRL_ID_MTMP, 0, 0);
+   if (err)
+   goto done;
+   /* convert from 0.125 celcius to millicelcius */
+   priv->params_ethtool.hw_val_temp[x] =
+   (s16)MLX5_GET(mtmp_reg, out_sensor, temperature) * 125;
+   }
+done:
+   return (err);
+}
+
 #defineMLX5_PARAM_OFFSET(n)\
 __offsetof(struct mlx5e_priv, params_ethtool.n)
 
@@ -1540,5 +1599,13 @@ mlx5e_create_ethtool(struct mlx5e_priv *priv)
CTLTYPE_UINT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
priv, 0, mlx5e_cable_length_handler, "IU",
"Set cable length in meters for xoff threshold 
calculation");
+   }
+
+   if (mlx5e_hw_temperature_update(priv) == 0) {
+   SYSCTL_ADD_PROC(>sysctl_ctx, 
SYSCTL_CHILDREN(priv->sysctl_ifnet),
+   OID_AUTO, "hw_temperature",
+   CTLTYPE_S32 | CTLFLAG_RD | CTLFLAG_MPSAFE,
+   priv, 0, mlx5e_hw_temperature_handler, "I",
+   "HW temperature in millicelcius");
}
 }

Modified: stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==
--- stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c   Mon May 18 09:03:12 
2020(r361170)
+++ 

svn commit: r361170 - in stable/12/sys/dev/mlx5: . mlx5_en

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:03:12 2020
New Revision: 361170
URL: https://svnweb.freebsd.org/changeset/base/361170

Log:
  MFC r360377:
  Add support for reading temperature in mlx5en(4).
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/sys/dev/mlx5/mlx5_en/en.h
  stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
  stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
  stable/12/sys/dev/mlx5/mlx5_ifc.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/mlx5/mlx5_en/en.h
==
--- stable/12/sys/dev/mlx5/mlx5_en/en.h Mon May 18 09:01:18 2020
(r361169)
+++ stable/12/sys/dev/mlx5/mlx5_en/en.h Mon May 18 09:03:12 2020
(r361170)
@@ -724,6 +724,8 @@ struct mlx5e_params_ethtool {
u8  fec_avail_10x_25x[MLX5E_MAX_FEC_10X_25X];
u16 fec_avail_50x[MLX5E_MAX_FEC_50X];
u32 fec_mode_active;
+   s32 hw_val_temp[MLX5_MAX_TEMPERATURE];
+   u32 hw_num_temp;
 };
 
 struct mlx5e_cq {
@@ -1187,5 +1189,6 @@ void  mlx5e_update_sq_inline(struct mlx5e_sq *sq);
 void   mlx5e_refresh_sq_inline(struct mlx5e_priv *priv);
 intmlx5e_update_buf_lossy(struct mlx5e_priv *priv);
 intmlx5e_fec_update(struct mlx5e_priv *priv);
+intmlx5e_hw_temperature_update(struct mlx5e_priv *priv);
 
 #endif /* _MLX5_EN_H_ */

Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
==
--- stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.cMon May 18 09:01:18 
2020(r361169)
+++ stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.cMon May 18 09:03:12 
2020(r361170)
@@ -801,6 +801,65 @@ mlx5e_cable_length_handler(SYSCTL_HANDLER_ARGS)
return (error);
 }
 
+static int
+mlx5e_hw_temperature_handler(SYSCTL_HANDLER_ARGS)
+{
+   struct mlx5e_priv *priv = arg1;
+   int err;
+
+   PRIV_LOCK(priv);
+   err = SYSCTL_OUT(req, priv->params_ethtool.hw_val_temp,
+   sizeof(priv->params_ethtool.hw_val_temp[0]) *
+   priv->params_ethtool.hw_num_temp);
+   if (err == 0 && req->newptr != NULL)
+   err = EOPNOTSUPP;
+   PRIV_UNLOCK(priv);
+   return (err);
+}
+
+int
+mlx5e_hw_temperature_update(struct mlx5e_priv *priv)
+{
+   int err;
+   u32 x;
+
+   if (priv->params_ethtool.hw_num_temp == 0) {
+   u32 out_cap[MLX5_ST_SZ_DW(mtcap)] = {};
+   const int sz_cap = MLX5_ST_SZ_BYTES(mtcap);
+   u32 value;
+
+   err = -mlx5_core_access_reg(priv->mdev, NULL, 0, out_cap, 
sz_cap,
+   MLX5_ACCESS_REG_SUMMARY_CTRL_ID_MTCAP, 0, 0);
+   if (err)
+   goto done;
+   value = MLX5_GET(mtcap, out_cap, sensor_count);
+   if (value == 0)
+   return (0);
+   if (value > MLX5_MAX_TEMPERATURE)
+   value = MLX5_MAX_TEMPERATURE;
+   /* update number of temperature sensors */
+   priv->params_ethtool.hw_num_temp = value;
+   }
+
+   for (x = 0; x != priv->params_ethtool.hw_num_temp; x++) {
+   u32 out_sensor[MLX5_ST_SZ_DW(mtmp_reg)] = {};
+   const int sz_sensor = MLX5_ST_SZ_BYTES(mtmp_reg);
+
+   MLX5_SET(mtmp_reg, out_sensor, sensor_index, x);
+
+   err = -mlx5_core_access_reg(priv->mdev, out_sensor, sz_sensor,
+   out_sensor, sz_sensor,
+   MLX5_ACCESS_REG_SUMMARY_CTRL_ID_MTMP, 0, 0);
+   if (err)
+   goto done;
+   /* convert from 0.125 celcius to millicelcius */
+   priv->params_ethtool.hw_val_temp[x] =
+   (s16)MLX5_GET(mtmp_reg, out_sensor, temperature) * 125;
+   }
+done:
+   return (err);
+}
+
 #defineMLX5_PARAM_OFFSET(n)\
 __offsetof(struct mlx5e_priv, params_ethtool.n)
 
@@ -1540,5 +1599,13 @@ mlx5e_create_ethtool(struct mlx5e_priv *priv)
CTLTYPE_UINT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
priv, 0, mlx5e_cable_length_handler, "IU",
"Set cable length in meters for xoff threshold 
calculation");
+   }
+
+   if (mlx5e_hw_temperature_update(priv) == 0) {
+   SYSCTL_ADD_PROC(>sysctl_ctx, 
SYSCTL_CHILDREN(priv->sysctl_ifnet),
+   OID_AUTO, "hw_temperature",
+   CTLTYPE_S32 | CTLFLAG_RD | CTLFLAG_MPSAFE,
+   priv, 0, mlx5e_hw_temperature_handler, "I",
+   "HW temperature in millicelcius");
}
 }

Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==
--- stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c   Mon May 18 09:01:18 
2020(r361169)
+++ 

svn commit: r361168 - stable/12/usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:00:45 2020
New Revision: 361168
URL: https://svnweb.freebsd.org/changeset/base/361168

Log:
  MFC r360197:
  Add support for Read_Local_Supported_Commands command to hccontrol(8).
  
  Submitted by: Marc Veldman 
  PR:   245811
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/usr.sbin/bluetooth/hccontrol/hccontrol.8
  stable/12/usr.sbin/bluetooth/hccontrol/hccontrol.h
  stable/12/usr.sbin/bluetooth/hccontrol/info.c
  stable/12/usr.sbin/bluetooth/hccontrol/util.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/bluetooth/hccontrol/hccontrol.8
==
--- stable/12/usr.sbin/bluetooth/hccontrol/hccontrol.8  Mon May 18 08:59:14 
2020(r361167)
+++ stable/12/usr.sbin/bluetooth/hccontrol/hccontrol.8  Mon May 18 09:00:45 
2020(r361168)
@@ -134,6 +134,7 @@ are:
 .It Cm Read_Page_Scan_Mode
 .It Cm Write_Page_Scan_Mode
 .It Cm Read_Local_Version_Information
+.It Cm Read_Local_Supported_Commands
 .It Cm Read_Local_Supported_Features
 .It Cm Read_Buffer_Size
 .It Cm Read_Country_Code

Modified: stable/12/usr.sbin/bluetooth/hccontrol/hccontrol.h
==
--- stable/12/usr.sbin/bluetooth/hccontrol/hccontrol.h  Mon May 18 08:59:14 
2020(r361167)
+++ stable/12/usr.sbin/bluetooth/hccontrol/hccontrol.h  Mon May 18 09:00:45 
2020(r361168)
@@ -72,6 +72,7 @@ char const *  hci_hmode2str   (int, char *, int);
 char const *   hci_ver2str (int);
 char const *   hci_lmpver2str  (int);
 char const *   hci_manufacturer2str(int);
+char const *   hci_commands2str(uint8_t *, char *, int);
 char const *   hci_features2str(uint8_t *, char *, int);
 char const *   hci_le_features2str (uint8_t *, char *, int);
 char const *   hci_cc2str  (int);

Modified: stable/12/usr.sbin/bluetooth/hccontrol/info.c
==
--- stable/12/usr.sbin/bluetooth/hccontrol/info.c   Mon May 18 08:59:14 
2020(r361167)
+++ stable/12/usr.sbin/bluetooth/hccontrol/info.c   Mon May 18 09:00:45 
2020(r361168)
@@ -72,6 +72,38 @@ hci_read_local_version_information(int s, int argc, ch
return (OK);
 } /* hci_read_local_version_information */
 
+/* Send Read_Local_Supported_Commands command to the unit */
+static int
+hci_read_local_supported_commands(int s, int argc, char **argv)
+{
+   ng_hci_read_local_commands_rp   rp;
+   int n;
+   charbuffer[16384];
+
+   n = sizeof(rp);
+   if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_INFO,
+   NG_HCI_OCF_READ_LOCAL_COMMANDS),
+   (char *) , ) == ERROR)
+   return (ERROR);
+
+   if (rp.status != 0x00) {
+   fprintf(stdout, "Status: %s [%#02x]\n", 
+   hci_status2str(rp.status), rp.status);
+   return (FAILED);
+   }
+
+   fprintf(stdout, "Supported commands:");
+   for (n = 0; n < sizeof(rp.features); n++) {
+   if (n % 8 == 0)
+   fprintf(stdout, "\n");
+   fprintf(stdout, "%#02x ", rp.features[n]);
+   }
+   fprintf(stdout, "\n%s\n", hci_commands2str(rp.features, 
+   buffer, sizeof(buffer)));
+
+   return (OK);
+} /* hci_read_local_supported_commands */
+
 /* Send Read_Local_Supported_Features command to the unit */
 static int
 hci_read_local_supported_features(int s, int argc, char **argv)
@@ -186,6 +218,11 @@ struct hci_command info_commands[] = {
 "\nThis command will read the values for the version information for the\n" \
 "local Bluetooth unit.",
 _read_local_version_information
+},
+{
+"read_local_supported_commands",
+"\nThis command will read the commands the local Bluetooth unit supports.\n",
+_read_local_supported_commands 
 },
 {
 "read_local_supported_features",

Modified: stable/12/usr.sbin/bluetooth/hccontrol/util.c
==
--- stable/12/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:59:14 
2020(r361167)
+++ stable/12/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 09:00:45 
2020(r361168)
@@ -2430,6 +2430,501 @@ hci_manufacturer2str(int m)
 } /* hci_manufacturer2str */
 
 char const *
+hci_commands2str(uint8_t *commands, char *buffer, int size)
+{
+   static char const * const   t[][8] = {
+   { /* byte 0 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ " ",
+   /* 3 */ " ",
+   /* 4 */ " ",
+   /* 5 */ " ",
+   /* 6 */ " ",
+   /* 7 */ " "
+   },
+   { /* byte 1 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ 

svn commit: r361169 - stable/11/usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 09:01:18 2020
New Revision: 361169
URL: https://svnweb.freebsd.org/changeset/base/361169

Log:
  MFC r360197:
  Add support for Read_Local_Supported_Commands command to hccontrol(8).
  
  Submitted by: Marc Veldman 
  PR:   245811
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/usr.sbin/bluetooth/hccontrol/hccontrol.8
  stable/11/usr.sbin/bluetooth/hccontrol/hccontrol.h
  stable/11/usr.sbin/bluetooth/hccontrol/info.c
  stable/11/usr.sbin/bluetooth/hccontrol/util.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/bluetooth/hccontrol/hccontrol.8
==
--- stable/11/usr.sbin/bluetooth/hccontrol/hccontrol.8  Mon May 18 09:00:45 
2020(r361168)
+++ stable/11/usr.sbin/bluetooth/hccontrol/hccontrol.8  Mon May 18 09:01:18 
2020(r361169)
@@ -134,6 +134,7 @@ are:
 .It Cm Read_Page_Scan_Mode
 .It Cm Write_Page_Scan_Mode
 .It Cm Read_Local_Version_Information
+.It Cm Read_Local_Supported_Commands
 .It Cm Read_Local_Supported_Features
 .It Cm Read_Buffer_Size
 .It Cm Read_Country_Code

Modified: stable/11/usr.sbin/bluetooth/hccontrol/hccontrol.h
==
--- stable/11/usr.sbin/bluetooth/hccontrol/hccontrol.h  Mon May 18 09:00:45 
2020(r361168)
+++ stable/11/usr.sbin/bluetooth/hccontrol/hccontrol.h  Mon May 18 09:01:18 
2020(r361169)
@@ -72,6 +72,7 @@ char const *  hci_hmode2str   (int, char *, int);
 char const *   hci_ver2str (int);
 char const *   hci_lmpver2str  (int);
 char const *   hci_manufacturer2str(int);
+char const *   hci_commands2str(uint8_t *, char *, int);
 char const *   hci_features2str(uint8_t *, char *, int);
 char const *   hci_le_features2str (uint8_t *, char *, int);
 char const *   hci_cc2str  (int);

Modified: stable/11/usr.sbin/bluetooth/hccontrol/info.c
==
--- stable/11/usr.sbin/bluetooth/hccontrol/info.c   Mon May 18 09:00:45 
2020(r361168)
+++ stable/11/usr.sbin/bluetooth/hccontrol/info.c   Mon May 18 09:01:18 
2020(r361169)
@@ -72,6 +72,38 @@ hci_read_local_version_information(int s, int argc, ch
return (OK);
 } /* hci_read_local_version_information */
 
+/* Send Read_Local_Supported_Commands command to the unit */
+static int
+hci_read_local_supported_commands(int s, int argc, char **argv)
+{
+   ng_hci_read_local_commands_rp   rp;
+   int n;
+   charbuffer[16384];
+
+   n = sizeof(rp);
+   if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_INFO,
+   NG_HCI_OCF_READ_LOCAL_COMMANDS),
+   (char *) , ) == ERROR)
+   return (ERROR);
+
+   if (rp.status != 0x00) {
+   fprintf(stdout, "Status: %s [%#02x]\n", 
+   hci_status2str(rp.status), rp.status);
+   return (FAILED);
+   }
+
+   fprintf(stdout, "Supported commands:");
+   for (n = 0; n < sizeof(rp.features); n++) {
+   if (n % 8 == 0)
+   fprintf(stdout, "\n");
+   fprintf(stdout, "%#02x ", rp.features[n]);
+   }
+   fprintf(stdout, "\n%s\n", hci_commands2str(rp.features, 
+   buffer, sizeof(buffer)));
+
+   return (OK);
+} /* hci_read_local_supported_commands */
+
 /* Send Read_Local_Supported_Features command to the unit */
 static int
 hci_read_local_supported_features(int s, int argc, char **argv)
@@ -186,6 +218,11 @@ struct hci_command info_commands[] = {
 "\nThis command will read the values for the version information for the\n" \
 "local Bluetooth unit.",
 _read_local_version_information
+},
+{
+"read_local_supported_commands",
+"\nThis command will read the commands the local Bluetooth unit supports.\n",
+_read_local_supported_commands 
 },
 {
 "read_local_supported_features",

Modified: stable/11/usr.sbin/bluetooth/hccontrol/util.c
==
--- stable/11/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 09:00:45 
2020(r361168)
+++ stable/11/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 09:01:18 
2020(r361169)
@@ -2430,6 +2430,501 @@ hci_manufacturer2str(int m)
 } /* hci_manufacturer2str */
 
 char const *
+hci_commands2str(uint8_t *commands, char *buffer, int size)
+{
+   static char const * const   t[][8] = {
+   { /* byte 0 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ " ",
+   /* 3 */ " ",
+   /* 4 */ " ",
+   /* 5 */ " ",
+   /* 6 */ " ",
+   /* 7 */ " "
+   },
+   { /* byte 1 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ 

svn commit: r361166 - stable/12/usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 08:58:41 2020
New Revision: 361166
URL: https://svnweb.freebsd.org/changeset/base/361166

Log:
  MFC r360172:
  Update string tables in hccontrol(8).
  
  Submitted by: Marc Veldman 
  PR:   245796
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/usr.sbin/bluetooth/hccontrol/util.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/bluetooth/hccontrol/util.c
==
--- stable/12/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:57:55 
2020(r361165)
+++ stable/12/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:58:41 
2020(r361166)
@@ -160,7 +160,10 @@ hci_ver2str(int ver)
/* 0x05 */ "Bluetooth HCI Specification 3.0",
/* 0x06 */ "Bluetooth HCI Specification 4.0",
/* 0x07 */ "Bluetooth HCI Specification 4.1",
-   /* 0x08 */ "Bluetooth HCI Specification 4.2"
+   /* 0x08 */ "Bluetooth HCI Specification 4.2",
+   /* 0x09 */ "Bluetooth HCI Specification 5.0",
+   /* 0x0a */ "Bluetooth HCI Specification 5.1",
+   /* 0x0b */ "Bluetooth HCI Specification 5.2"
};
 
return (ver >= SIZE(t)? "?" : t[ver]);
@@ -175,10 +178,13 @@ hci_lmpver2str(int ver)
/* 0x02 */ "Bluetooth LMP 1.2",
/* 0x03 */ "Bluetooth LMP 2.0",
/* 0x04 */ "Bluetooth LMP 2.1",
-   /* 0x04 */ "Bluetooth LMP 3.0",
-   /* 0x04 */ "Bluetooth LMP 4.0",
-   /* 0x04 */ "Bluetooth LMP 4.1",
-   /* 0x04 */ "Bluetooth LMP 4.2"  
+   /* 0x05 */ "Bluetooth LMP 3.0",
+   /* 0x06 */ "Bluetooth LMP 4.0",
+   /* 0x07 */ "Bluetooth LMP 4.1",
+   /* 0x08 */ "Bluetooth LMP 4.2",
+   /* 0x09 */ "Bluetooth LMP 5.0",
+   /* 0x0a */ "Bluetooth LMP 5.1",
+   /* 0x0b */ "Bluetooth LMP 5.2"
};
 
return (ver >= SIZE(t)? "?" : t[ver]);
@@ -198,7 +204,7 @@ hci_manufacturer2str(int m)
/* 0007 */ "Lucent",
/* 0008 */ "Motorola",
/* 0009 */ "Infineon Technologies AG",
-   /* 0010 */ "Cambridge Silicon Radio",
+   /* 0010 */ "Qualcomm Technologies International, Ltd. (QTIL)",
/* 0011 */ "Silicon Wave",
/* 0012 */ "Digianswer A/S",
/* 0013 */ "Texas Instruments Inc.",
@@ -213,7 +219,7 @@ hci_manufacturer2str(int m)
/* 0022 */ "KC Technology Inc.",
/* 0023 */ "Newlogic",
/* 0024 */ "Transilica, Inc.",
-   /* 0025 */ "Rohde & Schwartz GmbH & Co. KG",
+   /* 0025 */ "Rohde & Schwarz GmbH & Co. KG",
/* 0026 */ "TTPCom Limited",
/* 0027 */ "Signia Technologies, Inc.",
/* 0028 */ "Conexant Systems Inc.",
@@ -225,7 +231,7 @@ hci_manufacturer2str(int m)
/* 0034 */ "NEC Corporation",
/* 0035 */ "WavePlus Technology Co., Ltd.",
/* 0036 */ "Alcatel",
-   /* 0037 */ "Philips Semiconductors",
+   /* 0037 */ "NXP Semiconductors (formerly Philips 
Semiconductors)",
/* 0038 */ "C Technologies",
/* 0039 */ "Open Interface",
/* 0040 */ "R F Micro Devices",
@@ -237,22 +243,2187 @@ hci_manufacturer2str(int m)
/* 0046 */ "Norwood Systems",
/* 0047 */ "MewTel Technology Inc.",
/* 0048 */ "ST Microelectronics",
-   /* 0049 */ "Synopsys",
+   /* 0049 */ "Synopsys, Inc.",
/* 0050 */ "Red-M (Communications) Ltd",
/* 0051 */ "Commil Ltd",
/* 0052 */ "Computer Access Technology Corporation (CATC)",
/* 0053 */ "Eclipse (HQ Espana) S.L.",
-   /* 0054 */ "Renesas Technology Corp.",
+   /* 0054 */ "Renesas Electronics Corporation",
/* 0055 */ "Mobilian Corporation",
-   /* 0056 */ "Terax",
+   /* 0056 */ "Syntronix Corporation",
/* 0057 */ "Integrated System Solution Corp.",
-   /* 0058 */ "Matsushita Electric Industrial Co., Ltd.",
+   /* 0058 */ "Panasonic Corporation (formerly Matsushita Electric 
Industrial Co., Ltd.)",
/* 0059 */ "Gennum Corporation",
-   /* 0060 */ "Research In Motion",
+   /* 0060 */ "BlackBerry Limited (formerly Research In Motion)",
/* 0061 */ "IPextreme, Inc.",
/* 0062 */ "Systems and Chips, Inc",
/* 0063 */ "Bluetooth SIG, Inc",
-   /* 0064 */ "Seiko Epson Corporation"
+   /* 0064 */ "Seiko Epson Corporation",
+   /* 0065 */ "Integrated Silicon Solution 

svn commit: r361167 - stable/11/usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 08:59:14 2020
New Revision: 361167
URL: https://svnweb.freebsd.org/changeset/base/361167

Log:
  MFC r360172:
  Update string tables in hccontrol(8).
  
  Submitted by: Marc Veldman 
  PR:   245796
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/usr.sbin/bluetooth/hccontrol/util.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/bluetooth/hccontrol/util.c
==
--- stable/11/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:58:41 
2020(r361166)
+++ stable/11/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:59:14 
2020(r361167)
@@ -160,7 +160,10 @@ hci_ver2str(int ver)
/* 0x05 */ "Bluetooth HCI Specification 3.0",
/* 0x06 */ "Bluetooth HCI Specification 4.0",
/* 0x07 */ "Bluetooth HCI Specification 4.1",
-   /* 0x08 */ "Bluetooth HCI Specification 4.2"
+   /* 0x08 */ "Bluetooth HCI Specification 4.2",
+   /* 0x09 */ "Bluetooth HCI Specification 5.0",
+   /* 0x0a */ "Bluetooth HCI Specification 5.1",
+   /* 0x0b */ "Bluetooth HCI Specification 5.2"
};
 
return (ver >= SIZE(t)? "?" : t[ver]);
@@ -175,10 +178,13 @@ hci_lmpver2str(int ver)
/* 0x02 */ "Bluetooth LMP 1.2",
/* 0x03 */ "Bluetooth LMP 2.0",
/* 0x04 */ "Bluetooth LMP 2.1",
-   /* 0x04 */ "Bluetooth LMP 3.0",
-   /* 0x04 */ "Bluetooth LMP 4.0",
-   /* 0x04 */ "Bluetooth LMP 4.1",
-   /* 0x04 */ "Bluetooth LMP 4.2"  
+   /* 0x05 */ "Bluetooth LMP 3.0",
+   /* 0x06 */ "Bluetooth LMP 4.0",
+   /* 0x07 */ "Bluetooth LMP 4.1",
+   /* 0x08 */ "Bluetooth LMP 4.2",
+   /* 0x09 */ "Bluetooth LMP 5.0",
+   /* 0x0a */ "Bluetooth LMP 5.1",
+   /* 0x0b */ "Bluetooth LMP 5.2"
};
 
return (ver >= SIZE(t)? "?" : t[ver]);
@@ -198,7 +204,7 @@ hci_manufacturer2str(int m)
/* 0007 */ "Lucent",
/* 0008 */ "Motorola",
/* 0009 */ "Infineon Technologies AG",
-   /* 0010 */ "Cambridge Silicon Radio",
+   /* 0010 */ "Qualcomm Technologies International, Ltd. (QTIL)",
/* 0011 */ "Silicon Wave",
/* 0012 */ "Digianswer A/S",
/* 0013 */ "Texas Instruments Inc.",
@@ -213,7 +219,7 @@ hci_manufacturer2str(int m)
/* 0022 */ "KC Technology Inc.",
/* 0023 */ "Newlogic",
/* 0024 */ "Transilica, Inc.",
-   /* 0025 */ "Rohde & Schwartz GmbH & Co. KG",
+   /* 0025 */ "Rohde & Schwarz GmbH & Co. KG",
/* 0026 */ "TTPCom Limited",
/* 0027 */ "Signia Technologies, Inc.",
/* 0028 */ "Conexant Systems Inc.",
@@ -225,7 +231,7 @@ hci_manufacturer2str(int m)
/* 0034 */ "NEC Corporation",
/* 0035 */ "WavePlus Technology Co., Ltd.",
/* 0036 */ "Alcatel",
-   /* 0037 */ "Philips Semiconductors",
+   /* 0037 */ "NXP Semiconductors (formerly Philips 
Semiconductors)",
/* 0038 */ "C Technologies",
/* 0039 */ "Open Interface",
/* 0040 */ "R F Micro Devices",
@@ -237,22 +243,2187 @@ hci_manufacturer2str(int m)
/* 0046 */ "Norwood Systems",
/* 0047 */ "MewTel Technology Inc.",
/* 0048 */ "ST Microelectronics",
-   /* 0049 */ "Synopsys",
+   /* 0049 */ "Synopsys, Inc.",
/* 0050 */ "Red-M (Communications) Ltd",
/* 0051 */ "Commil Ltd",
/* 0052 */ "Computer Access Technology Corporation (CATC)",
/* 0053 */ "Eclipse (HQ Espana) S.L.",
-   /* 0054 */ "Renesas Technology Corp.",
+   /* 0054 */ "Renesas Electronics Corporation",
/* 0055 */ "Mobilian Corporation",
-   /* 0056 */ "Terax",
+   /* 0056 */ "Syntronix Corporation",
/* 0057 */ "Integrated System Solution Corp.",
-   /* 0058 */ "Matsushita Electric Industrial Co., Ltd.",
+   /* 0058 */ "Panasonic Corporation (formerly Matsushita Electric 
Industrial Co., Ltd.)",
/* 0059 */ "Gennum Corporation",
-   /* 0060 */ "Research In Motion",
+   /* 0060 */ "BlackBerry Limited (formerly Research In Motion)",
/* 0061 */ "IPextreme, Inc.",
/* 0062 */ "Systems and Chips, Inc",
/* 0063 */ "Bluetooth SIG, Inc",
-   /* 0064 */ "Seiko Epson Corporation"
+   /* 0064 */ "Seiko Epson Corporation",
+   /* 0065 */ "Integrated Silicon Solution 

svn commit: r361165 - in stable/11: sys/netgraph/bluetooth/hci sys/netgraph/bluetooth/include usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 08:57:55 2020
New Revision: 361165
URL: https://svnweb.freebsd.org/changeset/base/361165

Log:
  MFC r360116:
  Substitute le_read_supported_status with le_read_supported_states.
  Refer to bluetooth core v5.2 specifications Vol4. Part E. 7.8.27.
  
  PR:   245763
  Submitted by: Marc Veldman 
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/netgraph/bluetooth/hci/ng_hci_cmds.c
  stable/11/sys/netgraph/bluetooth/include/ng_hci.h
  stable/11/usr.sbin/bluetooth/hccontrol/le.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netgraph/bluetooth/hci/ng_hci_cmds.c
==
--- stable/11/sys/netgraph/bluetooth/hci/ng_hci_cmds.c  Mon May 18 08:57:21 
2020(r361164)
+++ stable/11/sys/netgraph/bluetooth/hci/ng_hci_cmds.c  Mon May 18 08:57:55 
2020(r361165)
@@ -840,7 +840,7 @@ process_le_params(ng_hci_unit_p unit, u_int16_t ocf,
case NG_HCI_OCF_LE_RAND:
case NG_HCI_OCF_LE_LONG_TERM_KEY_REQUEST_REPLY:
case NG_HCI_OCF_LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY:
-   case NG_HCI_OCF_LE_READ_SUPPORTED_STATUS:
+   case NG_HCI_OCF_LE_READ_SUPPORTED_STATES:
case NG_HCI_OCF_LE_RECEIVER_TEST:
case NG_HCI_OCF_LE_TRANSMITTER_TEST:
case NG_HCI_OCF_LE_TEST_END:
@@ -911,7 +911,7 @@ process_le_status(ng_hci_unit_p unit,ng_hci_command_st
case NG_HCI_OCF_LE_RAND:
case NG_HCI_OCF_LE_LONG_TERM_KEY_REQUEST_REPLY:
case NG_HCI_OCF_LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY:
-   case NG_HCI_OCF_LE_READ_SUPPORTED_STATUS:
+   case NG_HCI_OCF_LE_READ_SUPPORTED_STATES:
case NG_HCI_OCF_LE_RECEIVER_TEST:
case NG_HCI_OCF_LE_TRANSMITTER_TEST:
case NG_HCI_OCF_LE_TEST_END:

Modified: stable/11/sys/netgraph/bluetooth/include/ng_hci.h
==
--- stable/11/sys/netgraph/bluetooth/include/ng_hci.h   Mon May 18 08:57:21 
2020(r361164)
+++ stable/11/sys/netgraph/bluetooth/include/ng_hci.h   Mon May 18 08:57:55 
2020(r361165)
@@ -1667,12 +1667,12 @@ typedef struct {
 }__attribute__ ((packed)) ng_hci_le_long_term_key_request_negative_reply_rp;
 
 
-#define NG_HCI_OCF_LE_READ_SUPPORTED_STATUS0x001c
+#define NG_HCI_OCF_LE_READ_SUPPORTED_STATES0x001c
 /*No command parameter*/
 typedef struct {
u_int8_t status;
-   u_int64_t le_status;
-}__attribute__ ((packed)) ng_hci_le_read_supported_status_rp;
+   u_int64_t le_states;
+}__attribute__ ((packed)) ng_hci_le_read_supported_states_rp;
 
 #define NG_HCI_OCF_LE_RECEIVER_TEST0x001d
 typedef struct{

Modified: stable/11/usr.sbin/bluetooth/hccontrol/le.c
==
--- stable/11/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 08:57:21 2020
(r361164)
+++ stable/11/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 08:57:55 2020
(r361165)
@@ -52,7 +52,7 @@ static int le_set_scan_param(int s, int argc, char *ar
 static int le_set_scan_enable(int s, int argc, char *argv[]);
 static int parse_param(int argc, char *argv[], char *buf, int *len);
 static int le_set_scan_response(int s, int argc, char *argv[]);
-static int le_read_supported_status(int s, int argc, char *argv[]);
+static int le_read_supported_states(int s, int argc, char *argv[]);
 static int le_read_local_supported_features(int s, int argc ,char *argv[]);
 static int set_le_event_mask(int s, uint64_t mask);
 static int set_event_mask(int s, uint64_t mask);
@@ -259,20 +259,26 @@ le_read_local_supported_features(int s, int argc ,char
 }
 
 static int
-le_read_supported_status(int s, int argc, char *argv[])
+le_read_supported_states(int s, int argc, char *argv[])
 {
-   ng_hci_le_read_supported_status_rp rp;
-   int e;
+   ng_hci_le_read_supported_states_rp rp;
int n = sizeof(rp);
 
-   e = hci_simple_request(s, NG_HCI_OPCODE(
+   if (hci_simple_request(s, NG_HCI_OPCODE(
NG_HCI_OGF_LE,
-   NG_HCI_OCF_LE_READ_SUPPORTED_STATUS),
-   (void *), );
+   NG_HCI_OCF_LE_READ_SUPPORTED_STATES),
+   (void *), ) == ERROR)
+   return (ERROR);
 
-   printf("LE_STATUS: %d %d %jx\n", e, rp.status, (uintmax_t)rp.le_status);
+   if (rp.status != 0x00) {
+   fprintf(stdout, "Status: %s [%#02x]\n", 
+   hci_status2str(rp.status), rp.status);
+   return (FAILED);
+   }
 
-   return 0;
+   fprintf(stdout, "LE States: %jx\n", rp.le_states);
+   
+   return (OK); 
 }
 
 static int
@@ -347,11 +353,11 @@ struct hci_command le_commands[] = {
  _read_local_supported_features,
   },
   {
- 

svn commit: r361164 - in stable/12: sys/netgraph/bluetooth/hci sys/netgraph/bluetooth/include usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 08:57:21 2020
New Revision: 361164
URL: https://svnweb.freebsd.org/changeset/base/361164

Log:
  MFC r360116:
  Substitute le_read_supported_status with le_read_supported_states.
  Refer to bluetooth core v5.2 specifications Vol4. Part E. 7.8.27.
  
  PR:   245763
  Submitted by: Marc Veldman 
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/sys/netgraph/bluetooth/hci/ng_hci_cmds.c
  stable/12/sys/netgraph/bluetooth/include/ng_hci.h
  stable/12/usr.sbin/bluetooth/hccontrol/le.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/netgraph/bluetooth/hci/ng_hci_cmds.c
==
--- stable/12/sys/netgraph/bluetooth/hci/ng_hci_cmds.c  Mon May 18 08:56:22 
2020(r361163)
+++ stable/12/sys/netgraph/bluetooth/hci/ng_hci_cmds.c  Mon May 18 08:57:21 
2020(r361164)
@@ -842,7 +842,7 @@ process_le_params(ng_hci_unit_p unit, u_int16_t ocf,
case NG_HCI_OCF_LE_RAND:
case NG_HCI_OCF_LE_LONG_TERM_KEY_REQUEST_REPLY:
case NG_HCI_OCF_LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY:
-   case NG_HCI_OCF_LE_READ_SUPPORTED_STATUS:
+   case NG_HCI_OCF_LE_READ_SUPPORTED_STATES:
case NG_HCI_OCF_LE_RECEIVER_TEST:
case NG_HCI_OCF_LE_TRANSMITTER_TEST:
case NG_HCI_OCF_LE_TEST_END:
@@ -913,7 +913,7 @@ process_le_status(ng_hci_unit_p unit,ng_hci_command_st
case NG_HCI_OCF_LE_RAND:
case NG_HCI_OCF_LE_LONG_TERM_KEY_REQUEST_REPLY:
case NG_HCI_OCF_LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY:
-   case NG_HCI_OCF_LE_READ_SUPPORTED_STATUS:
+   case NG_HCI_OCF_LE_READ_SUPPORTED_STATES:
case NG_HCI_OCF_LE_RECEIVER_TEST:
case NG_HCI_OCF_LE_TRANSMITTER_TEST:
case NG_HCI_OCF_LE_TEST_END:

Modified: stable/12/sys/netgraph/bluetooth/include/ng_hci.h
==
--- stable/12/sys/netgraph/bluetooth/include/ng_hci.h   Mon May 18 08:56:22 
2020(r361163)
+++ stable/12/sys/netgraph/bluetooth/include/ng_hci.h   Mon May 18 08:57:21 
2020(r361164)
@@ -1673,12 +1673,12 @@ typedef struct {
 }__attribute__ ((packed)) ng_hci_le_long_term_key_request_negative_reply_rp;
 
 
-#define NG_HCI_OCF_LE_READ_SUPPORTED_STATUS0x001c
+#define NG_HCI_OCF_LE_READ_SUPPORTED_STATES0x001c
 /*No command parameter*/
 typedef struct {
u_int8_t status;
-   u_int64_t le_status;
-}__attribute__ ((packed)) ng_hci_le_read_supported_status_rp;
+   u_int64_t le_states;
+}__attribute__ ((packed)) ng_hci_le_read_supported_states_rp;
 
 #define NG_HCI_OCF_LE_RECEIVER_TEST0x001d
 typedef struct{

Modified: stable/12/usr.sbin/bluetooth/hccontrol/le.c
==
--- stable/12/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 08:56:22 2020
(r361163)
+++ stable/12/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 08:57:21 2020
(r361164)
@@ -52,7 +52,7 @@ static int le_set_scan_param(int s, int argc, char *ar
 static int le_set_scan_enable(int s, int argc, char *argv[]);
 static int parse_param(int argc, char *argv[], char *buf, int *len);
 static int le_set_scan_response(int s, int argc, char *argv[]);
-static int le_read_supported_status(int s, int argc, char *argv[]);
+static int le_read_supported_states(int s, int argc, char *argv[]);
 static int le_read_local_supported_features(int s, int argc ,char *argv[]);
 static int set_le_event_mask(int s, uint64_t mask);
 static int set_event_mask(int s, uint64_t mask);
@@ -259,20 +259,26 @@ le_read_local_supported_features(int s, int argc ,char
 }
 
 static int
-le_read_supported_status(int s, int argc, char *argv[])
+le_read_supported_states(int s, int argc, char *argv[])
 {
-   ng_hci_le_read_supported_status_rp rp;
-   int e;
+   ng_hci_le_read_supported_states_rp rp;
int n = sizeof(rp);
 
-   e = hci_simple_request(s, NG_HCI_OPCODE(
+   if (hci_simple_request(s, NG_HCI_OPCODE(
NG_HCI_OGF_LE,
-   NG_HCI_OCF_LE_READ_SUPPORTED_STATUS),
-   (void *), );
+   NG_HCI_OCF_LE_READ_SUPPORTED_STATES),
+   (void *), ) == ERROR)
+   return (ERROR);
 
-   printf("LE_STATUS: %d %d %jx\n", e, rp.status, (uintmax_t)rp.le_status);
+   if (rp.status != 0x00) {
+   fprintf(stdout, "Status: %s [%#02x]\n", 
+   hci_status2str(rp.status), rp.status);
+   return (FAILED);
+   }
 
-   return 0;
+   fprintf(stdout, "LE States: %jx\n", rp.le_states);
+   
+   return (OK); 
 }
 
 static int
@@ -347,11 +353,11 @@ struct hci_command le_commands[] = {
  _read_local_supported_features,
   },
   {
- 

svn commit: r361163 - stable/11/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 08:56:22 2020
New Revision: 361163
URL: https://svnweb.freebsd.org/changeset/base/361163

Log:
  MFC r360115:
  Allow the ERR_CAST() function in the LinuxKPI to take a const void pointer.
  No functional change.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/err.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/err.h
==
--- stable/11/sys/compat/linuxkpi/common/include/linux/err.hMon May 18 
08:55:49 2020(r361162)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/err.hMon May 18 
08:56:22 2020(r361163)
@@ -31,6 +31,8 @@
 #ifndef_LINUX_ERR_H_
 #define_LINUX_ERR_H_
 
+#include 
+
 #include 
 
 #define MAX_ERRNO  4095
@@ -62,9 +64,9 @@ IS_ERR_OR_NULL(const void *ptr)
 }
 
 static inline void *
-ERR_CAST(void *ptr)
+ERR_CAST(const void *ptr)
 {
-   return (void *)ptr;
+   return __DECONST(void *, ptr);
 }
 
 static inline int
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361162 - stable/12/sys/compat/linuxkpi/common/include/linux

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 08:55:49 2020
New Revision: 361162
URL: https://svnweb.freebsd.org/changeset/base/361162

Log:
  MFC r360115:
  Allow the ERR_CAST() function in the LinuxKPI to take a const void pointer.
  No functional change.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/sys/compat/linuxkpi/common/include/linux/err.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/err.h
==
--- stable/12/sys/compat/linuxkpi/common/include/linux/err.hMon May 18 
08:52:40 2020(r361161)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/err.hMon May 18 
08:55:49 2020(r361162)
@@ -31,6 +31,8 @@
 #ifndef_LINUX_ERR_H_
 #define_LINUX_ERR_H_
 
+#include 
+
 #include 
 
 #define MAX_ERRNO  4095
@@ -62,9 +64,9 @@ IS_ERR_OR_NULL(const void *ptr)
 }
 
 static inline void *
-ERR_CAST(void *ptr)
+ERR_CAST(const void *ptr)
 {
-   return (void *)ptr;
+   return __DECONST(void *, ptr);
 }
 
 static inline int
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361161 - stable/11/usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 08:52:40 2020
New Revision: 361161
URL: https://svnweb.freebsd.org/changeset/base/361161

Log:
  MFC r360095:
  Fix cut and paste off-by-one error in hccontrol(8).
  Make sure strncpy() doesn't write beyond its given buffer.
  
  PR:   245739
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/usr.sbin/bluetooth/hccontrol/util.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/bluetooth/hccontrol/util.c
==
--- stable/11/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:52:06 
2020(r361160)
+++ stable/11/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:52:40 
2020(r361161)
@@ -134,6 +134,7 @@ hci_hmode2str(int mode, char *buffer, int size)
int n;
 
memset(buffer, 0, size);
+   size--;
for (n = 0; n < SIZE(t); n++) {
int len = strlen(buffer);
 
@@ -347,6 +348,7 @@ hci_features2str(uint8_t *features, char *buffer, int 
 
memset(buffer, 0, size);
len1 = 0;
+   size--;
 
for (n = 0; n < SIZE(t); n++) {
for (i = 0; i < SIZE(t[n]); i++) {
@@ -460,6 +462,7 @@ hci_le_features2str(uint8_t *features, char *buffer, i
 
memset(buffer, 0, size);
len1 = 0;
+   size--;
 
for (n = 0; n < SIZE(t); n++) {
for (i = 0; i < SIZE(t[n]); i++) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361160 - stable/12/usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 08:52:06 2020
New Revision: 361160
URL: https://svnweb.freebsd.org/changeset/base/361160

Log:
  MFC r360095:
  Fix cut and paste off-by-one error in hccontrol(8).
  Make sure strncpy() doesn't write beyond its given buffer.
  
  PR:   245739
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/usr.sbin/bluetooth/hccontrol/util.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/bluetooth/hccontrol/util.c
==
--- stable/12/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:46:53 
2020(r361159)
+++ stable/12/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:52:06 
2020(r361160)
@@ -134,6 +134,7 @@ hci_hmode2str(int mode, char *buffer, int size)
int n;
 
memset(buffer, 0, size);
+   size--;
for (n = 0; n < SIZE(t); n++) {
int len = strlen(buffer);
 
@@ -347,6 +348,7 @@ hci_features2str(uint8_t *features, char *buffer, int 
 
memset(buffer, 0, size);
len1 = 0;
+   size--;
 
for (n = 0; n < SIZE(t); n++) {
for (i = 0; i < SIZE(t[n]); i++) {
@@ -460,6 +462,7 @@ hci_le_features2str(uint8_t *features, char *buffer, i
 
memset(buffer, 0, size);
len1 = 0;
+   size--;
 
for (n = 0; n < SIZE(t); n++) {
for (i = 0; i < SIZE(t[n]); i++) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361159 - stable/11/usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 08:46:53 2020
New Revision: 361159
URL: https://svnweb.freebsd.org/changeset/base/361159

Log:
  MFC r360094:
  Improve printing of le features in hccontrol(8).
  
  Submitted by: Marc Veldman 
  PR:   245739
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/usr.sbin/bluetooth/hccontrol/hccontrol.h
  stable/11/usr.sbin/bluetooth/hccontrol/le.c
  stable/11/usr.sbin/bluetooth/hccontrol/util.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/bluetooth/hccontrol/hccontrol.h
==
--- stable/11/usr.sbin/bluetooth/hccontrol/hccontrol.h  Mon May 18 08:46:17 
2020(r361158)
+++ stable/11/usr.sbin/bluetooth/hccontrol/hccontrol.h  Mon May 18 08:46:53 
2020(r361159)
@@ -73,6 +73,7 @@ char const *  hci_ver2str (int);
 char const *   hci_lmpver2str  (int);
 char const *   hci_manufacturer2str(int);
 char const *   hci_features2str(uint8_t *, char *, int);
+char const *   hci_le_features2str (uint8_t *, char *, int);
 char const *   hci_cc2str  (int);
 char const *   hci_con_state2str   (int);
 char const *   hci_status2str  (int);

Modified: stable/11/usr.sbin/bluetooth/hccontrol/le.c
==
--- stable/11/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 08:46:17 2020
(r361158)
+++ stable/11/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 08:46:53 2020
(r361159)
@@ -225,18 +225,37 @@ static int
 le_read_local_supported_features(int s, int argc ,char *argv[])
 {
ng_hci_le_read_local_supported_features_rp rp;
-   int e;
int n = sizeof(rp);
 
-   e = hci_simple_request(s,
+   union {
+   uint64_t raw;
+   uint8_t octets[8];
+   } le_features;
+
+   char buffer[2048];
+
+   if (hci_simple_request(s,
NG_HCI_OPCODE(NG_HCI_OGF_LE,
NG_HCI_OCF_LE_READ_LOCAL_SUPPORTED_FEATURES), 
-   (void *), );
+   (void *), ) == ERROR)
+   return (ERROR);
 
-   printf("LOCAL SUPPORTED: %d %d %jx\n", e, rp.status,
-  (uintmax_t) rp.le_features);
+   if (rp.status != 0x00) {
+   fprintf(stdout, "Status: %s [%#02x]\n", 
+   hci_status2str(rp.status), rp.status);
+   return (FAILED);
+   }
 
-   return 0;
+   le_features.raw = rp.le_features;
+
+   fprintf(stdout, "LE Features: ");
+   for(int i = 0; i < 8; i++)
+fprintf(stdout, " %#02x", le_features.octets[i]);
+   fprintf(stdout, "\n%s\n", hci_le_features2str(le_features.octets, 
+   buffer, sizeof(buffer)));
+   fprintf(stdout, "\n");
+
+   return OK;
 }
 
 static int

Modified: stable/11/usr.sbin/bluetooth/hccontrol/util.c
==
--- stable/11/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:46:17 
2020(r361158)
+++ stable/11/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:46:53 
2020(r361159)
@@ -371,6 +371,119 @@ done:
 } /* hci_features2str */
 
 char const *
+hci_le_features2str(uint8_t *features, char *buffer, int size)
+{
+   static char const * const t[][8] = {
+   { /* byte 0 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ " ",
+   /* 3 */ " ",
+   /* 4 */ " ",
+   /* 5 */ " ",
+   /* 6 */ " ",
+   /* 7 */ " "
+   },
+   { /* byte 1 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ " ",
+   /* 3 */ " ",
+   /* 4 */ " ",
+   /* 5 */ " ",
+   /* 6 */ " ",
+   /* 7 */ " "
+   },
+   { /* byte 2 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ " ",
+   /* 3 */ " ",
+   /* 4 */ " ",
+   /* 5 */ " ",
+   /* 6 */ " ",
+   /* 7 */ " "
+   },
+   { /* byte 3 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ " ",
+   /* 3 */ " ",
+   /* 4 */ " ",
+   /* 5 */ " ",
+   /* 6 */ " ",
+   /* 7 */ " "
+   },
+   { /* byte 4 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ " ",
+   /* 3 */ " ",
+   /* 4 */ " ",
+   /* 5 */ " ",
+   /* 6 */ " ",
+   /* 7 */ " "
+   },
+   { /* byte 5 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ " ",
+   /* 3 */ " ",
+   /* 4 */ " ",
+   /* 5 */ " ",
+   /* 6 */ " ",
+   /* 7 */ " "
+   },

svn commit: r361157 - in stable/10: sys/netgraph/bluetooth/hci usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 08:45:24 2020
New Revision: 361157
URL: https://svnweb.freebsd.org/changeset/base/361157

Log:
  MFC r360092:
  Bring HCI error messages up-to-date.
  See Bluetooth v5.6 core specification Vol.1 Part F: Controller error codes.
  
  Submitted by: Marc Veldman 
  PR:   245737
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/netgraph/bluetooth/hci/ng_hci_misc.c
  stable/10/usr.sbin/bluetooth/hccontrol/util.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netgraph/bluetooth/hci/ng_hci_misc.c
==
--- stable/10/sys/netgraph/bluetooth/hci/ng_hci_misc.c  Mon May 18 08:44:49 
2020(r361156)
+++ stable/10/sys/netgraph/bluetooth/hci/ng_hci_misc.c  Mon May 18 08:45:24 
2020(r361157)
@@ -488,7 +488,35 @@ ng_hci_str_error(u_int16_t code)
/* 0x26 */ "Unit key used",
/* 0x27 */ "QoS is not supported",
/* 0x28 */ "Instant passed",
-   /* 0x29 */ "Paring with unit key not supported",
+   /* 0x29 */ "Pairing with unit key not supported",
+   /* 0x2a */ "Different Transaction Collision",
+   /* 0x2b */ "Unknown error (Reserved for future use)",
+   /* 0x2c */ "QoS Unacceptable Parameter",
+   /* 0x2d */ "QoS Rejected",
+   /* 0x2e */ "Channel Classification Not Supported",
+   /* 0x2f */ "Insufficient Security",
+   /* 0x30 */ "Parameter Out Of Mandatory Range",
+   /* 0x31 */ "Unknown error (Reserved for future use)",
+   /* 0x32 */ "Role Switch Pending",
+   /* 0x33 */ "Unknown error (Reserved for future use)",
+   /* 0x34 */ "Reserved Slot Violation",
+   /* 0x35 */ "Role Switch Failed",
+   /* 0x36 */ "Extended Inquiry Response Too Large",
+   /* 0x37 */ "Secure Simple Pairing Not Supported By Host",
+   /* 0x38 */ "Host Busy - Pairing",
+   /* 0x39 */ "Connection Rejected due to No Suitable Channel Found",
+   /* 0x3a */ "Controller Busy",
+   /* 0x3b */ "Unacceptable Connection Parameters",
+   /* 0x3c */ "Advertising Timeout",
+   /* 0x3d */ "Connection Terminated due to MIC Failure",
+   /* 0x3e */ "Connection Failed to be Established / Synchronization 
Timeout",
+   /* 0x3f */ "MAC Connection Failed",
+   /* 0x40 */ "Coarse Clock Adjustment Rejected but Will Try to Adjust 
Using Clock Dragging",
+   /* 0x41 */ "Type0 Submap Not Defined",
+   /* 0x42 */ "Unknown Advertising Identifier",
+   /* 0x43 */ "Limit Reached",
+   /* 0x44 */ "Operation Cancelled by Host",
+   /* 0x45 */ "Packet Too Long",
/* SHOULD ALWAYS BE LAST */ "Unknown error"
};
 

Modified: stable/10/usr.sbin/bluetooth/hccontrol/util.c
==
--- stable/10/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:44:49 
2020(r361156)
+++ stable/10/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:45:24 
2020(r361157)
@@ -426,7 +426,35 @@ hci_status2str(int status)
/* 0x26 */ "Unit key used",
/* 0x27 */ "QoS is not supported",
/* 0x28 */ "Instant passed",
-   /* 0x29 */ "Pairing with unit key not supported"
+   /* 0x29 */ "Pairing with unit key not supported",
+   /* 0x2a */ "Different Transaction Collision",
+   /* 0x2b */ "Unknown error (Reserved for future use)",
+   /* 0x2c */ "QoS Unacceptable Parameter",
+   /* 0x2d */ "QoS Rejected",
+   /* 0x2e */ "Channel Classification Not Supported",
+   /* 0x2f */ "Insufficient Security",
+   /* 0x30 */ "Parameter Out Of Mandatory Range",
+   /* 0x31 */ "Unknown error (Reserved for future use)",
+   /* 0x32 */ "Role Switch Pending",
+   /* 0x33 */ "Unknown error (Reserved for future use)",
+   /* 0x34 */ "Reserved Slot Violation",
+   /* 0x35 */ "Role Switch Failed",
+   /* 0x36 */ "Extended Inquiry Response Too Large",
+   /* 0x37 */ "Secure Simple Pairing Not Supported By Host",
+   /* 0x38 */ "Host Busy - Pairing",
+   /* 0x39 */ "Connection Rejected due to No Suitable Channel 
Found",
+   /* 0x3a */ "Controller Busy",
+   /* 0x3b */ "Unacceptable Connection Parameters",
+   /* 0x3c */ "Advertising Timeout",
+   /* 0x3d */ "Connection Terminated due to MIC Failure",
+   /* 0x3e */ "Connection Failed to be Established / 
Synchronization Timeout",
+   /* 0x3f */ "MAC Connection Failed",
+   /* 0x40 */ "Coarse Clock Adjustment Rejected but Will Try to 
Adjust Using Clock Dragging",
+   /* 0x41 */ "Type0 Submap Not Defined",
+   /* 0x42 */ "Unknown Advertising Identifier",
+   /* 0x43 */ "Limit Reached",
+ 

svn commit: r361158 - stable/12/usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 08:46:17 2020
New Revision: 361158
URL: https://svnweb.freebsd.org/changeset/base/361158

Log:
  MFC r360094:
  Improve printing of le features in hccontrol(8).
  
  Submitted by: Marc Veldman 
  PR:   245739
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/usr.sbin/bluetooth/hccontrol/hccontrol.h
  stable/12/usr.sbin/bluetooth/hccontrol/le.c
  stable/12/usr.sbin/bluetooth/hccontrol/util.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/bluetooth/hccontrol/hccontrol.h
==
--- stable/12/usr.sbin/bluetooth/hccontrol/hccontrol.h  Mon May 18 08:45:24 
2020(r361157)
+++ stable/12/usr.sbin/bluetooth/hccontrol/hccontrol.h  Mon May 18 08:46:17 
2020(r361158)
@@ -73,6 +73,7 @@ char const *  hci_ver2str (int);
 char const *   hci_lmpver2str  (int);
 char const *   hci_manufacturer2str(int);
 char const *   hci_features2str(uint8_t *, char *, int);
+char const *   hci_le_features2str (uint8_t *, char *, int);
 char const *   hci_cc2str  (int);
 char const *   hci_con_state2str   (int);
 char const *   hci_status2str  (int);

Modified: stable/12/usr.sbin/bluetooth/hccontrol/le.c
==
--- stable/12/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 08:45:24 2020
(r361157)
+++ stable/12/usr.sbin/bluetooth/hccontrol/le.c Mon May 18 08:46:17 2020
(r361158)
@@ -225,18 +225,37 @@ static int
 le_read_local_supported_features(int s, int argc ,char *argv[])
 {
ng_hci_le_read_local_supported_features_rp rp;
-   int e;
int n = sizeof(rp);
 
-   e = hci_simple_request(s,
+   union {
+   uint64_t raw;
+   uint8_t octets[8];
+   } le_features;
+
+   char buffer[2048];
+
+   if (hci_simple_request(s,
NG_HCI_OPCODE(NG_HCI_OGF_LE,
NG_HCI_OCF_LE_READ_LOCAL_SUPPORTED_FEATURES), 
-   (void *), );
+   (void *), ) == ERROR)
+   return (ERROR);
 
-   printf("LOCAL SUPPORTED: %d %d %jx\n", e, rp.status,
-  (uintmax_t) rp.le_features);
+   if (rp.status != 0x00) {
+   fprintf(stdout, "Status: %s [%#02x]\n", 
+   hci_status2str(rp.status), rp.status);
+   return (FAILED);
+   }
 
-   return 0;
+   le_features.raw = rp.le_features;
+
+   fprintf(stdout, "LE Features: ");
+   for(int i = 0; i < 8; i++)
+fprintf(stdout, " %#02x", le_features.octets[i]);
+   fprintf(stdout, "\n%s\n", hci_le_features2str(le_features.octets, 
+   buffer, sizeof(buffer)));
+   fprintf(stdout, "\n");
+
+   return OK;
 }
 
 static int

Modified: stable/12/usr.sbin/bluetooth/hccontrol/util.c
==
--- stable/12/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:45:24 
2020(r361157)
+++ stable/12/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:46:17 
2020(r361158)
@@ -371,6 +371,119 @@ done:
 } /* hci_features2str */
 
 char const *
+hci_le_features2str(uint8_t *features, char *buffer, int size)
+{
+   static char const * const t[][8] = {
+   { /* byte 0 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ " ",
+   /* 3 */ " ",
+   /* 4 */ " ",
+   /* 5 */ " ",
+   /* 6 */ " ",
+   /* 7 */ " "
+   },
+   { /* byte 1 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ " ",
+   /* 3 */ " ",
+   /* 4 */ " ",
+   /* 5 */ " ",
+   /* 6 */ " ",
+   /* 7 */ " "
+   },
+   { /* byte 2 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ " ",
+   /* 3 */ " ",
+   /* 4 */ " ",
+   /* 5 */ " ",
+   /* 6 */ " ",
+   /* 7 */ " "
+   },
+   { /* byte 3 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ " ",
+   /* 3 */ " ",
+   /* 4 */ " ",
+   /* 5 */ " ",
+   /* 6 */ " ",
+   /* 7 */ " "
+   },
+   { /* byte 4 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ " ",
+   /* 3 */ " ",
+   /* 4 */ " ",
+   /* 5 */ " ",
+   /* 6 */ " ",
+   /* 7 */ " "
+   },
+   { /* byte 5 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ " ",
+   /* 3 */ " ",
+   /* 4 */ " ",
+   /* 5 */ " ",
+   /* 6 */ " ",
+   /* 7 */ " "
+   },

svn commit: r361156 - in stable/11: sys/netgraph/bluetooth/hci usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 08:44:49 2020
New Revision: 361156
URL: https://svnweb.freebsd.org/changeset/base/361156

Log:
  MFC r360092:
  Bring HCI error messages up-to-date.
  See Bluetooth v5.6 core specification Vol.1 Part F: Controller error codes.
  
  Submitted by: Marc Veldman 
  PR:   245737
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/netgraph/bluetooth/hci/ng_hci_misc.c
  stable/11/usr.sbin/bluetooth/hccontrol/util.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netgraph/bluetooth/hci/ng_hci_misc.c
==
--- stable/11/sys/netgraph/bluetooth/hci/ng_hci_misc.c  Mon May 18 08:44:16 
2020(r361155)
+++ stable/11/sys/netgraph/bluetooth/hci/ng_hci_misc.c  Mon May 18 08:44:49 
2020(r361156)
@@ -489,7 +489,35 @@ ng_hci_str_error(u_int16_t code)
/* 0x26 */ "Unit key used",
/* 0x27 */ "QoS is not supported",
/* 0x28 */ "Instant passed",
-   /* 0x29 */ "Paring with unit key not supported",
+   /* 0x29 */ "Pairing with unit key not supported",
+   /* 0x2a */ "Different Transaction Collision",
+   /* 0x2b */ "Unknown error (Reserved for future use)",
+   /* 0x2c */ "QoS Unacceptable Parameter",
+   /* 0x2d */ "QoS Rejected",
+   /* 0x2e */ "Channel Classification Not Supported",
+   /* 0x2f */ "Insufficient Security",
+   /* 0x30 */ "Parameter Out Of Mandatory Range",
+   /* 0x31 */ "Unknown error (Reserved for future use)",
+   /* 0x32 */ "Role Switch Pending",
+   /* 0x33 */ "Unknown error (Reserved for future use)",
+   /* 0x34 */ "Reserved Slot Violation",
+   /* 0x35 */ "Role Switch Failed",
+   /* 0x36 */ "Extended Inquiry Response Too Large",
+   /* 0x37 */ "Secure Simple Pairing Not Supported By Host",
+   /* 0x38 */ "Host Busy - Pairing",
+   /* 0x39 */ "Connection Rejected due to No Suitable Channel Found",
+   /* 0x3a */ "Controller Busy",
+   /* 0x3b */ "Unacceptable Connection Parameters",
+   /* 0x3c */ "Advertising Timeout",
+   /* 0x3d */ "Connection Terminated due to MIC Failure",
+   /* 0x3e */ "Connection Failed to be Established / Synchronization 
Timeout",
+   /* 0x3f */ "MAC Connection Failed",
+   /* 0x40 */ "Coarse Clock Adjustment Rejected but Will Try to Adjust 
Using Clock Dragging",
+   /* 0x41 */ "Type0 Submap Not Defined",
+   /* 0x42 */ "Unknown Advertising Identifier",
+   /* 0x43 */ "Limit Reached",
+   /* 0x44 */ "Operation Cancelled by Host",
+   /* 0x45 */ "Packet Too Long",
/* SHOULD ALWAYS BE LAST */ "Unknown error"
};
 

Modified: stable/11/usr.sbin/bluetooth/hccontrol/util.c
==
--- stable/11/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:44:16 
2020(r361155)
+++ stable/11/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:44:49 
2020(r361156)
@@ -439,7 +439,35 @@ hci_status2str(int status)
/* 0x26 */ "Unit key used",
/* 0x27 */ "QoS is not supported",
/* 0x28 */ "Instant passed",
-   /* 0x29 */ "Pairing with unit key not supported"
+   /* 0x29 */ "Pairing with unit key not supported",
+   /* 0x2a */ "Different Transaction Collision",
+   /* 0x2b */ "Unknown error (Reserved for future use)",
+   /* 0x2c */ "QoS Unacceptable Parameter",
+   /* 0x2d */ "QoS Rejected",
+   /* 0x2e */ "Channel Classification Not Supported",
+   /* 0x2f */ "Insufficient Security",
+   /* 0x30 */ "Parameter Out Of Mandatory Range",
+   /* 0x31 */ "Unknown error (Reserved for future use)",
+   /* 0x32 */ "Role Switch Pending",
+   /* 0x33 */ "Unknown error (Reserved for future use)",
+   /* 0x34 */ "Reserved Slot Violation",
+   /* 0x35 */ "Role Switch Failed",
+   /* 0x36 */ "Extended Inquiry Response Too Large",
+   /* 0x37 */ "Secure Simple Pairing Not Supported By Host",
+   /* 0x38 */ "Host Busy - Pairing",
+   /* 0x39 */ "Connection Rejected due to No Suitable Channel 
Found",
+   /* 0x3a */ "Controller Busy",
+   /* 0x3b */ "Unacceptable Connection Parameters",
+   /* 0x3c */ "Advertising Timeout",
+   /* 0x3d */ "Connection Terminated due to MIC Failure",
+   /* 0x3e */ "Connection Failed to be Established / 
Synchronization Timeout",
+   /* 0x3f */ "MAC Connection Failed",
+   /* 0x40 */ "Coarse Clock Adjustment Rejected but Will Try to 
Adjust Using Clock Dragging",
+   /* 0x41 */ "Type0 Submap Not Defined",
+   /* 0x42 */ "Unknown Advertising Identifier",
+   /* 0x43 */ "Limit Reached",
+ 

svn commit: r361155 - in stable/12: sys/netgraph/bluetooth/hci usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 08:44:16 2020
New Revision: 361155
URL: https://svnweb.freebsd.org/changeset/base/361155

Log:
  MFC r360092:
  Bring HCI error messages up-to-date.
  See Bluetooth v5.6 core specification Vol.1 Part F: Controller error codes.
  
  Submitted by: Marc Veldman 
  PR:   245737
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/sys/netgraph/bluetooth/hci/ng_hci_misc.c
  stable/12/usr.sbin/bluetooth/hccontrol/util.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/netgraph/bluetooth/hci/ng_hci_misc.c
==
--- stable/12/sys/netgraph/bluetooth/hci/ng_hci_misc.c  Mon May 18 08:43:05 
2020(r361154)
+++ stable/12/sys/netgraph/bluetooth/hci/ng_hci_misc.c  Mon May 18 08:44:16 
2020(r361155)
@@ -491,7 +491,35 @@ ng_hci_str_error(u_int16_t code)
/* 0x26 */ "Unit key used",
/* 0x27 */ "QoS is not supported",
/* 0x28 */ "Instant passed",
-   /* 0x29 */ "Paring with unit key not supported",
+   /* 0x29 */ "Pairing with unit key not supported",
+   /* 0x2a */ "Different Transaction Collision",
+   /* 0x2b */ "Unknown error (Reserved for future use)",
+   /* 0x2c */ "QoS Unacceptable Parameter",
+   /* 0x2d */ "QoS Rejected",
+   /* 0x2e */ "Channel Classification Not Supported",
+   /* 0x2f */ "Insufficient Security",
+   /* 0x30 */ "Parameter Out Of Mandatory Range",
+   /* 0x31 */ "Unknown error (Reserved for future use)",
+   /* 0x32 */ "Role Switch Pending",
+   /* 0x33 */ "Unknown error (Reserved for future use)",
+   /* 0x34 */ "Reserved Slot Violation",
+   /* 0x35 */ "Role Switch Failed",
+   /* 0x36 */ "Extended Inquiry Response Too Large",
+   /* 0x37 */ "Secure Simple Pairing Not Supported By Host",
+   /* 0x38 */ "Host Busy - Pairing",
+   /* 0x39 */ "Connection Rejected due to No Suitable Channel Found",
+   /* 0x3a */ "Controller Busy",
+   /* 0x3b */ "Unacceptable Connection Parameters",
+   /* 0x3c */ "Advertising Timeout",
+   /* 0x3d */ "Connection Terminated due to MIC Failure",
+   /* 0x3e */ "Connection Failed to be Established / Synchronization 
Timeout",
+   /* 0x3f */ "MAC Connection Failed",
+   /* 0x40 */ "Coarse Clock Adjustment Rejected but Will Try to Adjust 
Using Clock Dragging",
+   /* 0x41 */ "Type0 Submap Not Defined",
+   /* 0x42 */ "Unknown Advertising Identifier",
+   /* 0x43 */ "Limit Reached",
+   /* 0x44 */ "Operation Cancelled by Host",
+   /* 0x45 */ "Packet Too Long",
/* SHOULD ALWAYS BE LAST */ "Unknown error"
};
 

Modified: stable/12/usr.sbin/bluetooth/hccontrol/util.c
==
--- stable/12/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:43:05 
2020(r361154)
+++ stable/12/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:44:16 
2020(r361155)
@@ -439,7 +439,35 @@ hci_status2str(int status)
/* 0x26 */ "Unit key used",
/* 0x27 */ "QoS is not supported",
/* 0x28 */ "Instant passed",
-   /* 0x29 */ "Pairing with unit key not supported"
+   /* 0x29 */ "Pairing with unit key not supported",
+   /* 0x2a */ "Different Transaction Collision",
+   /* 0x2b */ "Unknown error (Reserved for future use)",
+   /* 0x2c */ "QoS Unacceptable Parameter",
+   /* 0x2d */ "QoS Rejected",
+   /* 0x2e */ "Channel Classification Not Supported",
+   /* 0x2f */ "Insufficient Security",
+   /* 0x30 */ "Parameter Out Of Mandatory Range",
+   /* 0x31 */ "Unknown error (Reserved for future use)",
+   /* 0x32 */ "Role Switch Pending",
+   /* 0x33 */ "Unknown error (Reserved for future use)",
+   /* 0x34 */ "Reserved Slot Violation",
+   /* 0x35 */ "Role Switch Failed",
+   /* 0x36 */ "Extended Inquiry Response Too Large",
+   /* 0x37 */ "Secure Simple Pairing Not Supported By Host",
+   /* 0x38 */ "Host Busy - Pairing",
+   /* 0x39 */ "Connection Rejected due to No Suitable Channel 
Found",
+   /* 0x3a */ "Controller Busy",
+   /* 0x3b */ "Unacceptable Connection Parameters",
+   /* 0x3c */ "Advertising Timeout",
+   /* 0x3d */ "Connection Terminated due to MIC Failure",
+   /* 0x3e */ "Connection Failed to be Established / 
Synchronization Timeout",
+   /* 0x3f */ "MAC Connection Failed",
+   /* 0x40 */ "Coarse Clock Adjustment Rejected but Will Try to 
Adjust Using Clock Dragging",
+   /* 0x41 */ "Type0 Submap Not Defined",
+   /* 0x42 */ "Unknown Advertising Identifier",
+   /* 0x43 */ "Limit Reached",
+ 

svn commit: r361154 - stable/10/usr.sbin/bluetooth/hccontrol

2020-05-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 18 08:43:05 2020
New Revision: 361154
URL: https://svnweb.freebsd.org/changeset/base/361154

Log:
  MFC r360070:
  Add missing feature descriptions to hci_features2str().
  
  The list of possible features in hccontrol/features2str() is incomplete.
  Refer to "Bluetooth Core Specification 5.2 Vol. 2 Part C. 3.3 Feature Mask 
Definition".
  
  Submitted by: Marc Veldman 
  PR:   245354
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/usr.sbin/bluetooth/hccontrol/info.c
  stable/10/usr.sbin/bluetooth/hccontrol/link_control.c
  stable/10/usr.sbin/bluetooth/hccontrol/node.c
  stable/10/usr.sbin/bluetooth/hccontrol/util.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/bluetooth/hccontrol/info.c
==
--- stable/10/usr.sbin/bluetooth/hccontrol/info.c   Mon May 18 08:42:10 
2020(r361153)
+++ stable/10/usr.sbin/bluetooth/hccontrol/info.c   Mon May 18 08:43:05 
2020(r361154)
@@ -75,7 +75,7 @@ hci_read_local_supported_features(int s, int argc, cha
 {
ng_hci_read_local_features_rp   rp;
int n;
-   charbuffer[1024];
+   charbuffer[2048];
 
n = sizeof(rp);
if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_INFO,

Modified: stable/10/usr.sbin/bluetooth/hccontrol/link_control.c
==
--- stable/10/usr.sbin/bluetooth/hccontrol/link_control.c   Mon May 18 
08:42:10 2020(r361153)
+++ stable/10/usr.sbin/bluetooth/hccontrol/link_control.c   Mon May 18 
08:43:05 2020(r361154)
@@ -609,7 +609,7 @@ hci_read_remote_supported_features(int s, int argc, ch
char b[512];
ng_hci_read_remote_features_cp   cp;
ng_hci_event_pkt_t  *e = (ng_hci_event_pkt_t *) b; 
-   char buffer[1024];
+   char buffer[2048];
 
/* parse command parameters */
switch (argc) {

Modified: stable/10/usr.sbin/bluetooth/hccontrol/node.c
==
--- stable/10/usr.sbin/bluetooth/hccontrol/node.c   Mon May 18 08:42:10 
2020(r361153)
+++ stable/10/usr.sbin/bluetooth/hccontrol/node.c   Mon May 18 08:43:05 
2020(r361154)
@@ -150,7 +150,7 @@ hci_read_node_features(int s, int argc, char **argv)
 {
struct ng_btsocket_hci_raw_node_featuresr;
int n;
-   charbuffer[1024];
+   charbuffer[2048];
 
memset(, 0, sizeof(r));
if (ioctl(s, SIOC_HCI_RAW_NODE_GET_FEATURES, , sizeof(r)) < 0)

Modified: stable/10/usr.sbin/bluetooth/hccontrol/util.c
==
--- stable/10/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:42:10 
2020(r361153)
+++ stable/10/usr.sbin/bluetooth/hccontrol/util.c   Mon May 18 08:43:05 
2020(r361154)
@@ -276,7 +276,57 @@ hci_features2str(uint8_t *features, char *buffer, int 
/* 4 */ " ",
/* 5 */ " ",
/* 6 */ " ",
-   /* 7 */ " "
+   /* 7 */ " "
+   },
+   { /* byte 3 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ " ",
+   /* 3 */ " ",
+   /* 4 */ " ",
+   /* 5 */ " ",
+   /* 6 */ " ",
+   /* 7 */ " "
+   },
+   { /* byte 4 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ " ",
+   /* 3 */ " ",
+   /* 4 */ " ",
+   /* 5 */ " ",
+   /* 6 */ " ",
+   /* 7 */ "<3-Slot EDR ACL packets> "
+   },
+   { /* byte 5 */
+   /* 0 */ "<5-Slot EDR ACL packets> ",
+   /* 1 */ " ",
+   /* 2 */ " ",
+   /* 3 */ " ",
+   /* 4 */ " ",
+   /* 5 */ " ",
+   /* 6 */ " ",
+   /* 7 */ "<3-Slot EDR eSCO packets> "
+   },
+   { /* byte 6 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ " ",
+   /* 3 */ " ",
+   /* 4 */ " ",
+   /* 5 */ " ",
+   /* 6 */ " ",
+   /* 7 */ " "
+   },
+   { /* byte 7 */
+   /* 0 */ " ",
+   /* 1 */ " ",
+   /* 2 */ " ",
+   /* 3 */ " ",
+   /* 4 */ " ",
+   /* 5 */ " ",
+   /* 6 */ " ",
+   /* 7 */ " "
}};
 
if (buffer != NULL && size > 0) {

  1   2   >