Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/usb/wlan/if_run.c
Context not available. | |||||
static SYSCTL_NODE(_hw_usb, OID_AUTO, run, CTLFLAG_RW, 0, "USB run"); | static SYSCTL_NODE(_hw_usb, OID_AUTO, run, CTLFLAG_RW, 0, "USB run"); | ||||
SYSCTL_INT(_hw_usb_run, OID_AUTO, debug, CTLFLAG_RWTUN, &run_debug, 0, | SYSCTL_INT(_hw_usb_run, OID_AUTO, debug, CTLFLAG_RWTUN, &run_debug, 0, | ||||
"run debug level"); | "run debug level"); | ||||
enum { | |||||
RUN_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ | |||||
RUN_DEBUG_XMIT_DESC = 0x00000002, /* xmit descriptors */ | |||||
RUN_DEBUG_RECV = 0x00000004, /* basic recv operation */ | |||||
RUN_DEBUG_RECV_DESC = 0x00000008, /* recv descriptors */ | |||||
RUN_DEBUG_STATE = 0x00000010, /* 802.11 state transitions */ | |||||
RUN_DEBUG_RATE = 0x00000020, /* rate adaptation */ | |||||
RUN_DEBUG_USB = 0x00000040, /* usb requests */ | |||||
RUN_DEBUG_FIRMWARE = 0x00000080, /* firmware(9) loading debug */ | |||||
RUN_DEBUG_BEACON = 0x00000100, /* beacon handling */ | |||||
RUN_DEBUG_INTR = 0x00000200, /* ISR */ | |||||
RUN_DEBUG_TEMP = 0x00000400, /* temperature calibration */ | |||||
RUN_DEBUG_ROM = 0x00000800, /* various ROM info */ | |||||
RUN_DEBUG_KEY = 0x00001000, /* crypto keys management */ | |||||
RUN_DEBUG_TXPWR = 0x00002000, /* dump Tx power values */ | |||||
RUN_DEBUG_RSSI = 0x00004000, /* dump RSSI lookups */ | |||||
RUN_DEBUG_RESET = 0x00008000, /* initialization progress */ | |||||
RUN_DEBUG_CALIB = 0x00010000, /* calibration progress */ | |||||
RUN_DEBUG_CMD = 0x00010000, /* command queue */ | |||||
RUN_DEBUG_ANY = 0xffffffff | |||||
}; | |||||
#define RUN_DPRINTF(_sc, _m, ...) do { \ | |||||
if (run_debug & (_m)) \ | |||||
device_printf((_sc)->sc_dev, __VA_ARGS__); \ | |||||
} while(0) | |||||
#else | |||||
#define RUN_DPRINTF(_sc, _m, ...) do { (void) _sc; } while (0) | |||||
#endif | #endif | ||||
#define IEEE80211_HAS_ADDR4(wh) IEEE80211_IS_DSTODS(wh) | #define IEEE80211_HAS_ADDR4(wh) IEEE80211_IS_DSTODS(wh) | ||||
Context not available. | |||||
if (opmode == IEEE80211_M_HOSTAP) | if (opmode == IEEE80211_M_HOSTAP) | ||||
sc->cmdq_run = RUN_CMDQ_GO; | sc->cmdq_run = RUN_CMDQ_GO; | ||||
DPRINTF("rvp_id=%d bmap=%x rvp_cnt=%d\n", | RUN_DPRINTF(sc, RUN_DEBUG_STATE, "rvp_id=%d bmap=%x rvp_cnt=%d\n", | ||||
rvp->rvp_id, sc->rvp_bmap, sc->rvp_cnt); | rvp->rvp_id, sc->rvp_bmap, sc->rvp_cnt); | ||||
return (vap); | return (vap); | ||||
Context not available. | |||||
run_set_region_4(sc, RT2860_BCN_BASE(rvp_id), 0, 512); | run_set_region_4(sc, RT2860_BCN_BASE(rvp_id), 0, 512); | ||||
--sc->rvp_cnt; | --sc->rvp_cnt; | ||||
DPRINTF("vap=%p rvp_id=%d bmap=%x rvp_cnt=%d\n", | RUN_DPRINTF(sc, RUN_DEBUG_STATE, | ||||
"vap=%p rvp_id=%d bmap=%x rvp_cnt=%d\n", | |||||
vap, rvp_id, sc->rvp_bmap, sc->rvp_cnt); | vap, rvp_id, sc->rvp_bmap, sc->rvp_cnt); | ||||
RUN_UNLOCK(sc); | RUN_UNLOCK(sc); | ||||
Context not available. | |||||
RUN_LOCK(sc); | RUN_LOCK(sc); | ||||
for (i = sc->cmdq_exec; sc->cmdq[i].func && pending; | for (i = sc->cmdq_exec; sc->cmdq[i].func && pending; | ||||
i = sc->cmdq_exec, pending--) { | i = sc->cmdq_exec, pending--) { | ||||
DPRINTFN(6, "cmdq_exec=%d pending=%d\n", i, pending); | RUN_DPRINTF(sc, RUN_DEBUG_CMD, "cmdq_exec=%d pending=%d\n", | ||||
i, pending); | |||||
if (sc->cmdq_run == RUN_CMDQ_GO) { | if (sc->cmdq_run == RUN_CMDQ_GO) { | ||||
/* | /* | ||||
* If arg0 is NULL, callback func needs more | * If arg0 is NULL, callback func needs more | ||||
Context not available. | |||||
req, data, 0, NULL, 250 /* ms */); | req, data, 0, NULL, 250 /* ms */); | ||||
if (err == 0) | if (err == 0) | ||||
break; | break; | ||||
DPRINTFN(1, "Control request failed, %s (retrying)\n", | RUN_DPRINTF(sc, RUN_DEBUG_USB, | ||||
"Control request failed, %s (retrying)\n", | |||||
usbd_errstr(err)); | usbd_errstr(err)); | ||||
run_delay(sc, 10); | run_delay(sc, 10); | ||||
} | } | ||||
Context not available. | |||||
if (sc->txpow2[i] < 0 || sc->txpow2[i] > 31) | if (sc->txpow2[i] < 0 || sc->txpow2[i] > 31) | ||||
sc->txpow2[i] = 5; | sc->txpow2[i] = 5; | ||||
} | } | ||||
DPRINTF("chan %d: power1=%d, power2=%d\n", | RUN_DPRINTF(sc, RUN_DEBUG_TXPWR, | ||||
"chan %d: power1=%d, power2=%d\n", | |||||
rt2860_rf2850[i].chan, sc->txpow1[i], sc->txpow2[i]); | rt2860_rf2850[i].chan, sc->txpow1[i], sc->txpow2[i]); | ||||
} | } | ||||
/* Read power settings for 5GHz channels. */ | /* Read power settings for 5GHz channels. */ | ||||
Context not available. | |||||
if (sc->txpow2[14 + i] < -7 || sc->txpow2[14 + i] > 15) | if (sc->txpow2[14 + i] < -7 || sc->txpow2[14 + i] > 15) | ||||
sc->txpow2[14 + i] = 5; | sc->txpow2[14 + i] = 5; | ||||
} | } | ||||
DPRINTF("chan %d: power1=%d, power2=%d\n", | RUN_DPRINTF(sc, RUN_DEBUG_TXPWR, | ||||
"chan %d: power1=%d, power2=%d\n", | |||||
rt2860_rf2850[14 + i].chan, sc->txpow1[14 + i], | rt2860_rf2850[14 + i].chan, sc->txpow1[14 + i], | ||||
sc->txpow2[14 + i]); | sc->txpow2[14 + i]); | ||||
} | } | ||||
Context not available. | |||||
sc->sc_srom_read = run_eeprom_read_2; | sc->sc_srom_read = run_eeprom_read_2; | ||||
if (sc->mac_ver >= 0x3070) { | if (sc->mac_ver >= 0x3070) { | ||||
run_read(sc, RT3070_EFUSE_CTRL, &tmp); | run_read(sc, RT3070_EFUSE_CTRL, &tmp); | ||||
DPRINTF("EFUSE_CTRL=0x%08x\n", tmp); | RUN_DPRINTF(sc, RUN_DEBUG_ROM, "EFUSE_CTRL=0x%08x\n", tmp); | ||||
if ((tmp & RT3070_SEL_EFUSE) || sc->mac_ver == 0x3593) | if ((tmp & RT3070_SEL_EFUSE) || sc->mac_ver == 0x3593) | ||||
sc->sc_srom_read = run_efuse_read_2; | sc->sc_srom_read = run_efuse_read_2; | ||||
} | } | ||||
Context not available. | |||||
/* read ROM version */ | /* read ROM version */ | ||||
run_srom_read(sc, RT2860_EEPROM_VERSION, &val); | run_srom_read(sc, RT2860_EEPROM_VERSION, &val); | ||||
DPRINTF("EEPROM rev=%d, FAE=%d\n", val >> 8, val & 0xff); | RUN_DPRINTF(sc, RUN_DEBUG_ROM, | ||||
"EEPROM rev=%d, FAE=%d\n", val >> 8, val & 0xff); | |||||
/* read MAC address */ | /* read MAC address */ | ||||
run_srom_read(sc, RT2860_EEPROM_MAC01, &val); | run_srom_read(sc, RT2860_EEPROM_MAC01, &val); | ||||
Context not available. | |||||
run_srom_read(sc, RT2860_EEPROM_BBP_BASE + i, &val); | run_srom_read(sc, RT2860_EEPROM_BBP_BASE + i, &val); | ||||
sc->bbp[i].val = val & 0xff; | sc->bbp[i].val = val & 0xff; | ||||
sc->bbp[i].reg = val >> 8; | sc->bbp[i].reg = val >> 8; | ||||
DPRINTF("BBP%d=0x%02x\n", sc->bbp[i].reg, | RUN_DPRINTF(sc, RUN_DEBUG_ROM, | ||||
sc->bbp[i].val); | "BBP%d=0x%02x\n", sc->bbp[i].reg, sc->bbp[i].val); | ||||
} | } | ||||
if (sc->mac_ver >= 0x3071) { | if (sc->mac_ver >= 0x3071) { | ||||
/* read vendor RF settings */ | /* read vendor RF settings */ | ||||
Context not available. | |||||
&val); | &val); | ||||
sc->rf[i].val = val & 0xff; | sc->rf[i].val = val & 0xff; | ||||
sc->rf[i].reg = val >> 8; | sc->rf[i].reg = val >> 8; | ||||
DPRINTF("RF%d=0x%02x\n", sc->rf[i].reg, | RUN_DPRINTF(sc, RUN_DEBUG_ROM, "RF%d=0x%02x\n", | ||||
sc->rf[i].val); | sc->rf[i].reg, sc->rf[i].val); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_FREQ_LEDS : | run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_FREQ_LEDS : | ||||
RT3593_EEPROM_FREQ, &val); | RT3593_EEPROM_FREQ, &val); | ||||
sc->freq = ((val & 0xff) != 0xff) ? val & 0xff : 0; | sc->freq = ((val & 0xff) != 0xff) ? val & 0xff : 0; | ||||
DPRINTF("EEPROM freq offset %d\n", sc->freq & 0xff); | RUN_DPRINTF(sc, RUN_DEBUG_ROM, "EEPROM freq offset %d\n", | ||||
sc->freq & 0xff); | |||||
run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_FREQ_LEDS : | run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_FREQ_LEDS : | ||||
RT3593_EEPROM_FREQ_LEDS, &val); | RT3593_EEPROM_FREQ_LEDS, &val); | ||||
Context not available. | |||||
sc->led[1] = 0x2221; | sc->led[1] = 0x2221; | ||||
sc->led[2] = 0x5627; /* differs from RT2860 */ | sc->led[2] = 0x5627; /* differs from RT2860 */ | ||||
} | } | ||||
DPRINTF("EEPROM LED mode=0x%02x, LEDs=0x%04x/0x%04x/0x%04x\n", | RUN_DPRINTF(sc, RUN_DEBUG_ROM, | ||||
"EEPROM LED mode=0x%02x, LEDs=0x%04x/0x%04x/0x%04x\n", | |||||
sc->leds, sc->led[0], sc->led[1], sc->led[2]); | sc->leds, sc->led[0], sc->led[1], sc->led[2]); | ||||
/* read RF information */ | /* read RF information */ | ||||
Context not available. | |||||
if (val == 0xffff) { | if (val == 0xffff) { | ||||
device_printf(sc->sc_dev, | device_printf(sc->sc_dev, | ||||
"invalid EEPROM antenna info, using default\n"); | "invalid EEPROM antenna info, using default\n"); | ||||
DPRINTF("invalid EEPROM antenna info, using default\n"); | |||||
if (sc->mac_ver == 0x3572) { | if (sc->mac_ver == 0x3572) { | ||||
/* default to RF3052 2T2R */ | /* default to RF3052 2T2R */ | ||||
sc->rf_rev = RT3070_RF_3052; | sc->rf_rev = RT3070_RF_3052; | ||||
Context not available. | |||||
sc->ntxchains = (val >> 4) & 0xf; | sc->ntxchains = (val >> 4) & 0xf; | ||||
sc->nrxchains = val & 0xf; | sc->nrxchains = val & 0xf; | ||||
} | } | ||||
DPRINTF("EEPROM RF rev=0x%04x chains=%dT%dR\n", | RUN_DPRINTF(sc, RUN_DEBUG_ROM, "EEPROM RF rev=0x%04x chains=%dT%dR\n", | ||||
sc->rf_rev, sc->ntxchains, sc->nrxchains); | sc->rf_rev, sc->ntxchains, sc->nrxchains); | ||||
/* check if RF supports automatic Tx access gain control */ | /* check if RF supports automatic Tx access gain control */ | ||||
run_srom_read(sc, RT2860_EEPROM_CONFIG, &val); | run_srom_read(sc, RT2860_EEPROM_CONFIG, &val); | ||||
DPRINTF("EEPROM CFG 0x%04x\n", val); | RUN_DPRINTF(sc, RUN_DEBUG_ROM, "EEPROM CFG 0x%04x\n", val); | ||||
/* check if driver should patch the DAC issue */ | /* check if driver should patch the DAC issue */ | ||||
if ((val >> 8) != 0xff) | if ((val >> 8) != 0xff) | ||||
sc->patch_dac = (val >> 15) & 1; | sc->patch_dac = (val >> 15) & 1; | ||||
Context not available. | |||||
if (!(val & 0x40)) /* negative number */ | if (!(val & 0x40)) /* negative number */ | ||||
delta_5ghz = -delta_5ghz; | delta_5ghz = -delta_5ghz; | ||||
} | } | ||||
DPRINTF("power compensation=%d (2GHz), %d (5GHz)\n", | RUN_DPRINTF(sc, RUN_DEBUG_ROM | RUN_DEBUG_TXPWR, | ||||
delta_2ghz, delta_5ghz); | "power compensation=%d (2GHz), %d (5GHz)\n", delta_2ghz, delta_5ghz); | ||||
for (ridx = 0; ridx < 5; ridx++) { | for (ridx = 0; ridx < 5; ridx++) { | ||||
uint32_t reg; | uint32_t reg; | ||||
Context not available. | |||||
sc->txpow40mhz_2ghz[ridx] = b4inc(reg, delta_2ghz); | sc->txpow40mhz_2ghz[ridx] = b4inc(reg, delta_2ghz); | ||||
sc->txpow40mhz_5ghz[ridx] = b4inc(reg, delta_5ghz); | sc->txpow40mhz_5ghz[ridx] = b4inc(reg, delta_5ghz); | ||||
DPRINTF("ridx %d: power 20MHz=0x%08x, 40MHz/2GHz=0x%08x, " | RUN_DPRINTF(sc, RUN_DEBUG_ROM | RUN_DEBUG_TXPWR, | ||||
"ridx %d: power 20MHz=0x%08x, 40MHz/2GHz=0x%08x, " | |||||
"40MHz/5GHz=0x%08x\n", ridx, sc->txpow20mhz[ridx], | "40MHz/5GHz=0x%08x\n", ridx, sc->txpow20mhz[ridx], | ||||
sc->txpow40mhz_2ghz[ridx], sc->txpow40mhz_5ghz[ridx]); | sc->txpow40mhz_2ghz[ridx], sc->txpow40mhz_5ghz[ridx]); | ||||
} | } | ||||
Context not available. | |||||
if ((val & 0xff) != 0xff) | if ((val & 0xff) != 0xff) | ||||
sc->txmixgain_2ghz = val & 0x7; | sc->txmixgain_2ghz = val & 0x7; | ||||
} | } | ||||
DPRINTF("tx mixer gain=%u (2GHz)\n", sc->txmixgain_2ghz); | RUN_DPRINTF(sc, RUN_DEBUG_ROM, "tx mixer gain=%u (2GHz)\n", | ||||
sc->txmixgain_2ghz); | |||||
} else | } else | ||||
sc->rssi_2ghz[2] = val & 0xff; /* Ant C */ | sc->rssi_2ghz[2] = val & 0xff; /* Ant C */ | ||||
if (sc->mac_ver == 0x3593) | if (sc->mac_ver == 0x3593) | ||||
Context not available. | |||||
*/ | */ | ||||
if ((val & 0xff) != 0xff) | if ((val & 0xff) != 0xff) | ||||
sc->txmixgain_5ghz = val & 0x7; | sc->txmixgain_5ghz = val & 0x7; | ||||
DPRINTF("tx mixer gain=%u (5GHz)\n", sc->txmixgain_5ghz); | RUN_DPRINTF(sc, RUN_DEBUG_ROM, "tx mixer gain=%u (5GHz)\n", | ||||
sc->txmixgain_5ghz); | |||||
} else | } else | ||||
sc->rssi_5ghz[2] = val & 0xff; /* Ant C */ | sc->rssi_5ghz[2] = val & 0xff; /* Ant C */ | ||||
if (sc->mac_ver == 0x3593) { | if (sc->mac_ver == 0x3593) { | ||||
Context not available. | |||||
/* fix broken 5GHz LNA entries */ | /* fix broken 5GHz LNA entries */ | ||||
if (sc->lna[2] == 0 || sc->lna[2] == 0xff) { | if (sc->lna[2] == 0 || sc->lna[2] == 0xff) { | ||||
DPRINTF("invalid LNA for channel group %d\n", 2); | RUN_DPRINTF(sc, RUN_DEBUG_ROM, | ||||
"invalid LNA for channel group %d\n", 2); | |||||
sc->lna[2] = sc->lna[1]; | sc->lna[2] = sc->lna[1]; | ||||
} | } | ||||
if (sc->lna[3] == 0 || sc->lna[3] == 0xff) { | if (sc->lna[3] == 0 || sc->lna[3] == 0xff) { | ||||
DPRINTF("invalid LNA for channel group %d\n", 3); | RUN_DPRINTF(sc, RUN_DEBUG_ROM, | ||||
"invalid LNA for channel group %d\n", 3); | |||||
sc->lna[3] = sc->lna[1]; | sc->lna[3] = sc->lna[1]; | ||||
} | } | ||||
Context not available. | |||||
/* fix broken RSSI offset entries */ | /* fix broken RSSI offset entries */ | ||||
for (ant = 0; ant < 3; ant++) { | for (ant = 0; ant < 3; ant++) { | ||||
if (sc->rssi_2ghz[ant] < -10 || sc->rssi_2ghz[ant] > 10) { | if (sc->rssi_2ghz[ant] < -10 || sc->rssi_2ghz[ant] > 10) { | ||||
DPRINTF("invalid RSSI%d offset: %d (2GHz)\n", | RUN_DPRINTF(sc, RUN_DEBUG_ROM | RUN_DEBUG_RSSI, | ||||
"invalid RSSI%d offset: %d (2GHz)\n", | |||||
ant + 1, sc->rssi_2ghz[ant]); | ant + 1, sc->rssi_2ghz[ant]); | ||||
sc->rssi_2ghz[ant] = 0; | sc->rssi_2ghz[ant] = 0; | ||||
} | } | ||||
if (sc->rssi_5ghz[ant] < -10 || sc->rssi_5ghz[ant] > 10) { | if (sc->rssi_5ghz[ant] < -10 || sc->rssi_5ghz[ant] > 10) { | ||||
DPRINTF("invalid RSSI%d offset: %d (5GHz)\n", | RUN_DPRINTF(sc, RUN_DEBUG_ROM | RUN_DEBUG_RSSI, | ||||
"invalid RSSI%d offset: %d (5GHz)\n", | |||||
ant + 1, sc->rssi_5ghz[ant]); | ant + 1, sc->rssi_5ghz[ant]); | ||||
sc->rssi_5ghz[ant] = 0; | sc->rssi_5ghz[ant] = 0; | ||||
} | } | ||||
Context not available. | |||||
ni = ieee80211_ref_node(vap->iv_bss); | ni = ieee80211_ref_node(vap->iv_bss); | ||||
rn = RUN_NODE(ni); | rn = RUN_NODE(ni); | ||||
rn->fix_ridx = ridx; | rn->fix_ridx = ridx; | ||||
DPRINTF("rate=%d, fix_ridx=%d\n", rate, rn->fix_ridx); | RUN_DPRINTF(sc, RUN_DEBUG_RATE, "rate=%d, fix_ridx=%d\n", | ||||
rate, rn->fix_ridx); | |||||
ieee80211_free_node(ni); | ieee80211_free_node(ni); | ||||
} | } | ||||
Context not available. | |||||
uint8_t bid = 1 << rvp->rvp_id; | uint8_t bid = 1 << rvp->rvp_id; | ||||
ostate = vap->iv_state; | ostate = vap->iv_state; | ||||
DPRINTF("%s -> %s\n", | RUN_DPRINTF(sc, RUN_DEBUG_STATE, "%s -> %s\n", | ||||
ieee80211_state_name[ostate], | ieee80211_state_name[ostate], | ||||
ieee80211_state_name[nstate]); | ieee80211_state_name[nstate]); | ||||
Context not available. | |||||
break; | break; | ||||
default: | default: | ||||
DPRINTFN(6, "undefined case\n"); | RUN_DPRINTF(sc, RUN_DEBUG_STATE, "undefined state\n"); | ||||
break; | break; | ||||
} | } | ||||
Context not available. | |||||
err: | err: | ||||
RUN_UNLOCK(sc); | RUN_UNLOCK(sc); | ||||
if (error) | if (error) | ||||
DPRINTF("WME update failed\n"); | RUN_DPRINTF(sc, RUN_DEBUG_USB, "WME update failed\n"); | ||||
return (error); | return (error); | ||||
} | } | ||||
Context not available. | |||||
mode = RT2860_MODE_AES_CCMP; | mode = RT2860_MODE_AES_CCMP; | ||||
break; | break; | ||||
default: | default: | ||||
DPRINTF("undefined case\n"); | RUN_DPRINTF(sc, RUN_DEBUG_KEY, "undefined case\n"); | ||||
return; | return; | ||||
} | } | ||||
DPRINTFN(1, "associd=%x, keyix=%d, mode=%x, type=%s, tx=%s, rx=%s\n", | RUN_DPRINTF(sc, RUN_DEBUG_KEY, | ||||
"associd=%x, keyix=%d, mode=%x, type=%s, tx=%s, rx=%s\n", | |||||
associd, k->wk_keyix, mode, | associd, k->wk_keyix, mode, | ||||
(k->wk_flags & IEEE80211_KEY_GROUP) ? "group" : "pairwise", | (k->wk_flags & IEEE80211_KEY_GROUP) ? "group" : "pairwise", | ||||
(k->wk_flags & IEEE80211_KEY_XMIT) ? "on" : "off", | (k->wk_flags & IEEE80211_KEY_XMIT) ? "on" : "off", | ||||
Context not available. | |||||
uint32_t i; | uint32_t i; | ||||
i = RUN_CMDQ_GET(&sc->cmdq_store); | i = RUN_CMDQ_GET(&sc->cmdq_store); | ||||
DPRINTF("cmdq_store=%d\n", i); | RUN_DPRINTF(sc, RUN_DEBUG_KEY, "cmdq_store=%d\n", i); | ||||
sc->cmdq[i].func = run_key_set_cb; | sc->cmdq[i].func = run_key_set_cb; | ||||
sc->cmdq[i].arg0 = NULL; | sc->cmdq[i].arg0 = NULL; | ||||
sc->cmdq[i].arg1 = vap; | sc->cmdq[i].arg1 = vap; | ||||
Context not available. | |||||
if (k->wk_flags & IEEE80211_KEY_GROUP) { | if (k->wk_flags & IEEE80211_KEY_GROUP) { | ||||
/* remove group key */ | /* remove group key */ | ||||
DPRINTF("removing group key\n"); | RUN_DPRINTF(sc, RUN_DEBUG_KEY, "removing group key\n"); | ||||
run_read(sc, RT2860_SKEY_MODE_0_7, &attr); | run_read(sc, RT2860_SKEY_MODE_0_7, &attr); | ||||
attr &= ~(0xf << (k->wk_keyix * 4)); | attr &= ~(0xf << (k->wk_keyix * 4)); | ||||
run_write(sc, RT2860_SKEY_MODE_0_7, attr); | run_write(sc, RT2860_SKEY_MODE_0_7, attr); | ||||
} else { | } else { | ||||
/* remove pairwise key */ | /* remove pairwise key */ | ||||
DPRINTF("removing key for wcid %x\n", k->wk_pad); | RUN_DPRINTF(sc, RUN_DEBUG_KEY, | ||||
"removing key for wcid %x\n", k->wk_pad); | |||||
/* matching wcid was written to wk_pad in run_key_set() */ | /* matching wcid was written to wk_pad in run_key_set() */ | ||||
wcid = k->wk_pad; | wcid = k->wk_pad; | ||||
run_read(sc, RT2860_WCID_ATTR(wcid), &attr); | run_read(sc, RT2860_WCID_ATTR(wcid), &attr); | ||||
Context not available. | |||||
* So, use atomic instead. | * So, use atomic instead. | ||||
*/ | */ | ||||
i = RUN_CMDQ_GET(&sc->cmdq_store); | i = RUN_CMDQ_GET(&sc->cmdq_store); | ||||
DPRINTF("cmdq_store=%d\n", i); | RUN_DPRINTF(sc, RUN_DEBUG_KEY, "cmdq_store=%d\n", i); | ||||
sc->cmdq[i].func = run_key_delete_cb; | sc->cmdq[i].func = run_key_delete_cb; | ||||
sc->cmdq[i].arg0 = NULL; | sc->cmdq[i].arg0 = NULL; | ||||
sc->cmdq[i].arg1 = sc; | sc->cmdq[i].arg1 = sc; | ||||
Context not available. | |||||
for (;;) { | for (;;) { | ||||
/* drain Tx status FIFO (maxsize = 16) */ | /* drain Tx status FIFO (maxsize = 16) */ | ||||
run_read(sc, RT2860_TX_STAT_FIFO, &stat); | run_read(sc, RT2860_TX_STAT_FIFO, &stat); | ||||
DPRINTFN(4, "tx stat 0x%08x\n", stat); | RUN_DPRINTF(sc, RUN_DEBUG_XMIT, "tx stat 0x%08x\n", stat); | ||||
if (!(stat & RT2860_TXQ_VLD)) | if (!(stat & RT2860_TXQ_VLD)) | ||||
break; | break; | ||||
Context not available. | |||||
(*wstat)[RUN_RETRY] += retry; | (*wstat)[RUN_RETRY] += retry; | ||||
} | } | ||||
} | } | ||||
DPRINTFN(3, "count=%d\n", sc->fifo_cnt); | RUN_DPRINTF(sc, RUN_DEBUG_XMIT, "count=%d\n", sc->fifo_cnt); | ||||
sc->fifo_cnt = 0; | sc->fifo_cnt = 0; | ||||
} | } | ||||
Context not available. | |||||
txs->nframes = txs->nretries + txs->nsuccess + | txs->nframes = txs->nretries + txs->nsuccess + | ||||
le16toh(sta[0].error.fail); | le16toh(sta[0].error.fail); | ||||
DPRINTFN(3, "retrycnt=%d success=%d failcnt=%d\n", | RUN_DPRINTF(sc, RUN_DEBUG_RATE, | ||||
txs->nretries, txs->nsuccess, | "retrycnt=%d success=%d failcnt=%d\n", | ||||
le16toh(sta[0].error.fail)); | txs->nretries, txs->nsuccess, le16toh(sta[0].error.fail)); | ||||
} else { | } else { | ||||
wstat = &(sc->wcid_stats[RUN_AID2WCID(ni->ni_associd)]); | wstat = &(sc->wcid_stats[RUN_AID2WCID(ni->ni_associd)]); | ||||
Context not available. | |||||
txs->nretries = (*wstat)[RUN_RETRY]; | txs->nretries = (*wstat)[RUN_RETRY]; | ||||
txs->nsuccess = (*wstat)[RUN_SUCCESS]; | txs->nsuccess = (*wstat)[RUN_SUCCESS]; | ||||
txs->nframes = (*wstat)[RUN_TXCNT]; | txs->nframes = (*wstat)[RUN_TXCNT]; | ||||
DPRINTFN(3, "retrycnt=%d txcnt=%d success=%d\n", | RUN_DPRINTF(sc, RUN_DEBUG_RATE, | ||||
"retrycnt=%d txcnt=%d success=%d\n", | |||||
txs->nretries, txs->nframes, txs->nsuccess); | txs->nretries, txs->nframes, txs->nsuccess); | ||||
memset(wstat, 0, sizeof(*wstat)); | memset(wstat, 0, sizeof(*wstat)); | ||||
Context not available. | |||||
fail: | fail: | ||||
RUN_UNLOCK(sc); | RUN_UNLOCK(sc); | ||||
DPRINTFN(3, "ridx=%d\n", rn->amrr_ridx); | RUN_DPRINTF(sc, RUN_DEBUG_RATE, "ridx=%d\n", rn->amrr_ridx); | ||||
} | } | ||||
static void | static void | ||||
Context not available. | |||||
* Need to defer. | * Need to defer. | ||||
*/ | */ | ||||
uint32_t cnt = RUN_CMDQ_GET(&sc->cmdq_store); | uint32_t cnt = RUN_CMDQ_GET(&sc->cmdq_store); | ||||
DPRINTF("cmdq_store=%d\n", cnt); | RUN_DPRINTF(sc, RUN_DEBUG_STATE, "cmdq_store=%d\n", cnt); | ||||
sc->cmdq[cnt].func = run_newassoc_cb; | sc->cmdq[cnt].func = run_newassoc_cb; | ||||
sc->cmdq[cnt].arg0 = NULL; | sc->cmdq[cnt].arg0 = NULL; | ||||
sc->cmdq[cnt].arg1 = ni; | sc->cmdq[cnt].arg1 = ni; | ||||
Context not available. | |||||
ieee80211_runtask(ic, &sc->cmdq_task); | ieee80211_runtask(ic, &sc->cmdq_task); | ||||
} | } | ||||
DPRINTF("new assoc isnew=%d associd=%x addr=%s\n", | RUN_DPRINTF(sc, RUN_DEBUG_STATE, | ||||
"new assoc isnew=%d associd=%x addr=%s\n", | |||||
isnew, ni->ni_associd, ether_sprintf(ni->ni_macaddr)); | isnew, ni->ni_associd, ether_sprintf(ni->ni_macaddr)); | ||||
for (i = 0; i < rs->rs_nrates; i++) { | for (i = 0; i < rs->rs_nrates; i++) { | ||||
Context not available. | |||||
/* no basic rate found, use mandatory one */ | /* no basic rate found, use mandatory one */ | ||||
rn->ctl_ridx[i] = rt2860_rates[ridx].ctl_ridx; | rn->ctl_ridx[i] = rt2860_rates[ridx].ctl_ridx; | ||||
} | } | ||||
DPRINTF("rate=0x%02x ridx=%d ctl_ridx=%d\n", | RUN_DPRINTF(sc, RUN_DEBUG_STATE | RUN_DEBUG_RATE, | ||||
"rate=0x%02x ridx=%d ctl_ridx=%d\n", | |||||
rs->rs_rates[i], rn->ridx[i], rn->ctl_ridx[i]); | rs->rs_rates[i], rn->ridx[i], rn->ctl_ridx[i]); | ||||
} | } | ||||
rate = vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)].mgmtrate; | rate = vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)].mgmtrate; | ||||
Context not available. | |||||
if (rt2860_rates[ridx].rate == rate) | if (rt2860_rates[ridx].rate == rate) | ||||
break; | break; | ||||
rn->mgt_ridx = ridx; | rn->mgt_ridx = ridx; | ||||
DPRINTF("rate=%d, mgmt_ridx=%d\n", rate, rn->mgt_ridx); | RUN_DPRINTF(sc, RUN_DEBUG_STATE | RUN_DEBUG_RATE, | ||||
"rate=%d, mgmt_ridx=%d\n", rate, rn->mgt_ridx); | |||||
RUN_LOCK(sc); | RUN_LOCK(sc); | ||||
if(sc->ratectl_run != RUN_RATECTL_OFF) | if(sc->ratectl_run != RUN_RATECTL_OFF) | ||||
Context not available. | |||||
rx_tstamp = le64toh(rx_tstamp); | rx_tstamp = le64toh(rx_tstamp); | ||||
if (ni_tstamp >= rx_tstamp) { | if (ni_tstamp >= rx_tstamp) { | ||||
DPRINTF("ibss merge, tsf %ju tstamp %ju\n", | RUN_DPRINTF(sc, RUN_DEBUG_RECV | RUN_DEBUG_BEACON, | ||||
"ibss merge, tsf %ju tstamp %ju\n", | |||||
(uintmax_t)rx_tstamp, (uintmax_t)ni_tstamp); | (uintmax_t)rx_tstamp, (uintmax_t)ni_tstamp); | ||||
(void) ieee80211_ibss_merge(ni); | (void) ieee80211_ibss_merge(ni); | ||||
} | } | ||||
Context not available. | |||||
if (__predict_false(len > dmalen)) { | if (__predict_false(len > dmalen)) { | ||||
m_freem(m); | m_freem(m); | ||||
counter_u64_add(ic->ic_ierrors, 1); | counter_u64_add(ic->ic_ierrors, 1); | ||||
DPRINTF("bad RXWI length %u > %u\n", len, dmalen); | RUN_DPRINTF(sc, RUN_DEBUG_RECV, | ||||
"bad RXWI length %u > %u\n", len, dmalen); | |||||
return; | return; | ||||
} | } | ||||
/* Rx descriptor is located at the end */ | /* Rx descriptor is located at the end */ | ||||
Context not available. | |||||
if (__predict_false(flags & (RT2860_RX_CRCERR | RT2860_RX_ICVERR))) { | if (__predict_false(flags & (RT2860_RX_CRCERR | RT2860_RX_ICVERR))) { | ||||
m_freem(m); | m_freem(m); | ||||
counter_u64_add(ic->ic_ierrors, 1); | counter_u64_add(ic->ic_ierrors, 1); | ||||
DPRINTF("%s error.\n", (flags & RT2860_RX_CRCERR)?"CRC":"ICV"); | RUN_DPRINTF(sc, RUN_DEBUG_RECV, "%s error.\n", | ||||
(flags & RT2860_RX_CRCERR)?"CRC":"ICV"); | |||||
return; | return; | ||||
} | } | ||||
Context not available. | |||||
} | } | ||||
if (flags & RT2860_RX_L2PAD) { | if (flags & RT2860_RX_L2PAD) { | ||||
DPRINTFN(8, "received RT2860_RX_L2PAD frame\n"); | RUN_DPRINTF(sc, RUN_DEBUG_RECV, | ||||
"received RT2860_RX_L2PAD frame\n"); | |||||
len += 2; | len += 2; | ||||
} | } | ||||
Context not available. | |||||
rxwi->keyidx); | rxwi->keyidx); | ||||
m_freem(m); | m_freem(m); | ||||
counter_u64_add(ic->ic_ierrors, 1); | counter_u64_add(ic->ic_ierrors, 1); | ||||
DPRINTF("MIC error. Someone is lying.\n"); | RUN_DPRINTF(sc, RUN_DEBUG_RECV, | ||||
"MIC error. Someone is lying.\n"); | |||||
return; | return; | ||||
} | } | ||||
Context not available. | |||||
switch (USB_GET_STATE(xfer)) { | switch (USB_GET_STATE(xfer)) { | ||||
case USB_ST_TRANSFERRED: | case USB_ST_TRANSFERRED: | ||||
DPRINTFN(15, "rx done, actlen=%d\n", xferlen); | RUN_DPRINTF(sc, RUN_DEBUG_RECV, | ||||
"rx done, actlen=%d\n", xferlen); | |||||
if (xferlen < (int)(sizeof(uint32_t) + rxwisize + | if (xferlen < (int)(sizeof(uint32_t) + rxwisize + | ||||
sizeof(struct rt2870_rxd))) { | sizeof(struct rt2870_rxd))) { | ||||
DPRINTF("xfer too short %d\n", xferlen); | RUN_DPRINTF(sc, RUN_DEBUG_RECV_DESC | RUN_DEBUG_USB, | ||||
"xfer too short %d\n", xferlen); | |||||
goto tr_setup; | goto tr_setup; | ||||
} | } | ||||
Context not available. | |||||
MJUMPAGESIZE /* xfer can be bigger than MCLBYTES */); | MJUMPAGESIZE /* xfer can be bigger than MCLBYTES */); | ||||
} | } | ||||
if (sc->rx_m == NULL) { | if (sc->rx_m == NULL) { | ||||
DPRINTF("could not allocate mbuf - idle with stall\n"); | RUN_DPRINTF(sc, RUN_DEBUG_RECV | RUN_DEBUG_RECV_DESC, | ||||
"could not allocate mbuf - idle with stall\n"); | |||||
counter_u64_add(ic->ic_ierrors, 1); | counter_u64_add(ic->ic_ierrors, 1); | ||||
usbd_xfer_set_stall(xfer); | usbd_xfer_set_stall(xfer); | ||||
usbd_xfer_set_frames(xfer, 0); | usbd_xfer_set_frames(xfer, 0); | ||||
Context not available. | |||||
if ((dmalen >= (uint32_t)-8) || (dmalen == 0) || | if ((dmalen >= (uint32_t)-8) || (dmalen == 0) || | ||||
((dmalen & 3) != 0)) { | ((dmalen & 3) != 0)) { | ||||
DPRINTF("bad DMA length %u\n", dmalen); | RUN_DPRINTF(sc, RUN_DEBUG_RECV_DESC | RUN_DEBUG_USB, | ||||
"bad DMA length %u\n", dmalen); | |||||
break; | break; | ||||
} | } | ||||
if ((dmalen + 8) > (uint32_t)xferlen) { | if ((dmalen + 8) > (uint32_t)xferlen) { | ||||
DPRINTF("bad DMA length %u > %d\n", | RUN_DPRINTF(sc, RUN_DEBUG_RECV_DESC | RUN_DEBUG_USB, | ||||
"bad DMA length %u > %d\n", | |||||
dmalen + 8, xferlen); | dmalen + 8, xferlen); | ||||
break; | break; | ||||
} | } | ||||
Context not available. | |||||
/* copy aggregated frames to another mbuf */ | /* copy aggregated frames to another mbuf */ | ||||
m0 = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); | m0 = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); | ||||
if (__predict_false(m0 == NULL)) { | if (__predict_false(m0 == NULL)) { | ||||
DPRINTF("could not allocate mbuf\n"); | RUN_DPRINTF(sc, RUN_DEBUG_RECV_DESC, | ||||
"could not allocate mbuf\n"); | |||||
counter_u64_add(ic->ic_ierrors, 1); | counter_u64_add(ic->ic_ierrors, 1); | ||||
break; | break; | ||||
} | } | ||||
Context not available. | |||||
switch (USB_GET_STATE(xfer)) { | switch (USB_GET_STATE(xfer)) { | ||||
case USB_ST_TRANSFERRED: | case USB_ST_TRANSFERRED: | ||||
DPRINTFN(11, "transfer complete: %d " | RUN_DPRINTF(sc, RUN_DEBUG_XMIT | RUN_DEBUG_USB, | ||||
"bytes @ index %d\n", actlen, index); | "transfer complete: %d bytes @ index %d\n", actlen, index); | ||||
data = usbd_xfer_get_priv(xfer); | data = usbd_xfer_get_priv(xfer); | ||||
run_tx_free(pq, data, 0); | run_tx_free(pq, data, 0); | ||||
Context not available. | |||||
sizeof(data->desc) + sizeof(uint32_t) : sizeof(data->desc); | sizeof(data->desc) + sizeof(uint32_t) : sizeof(data->desc); | ||||
if ((m->m_pkthdr.len + | if ((m->m_pkthdr.len + | ||||
size + 3 + 8) > RUN_MAX_TXSZ) { | size + 3 + 8) > RUN_MAX_TXSZ) { | ||||
DPRINTF("data overflow, %u bytes\n", | RUN_DPRINTF(sc, RUN_DEBUG_XMIT_DESC | RUN_DEBUG_USB, | ||||
m->m_pkthdr.len); | "data overflow, %u bytes\n", m->m_pkthdr.len); | ||||
run_tx_free(pq, data, 1); | run_tx_free(pq, data, 1); | ||||
goto tr_setup; | goto tr_setup; | ||||
} | } | ||||
Context not available. | |||||
ieee80211_radiotap_tx(vap, m); | ieee80211_radiotap_tx(vap, m); | ||||
} | } | ||||
DPRINTFN(11, "sending frame len=%u/%u @ index %d\n", | RUN_DPRINTF(sc, RUN_DEBUG_XMIT | RUN_DEBUG_USB, | ||||
"sending frame len=%u/%u @ index %d\n", | |||||
m->m_pkthdr.len, size, index); | m->m_pkthdr.len, size, index); | ||||
usbd_xfer_set_frame_len(xfer, 0, size); | usbd_xfer_set_frame_len(xfer, 0, size); | ||||
Context not available. | |||||
break; | break; | ||||
default: | default: | ||||
DPRINTF("USB transfer error, %s\n", | RUN_DPRINTF(sc, RUN_DEBUG_XMIT | RUN_DEBUG_USB, | ||||
usbd_errstr(error)); | "USB transfer error, %s\n", usbd_errstr(error)); | ||||
data = usbd_xfer_get_priv(xfer); | data = usbd_xfer_get_priv(xfer); | ||||
Context not available. | |||||
if (error == USB_ERR_TIMEOUT) { | if (error == USB_ERR_TIMEOUT) { | ||||
device_printf(sc->sc_dev, "device timeout\n"); | device_printf(sc->sc_dev, "device timeout\n"); | ||||
uint32_t i = RUN_CMDQ_GET(&sc->cmdq_store); | uint32_t i = RUN_CMDQ_GET(&sc->cmdq_store); | ||||
DPRINTF("cmdq_store=%d\n", i); | RUN_DPRINTF(sc, RUN_DEBUG_XMIT | RUN_DEBUG_USB, | ||||
"cmdq_store=%d\n", i); | |||||
sc->cmdq[i].func = run_usb_timeout_cb; | sc->cmdq[i].func = run_usb_timeout_cb; | ||||
sc->cmdq[i].arg0 = vap; | sc->cmdq[i].arg0 = vap; | ||||
ieee80211_runtask(ic, &sc->cmdq_task); | ieee80211_runtask(ic, &sc->cmdq_task); | ||||
Context not available. | |||||
} | } | ||||
qflags = (qid < 4) ? RT2860_TX_QSEL_EDCA : RT2860_TX_QSEL_HCCA; | qflags = (qid < 4) ? RT2860_TX_QSEL_EDCA : RT2860_TX_QSEL_HCCA; | ||||
DPRINTFN(8, "qos %d\tqid %d\ttid %d\tqflags %x\n", | RUN_DPRINTF(sc, RUN_DEBUG_XMIT, "qos %d\tqid %d\ttid %d\tqflags %x\n", | ||||
qos, qid, tid, qflags); | qos, qid, tid, qflags); | ||||
chan = (ni->ni_chan != IEEE80211_CHAN_ANYC)?ni->ni_chan:ic->ic_curchan; | chan = (ni->ni_chan != IEEE80211_CHAN_ANYC)?ni->ni_chan:ic->ic_curchan; | ||||
Context not available. | |||||
/* reserve slots for mgmt packets, just in case */ | /* reserve slots for mgmt packets, just in case */ | ||||
if (sc->sc_epq[qid].tx_nfree < 3) { | if (sc->sc_epq[qid].tx_nfree < 3) { | ||||
DPRINTFN(10, "tx ring %d is full\n", qid); | RUN_DPRINTF(sc, RUN_DEBUG_XMIT, "tx ring %d is full\n", qid); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
Context not available. | |||||
* with a non-sleepable lock, tcpinp. So, need to defer. | * with a non-sleepable lock, tcpinp. So, need to defer. | ||||
*/ | */ | ||||
uint32_t i = RUN_CMDQ_GET(&sc->cmdq_store); | uint32_t i = RUN_CMDQ_GET(&sc->cmdq_store); | ||||
DPRINTFN(6, "cmdq_store=%d\n", i); | RUN_DPRINTF(sc, RUN_DEBUG_XMIT, "cmdq_store=%d\n", i); | ||||
sc->cmdq[i].func = run_drain_fifo; | sc->cmdq[i].func = run_drain_fifo; | ||||
sc->cmdq[i].arg0 = sc; | sc->cmdq[i].arg0 = sc; | ||||
ieee80211_runtask(ic, &sc->cmdq_task); | ieee80211_runtask(ic, &sc->cmdq_task); | ||||
Context not available. | |||||
usbd_transfer_start(sc->sc_xfer[qid]); | usbd_transfer_start(sc->sc_xfer[qid]); | ||||
DPRINTFN(8, "sending data frame len=%d rate=%d qid=%d\n", | RUN_DPRINTF(sc, RUN_DEBUG_XMIT, | ||||
"sending data frame len=%d rate=%d qid=%d\n", | |||||
m->m_pkthdr.len + (int)(sizeof(struct rt2870_txd) + | m->m_pkthdr.len + (int)(sizeof(struct rt2870_txd) + | ||||
sizeof(struct rt2860_txwi)), rt2860_rates[ridx].rate, qid); | sizeof(struct rt2860_txwi)), rt2860_rates[ridx].rate, qid); | ||||
Context not available. | |||||
run_set_tx_desc(sc, data); | run_set_tx_desc(sc, data); | ||||
DPRINTFN(10, "sending mgt frame len=%d rate=%d\n", m->m_pkthdr.len + | RUN_DPRINTF(sc, RUN_DEBUG_XMIT, "sending mgt frame len=%d rate=%d\n", | ||||
(int)(sizeof(struct rt2870_txd) + sizeof(struct rt2860_txwi)), | m->m_pkthdr.len + (int)(sizeof(struct rt2870_txd) + | ||||
rt2860_rates[ridx].rate); | sizeof(struct rt2860_txwi)), rt2860_rates[ridx].rate); | ||||
STAILQ_INSERT_TAIL(&sc->sc_epq[0].tx_qh, data, next); | STAILQ_INSERT_TAIL(&sc->sc_epq[0].tx_qh, data, next); | ||||
Context not available. | |||||
} | } | ||||
if (mprot == NULL) { | if (mprot == NULL) { | ||||
if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1); | if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1); | ||||
DPRINTF("could not allocate mbuf\n"); | RUN_DPRINTF(sc, RUN_DEBUG_XMIT, "could not allocate mbuf\n"); | ||||
return (ENOBUFS); | return (ENOBUFS); | ||||
} | } | ||||
Context not available. | |||||
run_set_tx_desc(sc, data); | run_set_tx_desc(sc, data); | ||||
DPRINTFN(1, "sending prot len=%u rate=%u\n", | RUN_DPRINTF(sc, RUN_DEBUG_XMIT, "sending prot len=%u rate=%u\n", | ||||
m->m_pkthdr.len, rate); | m->m_pkthdr.len, rate); | ||||
STAILQ_INSERT_TAIL(&sc->sc_epq[0].tx_qh, data, next); | STAILQ_INSERT_TAIL(&sc->sc_epq[0].tx_qh, data, next); | ||||
Context not available. | |||||
if (sc->sc_epq[0].tx_nfree == 0) { | if (sc->sc_epq[0].tx_nfree == 0) { | ||||
/* let caller free mbuf */ | /* let caller free mbuf */ | ||||
DPRINTF("sending raw frame, but tx ring is full\n"); | RUN_DPRINTF(sc, RUN_DEBUG_XMIT, | ||||
"sending raw frame, but tx ring is full\n"); | |||||
return (EIO); | return (EIO); | ||||
} | } | ||||
data = STAILQ_FIRST(&sc->sc_epq[0].tx_fh); | data = STAILQ_FIRST(&sc->sc_epq[0].tx_fh); | ||||
Context not available. | |||||
run_set_tx_desc(sc, data); | run_set_tx_desc(sc, data); | ||||
DPRINTFN(10, "sending raw frame len=%u rate=%u\n", | RUN_DPRINTF(sc, RUN_DEBUG_XMIT, "sending raw frame len=%u rate=%u\n", | ||||
m->m_pkthdr.len, rate); | m->m_pkthdr.len, rate); | ||||
STAILQ_INSERT_TAIL(&sc->sc_epq[0].tx_qh, data, next); | STAILQ_INSERT_TAIL(&sc->sc_epq[0].tx_qh, data, next); | ||||
Context not available. | |||||
if (params == NULL) { | if (params == NULL) { | ||||
/* tx mgt packet */ | /* tx mgt packet */ | ||||
if ((error = run_tx_mgt(sc, m, ni)) != 0) { | if ((error = run_tx_mgt(sc, m, ni)) != 0) { | ||||
DPRINTF("mgt tx failed\n"); | RUN_DPRINTF(sc, RUN_DEBUG_XMIT, "mgt tx failed\n"); | ||||
goto done; | goto done; | ||||
} | } | ||||
} else { | } else { | ||||
/* tx raw packet with param */ | /* tx raw packet with param */ | ||||
if ((error = run_tx_param(sc, m, ni, params)) != 0) { | if ((error = run_tx_param(sc, m, ni, params)) != 0) { | ||||
DPRINTF("tx with param failed\n"); | RUN_DPRINTF(sc, RUN_DEBUG_XMIT, "tx with param failed\n"); | ||||
goto done; | goto done; | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
ieee80211_beacon_update(ni, rvp->beacon_mbuf, mcast); | ieee80211_beacon_update(ni, rvp->beacon_mbuf, mcast); | ||||
i = RUN_CMDQ_GET(&sc->cmdq_store); | i = RUN_CMDQ_GET(&sc->cmdq_store); | ||||
DPRINTF("cmdq_store=%d\n", i); | RUN_DPRINTF(sc, RUN_DEBUG_BEACON, "cmdq_store=%d\n", i); | ||||
sc->cmdq[i].func = run_update_beacon_cb; | sc->cmdq[i].func = run_update_beacon_cb; | ||||
sc->cmdq[i].arg0 = vap; | sc->cmdq[i].arg0 = vap; | ||||
ieee80211_runtask(ic, &sc->cmdq_task); | ieee80211_runtask(ic, &sc->cmdq_task); | ||||
Context not available. | |||||
uint32_t i; | uint32_t i; | ||||
i = RUN_CMDQ_GET(&sc->cmdq_store); | i = RUN_CMDQ_GET(&sc->cmdq_store); | ||||
DPRINTF("cmdq_store=%d\n", i); | RUN_DPRINTF(sc, RUN_DEBUG_BEACON, "cmdq_store=%d\n", i); | ||||
sc->cmdq[i].func = run_updateprot_cb; | sc->cmdq[i].func = run_updateprot_cb; | ||||
sc->cmdq[i].arg0 = ic; | sc->cmdq[i].arg0 = ic; | ||||
ieee80211_runtask(ic, &sc->cmdq_task); | ieee80211_runtask(ic, &sc->cmdq_task); | ||||
Context not available. | |||||
vap->iv_opmode != IEEE80211_M_STA) | vap->iv_opmode != IEEE80211_M_STA) | ||||
run_reset_livelock(sc); | run_reset_livelock(sc); | ||||
else if (vap->iv_state == IEEE80211_S_SCAN) { | else if (vap->iv_state == IEEE80211_S_SCAN) { | ||||
DPRINTF("timeout caused by scan\n"); | RUN_DPRINTF(sc, RUN_DEBUG_USB | RUN_DEBUG_STATE, | ||||
"timeout caused by scan\n"); | |||||
/* cancel bgscan */ | /* cancel bgscan */ | ||||
ieee80211_cancel_scan(vap); | ieee80211_cancel_scan(vap); | ||||
} else | } else | ||||
DPRINTF("timeout by unknown cause\n"); | RUN_DPRINTF(sc, RUN_DEBUG_USB | RUN_DEBUG_STATE, | ||||
"timeout by unknown cause\n"); | |||||
} | } | ||||
static void | static void | ||||
Context not available. | |||||
* crazy if protection is enabled. Reset MAC/BBP for a while | * crazy if protection is enabled. Reset MAC/BBP for a while | ||||
*/ | */ | ||||
run_read(sc, RT2860_DEBUG, &tmp); | run_read(sc, RT2860_DEBUG, &tmp); | ||||
DPRINTFN(3, "debug reg %08x\n", tmp); | RUN_DPRINTF(sc, RUN_DEBUG_RESET, "debug reg %08x\n", tmp); | ||||
if ((tmp & (1 << 29)) && (tmp & (1 << 7 | 1 << 5))) { | if ((tmp & (1 << 29)) && (tmp & (1 << 7 | 1 << 5))) { | ||||
DPRINTF("CTS-to-self livelock detected\n"); | RUN_DPRINTF(sc, RUN_DEBUG_RESET, | ||||
"CTS-to-self livelock detected\n"); | |||||
run_write(sc, RT2860_MAC_SYS_CTRL, RT2860_MAC_SRST); | run_write(sc, RT2860_MAC_SYS_CTRL, RT2860_MAC_SRST); | ||||
run_delay(sc, 1); | run_delay(sc, 1); | ||||
run_write(sc, RT2860_MAC_SYS_CTRL, | run_write(sc, RT2860_MAC_SYS_CTRL, | ||||
Context not available. | |||||
run_write(sc, RT2860_RX_FILTR_CFG, tmp); | run_write(sc, RT2860_RX_FILTR_CFG, tmp); | ||||
DPRINTF("%s promiscuous mode\n", (sc->sc_ic.ic_promisc > 0) ? | RUN_DPRINTF(sc, RUN_DEBUG_RECV, "%s promiscuous mode\n", | ||||
"entering" : "leaving"); | (sc->sc_ic.ic_promisc > 0) ? "entering" : "leaving"); | ||||
} | } | ||||
static void | static void | ||||
Context not available. | |||||
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); | struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); | ||||
uint32_t tmp; | uint32_t tmp; | ||||
DPRINTF("rvp_id=%d ic_opmode=%d\n", RUN_VAP(vap)->rvp_id, | RUN_DPRINTF(sc, RUN_DEBUG_BEACON, "rvp_id=%d ic_opmode=%d\n", | ||||
ic->ic_opmode); | RUN_VAP(vap)->rvp_id, ic->ic_opmode); | ||||
run_read(sc, RT2860_BCN_TIME_CFG, &tmp); | run_read(sc, RT2860_BCN_TIME_CFG, &tmp); | ||||
tmp &= ~0x1fffff; | tmp &= ~0x1fffff; | ||||
Context not available. | |||||
/* SYNC with nobody */ | /* SYNC with nobody */ | ||||
tmp |= 3 << RT2860_TSF_SYNC_MODE_SHIFT; | tmp |= 3 << RT2860_TSF_SYNC_MODE_SHIFT; | ||||
} else { | } else { | ||||
DPRINTF("Enabling TSF failed. undefined opmode\n"); | RUN_DPRINTF(sc, RUN_DEBUG_BEACON, | ||||
"Enabling TSF failed. undefined opmode\n"); | |||||
return; | return; | ||||
} | } | ||||
Context not available. | |||||
uint32_t i; | uint32_t i; | ||||
i = RUN_CMDQ_GET(&sc->cmdq_store); | i = RUN_CMDQ_GET(&sc->cmdq_store); | ||||
DPRINTF("cmdq_store=%d\n", i); | RUN_DPRINTF(sc, RUN_DEBUG_BEACON, "cmdq_store=%d\n", i); | ||||
sc->cmdq[i].func = run_updateslot_cb; | sc->cmdq[i].func = run_updateslot_cb; | ||||
sc->cmdq[i].arg0 = ic; | sc->cmdq[i].arg0 = ic; | ||||
ieee80211_runtask(ic, &sc->cmdq_task); | ieee80211_runtask(ic, &sc->cmdq_task); | ||||
Context not available. | |||||
/* wait for pending Tx to complete */ | /* wait for pending Tx to complete */ | ||||
for (ntries = 0; ntries < 100; ntries++) { | for (ntries = 0; ntries < 100; ntries++) { | ||||
if (run_read(sc, RT2860_TXRXQ_PCNT, &tmp) != 0) { | if (run_read(sc, RT2860_TXRXQ_PCNT, &tmp) != 0) { | ||||
DPRINTF("Cannot read Tx queue count\n"); | RUN_DPRINTF(sc, RUN_DEBUG_XMIT | RUN_DEBUG_RESET, | ||||
"Cannot read Tx queue count\n"); | |||||
break; | break; | ||||
} | } | ||||
if ((tmp & RT2860_TX2Q_PCNT_MASK) == 0) { | if ((tmp & RT2860_TX2Q_PCNT_MASK) == 0) { | ||||
DPRINTF("All Tx cleared\n"); | RUN_DPRINTF(sc, RUN_DEBUG_XMIT | RUN_DEBUG_RESET, | ||||
"All Tx cleared\n"); | |||||
break; | break; | ||||
} | } | ||||
run_delay(sc, 10); | run_delay(sc, 10); | ||||
} | } | ||||
if (ntries >= 100) | if (ntries >= 100) | ||||
DPRINTF("There are still pending Tx\n"); | RUN_DPRINTF(sc, RUN_DEBUG_XMIT | RUN_DEBUG_RESET, | ||||
"There are still pending Tx\n"); | |||||
run_delay(sc, 10); | run_delay(sc, 10); | ||||
run_write(sc, RT2860_USB_DMA_CFG, 0); | run_write(sc, RT2860_USB_DMA_CFG, 0); | ||||
Context not available. |