Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Teach urndis to handle some REMOTE_NDIS_INDICATE_STA...



details:   https://anonhg.NetBSD.org/src/rev/a016a53c4493
branches:  trunk
changeset: 964589:a016a53c4493
user:      maya <maya%NetBSD.org@localhost>
date:      Thu Aug 08 06:16:39 2019 +0000

description:
Teach urndis to handle some REMOTE_NDIS_INDICATE_STATUS_MSG. If the status
is reasonable, don't tell userland we got an error. Stops spurious EIO.
>From openbsd.

diffstat:

 sys/dev/ic/rndisreg.h   |  11 ++++++++++-
 sys/dev/usb/if_urndis.c |  42 ++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 50 insertions(+), 3 deletions(-)

diffs (102 lines):

diff -r 982710338a65 -r a016a53c4493 sys/dev/ic/rndisreg.h
--- a/sys/dev/ic/rndisreg.h     Thu Aug 08 05:50:20 2019 +0000
+++ b/sys/dev/ic/rndisreg.h     Thu Aug 08 06:16:39 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rndisreg.h,v 1.2 2019/02/15 08:54:02 nonaka Exp $ */
+/*     $NetBSD: rndisreg.h,v 1.3 2019/08/08 06:16:39 maya Exp $ */
 /*     NetBSD: if_urndisreg.h,v 1.4 2018/11/09 21:57:09 maya Exp */
 /*     $OpenBSD: if_urndisreg.h,v 1.14 2010/07/08 18:22:01 ckuethe Exp $ */
 
@@ -267,6 +267,15 @@
 /* 802.3 link-state or undefined message error. */
 #define REMOTE_NDIS_INDICATE_STATUS_MSG        0x00000007
 
+struct rndis_status_msg {
+       uint32_t        rm_type;
+       uint32_t        rm_len;
+       uint32_t        rm_status;
+       uint32_t        rm_stbuflen;
+       uint32_t        rm_stbufoffset;
+       /* rndis_diag_info */
+};
+
 /* Keepalive messsage.  May be sent by device. */
 #define REMOTE_NDIS_KEEPALIVE_MSG      0x00000008
 #define REMOTE_NDIS_KEEPALIVE_CMPLT    0x80000008
diff -r 982710338a65 -r a016a53c4493 sys/dev/usb/if_urndis.c
--- a/sys/dev/usb/if_urndis.c   Thu Aug 08 05:50:20 2019 +0000
+++ b/sys/dev/usb/if_urndis.c   Thu Aug 08 06:16:39 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_urndis.c,v 1.23 2019/08/07 22:26:28 macallan Exp $ */
+/*     $NetBSD: if_urndis.c,v 1.24 2019/08/08 06:16:40 maya Exp $ */
 /*     $OpenBSD: if_urndis.c,v 1.31 2011/07/03 15:47:17 matthew Exp $ */
 
 /*
@@ -21,7 +21,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.23 2019/08/07 22:26:28 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.24 2019/08/08 06:16:40 maya Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -143,6 +143,8 @@
     const struct rndis_comp_hdr *, void **, size_t *);
 static uint32_t urndis_ctrl_handle_reset(struct urndis_softc *,
     const struct rndis_comp_hdr *);
+static uint32_t urndis_ctrl_handle_status(struct urndis_softc *,
+    const struct rndis_comp_hdr *);
 
 static uint32_t urndis_ctrl_init(struct urndis_softc *);
 #if 0
@@ -278,6 +280,10 @@
                        rval = le32toh(hdr->rm_status);
                        break;
 
+               case REMOTE_NDIS_INDICATE_STATUS_MSG:
+                       rval = urndis_ctrl_handle_status(sc, hdr);
+                       break;
+
                default:
                        printf("%s: ctrl message error: unknown event 0x%x\n",
                            DEVNAME(sc), le32toh(hdr->rm_type));
@@ -451,6 +457,38 @@
 }
 
 static uint32_t
+urndis_ctrl_handle_status(struct urndis_softc *sc,
+    const struct rndis_comp_hdr *hdr)
+{
+       const struct rndis_status_msg   *msg;
+       uint32_t                        rval;
+
+       msg = (const struct rndis_status_msg *)hdr;
+
+       rval = le32toh(msg->rm_status);
+
+       DPRINTF(("%s: urndis_ctrl_handle_status: len %u status 0x%x "
+           "stbuflen %u\n",
+           DEVNAME(sc),
+           le32toh(msg->rm_len),
+           rval,
+           le32toh(msg->rm_stbuflen)));
+
+       switch (rval) {
+               case RNDIS_STATUS_MEDIA_CONNECT:
+               case RNDIS_STATUS_MEDIA_DISCONNECT:
+               case RNDIS_STATUS_OFFLOAD_CURRENT_CONFIG:
+                       rval = RNDIS_STATUS_SUCCESS;
+                       break;
+
+               default:
+                       printf("%s: status 0x%x\n", DEVNAME(sc), rval);
+       }
+
+       return rval;
+}
+
+static uint32_t
 urndis_ctrl_init(struct urndis_softc *sc)
 {
        struct rndis_init_req   *msg;



Home | Main Index | Thread Index | Old Index