PERFORCE change 143128 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Sun Jun 8 19:09:19 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=143128
Change 143128 by hselasky at hselasky_laptop001 on 2008/06/08 19:08:52
Final USB WLAN patches after IFC @ 143078 .
URAL, RUM and ZYD USB WLAN adapters have
been tested and found to work in STA mode
at least.
Sam: The USB WLAN drivers were
writing to "ic_myaddr" at "(void *)0", because
the IC structure is no longer in the softc. So
you need to store it in the softc and then
copy it to the IC later. Look at the
"sc_myaddr" lines in the diff.
Affected files ...
.. //depot/projects/usb/src/sys/dev/usb/if_rum.c#33 edit
.. //depot/projects/usb/src/sys/dev/usb/if_rumvar.h#7 edit
.. //depot/projects/usb/src/sys/dev/usb/if_ural.c#59 edit
.. //depot/projects/usb/src/sys/dev/usb/if_uralvar.h#22 edit
.. //depot/projects/usb/src/sys/dev/usb/if_zyd.c#40 edit
.. //depot/projects/usb/src/sys/dev/usb/if_zydreg.h#16 edit
Differences ...
==== //depot/projects/usb/src/sys/dev/usb/if_rum.c#33 (text+ko) ====
@@ -162,6 +162,8 @@
static int rum_raw_xmit_cb(struct ieee80211_node *ni, struct mbuf *m, const struct ieee80211_bpf_params *params);
static void rum_setup_desc_and_tx(struct rum_softc *sc, struct mbuf *m, uint32_t flags, uint16_t xflags, uint16_t rate);
static int rum_newstate_cb(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg);
+static void rum_update_mcast_cb(struct ifnet *ifp);
+static void rum_update_promisc_cb(struct ifnet *ifp);
/* various supported device vendors/products */
static const struct usb_devno rum_devs[] = {
@@ -823,6 +825,8 @@
ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
IFQ_SET_READY(&ifp->if_snd);
+ bcopy(sc->sc_myaddr, ic->ic_myaddr, sizeof(ic->ic_myaddr));
+
ic->ic_ifp = ifp;
ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */
ic->ic_opmode = IEEE80211_M_STA;
@@ -885,7 +889,8 @@
ic->ic_newassoc = &rum_newassoc;
ic->ic_raw_xmit = &rum_raw_xmit_cb;
ic->ic_node_alloc = &rum_node_alloc;
-
+ ic->ic_update_mcast = &rum_update_mcast_cb;
+ ic->ic_update_promisc = &rum_update_promisc_cb;
ic->ic_scan_start = &rum_scan_start_cb;
ic->ic_scan_end = &rum_scan_end_cb;
ic->ic_set_channel = &rum_set_channel_cb;
@@ -1113,14 +1118,15 @@
if (ieee80211_input(ni, m, rssi, RT2573_NOISE_FLOOR, 0)) {
/* ignore */
}
+ /* node is no longer needed */
ieee80211_free_node(ni);
} else {
if (ieee80211_input_all(ic, m, rssi, RT2573_NOISE_FLOOR, 0)) {
/* ignore */
}
}
- /* node is no longer needed */
- ieee80211_free_node(ni);
+
+ mtx_lock(&(sc->sc_mtx));
}
return;
@@ -1461,18 +1467,13 @@
{
struct rum_softc *sc = ifp->if_softc;
struct ieee80211com *ic = ifp->if_l2com;
- int error = 0;
+ int error;
switch (cmd) {
case SIOCSIFFLAGS:
-
mtx_lock(&(sc->sc_mtx));
if (ifp->if_flags & IFF_UP) {
- if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
- usbd_config_td_queue_command
- (&(sc->sc_config_td), &rum_config_copy,
- &rum_cfg_update_promisc, 0, 0);
- } else {
+ if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
usbd_config_td_queue_command
(&(sc->sc_config_td), &rum_cfg_pre_init,
&rum_cfg_init, 0, 0);
@@ -1485,6 +1486,7 @@
}
}
mtx_unlock(&(sc->sc_mtx));
+ error = 0;
break;
case SIOCGIFMEDIA:
@@ -1495,9 +1497,6 @@
default:
error = ether_ioctl(ifp, cmd, data);
}
-
- if (!error)
- ieee80211_start_all(ic);
return (error);
}
@@ -2078,12 +2077,10 @@
static void
rum_cfg_read_eeprom(struct rum_softc *sc)
{
- struct ifnet *ifp = sc->sc_ifp;
- struct ieee80211com *ic = ifp->if_l2com;
uint16_t val;
/* read MAC address */
- rum_cfg_eeprom_read(sc, RT2573_EEPROM_ADDRESS, ic->ic_myaddr, 6);
+ rum_cfg_eeprom_read(sc, RT2573_EEPROM_ADDRESS, sc->sc_myaddr, 6);
val = rum_cfg_eeprom_read_2(sc, RT2573_EEPROM_ANTENNA);
sc->sc_rf_rev = (val >> 11) & 0x1f;
@@ -2269,7 +2266,6 @@
/* clear STA registers */
rum_cfg_read_multi(sc, RT2573_STA_CSR0, sc->sc_sta, sizeof(sc->sc_sta));
-
/* set MAC address */
rum_cfg_set_macaddr(sc, cc->ic_myaddr);
@@ -2286,12 +2282,21 @@
if ((sc->sc_flags & RUM_FLAG_LL_READY) &&
(sc->sc_flags & RUM_FLAG_HL_READY)) {
+ struct ifnet *ifp = sc->sc_ifp;
+ struct ieee80211com *ic = ifp->if_l2com;
/*
* start the USB transfers, if not already started:
*/
usbd_transfer_start(sc->sc_xfer[1]);
usbd_transfer_start(sc->sc_xfer[0]);
+
+ /*
+ * start IEEE802.11 layer
+ */
+ mtx_unlock(&(sc->sc_mtx));
+ ieee80211_start_all(ic);
+ mtx_lock(&(sc->sc_mtx));
}
/* update Rx filter */
tmp = rum_cfg_read(sc, RT2573_TXRX_CSR0) & 0xffff;
@@ -2925,3 +2930,23 @@
mtx_unlock(&(sc->sc_mtx));
return (0);
}
+
+static void
+rum_update_mcast_cb(struct ifnet *ifp)
+{
+ /* not supported */
+ return;
+}
+
+static void
+rum_update_promisc_cb(struct ifnet *ifp)
+{
+ struct rum_softc *sc = ifp->if_softc;
+
+ mtx_lock(&(sc->sc_mtx));
+ usbd_config_td_queue_command
+ (&(sc->sc_config_td), &rum_config_copy,
+ &rum_cfg_update_promisc, 0, 0);
+ mtx_unlock(&(sc->sc_mtx));
+ return;
+}
==== //depot/projects/usb/src/sys/dev/usb/if_rumvar.h#7 (text+ko) ====
@@ -164,6 +164,7 @@
uint8_t sc_amrr_timer;
uint8_t sc_name[32];
uint8_t sc_beacon_buf[0x800];
+ uint8_t sc_myaddr[IEEE80211_ADDR_LEN];
int8_t sc_rssi_2ghz_corr;
int8_t sc_rssi_5ghz_corr;
==== //depot/projects/usb/src/sys/dev/usb/if_ural.c#59 (text+ko) ====
@@ -168,6 +168,8 @@
static void ural_tx_raw(struct ural_softc *sc, struct mbuf *m, struct ieee80211_node *ni, const struct ieee80211_bpf_params *params);
static int ural_raw_xmit_cb(struct ieee80211_node *ni, struct mbuf *m, const struct ieee80211_bpf_params *params);
static void ural_setup_desc_and_tx(struct ural_softc *sc, struct mbuf *m, uint32_t flags, uint16_t rate);
+static void ural_update_mcast_cb(struct ifnet *ifp);
+static void ural_update_promisc_cb(struct ifnet *ifp);
/* various supported device vendors/products */
static const struct usb_devno ural_devs[] = {
@@ -835,6 +837,8 @@
ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
IFQ_SET_READY(&ifp->if_snd);
+ bcopy(sc->sc_myaddr, ic->ic_myaddr, sizeof(ic->ic_myaddr));
+
ic->ic_ifp = ifp;
ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */
ic->ic_opmode = IEEE80211_M_STA;
@@ -870,7 +874,8 @@
ic->ic_newassoc = &ural_newassoc;
ic->ic_raw_xmit = &ural_raw_xmit_cb;
ic->ic_node_alloc = &ural_node_alloc;
-
+ ic->ic_update_mcast = &ural_update_mcast_cb;
+ ic->ic_update_promisc = &ural_update_promisc_cb;
ic->ic_scan_start = &ural_scan_start_cb;
ic->ic_scan_end = &ural_scan_end_cb;
ic->ic_set_channel = &ural_set_channel_cb;
@@ -1208,6 +1213,8 @@
uint16_t len;
uint8_t remainder;
+ DPRINTF(sc, 0, "in\n");
+
if (sc->sc_tx_queue.ifq_len >= IFQ_MAXLEN) {
/* free packet */
ural_tx_freem(m);
@@ -1297,6 +1304,8 @@
ural_tx_freem(m);
return;
}
+ DPRINTF(sc, 0, " %u %u (out)\n", sizeof(sc->sc_tx_desc), m->m_pkthdr.len);
+
bcopy(&(sc->sc_tx_desc), mm->m_data, sizeof(sc->sc_tx_desc));
mm->m_len = sizeof(sc->sc_tx_desc);
@@ -1451,18 +1460,14 @@
{
struct ural_softc *sc = ifp->if_softc;
struct ieee80211com *ic = ifp->if_l2com;
- int error = 0;
+ int error;
switch (cmd) {
case SIOCSIFFLAGS:
mtx_lock(&(sc->sc_mtx));
if (ifp->if_flags & IFF_UP) {
- if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+ if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
usbd_config_td_queue_command
- (&(sc->sc_config_td), &ural_config_copy,
- &ural_cfg_update_promisc, 0, 0);
- } else {
- usbd_config_td_queue_command
(&(sc->sc_config_td), &ural_cfg_pre_init,
&ural_cfg_init, 0, 0);
}
@@ -1474,6 +1479,7 @@
}
}
mtx_unlock(&(sc->sc_mtx));
+ error = 0;
break;
case SIOCGIFMEDIA:
@@ -1484,8 +1490,6 @@
default:
error = ether_ioctl(ifp, cmd, data);
}
- if (!error)
- ieee80211_start_all(ic);
return (error);
}
@@ -2028,8 +2032,6 @@
static void
ural_cfg_read_eeprom(struct ural_softc *sc)
{
- struct ifnet *ifp = sc->sc_ifp;
- struct ieee80211com *ic = ifp->if_l2com;
uint16_t val;
ural_cfg_eeprom_read(sc, RAL_EEPROM_CONFIG0, &val, 2);
@@ -2046,8 +2048,8 @@
DPRINTF(sc, 0, "val = 0x%04x\n", val);
/* read MAC address */
- ural_cfg_eeprom_read(sc, RAL_EEPROM_ADDRESS, ic->ic_myaddr,
- sizeof(ic->ic_myaddr));
+ ural_cfg_eeprom_read(sc, RAL_EEPROM_ADDRESS, sc->sc_myaddr,
+ sizeof(sc->sc_myaddr));
/* read default values for BBP registers */
ural_cfg_eeprom_read(sc, RAL_EEPROM_BBP_BASE, sc->sc_bbp_prom,
@@ -2199,12 +2201,21 @@
if ((sc->sc_flags & URAL_FLAG_LL_READY) &&
(sc->sc_flags & URAL_FLAG_HL_READY)) {
+ struct ifnet *ifp = sc->sc_ifp;
+ struct ieee80211com *ic = ifp->if_l2com;
/*
* start the USB transfers, if not already started:
*/
usbd_transfer_start(sc->sc_xfer[1]);
usbd_transfer_start(sc->sc_xfer[0]);
+
+ /*
+ * start IEEE802.11 layer
+ */
+ mtx_unlock(&(sc->sc_mtx));
+ ieee80211_start_all(ic);
+ mtx_lock(&(sc->sc_mtx));
}
/*
* start Rx
@@ -2751,3 +2762,23 @@
mtx_unlock(&(sc->sc_mtx));
return (0);
}
+
+static void
+ural_update_mcast_cb(struct ifnet *ifp)
+{
+ /* not supported */
+ return;
+}
+
+static void
+ural_update_promisc_cb(struct ifnet *ifp)
+{
+ struct ural_softc *sc = ifp->if_softc;
+
+ mtx_lock(&(sc->sc_mtx));
+ usbd_config_td_queue_command
+ (&(sc->sc_config_td), &ural_config_copy,
+ &ural_cfg_update_promisc, 0, 0);
+ mtx_unlock(&(sc->sc_mtx));
+ return;
+}
==== //depot/projects/usb/src/sys/dev/usb/if_uralvar.h#22 (text+ko) ====
@@ -156,4 +156,5 @@
uint8_t sc_nb_ant;
uint8_t sc_amrr_timer;
uint8_t sc_name[32];
+ uint8_t sc_myaddr[IEEE80211_ADDR_LEN];
};
==== //depot/projects/usb/src/sys/dev/usb/if_zyd.c#40 (text+ko) ====
@@ -136,7 +136,6 @@
static void zyd_cfg_set_mac_addr(struct zyd_softc *sc, const uint8_t *addr);
static void zyd_cfg_switch_radio(struct zyd_softc *sc, uint8_t onoff);
static void zyd_cfg_set_bssid(struct zyd_softc *sc, uint8_t *addr);
-static void zyd_start_transfers(struct zyd_softc *sc);
static void zyd_start_cb(struct ifnet *ifp);
static void zyd_init_cb(void *arg);
static int zyd_ioctl_cb(struct ifnet *ifp, u_long command, caddr_t data);
@@ -161,7 +160,8 @@
static void zyd_setup_desc_and_tx(struct zyd_softc *sc, struct mbuf *m, uint16_t rate);
static int zyd_newstate_cb(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg);
static void zyd_cfg_amrr_start(struct zyd_softc *sc);
-static void zyd_update_mcast(struct ifnet *ifp);
+static void zyd_update_mcast_cb(struct ifnet *ifp);
+static void zyd_update_promisc_cb(struct ifnet *ifp);
static const struct zyd_phy_pair zyd_def_phy[] = ZYD_DEF_PHY;
static const struct zyd_phy_pair zyd_def_phyB[] = ZYD_DEF_PHYB;
@@ -1815,13 +1815,13 @@
/* read MAC address */
zyd_cfg_read32(sc, ZYD_EEPROM_MAC_ADDR_P1, &tmp);
- sc->sc_ic.ic_myaddr[0] = tmp & 0xff;
- sc->sc_ic.ic_myaddr[1] = tmp >> 8;
- sc->sc_ic.ic_myaddr[2] = tmp >> 16;
- sc->sc_ic.ic_myaddr[3] = tmp >> 24;
+ sc->sc_myaddr[0] = tmp & 0xff;
+ sc->sc_myaddr[1] = tmp >> 8;
+ sc->sc_myaddr[2] = tmp >> 16;
+ sc->sc_myaddr[3] = tmp >> 24;
zyd_cfg_read32(sc, ZYD_EEPROM_MAC_ADDR_P2, &tmp);
- sc->sc_ic.ic_myaddr[4] = tmp & 0xff;
- sc->sc_ic.ic_myaddr[5] = tmp >> 8;
+ sc->sc_myaddr[4] = tmp & 0xff;
+ sc->sc_myaddr[5] = tmp >> 8;
zyd_cfg_read32(sc, ZYD_EEPROM_POD, &tmp);
sc->sc_rf_rev = tmp & 0x0f;
@@ -1960,10 +1960,10 @@
printf("%s: HMAC ZD1211%s, FW %02x.%02x, RF %s, PA %x, address %02x:%02x:%02x:%02x:%02x:%02x\n",
sc->sc_name, (sc->sc_mac_rev == ZYD_ZD1211) ? "" : "B",
sc->sc_fw_rev >> 8, sc->sc_fw_rev & 0xff, zyd_rf_name(sc->sc_rf_rev),
- sc->sc_pa_rev, sc->sc_ic.ic_myaddr[0],
- sc->sc_ic.ic_myaddr[1], sc->sc_ic.ic_myaddr[2],
- sc->sc_ic.ic_myaddr[3], sc->sc_ic.ic_myaddr[4],
- sc->sc_ic.ic_myaddr[5]);
+ sc->sc_pa_rev, sc->sc_myaddr[0],
+ sc->sc_myaddr[1], sc->sc_myaddr[2],
+ sc->sc_myaddr[3], sc->sc_myaddr[4],
+ sc->sc_myaddr[5]);
mtx_unlock(&(sc->sc_mtx));
@@ -1991,7 +1991,8 @@
ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
IFQ_SET_READY(&ifp->if_snd);
- /* Network interface setup */
+ bcopy(sc->sc_myaddr, ic->ic_myaddr, sizeof(ic->ic_myaddr));
+
ic->ic_ifp = ifp;
ic->ic_phytype = IEEE80211_T_OFDM;
ic->ic_opmode = IEEE80211_M_STA;
@@ -2026,7 +2027,8 @@
ic->ic_set_channel = &zyd_set_channel_cb;
ic->ic_vap_create = &zyd_vap_create;
ic->ic_vap_delete = &zyd_vap_delete;
- ic->ic_update_mcast = zyd_update_mcast;
+ ic->ic_update_mcast = &zyd_update_mcast_cb;
+ ic->ic_update_promisc = &zyd_update_promisc_cb;
sc->sc_rates = ieee80211_get_ratetable(ic->ic_curchan);
@@ -2436,6 +2438,24 @@
ZYD_FLAG_BULK_WRITE_STALL |
ZYD_FLAG_LL_READY);
+ if ((sc->sc_flags & ZYD_FLAG_LL_READY) &&
+ (sc->sc_flags & ZYD_FLAG_HL_READY)) {
+ struct ifnet *ifp = sc->sc_ifp;
+ struct ieee80211com *ic = ifp->if_l2com;
+
+ /*
+ * start the USB transfers, if not already started:
+ */
+ usbd_transfer_start(sc->sc_xfer[1]);
+ usbd_transfer_start(sc->sc_xfer[0]);
+
+ /*
+ * start IEEE802.11 layer
+ */
+ mtx_unlock(&(sc->sc_mtx));
+ ieee80211_start_all(ic);
+ mtx_lock(&(sc->sc_mtx));
+ }
return;
}
@@ -2490,16 +2510,27 @@
}
static void
-zyd_update_mcast(struct ifnet *ifp)
+zyd_update_mcast_cb(struct ifnet *ifp)
+{
+ struct zyd_softc *sc = ifp->if_softc;
+
+ mtx_lock(&(sc->sc_mtx));
+ usbd_config_td_queue_command
+ (&(sc->sc_config_td), &zyd_config_copy,
+ &zyd_cfg_update_promisc, 0, 0);
+ mtx_unlock(&(sc->sc_mtx));
+ return;
+}
+
+static void
+zyd_update_promisc_cb(struct ifnet *ifp)
{
struct zyd_softc *sc = ifp->if_softc;
mtx_lock(&(sc->sc_mtx));
- if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
- usbd_config_td_queue_command
- (&(sc->sc_config_td), &zyd_config_copy,
- &zyd_cfg_update_promisc, 0, 0);
- }
+ usbd_config_td_queue_command
+ (&(sc->sc_config_td), &zyd_config_copy,
+ &zyd_cfg_update_promisc, 0, 0);
mtx_unlock(&(sc->sc_mtx));
return;
}
@@ -2545,21 +2576,6 @@
}
static void
-zyd_start_transfers(struct zyd_softc *sc)
-{
- if ((sc->sc_flags & ZYD_FLAG_LL_READY) &&
- (sc->sc_flags & ZYD_FLAG_HL_READY)) {
-
- /*
- * start the USB transfers, if not already started:
- */
- usbd_transfer_start(sc->sc_xfer[ZYD_TR_BULK_DT_WR]);
- usbd_transfer_start(sc->sc_xfer[ZYD_TR_BULK_DT_RD]);
- }
- return;
-}
-
-static void
zyd_start_cb(struct ifnet *ifp)
{
struct zyd_softc *sc = ifp->if_softc;
@@ -2567,7 +2583,6 @@
mtx_lock(&(sc->sc_mtx));
usbd_transfer_start(sc->sc_xfer[ZYD_TR_BULK_DT_WR]);
mtx_unlock(&(sc->sc_mtx));
-
return;
}
@@ -2775,18 +2790,13 @@
{
struct zyd_softc *sc = ifp->if_softc;
struct ieee80211com *ic = ifp->if_l2com;
- int error = 0;
+ int error;
switch (cmd) {
case SIOCSIFFLAGS:
-
mtx_lock(&(sc->sc_mtx));
if (ifp->if_flags & IFF_UP) {
- if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
- usbd_config_td_queue_command
- (&(sc->sc_config_td), &zyd_config_copy,
- &zyd_cfg_update_promisc, 0, 0);
- } else {
+ if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
usbd_config_td_queue_command
(&(sc->sc_config_td), &zyd_cfg_pre_init,
&zyd_cfg_init, 0, 0);
@@ -2799,6 +2809,7 @@
}
}
mtx_unlock(&(sc->sc_mtx));
+ error = 0;
break;
case SIOCGIFMEDIA:
@@ -2811,8 +2822,6 @@
error = ether_ioctl(ifp, cmd, data);
break;
}
- if (!error)
- ieee80211_start_all(ic);
return (error);
}
@@ -2934,7 +2943,8 @@
{
sc->sc_flags &= ~ZYD_FLAG_WAIT_COMMAND;
- zyd_start_transfers(sc);
+ /* start write transfer, if not started */
+ usbd_transfer_start(sc->sc_xfer[0]);
return;
}
==== //depot/projects/usb/src/sys/dev/usb/if_zydreg.h#16 (text+ko) ====
@@ -1218,13 +1218,10 @@
struct zyd_softc {
void *sc_evilhack; /* XXX this pointer must be first */
- struct ieee80211_amrr sc_amrr;
- struct ieee80211com sc_ic;
struct zyd_rf sc_rf;
struct usb_callout sc_watchdog;
struct mtx sc_mtx;
struct usbd_config_td sc_config_td;
- struct ieee80211_beacon_offsets sc_bo;
struct zyd_rx_radiotap_header sc_rxtap;
struct zyd_tx_radiotap_header sc_txtap;
struct zyd_cmd sc_intr_ibuf;
@@ -1233,11 +1230,8 @@
struct zyd_ifq sc_tx_queue;
struct ifnet *sc_ifp;
- int (*sc_newstate) (struct ieee80211com *,
- enum ieee80211_state, int);
struct usbd_device *sc_udev;
struct usbd_xfer *sc_xfer[ZYD_N_TRANSFER];
- struct bpf_if *sc_drvbpf;
const struct ieee80211_rate_table *sc_rates;
enum ieee80211_state sc_ns_state;
@@ -1280,4 +1274,5 @@
uint8_t sc_amrr_timer;
uint8_t sc_name[16];
+ uint8_t sc_myaddr[IEEE80211_ADDR_LEN];
};
More information about the p4-projects
mailing list