diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-08-21 09:39:55 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-09-21 10:29:40 +0200 |
commit | 2df56dbd60bb5d925d2ce0ddbdefdbe6107ea783 (patch) | |
tree | bd7bad558534db4a1f400bc38a2c9aa7ea4f411e /freebsd/sys/dev/usb | |
parent | Update to FreeBSD head 2018-02-01 (diff) | |
download | rtems-libbsd-2df56dbd60bb5d925d2ce0ddbdefdbe6107ea783.tar.bz2 |
Update to FreeBSD head 2018-04-01
Git mirror commit 8dfb1ccc26d1cea7e2529303003ff61f9f1784c4.
Update #3472.
Diffstat (limited to 'freebsd/sys/dev/usb')
-rw-r--r-- | freebsd/sys/dev/usb/controller/musb_otg.c | 90 | ||||
-rw-r--r-- | freebsd/sys/dev/usb/controller/musb_otg.h | 7 | ||||
-rw-r--r-- | freebsd/sys/dev/usb/input/ukbd.c | 30 | ||||
-rw-r--r-- | freebsd/sys/dev/usb/input/wsp.c | 7 | ||||
-rw-r--r-- | freebsd/sys/dev/usb/net/if_axge.c | 7 | ||||
-rw-r--r-- | freebsd/sys/dev/usb/quirk/usb_quirk.c | 2 | ||||
-rw-r--r-- | freebsd/sys/dev/usb/serial/uftdi.c | 3 | ||||
-rw-r--r-- | freebsd/sys/dev/usb/serial/uslcom.c | 1 | ||||
-rw-r--r-- | freebsd/sys/dev/usb/usb_lookup.c | 67 | ||||
-rw-r--r-- | freebsd/sys/dev/usb/usbdi.h | 10 | ||||
-rw-r--r-- | freebsd/sys/dev/usb/wlan/if_rum.c | 34 | ||||
-rw-r--r-- | freebsd/sys/dev/usb/wlan/if_run.c | 46 | ||||
-rw-r--r-- | freebsd/sys/dev/usb/wlan/if_uath.c | 3 | ||||
-rw-r--r-- | freebsd/sys/dev/usb/wlan/if_upgt.c | 2 | ||||
-rw-r--r-- | freebsd/sys/dev/usb/wlan/if_ural.c | 36 | ||||
-rw-r--r-- | freebsd/sys/dev/usb/wlan/if_urtw.c | 56 | ||||
-rw-r--r-- | freebsd/sys/dev/usb/wlan/if_zyd.c | 15 |
17 files changed, 176 insertions, 240 deletions
diff --git a/freebsd/sys/dev/usb/controller/musb_otg.c b/freebsd/sys/dev/usb/controller/musb_otg.c index 16a3adef..99290386 100644 --- a/freebsd/sys/dev/usb/controller/musb_otg.c +++ b/freebsd/sys/dev/usb/controller/musb_otg.c @@ -151,6 +151,27 @@ static const struct usb_hw_ep_profile musbotg_ep_profile[1] = { } }; +static const struct musb_otg_ep_cfg musbotg_ep_default[] = { + { + .ep_end = 1, + .ep_fifosz_shift = 12, + .ep_fifosz_reg = MUSB2_VAL_FIFOSZ_4096 | MUSB2_MASK_FIFODB, + }, + { + .ep_end = 7, + .ep_fifosz_shift = 10, + .ep_fifosz_reg = MUSB2_VAL_FIFOSZ_512 | MUSB2_MASK_FIFODB, + }, + { + .ep_end = 15, + .ep_fifosz_shift = 7, + .ep_fifosz_reg = MUSB2_VAL_FIFOSZ_128, + }, + { + .ep_end = -1, + }, +}; + static int musbotg_channel_alloc(struct musbotg_softc *sc, struct musbotg_td *td, uint8_t is_tx) { @@ -3061,7 +3082,9 @@ musbotg_clear_stall(struct usb_device *udev, struct usb_endpoint *ep) usb_error_t musbotg_init(struct musbotg_softc *sc) { + const struct musb_otg_ep_cfg *cfg; struct usb_hw_ep_profile *pf; + int i; uint16_t offset; uint8_t nrx; uint8_t ntx; @@ -3077,6 +3100,10 @@ musbotg_init(struct musbotg_softc *sc) sc->sc_bus.usbrev = USB_REV_2_0; sc->sc_bus.methods = &musbotg_bus_methods; + /* Set a default endpoint configuration */ + if (sc->sc_ep_cfg == NULL) + sc->sc_ep_cfg = musbotg_ep_default; + USB_BUS_LOCK(&sc->sc_bus); /* turn on clocks */ @@ -3143,19 +3170,24 @@ musbotg_init(struct musbotg_softc *sc) MUSB2_WRITE_1(sc, MUSB2_REG_EPINDEX, 0); - /* read out number of endpoints */ + if (sc->sc_ep_max == 0) { + /* read out number of endpoints */ + + nrx = + (MUSB2_READ_1(sc, MUSB2_REG_EPINFO) / 16); - nrx = - (MUSB2_READ_1(sc, MUSB2_REG_EPINFO) / 16); + ntx = + (MUSB2_READ_1(sc, MUSB2_REG_EPINFO) % 16); - ntx = - (MUSB2_READ_1(sc, MUSB2_REG_EPINFO) % 16); + sc->sc_ep_max = (nrx > ntx) ? nrx : ntx; + } else { + nrx = ntx = sc->sc_ep_max; + } /* these numbers exclude the control endpoint */ DPRINTFN(2, "RX/TX endpoints: %u/%u\n", nrx, ntx); - sc->sc_ep_max = (nrx > ntx) ? nrx : ntx; if (sc->sc_ep_max == 0) { DPRINTFN(2, "ERROR: Looks like the clocks are off!\n"); } @@ -3195,20 +3227,15 @@ musbotg_init(struct musbotg_softc *sc) if (dynfifo) { if (frx && (temp <= nrx)) { - if (temp == 1) { - frx = 12; /* 4K */ - MUSB2_WRITE_1(sc, MUSB2_REG_RXFIFOSZ, - MUSB2_VAL_FIFOSZ_4096 | - MUSB2_MASK_FIFODB); - } else if (temp < 8) { - frx = 10; /* 1K */ - MUSB2_WRITE_1(sc, MUSB2_REG_RXFIFOSZ, - MUSB2_VAL_FIFOSZ_512 | - MUSB2_MASK_FIFODB); - } else { - frx = 7; /* 128 bytes */ - MUSB2_WRITE_1(sc, MUSB2_REG_RXFIFOSZ, - MUSB2_VAL_FIFOSZ_128); + for (i = 0; sc->sc_ep_cfg[i].ep_end >= 0; i++) { + cfg = &sc->sc_ep_cfg[i]; + if (temp <= cfg->ep_end) { + frx = cfg->ep_fifosz_shift; + MUSB2_WRITE_1(sc, + MUSB2_REG_RXFIFOSZ, + cfg->ep_fifosz_reg); + break; + } } MUSB2_WRITE_2(sc, MUSB2_REG_RXFIFOADD, @@ -3217,20 +3244,15 @@ musbotg_init(struct musbotg_softc *sc) offset += (1 << frx); } if (ftx && (temp <= ntx)) { - if (temp == 1) { - ftx = 12; /* 4K */ - MUSB2_WRITE_1(sc, MUSB2_REG_TXFIFOSZ, - MUSB2_VAL_FIFOSZ_4096 | - MUSB2_MASK_FIFODB); - } else if (temp < 8) { - ftx = 10; /* 1K */ - MUSB2_WRITE_1(sc, MUSB2_REG_TXFIFOSZ, - MUSB2_VAL_FIFOSZ_512 | - MUSB2_MASK_FIFODB); - } else { - ftx = 7; /* 128 bytes */ - MUSB2_WRITE_1(sc, MUSB2_REG_TXFIFOSZ, - MUSB2_VAL_FIFOSZ_128); + for (i = 0; sc->sc_ep_cfg[i].ep_end >= 0; i++) { + cfg = &sc->sc_ep_cfg[i]; + if (temp <= cfg->ep_end) { + ftx = cfg->ep_fifosz_shift; + MUSB2_WRITE_1(sc, + MUSB2_REG_TXFIFOSZ, + cfg->ep_fifosz_reg); + break; + } } MUSB2_WRITE_2(sc, MUSB2_REG_TXFIFOADD, diff --git a/freebsd/sys/dev/usb/controller/musb_otg.h b/freebsd/sys/dev/usb/controller/musb_otg.h index 55ab7aa6..5d445a3d 100644 --- a/freebsd/sys/dev/usb/controller/musb_otg.h +++ b/freebsd/sys/dev/usb/controller/musb_otg.h @@ -387,6 +387,12 @@ struct musbotg_flags { uint8_t d_pulled_up:1; }; +struct musb_otg_ep_cfg { + int ep_end; + int ep_fifosz_shift; + uint8_t ep_fifosz_reg; +}; + struct musbotg_softc { struct usb_bus sc_bus; union musbotg_hub_temp sc_hub_temp; @@ -423,6 +429,7 @@ struct musbotg_softc { uint8_t sc_id; uint8_t sc_mode; void *sc_platform_data; + const struct musb_otg_ep_cfg *sc_ep_cfg; }; /* prototypes */ diff --git a/freebsd/sys/dev/usb/input/ukbd.c b/freebsd/sys/dev/usb/input/ukbd.c index 9b1d28fc..5cb2636c 100644 --- a/freebsd/sys/dev/usb/input/ukbd.c +++ b/freebsd/sys/dev/usb/input/ukbd.c @@ -388,10 +388,22 @@ ukbd_any_key_pressed(struct ukbd_softc *sc) static void ukbd_start_timer(struct ukbd_softc *sc) { - sbintime_t delay, prec; + sbintime_t delay, now, prec; + now = sbinuptime(); + + /* check if initial delay passed and fallback to key repeat delay */ + if (sc->sc_delay == 0) + sc->sc_delay = sc->sc_kbd.kb_delay2; + + /* compute timeout */ delay = SBT_1MS * sc->sc_delay; sc->sc_co_basetime += delay; + + /* check if we are running behind */ + if (sc->sc_co_basetime < now) + sc->sc_co_basetime = now; + /* This is rarely called, so prefer precision to efficiency. */ prec = qmin(delay >> 7, SBT_1MS * 10); usb_callout_reset_sbt(&sc->sc_callout, sc->sc_co_basetime, prec, @@ -512,7 +524,6 @@ ukbd_get_key(struct ukbd_softc *sc, uint8_t wait) static void ukbd_interrupt(struct ukbd_softc *sc) { - struct timeval ctv; uint32_t n_mod; uint32_t o_mod; uint32_t now = sc->sc_time_ms; @@ -582,14 +593,11 @@ rfound: ; break; } } - if (j < UKBD_NKEYCODE) { - /* Old key repeating. */ - sc->sc_delay = sc->sc_kbd.kb_delay2; - } else { - /* New key. */ - microuptime(&ctv); - sc->sc_co_basetime = tvtosbt(ctv); + if (j == UKBD_NKEYCODE) { + /* New key - set initial delay and [re]start timer */ + sc->sc_co_basetime = sbinuptime(); sc->sc_delay = sc->sc_kbd.kb_delay1; + ukbd_start_timer(sc); } ukbd_put_key(sc, key | KEY_PRESS); @@ -840,10 +848,6 @@ ukbd_intr_callback(struct usb_xfer *xfer, usb_error_t error) ukbd_interrupt(sc); - if (ukbd_any_key_pressed(sc) != 0) { - ukbd_start_timer(sc); - } - case USB_ST_SETUP: tr_setup: if (sc->sc_inputs < UKBD_IN_BUF_FULL) { diff --git a/freebsd/sys/dev/usb/input/wsp.c b/freebsd/sys/dev/usb/input/wsp.c index 0eb2c024..02fa7722 100644 --- a/freebsd/sys/dev/usb/input/wsp.c +++ b/freebsd/sys/dev/usb/input/wsp.c @@ -931,7 +931,12 @@ wsp_intr_callback(struct usb_xfer *xfer, usb_error_t error) sc->sc_status.button = 0; if (ibt != 0) { - sc->sc_status.button |= MOUSE_BUTTON1DOWN; + if ((params->caps & HAS_INTEGRATED_BUTTON) && ntouch == 2) + sc->sc_status.button |= MOUSE_BUTTON3DOWN; + else if ((params->caps & HAS_INTEGRATED_BUTTON) && ntouch == 3) + sc->sc_status.button |= MOUSE_BUTTON2DOWN; + else + sc->sc_status.button |= MOUSE_BUTTON1DOWN; sc->ibtn = 1; } sc->intr_count++; diff --git a/freebsd/sys/dev/usb/net/if_axge.c b/freebsd/sys/dev/usb/net/if_axge.c index fc602b88..575571e4 100644 --- a/freebsd/sys/dev/usb/net/if_axge.c +++ b/freebsd/sys/dev/usb/net/if_axge.c @@ -589,6 +589,10 @@ axge_detach(device_t dev) sc = device_get_softc(dev); ue = &sc->sc_ue; if (device_is_attached(dev)) { + + /* wait for any post attach or other command to complete */ + usb_proc_drain(&ue->ue_tq); + AXGE_LOCK(sc); /* * XXX @@ -880,7 +884,8 @@ axge_stop(struct usb_ether *ue) val &= ~MSR_RE; axge_write_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_MSR, val); - ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); + if (ifp != NULL) + ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); sc->sc_flags &= ~AXGE_FLAG_LINK; /* diff --git a/freebsd/sys/dev/usb/quirk/usb_quirk.c b/freebsd/sys/dev/usb/quirk/usb_quirk.c index 3ae4a557..2aea57c8 100644 --- a/freebsd/sys/dev/usb/quirk/usb_quirk.c +++ b/freebsd/sys/dev/usb/quirk/usb_quirk.c @@ -139,6 +139,8 @@ static struct usb_quirk_entry usb_quirks[USB_DEV_QUIRKS_MAX] = { USB_QUIRK(CORSAIR, K60, 0x0000, 0xffff, UQ_KBD_BOOTPROTO), /* Quirk for Corsair Vengeance K70 keyboard */ USB_QUIRK(CORSAIR, K70, 0x0000, 0xffff, UQ_KBD_BOOTPROTO), + /* Quirk for Corsair K70 RGB keyboard */ + USB_QUIRK(CORSAIR, K70_RGB, 0x0000, 0xffff, UQ_KBD_BOOTPROTO), /* Quirk for Corsair STRAFE Gaming keyboard */ USB_QUIRK(CORSAIR, STRAFE, 0x0000, 0xffff, UQ_KBD_BOOTPROTO), /* umodem(4) device quirks */ diff --git a/freebsd/sys/dev/usb/serial/uftdi.c b/freebsd/sys/dev/usb/serial/uftdi.c index d07c055d..9f20662c 100644 --- a/freebsd/sys/dev/usb/serial/uftdi.c +++ b/freebsd/sys/dev/usb/serial/uftdi.c @@ -443,7 +443,7 @@ static const STRUCT_USB_HOST_ID uftdi_devs[] = { UFTDI_DEV(FTDI, IPLUS2, 0), UFTDI_DEV(FTDI, IRTRANS, 0), UFTDI_DEV(FTDI, KBS, 0), - UFTDI_DEV(FTDI, KTLINK, 0), + UFTDI_DEV(FTDI, KTLINK, UFTDI_JTAG_IFACE(0)), UFTDI_DEV(FTDI, LENZ_LIUSB, 0), UFTDI_DEV(FTDI, LK202, 0), UFTDI_DEV(FTDI, LK204, 0), @@ -524,6 +524,7 @@ static const STRUCT_USB_HOST_ID uftdi_devs[] = { UFTDI_DEV(FTDI, TERATRONIK_D2XX, 0), UFTDI_DEV(FTDI, TERATRONIK_VCP, 0), UFTDI_DEV(FTDI, THORLABS, 0), + UFTDI_DEV(FTDI, TIAO, 0), UFTDI_DEV(FTDI, TNC_X, 0), UFTDI_DEV(FTDI, TTUSB, 0), UFTDI_DEV(FTDI, TURTELIZER2, UFTDI_JTAG_IFACE(0)), diff --git a/freebsd/sys/dev/usb/serial/uslcom.c b/freebsd/sys/dev/usb/serial/uslcom.c index 08a563de..45835b82 100644 --- a/freebsd/sys/dev/usb/serial/uslcom.c +++ b/freebsd/sys/dev/usb/serial/uslcom.c @@ -315,6 +315,7 @@ static const STRUCT_USB_HOST_ID uslcom_devs[] = { USLCOM_DEV(SILABS, EMS_C1007), USLCOM_DEV(SILABS, HAMLINKUSB), USLCOM_DEV(SILABS, HELICOM), + USLCOM_DEV(SILABS, HUBZ), USLCOM_DEV(SILABS, IMS_USB_RS422), USLCOM_DEV(SILABS, INFINITY_MIC), USLCOM_DEV(SILABS, INGENI_ZIGBEE), diff --git a/freebsd/sys/dev/usb/usb_lookup.c b/freebsd/sys/dev/usb/usb_lookup.c index 6f6a763f..28b01afa 100644 --- a/freebsd/sys/dev/usb/usb_lookup.c +++ b/freebsd/sys/dev/usb/usb_lookup.c @@ -155,70 +155,3 @@ usbd_lookup_id_by_uaa(const struct usb_device_id *id, usb_size_t sizeof_id, return (ENXIO); } -/*------------------------------------------------------------------------* - * Export the USB device ID format we use to userspace tools. - *------------------------------------------------------------------------*/ -#if BYTE_ORDER == LITTLE_ENDIAN -#define U16_XOR "0" -#else -#define U16_XOR "8" -#endif - -#if defined(KLD_MODULE) && (USB_HAVE_ID_SECTION != 0) -static const char __section("bus_autoconf_format") __used usb_id_format[] = { - - /* Declare that three different sections use the same format */ - - "usb_host_id{256,:}" - "usb_device_id{256,:}" - "usb_dual_id{256,:}" - - /* List size of fields in the usb_device_id structure */ - - "mf_vendor{" U16_XOR ",1}" - "mf_product{" U16_XOR ",1}" - "mf_dev_lo{" U16_XOR ",1}" - "mf_dev_hi{" U16_XOR ",1}" - - "mf_dev_class{" U16_XOR ",1}" - "mf_dev_subclass{" U16_XOR ",1}" - "mf_dev_protocol{" U16_XOR ",1}" - "mf_int_class{" U16_XOR ",1}" - - "mf_int_subclass{" U16_XOR ",1}" - "mf_int_protocol{" U16_XOR ",1}" - "unused{" U16_XOR ",6}" - - "idVendor[0]{" U16_XOR ",8}" - "idVendor[1]{" U16_XOR ",8}" - "idProduct[0]{" U16_XOR ",8}" - "idProduct[1]{" U16_XOR ",8}" - "bcdDevice_lo[0]{" U16_XOR ",8}" - "bcdDevice_lo[1]{" U16_XOR ",8}" - "bcdDevice_hi[0]{" U16_XOR ",8}" - "bcdDevice_hi[1]{" U16_XOR ",8}" - - "bDeviceClass{0,8}" - "bDeviceSubClass{0,8}" - "bDeviceProtocol{0,8}" - "bInterfaceClass{0,8}" - "bInterfaceSubClass{0,8}" - "bInterfaceProtocol{0,8}" - -#if USB_HAVE_COMPAT_LINUX - "mfl_vendor{" U16_XOR ",1}" - "mfl_product{" U16_XOR ",1}" - "mfl_dev_lo{" U16_XOR ",1}" - "mfl_dev_hi{" U16_XOR ",1}" - - "mfl_dev_class{" U16_XOR ",1}" - "mfl_dev_subclass{" U16_XOR ",1}" - "mfl_dev_protocol{" U16_XOR ",1}" - "mfl_int_class{" U16_XOR ",1}" - - "mfl_int_subclass{" U16_XOR ",1}" - "mfl_int_protocol{" U16_XOR ",1}" - "unused{" U16_XOR ",6}" -#endif -}; -#endif diff --git a/freebsd/sys/dev/usb/usbdi.h b/freebsd/sys/dev/usb/usbdi.h index 2be8eef1..147b5d5e 100644 --- a/freebsd/sys/dev/usb/usbdi.h +++ b/freebsd/sys/dev/usb/usbdi.h @@ -336,19 +336,19 @@ struct usb_device_id { unsigned long driver_info; } __aligned(32); -#define USB_STD_PNP_INFO "M16:mask;U16:vendor;U16:product;L16:product;G16:product;" \ - "U8:devclass;U8:devsubclass;U8:devprotocol;" \ +#define USB_STD_PNP_INFO "M16:mask;U16:vendor;U16:product;L16:release;G16:release;" \ + "U8:devclass;U8:devsubclass;U8:devproto;" \ "U8:intclass;U8:intsubclass;U8:intprotocol;" #define USB_STD_PNP_HOST_INFO USB_STD_PNP_INFO "T:mode=host;" #define USB_STD_PNP_DEVICE_INFO USB_STD_PNP_INFO "T:mode=device;" #define USB_PNP_HOST_INFO(table) \ - MODULE_PNP_INFO(USB_STD_PNP_HOST_INFO, usb, table, table, sizeof(table[0]), \ + MODULE_PNP_INFO(USB_STD_PNP_HOST_INFO, uhub, table, table, sizeof(table[0]), \ sizeof(table) / sizeof(table[0])) #define USB_PNP_DEVICE_INFO(table) \ - MODULE_PNP_INFO(USB_STD_PNP_DEVICE_INFO, usb, table, table, sizeof(table[0]), \ + MODULE_PNP_INFO(USB_STD_PNP_DEVICE_INFO, uhub, table, table, sizeof(table[0]), \ sizeof(table) / sizeof(table[0])) #define USB_PNP_DUAL_INFO(table) \ - MODULE_PNP_INFO(USB_STD_PNP_INFO, usb, table, table, sizeof(table[0]), \ + MODULE_PNP_INFO(USB_STD_PNP_INFO, uhub, table, table, sizeof(table[0]), \ sizeof(table) / sizeof(table[0])) /* check that the size of the structure above is correct */ diff --git a/freebsd/sys/dev/usb/wlan/if_rum.c b/freebsd/sys/dev/usb/wlan/if_rum.c index dbb12335..5c826cac 100644 --- a/freebsd/sys/dev/usb/wlan/if_rum.c +++ b/freebsd/sys/dev/usb/wlan/if_rum.c @@ -29,6 +29,8 @@ __FBSDID("$FreeBSD$"); * http://www.ralinktech.com.tw/ */ +#include <rtems/bsd/local/opt_wlan.h> + #include <sys/param.h> #include <sys/sockio.h> #include <sys/sysctl.h> @@ -1421,37 +1423,25 @@ rum_sendprot(struct rum_softc *sc, const struct mbuf *m, struct ieee80211_node *ni, int prot, int rate) { struct ieee80211com *ic = ni->ni_ic; - const struct ieee80211_frame *wh; struct rum_tx_data *data; struct mbuf *mprot; - int protrate, pktlen, flags, isshort; - uint16_t dur; + int protrate, flags; RUM_LOCK_ASSERT(sc); - KASSERT(prot == IEEE80211_PROT_RTSCTS || prot == IEEE80211_PROT_CTSONLY, - ("protection %d", prot)); - wh = mtod(m, const struct ieee80211_frame *); - pktlen = m->m_pkthdr.len + IEEE80211_CRC_LEN; + mprot = ieee80211_alloc_prot(ni, m, rate, prot); + if (mprot == NULL) { + if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1); + device_printf(sc->sc_dev, + "could not allocate mbuf for protection mode %d\n", prot); + return (ENOBUFS); + } protrate = ieee80211_ctl_rate(ic->ic_rt, rate); - - isshort = (ic->ic_flags & IEEE80211_F_SHPREAMBLE) != 0; - dur = ieee80211_compute_duration(ic->ic_rt, pktlen, rate, isshort) - + ieee80211_ack_duration(ic->ic_rt, rate, isshort); flags = 0; - if (prot == IEEE80211_PROT_RTSCTS) { - /* NB: CTS is the same size as an ACK */ - dur += ieee80211_ack_duration(ic->ic_rt, rate, isshort); + if (prot == IEEE80211_PROT_RTSCTS) flags |= RT2573_TX_NEED_ACK; - mprot = ieee80211_alloc_rts(ic, wh->i_addr1, wh->i_addr2, dur); - } else { - mprot = ieee80211_alloc_cts(ic, ni->ni_vap->iv_myaddr, dur); - } - if (mprot == NULL) { - /* XXX stat + msg */ - return (ENOBUFS); - } + data = STAILQ_FIRST(&sc->tx_free); STAILQ_REMOVE_HEAD(&sc->tx_free, next); sc->tx_nfree--; diff --git a/freebsd/sys/dev/usb/wlan/if_run.c b/freebsd/sys/dev/usb/wlan/if_run.c index 71f53dd3..41f97ba4 100644 --- a/freebsd/sys/dev/usb/wlan/if_run.c +++ b/freebsd/sys/dev/usb/wlan/if_run.c @@ -27,6 +27,8 @@ __FBSDID("$FreeBSD$"); * http://www.ralinktech.com/ */ +#include <rtems/bsd/local/opt_wlan.h> + #include <sys/param.h> #include <sys/sockio.h> #include <sys/sysctl.h> @@ -3485,7 +3487,6 @@ run_tx_mgt(struct run_softc *sc, struct mbuf *m, struct ieee80211_node *ni) struct rt2860_txwi *txwi; uint16_t dur; uint8_t ridx = rn->mgt_ridx; - uint8_t type; uint8_t xflags = 0; uint8_t wflags = 0; @@ -3493,8 +3494,6 @@ run_tx_mgt(struct run_softc *sc, struct mbuf *m, struct ieee80211_node *ni) wh = mtod(m, struct ieee80211_frame *); - type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; - /* tell hardware to add timestamp for probe responses */ if ((wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == @@ -3545,57 +3544,35 @@ run_sendprot(struct run_softc *sc, const struct mbuf *m, struct ieee80211_node *ni, int prot, int rate) { struct ieee80211com *ic = ni->ni_ic; - struct ieee80211_frame *wh; struct run_tx_data *data; struct rt2870_txd *txd; struct rt2860_txwi *txwi; struct mbuf *mprot; int ridx; int protrate; - int ackrate; - int pktlen; - int isshort; - uint16_t dur; - uint8_t type; uint8_t wflags = 0; uint8_t xflags = 0; RUN_LOCK_ASSERT(sc, MA_OWNED); - KASSERT(prot == IEEE80211_PROT_RTSCTS || prot == IEEE80211_PROT_CTSONLY, - ("protection %d", prot)); - - wh = mtod(m, struct ieee80211_frame *); - pktlen = m->m_pkthdr.len + IEEE80211_CRC_LEN; - type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; - - protrate = ieee80211_ctl_rate(ic->ic_rt, rate); - ackrate = ieee80211_ack_rate(ic->ic_rt, rate); - - isshort = (ic->ic_flags & IEEE80211_F_SHPREAMBLE) != 0; - dur = ieee80211_compute_duration(ic->ic_rt, pktlen, rate, isshort) - + ieee80211_ack_duration(ic->ic_rt, rate, isshort); - wflags = RT2860_TX_FRAG; - /* check that there are free slots before allocating the mbuf */ if (sc->sc_epq[0].tx_nfree == 0) /* let caller free mbuf */ return (ENOBUFS); - if (prot == IEEE80211_PROT_RTSCTS) { - /* NB: CTS is the same size as an ACK */ - dur += ieee80211_ack_duration(ic->ic_rt, rate, isshort); - xflags |= RT2860_TX_ACK; - mprot = ieee80211_alloc_rts(ic, wh->i_addr1, wh->i_addr2, dur); - } else { - mprot = ieee80211_alloc_cts(ic, ni->ni_vap->iv_myaddr, dur); - } + mprot = ieee80211_alloc_prot(ni, m, rate, prot); if (mprot == NULL) { if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1); RUN_DPRINTF(sc, RUN_DEBUG_XMIT, "could not allocate mbuf\n"); return (ENOBUFS); } + protrate = ieee80211_ctl_rate(ic->ic_rt, rate); + wflags = RT2860_TX_FRAG; + xflags = 0; + if (prot == IEEE80211_PROT_RTSCTS) + xflags |= RT2860_TX_ACK; + data = STAILQ_FIRST(&sc->sc_epq[0].tx_fh); STAILQ_REMOVE_HEAD(&sc->sc_epq[0].tx_fh, next); sc->sc_epq[0].tx_nfree--; @@ -3633,11 +3610,9 @@ run_tx_param(struct run_softc *sc, struct mbuf *m, struct ieee80211_node *ni, const struct ieee80211_bpf_params *params) { struct ieee80211com *ic = ni->ni_ic; - struct ieee80211_frame *wh; struct run_tx_data *data; struct rt2870_txd *txd; struct rt2860_txwi *txwi; - uint8_t type; uint8_t ridx; uint8_t rate; uint8_t opflags = 0; @@ -3648,9 +3623,6 @@ run_tx_param(struct run_softc *sc, struct mbuf *m, struct ieee80211_node *ni, KASSERT(params != NULL, ("no raw xmit params")); - wh = mtod(m, struct ieee80211_frame *); - type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; - rate = params->ibp_rate0; if (!ieee80211_isratevalid(ic->ic_rt, rate)) { /* let caller free mbuf */ diff --git a/freebsd/sys/dev/usb/wlan/if_uath.c b/freebsd/sys/dev/usb/wlan/if_uath.c index e001d9ed..2b97060e 100644 --- a/freebsd/sys/dev/usb/wlan/if_uath.c +++ b/freebsd/sys/dev/usb/wlan/if_uath.c @@ -69,6 +69,9 @@ __FBSDID("$FreeBSD$"); * for these devices does not work in this way and so does not work * with this driver. */ + +#include <rtems/bsd/local/opt_wlan.h> + #include <sys/param.h> #include <sys/sockio.h> #include <sys/sysctl.h> diff --git a/freebsd/sys/dev/usb/wlan/if_upgt.c b/freebsd/sys/dev/usb/wlan/if_upgt.c index 8f19f63b..e1923bab 100644 --- a/freebsd/sys/dev/usb/wlan/if_upgt.c +++ b/freebsd/sys/dev/usb/wlan/if_upgt.c @@ -19,6 +19,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <rtems/bsd/local/opt_wlan.h> + #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> diff --git a/freebsd/sys/dev/usb/wlan/if_ural.c b/freebsd/sys/dev/usb/wlan/if_ural.c index 2f237d7d..4de0a9c5 100644 --- a/freebsd/sys/dev/usb/wlan/if_ural.c +++ b/freebsd/sys/dev/usb/wlan/if_ural.c @@ -30,6 +30,8 @@ __FBSDID("$FreeBSD$"); * http://www.ralinktech.com/ */ +#include <rtems/bsd/local/opt_wlan.h> + #include <sys/param.h> #include <sys/sockio.h> #include <sys/sysctl.h> @@ -1132,37 +1134,23 @@ ural_sendprot(struct ural_softc *sc, const struct mbuf *m, struct ieee80211_node *ni, int prot, int rate) { struct ieee80211com *ic = ni->ni_ic; - const struct ieee80211_frame *wh; struct ural_tx_data *data; struct mbuf *mprot; - int protrate, ackrate, pktlen, flags, isshort; - uint16_t dur; + int protrate, flags; - KASSERT(prot == IEEE80211_PROT_RTSCTS || prot == IEEE80211_PROT_CTSONLY, - ("protection %d", prot)); - - wh = mtod(m, const struct ieee80211_frame *); - pktlen = m->m_pkthdr.len + IEEE80211_CRC_LEN; + mprot = ieee80211_alloc_prot(ni, m, rate, prot); + if (mprot == NULL) { + if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1); + device_printf(sc->sc_dev, + "could not allocate mbuf for protection mode %d\n", prot); + return ENOBUFS; + } protrate = ieee80211_ctl_rate(ic->ic_rt, rate); - ackrate = ieee80211_ack_rate(ic->ic_rt, rate); - - isshort = (ic->ic_flags & IEEE80211_F_SHPREAMBLE) != 0; - dur = ieee80211_compute_duration(ic->ic_rt, pktlen, rate, isshort) - + ieee80211_ack_duration(ic->ic_rt, rate, isshort); flags = RAL_TX_RETRY(7); - if (prot == IEEE80211_PROT_RTSCTS) { - /* NB: CTS is the same size as an ACK */ - dur += ieee80211_ack_duration(ic->ic_rt, rate, isshort); + if (prot == IEEE80211_PROT_RTSCTS) flags |= RAL_TX_ACK; - mprot = ieee80211_alloc_rts(ic, wh->i_addr1, wh->i_addr2, dur); - } else { - mprot = ieee80211_alloc_cts(ic, ni->ni_vap->iv_myaddr, dur); - } - if (mprot == NULL) { - /* XXX stat + msg */ - return ENOBUFS; - } + data = STAILQ_FIRST(&sc->tx_free); STAILQ_REMOVE_HEAD(&sc->tx_free, next); sc->tx_nfree--; diff --git a/freebsd/sys/dev/usb/wlan/if_urtw.c b/freebsd/sys/dev/usb/wlan/if_urtw.c index d94cbee7..309375f0 100644 --- a/freebsd/sys/dev/usb/wlan/if_urtw.c +++ b/freebsd/sys/dev/usb/wlan/if_urtw.c @@ -18,6 +18,9 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); + +#include <rtems/bsd/local/opt_wlan.h> + #include <sys/param.h> #include <sys/sockio.h> #include <sys/sysctl.h> @@ -64,6 +67,12 @@ __FBSDID("$FreeBSD$"); #include <dev/usb/wlan/if_urtwreg.h> #include <dev/usb/wlan/if_urtwvar.h> +/* copy some rate indices from if_rtwn_ridx.h */ +#define URTW_RIDX_CCK5 2 +#define URTW_RIDX_CCK11 3 +#define URTW_RIDX_OFDM6 4 +#define URTW_RIDX_OFDM24 8 + static SYSCTL_NODE(_hw_usb, OID_AUTO, urtw, CTLFLAG_RW, 0, "USB Realtek 8187L"); #ifdef URTW_DEBUG int urtw_debug = 0; @@ -681,7 +690,6 @@ static void urtw_ledtask(void *, int); static void urtw_watchdog(void *); static void urtw_set_multi(void *); static int urtw_isbmode(uint16_t); -static uint16_t urtw_rate2rtl(uint32_t); static uint16_t urtw_rtl2rate(uint32_t); static usb_error_t urtw_set_rate(struct urtw_softc *); static usb_error_t urtw_update_msr(struct urtw_softc *); @@ -865,7 +873,7 @@ urtw_attach(device_t dev) sc->sc_rts_retry = URTW_DEFAULT_RTS_RETRY; sc->sc_tx_retry = URTW_DEFAULT_TX_RETRY; - sc->sc_currate = 3; + sc->sc_currate = URTW_RIDX_CCK11; sc->sc_preamble_mode = urtw_preamble_mode; ic->ic_softc = sc; @@ -1655,14 +1663,17 @@ urtw_tx_start(struct urtw_softc *sc, struct ieee80211_node *ni, struct mbuf *m0, sc->sc_xfer[URTW_8187B_BULK_TX_VO] }; struct usb_xfer *xfer; - int dur = 0, rtsdur = 0, rtsenable = 0, ctsenable = 0, rate, - pkttime = 0, txdur = 0, isshort = 0, xferlen; + int dur = 0, rtsdur = 0, rtsenable = 0, ctsenable = 0, rate, type, + pkttime = 0, txdur = 0, isshort = 0, xferlen, ismcast; uint16_t acktime, rtstime, ctstime; uint32_t flags; usb_error_t error; URTW_ASSERT_LOCKED(sc); + ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1); + type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; + /* * Software crypto. */ @@ -1691,13 +1702,13 @@ urtw_tx_start(struct urtw_softc *sc, struct ieee80211_node *ni, struct mbuf *m0, ieee80211_radiotap_tx(vap, m0); } - if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_MGT || - (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_CTL || + if (type == IEEE80211_FC0_TYPE_MGT || + type == IEEE80211_FC0_TYPE_CTL || (m0->m_flags & M_EAPOL) != 0) { rate = tp->mgmtrate; } else { /* for data frames */ - if (IEEE80211_IS_MULTICAST(wh->i_addr1)) + if (ismcast) rate = tp->mcastrate; else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) rate = tp->ucastrate; @@ -1707,7 +1718,7 @@ urtw_tx_start(struct urtw_softc *sc, struct ieee80211_node *ni, struct mbuf *m0, sc->sc_stats.txrates[sc->sc_currate]++; - if (IEEE80211_IS_MULTICAST(wh->i_addr1)) + if (ismcast) txdur = pkttime = urtw_compute_txtime(m0->m_pkthdr.len + IEEE80211_CRC_LEN, rate, 0, 0); else { @@ -1765,14 +1776,12 @@ urtw_tx_start(struct urtw_softc *sc, struct ieee80211_node *ni, struct mbuf *m0, flags |= URTW_TX_FLAG_CTS; if (rtsenable) { flags |= URTW_TX_FLAG_RTS; - flags |= (urtw_rate2rtl(11) & 0xf) << - URTW_TX_FLAG_RTSRATE_SHIFT; + flags |= URTW_RIDX_CCK5 << URTW_TX_FLAG_RTSRATE_SHIFT; tx->rtsdur = rtsdur; } tx->flag = htole32(flags); tx->txdur = txdur; - if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == - IEEE80211_FC0_TYPE_MGT && + if (type == IEEE80211_FC0_TYPE_MGT && (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) == IEEE80211_FC0_SUBTYPE_PROBE_RESP) tx->retry = 1; @@ -1787,7 +1796,7 @@ urtw_tx_start(struct urtw_softc *sc, struct ieee80211_node *ni, struct mbuf *m0, flags |= URTW_TX_FLAG_RTS; tx->rtsdur = rtsdur; } - flags |= (urtw_rate2rtl(11) & 0xf) << URTW_TX_FLAG_RTSRATE_SHIFT; + flags |= URTW_RIDX_CCK5 << URTW_TX_FLAG_RTSRATE_SHIFT; tx->flag = htole32(flags); tx->retry = 3; /* CW minimum */ tx->retry |= 7 << 4; /* CW maximum */ @@ -1800,7 +1809,7 @@ urtw_tx_start(struct urtw_softc *sc, struct ieee80211_node *ni, struct mbuf *m0, data->m = m0; if (sc->sc_flags & URTW_RTL8187B) { - switch (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) { + switch (type) { case IEEE80211_FC0_TYPE_CTL: case IEEE80211_FC0_TYPE_MGT: xfer = sc->sc_xfer[URTW_8187B_BULK_TX_EP12]; @@ -1907,9 +1916,9 @@ urtw_set_rate(struct urtw_softc *sc) uint16_t data; usb_error_t error; - basic_rate = urtw_rate2rtl(48); - min_rr_rate = urtw_rate2rtl(12); - max_rr_rate = urtw_rate2rtl(48); + basic_rate = URTW_RIDX_OFDM24; + min_rr_rate = URTW_RIDX_OFDM6; + max_rr_rate = URTW_RIDX_OFDM24; urtw_write8_m(sc, URTW_RESP_RATE, max_rr_rate << URTW_RESP_MAX_RATE_SHIFT | @@ -1927,19 +1936,6 @@ fail: } static uint16_t -urtw_rate2rtl(uint32_t rate) -{ - unsigned int i; - - for (i = 0; i < nitems(urtw_ratetable); i++) { - if (rate == urtw_ratetable[i].reg) - return urtw_ratetable[i].val; - } - - return (3); -} - -static uint16_t urtw_rtl2rate(uint32_t rate) { unsigned int i; diff --git a/freebsd/sys/dev/usb/wlan/if_zyd.c b/freebsd/sys/dev/usb/wlan/if_zyd.c index e4243d8f..dee03bdd 100644 --- a/freebsd/sys/dev/usb/wlan/if_zyd.c +++ b/freebsd/sys/dev/usb/wlan/if_zyd.c @@ -28,6 +28,8 @@ __FBSDID("$FreeBSD$"); * ZyDAS ZD1211/ZD1211B USB WLAN driver. */ +#include <rtems/bsd/local/opt_wlan.h> + #include <sys/param.h> #include <sys/sockio.h> #include <sys/sysctl.h> @@ -2443,7 +2445,7 @@ zyd_tx_start(struct zyd_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) struct ieee80211_frame *wh; const struct ieee80211_txparam *tp = ni->ni_txparms; struct ieee80211_key *k; - int rate, totlen; + int rate, totlen, type, ismcast; static const uint8_t ratediv[] = ZYD_TX_RATEDIV; uint8_t phy; uint16_t pktlen; @@ -2454,13 +2456,16 @@ zyd_tx_start(struct zyd_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) STAILQ_REMOVE_HEAD(&sc->tx_free, next); sc->tx_nfree--; - if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_MGT || - (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_CTL || + ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1); + type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; + + if (type == IEEE80211_FC0_TYPE_MGT || + type == IEEE80211_FC0_TYPE_CTL || (m0->m_flags & M_EAPOL) != 0) { rate = tp->mgmtrate; } else { /* for data frames */ - if (IEEE80211_IS_MULTICAST(wh->i_addr1)) + if (ismcast) rate = tp->mcastrate; else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) rate = tp->ucastrate; @@ -2498,7 +2503,7 @@ zyd_tx_start(struct zyd_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) desc->len = htole16(totlen); desc->flags = ZYD_TX_FLAG_BACKOFF; - if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { + if (!ismcast) { /* multicast frames are not sent at OFDM rates in 802.11b/g */ if (totlen > vap->iv_rtsthreshold) { desc->flags |= ZYD_TX_FLAG_RTS; |