svn commit: r368505 - stable/10/sbin/ifconfig

2020-12-10 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Dec 10 09:39:27 2020
New Revision: 368505
URL: https://svnweb.freebsd.org/changeset/base/368505

Log:
  Fix bug in ifconfig regarding VLAN creation.
  
  Detection of VLAN interface type must happen before detection of
  interface type by prefix. Else the following sequence of commands will
  try to create a LAGG interface instead of a VLAN interface, which
  accidentially works, because the data pointed to by the ifr_data
  pointer is not parsed by the VLAN create ioctl(2).
  
  How to reproduce:
  # ifconfig lagg0 create
  # ifconfig lagg0.256 create
  
  This is a direct commit.
  
  Differential Revision:https://reviews.freebsd.org/D27521
  Tested by:raul.mu...@custos.es
  Sponsored by: Mellanox Technologies // NVIDIA Networking

Modified:
  stable/10/sbin/ifconfig/ifclone.c

Modified: stable/10/sbin/ifconfig/ifclone.c
==
--- stable/10/sbin/ifconfig/ifclone.c   Thu Dec 10 09:37:06 2020
(r368504)
+++ stable/10/sbin/ifconfig/ifclone.c   Thu Dec 10 09:39:27 2020
(r368505)
@@ -122,6 +122,7 @@ ifclonecreate(int s, void *arg)
struct ifreq ifr;
struct clone_defcb *dcp;
clone_callback_func *clone_cb = NULL;
+   const char *ifr_name = strchr(name, '.') ? "vlan" : name;
 
memset(, 0, sizeof(ifr));
(void) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
@@ -129,7 +130,7 @@ ifclonecreate(int s, void *arg)
if (clone_cb == NULL) {
/* Try to find a default callback */
SLIST_FOREACH(dcp, _defcbh, next) {
-   if (strncmp(dcp->ifprefix, ifr.ifr_name,
+   if (strncmp(dcp->ifprefix, ifr_name,
strlen(dcp->ifprefix)) == 0) {
clone_cb = dcp->clone_cb;
break;
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r362313 - stable/10/sys/dev/mlx5/mlx5_en

2020-06-18 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Jun 18 10:41:51 2020
New Revision: 362313
URL: https://svnweb.freebsd.org/changeset/base/362313

Log:
  MFC r362045:
  Make sure packets generated by raw IP code is let through by mlx5en(4).
  
  Allow the TCP header to reside in the mbuf following the IP header.
  Else such packets will get dropped.
  
  Backtrace:
  mlx5e_sq_xmit()
  mlx5e_xmit()
  ether_output_frame()
  ether_output()
  ip_output_send()
  ip_output()
  rip_output()
  sosend_generic()
  sosend()
  kern_sendit()
  sendit()
  sys_sendto()
  amd64_syscall()
  fast_syscall_common()
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
==
--- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Thu Jun 18 10:40:16 2020
(r362312)
+++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Thu Jun 18 10:41:51 2020
(r362313)
@@ -228,9 +228,15 @@ mlx5e_get_header_size(const struct mbuf *mb)
default:
return (0);
}
-   if (unlikely(mb->m_len < eth_hdr_len + sizeof(*th)))
-   return (0);
-   th = (const struct tcphdr *)(mb->m_data + eth_hdr_len);
+   if (unlikely(mb->m_len < eth_hdr_len + sizeof(*th))) {
+   const struct mbuf *m_th = mb->m_next;
+   if (unlikely(mb->m_len != eth_hdr_len ||
+   m_th == NULL || m_th->m_len < sizeof(*th)))
+   return (0);
+   th = (const struct tcphdr *)(m_th->m_data);
+   } else {
+   th = (const struct tcphdr *)(mb->m_data + eth_hdr_len);
+   }
tcp_hlen = th->th_off << 2;
eth_hdr_len += tcp_hlen;
/*
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r362310 - stable/10/sys/dev/mlx5/mlx5_en

2020-06-18 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Jun 18 10:31:21 2020
New Revision: 362310
URL: https://svnweb.freebsd.org/changeset/base/362310

Log:
  MFC r362044:
  Extend use of unlikely() in the fast path, in mlx5en(4).
  
  Typically the TCP/IP headers fit within the first mbuf and should not
  trigger any of the error cases. Use unlikely() for these cases.
  
  No functional change.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
==
--- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Thu Jun 18 10:20:16 2020
(r362309)
+++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Thu Jun 18 10:31:21 2020
(r362310)
@@ -196,21 +196,21 @@ mlx5e_get_header_size(const struct mbuf *mb)
int eth_hdr_len;
 
eh = mtod(mb, const struct ether_vlan_header *);
-   if (mb->m_len < ETHER_HDR_LEN)
+   if (unlikely(mb->m_len < ETHER_HDR_LEN))
return (0);
if (eh->evl_encap_proto == htons(ETHERTYPE_VLAN)) {
+   if (unlikely(mb->m_len < (ETHER_HDR_LEN + 
ETHER_VLAN_ENCAP_LEN)))
+   return (0);
eth_type = ntohs(eh->evl_proto);
eth_hdr_len = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN;
} else {
eth_type = ntohs(eh->evl_encap_proto);
eth_hdr_len = ETHER_HDR_LEN;
}
-   if (mb->m_len < eth_hdr_len)
-   return (0);
switch (eth_type) {
case ETHERTYPE_IP:
ip = (const struct ip *)(mb->m_data + eth_hdr_len);
-   if (mb->m_len < eth_hdr_len + sizeof(*ip))
+   if (unlikely(mb->m_len < eth_hdr_len + sizeof(*ip)))
return (0);
if (ip->ip_p != IPPROTO_TCP)
return (0);
@@ -219,7 +219,7 @@ mlx5e_get_header_size(const struct mbuf *mb)
break;
case ETHERTYPE_IPV6:
ip6 = (const struct ip6_hdr *)(mb->m_data + eth_hdr_len);
-   if (mb->m_len < eth_hdr_len + sizeof(*ip6))
+   if (unlikely(mb->m_len < eth_hdr_len + sizeof(*ip6)))
return (0);
if (ip6->ip6_nxt != IPPROTO_TCP)
return (0);
@@ -228,12 +228,17 @@ mlx5e_get_header_size(const struct mbuf *mb)
default:
return (0);
}
-   if (mb->m_len < eth_hdr_len + sizeof(*th))
+   if (unlikely(mb->m_len < eth_hdr_len + sizeof(*th)))
return (0);
th = (const struct tcphdr *)(mb->m_data + eth_hdr_len);
tcp_hlen = th->th_off << 2;
eth_hdr_len += tcp_hlen;
-   if (mb->m_len < eth_hdr_len)
+   /*
+* m_copydata() will be used on the remaining header which
+* does not need to reside within the first m_len bytes of
+* data:
+*/
+   if (unlikely(mb->m_pkthdr.len < eth_hdr_len))
return (0);
return (eth_hdr_len);
 }
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r362307 - stable/10/sys/dev/mlx5/mlx5_en

2020-06-18 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Jun 18 10:17:36 2020
New Revision: 362307
URL: https://svnweb.freebsd.org/changeset/base/362307

Log:
  MFC r362043:
  Use const keyword when parsing the TCP/IP header in the fast path in 
mlx5en(4).
  
  When parsing the TCP/IP header in the fast path, make it clear by using
  the const keyword, no fields are to be modified inside the transmitted
  packet.
  
  No functional change.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
==
--- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Thu Jun 18 10:12:17 2020
(r362306)
+++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Thu Jun 18 10:17:36 2020
(r362307)
@@ -176,18 +176,26 @@ mlx5e_get_inline_hdr_size(struct mlx5e_sq *sq, struct 
return (MIN(sq->max_inline, mb->m_pkthdr.len));
 }
 
+/*
+ * This function parse IPv4 and IPv6 packets looking for TCP and UDP
+ * headers.
+ *
+ * The return value indicates the number of bytes from the beginning
+ * of the packet until the first byte after the TCP or UDP header. If
+ * this function returns zero, the parsing failed.
+ */
 static int
-mlx5e_get_header_size(struct mbuf *mb)
+mlx5e_get_header_size(const struct mbuf *mb)
 {
-   struct ether_vlan_header *eh;
-   struct tcphdr *th;
-   struct ip *ip;
+   const struct ether_vlan_header *eh;
+   const struct tcphdr *th;
+   const struct ip *ip;
int ip_hlen, tcp_hlen;
-   struct ip6_hdr *ip6;
+   const struct ip6_hdr *ip6;
uint16_t eth_type;
int eth_hdr_len;
 
-   eh = mtod(mb, struct ether_vlan_header *);
+   eh = mtod(mb, const struct ether_vlan_header *);
if (mb->m_len < ETHER_HDR_LEN)
return (0);
if (eh->evl_encap_proto == htons(ETHERTYPE_VLAN)) {
@@ -201,7 +209,7 @@ mlx5e_get_header_size(struct mbuf *mb)
return (0);
switch (eth_type) {
case ETHERTYPE_IP:
-   ip = (struct ip *)(mb->m_data + eth_hdr_len);
+   ip = (const struct ip *)(mb->m_data + eth_hdr_len);
if (mb->m_len < eth_hdr_len + sizeof(*ip))
return (0);
if (ip->ip_p != IPPROTO_TCP)
@@ -210,7 +218,7 @@ mlx5e_get_header_size(struct mbuf *mb)
eth_hdr_len += ip_hlen;
break;
case ETHERTYPE_IPV6:
-   ip6 = (struct ip6_hdr *)(mb->m_data + eth_hdr_len);
+   ip6 = (const struct ip6_hdr *)(mb->m_data + eth_hdr_len);
if (mb->m_len < eth_hdr_len + sizeof(*ip6))
return (0);
if (ip6->ip6_nxt != IPPROTO_TCP)
@@ -222,7 +230,7 @@ mlx5e_get_header_size(struct mbuf *mb)
}
if (mb->m_len < eth_hdr_len + sizeof(*th))
return (0);
-   th = (struct tcphdr *)(mb->m_data + eth_hdr_len);
+   th = (const struct tcphdr *)(mb->m_data + eth_hdr_len);
tcp_hlen = th->th_off << 2;
eth_hdr_len += tcp_hlen;
if (mb->m_len < eth_hdr_len)
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r362168 - stable/10/sys/dev/usb/net

2020-06-13 Thread Hans Petter Selasky
Author: hselasky
Date: Sun Jun 14 05:33:25 2020
New Revision: 362168
URL: https://svnweb.freebsd.org/changeset/base/362168

Log:
  MFC r362056:
  Add missing range checks when receiving USB ethernet packets.
  
  Found by: Ilja Van Sprundel, IOActive
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/net/if_smsc.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/net/if_smsc.c
==
--- stable/10/sys/dev/usb/net/if_smsc.c Sun Jun 14 05:27:37 2020
(r362167)
+++ stable/10/sys/dev/usb/net/if_smsc.c Sun Jun 14 05:33:25 2020
(r362168)
@@ -949,7 +949,7 @@ smsc_bulk_read_callback(struct usb_xfer *xfer, usb_err
struct mbuf *m;
struct usb_page_cache *pc;
uint32_t rxhdr;
-   uint16_t pktlen;
+   int pktlen;
int off;
int actlen;
 
@@ -975,6 +975,9 @@ smsc_bulk_read_callback(struct usb_xfer *xfer, usb_err
/* The frame header is always aligned on a 4 byte 
boundary */
off = ((off + 0x3) & ~0x3);
 
+   if ((off + sizeof(rxhdr)) > actlen)
+   goto tr_setup;
+
usbd_copy_out(pc, off, , sizeof(rxhdr));
off += (sizeof(rxhdr) + ETHER_ALIGN);
rxhdr = le32toh(rxhdr);
@@ -1003,7 +1006,13 @@ smsc_bulk_read_callback(struct usb_xfer *xfer, usb_err
ifp->if_iqdrops++;
goto tr_setup;
}
-   
+   if (pktlen > m->m_len) {
+   smsc_dbg_printf(sc, "buffer too small 
%d vs %d bytes",
+   pktlen, m->m_len);
+   if_inc_counter(ifp, IFCOUNTER_IQDROPS, 
1);
+   m_freem(m);
+   goto tr_setup;
+   }
usbd_copy_out(pc, off, mtod(m, uint8_t *), 
pktlen);
 
/* Check if RX TCP/UDP checksumming is being 
offloaded */
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r361921 - in stable/10: lib/libusbhid sys/dev/usb

2020-06-08 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jun  8 09:34:16 2020
New Revision: 361921
URL: https://svnweb.freebsd.org/changeset/base/361921

Log:
  MFC r361827:
  USB HID descriptors may push/pop the current state to allow
  description of items residing in a so-called union. FreeBSD currently
  only supports 4 such push levels.
  
  If the push level is not restored within the processing of the same
  HID item, an invalid memory location may be used for subsequent HID
  item processing.
  
  Verify that the push level is always valid when processing HID items.
  
  Reported by:  Andy Nguyen (Google)
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/lib/libusbhid/parse.c
  stable/10/sys/dev/usb/usb_hid.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libusbhid/parse.c
==
--- stable/10/lib/libusbhid/parse.c Mon Jun  8 09:33:45 2020
(r361920)
+++ stable/10/lib/libusbhid/parse.c Mon Jun  8 09:34:16 2020
(r361921)
@@ -401,26 +401,28 @@ hid_get_item_raw(hid_data_t s, hid_item_t *h)
s->loc_count = dval & mask;
break;
case 10:/* Push */
+   /* stop parsing, if invalid push level */
+   if ((s->pushlevel + 1) >= MAXPUSH)
+   return (0);
s->pushlevel ++;
-   if (s->pushlevel < MAXPUSH) {
-   s->cur[s->pushlevel] = *c;
-   /* store size and count */
-   c->report_size = s->loc_size;
-   c->report_count = s->loc_count;
-   /* update current item pointer */
-   c = >cur[s->pushlevel];
-   }
+   s->cur[s->pushlevel] = *c;
+   /* store size and count */
+   c->report_size = s->loc_size;
+   c->report_count = s->loc_count;
+   /* update current item pointer */
+   c = >cur[s->pushlevel];
break;
case 11:/* Pop */
+   /* stop parsing, if invalid push level */
+   if (s->pushlevel == 0)
+   return (0);
s->pushlevel --;
-   if (s->pushlevel < MAXPUSH) {
-   c = >cur[s->pushlevel];
-   /* restore size and count */
-   s->loc_size = c->report_size;
-   s->loc_count = c->report_count;
-   c->report_size = 0;
-   c->report_count = 0;
-   }
+   c = >cur[s->pushlevel];
+   /* restore size and count */
+   s->loc_size = c->report_size;
+   s->loc_count = c->report_count;
+   c->report_size = 0;
+   c->report_count = 0;
break;
default:
break;

Modified: stable/10/sys/dev/usb/usb_hid.c
==
--- stable/10/sys/dev/usb/usb_hid.c Mon Jun  8 09:33:45 2020
(r361920)
+++ stable/10/sys/dev/usb/usb_hid.c Mon Jun  8 09:34:16 2020
(r361921)
@@ -434,36 +434,36 @@ hid_get_item(struct hid_data *s, struct hid_item *h)
s->loc_count = dval & mask;
break;
case 10:/* Push */
-   s->pushlevel ++;
-   if (s->pushlevel < MAXPUSH) {
-   s->cur[s->pushlevel] = *c;
-   /* store size and count */
-   c->loc.size = s->loc_size;
-   c->loc.count = s->loc_count;
-   /* update current item pointer */
-   c = >cur[s->pushlevel];
-   } else {
-   DPRINTFN(0, "Cannot push "
-   "item @ %d\n", s->pushlevel);
+   /* stop parsing, if invalid push level */
+   if ((s->pushlevel + 1) 

svn commit: r361916 - stable/10/sys/netgraph/bluetooth/drivers/ubt

2020-06-08 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jun  8 09:31:14 2020
New Revision: 361916
URL: https://svnweb.freebsd.org/changeset/base/361916

Log:
  MFC r361582:
  Fix check for wMaxPacketSize in USB bluetooth driver,
  in case device is not FULL speed.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
==
--- stable/10/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c   Mon Jun  8 
09:30:43 2020(r361915)
+++ stable/10/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c   Mon Jun  8 
09:31:14 2020(r361916)
@@ -540,7 +540,7 @@ ubt_attach(device_t dev)
struct usb_endpoint_descriptor  *ed;
struct usb_interface_descriptor *id;
struct usb_interface*iface;
-   uint16_twMaxPacketSize;
+   uint32_twMaxPacketSize;
uint8_t alt_index, i, j;
uint8_t iface_index[2] = { 0, 1 };
 
@@ -630,9 +630,10 @@ ubt_attach(device_t dev)
if ((ed->bDescriptorType == UDESC_ENDPOINT) &&
(ed->bLength >= sizeof(*ed)) &&
(i == 1)) {
-   uint16_t temp;
+   uint32_t temp;
 
-   temp = UGETW(ed->wMaxPacketSize);
+   temp = usbd_get_max_frame_length(
+   ed, NULL, usbd_get_speed(uaa->device));
if (temp > wMaxPacketSize) {
wMaxPacketSize = temp;
alt_index = j;
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r361912 - stable/10/sys/dev/usb

2020-06-08 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jun  8 09:28:26 2020
New Revision: 361912
URL: https://svnweb.freebsd.org/changeset/base/361912

Log:
  MFC r361581:
  Implement helper function, usbd_get_max_frame_length(), which allows kernel
  device drivers to correctly predict the default USB transfer frame length.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/usb_transfer.c
  stable/10/sys/dev/usb/usbdi.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/usb_transfer.c
==
--- stable/10/sys/dev/usb/usb_transfer.cMon Jun  8 09:27:48 2020
(r361911)
+++ stable/10/sys/dev/usb/usb_transfer.cMon Jun  8 09:28:26 2020
(r361912)
@@ -373,6 +373,81 @@ usbd_transfer_setup_sub_malloc(struct usb_setup_params
 #endif
 
 /**
+ * usbd_get_max_frame_length
+ *
+ * This function returns the maximum single frame length as computed by
+ * usbd_transfer_setup(). It is useful when computing buffer sizes for
+ * devices having multiple alternate settings. The SuperSpeed endpoint
+ * companion pointer is allowed to be NULL.
+ **/
+uint32_t
+usbd_get_max_frame_length(const struct usb_endpoint_descriptor *edesc,
+const struct usb_endpoint_ss_comp_descriptor *ecomp,
+enum usb_dev_speed speed)
+{
+   uint32_t max_packet_size;
+   uint32_t max_packet_count;
+   uint8_t type;
+
+   max_packet_size = UGETW(edesc->wMaxPacketSize);
+   max_packet_count = 1;
+   type = (edesc->bmAttributes & UE_XFERTYPE);
+
+   switch (speed) {
+   case USB_SPEED_HIGH:
+   switch (type) {
+   case UE_ISOCHRONOUS:
+   case UE_INTERRUPT:
+   max_packet_count +=
+   (max_packet_size >> 11) & 3;
+
+   /* check for invalid max packet count */
+   if (max_packet_count > 3)
+   max_packet_count = 3;
+   break;
+   default:
+   break;
+   }
+   max_packet_size &= 0x7FF;
+   break;
+   case USB_SPEED_SUPER:
+   max_packet_count += (max_packet_size >> 11) & 3;
+
+   if (ecomp != NULL)
+   max_packet_count += ecomp->bMaxBurst;
+
+   if ((max_packet_count == 0) || 
+   (max_packet_count > 16))
+   max_packet_count = 16;
+
+   switch (type) {
+   case UE_CONTROL:
+   max_packet_count = 1;
+   break;
+   case UE_ISOCHRONOUS:
+   if (ecomp != NULL) {
+   uint8_t mult;
+
+   mult = UE_GET_SS_ISO_MULT(
+   ecomp->bmAttributes) + 1;
+   if (mult > 3)
+   mult = 3;
+
+   max_packet_count *= mult;
+   }
+   break;
+   default:
+   break;
+   }
+   max_packet_size &= 0x7FF;
+   break;
+   default:
+   break;
+   }
+   return (max_packet_size * max_packet_count);
+}
+
+/**
  * usbd_transfer_setup_sub - transfer setup subroutine
  *
  * This function must be called from the "xfer_setup" callback of the

Modified: stable/10/sys/dev/usb/usbdi.h
==
--- stable/10/sys/dev/usb/usbdi.h   Mon Jun  8 09:27:48 2020
(r361911)
+++ stable/10/sys/dev/usb/usbdi.h   Mon Jun  8 09:28:26 2020
(r361912)
@@ -519,6 +519,9 @@ uint8_t usbd_get_interface_altindex(struct usb_interfa
 usb_error_t usbd_set_alt_interface_index(struct usb_device *udev,
uint8_t iface_index, uint8_t alt_index);
 uint32_t usbd_get_isoc_fps(struct usb_device *udev);
+uint32_t usbd_get_max_frame_length(const struct usb_endpoint_descriptor *,
+const struct usb_endpoint_ss_comp_descriptor *,
+enum usb_dev_speed);
 usb_error_t usbd_transfer_setup(struct usb_device *udev,
const uint8_t *ifaces, struct usb_xfer **pxfer,
const struct usb_config *setup_start, uint16_t n_setup,
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r361908 - stable/10/sys/dev/usb

2020-06-08 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jun  8 09:25:01 2020
New Revision: 361908
URL: https://svnweb.freebsd.org/changeset/base/361908

Log:
  MFC r361577:
  Don't allow USB device drivers to parent own interface.
  It will prevent proper USB device detach.
  
  Sponsored by: Mellanox Technologies

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

Modified: stable/10/sys/dev/usb/usb_device.c
==
--- stable/10/sys/dev/usb/usb_device.c  Mon Jun  8 09:24:28 2020
(r361907)
+++ stable/10/sys/dev/usb/usb_device.c  Mon Jun  8 09:25:01 2020
(r361908)
@@ -1274,7 +1274,7 @@ usbd_set_parent_iface(struct usb_device *udev, uint8_t
 {
struct usb_interface *iface;
 
-   if (udev == NULL) {
+   if (udev == NULL || iface_index == parent_index) {
/* nothing to do */
return;
}
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


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: 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) {

svn commit: r360335 - stable/10/sys/dev/usb/controller

2020-04-26 Thread Hans Petter Selasky
Author: hselasky
Date: Sun Apr 26 08:38:10 2020
New Revision: 360335
URL: https://svnweb.freebsd.org/changeset/base/360335

Log:
  MFC r360075:
  Set the maximum exit latency to 0 for XHCI USB 3.0 devices, because we
  don't implement link power management, LPM.
  
  This fixes error code XHCI_TRB_ERROR_BANDWIDTH for isochronous USB 3.0
  transactions.
  
  Submitted by: Horse Ma 
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/controller/xhci.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/controller/xhci.c
==
--- stable/10/sys/dev/usb/controller/xhci.c Sun Apr 26 08:37:31 2020
(r360334)
+++ stable/10/sys/dev/usb/controller/xhci.c Sun Apr 26 08:38:10 2020
(r360335)
@@ -2665,23 +2665,6 @@ xhci_configure_device(struct usb_device *udev)
sc->sc_hw.devs[index].nports);
}
 
-   switch (udev->speed) {
-   case USB_SPEED_SUPER:
-   switch (sc->sc_hw.devs[index].state) {
-   case XHCI_ST_ADDRESSED:
-   case XHCI_ST_CONFIGURED:
-   /* enable power save */
-   temp |= XHCI_SCTX_1_MAX_EL_SET(sc->sc_exit_lat_max);
-   break;
-   default:
-   /* disable power save */
-   break;
-   }
-   break;
-   default:
-   break;
-   }
-
xhci_ctx_set_le32(sc, >ctx_slot.dwSctx1, temp);
 
temp = XHCI_SCTX_2_IRQ_TARGET_SET(0);
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r360332 - stable/10/sys/kern

2020-04-26 Thread Hans Petter Selasky
Author: hselasky
Date: Sun Apr 26 08:35:32 2020
New Revision: 360332
URL: https://svnweb.freebsd.org/changeset/base/360332

Log:
  MFC r359968:
  Cast all ioctl command arguments through uint32_t internally.
  
  Hide debug print showing use of sign extended ioctl command argument
  under INVARIANTS. The print is available to all and can easily fill
  up the logs.
  
  No functional change intended.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/kern/sys_generic.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/sys_generic.c
==
--- stable/10/sys/kern/sys_generic.cSun Apr 26 08:34:52 2020
(r360331)
+++ stable/10/sys/kern/sys_generic.cSun Apr 26 08:35:32 2020
(r360332)
@@ -663,18 +663,19 @@ int
 sys_ioctl(struct thread *td, struct ioctl_args *uap)
 {
u_char smalldata[SYS_IOCTL_SMALL_SIZE] __aligned(SYS_IOCTL_SMALL_ALIGN);
-   u_long com;
+   uint32_t com;
int arg, error;
u_int size;
caddr_t data;
 
+#ifdef INVARIANTS
if (uap->com > 0x) {
printf(
"WARNING pid %d (%s): ioctl sign-extension ioctl %lx\n",
td->td_proc->p_pid, td->td_name, uap->com);
-   uap->com &= 0x;
}
-   com = uap->com;
+#endif
+   com = (uint32_t)uap->com;
 
/*
 * Interpret high order word to find amount of data to be
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r359890 - stable/10/sys/dev/sound/usb

2020-04-13 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Apr 13 16:34:21 2020
New Revision: 359890
URL: https://svnweb.freebsd.org/changeset/base/359890

Log:
  MFC r359446:
  Add support for multiple playback and recording devices per physical USB audio
  device. This requires some structural refactoring inside the driver, mostly
  about converting existing audio channel structures into arrays.
  
  The main audio mixer is provided by the first PCM instance.
  The non-first audio instances may only have a software mixer for PCM playback.
  
  Tested by:Horse Ma 
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/sound/usb/uaudio.c
  stable/10/sys/dev/sound/usb/uaudio.h
  stable/10/sys/dev/sound/usb/uaudio_pcm.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/sound/usb/uaudio.c
==
--- stable/10/sys/dev/sound/usb/uaudio.cMon Apr 13 16:33:45 2020
(r359889)
+++ stable/10/sys/dev/sound/usb/uaudio.cMon Apr 13 16:34:21 2020
(r359890)
@@ -264,6 +264,8 @@ struct uaudio_chan {
 #defineCHAN_OP_START 1
 #defineCHAN_OP_STOP 2
 #defineCHAN_OP_DRAIN 3
+
+   uint8_t iface_index;
 };
 
 #defineUMIDI_EMB_JACK_MAX   16 /* units */
@@ -349,37 +351,45 @@ struct uaudio_hid {
 #defineUAUDIO_SPDIF_OUT_96K0x04/* Out sample rate = 96K */
 #defineUAUDIO_SPDIF_IN_MIX 0x10/* Input mix enable */
 
+#defineUAUDIO_MAX_CHILD 2
+
+struct uaudio_softc_child {
+   device_t pcm_device;
+   struct mtx *mixer_lock;
+   struct snd_mixer *mixer_dev;
+
+   uint32_t mix_info;
+   uint32_t recsrc_info;
+
+   uint8_t pcm_registered:1;
+   uint8_t mixer_init:1;
+};
+
 struct uaudio_softc {
struct sbuf sc_sndstat;
struct sndcard_func sc_sndcard_func;
-   struct uaudio_chan sc_rec_chan;
-   struct uaudio_chan sc_play_chan;
+   struct uaudio_chan sc_rec_chan[UAUDIO_MAX_CHILD];
+   struct uaudio_chan sc_play_chan[UAUDIO_MAX_CHILD];
struct umidi_chan sc_midi_chan;
struct uaudio_hid sc_hid;
struct uaudio_search_result sc_mixer_clocks;
struct uaudio_mixer_node sc_mixer_node;
struct uaudio_configure_msg sc_config_msg[2];
+   struct uaudio_softc_child sc_child[UAUDIO_MAX_CHILD];
 
-   struct mtx *sc_mixer_lock;
-   struct snd_mixer *sc_mixer_dev;
struct usb_device *sc_udev;
struct usb_xfer *sc_mixer_xfer[1];
struct uaudio_mixer_node *sc_mixer_root;
struct uaudio_mixer_node *sc_mixer_curr;
int (*sc_set_spdif_fn) (struct uaudio_softc *, int);
 
-   uint32_t sc_mix_info;
-   uint32_t sc_recsrc_info;
-
uint16_t sc_audio_rev;
uint16_t sc_mixer_count;
 
-   uint8_t sc_sndstat_valid;
uint8_t sc_mixer_iface_index;
uint8_t sc_mixer_iface_no;
uint8_t sc_mixer_chan;
-   uint8_t sc_pcm_registered:1;
-   uint8_t sc_mixer_init:1;
+   uint8_t sc_sndstat_valid:1;
uint8_t sc_uq_audio_swap_lr:1;
uint8_t sc_uq_au_inp_async:1;
uint8_t sc_uq_au_no_xu:1;
@@ -479,7 +489,7 @@ static usb_proc_callback_t uaudio_configure_msg;
 
 static int uaudio_mixer_sysctl_handler(SYSCTL_HANDLER_ARGS);
 static void uaudio_mixer_ctl_free(struct uaudio_softc *);
-static void uaudio_mixer_register_sysctl(struct uaudio_softc *, device_t);
+static void uaudio_mixer_register_sysctl(struct uaudio_softc *, device_t, 
unsigned);
 static void uaudio_mixer_reload_all(struct uaudio_softc *);
 static void uaudio_mixer_controls_create_ftu(struct uaudio_softc *);
 
@@ -539,7 +549,7 @@ static void uaudio_mixer_add_ctl(struct uaudio_softc *
 static voiduaudio_mixer_fill_info(struct uaudio_softc *,
struct usb_device *, void *);
 static int uaudio_mixer_signext(uint8_t, int);
-static voiduaudio_mixer_init(struct uaudio_softc *);
+static voiduaudio_mixer_init(struct uaudio_softc *, unsigned);
 static uint8_t umidi_convert_to_usb(struct umidi_sub_chan *, uint8_t, uint8_t);
 static struct  umidi_sub_chan *umidi_sub_by_fifo(struct usb_fifo *);
 static voidumidi_start_read(struct usb_fifo *);
@@ -829,6 +839,33 @@ static const STRUCT_USB_HOST_ID __used uaudio_devs[] =
 USB_IFACE_SUBCLASS(UISUBCLASS_MIDISTREAM),},
 };
 
+static unsigned
+uaudio_get_child_index_by_dev(struct uaudio_softc *sc, device_t dev)
+{
+   unsigned i;
+
+   for (i = 0; i != UAUDIO_MAX_CHILD; i++) {
+   if (dev == sc->sc_child[i].pcm_device)
+   return (i);
+   }
+   panic("uaudio_get_child_index_dev: Invalid device: %p\n", dev);
+   return (0);
+}
+
+static unsigned
+uaudio_get_child_index_by_chan(struct uaudio_softc *sc, struct uaudio_chan *ch)
+{
+   unsigned i;
+
+   for (i = 0; i != UAUDIO_MAX_CHILD; i++) {
+   if ((sc->sc_play_chan + i) == ch ||
+   

svn commit: r359887 - stable/10/sys/dev/sound/pcm

2020-04-13 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Apr 13 16:32:18 2020
New Revision: 359887
URL: https://svnweb.freebsd.org/changeset/base/359887

Log:
  MFC r359440:
  Implement new mixer API to return the device pointer based on the mixer 
pointer.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/sound/pcm/mixer.c
  stable/10/sys/dev/sound/pcm/mixer.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/sound/pcm/mixer.c
==
--- stable/10/sys/dev/sound/pcm/mixer.c Mon Apr 13 16:31:46 2020
(r359886)
+++ stable/10/sys/dev/sound/pcm/mixer.c Mon Apr 13 16:32:18 2020
(r359887)
@@ -1031,6 +1031,14 @@ mix_get_type(struct snd_mixer *m)
return (m->type);
 }
 
+device_t
+mix_get_dev(struct snd_mixer *m)
+{
+   KASSERT(m != NULL, ("NULL snd_mixer"));
+
+   return (m->dev);
+}
+
 /* --- */
 
 static int

Modified: stable/10/sys/dev/sound/pcm/mixer.h
==
--- stable/10/sys/dev/sound/pcm/mixer.h Mon Apr 13 16:31:46 2020
(r359886)
+++ stable/10/sys/dev/sound/pcm/mixer.h Mon Apr 13 16:32:18 2020
(r359887)
@@ -54,6 +54,7 @@ int mix_get(struct snd_mixer *m, u_int dev);
 int mix_setrecsrc(struct snd_mixer *m, u_int32_t src);
 u_int32_t mix_getrecsrc(struct snd_mixer *m);
 int mix_get_type(struct snd_mixer *m);
+device_t mix_get_dev(struct snd_mixer *m);
 
 void mix_setdevs(struct snd_mixer *m, u_int32_t v);
 void mix_setrecdevs(struct snd_mixer *m, u_int32_t v);
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r359884 - stable/10/sys/dev/sound/pcm

2020-04-13 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Apr 13 16:30:10 2020
New Revision: 359884
URL: https://svnweb.freebsd.org/changeset/base/359884

Log:
  MFC r359356:
  Change default microphone level from 0 to 25.
  
  Discussed with:   Horse Ma 
  Sponsored by: Mellanox Technologies

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

Modified: stable/10/sys/dev/sound/pcm/mixer.c
==
--- stable/10/sys/dev/sound/pcm/mixer.c Mon Apr 13 16:29:35 2020
(r359883)
+++ stable/10/sys/dev/sound/pcm/mixer.c Mon Apr 13 16:30:10 2020
(r359884)
@@ -82,7 +82,7 @@ static u_int16_t snd_mixerdefaults[SOUND_MIXER_NRDEVIC
[SOUND_MIXER_PCM]   = 75,
[SOUND_MIXER_SPEAKER]   = 75,
[SOUND_MIXER_LINE]  = 75,
-   [SOUND_MIXER_MIC]   = 0,
+   [SOUND_MIXER_MIC]   = 25,
[SOUND_MIXER_CD]= 75,
[SOUND_MIXER_IGAIN] = 0,
[SOUND_MIXER_LINE1] = 75,
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r359881 - stable/10/sys/dev/sound/usb

2020-04-13 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Apr 13 16:28:15 2020
New Revision: 359881
URL: https://svnweb.freebsd.org/changeset/base/359881

Log:
  MFC r359355:
  Improve USB audio mixer support for USB audio class 1 and 2.
  - make sure volume controls are correctly mapped to "pcm" and "rec" depending
on how they deliver audio to the USB host.
  - make sure there are no duplicate record selections.
  - remove internal only mixer class type.
  - don't add software volume controls for recording only.
  - some minor mixer code cleanup.
  
  Tested by:Horse Ma 
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/sound/usb/uaudio.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/sound/usb/uaudio.c
==
--- stable/10/sys/dev/sound/usb/uaudio.cMon Apr 13 16:27:40 2020
(r359880)
+++ stable/10/sys/dev/sound/usb/uaudio.cMon Apr 13 16:28:15 2020
(r359881)
@@ -198,7 +198,6 @@ struct uaudio_mixer_node {
 
 #defineMAX_SELECTOR_INPUT_PIN 256
uint8_t slctrtype[MAX_SELECTOR_INPUT_PIN];
-   uint8_t class;
uint8_t val_default;
 
uint8_t desc[64];
@@ -459,19 +458,6 @@ static const struct uaudio_format uaudio20_formats[] =
{0, 0, 0, NULL}
 };
 
-#defineUAC_OUTPUT  0
-#defineUAC_INPUT   1
-#defineUAC_EQUAL   2
-#defineUAC_RECORD  3
-#defineUAC_NCLASSES4
-
-#ifdef USB_DEBUG
-static const char *uac_names[] = {
-   "outputs", "inputs", "equalization", "record"
-};
-
-#endif
-
 /* prototypes */
 
 static device_probe_t uaudio_probe;
@@ -515,10 +501,7 @@ static voiduaudio_mixer_add_extension(struct 
uaudio_s
const struct uaudio_terminal_node *, int);
 static struct  usb_audio_cluster uaudio_mixer_get_cluster(uint8_t,
const struct uaudio_terminal_node *);
-static uint16_tuaudio_mixer_determine_class(const struct 
uaudio_terminal_node *,
-   struct uaudio_mixer_node *);
-static uint16_tuaudio_mixer_feature_name(const struct 
uaudio_terminal_node *,
-   struct uaudio_mixer_node *);
+static uint16_tuaudio_mixer_determine_class(const struct 
uaudio_terminal_node *);
 static voiduaudio_mixer_find_inputs_sub(struct uaudio_terminal_node *,
const uint8_t *, uint8_t, struct uaudio_search_result *);
 static const void *uaudio_mixer_verify_desc(const void *, uint32_t);
@@ -536,10 +519,7 @@ static voiduaudio20_mixer_add_feature(struct 
uaudio_s
const struct uaudio_terminal_node *, int);
 static struct  usb_audio20_cluster uaudio20_mixer_get_cluster(uint8_t,
const struct uaudio_terminal_node *);
-static uint16_tuaudio20_mixer_determine_class(const struct 
uaudio_terminal_node *,
-   struct uaudio_mixer_node *);
-static uint16_tuaudio20_mixer_feature_name(const struct 
uaudio_terminal_node *,
-   struct uaudio_mixer_node *);
+static uint16_tuaudio20_mixer_determine_class(const struct 
uaudio_terminal_node *);
 static voiduaudio20_mixer_find_inputs_sub(struct uaudio_terminal_node *,
const uint8_t *, uint8_t, struct uaudio_search_result *);
 static const void *uaudio20_mixer_verify_desc(const void *, uint32_t);
@@ -560,12 +540,6 @@ static voiduaudio_mixer_fill_info(struct 
uaudio_softc
struct usb_device *, void *);
 static int uaudio_mixer_signext(uint8_t, int);
 static voiduaudio_mixer_init(struct uaudio_softc *);
-static const struct uaudio_terminal_node *uaudio_mixer_get_input(
-   const struct uaudio_terminal_node *, uint8_t);
-static const struct uaudio_terminal_node *uaudio_mixer_get_output(
-   const struct uaudio_terminal_node *, uint8_t);
-static voiduaudio_mixer_find_outputs_sub(struct uaudio_terminal_node *,
-   uint8_t, uint8_t, struct uaudio_search_result *);
 static uint8_t umidi_convert_to_usb(struct umidi_sub_chan *, uint8_t, uint8_t);
 static struct  umidi_sub_chan *umidi_sub_by_fifo(struct usb_fifo *);
 static voidumidi_start_read(struct usb_fifo *);
@@ -1142,7 +1116,8 @@ uaudio_attach_sub(device_t dev, kobj_class_t mixer_cla
DPRINTF("hardware has swapped left and right\n");
/* uaudio_pcm_setflags(dev, SD_F_PSWAPLR); */
}
-   if (!(sc->sc_mix_info & SOUND_MASK_PCM)) {
+   if (sc->sc_play_chan.num_alt > 0 &&
+   (sc->sc_mix_info & SOUND_MASK_PCM) == 0) {
 
DPRINTF("emulating master volume\n");
 
@@ -2966,7 +2941,6 @@ uaudio_mixer_controls_create_ftu(struct uaudio_softc *
memset((sc), 0, sizeof(MIX(sc)));
MIX(sc).wIndex = MAKE_WORD(6, sc->sc_mixer_iface_no);
MIX(sc).wValue[0] = MAKE_WORD(8, 0);
-   MIX(sc).class = UAC_OUTPUT;

svn commit: r359878 - stable/10/sys/dev/sound/usb

2020-04-13 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Apr 13 16:26:15 2020
New Revision: 359878
URL: https://svnweb.freebsd.org/changeset/base/359878

Log:
  MFC r359323:
  Be more intelligent when classifying USB audio terminal types, so that we
  don't end up using SOUND_MIXER_VOLUME for all undefined types.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/sound/usb/uaudio.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/sound/usb/uaudio.c
==
--- stable/10/sys/dev/sound/usb/uaudio.cMon Apr 13 16:25:44 2020
(r359877)
+++ stable/10/sys/dev/sound/usb/uaudio.cMon Apr 13 16:26:15 2020
(r359878)
@@ -4515,52 +4515,61 @@ static const struct uaudio_tt_to_feature uaudio_tt_to_
{UATF_MULTITRACK, SOUND_MIXER_VOLUME},
{0x, SOUND_MIXER_VOLUME},
 
-   /* default */
-   {0x, SOUND_MIXER_VOLUME},
+   /* end */
+   {}
 };
 
 static uint16_t
-uaudio_mixer_feature_name(const struct uaudio_terminal_node *iot,
-struct uaudio_mixer_node *mix)
+uaudio_mixer_feature_name_sub(uint16_t terminal_type)
 {
const struct uaudio_tt_to_feature *uat = uaudio_tt_to_feature;
-   uint16_t terminal_type = uaudio_mixer_determine_class(iot, mix);
+   uint16_t retval;
 
-   if ((mix->class == UAC_RECORD) && (terminal_type == 0)) {
-   return (SOUND_MIXER_IMIX);
-   }
-   while (uat->terminal_type) {
-   if (uat->terminal_type == terminal_type) {
-   break;
+   while (1) {
+   if (uat->terminal_type == 0) {
+   switch (terminal_type >> 8) {
+   case UATI_UNDEFINED >> 8:
+   retval = SOUND_MIXER_RECLEV;
+   goto done;
+   case UATO_UNDEFINED >> 8:
+   retval = SOUND_MIXER_PCM;
+   goto done;
+   default:
+   retval = SOUND_MIXER_VOLUME;
+   goto done;
+   }
+   } else if (uat->terminal_type == terminal_type) {
+   retval = uat->feature;
+   goto done;
}
uat++;
}
-
+done:
DPRINTF("terminal_type=0x%04x -> %d\n",
-   terminal_type, uat->feature);
+   terminal_type, retval);
+   return (retval);
+}
 
-   return (uat->feature);
+static uint16_t
+uaudio_mixer_feature_name(const struct uaudio_terminal_node *iot,
+struct uaudio_mixer_node *mix)
+{
+   uint16_t terminal_type = uaudio_mixer_determine_class(iot, mix);
+
+   if (mix->class == UAC_RECORD && terminal_type == 0)
+   return (SOUND_MIXER_IMIX);
+   return (uaudio_mixer_feature_name_sub(terminal_type));
 }
 
 static uint16_t
 uaudio20_mixer_feature_name(const struct uaudio_terminal_node *iot,
 struct uaudio_mixer_node *mix)
 {
-   const struct uaudio_tt_to_feature *uat;
uint16_t terminal_type = uaudio20_mixer_determine_class(iot, mix);
 
-   if ((mix->class == UAC_RECORD) && (terminal_type == 0))
+   if (mix->class == UAC_RECORD && terminal_type == 0)
return (SOUND_MIXER_IMIX);
-   
-   for (uat = uaudio_tt_to_feature; uat->terminal_type != 0; uat++) {
-   if (uat->terminal_type == terminal_type)
-   break;
-   }
-
-   DPRINTF("terminal_type=0x%04x -> %d\n",
-   terminal_type, uat->feature);
-
-   return (uat->feature);
+   return (uaudio_mixer_feature_name_sub(terminal_type));
 }
 
 static const struct uaudio_terminal_node *
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r359875 - stable/10/sys/dev/sound/usb

2020-04-13 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Apr 13 16:24:21 2020
New Revision: 359875
URL: https://svnweb.freebsd.org/changeset/base/359875

Log:
  MFC r359322:
  Make mute controls available for USB audio mixers.
  
  Submitted by: Horse Ma 
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/sound/usb/uaudio.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/sound/usb/uaudio.c
==
--- stable/10/sys/dev/sound/usb/uaudio.cMon Apr 13 16:23:46 2020
(r359874)
+++ stable/10/sys/dev/sound/usb/uaudio.cMon Apr 13 16:24:21 2020
(r359875)
@@ -3579,7 +3579,7 @@ uaudio_mixer_add_feature(struct uaudio_softc *sc,
switch (ctl) {
case MUTE_CONTROL:
MIX(sc).type = MIX_ON_OFF;
-   MIX(sc).ctl = SOUND_MIXER_NRDEVICES;
+   MIX(sc).ctl = SOUND_MIXER_MUTE;
MIX(sc).name = "mute";
break;
 
@@ -3694,7 +3694,7 @@ uaudio20_mixer_add_feature(struct uaudio_softc *sc,
switch (ctl) {
case (3 << 0):
MIX(sc).type = MIX_ON_OFF;
-   MIX(sc).ctl = SOUND_MIXER_NRDEVICES;
+   MIX(sc).ctl = SOUND_MIXER_MUTE;
MIX(sc).name = "mute";
what = MUTE_CONTROL;
break;
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r359872 - stable/10/sys/dev/sound/usb

2020-04-13 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Apr 13 16:22:15 2020
New Revision: 359872
URL: https://svnweb.freebsd.org/changeset/base/359872

Log:
  MFC r359321:
  Factor out USB audio mixer value range check.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/sound/usb/uaudio.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/sound/usb/uaudio.c
==
--- stable/10/sys/dev/sound/usb/uaudio.cMon Apr 13 16:21:38 2020
(r359871)
+++ stable/10/sys/dev/sound/usb/uaudio.cMon Apr 13 16:22:15 2020
(r359872)
@@ -5380,25 +5380,19 @@ uaudio_mixer_bsd2value(struct uaudio_mixer_node *mc, i
 {
if (mc->type == MIX_ON_OFF) {
val = (val != 0);
-   } else if (mc->type == MIX_SELECTOR) {
-   if ((val < mc->minval) ||
-   (val > mc->maxval)) {
-   val = mc->minval;
-   }
-   } else {
+   } else if (mc->type != MIX_SELECTOR) {
 
/* compute actual volume */
val = (val * mc->mul) / 100;
 
/* add lower offset */
val = val + mc->minval;
-
-   /* make sure we don't write a value out of range */
-   if (val > mc->maxval)
-   val = mc->maxval;
-   else if (val < mc->minval)
-   val = mc->minval;
}
+   /* make sure we don't write a value out of range */
+   if (val > mc->maxval)
+   val = mc->maxval;
+   else if (val < mc->minval)
+   val = mc->minval;
 
DPRINTFN(6, "type=0x%03x val=%d min=%d max=%d val=%d\n",
mc->type, val, mc->minval, mc->maxval, val);
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r359869 - stable/10/sys/dev/sound/usb

2020-04-13 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Apr 13 16:19:45 2020
New Revision: 359869
URL: https://svnweb.freebsd.org/changeset/base/359869

Log:
  MFC r359320:
  Avoid scaling USB audio mixer values twice.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/sound/usb/uaudio.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/sound/usb/uaudio.c
==
--- stable/10/sys/dev/sound/usb/uaudio.cMon Apr 13 16:19:12 2020
(r359868)
+++ stable/10/sys/dev/sound/usb/uaudio.cMon Apr 13 16:19:45 2020
(r359869)
@@ -558,10 +558,7 @@ static voiduaudio_mixer_add_ctl(struct 
uaudio_softc *
struct uaudio_mixer_node *);
 static voiduaudio_mixer_fill_info(struct uaudio_softc *,
struct usb_device *, void *);
-static voiduaudio_mixer_ctl_set(struct uaudio_softc *,
-   struct uaudio_mixer_node *, uint8_t, int32_t val);
 static int uaudio_mixer_signext(uint8_t, int);
-static int uaudio_mixer_bsd2value(struct uaudio_mixer_node *, int32_t val);
 static voiduaudio_mixer_init(struct uaudio_softc *);
 static const struct uaudio_terminal_node *uaudio_mixer_get_input(
const struct uaudio_terminal_node *, uint8_t);
@@ -5379,7 +5376,7 @@ uaudio_mixer_signext(uint8_t type, int val)
 }
 
 static int
-uaudio_mixer_bsd2value(struct uaudio_mixer_node *mc, int32_t val)
+uaudio_mixer_bsd2value(struct uaudio_mixer_node *mc, int val)
 {
if (mc->type == MIX_ON_OFF) {
val = (val != 0);
@@ -5391,7 +5388,7 @@ uaudio_mixer_bsd2value(struct uaudio_mixer_node *mc, i
} else {
 
/* compute actual volume */
-   val = (val * mc->mul) / 255;
+   val = (val * mc->mul) / 100;
 
/* add lower offset */
val = val + mc->minval;
@@ -5410,7 +5407,7 @@ uaudio_mixer_bsd2value(struct uaudio_mixer_node *mc, i
 
 static void
 uaudio_mixer_ctl_set(struct uaudio_softc *sc, struct uaudio_mixer_node *mc,
-uint8_t chan, int32_t val)
+uint8_t chan, int val)
 {
val = uaudio_mixer_bsd2value(mc, val);
 
@@ -5499,8 +5496,7 @@ uaudio_mixer_set(struct uaudio_softc *sc, unsigned typ
if (mc->ctl == type) {
for (chan = 0; chan < mc->nchan; chan++) {
uaudio_mixer_ctl_set(sc, mc, chan,
-   (int)((chan == 0 ? left : right) *
-   255) / 100);
+   chan == 0 ? left : right);
}
}
}
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r359855 - stable/10/sys/dev/mlx5/mlx5_en

2020-04-13 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Apr 13 09:02:17 2020
New Revision: 359855
URL: https://svnweb.freebsd.org/changeset/base/359855

Log:
  MFC r359653:
  Count number of times transmit ring is out of buffers in mlx5en(4).
  
  Differential Revision:https://reviews.freebsd.org/D24273
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/mlx5/mlx5_en/en.h
  stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/mlx5/mlx5_en/en.h
==
--- stable/10/sys/dev/mlx5/mlx5_en/en.h Mon Apr 13 09:01:46 2020
(r359854)
+++ stable/10/sys/dev/mlx5/mlx5_en/en.h Mon Apr 13 09:02:17 2020
(r359855)
@@ -355,6 +355,7 @@ struct mlx5e_rq_stats {
   m(+1, u64 csum_offload_none, "csum_offload_none", "Transmitted packets") 
\
   m(+1, u64 defragged, "defragged", "Transmitted packets") \
   m(+1, u64 dropped, "dropped", "Transmitted packets") \
+  m(+1, u64 enobuf, "enobuf", "Transmitted packets")   \
   m(+1, u64 nop, "nop", "Transmitted packets")
 
 #defineMLX5E_SQ_STATS_NUM (0 MLX5E_SQ_STATS(MLX5E_STATS_COUNT))

Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
==
--- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Mon Apr 13 09:01:46 2020
(r359854)
+++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Mon Apr 13 09:02:17 2020
(r359855)
@@ -255,6 +255,7 @@ mlx5e_sq_xmit(struct mlx5e_sq *sq, struct mbuf **mbp)
 * of the mbuf into the drbr (see mlx5e_xmit_locked)
 */
if (unlikely(!mlx5e_sq_has_room_for(sq, 2 * MLX5_SEND_WQE_MAX_WQEBBS))) 
{
+   sq->stats.enobuf++;
return (ENOBUFS);
}
 
@@ -264,8 +265,10 @@ mlx5e_sq_xmit(struct mlx5e_sq *sq, struct mbuf **mbp)
/* Send one multi NOP message instead of many */
mlx5e_send_nop(sq, (pi + 1) * MLX5_SEND_WQEBB_NUM_DS);
pi = ((~sq->pc) & sq->wq.sz_m1);
-   if (pi < (MLX5_SEND_WQE_MAX_WQEBBS - 1))
+   if (pi < (MLX5_SEND_WQE_MAX_WQEBBS - 1)) {
+   sq->stats.enobuf++;
return (ENOMEM);
+   }
}
 
/* Setup local variables */
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r359123 - stable/10/sys/ofed/drivers/infiniband/ulp/ipoib

2020-03-19 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Mar 19 09:20:41 2020
New Revision: 359123
URL: https://svnweb.freebsd.org/changeset/base/359123

Log:
  MFC r359014:
  Fix for double unlock in ipoib.
  
  The ipoib_unicast_send() function is not supposed to unlock the priv lock.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
==
--- stable/10/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.cThu Mar 
19 09:20:04 2020(r359122)
+++ stable/10/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.cThu Mar 
19 09:20:41 2020(r359123)
@@ -657,7 +657,6 @@ ipoib_unicast_send(struct mbuf *mb, struct ipoib_dev_p
if (path) {
_IF_ENQUEUE(>queue, mb);
if (!path->query && path_rec_start(priv, path)) {
-   spin_unlock_irqrestore(>lock, flags);
if (new_path)
ipoib_path_free(priv, path);
return;
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r358949 - stable/10/lib/libusb

2020-03-13 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Mar 13 09:18:28 2020
New Revision: 358949
URL: https://svnweb.freebsd.org/changeset/base/358949

Log:
  MFC r358841:
  Fix for building libusb under Linux.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/lib/libusb/libusb_global_linux.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libusb/libusb_global_linux.h
==
--- stable/10/lib/libusb/libusb_global_linux.h  Fri Mar 13 09:17:51 2020
(r358948)
+++ stable/10/lib/libusb/libusb_global_linux.h  Fri Mar 13 09:18:28 2020
(r358949)
@@ -75,4 +75,11 @@
 } while (0)
 #endif
 
+#ifndef TAILQ_FOREACH_SAFE
+#defineTAILQ_FOREACH_SAFE(var, head, field, tvar)  
\
+   for ((var) = TAILQ_FIRST((head));   \
+   (var) && ((tvar) = TAILQ_NEXT((var), field), 1);\
+   (var) = (tvar))
+#endif
+
 #endif /* _LIBUSB_GLOBAL_LINUX_H_ */
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r358941 - stable/10/sys/compat/linux

2020-03-13 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Mar 13 08:57:22 2020
New Revision: 358941
URL: https://svnweb.freebsd.org/changeset/base/358941

Log:
  MFC r358838:
  Add support for the device statistics IOCTL, needed by the coming
  linux_libusb upgrade.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/compat/linux/linux_ioctl.c
  stable/10/sys/compat/linux/linux_ioctl.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/compat/linux/linux_ioctl.c
==
--- stable/10/sys/compat/linux/linux_ioctl.cFri Mar 13 08:56:46 2020
(r358940)
+++ stable/10/sys/compat/linux/linux_ioctl.cFri Mar 13 08:57:22 2020
(r358941)
@@ -3555,6 +3555,9 @@ linux_ioctl_fbsd_usb(struct thread *td, struct linux_i
case FBSD_LUSB_GET_POWER_USAGE:
args->cmd = USB_GET_POWER_USAGE;
break;
+   case FBSD_LUSB_DEVICESTATS:
+   args->cmd = USB_DEVICESTATS;
+   break;
default:
error = ENOIOCTL;
}

Modified: stable/10/sys/compat/linux/linux_ioctl.h
==
--- stable/10/sys/compat/linux/linux_ioctl.hFri Mar 13 08:56:46 2020
(r358940)
+++ stable/10/sys/compat/linux/linux_ioctl.hFri Mar 13 08:57:22 2020
(r358941)
@@ -740,9 +740,10 @@
 #defineFBSD_LUSB_FS_OPEN_STREAM0xffdf
 #defineFBSD_LUSB_GET_DEV_PORT_PATH 0xffde
 #defineFBSD_LUSB_GET_POWER_USAGE   0xffdd
+#defineFBSD_LUSB_DEVICESTATS   0xffdc
 
 #defineFBSD_LUSB_MAX   0x
-#defineFBSD_LUSB_MIN   0xffdd
+#defineFBSD_LUSB_MIN   0xffdc
 
 /*
  * Linux btrfs clone operation
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r358937 - stable/10/sys/sys

2020-03-13 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Mar 13 08:53:59 2020
New Revision: 358937
URL: https://svnweb.freebsd.org/changeset/base/358937

Log:
  MFC r358695:
  Define more subsystem orders.
  Intended for use with module_init_order() in the LinuxKPI.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/sys/kernel.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/sys/kernel.h
==
--- stable/10/sys/sys/kernel.h  Fri Mar 13 08:53:26 2020(r358936)
+++ stable/10/sys/sys/kernel.h  Fri Mar 13 08:53:59 2020(r358937)
@@ -183,6 +183,10 @@ enum sysinit_elem_order {
SI_ORDER_SECOND = 0x001,/* second*/
SI_ORDER_THIRD  = 0x002,/* third*/
SI_ORDER_FOURTH = 0x003,/* fourth*/
+   SI_ORDER_FIFTH  = 0x004,/* fifth*/
+   SI_ORDER_SIXTH  = 0x005,/* sixth*/
+   SI_ORDER_SEVENTH= 0x006,/* seventh*/
+   SI_ORDER_EIGHTH = 0x007,/* eighth*/
SI_ORDER_MIDDLE = 0x100,/* somewhere in the middle */
SI_ORDER_ANY= 0xfff /* last*/
 };
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r358933 - stable/10/sys/ofed/drivers/infiniband/ulp/ipoib

2020-03-13 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Mar 13 08:50:56 2020
New Revision: 358933
URL: https://svnweb.freebsd.org/changeset/base/358933

Log:
  MFC r358694:
  Fix some whitespace issues in ipoib.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
==
--- stable/10/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.cFri Mar 
13 08:49:45 2020(r358932)
+++ stable/10/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.cFri Mar 
13 08:50:56 2020(r358933)
@@ -1544,12 +1544,12 @@ module_exit(ipoib_cleanup_module);
 static int
 ipoib_evhand(module_t mod, int event, void *arg)
 {
-   return (0);
+   return (0);
 }
 
 static moduledata_t ipoib_mod = {
-   .name = "ipoib",
-   .evhand = ipoib_evhand,
+   .name = "ipoib",
+   .evhand = ipoib_evhand,
 };
 
 DECLARE_MODULE(ipoib, ipoib_mod, SI_SUB_SMP, SI_ORDER_ANY);
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r358879 - stable/10/sys/dev/sound/pcm

2020-03-11 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Mar 11 08:26:11 2020
New Revision: 358879
URL: https://svnweb.freebsd.org/changeset/base/358879

Log:
  MFC r358629:
  Implement a detaching flag for the sound(4) subsystem to take
  appropriate actions when we are trying to detach an audio device,
  but cannot because someone is using it.
  
  This avoids applications having to wait for the DSP read data
  timeout before they receive any error indication.
  Tested with virtual_oss(8).
  
  Remove some unused definitions while at it.
  
  PR:   194727
  Sponsored by: Mellanox Technologies

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

Modified: stable/10/sys/dev/sound/pcm/dsp.c
==
--- stable/10/sys/dev/sound/pcm/dsp.c   Wed Mar 11 08:25:33 2020
(r358878)
+++ stable/10/sys/dev/sound/pcm/dsp.c   Wed Mar 11 08:26:11 2020
(r358879)
@@ -459,7 +459,7 @@ dsp_open(struct cdev *i_dev, int flags, int mode, stru
return (ENODEV);
 
d = dsp_get_info(i_dev);
-   if (!PCM_REGISTERED(d))
+   if (PCM_DETACHING(d) || !PCM_REGISTERED(d))
return (EBADF);
 
PCM_GIANT_ENTER(d);
@@ -829,7 +829,7 @@ dsp_io_ops(struct cdev *i_dev, struct uio *buf)
("%s(): io train wreck!", __func__));
 
d = dsp_get_info(i_dev);
-   if (!DSP_REGISTERED(d, i_dev))
+   if (PCM_DETACHING(d) || !DSP_REGISTERED(d, i_dev))
return (EBADF);
 
PCM_GIANT_ENTER(d);
@@ -1074,7 +1074,7 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg,
int *arg_i, ret, tmp;
 
d = dsp_get_info(i_dev);
-   if (!DSP_REGISTERED(d, i_dev))
+   if (PCM_DETACHING(d) || !DSP_REGISTERED(d, i_dev))
return (EBADF);
 
PCM_GIANT_ENTER(d);
@@ -2169,9 +2169,11 @@ dsp_poll(struct cdev *i_dev, int events, struct thread
int ret, e;
 
d = dsp_get_info(i_dev);
-   if (!DSP_REGISTERED(d, i_dev))
-   return (EBADF);
-
+   if (PCM_DETACHING(d) || !DSP_REGISTERED(d, i_dev)) {
+   /* XXX many clients don't understand POLLNVAL */
+   return (events & (POLLHUP | POLLPRI | POLLIN |
+   POLLRDNORM | POLLOUT | POLLWRNORM));
+   }
PCM_GIANT_ENTER(d);
 
wrch = NULL;
@@ -2242,7 +2244,7 @@ dsp_mmap_single(struct cdev *i_dev, vm_ooffset_t *offs
return (EINVAL);
 
d = dsp_get_info(i_dev);
-   if (!DSP_REGISTERED(d, i_dev))
+   if (PCM_DETACHING(d) || !DSP_REGISTERED(d, i_dev))
return (EINVAL);
 
PCM_GIANT_ENTER(d);

Modified: stable/10/sys/dev/sound/pcm/mixer.c
==
--- stable/10/sys/dev/sound/pcm/mixer.c Wed Mar 11 08:25:33 2020
(r358878)
+++ stable/10/sys/dev/sound/pcm/mixer.c Wed Mar 11 08:26:11 2020
(r358879)
@@ -152,7 +152,7 @@ mixer_set_softpcmvol(struct snd_mixer *m, struct sndde
struct pcm_channel *c;
int dropmtx, acquiremtx;
 
-   if (!PCM_REGISTERED(d))
+   if (PCM_DETACHING(d) || !PCM_REGISTERED(d))
return (EINVAL);
 
if (mtx_owned(m->lock))
@@ -205,7 +205,7 @@ mixer_set_eq(struct snd_mixer *m, struct snddev_info *
else
return (EINVAL);
 
-   if (!PCM_REGISTERED(d))
+   if (PCM_DETACHING(d) || !PCM_REGISTERED(d))
return (EINVAL);
 
if (mtx_owned(m->lock))
@@ -1045,7 +1045,7 @@ mixer_open(struct cdev *i_dev, int flags, int mode, st
 
m = i_dev->si_drv1;
d = device_get_softc(m->dev);
-   if (!PCM_REGISTERED(d))
+   if (PCM_DETACHING(d) || !PCM_REGISTERED(d))
return (EBADF);
 
/* XXX Need Giant magic entry ??? */
@@ -1201,7 +1201,7 @@ mixer_ioctl(struct cdev *i_dev, u_long cmd, caddr_t ar
return (EBADF);
 
d = device_get_softc(((struct snd_mixer *)i_dev->si_drv1)->dev);
-   if (!PCM_REGISTERED(d))
+   if (PCM_DETACHING(d) || !PCM_REGISTERED(d))
return (EBADF);
 
PCM_GIANT_ENTER(d);
@@ -1412,7 +1412,7 @@ mixer_oss_mixerinfo(struct cdev *i_dev, oss_mixerinfo 
for (i = 0; pcm_devclass != NULL &&
i < devclass_get_maxunit(pcm_devclass); i++) {
d = devclass_get_softc(pcm_devclass, i);
-   if (!PCM_REGISTERED(d))
+   if (PCM_DETACHING(d) || !PCM_REGISTERED(d))
continue;
 
/* XXX Need Giant magic entry */

Modified: stable/10/sys/dev/sound/pcm/sound.c
==
--- stable/10/sys/dev/sound/pcm/sound.c Wed Mar 11 08:25:33 2020
(r358878)
+++ stable/10/sys/dev/sound/pcm/sound.c Wed Mar 11 08:26:11 2020 

svn commit: r358875 - in stable/10/sys/dev/usb: . controller

2020-03-11 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Mar 11 08:21:48 2020
New Revision: 358875
URL: https://svnweb.freebsd.org/changeset/base/358875

Log:
  MFC r358738:
  Remove the power bit from the super speed root hub port status register
  because it clobbers the super speed link status when a device is in super
  speed mode. Currently the power bit is not needed for anything in the USB
  hub driver.
  
  This fixes USB warm reset for super speed devices.
  
  Tested by:shichun...@dell.com
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/controller/xhci.c
  stable/10/sys/dev/usb/usb_hub.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/controller/xhci.c
==
--- stable/10/sys/dev/usb/controller/xhci.c Wed Mar 11 08:21:04 2020
(r358874)
+++ stable/10/sys/dev/usb/controller/xhci.c Wed Mar 11 08:21:48 2020
(r358875)
@@ -3591,13 +3591,10 @@ xhci_roothub_exec(struct usb_device *udev,
i |= UPS_OVERCURRENT_INDICATOR;
if (v & XHCI_PS_PR)
i |= UPS_RESET;
-   if (v & XHCI_PS_PP) {
-   /*
-* The USB 3.0 RH is using the
-* USB 2.0's power bit
-*/
-   i |= UPS_PORT_POWER;
-   }
+#if 0
+   if (v & XHCI_PS_PP)
+   /* XXX undefined */
+#endif
USETW(sc->sc_hub_desc.ps.wPortStatus, i);
 
i = 0;

Modified: stable/10/sys/dev/usb/usb_hub.c
==
--- stable/10/sys/dev/usb/usb_hub.c Wed Mar 11 08:21:04 2020
(r358874)
+++ stable/10/sys/dev/usb/usb_hub.c Wed Mar 11 08:21:48 2020
(r358875)
@@ -692,7 +692,7 @@ repeat:
break;
case USB_SPEED_SUPER:
if (udev->parent_hub == NULL)
-   power_mask = UPS_PORT_POWER;
+   power_mask = 0; /* XXX undefined */
else
power_mask = UPS_PORT_POWER_SS;
break;
@@ -700,7 +700,7 @@ repeat:
power_mask = 0;
break;
}
-   if (!(sc->sc_st.port_status & power_mask)) {
+   if ((sc->sc_st.port_status & power_mask) != power_mask) {
DPRINTF("WARNING: strange, connected port %d "
"has no power\n", portno);
}
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r357439 - stable/10/lib/libusb

2020-02-03 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Feb  3 11:05:59 2020
New Revision: 357439
URL: https://svnweb.freebsd.org/changeset/base/357439

Log:
  MFC r357298:
  Add missing mutex unlock in failure case.
  
  Differential Revision:https://reviews.freebsd.org/D23430
  Submitted by: cem
  Reported by:  Coverity
  Coverity CID: 1368773
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/lib/libusb/libusb10_hotplug.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libusb/libusb10_hotplug.c
==
--- stable/10/lib/libusb/libusb10_hotplug.c Mon Feb  3 11:05:14 2020
(r357438)
+++ stable/10/lib/libusb/libusb10_hotplug.c Mon Feb  3 11:05:59 2020
(r357439)
@@ -123,8 +123,10 @@ libusb_hotplug_scan(void *arg)
TAILQ_INIT(_devs);
 
if (ctx->hotplug_handler != NO_THREAD) {
-   if (libusb_hotplug_enumerate(ctx, _devs) < 0)
+   if (libusb_hotplug_enumerate(ctx, _devs) < 0) {
+   HOTPLUG_UNLOCK(ctx);
continue;
+   }
} else {
do_loop = 0;
}
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r357432 - in stable/10/sys/dev/usb: . serial

2020-02-03 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Feb  3 10:50:52 2020
New Revision: 357432
URL: https://svnweb.freebsd.org/changeset/base/357432

Log:
  MFC r356952:
  Add new USB ID to uslcom(4).
  
  Submitted by: Oleg Sharoyko 
  PR:   243494
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/serial/uslcom.c
  stable/10/sys/dev/usb/usbdevs
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/serial/uslcom.c
==
--- stable/10/sys/dev/usb/serial/uslcom.c   Mon Feb  3 10:50:05 2020
(r357431)
+++ stable/10/sys/dev/usb/serial/uslcom.c   Mon Feb  3 10:50:52 2020
(r357432)
@@ -314,6 +314,7 @@ static const STRUCT_USB_HOST_ID uslcom_devs[] = {
 USLCOM_DEV(SILABS, HAMLINKUSB),
 USLCOM_DEV(SILABS, HELICOM),
 USLCOM_DEV(SILABS, HUBZ),
+USLCOM_DEV(SILABS, BV_AV2010_10),
 USLCOM_DEV(SILABS, IMS_USB_RS422),
 USLCOM_DEV(SILABS, INFINITY_MIC),
 USLCOM_DEV(SILABS, INGENI_ZIGBEE),

Modified: stable/10/sys/dev/usb/usbdevs
==
--- stable/10/sys/dev/usb/usbdevs   Mon Feb  3 10:50:05 2020
(r357431)
+++ stable/10/sys/dev/usb/usbdevs   Mon Feb  3 10:50:52 2020
(r357432)
@@ -4177,6 +4177,7 @@ product SILABSAC_SERV_OBD 0x8665  AC-Services OBD 
Inte
 product SILABS MMB_ZIGBEE  0x88a4  MMB Networks ZigBee
 product SILABS INGENI_ZIGBEE   0x88a5  Planet Innovation Ingeni ZigBee
 product SILABS HUBZ0x8a2a  HubZ dual ZigBee and Z-Wave
+product SILABS BV_AV2010_100x8b34  Bitron Video AV2010/10 ZigBee USB Stick
 product SILABS CP2102  0xea60  SILABS USB UART
 product SILABS CP210X_20xea61  CP210x Serial
 product SILABS CP210X_30xea70  CP210x Serial
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r357429 - stable/10/sys/ofed/drivers/infiniband/ulp/ipoib

2020-02-03 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Feb  3 10:47:44 2020
New Revision: 357429
URL: https://svnweb.freebsd.org/changeset/base/357429

Log:
  MFC r356633:
  Make sure the VNET is properly set when reaping mbufs in ipoib.
  Else the following panic may happen:
  
  panic()
  icmp_error()
  ipoib_cm_mb_reap()
  linux_work_fn()
  taskqueue_run_locked()
  taskqueue_thread_loop()
  fork_exit()
  fork_trampoline()
  
  Submitted by: Andreas Kempe 
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c
==
--- stable/10/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c  Mon Feb  3 
10:46:29 2020(r357428)
+++ stable/10/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c  Mon Feb  3 
10:47:44 2020(r357429)
@@ -1259,6 +1259,8 @@ static void ipoib_cm_mb_reap(struct work_struct *work)
 
spin_lock_irqsave(>lock, flags);
 
+   CURVNET_SET_QUIET(priv->dev->if_vnet);
+
for (;;) {
IF_DEQUEUE(>cm.mb_queue, mb);
if (mb == NULL)
@@ -1284,6 +1286,8 @@ static void ipoib_cm_mb_reap(struct work_struct *work)
 
spin_lock_irqsave(>lock, flags);
}
+
+   CURVNET_RESTORE();
 
spin_unlock_irqrestore(>lock, flags);
 }
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r356783 - stable/10/sys/dev/usb/controller

2020-01-16 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Jan 16 08:53:59 2020
New Revision: 356783
URL: https://svnweb.freebsd.org/changeset/base/356783

Log:
  MFC r356545:
  Fix a XHCI driver issue with Intel's Gemini Lake SOC.
  
  Do not configure any endpoint twice, but instead keep track of which
  endpoints are configured on a per device basis, and use an evaluate
  endpoint context command instead. When changing the configuration make
  sure all endpoints get deconfigured and the configured endpoint mask
  is reset.
  
  This fixes an issue where an endpoint might stop working if there is
  an error and the endpoint needs to be reconfigured as a part of the
  error recovery mechanism in the FreeBSD USB stack.
  
  Tested by:shichun...@dell.com
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/controller/xhci.c
  stable/10/sys/dev/usb/controller/xhci.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/controller/xhci.c
==
--- stable/10/sys/dev/usb/controller/xhci.c Thu Jan 16 08:52:54 2020
(r356782)
+++ stable/10/sys/dev/usb/controller/xhci.c Thu Jan 16 08:53:59 2020
(r356783)
@@ -3841,6 +3841,7 @@ xhci_configure_reset_endpoint(struct usb_xfer *xfer)
struct usb_page_cache *pcinp;
usb_error_t err;
usb_stream_t stream_id;
+   uint32_t mask;
uint8_t index;
uint8_t epno;
 
@@ -3906,16 +3907,20 @@ xhci_configure_reset_endpoint(struct usb_xfer *xfer)
 * endpoint context state diagram in the XHCI specification:
 */
 
-   xhci_configure_mask(udev, (1U << epno) | 1U, 0);
+   mask = (1U << epno);
+   xhci_configure_mask(udev, mask | 1U, 0);
 
-   if (epno > 1)
+   if (!(sc->sc_hw.devs[index].ep_configured & mask)) {
+   sc->sc_hw.devs[index].ep_configured |= mask;
err = xhci_cmd_configure_ep(sc, buf_inp.physaddr, 0, index);
-   else
+   } else {
err = xhci_cmd_evaluate_ctx(sc, buf_inp.physaddr, index);
+   }
 
-   if (err != 0)
-   DPRINTF("Could not configure endpoint %u\n", epno);
-
+   if (err != 0) {
+   DPRINTF("Could not configure "
+   "endpoint %u at slot %u.\n", epno, index);
+   }
XHCI_CMD_UNLOCK(sc);
 
return (0);
@@ -4276,6 +4281,7 @@ xhci_device_state_change(struct usb_device *udev)
 
/* set default state */
sc->sc_hw.devs[index].state = XHCI_ST_DEFAULT;
+   sc->sc_hw.devs[index].ep_configured = 3U;
 
/* reset number of contexts */
sc->sc_hw.devs[index].context_num = 0;
@@ -4293,6 +4299,7 @@ xhci_device_state_change(struct usb_device *udev)
break;
 
sc->sc_hw.devs[index].state = XHCI_ST_ADDRESSED;
+   sc->sc_hw.devs[index].ep_configured = 3U;
 
/* set configure mask to slot only */
xhci_configure_mask(udev, 1, 0);
@@ -4307,11 +4314,19 @@ xhci_device_state_change(struct usb_device *udev)
break;
 
case USB_STATE_CONFIGURED:
-   if (sc->sc_hw.devs[index].state == XHCI_ST_CONFIGURED)
-   break;
+   if (sc->sc_hw.devs[index].state == XHCI_ST_CONFIGURED) {
+   /* deconfigure all endpoints, except EP0 */
+   err = xhci_cmd_configure_ep(sc, 0, 1, index);
 
+   if (err) {
+   DPRINTF("Failed to deconfigure "
+   "slot %u.\n", index);
+   }
+   }
+
/* set configured state */
sc->sc_hw.devs[index].state = XHCI_ST_CONFIGURED;
+   sc->sc_hw.devs[index].ep_configured = 3U;
 
/* reset number of contexts */
sc->sc_hw.devs[index].context_num = 0;

Modified: stable/10/sys/dev/usb/controller/xhci.h
==
--- stable/10/sys/dev/usb/controller/xhci.h Thu Jan 16 08:52:54 2020
(r356782)
+++ stable/10/sys/dev/usb/controller/xhci.h Thu Jan 16 08:53:59 2020
(r356783)
@@ -406,6 +406,8 @@ struct xhci_hw_dev {
 
struct xhci_endpoint_ext endp[XHCI_MAX_ENDPOINTS];
 
+   uint32_tep_configured;
+
uint8_t state;
uint8_t nports;
uint8_t tt;
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r356681 - in stable/10/sys: dev/usb sys

2020-01-13 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jan 13 11:33:03 2020
New Revision: 356681
URL: https://svnweb.freebsd.org/changeset/base/356681

Log:
  MFC r356409:
  Add own counter for cancelled USB transfers.
  Do not count these as errors.
  
  Bump the FreeBSD version to force recompilation of external modules.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/usb_device.h
  stable/10/sys/dev/usb/usb_transfer.c
  stable/10/sys/sys/param.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/usb_device.h
==
--- stable/10/sys/dev/usb/usb_device.h  Mon Jan 13 11:30:07 2020
(r356680)
+++ stable/10/sys/dev/usb/usb_device.h  Mon Jan 13 11:33:03 2020
(r356681)
@@ -189,6 +189,7 @@ struct usb_device {
/* statistics */
struct usb_device_statistics stats_err;
struct usb_device_statistics stats_ok;
+   struct usb_device_statistics stats_cancelled;
 
/* generic clear stall message */
struct usb_udev_msg cs_msg[2];

Modified: stable/10/sys/dev/usb/usb_transfer.c
==
--- stable/10/sys/dev/usb/usb_transfer.cMon Jan 13 11:30:07 2020
(r356680)
+++ stable/10/sys/dev/usb/usb_transfer.cMon Jan 13 11:33:03 2020
(r356681)
@@ -2592,7 +2592,10 @@ usbd_transfer_done(struct usb_xfer *xfer, usb_error_t 
}
 #endif
/* keep some statistics */
-   if (xfer->error) {
+   if (xfer->error == USB_ERR_CANCELLED) {
+   info->udev->stats_cancelled.uds_requests
+   [xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE]++;
+   } else if (xfer->error != USB_ERR_NORMAL_COMPLETION) {
info->udev->stats_err.uds_requests
[xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE]++;
} else {

Modified: stable/10/sys/sys/param.h
==
--- stable/10/sys/sys/param.h   Mon Jan 13 11:30:07 2020(r356680)
+++ stable/10/sys/sys/param.h   Mon Jan 13 11:33:03 2020(r356681)
@@ -58,7 +58,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1004502  /* Master, propagated to newvers */
+#define __FreeBSD_version 1004503  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r356412 - stable/10/sys/dev/hyperv/netvsc

2020-01-06 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jan  6 09:51:54 2020
New Revision: 356412
URL: https://svnweb.freebsd.org/changeset/base/356412

Log:
  MFC r356201:
  Fix spelling.
  
  PR:   242891
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/hyperv/netvsc/if_hn.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c
==
--- stable/10/sys/dev/hyperv/netvsc/if_hn.c Mon Jan  6 09:51:22 2020
(r356411)
+++ stable/10/sys/dev/hyperv/netvsc/if_hn.c Mon Jan  6 09:51:54 2020
(r356412)
@@ -1502,7 +1502,7 @@ hn_vf_rss_fixup(struct hn_softc *sc, bool reconf)
strlcpy(ifrk.ifrk_name, vf_ifp->if_xname, sizeof(ifrk.ifrk_name));
error = vf_ifp->if_ioctl(vf_ifp, SIOCGIFRSSKEY, (caddr_t));
if (error) {
-   if_printf(ifp, "%s SIOCGRSSKEY failed: %d\n",
+   if_printf(ifp, "%s SIOCGIFRSSKEY failed: %d\n",
vf_ifp->if_xname, error);
goto done;
}
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r356407 - stable/10/usr.sbin/usbconfig

2020-01-06 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jan  6 09:40:18 2020
New Revision: 356407
URL: https://svnweb.freebsd.org/changeset/base/356407

Log:
  MFC r351146:
  Implement detach_kernel_driver command in usbconfig(8).
  
  Submitted by: Kevin Zheng 
  PR:   239916

Modified:
  stable/10/usr.sbin/usbconfig/usbconfig.8
  stable/10/usr.sbin/usbconfig/usbconfig.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/usbconfig/usbconfig.8
==
--- stable/10/usr.sbin/usbconfig/usbconfig.8Mon Jan  6 09:38:57 2020
(r356406)
+++ stable/10/usr.sbin/usbconfig/usbconfig.8Mon Jan  6 09:40:18 2020
(r356407)
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd April 29, 2018
+.Dd August 16, 2019
 .Dt USBCONFIG 8
 .Os
 .Sh NAME
@@ -52,6 +52,9 @@ Should only be used in conjunction with the unit argum
 .It Fl d Ar [ugen].
 Limit device range to USB devices connected to the given unit and address.
 The unit and address coordinates may be prefixed by the lowercased word "ugen".
+.It Fl i Ar interface_index
+Specify interface index as indicated by the command description.
+If this argument is not specified a value of zero will be used for the 
interface index.
 .It Fl h
 Show help and available commands.
 .El
@@ -71,7 +74,7 @@ the interface drivers and reducing the power consumpti
 but without going into power saving mode or detaching from the bus.
 In some cases, it prevents the device from charging.
 .It Cm set_alt Ar alt_index
-Choose the alternate interface for the USB device.
+Choose the alternate interface for the selected interface and USB device.
 Alternative settings for the current configuration are available as the
 .Ar bAlternateSetting
 in
@@ -119,6 +122,8 @@ Display the list of interface drivers (such as
 or
 .Xr u3g 4 )
 currently attached to the device.
+.It Cm detach_kernel_driver
+Detach kernel driver for the selected interface and USB device.
 .It Cm suspend
 Force the device to suspend.
 .It Cm resume

Modified: stable/10/usr.sbin/usbconfig/usbconfig.c
==
--- stable/10/usr.sbin/usbconfig/usbconfig.cMon Jan  6 09:38:57 2020
(r356406)
+++ stable/10/usr.sbin/usbconfig/usbconfig.cMon Jan  6 09:40:18 2020
(r356407)
@@ -87,6 +87,7 @@ struct options {
uint8_t got_add_quirk:1;
uint8_t got_dump_string:1;
uint8_t got_do_request:1;
+   uint8_t got_detach_kernel_driver:1;
 };
 
 struct token {
@@ -109,6 +110,7 @@ enum {
T_ADD_QUIRK,
T_REMOVE_QUIRK,
T_SHOW_IFACE_DRIVER,
+   T_DETACH_KERNEL_DRIVER,
T_DUMP_QUIRK_NAMES,
T_DUMP_DEVICE_QUIRKS,
T_DUMP_ALL_DESC,
@@ -142,6 +144,7 @@ static const struct token token[] = {
{"remove_dev_quirk_vplh", T_REMOVE_DEVICE_QUIRK, 5},
{"add_quirk", T_ADD_QUIRK, 1},
{"remove_quirk", T_REMOVE_QUIRK, 1},
+   {"detach_kernel_driver", T_DETACH_KERNEL_DRIVER, 0},
{"dump_quirk_names", T_DUMP_QUIRK_NAMES, 0},
{"dump_device_quirks", T_DUMP_DEVICE_QUIRKS, 0},
{"dump_all_desc", T_DUMP_ALL_DESC, 0},
@@ -282,6 +285,7 @@ usage(void)
"  remove_dev_quirk_vplh " "\n"
"  add_quirk " "\n"
"  remove_quirk " "\n"
+   "  detach_kernel_driver" "\n"
"  dump_quirk_names" "\n"
"  dump_device_quirks" "\n"
"  dump_all_desc" "\n"
@@ -490,6 +494,11 @@ flush_command(struct libusb20_backend *pbe, struct opt
err(1, "could not set power ON");
}
}
+   if (opt->got_detach_kernel_driver) {
+   if (libusb20_dev_detach_kernel_driver(pdev, 
opt->iface)) {
+   err(1, "could not detach kernel driver");
+   }
+   }
dump_any =
(opt->got_dump_all_desc ||
opt->got_dump_device_desc ||
@@ -606,6 +615,13 @@ main(int argc, char **argv)
opt->quirkname = argv[n + 5];
n += 5;
opt->got_remove_device_quirk = 1;
+   opt->got_any++;
+   break;
+
+   case T_DETACH_KERNEL_DRIVER:
+   if (opt->got_detach_kernel_driver)
+   duplicate_option(argv[n]);
+   opt->got_detach_kernel_driver = 1;
opt->got_any++;
break;
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r356408 - stable/10/usr.sbin/usbconfig

2020-01-06 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jan  6 09:40:59 2020
New Revision: 356408
URL: https://svnweb.freebsd.org/changeset/base/356408

Log:
  MFC r356137:
  Implement dump_stats command for usbconfig(8).
  
  This command is useful when debugging USB device issues.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/usr.sbin/usbconfig/dump.c
  stable/10/usr.sbin/usbconfig/dump.h
  stable/10/usr.sbin/usbconfig/usbconfig.8
  stable/10/usr.sbin/usbconfig/usbconfig.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/usbconfig/dump.c
==
--- stable/10/usr.sbin/usbconfig/dump.c Mon Jan  6 09:40:18 2020
(r356407)
+++ stable/10/usr.sbin/usbconfig/dump.c Mon Jan  6 09:40:59 2020
(r356408)
@@ -481,3 +481,32 @@ dump_string_by_index(struct libusb20_device *pdev, uin
}
free(pbuf);
 }
+
+void
+dump_device_stats(struct libusb20_device *pdev)
+{
+   struct libusb20_device_stats st;
+
+   if (libusb20_dev_get_stats(pdev, )) {
+   printf("{}\n");
+   } else {
+   printf("{\n"
+   "UE_CONTROL_OK   : %llu\n"
+   "UE_ISOCHRONOUS_OK   : %llu\n"
+   "UE_BULK_OK  : %llu\n"
+   "UE_INTERRUPT_OK : %llu\n"
+   "UE_CONTROL_FAIL : %llu\n"
+   "UE_ISOCHRONOUS_FAIL : %llu\n"
+   "UE_BULK_FAIL: %llu\n"
+   "UE_INTERRUPT_FAIL   : %llu\n"
+   "}\n",
+   (unsigned long long)st.xfer_ok[0],
+   (unsigned long long)st.xfer_ok[1],
+   (unsigned long long)st.xfer_ok[2],
+   (unsigned long long)st.xfer_ok[3],
+   (unsigned long long)st.xfer_fail[0],
+   (unsigned long long)st.xfer_fail[1],
+   (unsigned long long)st.xfer_fail[2],
+   (unsigned long long)st.xfer_fail[3]);
+   }
+}

Modified: stable/10/usr.sbin/usbconfig/dump.h
==
--- stable/10/usr.sbin/usbconfig/dump.h Mon Jan  6 09:40:18 2020
(r356407)
+++ stable/10/usr.sbin/usbconfig/dump.h Mon Jan  6 09:40:59 2020
(r356408)
@@ -35,6 +35,7 @@ void  dump_device_info(struct libusb20_device *pdev, ui
 void   dump_be_quirk_names(struct libusb20_backend *pbe);
 void   dump_be_dev_quirks(struct libusb20_backend *pbe);
 void   dump_device_desc(struct libusb20_device *pdev);
+void   dump_device_stats(struct libusb20_device *pdev);
 void   dump_config(struct libusb20_device *pdev, uint8_t all_cfg);
 
 #endif /* _DUMP_H_ */

Modified: stable/10/usr.sbin/usbconfig/usbconfig.8
==
--- stable/10/usr.sbin/usbconfig/usbconfig.8Mon Jan  6 09:40:18 2020
(r356407)
+++ stable/10/usr.sbin/usbconfig/usbconfig.8    Mon Jan  6 09:40:59 2020
(r356408)
@@ -1,6 +1,6 @@
 .\" $FreeBSD$
 .\"
-.\" Copyright (c) 2008-2010 Hans Petter Selasky. All rights reserved.
+.\" Copyright (c) 2008-2019 Hans Petter Selasky. All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd August 16, 2019
+.Dd December 27, 2019
 .Dt USBCONFIG 8
 .Os
 .Sh NAME
@@ -116,6 +116,8 @@ Display all the configuration descriptors.
 Display string descriptor at selected index.
 .It Cm dump_info
 Display summary information about the device.
+.It Cm dump_stats
+Display USB transfer statistics.
 .It Cm show_ifdrv
 Display the list of interface drivers (such as
 .Xr ukbd 4

Modified: stable/10/usr.sbin/usbconfig/usbconfig.c
==
--- stable/10/usr.sbin/usbconfig/usbconfig.cMon Jan  6 09:40:18 2020
(r356407)
+++ stable/10/usr.sbin/usbconfig/usbconfig.cMon Jan  6 09:40:59 2020
(r356408)
@@ -80,6 +80,7 @@ struct options {
uint8_t got_dump_curr_config:1;
uint8_t got_dump_all_config:1;
uint8_t got_dump_info:1;
+   uint8_t got_dump_stats:1;
uint8_t got_show_iface_driver:1;
uint8_t got_remove_device_quirk:1;
uint8_t got_add_device_quirk:1;
@@ -119,6 +120,7 @@ enum {
T_DUMP_ALL_CONFIG_DESC,
T_DUMP_STRING,
T_DUMP_INFO,
+   T_DUMP_STATS,
T_SUSPEND,
T_RESUME,
T_POWER_OFF,
@@ -153,6 +155,7 @@ static const struct token token[] = {
{"dump_all_config_desc", T_DUMP_ALL_CONFIG_DESC, 0}

svn commit: r356406 - stable/10/usr.sbin/usbconfig

2020-01-06 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jan  6 09:38:57 2020
New Revision: 356406
URL: https://svnweb.freebsd.org/changeset/base/356406

Log:
  MFC r333089:
  Clean up the EXAMPLES section of usbconfig(8).  This removes parts that
  become redundant after documenting all the subcommands, and switches
  to the new syntax, without the '-d'.
  
  Reviewed by:  hselasky@
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/10/usr.sbin/usbconfig/usbconfig.8
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/usbconfig/usbconfig.8
==
--- stable/10/usr.sbin/usbconfig/usbconfig.8Mon Jan  6 09:38:08 2020
(r356405)
+++ stable/10/usr.sbin/usbconfig/usbconfig.8Mon Jan  6 09:38:57 2020
(r356406)
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd April 17, 2018
+.Dd April 29, 2018
 .Dt USBCONFIG 8
 .Os
 .Sh NAME
@@ -146,33 +146,21 @@ See
 for more information.
 .El
 .Sh EXAMPLES
-Show information about the device on USB bus 1 at address 2:
+List all connected USB devices and their attached interface drivers:
 .Pp
-.Dl usbconfig -d ugen1.2 dump_info
+.Dl usbconfig show_ifdrv
 .Pp
-Dump HID descriptor for device on USB bus 1 at address 2:
+Dump device and configuration descriptors for device on USB bus 1 at address 2:
 .Pp
-.Dl usbconfig -d ugen1.2 do_request 0x81 0x06 0x2200 0 0x100
+.Dl usbconfig ugen1.2 dump_all_desc
 .Pp
-Dump string descriptor at index Z for device on USB bus 1 at address 2:
+Dump HID descriptor for device on USB bus 1 at address 2:
 .Pp
-.Dl usbconfig -d ugen1.2 dump_string Z
+.Dl usbconfig ugen1.2 do_request 0x81 0x06 0x2200 0 0x100
 .Pp
-Dump current configuration descriptor for device on USB bus 1 at address 2:
+Power off the device on USB bus 1 at address 2:
 .Pp
-.Dl usbconfig -d ugen1.2 dump_curr_config_desc
-.Pp
-Dump device descriptor for device on USB bus 1 at address 2:
-.Pp
-.Dl usbconfig -d ugen1.2 dump_device_desc
-.Pp
-Program the device on USB bus 1 at address 2 to suspend, resume, power off, go 
into power save, or power on:
-.Pp
-.Dl usbconfig -d ugen1.2 suspend
-.Dl usbconfig -d ugen1.2 resume
-.Dl usbconfig -d ugen1.2 power_off
-.Dl usbconfig -d ugen1.2 power_save
-.Dl usbconfig -d ugen1.2 power_on
+.Dl usbconfig ugen1.2 power_off
 .Sh SEE ALSO
 .Xr usb 4 ,
 .Xr usb_quirk 4 ,
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r356405 - stable/10/usr.sbin/usbconfig

2020-01-06 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jan  6 09:38:08 2020
New Revision: 356405
URL: https://svnweb.freebsd.org/changeset/base/356405

Log:
  MFC r332659:
  Make it possible to pass the ugenX.Y to usbconfig(8) without using "-d",
  eg "usbconfig ugen1.2 dump_all_desc".
  
  Reviewed by:  hselasky@
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/10/usr.sbin/usbconfig/usbconfig.8
  stable/10/usr.sbin/usbconfig/usbconfig.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/usbconfig/usbconfig.8
==
--- stable/10/usr.sbin/usbconfig/usbconfig.8Mon Jan  6 09:37:13 2020
(r356404)
+++ stable/10/usr.sbin/usbconfig/usbconfig.8Mon Jan  6 09:38:08 2020
(r356405)
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd December 30, 2017
+.Dd April 17, 2018
 .Dt USBCONFIG 8
 .Os
 .Sh NAME
@@ -35,7 +35,7 @@
 .Op Fl a Ar addr
 .Op cmds...
 .Nm
-.Op Fl d Ar [ugen].
+.Op Oo Fl d Oc Ar [ugen].
 .Op cmds...
 .Sh DESCRIPTION
 The

Modified: stable/10/usr.sbin/usbconfig/usbconfig.c
==
--- stable/10/usr.sbin/usbconfig/usbconfig.cMon Jan  6 09:37:13 2020
(r356404)
+++ stable/10/usr.sbin/usbconfig/usbconfig.cMon Jan  6 09:38:08 2020
(r356405)
@@ -818,6 +818,29 @@ main(int argc, char **argv)
opt->got_any++;
break;
default:
+   if (n == 1) {
+   ptr = argv[n];
+
+   if ((ptr[0] == 'u') &&
+   (ptr[1] == 'g') &&
+   (ptr[2] == 'e') &&
+   (ptr[3] == 'n'))
+   ptr += 4;
+
+   if ((sscanf(ptr, "%d.%d",
+   , ) != 2) ||
+   (unit < 0) || (unit > 65535) ||
+   (addr < 0) || (addr > 65535)) {
+   usage();
+   break;
+   }
+
+   opt->bus = unit;
+   opt->addr = addr;
+   opt->got_bus = 1;
+   opt->got_addr = 1;
+   break;
+   }
usage();
break;
}
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r356404 - stable/10/usr.sbin/usbconfig

2020-01-06 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jan  6 09:37:13 2020
New Revision: 356404
URL: https://svnweb.freebsd.org/changeset/base/356404

Log:
  MFC r330875:
  Add "usbconfig dump_all_desc", a subcommand to dump all device and config
  descriptors.
  
  Reviewed by:  hselasky@
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/10/usr.sbin/usbconfig/usbconfig.8
  stable/10/usr.sbin/usbconfig/usbconfig.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/usbconfig/usbconfig.8
==
--- stable/10/usr.sbin/usbconfig/usbconfig.8Mon Jan  6 09:35:57 2020
(r356403)
+++ stable/10/usr.sbin/usbconfig/usbconfig.8Mon Jan  6 09:37:13 2020
(r356404)
@@ -97,6 +97,8 @@ Remove a quirk.
 Add quirk for the currently selected USB device.
 .It Cm remove_quirk Ar quirk_name
 Remove a quirk for the currently selected USB device.
+.It Cm dump_all_desc
+Display the device and configuration descriptors.
 .It Cm dump_quirk_names
 Display the list of supported quirk names.
 .It Cm dump_device_quirks

Modified: stable/10/usr.sbin/usbconfig/usbconfig.c
==
--- stable/10/usr.sbin/usbconfig/usbconfig.cMon Jan  6 09:35:57 2020
(r356403)
+++ stable/10/usr.sbin/usbconfig/usbconfig.cMon Jan  6 09:37:13 2020
(r356404)
@@ -75,6 +75,7 @@ struct options {
uint8_t got_power_on:1;
uint8_t got_dump_device_quirks:1;
uint8_t got_dump_quirk_names:1;
+   uint8_t got_dump_all_desc:1;
uint8_t got_dump_device_desc:1;
uint8_t got_dump_curr_config:1;
uint8_t got_dump_all_config:1;
@@ -110,6 +111,7 @@ enum {
T_SHOW_IFACE_DRIVER,
T_DUMP_QUIRK_NAMES,
T_DUMP_DEVICE_QUIRKS,
+   T_DUMP_ALL_DESC,
T_DUMP_DEVICE_DESC,
T_DUMP_CURR_CONFIG_DESC,
T_DUMP_ALL_CONFIG_DESC,
@@ -142,6 +144,7 @@ static const struct token token[] = {
{"remove_quirk", T_REMOVE_QUIRK, 1},
{"dump_quirk_names", T_DUMP_QUIRK_NAMES, 0},
{"dump_device_quirks", T_DUMP_DEVICE_QUIRKS, 0},
+   {"dump_all_desc", T_DUMP_ALL_DESC, 0},
{"dump_device_desc", T_DUMP_DEVICE_DESC, 0},
{"dump_curr_config_desc", T_DUMP_CURR_CONFIG_DESC, 0},
{"dump_all_config_desc", T_DUMP_ALL_CONFIG_DESC, 0},
@@ -281,6 +284,7 @@ usage(void)
"  remove_quirk " "\n"
"  dump_quirk_names" "\n"
"  dump_device_quirks" "\n"
+   "  dump_all_desc" "\n"
"  dump_device_desc" "\n"
"  dump_curr_config_desc" "\n"
"  dump_all_config_desc" "\n"
@@ -487,7 +491,8 @@ flush_command(struct libusb20_backend *pbe, struct opt
}
}
dump_any =
-   (opt->got_dump_device_desc ||
+   (opt->got_dump_all_desc ||
+   opt->got_dump_device_desc ||
opt->got_dump_curr_config ||
opt->got_dump_all_config ||
opt->got_dump_info);
@@ -506,6 +511,10 @@ flush_command(struct libusb20_backend *pbe, struct opt
} else if (opt->got_dump_curr_config) {
printf("\n");
dump_config(pdev, 0);
+   } else if (opt->got_dump_all_desc) {
+   printf("\n");
+   dump_device_desc(pdev);
+   dump_config(pdev, 1);
}
if (dump_any) {
printf("\n");
@@ -692,6 +701,12 @@ main(int argc, char **argv)
if (opt->got_get_template)
duplicate_option(argv[n]);
opt->got_get_template = 1;
+   opt->got_any++;
+   break;
+   case T_DUMP_ALL_DESC:
+   if (opt->got_dump_all_desc)
+   duplicate_option(argv[n]);
+   opt->got_dump_all_desc = 1;
opt->got_any++;
break;
case T_DUMP_DEVICE_DESC:
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r356403 - stable/10/usr.sbin/usbconfig

2020-01-06 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jan  6 09:35:57 2020
New Revision: 356403
URL: https://svnweb.freebsd.org/changeset/base/356403

Log:
  MFC r327522:
  Fix warnings from "mandoc -Tlint -Wwarning".
  
  Reported by:  Yuri Pankov 
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/10/usr.sbin/usbconfig/usbconfig.8
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/usbconfig/usbconfig.8
==
--- stable/10/usr.sbin/usbconfig/usbconfig.8Mon Jan  6 09:35:11 2020
(r356402)
+++ stable/10/usr.sbin/usbconfig/usbconfig.8Mon Jan  6 09:35:57 2020
(r356403)
@@ -144,7 +144,6 @@ See
 for more information.
 .El
 .Sh EXAMPLES
-.Pp
 Show information about the device on USB bus 1 at address 2:
 .Pp
 .Dl usbconfig -d ugen1.2 dump_info
@@ -172,7 +171,6 @@ Program the device on USB bus 1 at address 2 to suspen
 .Dl usbconfig -d ugen1.2 power_off
 .Dl usbconfig -d ugen1.2 power_save
 .Dl usbconfig -d ugen1.2 power_on
-.Pp
 .Sh SEE ALSO
 .Xr usb 4 ,
 .Xr usb_quirk 4 ,
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r356402 - stable/10/usr.sbin/usbconfig

2020-01-06 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jan  6 09:35:11 2020
New Revision: 356402
URL: https://svnweb.freebsd.org/changeset/base/356402

Log:
  MFC r327382:
  Improve usbconfig(8) manual page by adding descriptions for subcommands.
  
  Reviewed by:  hselasky
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D13445

Modified:
  stable/10/usr.sbin/usbconfig/usbconfig.8
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/usbconfig/usbconfig.8
==
--- stable/10/usr.sbin/usbconfig/usbconfig.8Mon Jan  6 09:24:47 2020
(r356401)
+++ stable/10/usr.sbin/usbconfig/usbconfig.8Mon Jan  6 09:35:11 2020
(r356402)
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd January 6, 2010
+.Dd December 30, 2017
 .Dt USBCONFIG 8
 .Os
 .Sh NAME
@@ -56,45 +56,124 @@ The unit and address coordinates may be prefixed by th
 Show help and available commands.
 .El
 .Pp
-When called without options,
+The following commands may be used with
+.Nm :
+.Bl -tag -width indent
+.It Cm set_config Ar cfg_index
+Choose the configuration for the USB device.
+Valid values range from zero to the number reported as the
+.Ar bNumConfigurations
+in
+.Cm dump_device_desc
+output.
+The special value of 255 unconfigures the device, detaching
+the interface drivers and reducing the power consumption to minimum,
+but without going into power saving mode or detaching from the bus.
+In some cases, it prevents the device from charging.
+.It Cm set_alt Ar alt_index
+Choose the alternate interface for the USB device.
+Alternative settings for the current configuration are available as the
+.Ar bAlternateSetting
+in
+.Cm dump_curr_config_desc
+output.
+Usually there is no need to adjust this setting.
+.It Cm set_template Ar template
+Set the global USB device side template.
+See
+.Xr usb_template 4
+for more information.
+.It Cm get_template
+Get the current USB device side template.
+.It Cm add_dev_quirk_vplh Ar vid Ar pid Ar lo_rev Ar hi_rev Ar quirk_name
+Add a quirk by specifying the Vendor ID, Product ID, low and high
+revision numbers, and the quirk name.
+See
+.Xr usb_quirk 4
+for more information.
+.It Cm remove_dev_quirk_vplh Ar vid Ar pid Ar lo_rev Ar hi_rev Ar quirk_name
+Remove a quirk.
+.It Cm add_quirk Ar quirk_name
+Add quirk for the currently selected USB device.
+.It Cm remove_quirk Ar quirk_name
+Remove a quirk for the currently selected USB device.
+.It Cm dump_quirk_names
+Display the list of supported quirk names.
+.It Cm dump_device_quirks
+Display the list of current device quirks.
+.It Cm dump_device_desc
+Display the device descriptor.
+.It Cm dump_curr_config_desc
+Display current configuration descriptor.
+.It Cm dump_all_config_desc
+Display all the configuration descriptors.
+.It Cm dump_string Ar index
+Display string descriptor at selected index.
+.It Cm dump_info
+Display summary information about the device.
+.It Cm show_ifdrv
+Display the list of interface drivers (such as
+.Xr ukbd 4
+or
+.Xr u3g 4 )
+currently attached to the device.
+.It Cm suspend
+Force the device to suspend.
+.It Cm resume
+Force the device to resume.
+.It Cm power_off
+Turn the device off.
+.It Cm power_save
+Turn the automatic suspend and resume on.
+This is the default for USB hubs.
+.It Cm power_on
+Turn the device on and disable automatic suspend and resume.
+This is the default for non-hub devices.
+.It Cm reset
+Reset the device.
+This forces the USB stack to reenumerate the bus.
+.It Cm list
+List all available USB devices.
+This is the default if
 .Nm
-prints a list of all available USB devices.
+is called without specifying a command.
+.It Cm do_request Ar bmReqTyp Ar bReq Ar wVal Ar wIdx Ar wLen Ar data...
+Perform a synchronous control request on the specified device.
+See
+.Xr libusb20_dev_request_sync 3
+for more information.
+.El
 .Sh EXAMPLES
+.Pp
 Show information about the device on USB bus 1 at address 2:
 .Pp
-.Dl usbconfig -u 1 -a 2 dump_info
+.Dl usbconfig -d ugen1.2 dump_info
 .Pp
 Dump HID descriptor for device on USB bus 1 at address 2:
 .Pp
-.Dl usbconfig -u 1 -a 2 do_request 0x81 0x06 0x2200 0 0x100
+.Dl usbconfig -d ugen1.2 do_request 0x81 0x06 0x2200 0 0x100
 .Pp
 Dump string descriptor at index Z for device on USB bus 1 at address 2:
 .Pp
-.Dl usbconfig -u 1 -a 2 dump_string Z
+.Dl usbconfig -d ugen1.2 dump_string Z
 .Pp
 Dump current configuration descriptor for device on USB bus 1 at address 2:
 .Pp
-.Dl usbconfig -u 1 -a 2 dump_curr_config_desc
+.Dl usbconfig -d ugen1.2 dump_curr_config_desc
 .Pp
 Dump device descriptor for device on USB bus 1 at address 2:
 .Pp
-.Dl usbconfig -u 1 -a 2 dump_device_desc
+.Dl usbconfig -d ugen1.2 dump_device_desc
 .Pp
 Program the device on USB bus 1 at address 2 to suspend, resume, power off, go 
into power save, or power on:
 .Pp
-.Dl usbconfig -u 1 -a 2 

svn commit: r356399 - stable/10/lib/libusb

2020-01-06 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jan  6 09:22:33 2020
New Revision: 356399
URL: https://svnweb.freebsd.org/changeset/base/356399

Log:
  MFC r356136:
  Implement new libusb v2.0 API function, libusb20_dev_get_stats().
  
  This function is useful when debugging USB device issues.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/lib/libusb/Makefile
  stable/10/lib/libusb/libusb20.3
  stable/10/lib/libusb/libusb20.c
  stable/10/lib/libusb/libusb20.h
  stable/10/lib/libusb/libusb20_int.h
  stable/10/lib/libusb/libusb20_ugen20.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libusb/Makefile
==
--- stable/10/lib/libusb/Makefile   Mon Jan  6 09:21:15 2020
(r356398)
+++ stable/10/lib/libusb/Makefile   Mon Jan  6 09:22:33 2020
(r356399)
@@ -222,6 +222,7 @@ MLINKS += libusb20.3 libusb20_dev_get_backend_name.3
 MLINKS += libusb20.3 libusb20_dev_get_info.3
 MLINKS += libusb20.3 libusb20_dev_get_iface_desc.3
 MLINKS += libusb20.3 libusb20_dev_get_desc.3
+MLINKS += libusb20.3 libusb20_dev_get_stats.3
 MLINKS += libusb20.3 libusb20_dev_close.3
 MLINKS += libusb20.3 libusb20_dev_detach_kernel_driver.3
 MLINKS += libusb20.3 libusb20_dev_set_config_index.3

Modified: stable/10/lib/libusb/libusb20.3
==
--- stable/10/lib/libusb/libusb20.3 Mon Jan  6 09:21:15 2020
(r356398)
+++ stable/10/lib/libusb/libusb20.3 Mon Jan  6 09:22:33 2020
(r356399)
@@ -1,5 +1,5 @@
 .\"
-.\" Copyright (c) 2008 Hans Petter Selasky
+.\" Copyright (c) 2008-2019 Hans Petter Selasky
 .\"
 .\" All rights reserved.
 .\"
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 3, 2013
+.Dd December 27, 2019
 .Dt LIBUSB20 3
 .Os
 .Sh NAME
@@ -122,6 +122,8 @@ USB access library (libusb -lusb)
 .Ft const char *
 .Fn libusb20_dev_get_desc "struct libusb20_device *pdev"
 .Ft int
+.Fn libusb20_dev_get_stats "struct libusb20_device *pdev" "struct 
libusb20_device_stats *pstats"
+.Ft int
 .Fn libusb20_dev_close "struct libusb20_device *pdev"
 .Ft int
 .Fn libusb20_dev_detach_kernel_driver "struct libusb20_device *pdev" "uint8_t 
iface_index"
@@ -594,6 +596,14 @@ This function returns zero on success else a LIBUSB20_
 .Fn libusb20_dev_get_desc
 returns a zero terminated string describing the given USB device.
 The format of the string is: "drivername: "
+.
+.Pp
+.
+.Fn libusb20_dev_get_stats
+retrieves the device statistics into the structure pointed to by the
+.Fa pstats
+argument.
+This function returns zero on success else a LIBUSB20_ERROR value is returned.
 .
 .Pp
 .

Modified: stable/10/lib/libusb/libusb20.c
==
--- stable/10/lib/libusb/libusb20.c Mon Jan  6 09:21:15 2020
(r356398)
+++ stable/10/lib/libusb/libusb20.c Mon Jan  6 09:22:33 2020
(r356399)
@@ -77,6 +77,7 @@ dummy_callback(struct libusb20_transfer *xfer)
 #definedummy_get_power_mode (void *)dummy_int
 #definedummy_get_port_path (void *)dummy_int
 #definedummy_get_power_usage (void *)dummy_int
+#definedummy_get_stats (void *)dummy_int
 #definedummy_kernel_driver_active (void *)dummy_int
 #definedummy_detach_kernel_driver (void *)dummy_int
 #definedummy_do_request_sync (void *)dummy_int
@@ -1027,6 +1028,31 @@ uint8_t
 libusb20_dev_get_speed(struct libusb20_device *pdev)
 {
return (pdev->usb_speed);
+}
+
+int
+libusb20_dev_get_stats(struct libusb20_device *pdev, struct 
libusb20_device_stats *pstats)
+{
+   uint8_t do_close;
+   int error;
+
+   if (!pdev->is_opened) {
+   error = libusb20_dev_open(pdev, 0);
+   if (error == 0) {
+   do_close = 1;
+   } else {
+   do_close = 0;
+   }
+   } else {
+   do_close = 0;
+   }
+
+   error = pdev->methods->get_stats(pdev, pstats);
+
+   if (do_close)
+   (void) libusb20_dev_close(pdev);
+
+   return (error);
 }
 
 /* if this function returns an error, the device is gone */

Modified: stable/10/lib/libusb/libusb20.h
==
--- stable/10/lib/libusb/libusb20.h Mon Jan  6 09:21:15 2020
(r356398)
+++ stable/10/lib/libusb/libusb20.h Mon Jan  6 09:22:33 2020
(r356399)
@@ -193,6 +193,12 @@ struct libusb20_quirk {
charquirkname[64 - 12];
 };
 
+struct libusb20_device_stats {
+   uint64_t xfer_ok[4];/* sorted by USB transfer type, UE_XXX 
*/
+   uint64_t xfer_fail[4];  /* sorted by USB transfer type, UE_XXX 
*/
+   uint64_t xfer_reserved[24]; /* reserv

svn commit: r356396 - in stable/10/sys: dev/usb sys

2020-01-06 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jan  6 09:16:41 2020
New Revision: 356396
URL: https://svnweb.freebsd.org/changeset/base/356396

Log:
  MFC r356135:
  Make USB statistics per device instead of per bus.
  
  Bump the FreeBSD version due to structure change to
  force recompilation of external USB modules.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/usb_bus.h
  stable/10/sys/dev/usb/usb_device.h
  stable/10/sys/dev/usb/usb_generic.c
  stable/10/sys/dev/usb/usb_transfer.c
  stable/10/sys/sys/param.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/usb_bus.h
==
--- stable/10/sys/dev/usb/usb_bus.h Mon Jan  6 09:10:13 2020
(r356395)
+++ stable/10/sys/dev/usb/usb_bus.h Mon Jan  6 09:16:41 2020
(r356396)
@@ -1,6 +1,6 @@
 /* $FreeBSD$ */
 /*-
- * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
+ * Copyright (c) 2008-2019 Hans Petter Selasky. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -40,19 +40,10 @@ struct usb_bus_msg {
 };
 
 /*
- * The following structure defines the USB statistics structure.
- */
-struct usb_bus_stat {
-   uint32_t uds_requests[4];
-};
-
-/*
  * The following structure defines an USB BUS. There is one USB BUS
  * for every Host or Device controller.
  */
 struct usb_bus {
-   struct usb_bus_stat stats_err;
-   struct usb_bus_stat stats_ok;
 #if USB_HAVE_ROOT_MOUNT_HOLD
struct root_hold_token *bus_roothold;
 #endif

Modified: stable/10/sys/dev/usb/usb_device.h
==
--- stable/10/sys/dev/usb/usb_device.h  Mon Jan  6 09:10:13 2020
(r356395)
+++ stable/10/sys/dev/usb/usb_device.h  Mon Jan  6 09:16:41 2020
(r356396)
@@ -1,6 +1,6 @@
 /* $FreeBSD$ */
 /*-
- * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
+ * Copyright (c) 2008-2019 Hans Petter Selasky. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -175,10 +175,21 @@ union usb_device_scratch {
 };
 
 /*
+ * Helper structure to keep track of USB device statistics.
+ */
+struct usb_device_statistics {
+   uint32_t uds_requests[4];
+};
+
+/*
  * The following structure defines an USB device. There exists one of
  * these structures for every USB device.
  */
 struct usb_device {
+   /* statistics */
+   struct usb_device_statistics stats_err;
+   struct usb_device_statistics stats_ok;
+
/* generic clear stall message */
struct usb_udev_msg cs_msg[2];
struct sx enum_sx;

Modified: stable/10/sys/dev/usb/usb_generic.c
==
--- stable/10/sys/dev/usb/usb_generic.c Mon Jan  6 09:10:13 2020
(r356395)
+++ stable/10/sys/dev/usb/usb_generic.c Mon Jan  6 09:16:41 2020
(r356396)
@@ -,10 +,9 @@ ugen_ioctl_post(struct usb_fifo *f, u_long cmd, void *
for (n = 0; n != 4; n++) {
 
u.stat->uds_requests_fail[n] =
-   f->udev->bus->stats_err.uds_requests[n];
-
+   f->udev->stats_err.uds_requests[n];
u.stat->uds_requests_ok[n] =
-   f->udev->bus->stats_ok.uds_requests[n];
+   f->udev->stats_ok.uds_requests[n];
}
break;
 

Modified: stable/10/sys/dev/usb/usb_transfer.c
==
--- stable/10/sys/dev/usb/usb_transfer.cMon Jan  6 09:10:13 2020
(r356395)
+++ stable/10/sys/dev/usb/usb_transfer.cMon Jan  6 09:16:41 2020
(r356396)
@@ -2593,10 +2593,10 @@ usbd_transfer_done(struct usb_xfer *xfer, usb_error_t 
 #endif
/* keep some statistics */
if (xfer->error) {
-   info->bus->stats_err.uds_requests
+   info->udev->stats_err.uds_requests
[xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE]++;
} else {
-   info->bus->stats_ok.uds_requests
+   info->udev->stats_ok.uds_requests
[xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE]++;
}
 

Modified: stable/10/sys/sys/param.h
==
--- stable/10/sys/sys/param.h   Mon Jan  6 09:10:13 2020(r356395)
+++ stable/10/sys/sys/param.h   Mon Jan  6 09:16:41 2020(r356396)
@@ -58,7 +58,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1004501  

svn commit: r356074 - stable/10/sys/dev/mlx5

2019-12-25 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Dec 25 09:34:16 2019
New Revision: 356074
URL: https://svnweb.freebsd.org/changeset/base/356074

Log:
  MFC r355447:
  Fix compilation issue with mlx5core and sparc64 (gcc48):
  
  sys/dev/mlx5/mlx5_en/mlx5_en_tx.c:335: error: requested alignment is not a 
constant
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/mlx5/qp.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/mlx5/qp.h
==
--- stable/10/sys/dev/mlx5/qp.h Wed Dec 25 09:33:37 2019(r356073)
+++ stable/10/sys/dev/mlx5/qp.h Wed Dec 25 09:34:16 2019(r356074)
@@ -135,11 +135,8 @@ enum {
MLX5_WQE_CTRL_SOLICITED = 1 << 1,
 };
 
-enum {
-   MLX5_SEND_WQE_DS= 16,
-   MLX5_SEND_WQE_BB= 64,
-};
-
+#defineMLX5_SEND_WQE_DS16
+#defineMLX5_SEND_WQE_BB64
 #define MLX5_SEND_WQEBB_NUM_DS (MLX5_SEND_WQE_BB / MLX5_SEND_WQE_DS)
 
 enum {
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r355419 - stable/10/sys/kern

2019-12-05 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Dec  5 14:53:46 2019
New Revision: 355419
URL: https://svnweb.freebsd.org/changeset/base/355419

Log:
  MFC r355108 and r355170:
  Fix panic when loading kernel modules before root file system is mounted.
  Make sure the rootvnode is always NULL checked.
  
  Differential Revision:https://reviews.freebsd.org/D22545
  PR:   241639
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/kern/kern_linker.c
  stable/10/sys/kern/subr_firmware.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/kern_linker.c
==
--- stable/10/sys/kern/kern_linker.cThu Dec  5 14:52:06 2019
(r355418)
+++ stable/10/sys/kern/kern_linker.cThu Dec  5 14:53:46 2019
(r355419)
@@ -2000,14 +2000,18 @@ linker_load_module(const char *kldname, const char *mo
 */
KASSERT(verinfo == NULL, ("linker_load_module: verinfo"
" is not NULL"));
+   /* check if root file system is not mounted */
+   if (rootvnode == NULL || curproc->p_fd->fd_rdir == NULL)
+   return (ENXIO);
pathname = linker_search_kld(kldname);
} else {
if (modlist_lookup2(modname, verinfo) != NULL)
return (EEXIST);
+   /* check if root file system is not mounted */
+   if (rootvnode == NULL || curproc->p_fd->fd_rdir == NULL)
+   return (ENXIO);
if (kldname != NULL)
pathname = strdup(kldname, M_LINKER);
-   else if (rootvnode == NULL)
-   pathname = NULL;
else
/*
 * Need to find a KLD with required module

Modified: stable/10/sys/kern/subr_firmware.c
==
--- stable/10/sys/kern/subr_firmware.c  Thu Dec  5 14:52:06 2019
(r355418)
+++ stable/10/sys/kern/subr_firmware.c  Thu Dec  5 14:53:46 2019
(r355419)
@@ -255,7 +255,6 @@ firmware_unregister(const char *imagename)
 static void
 loadimage(void *arg, int npending)
 {
-   struct thread *td = curthread;
char *imagename = arg;
struct priv_fw *fp;
linker_file_t result;
@@ -265,11 +264,6 @@ loadimage(void *arg, int npending)
mtx_lock(_mtx);
mtx_unlock(_mtx);
 
-   if (td->td_proc->p_fd->fd_rdir == NULL) {
-   printf("%s: root not mounted yet, no way to load image\n",
-   imagename);
-   goto done;
-   }
error = linker_reference_module(imagename, NULL, );
if (error != 0) {
printf("%s: could not load firmware image, error %d\n",
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r353179 - in stable/10/sys/dev/usb: . controller

2019-10-07 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Oct  7 08:25:25 2019
New Revision: 353179
URL: https://svnweb.freebsd.org/changeset/base/353179

Log:
  MFC r352556:
  Add quirk for XHCI(4) controllers to support USB control transfers
  above 1Kbyte.  It might look like some XHCI(4) controllers do not
  support when the USB control transfer is split using a link TRB. The
  next NORMAL TRB after the link TRB is simply failing with XHCI error
  code 4. The quirk ensures we allocate a 64Kbyte buffer so that the
  data stage TRB is not broken with a link TRB.
  
  Found at: EuroBSDcon 2019
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/controller/xhci.c
  stable/10/sys/dev/usb/usb_bus.h
  stable/10/sys/dev/usb/usb_transfer.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/controller/xhci.c
==
--- stable/10/sys/dev/usb/controller/xhci.c Mon Oct  7 08:24:46 2019
(r353178)
+++ stable/10/sys/dev/usb/controller/xhci.c Mon Oct  7 08:25:25 2019
(r353179)
@@ -605,6 +605,9 @@ xhci_init(struct xhci_softc *sc, device_t self, uint8_
device_printf(self, "%d bytes context size, %d-bit DMA\n",
sc->sc_ctx_is_64_byte ? 64 : 32, (int)sc->sc_bus.dma_bits);
 
+   /* enable 64Kbyte control endpoint quirk */
+   sc->sc_bus.control_ep_quirk = 1;
+
temp = XREAD4(sc, capa, XHCI_HCSPARAMS1);
 
/* get number of device slots */

Modified: stable/10/sys/dev/usb/usb_bus.h
==
--- stable/10/sys/dev/usb/usb_bus.h Mon Oct  7 08:24:46 2019
(r353178)
+++ stable/10/sys/dev/usb/usb_bus.h Mon Oct  7 08:25:25 2019
(r353179)
@@ -129,6 +129,7 @@ struct usb_bus {
uint8_t do_probe;   /* set if USB should be re-probed */
uint8_t no_explore; /* don't explore USB ports */
uint8_t dma_bits;   /* number of DMA address lines */
+   uint8_t control_ep_quirk;   /* need 64kByte buffer for data stage */
 };
 
 #endif /* _USB_BUS_H_ */

Modified: stable/10/sys/dev/usb/usb_transfer.c
==
--- stable/10/sys/dev/usb/usb_transfer.cMon Oct  7 08:24:46 2019
(r353178)
+++ stable/10/sys/dev/usb/usb_transfer.cMon Oct  7 08:25:25 2019
(r353179)
@@ -105,6 +105,33 @@ static const struct usb_config usb_control_ep_cfg[USB_
},
 };
 
+static const struct usb_config usb_control_ep_quirk_cfg[USB_CTRL_XFER_MAX] = {
+
+   /* This transfer is used for generic control endpoint transfers */
+
+   [0] = {
+   .type = UE_CONTROL,
+   .endpoint = 0x00,   /* Control endpoint */
+   .direction = UE_DIR_ANY,
+   .bufsize = 65535,   /* bytes */
+   .callback = _request_callback,
+   .usb_mode = USB_MODE_DUAL,  /* both modes */
+   },
+
+   /* This transfer is used for generic clear stall only */
+
+   [1] = {
+   .type = UE_CONTROL,
+   .endpoint = 0x00,   /* Control pipe */
+   .direction = UE_DIR_ANY,
+   .bufsize = sizeof(struct usb_device_request),
+   .callback = _do_clear_stall_callback,
+   .timeout = 1000,/* 1 second */
+   .interval = 50, /* 50ms */
+   .usb_mode = USB_MODE_HOST,
+   },
+};
+
 /* function prototypes */
 
 static voidusbd_update_max_frame_size(struct usb_xfer *);
@@ -1020,7 +1047,8 @@ usbd_transfer_setup(struct usb_device *udev,
 * context, else there is a chance of
 * deadlock!
 */
-   if (setup_start == usb_control_ep_cfg)
+   if (setup_start == usb_control_ep_cfg ||
+   setup_start == usb_control_ep_quirk_cfg)
info->done_p =
USB_BUS_CONTROL_XFER_PROC(udev->bus);
else if (xfer_mtx == )
@@ -3148,7 +3176,8 @@ repeat:
 */
iface_index = 0;
if (usbd_transfer_setup(udev, _index,
-   udev->ctrl_xfer, usb_control_ep_cfg, USB_CTRL_XFER_MAX, NULL,
+   udev->ctrl_xfer, udev->bus->control_ep_quirk ?
+   usb_control_ep_quirk_cfg : usb_control_ep_cfg, USB_CTRL_XFER_MAX, 
NULL,
>device_mtx)) {
DPRINTFN(0, "could not setup default "
"USB transfer\n");
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r353175 - stable/10/sys/dev/usb

2019-10-07 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Oct  7 08:13:49 2019
New Revision: 353175
URL: https://svnweb.freebsd.org/changeset/base/353175

Log:
  MFC r352555:
  Increase the maximum user-space buffer size from 256kBytes to 32MBytes for
  libusb. This is useful for speeding up large data transfers while reducing
  the interrupt rate.
  
  Found at: EuroBSDcon 2019
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/usb_ioctl.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/usb_ioctl.h
==
--- stable/10/sys/dev/usb/usb_ioctl.h   Mon Oct  7 08:13:10 2019
(r353174)
+++ stable/10/sys/dev/usb/usb_ioctl.h   Mon Oct  7 08:13:49 2019
(r353175)
@@ -218,7 +218,7 @@ struct usb_fs_uninit {
 } USB_IOCTL_STRUCT_ALIGN(1);
 
 struct usb_fs_open {
-#defineUSB_FS_MAX_BUFSIZE (1 << 18)
+#defineUSB_FS_MAX_BUFSIZE (1 << 25)/* 32 MBytes */
uint32_t max_bufsize;
 #defineUSB_FS_MAX_FRAMES   (1U << 12)
 #defineUSB_FS_MAX_FRAMES_PRE_SCALE (1U << 31)  /* for 
ISOCHRONOUS transfers */
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r353171 - stable/10/sys/dev/usb/controller

2019-10-07 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Oct  7 08:11:12 2019
New Revision: 353171
URL: https://svnweb.freebsd.org/changeset/base/353171

Log:
  MFC r352554:
  The maximum TD size is 31 and not 15.
  
  Found at: EuroBSDcon 2019
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/controller/xhci.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/controller/xhci.c
==
--- stable/10/sys/dev/usb/controller/xhci.c Mon Oct  7 08:10:26 2019
(r353170)
+++ stable/10/sys/dev/usb/controller/xhci.c Mon Oct  7 08:11:12 2019
(r353171)
@@ -2007,7 +2007,7 @@ restart:
 
/* clear TD SIZE to zero, hence this is the last TRB */
/* remove chain bit because this is the last data TRB in the chain */
-   td->td_trb[td->ntrb - 1].dwTrb2 &= ~htole32(XHCI_TRB_2_TDSZ_SET(15));
+   td->td_trb[td->ntrb - 1].dwTrb2 &= ~htole32(XHCI_TRB_2_TDSZ_SET(31));
td->td_trb[td->ntrb - 1].dwTrb3 &= ~htole32(XHCI_TRB_3_CHAIN_BIT);
/* remove CHAIN-BIT from last LINK TRB */
td->td_trb[td->ntrb].dwTrb3 &= ~htole32(XHCI_TRB_3_CHAIN_BIT);
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r351017 - stable/10/sys/dev/usb/net

2019-08-14 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Aug 14 09:42:26 2019
New Revision: 351017
URL: https://svnweb.freebsd.org/changeset/base/351017

Log:
  MFC r350396:
  Add support for tethering with Nokia 7 plus and the alike.
  
  PR:   239495
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/net/if_urndis.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/net/if_urndis.c
==
--- stable/10/sys/dev/usb/net/if_urndis.c   Wed Aug 14 09:42:16 2019
(r351016)
+++ stable/10/sys/dev/usb/net/if_urndis.c   Wed Aug 14 09:42:26 2019
(r351017)
@@ -190,6 +190,9 @@ static const STRUCT_USB_HOST_ID urndis_host_devs[] = {
{USB_VENDOR(USB_VENDOR_PALM), USB_IFACE_CLASS(UICLASS_CDC),
USB_IFACE_SUBCLASS(UISUBCLASS_ABSTRACT_CONTROL_MODEL),
USB_IFACE_PROTOCOL(0xff)},
+   /* Nokia 7 plus */
+   {USB_IFACE_CLASS(UICLASS_IAD), USB_IFACE_SUBCLASS(0x4),
+   USB_IFACE_PROTOCOL(UIPROTO_ACTIVESYNC)},
 };
 
 static int
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r349669 - stable/10/lib/libusb

2019-07-03 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Jul  3 18:26:07 2019
New Revision: 349669
URL: https://svnweb.freebsd.org/changeset/base/349669

Log:
  MFC r349409 and r349410:
  Fix support for LIBUSB_HOTPLUG_ENUMERATE in libusb. Currently all
  devices are enumerated regardless of of the LIBUSB_HOTPLUG_ENUMERATE
  flag. Make sure when the flag is not specified no arrival events are
  generated for currently enumerated devices.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/lib/libusb/libusb10.h
  stable/10/lib/libusb/libusb10_hotplug.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libusb/libusb10.h
==
--- stable/10/lib/libusb/libusb10.h Wed Jul  3 18:25:05 2019
(r349668)
+++ stable/10/lib/libusb/libusb10.h Wed Jul  3 18:26:07 2019
(r349669)
@@ -87,6 +87,8 @@ struct libusb_hotplug_callback_handle_struct {
void *user_data;
 };
 
+TAILQ_HEAD(libusb_device_head, libusb_device);
+
 struct libusb_context {
int debug;
int debug_fixed;
@@ -104,7 +106,7 @@ struct libusb_context {
TAILQ_HEAD(, libusb_super_pollfd) pollfds;
TAILQ_HEAD(, libusb_super_transfer) tr_done;
TAILQ_HEAD(, libusb_hotplug_callback_handle_struct) hotplug_cbh;
-   TAILQ_HEAD(, libusb_device) hotplug_devs;
+   struct libusb_device_head hotplug_devs;
 
struct libusb_super_pollfd ctx_poll;
 

Modified: stable/10/lib/libusb/libusb10_hotplug.c
==
--- stable/10/lib/libusb/libusb10_hotplug.c Wed Jul  3 18:25:05 2019
(r349668)
+++ stable/10/lib/libusb/libusb10_hotplug.c Wed Jul  3 18:26:07 2019
(r349669)
@@ -1,6 +1,6 @@
 /* $FreeBSD$ */
 /*-
- * Copyright (c) 2016 Hans Petter Selasky. All rights reserved.
+ * Copyright (c) 2016-2019 Hans Petter Selasky. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -85,20 +85,35 @@ libusb_hotplug_filter(libusb_context *ctx, libusb_hotp
return (pcbh->fn(ctx, dev, event, pcbh->user_data));
 }
 
+static int
+libusb_hotplug_enumerate(libusb_context *ctx, struct libusb_device_head *phead)
+{
+   libusb_device **ppdev;
+   ssize_t count;
+   ssize_t x;
+
+   count = libusb_get_device_list(ctx, );
+   if (count < 0)
+   return (-1);
+
+   for (x = 0; x != count; x++)
+   TAILQ_INSERT_TAIL(phead, ppdev[x], hotplug_entry);
+
+   libusb_free_device_list(ppdev, 0);
+   return (0);
+}
+
 static void *
 libusb_hotplug_scan(void *arg)
 {
-   TAILQ_HEAD(, libusb_device) hotplug_devs;
+   struct libusb_device_head hotplug_devs;
libusb_hotplug_callback_handle acbh;
libusb_hotplug_callback_handle bcbh;
libusb_context *ctx = arg;
-   libusb_device **ppdev;
libusb_device *temp;
libusb_device *adev;
libusb_device *bdev;
unsigned do_loop = 1;
-   ssize_t count;
-   ssize_t x;
 
while (do_loop) {
usleep(400);
@@ -108,14 +123,8 @@ libusb_hotplug_scan(void *arg)
TAILQ_INIT(_devs);
 
if (ctx->hotplug_handler != NO_THREAD) {
-   count = libusb_get_device_list(ctx, );
-   if (count < 0)
+   if (libusb_hotplug_enumerate(ctx, _devs) < 0)
continue;
-   for (x = 0; x != count; x++) {
-   TAILQ_INSERT_TAIL(_devs, ppdev[x],
-   hotplug_entry);
-   }
-   libusb_free_device_list(ppdev, 0);
} else {
do_loop = 0;
}
@@ -191,6 +200,8 @@ int libusb_hotplug_register_callback(libusb_context *c
 
HOTPLUG_LOCK(ctx);
if (ctx->hotplug_handler == NO_THREAD) {
+   libusb_hotplug_enumerate(ctx, >hotplug_devs);
+
if (pthread_create(>hotplug_handler, NULL,
_hotplug_scan, ctx) != 0)
ctx->hotplug_handler = NO_THREAD;
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r349666 - stable/10/usr.sbin/usbdump

2019-07-03 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Jul  3 18:19:29 2019
New Revision: 349666
URL: https://svnweb.freebsd.org/changeset/base/349666

Log:
  MFC r349370:
  Fix parsing of corrupt data in usbdump(8). Check that the transfer
  type array lookup is within bounds to avoid segfault.
  
  PR:   238801
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/usr.sbin/usbdump/usbdump.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/usbdump/usbdump.c
==
--- stable/10/usr.sbin/usbdump/usbdump.cWed Jul  3 18:18:42 2019
(r349665)
+++ stable/10/usr.sbin/usbdump/usbdump.cWed Jul  3 18:19:29 2019
(r349666)
@@ -148,7 +148,9 @@ static const char *errstr_table[USB_ERR_MAX] = {
[USB_ERR_NOT_LOCKED]= "NOT_LOCKED",
 };
 
-static const char *xfertype_table[4] = {
+#defineUSB_XFERTYPE_MAX 4
+
+static const char *xfertype_table[USB_XFERTYPE_MAX] = {
[UE_CONTROL]= "CTRL",
[UE_ISOCHRONOUS]= "ISOC",
[UE_BULK]   = "BULK",
@@ -319,6 +321,15 @@ usb_speedstr(uint8_t speed)
return (speed_table[speed]);
 }
 
+static const char *
+usb_xferstr(uint8_t type)
+{
+   if (type >= USB_XFERTYPE_MAX  || xfertype_table[type] == NULL)
+   return ("UNKN");
+   else
+   return (xfertype_table[type]);
+}
+
 static void
 print_flags(uint32_t flags)
 {
@@ -495,7 +506,7 @@ print_apacket(const struct header_32 *hdr, const uint8
(int)len, buf, tv.tv_usec,
(int)up->up_busunit, (int)up->up_address,
(up->up_type == USBPF_XFERTAP_SUBMIT) ? "SUBM" : "DONE",
-   xfertype_table[up->up_xfertype],
+   usb_xferstr(up->up_xfertype),
(unsigned int)up->up_endpoint,
usb_speedstr(up->up_speed),
(int)up->up_frames,
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r348895 - stable/10/lib/libusb

2019-06-11 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Jun 11 08:53:26 2019
New Revision: 348895
URL: https://svnweb.freebsd.org/changeset/base/348895

Log:
  MFC r348797:
  Fix for reading the configuration descriptor in libusb. Catch invalid
  configuration descriptor reads early on to avoid issues with devices
  that don't check for a valid USB configuration read request.
  
  Submitted by: takahiro.kuros...@gmail.com
  PR:   238412

Modified:
  stable/10/lib/libusb/libusb20.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libusb/libusb20.c
==
--- stable/10/lib/libusb/libusb20.c Tue Jun 11 08:52:48 2019
(r348894)
+++ stable/10/lib/libusb/libusb20.c Tue Jun 11 08:53:26 2019
(r348895)
@@ -935,6 +935,14 @@ libusb20_dev_alloc_config(struct libusb20_device *pdev
uint8_t do_close;
int error;
 
+   /*
+* Catch invalid configuration descriptor reads early on to
+* avoid issues with devices that don't check for a valid USB
+* configuration read request.
+*/
+   if (configIndex >= pdev->ddesc.bNumConfigurations)
+   return (NULL);
+
if (!pdev->is_opened) {
error = libusb20_dev_open(pdev, 0);
if (error) {
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r348857 - stable/10/sys/dev/usb

2019-06-10 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jun 10 13:37:38 2019
New Revision: 348857
URL: https://svnweb.freebsd.org/changeset/base/348857

Log:
  MFC r348631:
  In usb(4) fix a lost completion event issue towards libusb(3). It may happen
  if a USB transfer is cancelled that we need to fake a completion event.
  Implement missing support in ugen_fs_copy_out() to handle this.
  
  This fixes issues with webcamd(8) and firefox.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/usb_generic.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/usb_generic.c
==
--- stable/10/sys/dev/usb/usb_generic.c Mon Jun 10 13:36:53 2019
(r348856)
+++ stable/10/sys/dev/usb/usb_generic.c Mon Jun 10 13:37:38 2019
(r348857)
@@ -1218,6 +1218,40 @@ complete:
 }
 
 static int
+ugen_fs_copy_out_cancelled(struct usb_fs_endpoint *fs_ep_uptr)
+{
+   struct usb_fs_endpoint fs_ep;
+   int error;
+
+   error = copyin(fs_ep_uptr, _ep, sizeof(fs_ep));
+   if (error)
+   return (error);
+
+   fs_ep.status = USB_ERR_CANCELLED;
+   fs_ep.aFrames = 0;
+   fs_ep.isoc_time_complete = 0;
+
+   /* update "aFrames" */
+   error = copyout(_ep.aFrames, _ep_uptr->aFrames,
+   sizeof(fs_ep.aFrames));
+   if (error)
+   goto done;
+
+   /* update "isoc_time_complete" */
+   error = copyout(_ep.isoc_time_complete,
+   _ep_uptr->isoc_time_complete,
+   sizeof(fs_ep.isoc_time_complete));
+   if (error)
+   goto done;
+
+   /* update "status" */
+   error = copyout(_ep.status, _ep_uptr->status,
+   sizeof(fs_ep.status));
+done:
+   return (error);
+}
+
+static int
 ugen_fs_copy_out(struct usb_fifo *f, uint8_t ep_index)
 {
struct usb_device_request *req;
@@ -1242,8 +1276,13 @@ ugen_fs_copy_out(struct usb_fifo *f, uint8_t ep_index)
return (EINVAL);
 
mtx_lock(f->priv_mtx);
-   if (usbd_transfer_pending(xfer)) {
+   if (!xfer->flags_int.transferring &&
+   !xfer->flags_int.started) {
mtx_unlock(f->priv_mtx);
+   DPRINTF("Returning fake cancel event\n");
+   return (ugen_fs_copy_out_cancelled(f->fs_ep_ptr + ep_index));
+   } else if (usbd_transfer_pending(xfer)) {
+   mtx_unlock(f->priv_mtx);
return (EBUSY); /* should not happen */
}
mtx_unlock(f->priv_mtx);
@@ -1363,6 +1402,7 @@ complete:
sizeof(fs_ep.isoc_time_complete));
if (error)
goto done;
+
/* update "status" */
error = copyout(_ep.status, _ep_uptr->status,
sizeof(fs_ep.status));
@@ -1451,12 +1491,15 @@ ugen_ioctl(struct usb_fifo *f, u_long cmd, void *addr,
xfer = f->fs_xfer[u.pstart->ep_index];
if (usbd_transfer_pending(xfer)) {
usbd_transfer_stop(xfer);
+
/*
 * Check if the USB transfer was stopped
-* before it was even started. Else a cancel
-* callback will be pending.
+* before it was even started and fake a
+* cancel event.
 */
-   if (!xfer->flags_int.transferring) {
+   if (!xfer->flags_int.transferring &&
+   !xfer->flags_int.started) {
+   DPRINTF("Issuing fake completion event\n");
ugen_fs_set_complete(xfer->priv_sc,
USB_P2U(xfer->priv_fifo));
}
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r348853 - stable/10/sys/dev/usb/controller

2019-06-10 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jun 10 13:17:39 2019
New Revision: 348853
URL: https://svnweb.freebsd.org/changeset/base/348853

Log:
  MFC r348604:
  In xhci(4) there is no stream ID in the completion TRB.
  Instead iterate all the stream IDs in stream mode to find
  the matching USB transfer.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/controller/xhci.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/controller/xhci.c
==
--- stable/10/sys/dev/usb/controller/xhci.c Mon Jun 10 13:16:49 2019
(r348852)
+++ stable/10/sys/dev/usb/controller/xhci.c Mon Jun 10 13:17:39 2019
(r348853)
@@ -895,7 +895,7 @@ xhci_check_transfer(struct xhci_softc *sc, struct xhci
uint64_t td_event;
uint32_t temp;
uint32_t remainder;
-   uint16_t stream_id;
+   uint16_t stream_id = 0;
uint16_t i;
uint8_t status;
uint8_t halted;
@@ -908,7 +908,6 @@ xhci_check_transfer(struct xhci_softc *sc, struct xhci
 
remainder = XHCI_TRB_2_REM_GET(temp);
status = XHCI_TRB_2_ERROR_GET(temp);
-   stream_id = XHCI_TRB_2_STREAM_GET(temp);
 
temp = le32toh(trb->dwTrb3);
epno = XHCI_TRB_3_EP_GET(temp);
@@ -918,8 +917,8 @@ xhci_check_transfer(struct xhci_softc *sc, struct xhci
halted = (status != XHCI_TRB_ERROR_SHORT_PKT &&
status != XHCI_TRB_ERROR_SUCCESS);
 
-   DPRINTF("slot=%u epno=%u stream=%u remainder=%u status=%u\n",
-   index, epno, stream_id, remainder, status);
+   DPRINTF("slot=%u epno=%u remainder=%u status=%u\n",
+   index, epno, remainder, status);
 
if (index > sc->sc_noslot) {
DPRINTF("Invalid slot.\n");
@@ -933,18 +932,19 @@ xhci_check_transfer(struct xhci_softc *sc, struct xhci
 
pepext = >sc_hw.devs[index].endp[epno];
 
-   if (pepext->trb_ep_mode != USB_EP_MODE_STREAMS) {
-   stream_id = 0;
-   DPRINTF("stream_id=0\n");
-   } else if (stream_id >= XHCI_MAX_STREAMS) {
-   DPRINTF("Invalid stream ID.\n");
-   return;
-   }
-
/* try to find the USB transfer that generated the event */
-   for (i = 0; i != (XHCI_MAX_TRANSFERS - 1); i++) {
+   for (i = 0;; i++) {
struct usb_xfer *xfer;
struct xhci_td *td;
+
+   if (i == (XHCI_MAX_TRANSFERS - 1)) {
+   if (pepext->trb_ep_mode != USB_EP_MODE_STREAMS ||
+   stream_id == (XHCI_MAX_STREAMS - 1))
+   break;
+   stream_id++;
+   i = 0;
+   DPRINTFN(5, "stream_id=%u\n", stream_id);
+   }
 
xfer = pepext->xfer[i + (XHCI_MAX_TRANSFERS * stream_id)];
if (xfer == NULL)
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r348832 - stable/10/sys/dev/mlx5/mlx5_en

2019-06-09 Thread Hans Petter Selasky
Author: hselasky
Date: Sun Jun  9 08:22:38 2019
New Revision: 348832
URL: https://svnweb.freebsd.org/changeset/base/348832

Log:
  MFC r348603:
  Make sure the DMA tags get freed in mlx5en(4).
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==
--- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c   Sun Jun  9 08:19:45 
2019(r348831)
+++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c   Sun Jun  9 08:22:38 
2019(r348832)
@@ -772,6 +772,7 @@ mlx5e_destroy_rq(struct mlx5e_rq *rq)
}
free(rq->mbuf, M_MLX5EN);
mlx5_wq_destroy(>wq_ctrl);
+   bus_dma_tag_destroy(rq->dma_tag);
 }
 
 static int
@@ -1098,6 +1099,7 @@ mlx5e_destroy_sq(struct mlx5e_sq *sq)
}
if (sq->br != NULL)
buf_ring_free(sq->br, M_MLX5EN);
+   bus_dma_tag_destroy(sq->dma_tag);
 }
 
 int
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r346669 - stable/10/sys/dev/usb/controller

2019-04-25 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Apr 25 12:02:17 2019
New Revision: 346669
URL: https://svnweb.freebsd.org/changeset/base/346669

Log:
  MFC r346229 and r346248:
  Fix spelling and remove superfluous USB keyword.
  
  Submitted by: Dmitry Luhtionov 
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/controller/ehci_pci.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/controller/ehci_pci.c
==
--- stable/10/sys/dev/usb/controller/ehci_pci.c Thu Apr 25 12:01:11 2019
(r346668)
+++ stable/10/sys/dev/usb/controller/ehci_pci.c Thu Apr 25 12:02:17 2019
(r346669)
@@ -179,7 +179,7 @@ ehci_pci_match(device_t self)
case 0x8d2d8086:
return ("Intel Wellsburg USB 2.0 controller");
case 0x9c268086:
-   return ("Intel Lynx Point LP USB 2.0 controller USB");
+   return ("Intel Lynx Point-LP USB 2.0 controller");
 
case 0x00e01033:
return ("NEC uPD 72010x USB 2.0 controller");
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r345943 - stable/10/sys/sys

2019-04-05 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Apr  5 11:35:58 2019
New Revision: 345943
URL: https://svnweb.freebsd.org/changeset/base/345943

Log:
  MFC r345499:
  Change all kernel C-type macros into static inline functions.
  
  The current kernel C-type macros might obscurely hide the fact that
  the input argument might be used multiple times.
  
  This breaks code like:
  isalpha(*ptr++)
  
  Use static inline functions instead of macros to fix this.
  
  Reviewed by:  kib @
  Differential Revision:https://reviews.freebsd.org/D19694
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/sys/ctype.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/sys/ctype.h
==
--- stable/10/sys/sys/ctype.h   Fri Apr  5 11:35:02 2019(r345942)
+++ stable/10/sys/sys/ctype.h   Fri Apr  5 11:35:58 2019(r345943)
@@ -39,19 +39,65 @@
 
 #ifdef _KERNEL
 
-#define isspace(c) ((c) == ' ' || ((c) >= '\t' && (c) <= '\r'))
-#define isascii(c) (((c) & ~0x7f) == 0)
-#define isupper(c) ((c) >= 'A' && (c) <= 'Z')
-#define islower(c) ((c) >= 'a' && (c) <= 'z')
-#define isalpha(c) (isupper(c) || islower(c))
-#define isdigit(c) ((c) >= '0' && (c) <= '9')
-#define isxdigit(c)(isdigit(c) \
- || ((c) >= 'A' && (c) <= 'F') \
- || ((c) >= 'a' && (c) <= 'f'))
-#define isprint(c) ((c) >= ' ' && (c) <= '~')
+static __inline int
+isspace(int c)
+{
+   return (c == ' ' || (c >= '\t' && c <= '\r'));
+}
 
-#define toupper(c) ((c) - 0x20 * (((c) >= 'a') && ((c) <= 'z')))
-#define tolower(c) ((c) + 0x20 * (((c) >= 'A') && ((c) <= 'Z')))
+static __inline int
+isascii(int c)
+{
+   return ((c & ~0x7f) == 0);
+}
+
+static __inline int
+isupper(int c)
+{
+   return (c >= 'A' && c <= 'Z');
+}
+
+static __inline int
+islower(int c)
+{
+   return (c >= 'a' && c <= 'z');
+}
+
+static __inline int
+isalpha(int c)
+{
+   return (isupper(c) || islower(c));
+}
+
+static __inline int
+isdigit(int c)
+{
+   return (c >= '0' && c <= '9');
+}
+
+static __inline int
+isxdigit(int c)
+{
+   return (isdigit(c) || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'));
+}
+
+static __inline int
+isprint(int c)
+{
+   return (c >= ' ' && c <= '~');
+}
+
+static __inline int
+toupper(int c)
+{
+   return (c - 0x20 * ((c >= 'a') && (c <= 'z')));
+}
+
+static __inline int
+tolower(int c)
+{
+   return (c + 0x20 * ((c >= 'A') && (c <= 'Z')));
+}
 
 #endif
 #endif /* !_SYS_CTYPE_H_ */
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r345546 - in stable/10/sys/dev: sound/usb usb usb/quirk

2019-03-26 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Mar 26 13:53:33 2019
New Revision: 345546
URL: https://svnweb.freebsd.org/changeset/base/345546

Log:
  MFC r342961:
  snd_uaudio: Add quirks for Edirol UA-25EX in advanced driver mode.
  
  Extend the vendor class USB audio quirk to cover devices without
  the USB audio control descriptor.
  
  PR:   234794
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/sound/usb/uaudio.c
  stable/10/sys/dev/sound/usb/uaudioreg.h
  stable/10/sys/dev/usb/quirk/usb_quirk.c
  stable/10/sys/dev/usb/usbdevs
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/sound/usb/uaudio.c
==
--- stable/10/sys/dev/sound/usb/uaudio.cTue Mar 26 13:52:46 2019
(r345545)
+++ stable/10/sys/dev/sound/usb/uaudio.cTue Mar 26 13:53:33 2019
(r345546)
@@ -1749,7 +1749,7 @@ uaudio_chan_fill_info_sub(struct uaudio_softc *sc, str
continue;
}
 
-   if ((acdp != NULL) &&
+   if ((acdp != NULL || sc->sc_uq_au_vendor_class != 0) &&
(desc->bDescriptorType == UDESC_CS_INTERFACE) &&
(desc->bDescriptorSubtype == AS_GENERAL) &&
(asid.v1 == NULL)) {
@@ -1765,7 +1765,7 @@ uaudio_chan_fill_info_sub(struct uaudio_softc *sc, str
}
}
}
-   if ((acdp != NULL) &&
+   if ((acdp != NULL || sc->sc_uq_au_vendor_class != 0) &&
(desc->bDescriptorType == UDESC_CS_INTERFACE) &&
(desc->bDescriptorSubtype == FORMAT_TYPE) &&
(asf1d.v1 == NULL)) {
@@ -1804,7 +1804,7 @@ uaudio_chan_fill_info_sub(struct uaudio_softc *sc, str
continue;
}
}
-   if ((acdp != NULL) &&
+   if ((acdp != NULL || sc->sc_uq_au_vendor_class != 0) &&
(desc->bDescriptorType == UDESC_CS_ENDPOINT) &&
(desc->bDescriptorSubtype == AS_GENERAL) &&
(sed.v1 == NULL)) {

Modified: stable/10/sys/dev/sound/usb/uaudioreg.h
==
--- stable/10/sys/dev/sound/usb/uaudioreg.h Tue Mar 26 13:52:46 2019
(r345545)
+++ stable/10/sys/dev/sound/usb/uaudioreg.h Tue Mar 26 13:53:33 2019
(r345546)
@@ -34,7 +34,7 @@
 #ifndef _UAUDIOREG_H_
 #define_UAUDIOREG_H_
 
-#defineUAUDIO_VERSION  0x0100
+#defineUAUDIO_VERSION_10   0x0100
 #defineUAUDIO_VERSION_20   0x0200
 #defineUAUDIO_VERSION_30   0x0300
 

Modified: stable/10/sys/dev/usb/quirk/usb_quirk.c
==
--- stable/10/sys/dev/usb/quirk/usb_quirk.c Tue Mar 26 13:52:46 2019
(r345545)
+++ stable/10/sys/dev/usb/quirk/usb_quirk.c Tue Mar 26 13:53:33 2019
(r345546)
@@ -526,6 +526,7 @@ static struct usb_quirk_entry usb_quirks[USB_DEV_QUIRK
USB_QUIRK(MAUDIO, FASTTRACKULTRA8R, 0x, 0x, UQ_AU_VENDOR_CLASS),
USB_QUIRK(CMEDIA, CM6206, 0x, 0x, UQ_AU_SET_SPDIF_CM6206),
USB_QUIRK(PLOYTEC, SPL_CRIMSON_1, 0x, 0x, UQ_CFG_INDEX_1),
+   USB_QUIRK(ROLAND, UA25EX_AD, 0x, 0x, UQ_AU_VENDOR_CLASS),
 
/*
 * Quirks for manufacturers which USB devices does not respond

Modified: stable/10/sys/dev/usb/usbdevs
==
--- stable/10/sys/dev/usb/usbdevs   Tue Mar 26 13:52:46 2019
(r345545)
+++ stable/10/sys/dev/usb/usbdevs   Tue Mar 26 13:53:33 2019
(r345546)
@@ -3871,6 +3871,8 @@ product ROLAND SD20   0x0027  SD-20 MIDI Synth
 product ROLAND SD800x0029  SD-80 MIDI Synth
 product ROLAND UA700   0x002b  UA-700 Audio I/F
 product ROLAND PCR300  0x0033  EDIROL PCR-300 MIDI I/F
+product ROLAND UA25EX_AD   0x00e6  EDIROL UA-25EX (Advanced Driver)
+product ROLAND UA25EX_CC   0x00e7  EDIROL UA-25EX (Class Compliant)
 
 /* Rockfire products */
 product ROCKFIRE GAMEPAD   0x2033  gamepad 203USB
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r345541 - stable/10/lib/libusb

2019-03-26 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Mar 26 13:46:47 2019
New Revision: 345541
URL: https://svnweb.freebsd.org/changeset/base/345541

Log:
  MFC r344795:
  Fix typos in libusb.
  
  Found by: Denis Ahrens 
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/lib/libusb/libusb10.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libusb/libusb10.c
==
--- stable/10/lib/libusb/libusb10.c Tue Mar 26 13:46:00 2019
(r345540)
+++ stable/10/lib/libusb/libusb10.c Tue Mar 26 13:46:47 2019
(r345541)
@@ -537,7 +537,7 @@ libusb_open_device_with_vid_pid(libusb_context *ctx, u
if (ctx == NULL)
return (NULL);  /* be NULL safe */
 
-   DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_width_vid_pid 
enter");
+   DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_with_vid_pid 
enter");
 
if ((i = libusb_get_device_list(ctx, )) < 0)
return (NULL);
@@ -561,7 +561,7 @@ libusb_open_device_with_vid_pid(libusb_context *ctx, u
}
 
libusb_free_device_list(devs, 1);
-   DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_width_vid_pid 
leave");
+   DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_with_vid_pid 
leave");
return (pdev);
 }
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r344695 - in stable/10/sys/dev/usb: . quirk

2019-03-01 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Mar  1 08:06:23 2019
New Revision: 344695
URL: https://svnweb.freebsd.org/changeset/base/344695

Log:
  MFC r344477:
  Add new USB quirk.
  
  PR:   235897
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/quirk/usb_quirk.c
  stable/10/sys/dev/usb/usbdevs
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/quirk/usb_quirk.c
==
--- stable/10/sys/dev/usb/quirk/usb_quirk.c Fri Mar  1 08:05:29 2019
(r344694)
+++ stable/10/sys/dev/usb/quirk/usb_quirk.c Fri Mar  1 08:06:23 2019
(r344695)
@@ -357,6 +357,8 @@ static struct usb_quirk_entry usb_quirks[USB_DEV_QUIRK
UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE),
USB_QUIRK(SANDISK, SDCZ4_256, 0x, 0x, UQ_MSC_FORCE_WIRE_BBB,
UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE),
+   USB_QUIRK(SANDISK, SDCZ48_32, 0x, 0x, UQ_MSC_NO_SYNC_CACHE,
+   UQ_MSC_NO_TEST_UNIT_READY),
USB_QUIRK(SANDISK, SDDR31, 0x, 0x, UQ_MSC_FORCE_WIRE_BBB,
UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_READ_CAP_OFFBY1),
USB_QUIRK(SANDISK, IMAGEMATE_SDDR289, 0x, 0x,

Modified: stable/10/sys/dev/usb/usbdevs
==
--- stable/10/sys/dev/usb/usbdevs   Fri Mar  1 08:05:29 2019
(r344694)
+++ stable/10/sys/dev/usb/usbdevs   Fri Mar  1 08:06:23 2019
(r344695)
@@ -3911,6 +3911,7 @@ product SANDISK SDCZ2_128 0x7100  Cruzer Mini 128MB
 product SANDISK SDCZ2_256  0x7104  Cruzer Mini 256MB
 product SANDISK SDCZ4_128  0x7112  Cruzer Micro 128MB
 product SANDISK SDCZ4_256  0x7113  Cruzer Micro 256MB
+product SANDISK SDCZ48_32  0x5581  Ultra 32GB
 product SANDISK IMAGEMATE_SDDR289  0xb6ba  ImageMate SDDR-289
 
 /* Sanwa Electric Instrument Co., Ltd. products */
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r344146 - stable/10/usr.sbin/bluetooth/sdpd

2019-02-15 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Feb 15 09:22:23 2019
New Revision: 344146
URL: https://svnweb.freebsd.org/changeset/base/344146

Log:
  MFC r343905:
  Improve Bluetooth device discovery support for Android and Microsoft devices.
  
  Tested using the virtual_bt_speaker(8) tool from the virtual_oss(8)
  project at github.com.
  
  PR:   210089
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/usr.sbin/bluetooth/sdpd/ssar.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/bluetooth/sdpd/ssar.c
==
--- stable/10/usr.sbin/bluetooth/sdpd/ssar.cFri Feb 15 09:21:16 2019
(r344145)
+++ stable/10/usr.sbin/bluetooth/sdpd/ssar.cFri Feb 15 09:22:23 2019
(r344146)
@@ -44,6 +44,131 @@ int32_t server_prepare_attr_list(provider_p const prov
uint8_t *rsp, uint8_t const * const rsp_end);
 
 /*
+ * Scan an attribute for matching UUID.
+ */
+static int
+server_search_uuid_sub(uint8_t *buf, uint8_t const * const eob, const 
uint128_t *uuid)
+{
+int128_t duuid;
+uint32_t value;
+uint8_t type;
+
+while (buf < eob) {
+
+SDP_GET8(type, buf);
+
+switch (type) {
+case SDP_DATA_UUID16:
+if (buf + 2 > eob)
+continue;
+SDP_GET16(value, buf);
+
+memcpy(, _base, sizeof(duuid));
+duuid.b[2] = value >> 8 & 0xff;
+duuid.b[3] = value & 0xff;
+
+if (memcmp(, uuid, sizeof(duuid)) == 0)
+return (0);
+break;
+case SDP_DATA_UUID32:
+if (buf + 4 > eob)
+continue;
+SDP_GET32(value, buf);
+memcpy(, _base, sizeof(duuid));
+duuid.b[0] = value >> 24 & 0xff;
+duuid.b[1] = value >> 16 & 0xff;
+duuid.b[2] = value >> 8 & 0xff;
+duuid.b[3] = value & 0xff;
+
+if (memcmp(, uuid, sizeof(duuid)) == 0)
+return (0);
+break;
+case SDP_DATA_UUID128:
+if (buf + 16 > eob)
+continue;
+SDP_GET_UUID128(, buf);
+
+if (memcmp(, uuid, sizeof(duuid)) == 0)
+return (0);
+break;
+case SDP_DATA_UINT8:
+case SDP_DATA_INT8:
+case SDP_DATA_SEQ8:
+buf++;
+break;
+case SDP_DATA_UINT16:
+case SDP_DATA_INT16:
+case SDP_DATA_SEQ16:
+buf += 2;
+break;
+case SDP_DATA_UINT32:
+case SDP_DATA_INT32:
+case SDP_DATA_SEQ32:
+buf += 4;
+break;
+case SDP_DATA_UINT64:
+case SDP_DATA_INT64:
+buf += 8;
+break;
+case SDP_DATA_UINT128:
+case SDP_DATA_INT128:
+buf += 16;
+break;
+case SDP_DATA_STR8:
+if (buf + 1 > eob)
+continue;
+SDP_GET8(value, buf);
+buf += value;
+break;
+case SDP_DATA_STR16:
+if (buf + 2 > eob)
+continue;
+SDP_GET16(value, buf);
+if (value > (eob - buf))
+return (1);
+buf += value;
+break;
+case SDP_DATA_STR32:
+if (buf + 4 > eob)
+continue;
+SDP_GET32(value, buf);
+if (value > (eob - buf))
+return (1);
+buf += value;
+break;
+case SDP_DATA_BOOL:
+buf += 1;
+break;
+default:
+return (1);
+}
+}
+return (1);
+}
+
+/*
+ * Search a provider for matching UUID in its attributes.
+ */
+static int
+server_search_uuid(provider_p const provider, const uint128_t *uuid)
+{
+uint8_t buffer[256];
+const attr_t *attr;
+int len;
+
+for (attr = provider->profile->attrs; attr->create != NULL; attr++) {
+
+  

svn commit: r343902 - in stable/10: lib/libsdp usr.sbin/bluetooth/sdpd

2019-02-08 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Feb  8 10:28:13 2019
New Revision: 343902
URL: https://svnweb.freebsd.org/changeset/base/343902

Log:
  MFC r343572:
  Add support for Audio Sink and Audio Source profiles to sdpd(8).
  
  This allows user-space programs like virtual_oss(8) to act
  as a Bluetooth speaker device.
  
  Sponsored by: Mellanox Technologies

Added:
  stable/10/usr.sbin/bluetooth/sdpd/audio_sink.c
 - copied unchanged from r343572, head/usr.sbin/bluetooth/sdpd/audio_sink.c
  stable/10/usr.sbin/bluetooth/sdpd/audio_source.c
 - copied unchanged from r343572, 
head/usr.sbin/bluetooth/sdpd/audio_source.c
Modified:
  stable/10/lib/libsdp/sdp.h
  stable/10/usr.sbin/bluetooth/sdpd/Makefile
  stable/10/usr.sbin/bluetooth/sdpd/profile.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libsdp/sdp.h
==
--- stable/10/lib/libsdp/sdp.h  Fri Feb  8 10:27:02 2019(r343901)
+++ stable/10/lib/libsdp/sdp.h  Fri Feb  8 10:28:13 2019(r343902)
@@ -583,6 +583,24 @@ void   sdp_print  (uint32_t level, uin
 #define SDP_PDU_SERVICE_UNREGISTER_REQUEST 0x82
 #define SDP_PDU_SERVICE_CHANGE_REQUEST 0x83
 
+struct sdp_audio_sink_profile
+{
+   uint16_t psm;
+   uint16_t protover;
+   uint16_t features;
+};
+typedef struct sdp_audio_sink_profile  sdp_audio_sink_profile_t;
+typedef struct sdp_audio_sink_profile  *sdp_audio_sink_profile_p;
+
+struct sdp_audio_source_profile
+{
+   uint16_t psm;
+   uint16_t protover;
+   uint16_t features;
+};
+typedef struct sdp_audio_source_profilesdp_audio_source_profile_t;
+typedef struct sdp_audio_source_profile *sdp_audio_source_profile_p;
+
 struct sdp_dun_profile
 {
uint8_t server_channel;

Modified: stable/10/usr.sbin/bluetooth/sdpd/Makefile
==
--- stable/10/usr.sbin/bluetooth/sdpd/Makefile  Fri Feb  8 10:27:02 2019
(r343901)
+++ stable/10/usr.sbin/bluetooth/sdpd/Makefile  Fri Feb  8 10:28:13 2019
(r343902)
@@ -3,7 +3,8 @@
 
 PROG=  sdpd
 MAN=   sdpd.8
-SRCS=  bgd.c dun.c ftrn.c gn.c irmc.c irmc_command.c lan.c log.c \
+SRCS=  audio_sink.c audio_source.c \
+   bgd.c dun.c ftrn.c gn.c irmc.c irmc_command.c lan.c log.c \
main.c nap.c opush.c panu.c profile.c provider.c sar.c scr.c \
sd.c server.c sp.c srr.c ssar.c ssr.c sur.c uuid.c
 

Copied: stable/10/usr.sbin/bluetooth/sdpd/audio_sink.c (from r343572, 
head/usr.sbin/bluetooth/sdpd/audio_sink.c)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/10/usr.sbin/bluetooth/sdpd/audio_sink.c  Fri Feb  8 10:28:13 
2019(r343902, copy of r343572, 
head/usr.sbin/bluetooth/sdpd/audio_sink.c)
@@ -0,0 +1,188 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2019 Hans Petter Selasky 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include 
+#defineL2CAP_SOCKET_CHECKED
+#include 
+#include 
+#include 
+#include "profile.h"
+#include "provider.h"
+
+static int32_t
+audio_sink_profile_create_service_class_id_list(
+uint8_t *buf, uint8_t const *const eob,
+uint8_t const *data, uint32_t datalen)
+{
+   static const uint16_t service_classes[] = {
+   SDP_SERVICE_CLASS_AUDIO_SINK,
+   };
+
+   return (common_profile_create_service_class_id_list(
+   buf, eob,
+   (uint8_t con

svn commit: r343658 - in stable/10/sys/dev/usb: . quirk

2019-02-01 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Feb  1 10:09:54 2019
New Revision: 343658
URL: https://svnweb.freebsd.org/changeset/base/343658

Log:
  MFC r343453:
  Add new USB quirk.
  
  PR:   235202
  Differential Revision:https://reviews.freebsd.org/D18917
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/quirk/usb_quirk.c
  stable/10/sys/dev/usb/usbdevs
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/quirk/usb_quirk.c
==
--- stable/10/sys/dev/usb/quirk/usb_quirk.c Fri Feb  1 10:09:13 2019
(r343657)
+++ stable/10/sys/dev/usb/quirk/usb_quirk.c Fri Feb  1 10:09:54 2019
(r343658)
@@ -140,6 +140,7 @@ static struct usb_quirk_entry usb_quirks[USB_DEV_QUIRK
USB_QUIRK(CORSAIR, K70_RGB, 0x, 0x, UQ_KBD_BOOTPROTO),
/* Quirk for Corsair STRAFE Gaming keyboard */
USB_QUIRK(CORSAIR, STRAFE, 0x, 0x, UQ_KBD_BOOTPROTO),
+   USB_QUIRK(CORSAIR, STRAFE2, 0x, 0x, UQ_KBD_BOOTPROTO),
/* umodem(4) device quirks */
USB_QUIRK(METRICOM, RICOCHET_GS, 0x100, 0x100, UQ_ASSUME_CM_OVER_DATA),
USB_QUIRK(SANYO, SCP4900, 0x000, 0x000, UQ_ASSUME_CM_OVER_DATA),

Modified: stable/10/sys/dev/usb/usbdevs
==
--- stable/10/sys/dev/usb/usbdevs   Fri Feb  1 10:09:13 2019
(r343657)
+++ stable/10/sys/dev/usb/usbdevs   Fri Feb  1 10:09:54 2019
(r343658)
@@ -1520,7 +1520,8 @@ product COREGA FETHER_USB_TXC 0x9601  FEther USB-TXC
 product CORSAIR K600x0a60  Corsair Vengeance K60 keyboard
 product CORSAIR K700x1b09  Corsair Vengeance K70 keyboard
 product CORSAIR K70_RGB0x1b13  Corsair K70 RGB Keyboard
-product CORSAIR STRAFE 0x1b15  Cossair STRAFE Gaming keyboard
+product CORSAIR STRAFE 0x1b15  Corsair STRAFE Gaming keyboard
+product CORSAIR STRAFE20x1b44  Corsair STRAFE Gaming keyboard
 
 /* Creative products */
 product CREATIVE NOMAD_II  0x1002  Nomad II MP3 player
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r343139 - stable/10/sys/netinet6

2019-01-18 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Jan 18 08:59:00 2019
New Revision: 343139
URL: https://svnweb.freebsd.org/changeset/base/343139

Log:
  MFC r342884:
  Fix loopback traffic when using non-lo0 link local IPv6 addresses.
  
  The loopback interface can only receive packets with a single scope ID,
  namely the scope ID of the loopback interface itself. To mitigate this
  packets which use the scope ID are appearing as received by the real
  network interface, see "origifp" in the patch. The current code would
  drop packets which are designated for loopback which use a link-local
  scope ID in the destination address or source address, because they
  won't match the lo0's scope ID. To fix this restore the network
  interface pointer from the scope ID in the destination address for
  the problematic cases. See comments added in patch for a more detailed
  description.
  
  This issue was introduced with route caching by karels@ .
  
  Reviewed by:  bz (network)
  Differential Revision:https://reviews.freebsd.org/D18769
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/netinet6/ip6_output.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netinet6/ip6_output.c
==
--- stable/10/sys/netinet6/ip6_output.c Fri Jan 18 08:57:23 2019
(r343138)
+++ stable/10/sys/netinet6/ip6_output.c Fri Jan 18 08:59:00 2019
(r343139)
@@ -565,52 +565,72 @@ again:
counter_u64_add(rt->rt_pksent, 1);
}
 
-
-   /*
-* The outgoing interface must be in the zone of source and
-* destination addresses.
-*/
-   origifp = ifp;
-
+   /* Setup data structures for scope ID checks. */
src0 = ip6->ip6_src;
-   if (in6_setscope(, origifp, ))
-   goto badscope;
bzero(_sa, sizeof(src_sa));
src_sa.sin6_family = AF_INET6;
src_sa.sin6_len = sizeof(src_sa);
src_sa.sin6_addr = ip6->ip6_src;
-   if (sa6_recoverscope(_sa) || zone != src_sa.sin6_scope_id)
-   goto badscope;
 
dst0 = ip6->ip6_dst;
-   if (in6_setscope(, origifp, ))
-   goto badscope;
/* re-initialize to be sure */
bzero(_sa, sizeof(dst_sa));
dst_sa.sin6_family = AF_INET6;
dst_sa.sin6_len = sizeof(dst_sa);
dst_sa.sin6_addr = ip6->ip6_dst;
-   if (sa6_recoverscope(_sa) || zone != dst_sa.sin6_scope_id) {
-   goto badscope;
-   }
 
-   /* We should use ia_ifp to support the case of
-* sending packets to an address of our own.
-*/
-   if (ia != NULL && ia->ia_ifp)
-   ifp = ia->ia_ifp;
+   /* Check for valid scope ID. */
+   if (in6_setscope(, ifp, ) == 0 &&
+   sa6_recoverscope(_sa) == 0 && zone == src_sa.sin6_scope_id &&
+   in6_setscope(, ifp, ) == 0 &&
+   sa6_recoverscope(_sa) == 0 && zone == dst_sa.sin6_scope_id) {
+   /*
+* The outgoing interface is in the zone of the source
+* and destination addresses.
+*
+* Because the loopback interface cannot receive
+* packets with a different scope ID than its own,
+* there is a trick is to pretend the outgoing packet
+* was received by the real network interface, by
+* setting "origifp" different from "ifp". This is
+* only allowed when "ifp" is a loopback network
+* interface. Refer to code in nd6_output_ifp() for
+* more details.
+*/
+   origifp = ifp;
+   
+   /*
+* We should use ia_ifp to support the case of sending
+* packets to an address of our own.
+*/
+   if (ia != NULL && ia->ia_ifp)
+   ifp = ia->ia_ifp;
 
-   /* scope check is done. */
-   goto routefound;
+   } else if ((ifp->if_flags & IFF_LOOPBACK) == 0 ||
+   sa6_recoverscope(_sa) != 0 ||
+   sa6_recoverscope(_sa) != 0 ||
+   dst_sa.sin6_scope_id == 0 ||
+   (src_sa.sin6_scope_id != 0 &&
+   src_sa.sin6_scope_id != dst_sa.sin6_scope_id) ||
+   (origifp = ifnet_byindex(dst_sa.sin6_scope_id)) == NULL) {
+   /*
+* If the destination network interface is not a
+* loopback interface, or the destination network
+* address has no scope ID, or the source address has
+* a scope ID set which is different from the
+* destination address one, or there is no network
+* interface representing this scope ID, the address
+* pair is considered invalid.
+*/
+   IP6STAT_INC(ip6s_badscope);
+   in6_ifstat_inc(ifp, ifs6_out_discard);
+   

svn commit: r343136 - stable/10/sys/dev/usb

2019-01-18 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Jan 18 08:49:10 2019
New Revision: 343136
URL: https://svnweb.freebsd.org/changeset/base/343136

Log:
  MFC r342778:
  Reduce timeout for reading the USB HUB port status to 1000ms and try to filter
  out dead USB HUB devices by implementing an error counter, so that the USB
  enumeration thread does not spend all its time reading from non-responding
  devices, blocking user-space access in the end.
  
  Tested by:Matthias Apitz 
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/usb_hub.c
  stable/10/sys/dev/usb/usb_request.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/usb_hub.c
==
--- stable/10/sys/dev/usb/usb_hub.c Fri Jan 18 08:48:30 2019
(r343135)
+++ stable/10/sys/dev/usb/usb_hub.c Fri Jan 18 08:49:10 2019
(r343136)
@@ -130,6 +130,8 @@ struct uhub_softc {
int sc_disable_enumeration;
int sc_disable_port_power;
 #endif
+   uint8_t sc_usb_port_errors; /* error counter */
+#defineUHUB_USB_PORT_ERRORS_MAX 4
uint8_t sc_flags;
 #defineUHUB_FLAG_DID_EXPLORE 0x01
 };
@@ -588,13 +590,25 @@ uhub_read_port_status(struct uhub_softc *sc, uint8_t p
struct usb_port_status ps;
usb_error_t err;
 
+   if (sc->sc_usb_port_errors >= UHUB_USB_PORT_ERRORS_MAX) {
+   DPRINTFN(4, "port %d, HUB looks dead, too many errors\n", 
portno);
+   sc->sc_st.port_status = 0;
+   sc->sc_st.port_change = 0;
+   return (USB_ERR_TIMEOUT);
+   }
+
err = usbd_req_get_port_status(
sc->sc_udev, NULL, , portno);
 
-   /* update status regardless of error */
-
-   sc->sc_st.port_status = UGETW(ps.wPortStatus);
-   sc->sc_st.port_change = UGETW(ps.wPortChange);
+   if (err == 0) {
+   sc->sc_st.port_status = UGETW(ps.wPortStatus);
+   sc->sc_st.port_change = UGETW(ps.wPortChange);
+   sc->sc_usb_port_errors = 0;
+   } else {
+   sc->sc_st.port_status = 0;
+   sc->sc_st.port_change = 0;
+   sc->sc_usb_port_errors++;
+   }
 
/* debugging print */
 

Modified: stable/10/sys/dev/usb/usb_request.c
==
--- stable/10/sys/dev/usb/usb_request.c Fri Jan 18 08:48:30 2019
(r343135)
+++ stable/10/sys/dev/usb/usb_request.c Fri Jan 18 08:49:10 2019
(r343136)
@@ -1595,8 +1595,9 @@ usbd_req_get_port_status(struct usb_device *udev, stru
USETW(req.wValue, 0);
req.wIndex[0] = port;
req.wIndex[1] = 0;
-   USETW(req.wLength, sizeof *ps);
-   return (usbd_do_request(udev, mtx, , ps));
+   USETW(req.wLength, sizeof(*ps));
+
+   return (usbd_do_request_flags(udev, mtx, , ps, 0, NULL, 1000));
 }
 
 /**
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r343133 - stable/10/sys/dev/usb

2019-01-18 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Jan 18 08:45:56 2019
New Revision: 343133
URL: https://svnweb.freebsd.org/changeset/base/343133

Log:
  MFC r342730:
  Improve USB generic debug messages. Print process ID and name when opening
  and closing usb/ugenX.Y character device nodes.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/usb_generic.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/usb_generic.c
==
--- stable/10/sys/dev/usb/usb_generic.c Fri Jan 18 08:44:50 2019
(r343132)
+++ stable/10/sys/dev/usb/usb_generic.c Fri Jan 18 08:45:56 2019
(r343133)
@@ -182,7 +182,8 @@ ugen_open(struct usb_fifo *f, int fflags)
struct usb_endpoint_descriptor *ed = ep->edesc;
uint8_t type;
 
-   DPRINTFN(6, "flag=0x%x\n", fflags);
+   DPRINTFN(1, "flag=0x%x pid=%d name=%s\n", fflags,
+   curthread->td_proc->p_pid, curthread->td_proc->p_comm);
 
mtx_lock(f->priv_mtx);
switch (usbd_get_speed(f->udev)) {
@@ -212,7 +213,9 @@ ugen_open(struct usb_fifo *f, int fflags)
 static void
 ugen_close(struct usb_fifo *f, int fflags)
 {
-   DPRINTFN(6, "flag=0x%x\n", fflags);
+
+   DPRINTFN(1, "flag=0x%x pid=%d name=%s\n", fflags,
+   curthread->td_proc->p_pid, curthread->td_proc->p_comm);
 
/* cleanup */
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r342727 - in stable/10/sys/dev/usb: . quirk

2019-01-03 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Jan  3 09:28:18 2019
New Revision: 342727
URL: https://svnweb.freebsd.org/changeset/base/342727

Log:
  MFC r342549:
  Add USB quirk for SPL Crimson Rev 1.
  
  PR:   234380
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/quirk/usb_quirk.c
  stable/10/sys/dev/usb/usbdevs
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/quirk/usb_quirk.c
==
--- stable/10/sys/dev/usb/quirk/usb_quirk.c Thu Jan  3 09:27:35 2019
(r342726)
+++ stable/10/sys/dev/usb/quirk/usb_quirk.c Thu Jan  3 09:28:18 2019
(r342727)
@@ -522,6 +522,7 @@ static struct usb_quirk_entry usb_quirks[USB_DEV_QUIRK
USB_QUIRK(MAUDIO, FASTTRACKULTRA, 0x, 0x, UQ_AU_VENDOR_CLASS),
USB_QUIRK(MAUDIO, FASTTRACKULTRA8R, 0x, 0x, UQ_AU_VENDOR_CLASS),
USB_QUIRK(CMEDIA, CM6206, 0x, 0x, UQ_AU_SET_SPDIF_CM6206),
+   USB_QUIRK(PLOYTEC, SPL_CRIMSON_1, 0x, 0x, UQ_CFG_INDEX_1),
 
/*
 * Quirks for manufacturers which USB devices does not respond

Modified: stable/10/sys/dev/usb/usbdevs
==
--- stable/10/sys/dev/usb/usbdevs   Thu Jan  3 09:27:35 2019
(r342726)
+++ stable/10/sys/dev/usb/usbdevs   Thu Jan  3 09:28:18 2019
(r342727)
@@ -488,6 +488,7 @@ vendor ASAHIOPTICAL 0x0a17  Asahi Optical
 vendor BOCASYSTEMS 0x0a43  Boca Systems
 vendor SHANTOU 0x0a46  ShanTou
 vendor MEDIAGEAR   0x0a48  MediaGear
+vendor PLOYTEC 0x0a4a  Ploytec GmbH
 vendor BROADCOM0x0a5c  Broadcom
 vendor GREENHOUSE  0x0a6b  GREENHOUSE
 vendor MEDELI  0x0a67  Medeli
@@ -3573,6 +3574,9 @@ product PLANEX2 GWUSNANO  0xab28  GW-USNano
 
 /* Plextor Corp. */
 product PLEXTOR 40_12_40U  0x0011  PlexWriter 40/12/40U
+
+/* Ploytec GmbH */
+product PLOYTEC SPL_CRIMSON_1  0xc150  SPL Crimson Revision 1
 
 /* PLX products */
 product PLX TESTBOARD  0x9060  test board
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r342724 - stable/10/sys/dev/sound/usb

2019-01-03 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Jan  3 09:25:39 2019
New Revision: 342724
URL: https://svnweb.freebsd.org/changeset/base/342724

Log:
  MFC r342456:
  Fix reading of USB sample rate descriptor for SPL Crimson Rev 1.
  
  Read first one entry, then try to read the full rate descriptor table.
  
  PR:   234380
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/sound/usb/uaudio.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/sound/usb/uaudio.c
==
--- stable/10/sys/dev/sound/usb/uaudio.cThu Jan  3 09:24:37 2019
(r342723)
+++ stable/10/sys/dev/sound/usb/uaudio.cThu Jan  3 09:25:39 2019
(r342724)
@@ -1524,7 +1524,8 @@ uaudio20_check_rate(struct usb_device *udev, uint8_t i
 {
struct usb_device_request req;
usb_error_t error;
-   uint8_t data[255];
+#defineUAUDIO20_MAX_RATES 32   /* we support at maxium 32 rates */
+   uint8_t data[2 + UAUDIO20_MAX_RATES * 12];
uint16_t actlen;
uint16_t rates;
uint16_t x;
@@ -1536,19 +1537,57 @@ uaudio20_check_rate(struct usb_device *udev, uint8_t i
req.bRequest = UA20_CS_RANGE;
USETW2(req.wValue, UA20_CS_SAM_FREQ_CONTROL, 0);
USETW2(req.wIndex, clockid, iface_no);
-   USETW(req.wLength, 255);
+   /*
+* Assume there is at least one rate to begin with, else some
+* devices might refuse to return the USB descriptor:
+*/
+   USETW(req.wLength, (2 + 1 * 12));
 
-error = usbd_do_request_flags(udev, NULL, , data,
+   error = usbd_do_request_flags(udev, NULL, , data,
USB_SHORT_XFER_OK, , USB_DEFAULT_TIMEOUT);
 
-   if (error != 0 || actlen < 2)
-   return (USB_ERR_INVAL);
+   if (error != 0 || actlen < 2) {
+   /*
+* Likely the descriptor doesn't fit into the supplied
+* buffer. Try using a larger buffer and see if that
+* helps:
+*/
+   rates = MIN(UAUDIO20_MAX_RATES, (255 - 2) / 12);
+   error = USB_ERR_INVAL;
+   } else {
+   rates = UGETW(data);
 
-   rates = data[0] | (data[1] << 8);
+   if (rates > UAUDIO20_MAX_RATES) {
+   DPRINTF("Too many rates truncating to %d\n", 
UAUDIO20_MAX_RATES);
+   rates = UAUDIO20_MAX_RATES;
+   error = USB_ERR_INVAL;
+   } else if (rates > 1) {
+   DPRINTF("Need to read full rate descriptor\n");
+   error = USB_ERR_INVAL;
+   }
+   }
+
+   if (error != 0) {
+   /*
+* Try to read full rate descriptor.
+*/
+   actlen = (2 + rates * 12);
+
+   USETW(req.wLength, actlen);
+
+   error = usbd_do_request_flags(udev, NULL, , data,
+   USB_SHORT_XFER_OK, , USB_DEFAULT_TIMEOUT);
+   
+   if (error != 0 || actlen < 2)
+   return (USB_ERR_INVAL);
+
+   rates = UGETW(data);
+   }
+
actlen = (actlen - 2) / 12;
 
if (rates > actlen) {
-   DPRINTF("Too many rates\n");
+   DPRINTF("Too many rates truncating to %d\n", actlen);
rates = actlen;
}
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r342037 - in stable/10/sys/dev/usb: . serial

2018-12-13 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Dec 13 10:34:26 2018
New Revision: 342037
URL: https://svnweb.freebsd.org/changeset/base/342037

Log:
  MFC r334648:
  Add support for SIMCom SIM7600E.
  
  PR:   226066
  Sponsored by: MSI/FUNTORO

Modified:
  stable/10/sys/dev/usb/serial/u3g.c
  stable/10/sys/dev/usb/usbdevs
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/serial/u3g.c
==
--- stable/10/sys/dev/usb/serial/u3g.c  Thu Dec 13 10:33:17 2018
(r342036)
+++ stable/10/sys/dev/usb/serial/u3g.c  Thu Dec 13 10:34:26 2018
(r342037)
@@ -213,6 +213,7 @@ static const STRUCT_USB_HOST_ID u3g_devs[] = {
U3G_DEV(ALINK, 3G, 0),
U3G_DEV(ALINK, 3GU, 0),
U3G_DEV(ALINK, DWM652U5, 0),
+   U3G_DEV(ALINK, SIM7600E, 0),
U3G_DEV(AMOI, H01, 0),
U3G_DEV(AMOI, H01A, 0),
U3G_DEV(AMOI, H02, 0),

Modified: stable/10/sys/dev/usb/usbdevs
==
--- stable/10/sys/dev/usb/usbdevs   Thu Dec 13 10:33:17 2018
(r342036)
+++ stable/10/sys/dev/usb/usbdevs   Thu Dec 13 10:34:26 2018
(r342037)
@@ -1008,6 +1008,7 @@ product ALCOR AU6390  0x6390  AU6390 USB-IDE converter
 /* Alink products */
 product ALINK DWM652U5 0xce16  DWM-652
 product ALINK 3G   0x9000  3G modem
+product ALINK SIM7600E 0x9001  LTE modem
 product ALINK 3GU  0x9200  3G modem
 
 /* Altec Lansing products */
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r340625 - stable/10/etc/newsyslog.conf.d

2018-11-19 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Nov 19 09:50:06 2018
New Revision: 340625
URL: https://svnweb.freebsd.org/changeset/base/340625

Log:
  MFC r340254:
  Put a size limit on the opensm.log and use bzip2(1).
  
  Discussed with:   markj@
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/etc/newsyslog.conf.d/opensm.conf
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/etc/newsyslog.conf.d/opensm.conf
==
--- stable/10/etc/newsyslog.conf.d/opensm.conf  Mon Nov 19 09:46:47 2018
(r340624)
+++ stable/10/etc/newsyslog.conf.d/opensm.conf  Mon Nov 19 09:50:06 2018
(r340625)
@@ -1,3 +1,3 @@
 # $FreeBSD$
 
-/var/log/opensm.log600  7  *   *   Z   
/var/run/opensm.pid 30
+/var/log/opensm.log600  7  1000*   J   
/var/run/opensm.pid 30
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r340352 - stable/10/sys/dev/sound/usb

2018-11-11 Thread Hans Petter Selasky
Author: hselasky
Date: Sun Nov 11 12:34:19 2018
New Revision: 340352
URL: https://svnweb.freebsd.org/changeset/base/340352

Log:
  MFC r340248:
  Don't read the USB audio sync endpoint when we don't use it to save
  isochronous bandwidth.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/sound/usb/uaudio.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/sound/usb/uaudio.c
==
--- stable/10/sys/dev/sound/usb/uaudio.cSun Nov 11 12:33:16 2018
(r340351)
+++ stable/10/sys/dev/sound/usb/uaudio.cSun Nov 11 12:34:19 2018
(r340352)
@@ -98,7 +98,7 @@ static int uaudio_default_channels = 0;   /* use 
defaul
 static int uaudio_buffer_ms = 8;
 
 #ifdef USB_DEBUG
-static int uaudio_debug = 0;
+static int uaudio_debug;
 
 static SYSCTL_NODE(_hw_usb, OID_AUTO, uaudio, CTLFLAG_RW, 0, "USB uaudio");
 
@@ -140,6 +140,8 @@ uaudio_buffer_ms_sysctl(SYSCTL_HANDLER_ARGS)
 SYSCTL_PROC(_hw_usb_uaudio, OID_AUTO, buffer_ms, CTLTYPE_INT | CTLFLAG_RWTUN,
 0, sizeof(int), uaudio_buffer_ms_sysctl, "I",
 "uaudio buffering delay from 2ms to 8ms");
+#else
+#defineuaudio_debug 0
 #endif
 
 #defineUAUDIO_NFRAMES  64  /* must be factor of 8 due 
HS-USB */
@@ -2165,6 +2167,14 @@ uaudio_chan_play_sync_callback(struct usb_xfer *xfer, 
break;
 
case USB_ST_SETUP:
+   /*
+* Check if the recording stream can be used as a
+* source of jitter information to save some
+* isochronous bandwidth:
+*/
+   if (ch->priv_sc->sc_rec_chan.num_alt != 0 &&
+   uaudio_debug == 0)
+   break;
usbd_xfer_set_frames(xfer, 1);
usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_framelen(xfer));
usbd_transfer_submit(xfer);
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r340317 - stable/10/sys/dev/usb/controller

2018-11-10 Thread Hans Petter Selasky
Author: hselasky
Date: Sat Nov 10 10:32:55 2018
New Revision: 340317
URL: https://svnweb.freebsd.org/changeset/base/340317

Log:
  MFC r340212:
  Sometimes the complete split packet may be queued too early and the
  transaction translator will return a NAK. Ignore this message and
  retry the complete split instead.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/controller/dwc_otg.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/controller/dwc_otg.c
==
--- stable/10/sys/dev/usb/controller/dwc_otg.c  Sat Nov 10 10:31:35 2018
(r340316)
+++ stable/10/sys/dev/usb/controller/dwc_otg.c  Sat Nov 10 10:32:55 2018
(r340317)
@@ -1435,6 +1435,19 @@ dwc_otg_host_data_rx(struct dwc_otg_softc *sc, struct 
goto receive_pkt;
}
} else if (td->ep_type == UE_ISOCHRONOUS) {
+   if (td->hcsplt != 0) {
+   /*
+* Sometimes the complete
+* split packet may be queued
+* too early and the
+* transaction translator will
+* return a NAK. Ignore
+* this message and retry the
+* complete split instead.
+*/
+   DPRINTF("Retrying complete split\n");
+   goto receive_pkt;
+   }
goto complete;
}
td->did_nak = 1;
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r340281 - stable/10/usr.sbin/uhsoctl

2018-11-09 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Nov  9 08:47:54 2018
New Revision: 340281
URL: https://svnweb.freebsd.org/changeset/base/340281

Log:
  MFC r340089:
  Use correct type for IOCTL request argument.
  This fixes signed IOCTL value warnings in uhsoctl().
  
  Submitted by: Marcin Cieslak 
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/usr.sbin/uhsoctl/uhsoctl.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/uhsoctl/uhsoctl.c
==
--- stable/10/usr.sbin/uhsoctl/uhsoctl.cFri Nov  9 08:45:47 2018
(r340280)
+++ stable/10/usr.sbin/uhsoctl/uhsoctl.cFri Nov  9 08:47:54 2018
(r340281)
@@ -359,7 +359,7 @@ logger(int pri, const char *fmt, ...)
 
 /* Add/remove IP address from an interface */
 static int
-ifaddr_ad(int d, const char *ifnam, struct sockaddr *sa, struct sockaddr *mask)
+ifaddr_ad(unsigned long d, const char *ifnam, struct sockaddr *sa, struct 
sockaddr *mask)
 {
struct ifaliasreq req;
int fd, error;
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r339853 - stable/10/sys/dev/usb/serial

2018-10-29 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Oct 29 12:11:27 2018
New Revision: 339853
URL: https://svnweb.freebsd.org/changeset/base/339853

Log:
  MFC r339587:
  Added support for formula-based arbitrary baud rates, in contrast to
  the current fixed values, which enables use of rates above 1 Mbps.
  Improved the detection of HXD chips, and the status flag handling as
  well.
  
  Submitted by: Gabor Simon 
  PR:   225932
  Differential revision:https://reviews.freebsd.org/D16639
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/serial/uplcom.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/serial/uplcom.c
==
--- stable/10/sys/dev/usb/serial/uplcom.c   Mon Oct 29 12:10:06 2018
(r339852)
+++ stable/10/sys/dev/usb/serial/uplcom.c   Mon Oct 29 12:11:27 2018
(r339853)
@@ -132,12 +132,20 @@ SYSCTL_INT(_hw_usb_uplcom, OID_AUTO, debug, CTLFLAG_RW
 #defineUPLCOM_SET_CRTSCTS  0x41
 #defineUPLCOM_SET_CRTSCTS_PL2303X  0x61
 #defineRSAQ_STATUS_CTS 0x80
+#defineRSAQ_STATUS_OVERRUN_ERROR   0x40
+#defineRSAQ_STATUS_PARITY_ERROR0x20 
+#defineRSAQ_STATUS_FRAME_ERROR 0x10
+#defineRSAQ_STATUS_RING0x08
+#defineRSAQ_STATUS_BREAK_ERROR 0x04
 #defineRSAQ_STATUS_DSR 0x02
 #defineRSAQ_STATUS_DCD 0x01
 
 #defineTYPE_PL2303 0
 #defineTYPE_PL2303HX   1
+#defineTYPE_PL2303HXD  2
 
+#defineUPLCOM_STATE_INDEX  8
+
 enum {
UPLCOM_BULK_DT_WR,
UPLCOM_BULK_DT_RD,
@@ -366,18 +374,49 @@ uplcom_attach(device_t dev)
 
sc->sc_udev = uaa->device;
 
-   /* Determine the chip type.  This algorithm is taken from Linux. */
dd = usbd_get_device_descriptor(sc->sc_udev);
-   if (dd->bDeviceClass == 0x02)
-   sc->sc_chiptype = TYPE_PL2303;
-   else if (dd->bMaxPacketSize == 0x40)
+
+   switch (UGETW(dd->bcdDevice)) {
+   case 0x0300:
sc->sc_chiptype = TYPE_PL2303HX;
-   else
-   sc->sc_chiptype = TYPE_PL2303;
+   /* or TA, that is HX with external crystal */
+   break;
+   case 0x0400:
+   sc->sc_chiptype = TYPE_PL2303HXD;
+   /* or EA, that is HXD with ESD protection */
+   /* or RA, that has internal voltage level converter that works 
only up to 1Mbaud (!) */
+   break;
+   case 0x0500:
+   sc->sc_chiptype = TYPE_PL2303HXD;
+   /* in fact it's TB, that is HXD with external crystal */
+   break;
+   default:
+   /* NOTE: I have no info about the bcdDevice for the base PL2303 
(up to 1.2Mbaud,
+  only fixed rates) and for PL2303SA (8-pin chip, up to 115200 
baud */
+   /* Determine the chip type.  This algorithm is taken from 
Linux. */
+   if (dd->bDeviceClass == 0x02)
+   sc->sc_chiptype = TYPE_PL2303;
+   else if (dd->bMaxPacketSize == 0x40)
+   sc->sc_chiptype = TYPE_PL2303HX;
+   else
+   sc->sc_chiptype = TYPE_PL2303;
+   break;
+   }
 
-   DPRINTF("chiptype: %s\n",
-   (sc->sc_chiptype == TYPE_PL2303HX) ?
-   "2303X" : "2303");
+   switch (sc->sc_chiptype) {
+   case TYPE_PL2303:
+   DPRINTF("chiptype: 2303\n");
+   break;
+   case TYPE_PL2303HX:
+   DPRINTF("chiptype: 2303HX/TA\n");
+   break;
+   case TYPE_PL2303HXD:
+   DPRINTF("chiptype: 2303HXD/TB/RA/EA\n");
+   break;
+   default:
+   DPRINTF("chiptype: unknown %d\n", sc->sc_chiptype);
+   break;
+   }
 
/*
 * USB-RSAQ1 has two interface
@@ -426,13 +465,14 @@ uplcom_attach(device_t dev)
goto detach;
}
 
-   if (sc->sc_chiptype != TYPE_PL2303HX) {
+   if (sc->sc_chiptype == TYPE_PL2303) {
/* HX variants seem to lock up after a clear stall request. */
mtx_lock(>sc_mtx);
usbd_xfer_set_stall(sc->sc_xfer[UPLCOM_BULK_DT_WR]);
usbd_xfer_set_stall(sc->sc_xfer[UPLCOM_BULK_DT_RD]);
mtx_unlock(>sc_mtx);
} else {
+   /* reset upstream data pipes */
if (uplcom_pl2303_do(sc->sc_udev, UT_WRITE_VENDOR_DEVICE,
UPLCOM_SET_REQUEST, 8, 0, 0) ||
uplcom_pl2303_do(sc->sc_udev, UT_WRITE_VENDOR_DEVICE,
@@ -551,7 +591,7 @@ uplcom_pl2303_init(struct usb_device *udev, uint8_t ch
|| uplcom_pl2303_do(udev, UT_WRITE_VENDOR_DEVICE, 
UPLCOM_SET_REQUEST, 1, 0, 0))

svn commit: r339721 - stable/10/sys/dev/sound/midi

2018-10-25 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Oct 25 14:56:19 2018
New Revision: 339721
URL: https://svnweb.freebsd.org/changeset/base/339721

Log:
  MFC r339582:
  Drop sequencer mutex around uiomove() and make sure we don't move more bytes
  than is available, else a panic might happen.
  
  Found by: Peter Holm 
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/sound/midi/sequencer.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/sound/midi/sequencer.c
==
--- stable/10/sys/dev/sound/midi/sequencer.cThu Oct 25 14:55:04 2018
(r339720)
+++ stable/10/sys/dev/sound/midi/sequencer.cThu Oct 25 14:56:19 2018
(r339721)
@@ -928,7 +928,9 @@ seq_read(struct cdev *i_dev, struct uio *uio, int iofl
 
SEQ_DEBUG(8, printf("midiread: uiomove cc=%d\n", used));
MIDIQ_DEQ(scp->in_q, buf, used);
+   mtx_unlock(>seq_lock);
retval = uiomove(buf, used, uio);
+   mtx_lock(>seq_lock);
if (retval)
goto err1;
}
@@ -1003,7 +1005,9 @@ seq_write(struct cdev *i_dev, struct uio *uio, int iof
retval = ENXIO;
goto err0;
}
+   mtx_unlock(>seq_lock);
retval = uiomove(event, used, uio);
+   mtx_lock(>seq_lock);
if (retval)
goto err0;
 
@@ -1041,7 +1045,9 @@ seq_write(struct cdev *i_dev, struct uio *uio, int iof
SEQ_DEBUG(2,
   printf("seq_write: SEQ_FULLSIZE flusing buffer.\n"));
while (uio->uio_resid > 0) {
-   retval = uiomove(event, EV_SZ, uio);
+   mtx_unlock(>seq_lock);
+   retval = uiomove(event, MIN(EV_SZ, 
uio->uio_resid), uio);
+   mtx_lock(>seq_lock);
if (retval)
goto err0;
 
@@ -1052,6 +1058,7 @@ seq_write(struct cdev *i_dev, struct uio *uio, int iof
}
retval = EINVAL;
if (ev_code >= 128) {
+   int error;
 
/*
 * Some sort of an extended event. The size is eight
@@ -1061,7 +1068,13 @@ seq_write(struct cdev *i_dev, struct uio *uio, int iof
SEQ_DEBUG(2, printf("seq_write: invalid level 
two event %x.\n", ev_code));
goto err0;
}
-   if (uiomove((caddr_t)[4], 4, uio)) {
+   mtx_unlock(>seq_lock);
+   if (uio->uio_resid < 4)
+   error = EINVAL;
+   else
+   error = uiomove((caddr_t)[4], 4, uio);
+   mtx_lock(>seq_lock);
+   if (error) {
SEQ_DEBUG(2,
   printf("seq_write: user memory mangled?\n"));
goto err0;
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r339443 - stable/10/sys/dev/usb/controller

2018-10-19 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Oct 19 08:40:25 2018
New Revision: 339443
URL: https://svnweb.freebsd.org/changeset/base/339443

Log:
  MFC r339388:
  Fix for reception of large full speed isochronous frames via the transaction
  translator, when using the DWC OTG USB controller driver. Make sure to re-try
  getting the complete split packets until a DATA0 packet is received. Larger
  isochronous frames may be split into multiple MDATA packets terminated
  by a single DATA0 packet.
  
  PR:   230434
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/controller/dwc_otg.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/controller/dwc_otg.c
==
--- stable/10/sys/dev/usb/controller/dwc_otg.c  Fri Oct 19 08:38:34 2018
(r339442)
+++ stable/10/sys/dev/usb/controller/dwc_otg.c  Fri Oct 19 08:40:25 2018
(r339443)
@@ -1461,6 +1461,8 @@ dwc_otg_host_data_rx(struct dwc_otg_softc *sc, struct 
/* check if we are complete */
if (td->tt_xactpos == HCSPLT_XACTPOS_BEGIN) {
goto complete;
+   } else if (td->hcsplt != 0) {
+   goto receive_pkt;
} else {
/* get more packets */
goto busy;
@@ -1519,8 +1521,10 @@ receive_pkt:
if (td->hcsplt != 0) {
delta = td->tt_complete_slot - sc->sc_last_frame_num - 1;
if (td->tt_scheduled == 0 || delta < DWC_OTG_TT_SLOT_MAX) {
-   td->state = DWC_CHAN_ST_WAIT_C_PKT;
-   goto busy;
+   if (td->ep_type != UE_ISOCHRONOUS) {
+   td->state = DWC_CHAN_ST_WAIT_C_PKT;
+   goto busy;
+   }
}
delta = sc->sc_last_frame_num - td->tt_start_slot;
if (delta > DWC_OTG_TT_SLOT_MAX) {
@@ -1566,12 +1570,23 @@ receive_pkt:
hcchar = td->hcchar;
hcchar |= HCCHAR_EPDIR_IN;
 
-   /* receive complete split ASAP */
-   if ((sc->sc_last_frame_num & 1) != 0 &&
-   td->ep_type == UE_ISOCHRONOUS)
-   hcchar |= HCCHAR_ODDFRM;
-   else
+   if (td->ep_type == UE_ISOCHRONOUS) {
+   if (td->hcsplt != 0) {
+   /* continously buffer */
+   if (sc->sc_last_frame_num & 1)
+   hcchar &= ~HCCHAR_ODDFRM;
+   else
+   hcchar |= HCCHAR_ODDFRM;
+   } else {
+   /* multi buffer, if any */
+   if (sc->sc_last_frame_num & 1)
+   hcchar |= HCCHAR_ODDFRM;
+   else
+   hcchar &= ~HCCHAR_ODDFRM;
+   }
+   } else {
hcchar &= ~HCCHAR_ODDFRM;
+   }
 
/* must enable channel before data can be received */
DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(channel), hcchar);
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r339086 - stable/10/sys/ofed/drivers/net/mlx4

2018-10-02 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Oct  2 16:01:33 2018
New Revision: 339086
URL: https://svnweb.freebsd.org/changeset/base/339086

Log:
  Selectivly backport fix for firmware command hang when switching from
  polling-based firmware commands to event based firmware commands.
  
  This is a direct commit.
  
  Linux commit:
  a7e1f04905e5b2b90251974e781301b6be37
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/ofed/drivers/net/mlx4/cmd.c
  stable/10/sys/ofed/drivers/net/mlx4/mlx4.h

Modified: stable/10/sys/ofed/drivers/net/mlx4/cmd.c
==
--- stable/10/sys/ofed/drivers/net/mlx4/cmd.c   Tue Oct  2 15:58:17 2018
(r339085)
+++ stable/10/sys/ofed/drivers/net/mlx4/cmd.c   Tue Oct  2 16:01:33 2018
(r339086)
@@ -794,14 +794,19 @@ int __mlx4_cmd(struct mlx4_dev *dev, u64 in_param, u64
return -EIO;
 
if (!mlx4_is_mfunc(dev) || (native && mlx4_is_master(dev))) {
+   int ret;
+
+   down_read(_priv(dev)->cmd.switch_sem);
if (mlx4_priv(dev)->cmd.use_events)
-   return mlx4_cmd_wait(dev, in_param, out_param,
-out_is_imm, in_modifier,
-op_modifier, op, timeout);
+   ret = mlx4_cmd_wait(dev, in_param, out_param,
+   out_is_imm, in_modifier,
+   op_modifier, op, timeout);
else
-   return mlx4_cmd_poll(dev, in_param, out_param,
-out_is_imm, in_modifier,
-op_modifier, op, timeout);
+   ret = mlx4_cmd_poll(dev, in_param, out_param,
+   out_is_imm, in_modifier,
+   op_modifier, op, timeout);
+   up_read(_priv(dev)->cmd.switch_sem);
+   return ret;
}
return mlx4_slave_cmd(dev, in_param, out_param, out_is_imm,
  in_modifier, op_modifier, op, timeout);
@@ -2253,6 +2258,7 @@ int mlx4_cmd_init(struct mlx4_dev *dev)
 {
struct mlx4_priv *priv = mlx4_priv(dev);
 
+   init_rwsem(>cmd.switch_sem);
mutex_init(>cmd.hcr_mutex);
mutex_init(>cmd.slave_cmd_mutex);
sema_init(>cmd.poll_sem, 1);
@@ -2351,6 +2357,7 @@ int mlx4_cmd_use_events(struct mlx4_dev *dev)
if (!priv->cmd.context)
return -ENOMEM;
 
+   down_write(>cmd.switch_sem);
for (i = 0; i < priv->cmd.max_cmds; ++i) {
priv->cmd.context[i].token = i;
priv->cmd.context[i].next  = i + 1;
@@ -2370,6 +2377,7 @@ int mlx4_cmd_use_events(struct mlx4_dev *dev)
 
down(>cmd.poll_sem);
priv->cmd.use_events = 1;
+   up_write(>cmd.switch_sem);
 
return err;
 }
@@ -2382,6 +2390,7 @@ void mlx4_cmd_use_polling(struct mlx4_dev *dev)
struct mlx4_priv *priv = mlx4_priv(dev);
int i;
 
+   down_write(>cmd.switch_sem);
priv->cmd.use_events = 0;
 
for (i = 0; i < priv->cmd.max_cmds; ++i)
@@ -2390,6 +2399,7 @@ void mlx4_cmd_use_polling(struct mlx4_dev *dev)
kfree(priv->cmd.context);
 
up(>cmd.poll_sem);
+   up_write(>cmd.switch_sem);
 }
 
 struct mlx4_cmd_mailbox *mlx4_alloc_cmd_mailbox(struct mlx4_dev *dev)

Modified: stable/10/sys/ofed/drivers/net/mlx4/mlx4.h
==
--- stable/10/sys/ofed/drivers/net/mlx4/mlx4.h  Tue Oct  2 15:58:17 2018
(r339085)
+++ stable/10/sys/ofed/drivers/net/mlx4/mlx4.h  Tue Oct  2 16:01:33 2018
(r339086)
@@ -44,6 +44,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -596,6 +597,7 @@ struct mlx4_cmd {
struct mutexslave_cmd_mutex;
struct semaphorepoll_sem;
struct semaphoreevent_sem;
+   struct rw_semaphore switch_sem;
int max_cmds;
spinlock_t  context_lock;
int free_head;
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r338792 - stable/10/lib/libusb

2018-09-19 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Sep 19 08:12:41 2018
New Revision: 338792
URL: https://svnweb.freebsd.org/changeset/base/338792

Log:
  MFC r338679:
  Improve LibUSB debugging by simultaneously allowing both function
  and transfer prints. Make sure the debug level comes from the
  correct USB context.
  
  Found by: Ludovic Rousseau 
  PR:   231264
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/lib/libusb/libusb10.h
  stable/10/lib/libusb/libusb10_io.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libusb/libusb10.h
==
--- stable/10/lib/libusb/libusb10.h Wed Sep 19 08:11:44 2018
(r338791)
+++ stable/10/lib/libusb/libusb10.h Wed Sep 19 08:12:41 2018
(r338792)
@@ -39,22 +39,24 @@
 #defineHOTPLUG_LOCK(ctx) pthread_mutex_lock(&(ctx)->hotplug_lock)
 #defineHOTPLUG_UNLOCK(ctx) pthread_mutex_unlock(&(ctx)->hotplug_lock)
 
-#defineDPRINTF(ctx, dbg, format, args...) do { \
-if ((ctx)->debug == dbg) { \
-   switch (dbg) {  \
-   case LIBUSB_DEBUG_FUNCTION: \
-   printf("LIBUSB_FUNCTION: "  \
-   format "\n", ## args);  \
-   break;  \
-   case LIBUSB_DEBUG_TRANSFER: \
-   printf("LIBUSB_TRANSFER: "  \
-   format "\n", ## args);  \
-   break;  \
-   default:\
-   break;  \
-   }   \
-}  \
-} while(0)
+#defineDPRINTF(ctx, dbg, format, ...) do { \
+   switch (dbg) {  \
+   case LIBUSB_DEBUG_FUNCTION: \
+   if ((ctx)->debug & LIBUSB_DEBUG_FUNCTION) { \
+   printf("LIBUSB_FUNCTION: "  \
+  format "\n", ## __VA_ARGS__);\
+   }   \
+   break;  \
+   case LIBUSB_DEBUG_TRANSFER: \
+   if ((ctx)->debug & LIBUSB_DEBUG_TRANSFER) { \
+   printf("LIBUSB_TRANSFER: "  \
+  format "\n", ## __VA_ARGS__);\
+   }   \
+   break;  \
+   default:\
+   break;  \
+   }   \
+} while (0)
 
 /* internal structures */
 

Modified: stable/10/lib/libusb/libusb10_io.c
==
--- stable/10/lib/libusb/libusb10_io.c  Wed Sep 19 08:11:44 2018
(r338791)
+++ stable/10/lib/libusb/libusb10_io.c  Wed Sep 19 08:12:41 2018
(r338792)
@@ -487,13 +487,26 @@ libusb_control_transfer(libusb_device_handle *devh,
return (actlen);
 }
 
+static libusb_context *
+libusb10_get_context_by_device_handle(libusb_device_handle *devh)
+{
+   libusb_context *ctx;
+
+   if (devh != NULL)
+   ctx = libusb_get_device(devh)->ctx;
+   else
+   ctx = NULL;
+
+   return (GET_CONTEXT(ctx));
+}
+
 static void
 libusb10_do_transfer_cb(struct libusb_transfer *transfer)
 {
libusb_context *ctx;
int *pdone;
 
-   ctx = GET_CONTEXT(NULL);
+   ctx = libusb10_get_context_by_device_handle(transfer->dev_handle);
 
DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "sync I/O done");
 
@@ -583,7 +596,8 @@ libusb_bulk_transfer(libusb_device_handle *devh,
libusb_context *ctx;
int ret;
 
-   ctx = GET_CONTEXT(NULL);
+   ctx = libusb10_get_context_by_device_handle(devh);
+
DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_bulk_transfer enter");
 
ret = libusb10_do_transfer(devh, endpoint, data, length, transferred,
@@ -601,7 +615,8 @@ libusb_interrupt_transfer(libusb_device_handle *devh,
libusb_context *ctx;
int ret;
 
-   ctx = GET_CONTEXT(NULL);
+   ctx = libusb10_get_context_by_device_handle(devh);
+
DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_interrupt_transfer enter");
 
ret = libusb10_do_transfer(devh, endpoint, data, length, transferred,
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r338789 - stable/10/lib/libusb

2018-09-19 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Sep 19 07:57:30 2018
New Revision: 338789
URL: https://svnweb.freebsd.org/changeset/base/338789

Log:
  MFC r338616:
  Fix issues about cancelling USB transfers in LibUSB when the USB device has
  been detached. When a USB device has been detached the kernel file handle
  stops responding to commands. USB applications which continue to run after
  the USB device has been detached, depend on LibUSB generated events to tear
  down its pending USB transfers. Add code to handle the needed cleanup when
  processing the USB transfer(s) fails and prevent new USB transfer(s) from
  being submitted.
  
  Found by: Ludovic Rousseau 
  PR:   231076
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/lib/libusb/libusb10.c
  stable/10/lib/libusb/libusb10.h
  stable/10/lib/libusb/libusb10_io.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libusb/libusb10.c
==
--- stable/10/lib/libusb/libusb10.c Wed Sep 19 07:56:19 2018
(r338788)
+++ stable/10/lib/libusb/libusb10.c Wed Sep 19 07:57:30 2018
(r338789)
@@ -112,6 +112,19 @@ libusb_set_nonblocking(int f)
fcntl(f, F_SETFL, flags);
 }
 
+static void
+libusb10_wakeup_event_loop(libusb_context *ctx)
+{
+   uint8_t dummy = 0;
+   int err;
+
+   err = write(ctx->ctrl_pipe[1], , sizeof(dummy));
+   if (err < (int)sizeof(dummy)) {
+   /* ignore error, if any */
+   DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "Waking up event loop 
failed!");
+   }
+}
+
 int
 libusb_init(libusb_context **context)
 {
@@ -482,7 +495,6 @@ libusb_open(libusb_device *dev, libusb_device_handle *
 {
libusb_context *ctx = dev->ctx;
struct libusb20_device *pdev = dev->os_priv;
-   uint8_t dummy;
int err;
 
if (devh == NULL)
@@ -504,12 +516,8 @@ libusb_open(libusb_device *dev, libusb_device_handle *
POLLOUT | POLLRDNORM | POLLWRNORM);
 
/* make sure our event loop detects the new device */
-   dummy = 0;
-   err = write(ctx->ctrl_pipe[1], , sizeof(dummy));
-   if (err < (int)sizeof(dummy)) {
-   /* ignore error, if any */
-   DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open write 
failed!");
-   }
+   libusb10_wakeup_event_loop(ctx);
+
*devh = pdev;
 
return (0);
@@ -562,8 +570,6 @@ libusb_close(struct libusb20_device *pdev)
 {
libusb_context *ctx;
struct libusb_device *dev;
-   uint8_t dummy;
-   int err;
 
if (pdev == NULL)
return; /* be NULL safe */
@@ -579,12 +585,7 @@ libusb_close(struct libusb20_device *pdev)
libusb_unref_device(dev);
 
/* make sure our event loop detects the closed device */
-   dummy = 0;
-   err = write(ctx->ctrl_pipe[1], , sizeof(dummy));
-   if (err < (int)sizeof(dummy)) {
-   /* ignore error, if any */
-   DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_close write 
failed!");
-   }
+   libusb10_wakeup_event_loop(ctx);
 }
 
 libusb_device *
@@ -1319,7 +1320,6 @@ libusb10_submit_transfer_sub(struct libusb20_device *p
int buffsize;
int maxframe;
int temp;
-   uint8_t dummy;
 
dev = libusb_get_device(pdev);
 
@@ -1420,10 +1420,8 @@ found:
 
 failure:
libusb10_complete_transfer(pxfer0, sxfer, LIBUSB_TRANSFER_ERROR);
-
/* make sure our event loop spins the done handler */
-   dummy = 0;
-   err = write(dev->ctx->ctrl_pipe[1], , sizeof(dummy));
+   libusb10_wakeup_event_loop(dev->ctx);
 }
 
 /* The following function must be called unlocked */
@@ -1464,6 +1462,8 @@ libusb_submit_transfer(struct libusb_transfer *uxfer)
(libusb20_tr_get_priv_sc1(pxfer0) == sxfer) ||
(libusb20_tr_get_priv_sc1(pxfer1) == sxfer)) {
err = LIBUSB_ERROR_BUSY;
+   } else if (dev->device_is_gone != 0) {
+   err = LIBUSB_ERROR_NO_DEVICE;
} else {
 
/* set pending state */
@@ -1495,6 +1495,7 @@ libusb_cancel_transfer(struct libusb_transfer *uxfer)
struct libusb20_transfer *pxfer1;
struct libusb_super_transfer *sxfer;
struct libusb_device *dev;
+   struct libusb_device_handle *devh;
uint8_t endpoint;
int retval;
 
@@ -1502,12 +1503,12 @@ libusb_cancel_transfer(struct libusb_transfer *uxfer)
return (LIBUSB_ERROR_INVALID_PARAM);
 
/* check if not initialised */
-   if (uxfer->dev_handle == NULL)
+   if ((devh = uxfer->dev_handle) == NULL)
return (LIBUSB_ERROR_NOT_FOUND);
 
endpoint = uxfer->endpoint;
 
-   dev = libusb_get_device(uxfer->dev_handle);
+   dev = libusb_get_device(devh);
 
DPRINTF(dev->ctx, LIBUSB_DEBUG_FUNCTION, "libusb_cancel_transfer 
enter");
 
@@ -1518,8 +1519,8 @@ 

svn commit: r338615 - stable/10/sys/ofed/drivers/infiniband/core

2018-09-12 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Sep 12 10:53:22 2018
New Revision: 338615
URL: https://svnweb.freebsd.org/changeset/base/338615

Log:
  Fix incorrect display of the sys.class.infiniband.xxx.ports.1.rate sysctl
  entry in ibcore by adding support for new rate types.
  
  This is a direct commit.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/ofed/drivers/infiniband/core/sysfs.c

Modified: stable/10/sys/ofed/drivers/infiniband/core/sysfs.c
==
--- stable/10/sys/ofed/drivers/infiniband/core/sysfs.c  Wed Sep 12 10:27:58 
2018(r338614)
+++ stable/10/sys/ofed/drivers/infiniband/core/sysfs.c  Wed Sep 12 10:53:22 
2018(r338615)
@@ -180,7 +180,7 @@ static ssize_t rate_show(struct ib_port *p, struct por
 {
struct ib_port_attr attr;
char *speed = "";
-   int rate;
+   int rate;   /* in deci-Gb/sec */
ssize_t ret;
 
ret = ib_query_port(p->ibdev, p->port_num, );
@@ -188,11 +188,33 @@ static ssize_t rate_show(struct ib_port *p, struct por
return ret;
 
switch (attr.active_speed) {
-   case 2: speed = " DDR"; break;
-   case 4: speed = " QDR"; break;
+   case IB_SPEED_DDR:
+   speed = " DDR";
+   rate = 50;
+   break;
+   case IB_SPEED_QDR:
+   speed = " QDR";
+   rate = 100;
+   break;
+   case IB_SPEED_FDR10:
+   speed = " FDR10";
+   rate = 100;
+   break;
+   case IB_SPEED_FDR:
+   speed = " FDR";
+   rate = 140;
+   break;
+   case IB_SPEED_EDR:
+   speed = " EDR";
+   rate = 250;
+   break;
+   case IB_SPEED_SDR:
+   default:/* default to SDR for invalid rates */
+   rate = 25;
+   break;
}
 
-   rate = 25 * ib_width_enum_to_int(attr.active_width) * attr.active_speed;
+   rate *= ib_width_enum_to_int(attr.active_width);
if (rate < 0)
return -EINVAL;
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r338553 - stable/10/sys/dev/mlx5/mlx5_en

2018-09-10 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Sep 10 08:10:52 2018
New Revision: 338553
URL: https://svnweb.freebsd.org/changeset/base/338553

Log:
  MFC r338492:
  Add support for receive side scaling stride, RSSS, in mlx5en(4).
  
  The receive side scaling stride parameter is a value which define the interval
  between active receive side queues. The traffic for the inactive queues is
  redirected to the nearest active queue by use of modulus. The default value
  of this parameter is one, which means all receive side queues are used.
  
  The point of this feature is to redirect more traffic to fewer receive side
  queues in order to take more advantage of sorted large receive offload,
  sorted LRO. The sorted LRO works better when more packets are accumulated
  per service interval.
  
  Sponsored by: Mellanox Technologies

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

Modified: stable/10/sys/dev/mlx5/mlx5_en/en.h
==
--- stable/10/sys/dev/mlx5/mlx5_en/en.h Mon Sep 10 08:09:42 2018
(r338552)
+++ stable/10/sys/dev/mlx5/mlx5_en/en.h Mon Sep 10 08:10:52 2018
(r338553)
@@ -407,6 +407,7 @@ struct mlx5e_params {
u32 rx_pauseframe_control;
u16 tx_max_inline;
u8  tx_min_inline_mode;
+   u8  channels_rsss;
 };
 
 #defineMLX5E_PARAMS(m) 
\
@@ -415,6 +416,7 @@ struct mlx5e_params {
   m(+1, u64 tx_queue_size, "tx_queue_size", "Default send queue size") \
   m(+1, u64 rx_queue_size, "rx_queue_size", "Default receive queue size") \
   m(+1, u64 channels, "channels", "Default number of channels")
\
+  m(+1, u64 channels_rsss, "channels_rsss", "Default channels receive side 
scaling stride") \
   m(+1, u64 coalesce_usecs_max, "coalesce_usecs_max", "Maximum usecs for 
joining packets") \
   m(+1, u64 coalesce_pkts_max, "coalesce_pkts_max", "Maximum packets to join") 
\
   m(+1, u64 rx_coalesce_usecs, "rx_coalesce_usecs", "Limit in usec for joining 
rx packets") \

Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
==
--- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.cMon Sep 10 08:09:42 
2018(r338552)
+++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.cMon Sep 10 08:10:52 
2018(r338553)
@@ -246,6 +246,24 @@ mlx5e_ethtool_handler(SYSCTL_HANDLER_ARGS)
mlx5e_open_locked(priv->ifp);
break;
 
+   case MLX5_PARAM_OFFSET(channels_rsss):
+   /* network interface must be down */
+   if (was_opened)
+   mlx5e_close_locked(priv->ifp);
+
+   /* import number of channels */
+   if (priv->params_ethtool.channels_rsss < 1)
+   priv->params_ethtool.channels_rsss = 1;
+   else if (priv->params_ethtool.channels_rsss > 128)
+   priv->params_ethtool.channels_rsss = 128;
+
+   priv->params.channels_rsss = priv->params_ethtool.channels_rsss;
+
+   /* restart network interface, if any */
+   if (was_opened)
+   mlx5e_open_locked(priv->ifp);
+   break;
+
case MLX5_PARAM_OFFSET(channels):
/* network interface must be down */
if (was_opened)
@@ -694,6 +712,7 @@ mlx5e_create_ethtool(struct mlx5e_priv *priv)
priv->params_ethtool.tx_queue_size = 1 << priv->params.log_sq_size;
priv->params_ethtool.rx_queue_size = 1 << priv->params.log_rq_size;
priv->params_ethtool.channels = priv->params.num_channels;
+   priv->params_ethtool.channels_rsss = priv->params.channels_rsss;
priv->params_ethtool.coalesce_pkts_max = MLX5E_FLD_MAX(cqc, 
cq_max_count);
priv->params_ethtool.coalesce_usecs_max = MLX5E_FLD_MAX(cqc, cq_period);
priv->params_ethtool.rx_coalesce_mode = 
priv->params.rx_cq_moderation_mode;

Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==
--- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c   Mon Sep 10 08:09:42 
2018(r338552)
+++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c   Mon Sep 10 08:10:52 
2018(r338553)
@@ -2055,14 +2055,16 @@ mlx5e_open_rqt(struct mlx5e_priv *priv)
MLX5_SET(rqtc, rqtc, rqt_max_size, sz);
 
for (i = 0; i < sz; i++) {
-   int ix;
+   int ix = i;
 #ifdef RSS
-   ix = rss_get_indirection_to_bucket(i);
-#else
-   ix = i;
+   ix = rss_get_indirection_to_bucket(ix);
 #endif
/* ensure we don't overflow */
ix %= priv->params.num_channels;
+
+   

svn commit: r338551 - stable/10/sys/dev/mlx5/mlx5_en

2018-09-10 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Sep 10 08:06:34 2018
New Revision: 338551
URL: https://svnweb.freebsd.org/changeset/base/338551

Log:
  MFC r338490:
  Don't stall transmit queue on drops in mlx5en(4).
  
  When a transmitted packet is dropped don't stall the transmit queue.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
==
--- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Mon Sep 10 08:05:36 2018
(r338550)
+++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Mon Sep 10 08:06:34 2018
(r338551)
@@ -515,13 +515,11 @@ mlx5e_xmit_locked(struct ifnet *ifp, struct mlx5e_sq *
/* Process the queue */
while ((next = drbr_peek(ifp, sq->br)) != NULL) {
if (mlx5e_sq_xmit(sq, ) != 0) {
-   if (next == NULL) {
-   drbr_advance(ifp, sq->br);
-   } else {
+   if (next != NULL) {
drbr_putback(ifp, sq->br, next);
atomic_store_rel_int(>queue_state, 
MLX5E_SQ_FULL);
+   break;
}
-   break;
}
drbr_advance(ifp, sq->br);
}
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r338549 - stable/10/sys/dev/mlx5/mlx5_en

2018-09-10 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Sep 10 08:03:52 2018
New Revision: 338549
URL: https://svnweb.freebsd.org/changeset/base/338549

Log:
  MFC r338489:
  Maximum number of mbuf frags is off-by-one for worst case scenario in 
mlx5en(4).
  
  Inspecting the PRM no more than 0x3F data segments, DS, of size 16 bytes is
  allowed.
  
  Worst case scenario summary of DS usage:
  Header is fixed:  2 DS
  Maximum inlining: 98 => (98 - 2) / 16 = 6 DS
  Remainder:0x3F - 2 - 6 = 55 DS (mbuf frags)
  
  Previously a value of 56 DS was used and this would work in the
  normal case because not all inline data area was used up.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/mlx5/mlx5_en/en.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/mlx5/mlx5_en/en.h
==
--- stable/10/sys/dev/mlx5/mlx5_en/en.h Mon Sep 10 08:02:02 2018
(r338548)
+++ stable/10/sys/dev/mlx5/mlx5_en/en.h Mon Sep 10 08:03:52 2018
(r338549)
@@ -125,7 +125,8 @@
 #defineMLX5E_MAX_TX_MBUF_SIZE  65536   /* bytes */
 #defineMLX5E_MAX_TX_MBUF_FRAGS \
 ((MLX5_SEND_WQE_MAX_WQEBBS * MLX5_SEND_WQEBB_NUM_DS) - \
-(MLX5E_MAX_TX_HEADER / MLX5_SEND_WQE_DS))  /* units */
+(MLX5E_MAX_TX_HEADER / MLX5_SEND_WQE_DS) - \
+1 /* the maximum value of the DS counter is 0x3F and not 0x40 */)  /* 
units */
 #defineMLX5E_MAX_TX_INLINE \
   (MLX5E_MAX_TX_HEADER - sizeof(struct mlx5e_tx_wqe) + \
   sizeof(((struct mlx5e_tx_wqe *)0)->eth.inline_hdr_start))/* bytes */
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r337746 - stable/10/sys/dev/mlx5/mlx5_en

2018-08-14 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Aug 14 11:43:02 2018
New Revision: 337746
URL: https://svnweb.freebsd.org/changeset/base/337746

Log:
  MFC r325661:
  Expose the current hardware MTU in mlx5en(4) as a separate entry
  in the sysctl tree.
  
  Sponsored by: Mellanox Technologies

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

Modified: stable/10/sys/dev/mlx5/mlx5_en/en.h
==
--- stable/10/sys/dev/mlx5/mlx5_en/en.h Tue Aug 14 11:42:32 2018
(r337745)
+++ stable/10/sys/dev/mlx5/mlx5_en/en.h Tue Aug 14 11:43:02 2018
(r337746)
@@ -428,7 +428,8 @@ struct mlx5e_params {
   m(+1, u64 hw_lro, "hw_lro", "set to enable hw_lro") \
   m(+1, u64 cqe_zipping, "cqe_zipping", "0 : CQE zipping disabled") \
   m(+1, u64 diag_pci_enable, "diag_pci_enable", "0: Disabled 1: Enabled") \
-  m(+1, u64 diag_general_enable, "diag_general_enable", "0: Disabled 1: 
Enabled")
+  m(+1, u64 diag_general_enable, "diag_general_enable", "0: Disabled 1: 
Enabled") \
+  m(+1, u64 hw_mtu, "hw_mtu", "Current hardware MTU value")
 
 #defineMLX5E_PARAMS_NUM (0 MLX5E_PARAMS(MLX5E_STATS_COUNT))
 

Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
==
--- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.cTue Aug 14 11:42:32 
2018(r337745)
+++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.cTue Aug 14 11:43:02 
2018(r337746)
@@ -714,7 +714,8 @@ mlx5e_create_ethtool(struct mlx5e_priv *priv)
return;
for (x = 0; x != MLX5E_PARAMS_NUM; x++) {
/* check for read-only parameter */
-   if (strstr(mlx5e_params_desc[2 * x], "_max") != NULL) {
+   if (strstr(mlx5e_params_desc[2 * x], "_max") != NULL ||
+   strstr(mlx5e_params_desc[2 * x], "_mtu") != NULL) {
SYSCTL_ADD_PROC(>sysctl_ctx, 
SYSCTL_CHILDREN(node), OID_AUTO,
mlx5e_params_desc[2 * x], CTLTYPE_U64 | CTLFLAG_RD |
CTLFLAG_MPSAFE, priv, x, _ethtool_handler, 
"QU",

Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==
--- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c   Tue Aug 14 11:42:32 
2018(r337745)
+++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c   Tue Aug 14 11:43:02 
2018(r337746)
@@ -2353,10 +2353,13 @@ mlx5e_set_dev_port_mtu(struct ifnet *ifp, int sw_mtu)
__func__, sw_mtu, err);
return (err);
}
+
+   ifp->if_mtu = sw_mtu;
err = mlx5_query_port_oper_mtu(mdev, _mtu);
if (err) {
if_printf(ifp, "Query port MTU, after setting new "
"MTU value, failed\n");
+   return (err);
} else if (MLX5E_HW2SW_MTU(hw_mtu) < sw_mtu) {
err = -E2BIG,
if_printf(ifp, "Port MTU %d is smaller than "
@@ -2366,7 +2369,8 @@ mlx5e_set_dev_port_mtu(struct ifnet *ifp, int sw_mtu)
 if_printf(ifp, "Port MTU %d is bigger than "
 "ifp mtu %d\n", hw_mtu, sw_mtu);
}
-   ifp->if_mtu = sw_mtu;
+   priv->params_ethtool.hw_mtu = hw_mtu;
+
return (err);
 }
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r337743 - in stable/10/sys/dev/mlx5: mlx5_core mlx5_en

2018-08-14 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Aug 14 11:24:14 2018
New Revision: 337743
URL: https://svnweb.freebsd.org/changeset/base/337743

Log:
  Enter error state when handling bad device in mlx5core and add checks
  for error state to mlx5en(4) to make live migration work.
  
  This is a direct commit.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/mlx5/mlx5_core/mlx5_health.c
  stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c

Modified: stable/10/sys/dev/mlx5/mlx5_core/mlx5_health.c
==
--- stable/10/sys/dev/mlx5/mlx5_core/mlx5_health.c  Tue Aug 14 11:19:04 
2018(r337742)
+++ stable/10/sys/dev/mlx5/mlx5_core/mlx5_health.c  Tue Aug 14 11:24:14 
2018(r337743)
@@ -56,10 +56,13 @@ static void health_care(struct work_struct *work)
priv = container_of(health, struct mlx5_priv, health);
dev = container_of(priv, struct mlx5_core_dev, priv);
mlx5_core_warn(dev, "handling bad device here\n");
-   /* nothing yet */
+
spin_lock_irq(_lock);
list_del_init(>list);
spin_unlock_irq(_lock);
+
+   /* enter error state */
+   mlx5_enter_error_state(dev);
}
 }
 

Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==
--- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c   Tue Aug 14 11:19:04 
2018(r337742)
+++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c   Tue Aug 14 11:24:14 
2018(r337743)
@@ -921,8 +921,11 @@ mlx5e_close_rq(struct mlx5e_rq *rq)
 static void
 mlx5e_close_rq_wait(struct mlx5e_rq *rq)
 {
+   struct mlx5_core_dev *mdev = rq->channel->priv->mdev;
+
/* wait till RQ is empty */
-   while (!mlx5_wq_ll_is_empty(>wq)) {
+   while (!mlx5_wq_ll_is_empty(>wq) &&
+   (mdev->state != MLX5_DEVICE_STATE_INTERNAL_ERROR)) {
msleep(4);
rq->cq.mcq.comp(>cq.mcq);
}
@@ -1264,6 +1267,7 @@ void
 mlx5e_drain_sq(struct mlx5e_sq *sq)
 {
int error;
+   struct mlx5_core_dev *mdev = sq->priv->mdev;
 
/*
 * Check if already stopped.
@@ -1296,7 +1300,8 @@ mlx5e_drain_sq(struct mlx5e_sq *sq)
/* wait till SQ is empty or link is down */
mtx_lock(>lock);
while (sq->cc != sq->pc &&
-   (sq->priv->media_status_last & IFM_ACTIVE) != 0) {
+   (sq->priv->media_status_last & IFM_ACTIVE) != 0 &&
+   mdev->state != MLX5_DEVICE_STATE_INTERNAL_ERROR) {
mtx_unlock(>lock);
msleep(1);
sq->cq.mcq.comp(>cq.mcq);
@@ -1313,7 +1318,8 @@ mlx5e_drain_sq(struct mlx5e_sq *sq)
 
/* wait till SQ is empty */
mtx_lock(>lock);
-   while (sq->cc != sq->pc) {
+   while (sq->cc != sq->pc &&
+   mdev->state != MLX5_DEVICE_STATE_INTERNAL_ERROR) {
mtx_unlock(>lock);
msleep(1);
sq->cq.mcq.comp(>cq.mcq);
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r337742 - in stable/10/sys/dev/mlx5: . mlx5_core mlx5_en

2018-08-14 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Aug 14 11:19:04 2018
New Revision: 337742
URL: https://svnweb.freebsd.org/changeset/base/337742

Log:
  MFC r336450:
  Do not inline transmit headers and use HW VLAN tagging if supported by 
mlx5en(4).
  
  Query the minimal inline mode supported by the card.
  When creating a send queue, cache the queried mode and optimize the transmit
  if no inlining is required.  In this case, we can avoid touching the headers
  cache line and avoid dirtying several more lines by copying headers into
  the send WQEs.  Also, if no inline headers are used, hardware assists in
  the VLAN tag framing.
  
  Submitted by: kib@, slavash@
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/mlx5/device.h
  stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c
  stable/10/sys/dev/mlx5/mlx5_en/en.h
  stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
  stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
  stable/10/sys/dev/mlx5/qp.h
  stable/10/sys/dev/mlx5/vport.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/mlx5/device.h
==
--- stable/10/sys/dev/mlx5/device.h Tue Aug 14 11:15:05 2018
(r337741)
+++ stable/10/sys/dev/mlx5/device.h Tue Aug 14 11:19:04 2018
(r337742)
@@ -1311,6 +1311,13 @@ enum {
MLX5_CMD_HCA_CAP_MIN_WQE_INLINE_MODE_NOT_REQUIRED = 0x2
 };
 
+enum mlx5_inline_modes {
+   MLX5_INLINE_MODE_NONE,
+   MLX5_INLINE_MODE_L2,
+   MLX5_INLINE_MODE_IP,
+   MLX5_INLINE_MODE_TCP_UDP,
+};
+
 enum {
MLX5_QUERY_VPORT_STATE_OUT_STATE_FOLLOW = 0x2,
 };

Modified: stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c
==
--- stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c   Tue Aug 14 11:15:05 
2018(r337741)
+++ stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c   Tue Aug 14 11:19:04 
2018(r337742)
@@ -228,6 +228,58 @@ int mlx5_vport_query_out_of_rx_buffer(struct mlx5_core
return err;
 }
 
+int mlx5_query_nic_vport_min_inline(struct mlx5_core_dev *mdev,
+   u16 vport, u8 *min_inline)
+{
+   u32 out[MLX5_ST_SZ_DW(query_nic_vport_context_out)] = {0};
+   int err;
+
+   err = mlx5_query_nic_vport_context(mdev, vport, out, sizeof(out));
+   if (!err)
+   *min_inline = MLX5_GET(query_nic_vport_context_out, out,
+  nic_vport_context.min_wqe_inline_mode);
+   return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_min_inline);
+
+void mlx5_query_min_inline(struct mlx5_core_dev *mdev,
+  u8 *min_inline_mode)
+{
+   switch (MLX5_CAP_ETH(mdev, wqe_inline_mode)) {
+   case MLX5_CAP_INLINE_MODE_L2:
+   *min_inline_mode = MLX5_INLINE_MODE_L2;
+   break;
+   case MLX5_CAP_INLINE_MODE_VPORT_CONTEXT:
+   mlx5_query_nic_vport_min_inline(mdev, 0, min_inline_mode);
+   break;
+   case MLX5_CAP_INLINE_MODE_NOT_REQUIRED:
+   *min_inline_mode = MLX5_INLINE_MODE_NONE;
+   break;
+   }
+}
+EXPORT_SYMBOL_GPL(mlx5_query_min_inline);
+
+int mlx5_modify_nic_vport_min_inline(struct mlx5_core_dev *mdev,
+u16 vport, u8 min_inline)
+{
+   u32 in[MLX5_ST_SZ_DW(modify_nic_vport_context_in)] = {0};
+   int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in);
+   void *nic_vport_ctx;
+
+   MLX5_SET(modify_nic_vport_context_in, in,
+field_select.min_wqe_inline_mode, 1);
+   MLX5_SET(modify_nic_vport_context_in, in, vport_number, vport);
+   MLX5_SET(modify_nic_vport_context_in, in, other_vport, 1);
+
+   nic_vport_ctx = MLX5_ADDR_OF(modify_nic_vport_context_in,
+in, nic_vport_context);
+   MLX5_SET(nic_vport_context, nic_vport_ctx,
+min_wqe_inline_mode, min_inline);
+
+   return mlx5_modify_nic_vport_context(mdev, in, inlen);
+}
+EXPORT_SYMBOL_GPL(mlx5_modify_nic_vport_min_inline);
+
 int mlx5_query_nic_vport_mac_address(struct mlx5_core_dev *mdev,
 u16 vport, u8 *addr)
 {

Modified: stable/10/sys/dev/mlx5/mlx5_en/en.h
==
--- stable/10/sys/dev/mlx5/mlx5_en/en.h Tue Aug 14 11:15:05 2018
(r337741)
+++ stable/10/sys/dev/mlx5/mlx5_en/en.h Tue Aug 14 11:19:04 2018
(r337742)
@@ -404,6 +404,8 @@ struct mlx5e_params {
u16 rx_hash_log_tbl_sz;
u32 tx_pauseframe_control;
u32 rx_pauseframe_control;
+   u16 tx_max_inline;
+   u8  tx_min_inline_mode;
 };
 
 #defineMLX5E_PARAMS(m) 
\
@@ -560,6 +562,9 @@ struct mlx5e_sq {
u32 sqn;
u32 bf_buf_size;
u32 mkey_be;
+   u16 max_inline;
+ 

svn commit: r337741 - stable/10/sys/dev/mlx5/mlx5_en

2018-08-14 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Aug 14 11:15:05 2018
New Revision: 337741
URL: https://svnweb.freebsd.org/changeset/base/337741

Log:
  MFC r336407:
  Handle jumbo frames without requiring big clusters in mlx5en(4).
  
  The scatter list is formed by the chunks of MCLBYTES each, and larger
  than default packets are returned to the stack as the mbuf chain.
  
  Submitted by: kib@
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/mlx5/mlx5_en/en.h
  stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
  stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/mlx5/mlx5_en/en.h
==
--- stable/10/sys/dev/mlx5/mlx5_en/en.h Tue Aug 14 11:01:52 2018
(r337740)
+++ stable/10/sys/dev/mlx5/mlx5_en/en.h Tue Aug 14 11:15:05 2018
(r337741)
@@ -83,8 +83,19 @@
 #defineMLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE0xa
 #defineMLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE0xe
 
-/* freeBSD HW LRO is limited by 16KB - the size of max mbuf */
+#defineMLX5E_MAX_RX_SEGS 7
+
+#ifndef MLX5E_MAX_RX_BYTES
+#defineMLX5E_MAX_RX_BYTES MCLBYTES
+#endif
+
+#if (MLX5E_MAX_RX_SEGS == 1)
+/* FreeBSD HW LRO is limited by 16KB - the size of max mbuf */
 #defineMLX5E_PARAMS_DEFAULT_LRO_WQE_SZ MJUM16BYTES
+#else
+#defineMLX5E_PARAMS_DEFAULT_LRO_WQE_SZ \
+MIN(65535, MLX5E_MAX_RX_SEGS * MLX5E_MAX_RX_BYTES)
+#endif
 #defineMLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC  0x10
 #defineMLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC_FROM_CQE 0x3
 #defineMLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_PKTS  0x20
@@ -476,6 +487,7 @@ struct mlx5e_rq {
struct mtx mtx;
bus_dma_tag_t dma_tag;
u32 wqe_sz;
+   u32 nsegs;
struct mlx5e_rq_mbuf *mbuf;
struct ifnet *ifp;
struct mlx5e_rq_stats stats;
@@ -709,8 +721,11 @@ struct mlx5e_tx_wqe {
 
 struct mlx5e_rx_wqe {
struct mlx5_wqe_srq_next_seg next;
-   struct mlx5_wqe_data_seg data;
+   struct mlx5_wqe_data_seg data[];
 };
+
+/* the size of the structure above must be power of two */
+CTASSERT(powerof2(sizeof(struct mlx5e_rx_wqe)));
 
 struct mlx5e_eeprom {
int lock_bit;

Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==
--- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c   Tue Aug 14 11:01:52 
2018(r337740)
+++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c   Tue Aug 14 11:15:05 
2018(r337741)
@@ -34,6 +34,8 @@
 char mlx5e_version[] = "Mellanox Ethernet driver"
 " (" ETH_DRIVER_VERSION ")";
 
+static int mlx5e_get_wqe_sz(struct mlx5e_priv *priv, u32 *wqe_sz, u32 *nsegs);
+
 struct mlx5e_channel_param {
struct mlx5e_rq_param rq;
struct mlx5e_sq_param sq;
@@ -654,7 +656,12 @@ mlx5e_create_rq(struct mlx5e_channel *c,
int wq_sz;
int err;
int i;
+   u32 nsegs, wqe_sz;
 
+   err = mlx5e_get_wqe_sz(priv, _sz, );
+   if (err != 0)
+   goto done;
+
/* Create DMA descriptor TAG */
if ((err = -bus_dma_tag_create(
bus_get_dma_tag(mdev->pdev->dev.bsddev),
@@ -663,9 +670,9 @@ mlx5e_create_rq(struct mlx5e_channel *c,
BUS_SPACE_MAXADDR,  /* lowaddr */
BUS_SPACE_MAXADDR,  /* highaddr */
NULL, NULL, /* filter, filterarg */
-   MJUM16BYTES,/* maxsize */
-   1,  /* nsegments */
-   MJUM16BYTES,/* maxsegsize */
+   nsegs * MLX5E_MAX_RX_BYTES, /* maxsize */
+   nsegs,  /* nsegments */
+   nsegs * MLX5E_MAX_RX_BYTES, /* maxsegsize */
0,  /* flags */
NULL, NULL, /* lockfunc, lockfuncarg */
>dma_tag)))
@@ -678,29 +685,19 @@ mlx5e_create_rq(struct mlx5e_channel *c,
 
rq->wq.db = >wq.db[MLX5_RCV_DBR];
 
-   if (priv->params.hw_lro_en) {
-   rq->wqe_sz = priv->params.lro_wqe_sz;
-   } else {
-   rq->wqe_sz = MLX5E_SW2MB_MTU(priv->ifp->if_mtu);
-   }
-   if (rq->wqe_sz > MJUM16BYTES) {
-   err = -ENOMEM;
+   err = mlx5e_get_wqe_sz(priv, >wqe_sz, >nsegs);
+   if (err != 0)
goto err_rq_wq_destroy;
-   } else if (rq->wqe_sz > MJUM9BYTES) {
-   rq->wqe_sz = MJUM16BYTES;
-   } else if (rq->wqe_sz > MJUMPAGESIZE) {
-   rq->wqe_sz = MJUM9BYTES;
-   } else if (rq->wqe_sz > MCLBYTES) {
-   rq->wqe_sz = MJUMPAGESIZE;
-   } else {
-   rq->wqe_sz = MCLBYTES;
-   }
 
wq_sz = mlx5_wq_ll_get_size(>wq);
rq->mbuf = malloc(wq_sz * sizeof(rq->mbuf[0]), M_MLX5EN, M_WAITOK | 
M_ZERO);

svn commit: r337042 - stable/10/sys/sys

2018-08-01 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Aug  1 13:13:43 2018
New Revision: 337042
URL: https://svnweb.freebsd.org/changeset/base/337042

Log:
  MFC r322596:
  Add SI_SUB_TASKQ after SI_SUB_INTR and move taskqueue initialization there 
for EARLY_AP_STARTUP
  
  This fixes a regression accidentally introduced in r322588, due to an
  interaction with EARLY_AP_STARTUP.
  
  Reviewed by:  bdrewery@, jhb@
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D12053

Modified:
  stable/10/sys/sys/kernel.h
  stable/10/sys/sys/taskqueue.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/sys/kernel.h
==
--- stable/10/sys/sys/kernel.h  Wed Aug  1 12:49:51 2018(r337041)
+++ stable/10/sys/sys/kernel.h  Wed Aug  1 13:13:43 2018(r337042)
@@ -127,8 +127,9 @@ enum sysinit_sub_id {
SI_SUB_SCHED_IDLE   = 0x260,/* required idle procs */
SI_SUB_MBUF = 0x270,/* mbuf subsystem */
SI_SUB_INTR = 0x280,/* interrupt threads */
-   SI_SUB_SOFTINTR = 0x281,/* start soft interrupt thread 
*/
+   SI_SUB_TASKQ= 0x288,/* task queues */
SI_SUB_ACL  = 0x290,/* start for filesystem ACLs */
+   SI_SUB_SOFTINTR = 0x2A0,/* start soft interrupt thread 
*/
SI_SUB_DEVFS= 0x2F0,/* devfs ready for devices */
SI_SUB_INIT_IF  = 0x300,/* prep for net interfaces */
SI_SUB_NETGRAPH = 0x301,/* Let Netgraph initialize */

Modified: stable/10/sys/sys/taskqueue.h
==
--- stable/10/sys/sys/taskqueue.h   Wed Aug  1 12:49:51 2018
(r337041)
+++ stable/10/sys/sys/taskqueue.h   Wed Aug  1 13:13:43 2018
(r337042)
@@ -141,7 +141,7 @@ taskqueue_define_##name(void *arg)  
\
init;   \
 }  \
\
-SYSINIT(taskqueue_##name, SI_SUB_CONFIGURE, SI_ORDER_SECOND,   \
+SYSINIT(taskqueue_##name, SI_SUB_TASKQ, SI_ORDER_SECOND,   \
taskqueue_define_##name, NULL); \
\
 struct __hack
@@ -166,7 +166,7 @@ taskqueue_define_##name(void *arg)  
\
init;   \
 }  \
\
-SYSINIT(taskqueue_##name, SI_SUB_CONFIGURE, SI_ORDER_SECOND,   \
+SYSINIT(taskqueue_##name, SI_SUB_TASKQ, SI_ORDER_SECOND,   \
taskqueue_define_##name, NULL); \
\
 struct __hack
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r337041 - in stable/10/sys: amd64/include i386/include

2018-08-01 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Aug  1 12:49:51 2018
New Revision: 337041
URL: https://svnweb.freebsd.org/changeset/base/337041

Log:
  MFC r311169, r312975, r313080, r315718 and r316031:
  
  Add support for atomic_(f)cmpset to x86.

Modified:
  stable/10/sys/amd64/include/atomic.h
  stable/10/sys/i386/include/atomic.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/amd64/include/atomic.h
==
--- stable/10/sys/amd64/include/atomic.hWed Aug  1 12:18:52 2018
(r337040)
+++ stable/10/sys/amd64/include/atomic.hWed Aug  1 12:49:51 2018
(r337041)
@@ -78,8 +78,15 @@
 void atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v); \
 void atomic_##NAME##_barr_##TYPE(volatile u_##TYPE *p, u_##TYPE v)
 
+intatomic_cmpset_char(volatile u_char *dst, u_char expect, u_char src);
+intatomic_cmpset_short(volatile u_short *dst, u_short expect, u_short src);
 intatomic_cmpset_int(volatile u_int *dst, u_int expect, u_int src);
 intatomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src);
+intatomic_fcmpset_char(volatile u_char *dst, u_char *expect, u_char src);
+intatomic_fcmpset_short(volatile u_short *dst, u_short *expect,
+   u_short src);
+intatomic_fcmpset_int(volatile u_int *dst, u_int *expect, u_int src);
+intatomic_fcmpset_long(volatile u_long *dst, u_long *expect, u_long src);
 u_int  atomic_fetchadd_int(volatile u_int *p, u_int v);
 u_long atomic_fetchadd_long(volatile u_long *p, u_long v);
 intatomic_testandset_int(volatile u_int *p, u_int v);
@@ -130,49 +137,62 @@ atomic_##NAME##_barr_##TYPE(volatile u_##TYPE *p, u_##
 struct __hack
 
 /*
- * Atomic compare and set, used by the mutex functions
+ * Atomic compare and set, used by the mutex functions.
  *
- * if (*dst == expect) *dst = src (all 32 bit words)
+ * cmpset:
+ * if (*dst == expect)
+ * *dst = src
  *
- * Returns 0 on failure, non-zero on success
+ * fcmpset:
+ * if (*dst == *expect)
+ * *dst = src
+ * else
+ * *expect = *dst
+ *
+ * Returns 0 on failure, non-zero on success.
  */
-
-static __inline int
-atomic_cmpset_int(volatile u_int *dst, u_int expect, u_int src)
-{
-   u_char res;
-
-   __asm __volatile(
-   "   " MPLOCKED ""
-   "   cmpxchgl %3,%1 ;"
-   "   sete%0 ;"
-   "# atomic_cmpset_int"
-   : "=q" (res),   /* 0 */
- "+m" (*dst),  /* 1 */
- "+a" (expect) /* 2 */
-   : "r" (src) /* 3 */
-   : "memory", "cc");
-   return (res);
+#defineATOMIC_CMPSET(TYPE) \
+static __inline int\
+atomic_cmpset_##TYPE(volatile u_##TYPE *dst, u_##TYPE expect, u_##TYPE src) \
+{  \
+   u_char res; \
+   \
+   __asm __volatile(   \
+   "   " MPLOCKED ""   \
+   "   cmpxchg %3,%1 ; "   \
+   "   sete%0 ;"   \
+   "# atomic_cmpset_" #TYPE "  "   \
+   : "=q" (res),   /* 0 */ \
+ "+m" (*dst),  /* 1 */ \
+ "+a" (expect) /* 2 */ \
+   : "r" (src) /* 3 */ \
+   : "memory", "cc");  \
+   return (res);   \
+}  \
+   \
+static __inline int\
+atomic_fcmpset_##TYPE(volatile u_##TYPE *dst, u_##TYPE *expect, u_##TYPE src) \
+{  \
+   u_char res; \
+   \
+   __asm __volatile(   \
+   "   " MPLOCKED ""   \
+   "   cmpxchg %3,%1 ; "   \
+   "   sete%0 ;"   \
+   "# atomic_fcmpset_" #TYPE " "   \
+   : "=q" (res),   /* 0 */ \
+ "+m" (*dst),  /* 1 */ \
+ "+a" (*expect)/* 2 */ \
+   : "r" (src) /* 3 */ \
+   : "memory", "cc");  \
+   return (res);   \
 }
 
-static __inline int
-atomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src)
-{
-   u_char res;
+ATOMIC_CMPSET(char);
+ATOMIC_CMPSET(short);

svn commit: r337036 - in stable/10/sys: arm/arm sys

2018-08-01 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Aug  1 11:08:52 2018
New Revision: 337036
URL: https://svnweb.freebsd.org/changeset/base/337036

Log:
  MFC r321686 and r330361:
  Add inline functions to convert between sbintime_t and decimal time units.
  Use them in some existing code that is vulnerable to roundoff errors.

Modified:
  stable/10/sys/arm/arm/mpcore_timer.c
  stable/10/sys/sys/time.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/arm/arm/mpcore_timer.c
==
--- stable/10/sys/arm/arm/mpcore_timer.cWed Aug  1 10:35:49 2018
(r337035)
+++ stable/10/sys/arm/arm/mpcore_timer.cWed Aug  1 11:08:52 2018
(r337036)
@@ -349,7 +349,7 @@ attach_et(struct arm_tmr_softc *sc)
sc->et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_ONESHOT | 
ET_FLAGS_PERCPU;
sc->et.et_quality = 1000;
sc->et.et_frequency = sc->clkfreq;
-   sc->et.et_min_period = 20 * SBT_1NS;
+   sc->et.et_min_period = nstosbt(20);
sc->et.et_max_period =  2 * SBT_1S;
sc->et.et_start = arm_tmr_start;
sc->et.et_stop = arm_tmr_stop;

Modified: stable/10/sys/sys/time.h
==
--- stable/10/sys/sys/time.hWed Aug  1 10:35:49 2018(r337035)
+++ stable/10/sys/sys/time.hWed Aug  1 11:08:52 2018(r337036)
@@ -128,7 +128,7 @@ bintime_shift(struct bintime *_bt, int _exp)
 #defineSBT_1M  (SBT_1S * 60)
 #defineSBT_1MS (SBT_1S / 1000)
 #defineSBT_1US (SBT_1S / 100)
-#defineSBT_1NS (SBT_1S / 10)
+#defineSBT_1NS (SBT_1S / 10) /* beware rounding, see nstosbt() 
*/
 #defineSBT_MAX 0x7fffLL
 
 static __inline int
@@ -155,6 +155,53 @@ sbttobt(sbintime_t _sbt)
return (_bt);
 }
 
+/*
+ * Decimal<->sbt conversions.  Multiplying or dividing by SBT_1NS results in
+ * large roundoff errors which sbttons() and nstosbt() avoid.  Millisecond and
+ * microsecond functions are also provided for completeness.
+ */
+static __inline int64_t
+sbttons(sbintime_t _sbt)
+{
+
+   return ((10 * _sbt) >> 32);
+}
+
+static __inline sbintime_t
+nstosbt(int64_t _ns)
+{
+
+   return ((_ns * (((uint64_t)1 << 63) / 5)) >> 32);
+}
+
+static __inline int64_t
+sbttous(sbintime_t _sbt)
+{
+
+   return ((100 * _sbt) >> 32);
+}
+
+static __inline sbintime_t
+ustosbt(int64_t _us)
+{
+
+   return ((_us * (((uint64_t)1 << 63) / 50)) >> 32);
+}
+
+static __inline int64_t
+sbttoms(sbintime_t _sbt)
+{
+
+   return ((1000 * _sbt) >> 32);
+}
+
+static __inline sbintime_t
+mstosbt(int64_t _ms)
+{
+
+   return ((_ms * (((uint64_t)1 << 63) / 500)) >> 32);
+}
+
 /*-
  * Background information:
  *
@@ -210,7 +257,7 @@ sbttots(sbintime_t _sbt)
struct timespec _ts;
 
_ts.tv_sec = _sbt >> 32;
-   _ts.tv_nsec = ((uint64_t)10 * (uint32_t)_sbt) >> 32;
+   _ts.tv_nsec = sbttons((uint32_t)_sbt);
return (_ts);
 }
 
@@ -218,8 +265,7 @@ static __inline sbintime_t
 tstosbt(struct timespec _ts)
 {
 
-   return (((sbintime_t)_ts.tv_sec << 32) +
-   (_ts.tv_nsec * (((uint64_t)1 << 63) / 5) >> 32));
+   return (((sbintime_t)_ts.tv_sec << 32) + nstosbt(_ts.tv_nsec));
 }
 
 static __inline struct timeval
@@ -228,7 +274,7 @@ sbttotv(sbintime_t _sbt)
struct timeval _tv;
 
_tv.tv_sec = _sbt >> 32;
-   _tv.tv_usec = ((uint64_t)100 * (uint32_t)_sbt) >> 32;
+   _tv.tv_usec = sbttous((uint32_t)_sbt);
return (_tv);
 }
 
@@ -236,8 +282,7 @@ static __inline sbintime_t
 tvtosbt(struct timeval _tv)
 {
 
-   return (((sbintime_t)_tv.tv_sec << 32) +
-   (_tv.tv_usec * (((uint64_t)1 << 63) / 50) >> 32));
+   return (((sbintime_t)_tv.tv_sec << 32) + ustosbt(_tv.tv_usec));
 }
 #endif /* __BSD_VISIBLE */
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r337034 - in stable/10: share/man/man9 sys/kern sys/sys

2018-08-01 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Aug  1 10:34:53 2018
New Revision: 337034
URL: https://svnweb.freebsd.org/changeset/base/337034

Log:
  MFC r330349 and r330362:
  
  Allow pause_sbt() to catch signals during sleep by passing C_CATCH flag.
  Define pause_sig() function macro helper similarly to other kernel functions
  which catch signals. Update outdated function description.
  
  Document pause_sig(9) and update prototypes for existing pause(9) and
  pause_sbt(9) functions.
  
  Discussed with:   kib@
  Suggested by: cem@
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/share/man/man9/Makefile
  stable/10/share/man/man9/sleep.9
  stable/10/sys/kern/kern_synch.c
  stable/10/sys/sys/callout.h
  stable/10/sys/sys/systm.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/share/man/man9/Makefile
==
--- stable/10/share/man/man9/Makefile   Wed Aug  1 08:24:34 2018
(r337033)
+++ stable/10/share/man/man9/Makefile   Wed Aug  1 10:34:53 2018
(r337034)
@@ -1249,6 +1249,7 @@ MLINKS+=sleep.9 msleep.9 \
sleep.9 msleep_spin.9 \
sleep.9 msleep_spin_sbt.9 \
sleep.9 pause.9 \
+   sleep.9 pause_sig.9 \
sleep.9 pause_sbt.9 \
sleep.9 tsleep.9 \
sleep.9 tsleep_sbt.9 \

Modified: stable/10/share/man/man9/sleep.9
==
--- stable/10/share/man/man9/sleep.9Wed Aug  1 08:24:34 2018
(r337033)
+++ stable/10/share/man/man9/sleep.9Wed Aug  1 10:34:53 2018
(r337034)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 19, 2013
+.Dd August 1, 2018
 .Dt SLEEP 9
 .Os
 .Sh NAME
@@ -34,6 +34,7 @@
 .Nm msleep_spin ,
 .Nm msleep_spin_sbt ,
 .Nm pause ,
+.Nm pause_sig ,
 .Nm pause_sbt ,
 .Nm tsleep ,
 .Nm tsleep_sbt ,
@@ -53,9 +54,11 @@
 .Ft int
 .Fn msleep_spin_sbt "void *chan" "struct mtx *mtx" "const char *wmesg" \
 "sbintime_t sbt" "sbintime_t pr" "int flags"
-.Ft void
+.Ft int
 .Fn pause "const char *wmesg" "int timo"
-.Ft void
+.Ft int
+.Fn pause_sig "const char *wmesg" "int timo"
+.Ft int
 .Fn pause_sbt "const char *wmesg" "sbintime_t sbt" "sbintime_t pr" \
  "int flags"
 .Ft int
@@ -73,6 +76,8 @@ The functions
 .Fn msleep ,
 .Fn msleep_spin ,
 .Fn pause ,
+.Fn pause_sig ,
+.Fn pause_sbt ,
 .Fn wakeup ,
 and
 .Fn wakeup_one
@@ -82,8 +87,10 @@ external event, it is put to sleep by
 .Fn tsleep ,
 .Fn msleep ,
 .Fn msleep_spin ,
+.Fn pause ,
+.Fn pause_sig ,
 or
-.Fn pause .
+.Fn pause_sbt .
 Threads may also wait using one of the locking primitive sleep routines
 .Xr mtx_sleep 9 ,
 .Xr rw_sleep 9 ,
@@ -261,6 +268,11 @@ The thread can not be awakened early by signals or cal
 .Fn wakeup
 or
 .Fn wakeup_one .
+The
+.Fn pause_sig
+function is a variant of
+.Fn pause
+which can be awakened early by signals.
 .Pp
 The
 .Fn wakeup_one
@@ -380,6 +392,10 @@ The
 .Fn pause
 function appeared in
 .Fx 7.0 .
+The
+.Fn pause_sig
+function appeared in
+.Fx 12.0 .
 .Sh AUTHORS
 .An -nosplit
 This manual page was written by

Modified: stable/10/sys/kern/kern_synch.c
==
--- stable/10/sys/kern/kern_synch.c Wed Aug  1 08:24:34 2018
(r337033)
+++ stable/10/sys/kern/kern_synch.c Wed Aug  1 10:34:53 2018
(r337034)
@@ -334,16 +334,16 @@ msleep_spin_sbt(void *ident, struct mtx *mtx, const ch
 }
 
 /*
- * pause() delays the calling thread by the given number of system ticks.
- * During cold bootup, pause() uses the DELAY() function instead of
- * the tsleep() function to do the waiting. The "timo" argument must be
- * greater than or equal to zero. A "timo" value of zero is equivalent
- * to a "timo" value of one.
+ * pause_sbt() delays the calling thread by the given signed binary
+ * time. During cold bootup, pause_sbt() uses the DELAY() function
+ * instead of the _sleep() function to do the waiting. The "sbt"
+ * argument must be greater than or equal to zero. A "sbt" value of
+ * zero is equivalent to a "sbt" value of one tick.
  */
 int
 pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags)
 {
-   KASSERT(sbt >= 0, ("pause: timeout must be >= 0"));
+   KASSERT(sbt >= 0, ("pause_sbt: timeout must be >= 0"));
 
/* silently convert invalid timeouts */
if (sbt == 0)
@@ -364,7 +364,8 @@ pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_
DELAY(sbt);
return (0);
}
-   return (_sleep(_wchan[curcpu], NULL, 0, wmesg, sbt, pr, flags));
+   return (_sleep(_wchan[curcpu], NULL,
+   (flags & C_CATCH) ? PCATCH : 0, wmesg, sbt, pr, flags));
 }
 
 /*

Modified: stable/10/sys/sys/callout.h
==
--- stable/10/sys/sys/callout.h Wed Aug  1 08:24:34 2018(r337033)
+++ stable/10/sys/sys/callout.h Wed Aug  1 10:34:53 2018   

svn commit: r337035 - stable/10/sys/kern

2018-08-01 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Aug  1 10:35:49 2018
New Revision: 337035
URL: https://svnweb.freebsd.org/changeset/base/337035

Log:
  MFC r330344:
  Correct the return code from pause() during cold startup from zero to
  EWOULDBLOCK. This also matches the description in pause(9).
  
  Discussed with:   kib@
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/kern/kern_synch.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/kern_synch.c
==
--- stable/10/sys/kern/kern_synch.c Wed Aug  1 10:34:53 2018
(r337034)
+++ stable/10/sys/kern/kern_synch.c Wed Aug  1 10:35:49 2018
(r337035)
@@ -362,7 +362,7 @@ pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_
sbt = (sbt + SBT_1US - 1) / SBT_1US;
if (sbt > 0)
DELAY(sbt);
-   return (0);
+   return (EWOULDBLOCK);
}
return (_sleep(_wchan[curcpu], NULL,
(flags & C_CATCH) ? PCATCH : 0, wmesg, sbt, pr, flags));
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r336890 - stable/10/sys/dev/sound/pcm

2018-07-30 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jul 30 09:28:00 2018
New Revision: 336890
URL: https://svnweb.freebsd.org/changeset/base/336890

Log:
  MFC r336632:
  Update modify counter when setting a mixer control.
  
  PR:   229969

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

Modified: stable/10/sys/dev/sound/pcm/mixer.c
==
--- stable/10/sys/dev/sound/pcm/mixer.c Mon Jul 30 09:25:56 2018
(r336889)
+++ stable/10/sys/dev/sound/pcm/mixer.c Mon Jul 30 09:28:00 2018
(r336890)
@@ -323,6 +323,7 @@ mixer_set(struct snd_mixer *m, u_int dev, u_int lev)
MIXER_SET_LOCK(m, dropmtx);
 
m->level[dev] = l | (r << 8);
+   m->modify_counter++;
 
return 0;
 }
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r336887 - stable/10/sys/dev/usb

2018-07-30 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jul 30 09:21:19 2018
New Revision: 336887
URL: https://svnweb.freebsd.org/changeset/base/336887

Log:
  MFC r335700:
  Improve the kernel's USB descriptor reading function.
  Some USB devices does not allow a partial descriptor readout.
  
  Found by: bz@
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/usb_request.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/usb_request.c
==
--- stable/10/sys/dev/usb/usb_request.c Mon Jul 30 09:20:17 2018
(r336886)
+++ stable/10/sys/dev/usb/usb_request.c Mon Jul 30 09:21:19 2018
(r336887)
@@ -988,7 +988,7 @@ usbd_req_get_desc(struct usb_device *udev,
 uint8_t retries)
 {
struct usb_device_request req;
-   uint8_t *buf;
+   uint8_t *buf = desc;
usb_error_t err;
 
DPRINTFN(4, "id=%d, type=%d, index=%d, max_len=%d\n",
@@ -1010,6 +1010,32 @@ usbd_req_get_desc(struct usb_device *udev,
err = usbd_do_request_flags(udev, mtx, ,
desc, 0, NULL, 500 /* ms */);
 
+   if (err != 0 && err != USB_ERR_TIMEOUT &&
+   min_len != max_len) {
+   /* clear descriptor data */
+   memset(desc, 0, max_len);
+
+   /* try to read full descriptor length */
+   USETW(req.wLength, max_len);
+
+   err = usbd_do_request_flags(udev, mtx, ,
+   desc, USB_SHORT_XFER_OK, NULL, 500 /* ms */);
+
+   if (err == 0) {
+   /* verify length */
+   if (buf[0] > max_len)
+   buf[0] = max_len;
+   else if (buf[0] < 2)
+   err = USB_ERR_INVAL;
+
+   min_len = buf[0];
+
+   /* enforce descriptor type */
+   buf[1] = type;
+   goto done;
+   }
+   }
+
if (err) {
if (!retries) {
goto done;
@@ -1020,7 +1046,6 @@ usbd_req_get_desc(struct usb_device *udev,
 
continue;
}
-   buf = desc;
 
if (min_len == max_len) {
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r336884 - stable/10/lib/libusb

2018-07-30 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jul 30 09:16:47 2018
New Revision: 336884
URL: https://svnweb.freebsd.org/changeset/base/336884

Log:
  MFC r335669:
  Improve the userspace USB string reading function in LibUSB.
  Some USB devices does not allow a partial descriptor readout.
  
  Found by: bz @
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/lib/libusb/libusb20.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libusb/libusb20.c
==
--- stable/10/lib/libusb/libusb20.c Mon Jul 30 09:15:09 2018
(r336883)
+++ stable/10/lib/libusb/libusb20.c Mon Jul 30 09:16:47 2018
(r336884)
@@ -794,6 +794,7 @@ libusb20_dev_req_string_sync(struct libusb20_device *p
 {
struct LIBUSB20_CONTROL_SETUP_DECODED req;
int error;
+   int flags;
 
/* make sure memory is initialised */
memset(ptr, 0, len);
@@ -820,22 +821,24 @@ libusb20_dev_req_string_sync(struct libusb20_device *p
error = libusb20_dev_request_sync(pdev, ,
ptr, NULL, 1000, LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK);
if (error) {
-   return (error);
+   /* try to request full string */
+   req.wLength = 255;
+   flags = 0;
+   } else {
+   /* extract length and request full string */
+   req.wLength = *(uint8_t *)ptr;
+   flags = LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK;
}
-   req.wLength = *(uint8_t *)ptr;  /* bytes */
if (req.wLength > len) {
/* partial string read */
req.wLength = len;
}
-   error = libusb20_dev_request_sync(pdev, ,
-   ptr, NULL, 1000, LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK);
-
-   if (error) {
+   error = libusb20_dev_request_sync(pdev, , ptr, NULL, 1000, flags);
+   if (error)
return (error);
-   }
-   if (((uint8_t *)ptr)[1] != LIBUSB20_DT_STRING) {
+
+   if (((uint8_t *)ptr)[1] != LIBUSB20_DT_STRING)
return (LIBUSB20_ERROR_OTHER);
-   }
return (0); /* success */
 }
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r334758 - stable/10/sys/dev/usb/net

2018-06-07 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Jun  7 07:33:46 2018
New Revision: 334758
URL: https://svnweb.freebsd.org/changeset/base/334758

Log:
  MFC r334158:
  Add function to wait for USB ethernet attach to complete.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/net/usb_ethernet.c
  stable/10/sys/dev/usb/net/usb_ethernet.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/net/usb_ethernet.c
==
--- stable/10/sys/dev/usb/net/usb_ethernet.cThu Jun  7 07:32:51 2018
(r334757)
+++ stable/10/sys/dev/usb/net/usb_ethernet.cThu Jun  7 07:33:46 2018
(r334758)
@@ -187,6 +187,17 @@ error:
return (error);
 }
 
+void
+uether_ifattach_wait(struct usb_ether *ue)
+{
+
+   UE_LOCK(ue);
+   usb_proc_mwait(>ue_tq,
+   >ue_sync_task[0].hdr,
+   >ue_sync_task[1].hdr);
+   UE_UNLOCK(ue);
+}
+
 static void
 ue_attach_post_task(struct usb_proc_msg *_task)
 {

Modified: stable/10/sys/dev/usb/net/usb_ethernet.h
==
--- stable/10/sys/dev/usb/net/usb_ethernet.hThu Jun  7 07:32:51 2018
(r334757)
+++ stable/10/sys/dev/usb/net/usb_ethernet.hThu Jun  7 07:33:46 2018
(r334758)
@@ -111,6 +111,7 @@ struct ifnet*uether_getifp(struct usb_ether *);
 struct mii_data *uether_getmii(struct usb_ether *);
 void   *uether_getsc(struct usb_ether *);
 intuether_ifattach(struct usb_ether *);
+void   uether_ifattach_wait(struct usb_ether *);
 void   uether_ifdetach(struct usb_ether *);
 intuether_ifmedia_upd(struct ifnet *);
 void   uether_init(void *);
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r333203 - stable/10/sys/dev/usb/controller

2018-05-03 Thread Hans Petter Selasky
Author: hselasky
Date: Thu May  3 07:38:45 2018
New Revision: 333203
URL: https://svnweb.freebsd.org/changeset/base/333203

Log:
  MFC r333100:
  Improve fix in r304629 by allowing configuration of the behaviour
  through a SYSCTL instead of a compile time define.
  
  Add quirk by default for all LynxPoint XHCI controllers.
  
  PR:   227602
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/controller/xhci.c
  stable/10/sys/dev/usb/controller/xhci.h
  stable/10/sys/dev/usb/controller/xhci_pci.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/controller/xhci.c
==
--- stable/10/sys/dev/usb/controller/xhci.c Thu May  3 07:37:49 2018
(r333202)
+++ stable/10/sys/dev/usb/controller/xhci.c Thu May  3 07:38:45 2018
(r333203)
@@ -99,6 +99,7 @@ static int xhcidebug;
 static int xhciroute;
 static int xhcipolling;
 static int xhcidma32;
+static int xhcictlstep;
 
 SYSCTL_INT(_hw_usb_xhci, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN,
 , 0, "Debug level");
@@ -112,9 +113,13 @@ TUNABLE_INT("hw.usb.xhci.use_polling", );
 SYSCTL_INT(_hw_usb_xhci, OID_AUTO, dma32, CTLFLAG_RWTUN,
 , 0, "Set to only use 32-bit DMA for the XHCI controller");
 TUNABLE_INT("hw.usb.xhci.dma32", );
+SYSCTL_INT(_hw_usb_xhci, OID_AUTO, ctlstep, CTLFLAG_RWTUN,
+, 0, "Set to enable control endpoint status stage stepping");
+TUNABLE_INT("hw.usb.xhci.ctlstep", );
 #else
 #definexhciroute 0
 #definexhcidma32 0
+#definexhcictlstep 0
 #endif
 
 #defineXHCI_INTR_ENDPT 1
@@ -2244,11 +2249,17 @@ xhci_setup_generic_chain(struct usb_xfer *xfer)
 * Send a DATA1 message and invert the current
 * endpoint direction.
 */
-#ifdef XHCI_STEP_STATUS_STAGE
-   temp.step_td = (xfer->nframes != 0);
-#else
-   temp.step_td = 0;
-#endif
+   if (xhcictlstep || temp.sc->sc_ctlstep) {
+   /*
+* Some XHCI controllers will not delay the
+* status stage until the next SOF. Force this
+* behaviour to avoid failed control
+* transfers.
+*/
+   temp.step_td = (xfer->nframes != 0);
+   } else {
+   temp.step_td = 0;
+   }
temp.direction = UE_GET_DIR(xfer->endpointno) ^ UE_DIR_IN;
temp.len = 0;
temp.pc = NULL;

Modified: stable/10/sys/dev/usb/controller/xhci.h
==
--- stable/10/sys/dev/usb/controller/xhci.h Thu May  3 07:37:49 2018
(r333202)
+++ stable/10/sys/dev/usb/controller/xhci.h Thu May  3 07:38:45 2018
(r333203)
@@ -506,6 +506,8 @@ struct xhci_softc {
uint8_t sc_noport;
/* root HUB device configuration */
uint8_t sc_conf;
+   /* step status stage of all control transfers */
+   uint8_t sc_ctlstep;
/* root HUB port event bitmap, max 256 ports */
uint8_t sc_hub_idata[32];
 

Modified: stable/10/sys/dev/usb/controller/xhci_pci.c
==
--- stable/10/sys/dev/usb/controller/xhci_pci.c Thu May  3 07:37:49 2018
(r333202)
+++ stable/10/sys/dev/usb/controller/xhci_pci.c Thu May  3 07:38:45 2018
(r333203)
@@ -240,6 +240,7 @@ xhci_pci_attach(device_t self)
 */
sc->sc_port_route = _pci_port_route;
sc->sc_imod_default = XHCI_IMOD_DEFAULT_LP;
+   sc->sc_ctlstep = 1;
break;
}
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r332928 - stable/10/sys/ofed/include/linux

2018-04-24 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Apr 24 10:32:25 2018
New Revision: 332928
URL: https://svnweb.freebsd.org/changeset/base/332928

Log:
  MFC r329372 and r329464:
  Implement enable_irq() and disable_irq() in the LinuxKPI and add checks for
  valid IRQ tag before setting up or tearing down an interrupt handler in the
  LinuxKPI. This is needed when the interrupt handler is disabled
  before freeing the interrupt.
  
  Submitted by: Johannes Lundberg 
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/ofed/include/linux/interrupt.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/ofed/include/linux/interrupt.h
==
--- stable/10/sys/ofed/include/linux/interrupt.hTue Apr 24 10:11:01 
2018(r332927)
+++ stable/10/sys/ofed/include/linux/interrupt.hTue Apr 24 10:32:25 
2018(r332928)
@@ -118,6 +118,39 @@ request_irq(unsigned int irq, irq_handler_t handler, u
 }
 
 static inline int
+enable_irq(unsigned int irq)
+{
+   struct irq_ent *irqe;
+   struct device *dev;
+
+   dev = _pci_find_irq_dev(irq);
+   if (dev == NULL)
+   return -EINVAL;
+   irqe = _irq_ent(dev, irq);
+   if (irqe == NULL || irqe->tag != NULL)
+   return -EINVAL;
+   return -bus_setup_intr(dev->bsddev, irqe->res, INTR_TYPE_NET | 
INTR_MPSAFE,
+   NULL, _irq_handler, irqe, >tag);
+}
+
+static inline void
+disable_irq(unsigned int irq)
+{
+   struct irq_ent *irqe;
+   struct device *dev;
+
+   dev = _pci_find_irq_dev(irq);
+   if (dev == NULL)
+   return;
+   irqe = _irq_ent(dev, irq);
+   if (irqe == NULL)
+   return;
+   if (irqe->tag != NULL)
+   bus_teardown_intr(dev->bsddev, irqe->res, irqe->tag);
+   irqe->tag = NULL;
+}
+
+static inline int
 bind_irq_to_cpu(unsigned int irq, int cpu_id)
 {
struct irq_ent *irqe;
@@ -148,7 +181,8 @@ free_irq(unsigned int irq, void *device)
irqe = _irq_ent(dev, irq);
if (irqe == NULL)
return;
-   bus_teardown_intr(dev->bsddev, irqe->res, irqe->tag);
+   if (irqe->tag != NULL)
+   bus_teardown_intr(dev->bsddev, irqe->res, irqe->tag);
bus_release_resource(dev->bsddev, SYS_RES_IRQ, rid, irqe->res);
list_del(>links);
kfree(irqe);
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r332922 - stable/10/sys/ofed/include/linux

2018-04-24 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Apr 24 10:05:23 2018
New Revision: 332922
URL: https://svnweb.freebsd.org/changeset/base/332922

Log:
  MFC r331355:
  Clear old MSIX IRQ numbers in the LinuxKPI.
  
  When disabling the MSIX IRQ vectors for a PCI device through the
  LinuxKPI, make sure any old MSIX IRQ numbers are no longer visible to
  the linux_pci_find_irq_dev() function else IRQs can be requested from
  the wrong PCI device.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/ofed/include/linux/pci.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/ofed/include/linux/pci.h
==
--- stable/10/sys/ofed/include/linux/pci.h  Tue Apr 24 10:03:16 2018
(r332921)
+++ stable/10/sys/ofed/include/linux/pci.h  Tue Apr 24 10:05:23 2018
(r332922)
@@ -349,6 +349,15 @@ pci_disable_msix(struct pci_dev *pdev)
 {
 
pci_release_msi(pdev->dev.bsddev);
+
+   /*
+* The MSIX IRQ numbers associated with this PCI device are no
+* longer valid and might be re-assigned. Make sure
+* linux_pci_find_irq_dev() does no longer see them by
+* resetting their references to zero:
+*/
+   pdev->dev.msix = 0;
+   pdev->dev.msix_max = 0;
 }
 
 #definePCI_CAP_ID_EXP  PCIY_EXPRESS
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


  1   2   3   4   >