summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/net/if_urndis.c
diff options
context:
space:
mode:
authorsephe <sephe@FreeBSD.org>2016-10-13 03:23:43 +0000
committersephe <sephe@FreeBSD.org>2016-10-13 03:23:43 +0000
commitfe98667df087b2bb29f7f01c25de533bfe0abeb7 (patch)
treec8804c440b2fc87a7b4e3560bb780ff90a6604f4 /sys/dev/usb/net/if_urndis.c
parent7070a26e1277fcf460628a0a23f886d891fc1352 (diff)
downloadFreeBSD-src-fe98667df087b2bb29f7f01c25de533bfe0abeb7.zip
FreeBSD-src-fe98667df087b2bb29f7f01c25de533bfe0abeb7.tar.gz
MFC 304654,304722,304723
304654 net: Split RNDIS protocol structs/macros out of dev/usb/net/if_urndisreg.h So that Hyper-V can leverage them instead of rolling its own definition. Discussed with: hps Reviewed by: hps Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7592 304722 net/rndis: Add canonical RNDIS major/minor version as of today. Reviewed by: hps Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7593 304723 net/rndis: Fix RNDIS_STATUS_PENDING definition. While I'm here, sort the RNDIS status in ascending order. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7594
Diffstat (limited to 'sys/dev/usb/net/if_urndis.c')
-rw-r--r--sys/dev/usb/net/if_urndis.c69
1 files changed, 35 insertions, 34 deletions
diff --git a/sys/dev/usb/net/if_urndis.c b/sys/dev/usb/net/if_urndis.c
index 5d2a637..85af59f 100644
--- a/sys/dev/usb/net/if_urndis.c
+++ b/sys/dev/usb/net/if_urndis.c
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/if_var.h>
+#include <net/rndis.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
@@ -79,17 +80,17 @@ static uether_fn_t urndis_setmulti;
static uether_fn_t urndis_setpromisc;
static uint32_t urndis_ctrl_query(struct urndis_softc *sc, uint32_t oid,
- struct urndis_query_req *msg, uint16_t len,
+ struct rndis_query_req *msg, uint16_t len,
const void **rbuf, uint16_t *rbufsz);
static uint32_t urndis_ctrl_set(struct urndis_softc *sc, uint32_t oid,
- struct urndis_set_req *msg, uint16_t len);
+ struct rndis_set_req *msg, uint16_t len);
static uint32_t urndis_ctrl_handle_init(struct urndis_softc *sc,
- const struct urndis_comp_hdr *hdr);
+ const struct rndis_comp_hdr *hdr);
static uint32_t urndis_ctrl_handle_query(struct urndis_softc *sc,
- const struct urndis_comp_hdr *hdr, const void **buf,
+ const struct rndis_comp_hdr *hdr, const void **buf,
uint16_t *bufsz);
static uint32_t urndis_ctrl_handle_reset(struct urndis_softc *sc,
- const struct urndis_comp_hdr *hdr);
+ const struct rndis_comp_hdr *hdr);
static uint32_t urndis_ctrl_init(struct urndis_softc *sc);
static uint32_t urndis_ctrl_halt(struct urndis_softc *sc);
@@ -211,8 +212,8 @@ urndis_attach(device_t dev)
{
static struct {
union {
- struct urndis_query_req query;
- struct urndis_set_req set;
+ struct rndis_query_req query;
+ struct rndis_set_req set;
} hdr;
union {
uint8_t eaddr[ETHER_ADDR_LEN];
@@ -452,10 +453,10 @@ urndis_ctrl_send(struct urndis_softc *sc, void *buf, uint16_t len)
return (err);
}
-static struct urndis_comp_hdr *
+static struct rndis_comp_hdr *
urndis_ctrl_recv(struct urndis_softc *sc)
{
- struct urndis_comp_hdr *hdr;
+ struct rndis_comp_hdr *hdr;
usb_error_t err;
err = urndis_ctrl_msg(sc, UT_READ_CLASS_INTERFACE,
@@ -465,7 +466,7 @@ urndis_ctrl_recv(struct urndis_softc *sc)
if (err != USB_ERR_NORMAL_COMPLETION)
return (NULL);
- hdr = (struct urndis_comp_hdr *)sc->sc_response_buf;
+ hdr = (struct rndis_comp_hdr *)sc->sc_response_buf;
DPRINTF("type 0x%x len %u\n", le32toh(hdr->rm_type),
le32toh(hdr->rm_len));
@@ -479,7 +480,7 @@ urndis_ctrl_recv(struct urndis_softc *sc)
}
static uint32_t
-urndis_ctrl_handle(struct urndis_softc *sc, struct urndis_comp_hdr *hdr,
+urndis_ctrl_handle(struct urndis_softc *sc, struct rndis_comp_hdr *hdr,
const void **buf, uint16_t *bufsz)
{
uint32_t rval;
@@ -520,11 +521,11 @@ urndis_ctrl_handle(struct urndis_softc *sc, struct urndis_comp_hdr *hdr,
static uint32_t
urndis_ctrl_handle_init(struct urndis_softc *sc,
- const struct urndis_comp_hdr *hdr)
+ const struct rndis_comp_hdr *hdr)
{
- const struct urndis_init_comp *msg;
+ const struct rndis_init_comp *msg;
- msg = (const struct urndis_init_comp *)hdr;
+ msg = (const struct rndis_init_comp *)hdr;
DPRINTF("len %u rid %u status 0x%x "
"ver_major %u ver_minor %u devflags 0x%x medium 0x%x pktmaxcnt %u "
@@ -563,12 +564,12 @@ urndis_ctrl_handle_init(struct urndis_softc *sc,
static uint32_t
urndis_ctrl_handle_query(struct urndis_softc *sc,
- const struct urndis_comp_hdr *hdr, const void **buf, uint16_t *bufsz)
+ const struct rndis_comp_hdr *hdr, const void **buf, uint16_t *bufsz)
{
- const struct urndis_query_comp *msg;
+ const struct rndis_query_comp *msg;
uint64_t limit;
- msg = (const struct urndis_query_comp *)hdr;
+ msg = (const struct rndis_query_comp *)hdr;
DPRINTF("len %u rid %u status 0x%x "
"buflen %u bufoff %u\n",
@@ -608,12 +609,12 @@ urndis_ctrl_handle_query(struct urndis_softc *sc,
static uint32_t
urndis_ctrl_handle_reset(struct urndis_softc *sc,
- const struct urndis_comp_hdr *hdr)
+ const struct rndis_comp_hdr *hdr)
{
- const struct urndis_reset_comp *msg;
+ const struct rndis_reset_comp *msg;
uint32_t rval;
- msg = (const struct urndis_reset_comp *)hdr;
+ msg = (const struct rndis_reset_comp *)hdr;
rval = le32toh(msg->rm_status);
@@ -629,7 +630,7 @@ urndis_ctrl_handle_reset(struct urndis_softc *sc,
}
if (msg->rm_adrreset != 0) {
struct {
- struct urndis_set_req hdr;
+ struct rndis_set_req hdr;
uint32_t filter;
} msg_filter;
@@ -649,14 +650,14 @@ urndis_ctrl_handle_reset(struct urndis_softc *sc,
static uint32_t
urndis_ctrl_init(struct urndis_softc *sc)
{
- struct urndis_init_req msg;
- struct urndis_comp_hdr *hdr;
+ struct rndis_init_req msg;
+ struct rndis_comp_hdr *hdr;
uint32_t rval;
msg.rm_type = htole32(REMOTE_NDIS_INITIALIZE_MSG);
msg.rm_len = htole32(sizeof(msg));
msg.rm_rid = 0;
- msg.rm_ver_major = htole32(1);
+ msg.rm_ver_major = htole32(RNDIS_VERSION_MAJOR);
msg.rm_ver_minor = htole32(1);
msg.rm_max_xfersz = htole32(RNDIS_RX_MAXLEN);
@@ -687,7 +688,7 @@ urndis_ctrl_init(struct urndis_softc *sc)
static uint32_t
urndis_ctrl_halt(struct urndis_softc *sc)
{
- struct urndis_halt_req msg;
+ struct rndis_halt_req msg;
uint32_t rval;
msg.rm_type = htole32(REMOTE_NDIS_HALT_MSG);
@@ -713,10 +714,10 @@ urndis_ctrl_halt(struct urndis_softc *sc)
*/
static uint32_t
urndis_ctrl_query(struct urndis_softc *sc, uint32_t oid,
- struct urndis_query_req *msg, uint16_t len, const void **rbuf,
+ struct rndis_query_req *msg, uint16_t len, const void **rbuf,
uint16_t *rbufsz)
{
- struct urndis_comp_hdr *hdr;
+ struct rndis_comp_hdr *hdr;
uint32_t datalen, rval;
msg->rm_type = htole32(REMOTE_NDIS_QUERY_MSG);
@@ -760,9 +761,9 @@ urndis_ctrl_query(struct urndis_softc *sc, uint32_t oid,
static uint32_t
urndis_ctrl_set(struct urndis_softc *sc, uint32_t oid,
- struct urndis_set_req *msg, uint16_t len)
+ struct rndis_set_req *msg, uint16_t len)
{
- struct urndis_comp_hdr *hdr;
+ struct rndis_comp_hdr *hdr;
uint32_t datalen, rval;
msg->rm_type = htole32(REMOTE_NDIS_SET_MSG);
@@ -812,7 +813,7 @@ urndis_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
struct urndis_softc *sc = usbd_xfer_softc(xfer);
struct usb_page_cache *pc = usbd_xfer_get_frame(xfer, 0);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
- struct urndis_packet_msg msg;
+ struct rndis_packet_msg msg;
struct mbuf *m;
int actlen;
int aframes;
@@ -872,11 +873,11 @@ urndis_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
"datalen %u\n", msg.rm_datalen, actlen);
goto tr_setup;
} else if ((msg.rm_dataoffset + msg.rm_datalen +
- (uint32_t)__offsetof(struct urndis_packet_msg,
+ (uint32_t)__offsetof(struct rndis_packet_msg,
rm_dataoffset)) > (uint32_t)actlen) {
DPRINTF("invalid dataoffset %u larger than %u\n",
msg.rm_dataoffset + msg.rm_datalen +
- (uint32_t)__offsetof(struct urndis_packet_msg,
+ (uint32_t)__offsetof(struct rndis_packet_msg,
rm_dataoffset), actlen);
goto tr_setup;
} else if (msg.rm_datalen < (uint32_t)sizeof(struct ether_header)) {
@@ -902,7 +903,7 @@ urndis_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
m_adj(m, ETHER_ALIGN);
usbd_copy_out(pc, offset + msg.rm_dataoffset +
- __offsetof(struct urndis_packet_msg,
+ __offsetof(struct rndis_packet_msg,
rm_dataoffset), m->m_data, msg.rm_datalen);
/* enqueue */
@@ -938,7 +939,7 @@ tr_setup:
static void
urndis_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct urndis_packet_msg msg;
+ struct rndis_packet_msg msg;
struct urndis_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
struct mbuf *m;
OpenPOWER on IntegriCloud