Re: axen Ethernet device errors on both USB3.0 and USB2.0 ports

2018-07-29 Thread sc . dying

Hi,

On 2018/07/27 09:14, Denis wrote:

Every time (after 2-3 minutes of work) ASIX Electronics USB-Ethernet
device reports:

axen0: usb errors on rx: IOERROR
axen0: usb errors on rx: IOERROR
axen0: usb errors on tx: IOERROR
axen0: watchdog timeout
axen0: usb errors on tx: IOERROR

The device hangs and must be reattached to have it working again for 2-3
minutes.


Do you want to try this patch?

-
 - header: fix comments
 - header: fix unused L3 type mask definition
 - rxeof: Avoid allocating mbuf if checksum errors are detected.
 - rxeof: Avoid loop to extract packets if pkt_count is 0.
 - rxeof: Add more sanity checks.
 - rxeof: Increament if_ierror in some error paths.
 - qctrl: Apply queuing control parameters from FreeBSD axge(4).
 - qctrl: Set qctrl in miireg_statchg dynamically, not statically.
 - Use DMA buffer aligned at 64KB boundary to avoid xhci bug.


--- sys/dev/usb/if_axenreg.hFri Sep 16 22:17:07 2016
+++ sys/dev/usb/if_axenreg.hMon Jun 19 10:54:28 2017
@@ -26,8 +26,8 @@
  * || ++-L3_type (1:ipv4, 0/2:ipv6)
  *pkt_len(13)  || ||+ ++-L4_type(0: icmp, 1: UDP, 4: TCP)
  * |765|43210 76543210|7654 3210 7654 3210|
- *  ||+-crc_err  |+-L4_err |+-L4_CSUM_ERR
- *  |+-mii_err   +--L3_err +--L3_CSUM_ERR
+ *  ||+-crc_err   |+-L4_err |+-L4_CSUM_ERR
+ *  |+-mii_err+--L3_err +--L3_CSUM_ERR
  *  +-drop_err
  *
  * ex) pkt_hdr 0x00680820
@@ -70,7 +70,7 @@
 #define   AXEN_RXHDR_L4_TYPE_TCP   0x4
 
 /* L3 packet type (2bit) */

-#define AXEN_RXHDR_L3_TYPE_MASK0x0600
+#define AXEN_RXHDR_L3_TYPE_MASK0x0060
 #define AXEN_RXHDR_L3_TYPE_OFFSET  5
 #define   AXEN_RXHDR_L3_TYPE_UNDEF 0x0
 #define   AXEN_RXHDR_L3_TYPE_IPV4  0x1
--- sys/dev/usb/if_axen.c.orig  Tue Jun 12 15:36:59 2018
+++ sys/dev/usb/if_axen.c   Sun Jul 29 01:53:43 2018
@@ -53,6 +53,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -121,6 +122,13 @@ void	axen_unlock_mii(struct axen_softc *sc);
 
 void	axen_ax88179_init(struct axen_softc *);
 
+struct axen_qctrl axen_bulk_size[] = {

+   { 7, 0x4f, 0x00, 0x12, 0xff },
+   { 7, 0x20, 0x03, 0x16, 0xff },
+   { 7, 0xae, 0x07, 0x18, 0xff },
+   { 7, 0xcc, 0x4c, 0x18, 0x08 }
+};
+
 /* Get exclusive access to the MII registers */
 void
 axen_lock_mii(struct axen_softc *sc)
@@ -238,6 +246,8 @@ axen_miibus_statchg(struct device *dev)
int err;
uint16_tval;
uWord   wval;
+   uint8_t linkstat = 0;
+   int qctrl;
 
 	ifp = GET_IFP(sc);

if (mii == NULL || ifp == NULL ||
@@ -265,27 +275,49 @@ axen_miibus_statchg(struct device *dev)
return;
 
 	val = 0;

-   if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0)
+   if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) {
val |= AXEN_MEDIUM_FDX;
+   if ((IFM_OPTIONS(mii->mii_media_active) & IFM_ETH_TXPAUSE) != 0)
+   val |= AXEN_MEDIUM_TXFLOW_CTRL_EN;
+   if ((IFM_OPTIONS(mii->mii_media_active) & IFM_ETH_RXPAUSE) != 0)
+   val |= AXEN_MEDIUM_RXFLOW_CTRL_EN;
+   }
 
-	val |= (AXEN_MEDIUM_RECV_EN | AXEN_MEDIUM_ALWAYS_ONE);

-   val |= (AXEN_MEDIUM_RXFLOW_CTRL_EN | AXEN_MEDIUM_TXFLOW_CTRL_EN);
+   val |= AXEN_MEDIUM_RECV_EN;
 
+	/* bulkin queue setting */

+   axen_lock_mii(sc);
+   axen_cmd(sc, AXEN_CMD_MAC_READ, 1, AXEN_USB_UPLINK, );
+   axen_unlock_mii(sc);
+
switch (IFM_SUBTYPE(mii->mii_media_active)) {
case IFM_1000_T:
val |= AXEN_MEDIUM_GIGA | AXEN_MEDIUM_EN_125MHZ;
+   if (linkstat & AXEN_USB_SS)
+   qctrl = 0;
+   else if (linkstat & AXEN_USB_HS)
+   qctrl = 1;
+   else
+   qctrl = 3;
break;
case IFM_100_TX:
val |= AXEN_MEDIUM_PS;
+   if (linkstat & (AXEN_USB_SS | AXEN_USB_HS))
+   qctrl = 2;
+   else
+   qctrl = 3;
break;
case IFM_10_T:
-   /* doesn't need to be handled */
+   default:
+   qctrl = 3;
break;
}
 
 	DPRINTF(("axen_miibus_statchg: val=0x%x\n", val));

USETW(wval, val);
axen_lock_mii(sc);
+   axen_cmd(sc, AXEN_CMD_MAC_SET_RXSR, 5, AXEN_RX_BULKIN_QCTRL,
+   _bulk_size[qctrl]);
err = axen_cmd(sc, AXEN_CMD_MAC_WRITE2, 2, AXEN_MEDIUM_STATUS, );
axen_unlock_mii(sc);
if (err) {
@@ -408,7 +440,6 @@ axen_ax88179_init(struct axen_softc *sc)
uWord   wval;
uByte   val;
u_int16_t   ctl, temp;
-   struct axen_qctrl qctrl;
 
 	axen_lock_mii(sc);
 
@@ -471,27 +502,12 @@ axen_ax88179_init(struct axen_softc *sc)


Re: slowcgi -u user option does not change socket ownership

2018-07-29 Thread Florian Obser
On Thu, Jul 26, 2018 at 05:31:39PM -0500, andrew.daugher...@gmail.com wrote:
> >Synopsis:slowcgi -u user option does not change socket ownership
> >Category:user
> >Environment:
>   System  : OpenBSD 6.3
>   Details : OpenBSD 6.3 (GENERIC.MP) #4: Sun Jun 17 11:22:20 CEST 2018
>
> r...@syspatch-63-amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> 
>   Architecture: OpenBSD.amd64
>   Machine : amd64
> >Description:
> When using the '-u user' option to run slowcgi under a different username, the
> socket is still owned by the default www user.  This prevents the specified
> user from interacting with the slowcgi socket (and maybe even slowcgi itself
> after it drops privileges?).

It is behaving as intended. The slowcgi.sock is for the webserver to
interact with. The specified user is not supposed to interact with the
socket. CGI scripts are executed as this user.

slowcgi itself can use the socket just fine since it already has a
filedescriptor open.

What problem are you trying to solve?

> 
> >How-To-Repeat:
> $ doas slowcgi -u andrew -s /home/andrew/slowcgi.sock
> $ ls -l /home/andrew/slowcgi.sock
> srw-rw  1 www  www  0 Jul 26 16:07 /home/andrew/slowcgi.sock
> 
> >Fix:
> Moving the slowcgi_listen() call to after the pw struct is set to slowcgi_user
> fixes it:
> 
> --- usr.sbin/slowcgi/slowcgi.c  2018-07-25 20:46:56.358667880 -0500
> +++ usr.sbin/slowcgi/slowcgi.c  2018-07-26 15:14:52.840052633 -0500
> @@ -330,13 +330,13 @@
>   if (pw == NULL)
>   lerrx(1, "no %s user", SLOWCGI_USER);
> 
> - fd = slowcgi_listen(fcgi_socket, pw);
> -
>   lwarnx("slowcgi_user: %s", slowcgi_user);
>   pw = getpwnam(slowcgi_user);
>   if (pw == NULL)
>   lerrx(1, "no %s user", slowcgi_user);
> 
> + fd = slowcgi_listen(fcgi_socket, pw);
> +
>   if (chrootpath == NULL)
>   chrootpath = pw->pw_dir;
> 
> $ ls -l /home/andrew/slowcgi.sock
> srw-rw  1 andrew  andrew  0 Jul 26 16:34 /home/andrew/slowcgi.sock
> 

-- 
I'm not entirely sure you are real.