Module Name: src
Committed By: nonaka
Date: Fri Feb 13 17:14:06 UTC 2015
Modified Files:
src/sys/dev/pci: if_iwm.c if_iwmvar.h
Log Message:
Sync with OpenBSD if_iwm.c rev.1.18.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/pci/if_iwm.c src/sys/dev/pci/if_iwmvar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/pci/if_iwm.c
diff -u src/sys/dev/pci/if_iwm.c:1.1 src/sys/dev/pci/if_iwm.c:1.2
--- src/sys/dev/pci/if_iwm.c:1.1 Sat Feb 7 13:20:00 2015
+++ src/sys/dev/pci/if_iwm.c Fri Feb 13 17:14:06 2015
@@ -1,5 +1,5 @@
-/* $NetBSD: if_iwm.c,v 1.1 2015/02/07 13:20:00 pooka Exp $ */
-/* OpenBSD: if_iwm.c,v 1.3 2015/02/07 07:10:44 phessler Exp */
+/* $NetBSD: if_iwm.c,v 1.2 2015/02/13 17:14:06 nonaka Exp $ */
+/* OpenBSD: if_iwm.c,v 1.18 2015/02/11 01:12:42 brad Exp */
/*
* Copyright (c) 2014 genua mbh <[email protected]>
@@ -105,7 +105,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.1 2015/02/07 13:20:00 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.2 2015/02/13 17:14:06 nonaka Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -173,6 +173,7 @@ const uint8_t iwm_nvm_channels[] = {
};
#define IWM_NUM_2GHZ_CHANNELS 14
+/* It looks like 11a TX is broken, unfortunately. */
#define IWM_NO_5GHZ 1
const struct iwm_rate {
@@ -198,18 +199,6 @@ const struct iwm_rate {
#define IWM_RIDX_IS_CCK(_i_) ((_i_) < IWM_RIDX_OFDM)
#define IWM_RIDX_IS_OFDM(_i_) ((_i_) >= IWM_RIDX_OFDM)
-/*
- * Supported rates for 802.11a/b/g modes (in 500Kbps unit).
- */
-const struct ieee80211_rateset iwm_rateset_11a =
- { 8, { 12, 18, 24, 36, 48, 72, 96, 108 } };
-
-const struct ieee80211_rateset iwm_rateset_11b =
- { 4, { 2, 4, 11, 22 } };
-
-const struct ieee80211_rateset iwm_rateset_11g =
- { 12, { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 } };
-
struct iwm_newstate_state {
struct work ns_wk;
struct ieee80211com *ns_ic;
@@ -409,7 +398,9 @@ void iwm_stop(struct ifnet *, int);
void iwm_watchdog(struct ifnet *);
int iwm_ioctl(struct ifnet *, u_long, void *);
const char *iwm_desc_lookup(uint32_t);
+#ifdef IWM_DEBUG
void iwm_nic_error(struct iwm_softc *);
+#endif
void iwm_notif_intr(struct iwm_softc *);
int iwm_intr(void *);
int iwm_preinit(struct iwm_softc *);
@@ -579,8 +570,8 @@ iwm_set_default_calib(struct iwm_softc *
uint32_t ucode_type = le32toh(def_calib->ucode_type);
if (ucode_type >= IWM_UCODE_TYPE_MAX) {
- printf("%s: Wrong ucode_type %u for default "
- "calibration.\n", DEVNAME(sc), ucode_type);
+ DPRINTF(("%s: Wrong ucode_type %u for default "
+ "calibration.\n", DEVNAME(sc), ucode_type));
return EINVAL;
}
@@ -600,7 +591,8 @@ iwm_read_firmware(struct iwm_softc *sc)
struct iwm_ucode_tlv tlv;
enum iwm_ucode_tlv_type tlv_type;
uint8_t *data;
- int error, status, len;
+ int error, status;
+ size_t len;
if (fw->fw_status == IWM_FW_STATUS_NONE) {
fw->fw_status = IWM_FW_STATUS_INPROGRESS;
@@ -612,10 +604,6 @@ iwm_read_firmware(struct iwm_softc *sc)
if (status == IWM_FW_STATUS_DONE)
return 0;
- else if (status < 0)
- return -status;
-
- KASSERT(status == IWM_FW_STATUS_INPROGRESS);
/*
* Load firmware into driver memory.
@@ -623,8 +611,8 @@ iwm_read_firmware(struct iwm_softc *sc)
*/
error = iwm_firmload(sc);
if (error != 0) {
- printf("%s: could not read firmware %s\n",
- DEVNAME(sc), sc->sc_fwname);
+ printf("%s: could not read firmware %s (error %d)\n",
+ DEVNAME(sc), sc->sc_fwname, error);
goto out;
}
@@ -646,7 +634,7 @@ iwm_read_firmware(struct iwm_softc *sc)
len = fw->fw_rawsize - sizeof(*uhdr);
while (len >= sizeof(tlv)) {
- uint32_t tlv_len;
+ size_t tlv_len;
void *tlv_data;
memcpy(&tlv, data, sizeof(tlv));
@@ -658,7 +646,8 @@ iwm_read_firmware(struct iwm_softc *sc)
tlv_data = data;
if (len < tlv_len) {
- printf("%s: firmware image invalid length\n", DEVNAME(sc));
+ printf("%s: firmware too short: %zu bytes\n",
+ DEVNAME(sc), len);
error = EINVAL;
goto parse_out;
}
@@ -673,8 +662,8 @@ iwm_read_firmware(struct iwm_softc *sc)
= le32toh(*(uint32_t *)tlv_data);
/* limit it to something sensible */
if (sc->sc_capa_max_probe_len > (1<<16)) {
- printf("%s: IWM_UCODE_TLV_PROBE_MAX_LEN "
- "ridiculous\n", DEVNAME(sc));
+ DPRINTF(("%s: IWM_UCODE_TLV_PROBE_MAX_LEN "
+ "ridiculous\n", DEVNAME(sc)));
error = EINVAL;
goto parse_out;
}
@@ -715,8 +704,8 @@ iwm_read_firmware(struct iwm_softc *sc)
goto parse_out;
}
if (le32toh(*(uint32_t*)tlv_data) != 1) {
- printf("%s: driver supports "
- "only TLV_NUM_OF_CPU == 1", DEVNAME(sc));
+ DPRINTF(("%s: driver supports "
+ "only TLV_NUM_OF_CPU == 1", DEVNAME(sc)));
error = EINVAL;
goto parse_out;
}
@@ -758,8 +747,8 @@ iwm_read_firmware(struct iwm_softc *sc)
break;
default:
- printf("%s: unknown firmware section %d, abort\n",
- DEVNAME(sc), tlv_type);
+ DPRINTF(("%s: unknown firmware section %d, abort\n",
+ DEVNAME(sc), tlv_type));
error = EINVAL;
goto parse_out;
}
@@ -782,12 +771,10 @@ iwm_read_firmware(struct iwm_softc *sc)
}
out:
- if (error) {
- KASSERT(error > 0);
- fw->fw_status = -error;
- } else {
+ if (error)
+ fw->fw_status = IWM_FW_STATUS_NONE;
+ else
fw->fw_status = IWM_FW_STATUS_DONE;
- }
wakeup(&sc->sc_fw);
if (error) {
@@ -841,7 +828,7 @@ iwm_read_mem(struct iwm_softc *sc, uint3
int
iwm_write_mem(struct iwm_softc *sc, uint32_t addr, const void *buf, int dwords)
{
- int offs, ret = 0;
+ int offs;
const uint32_t *vals = buf;
if (iwm_nic_lock(sc)) {
@@ -853,11 +840,10 @@ iwm_write_mem(struct iwm_softc *sc, uint
}
iwm_nic_unlock(sc);
} else {
- /* let's just say that it's good to notice this failure */
- printf("%s: WARNING: write_mem failed\n", DEVNAME(sc));
- ret = EBUSY;
+ DPRINTF(("%s: write_mem failed\n", DEVNAME(sc)));
+ return EBUSY;
}
- return ret;
+ return 0;
}
int
@@ -1104,7 +1090,6 @@ iwm_alloc_rx_ring(struct iwm_softc *sc,
}
if ((error = iwm_rx_addbuf(sc, IWM_RBUF_SIZE, i)) != 0) {
- printf("%s: could not add mbuf to ring", DEVNAME(sc));
goto fail;
}
}
@@ -1127,10 +1112,6 @@ iwm_reset_rx_ring(struct iwm_softc *sc,
break;
DELAY(10);
}
- if (ntries == 1000) {
- printf("%s: unable to detect idle rx chan after "
- "reset\n", DEVNAME(sc));
- }
iwm_nic_unlock(sc);
}
ring->cur = 0;
@@ -1468,7 +1449,8 @@ iwm_apm_init(struct iwm_softc *sc)
if (!iwm_poll_bit(sc, IWM_CSR_GP_CNTRL,
IWM_CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
IWM_CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000)) {
- printf("%s: Failed to init the card\n", DEVNAME(sc));
+ printf("%s: timeout waiting for clock stabilization\n",
+ DEVNAME(sc));
goto out;
}
@@ -1527,7 +1509,7 @@ iwm_apm_stop(struct iwm_softc *sc)
if (!iwm_poll_bit(sc, IWM_CSR_RESET,
IWM_CSR_RESET_REG_FLAG_MASTER_DISABLED,
IWM_CSR_RESET_REG_FLAG_MASTER_DISABLED, 100))
- printf("%s: Master Disable Timed Out, 100 usec\n", DEVNAME(sc));
+ printf("%s: timeout waiting for master\n", DEVNAME(sc));
DPRINTF(("iwm apm stop\n"));
}
@@ -1587,10 +1569,6 @@ iwm_stop_device(struct iwm_softc *sc)
break;
DELAY(20);
}
- if (ntries == 200) {
- printf("%s: unable to detect idle tx "
- "chan after reset\n", DEVNAME(sc));
- }
}
iwm_nic_unlock(sc);
}
@@ -1807,8 +1785,8 @@ void
iwm_enable_txq(struct iwm_softc *sc, int qid, int fifo)
{
if (!iwm_nic_lock(sc)) {
- printf("%s: cannot enable txq %d\n", DEVNAME(sc), qid);
- return;
+ DPRINTF(("%s: cannot enable txq %d\n", DEVNAME(sc), qid));
+ return; /* XXX return EBUSY */
}
/* unactivate before configuration */
@@ -1856,7 +1834,7 @@ iwm_post_alive(struct iwm_softc *sc)
return EBUSY;
if (sc->sched_base != iwm_read_prph(sc, IWM_SCD_SRAM_BASE_ADDR)) {
- printf("%s: sched addr mismatch", DEVNAME(sc));
+ DPRINTF(("%s: sched addr mismatch", DEVNAME(sc)));
error = EINVAL;
goto out;
}
@@ -2150,8 +2128,8 @@ iwm_phy_db_send_all_channel_groups(struc
/* Send the requested PHY DB section */
err = iwm_send_phy_db_cmd(sc, type, entry->size, entry->data);
if (err) {
- printf("%s: Can't SEND phy_db section %d (%d), err %d",
- DEVNAME(sc), type, i, err);
+ DPRINTF(("%s: Can't SEND phy_db section %d (%d), "
+ "err %d\n", DEVNAME(sc), type, i, err));
return err;
}
@@ -2173,29 +2151,30 @@ iwm_send_phy_db_data(struct iwm_softc *s
/* Send PHY DB CFG section */
err = iwm_phy_db_get_section_data(sc, IWM_PHY_DB_CFG, &data, &size, 0);
if (err) {
- printf("%s: Cannot get Phy DB cfg section\n", DEVNAME(sc));
+ DPRINTF(("%s: Cannot get Phy DB cfg section, %d\n",
+ DEVNAME(sc), err));
return err;
}
err = iwm_send_phy_db_cmd(sc, IWM_PHY_DB_CFG, size, data);
if (err) {
- printf("%s: Cannot send HCMD of Phy DB cfg section\n",
- DEVNAME(sc));
+ DPRINTF(("%s: Cannot send HCMD of Phy DB cfg section, %d\n",
+ DEVNAME(sc), err));
return err;
}
err = iwm_phy_db_get_section_data(sc, IWM_PHY_DB_CALIB_NCH,
&data, &size, 0);
if (err) {
- printf("%s: Cannot get Phy DB non specific channel section\n",
- DEVNAME(sc));
+ DPRINTF(("%s: Cannot get Phy DB non specific channel section, "
+ "%d\n", DEVNAME(sc), err));
return err;
}
err = iwm_send_phy_db_cmd(sc, IWM_PHY_DB_CALIB_NCH, size, data);
if (err) {
- printf("%s: Cannot send HCMD of Phy DB non specific channel "
- "sect, %d\n", DEVNAME(sc), err);
+ DPRINTF(("%s: Cannot send HCMD of Phy DB non specific channel "
+ "sect, %d\n", DEVNAME(sc), err));
return err;
}
@@ -2203,8 +2182,8 @@ iwm_send_phy_db_data(struct iwm_softc *s
err = iwm_phy_db_send_all_channel_groups(sc,
IWM_PHY_DB_CALIB_CHG_PAPD, IWM_NUM_PAPD_CH_GROUPS);
if (err) {
- printf("%s: Cannot send channel specific PAPD groups",
- DEVNAME(sc));
+ DPRINTF(("%s: Cannot send channel specific PAPD groups, %d\n",
+ DEVNAME(sc), err));
return err;
}
@@ -2212,8 +2191,8 @@ iwm_send_phy_db_data(struct iwm_softc *s
err = iwm_phy_db_send_all_channel_groups(sc,
IWM_PHY_DB_CALIB_CHG_TXP, IWM_NUM_TXP_CH_GROUPS);
if (err) {
- printf("%s: Cannot send channel specific TX power groups",
- DEVNAME(sc));
+ DPRINTF(("%s: Cannot send channel specific TX power groups, "
+ "%d\n", DEVNAME(sc), err));
return err;
}
@@ -2307,8 +2286,8 @@ iwm_mvm_time_event_send_add(struct iwm_s
ret = iwm_mvm_send_time_event_cmd(sc, te_cmd);
if (ret) {
- printf("%s: Couldn't send IWM_TIME_EVENT_CMD: %d\n",
- DEVNAME(sc), ret);
+ DPRINTF(("%s: Couldn't send IWM_TIME_EVENT_CMD: %d\n",
+ DEVNAME(sc), ret));
}
return ret;
@@ -2398,8 +2377,8 @@ iwm_nvm_read_chunk(struct iwm_softc *sc,
pkt = cmd.resp_pkt;
if (pkt->hdr.flags & IWM_CMD_FAILED_MSK) {
- printf("%s: Bad return from IWM_NVM_ACCES_COMMAND (0x%08X)\n",
- DEVNAME(sc), pkt->hdr.flags);
+ DPRINTF(("%s: Bad return from IWM_NVM_ACCES_COMMAND (0x%08X)\n",
+ DEVNAME(sc), pkt->hdr.flags));
ret = EIO;
goto exit;
}
@@ -2412,15 +2391,15 @@ iwm_nvm_read_chunk(struct iwm_softc *sc,
offset_read = le16toh(nvm_resp->offset);
resp_data = nvm_resp->data;
if (ret) {
- printf("%s: NVM access command failed with status %d\n",
- DEVNAME(sc), ret);
+ DPRINTF(("%s: NVM access command failed with status %d\n",
+ DEVNAME(sc), ret));
ret = EINVAL;
goto exit;
}
if (offset_read != offset) {
- printf("%s: NVM ACCESS response with invalid offset %d\n",
- DEVNAME(sc), offset_read);
+ DPRINTF(("%s: NVM ACCESS response with invalid offset %d\n",
+ DEVNAME(sc), offset_read));
ret = EINVAL;
goto exit;
}
@@ -2608,13 +2587,17 @@ iwm_parse_nvm_data(struct iwm_softc *sc,
sku = le16_to_cpup(nvm_sw + IWM_SKU);
data->sku_cap_band_24GHz_enable = sku & IWM_NVM_SKU_CAP_BAND_24GHZ;
+#ifndef IWM_NO_5GHZ
data->sku_cap_band_52GHz_enable = sku & IWM_NVM_SKU_CAP_BAND_52GHZ;
+#else
+ data->sku_cap_band_52GHz_enable = 0;
+#endif
data->sku_cap_11n_enable = 0;
if (!data->valid_tx_ant || !data->valid_rx_ant) {
- printf("%s: invalid antennas (0x%x, 0x%x)\n",
+ DPRINTF(("%s: invalid antennas (0x%x, 0x%x)\n",
DEVNAME(sc), data->valid_tx_ant,
- data->valid_rx_ant);
+ data->valid_rx_ant));
return EINVAL;
}
@@ -2666,7 +2649,7 @@ iwm_parse_nvm_sections(struct iwm_softc
/* Checking for required sections */
if (!sections[IWM_NVM_SECTION_TYPE_SW].data ||
!sections[IWM_NVM_SECTION_TYPE_HW].data) {
- printf("%s: Can't parse empty NVM sections\n", DEVNAME(sc));
+ DPRINTF(("%s: Can't parse empty NVM sections\n", DEVNAME(sc)));
return ENOENT;
}
@@ -2804,7 +2787,7 @@ iwm_start_fw(struct iwm_softc *sc, enum
IWM_WRITE(sc, IWM_CSR_INT, ~0);
if ((error = iwm_nic_init(sc)) != 0) {
- printf("%s: Unable to init nic\n", DEVNAME(sc));
+ printf("%s: unable to init nic\n", DEVNAME(sc));
return error;
}
@@ -2896,7 +2879,8 @@ iwm_run_init_mvm_ucode(struct iwm_softc
/* do not operate with rfkill switch turned on */
if ((sc->sc_flags & IWM_FLAG_RFKILL) && !justnvm) {
- printf("%s: rfkill active, no go\n", DEVNAME(sc));
+ printf("%s: radio is disabled by hardware switch\n",
+ DEVNAME(sc));
return EPERM;
}
@@ -2931,8 +2915,8 @@ iwm_run_init_mvm_ucode(struct iwm_softc
* to start the 16.0 uCode init image internal calibrations.
*/
if ((error = iwm_send_phy_cfg_cmd(sc)) != 0 ) {
- printf("%s: Failed to run INIT "
- "calibrations: %d\n", DEVNAME(sc), error);
+ DPRINTF(("%s: failed to run internal calibration: %d\n",
+ DEVNAME(sc), error));
return error;
}
@@ -3248,8 +3232,8 @@ iwm_mvm_rx_tx_cmd(struct iwm_softc *sc,
struct iwm_node *in = txd->in;
if (txd->done) {
- printf("%s: got tx interrupt that's already been handled!\n",
- DEVNAME(sc));
+ DPRINTF(("%s: got tx interrupt that's already been handled!\n",
+ DEVNAME(sc)));
return;
}
@@ -3316,13 +3300,14 @@ iwm_mvm_binding_cmd(struct iwm_softc *sc
ret = iwm_mvm_send_cmd_pdu_status(sc, IWM_BINDING_CONTEXT_CMD,
sizeof(cmd), &cmd, &status);
if (ret) {
- printf("%s: Failed to send binding (action:%d): %d\n",
- DEVNAME(sc), action, ret);
+ DPRINTF(("%s: Failed to send binding (action:%d): %d\n",
+ DEVNAME(sc), action, ret));
return ret;
}
if (status) {
- printf("%s: Binding command failed: %u\n", DEVNAME(sc), status);
+ DPRINTF(("%s: Binding command failed: %u\n", DEVNAME(sc),
+ status));
ret = EIO;
}
@@ -3584,7 +3569,7 @@ iwm_send_cmd(struct iwm_softc *sc, struc
IWM_CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN,
(IWM_CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY |
IWM_CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000)) {
- printf("%s: acquiring device failed\n", DEVNAME(sc));
+ DPRINTF(("%s: acquiring device failed\n", DEVNAME(sc)));
error = EBUSY;
goto out;
}
@@ -3838,8 +3823,8 @@ iwm_tx(struct iwm_softc *sc, struct mbuf
sizeof (struct ieee80211_frame);
if (hdrlen != hdrlen2)
- printf("%s: hdrlen error (%d != %d)\n",
- DEVNAME(sc), hdrlen, hdrlen2);
+ DPRINTF(("%s: hdrlen error (%d != %d)\n",
+ DEVNAME(sc), hdrlen, hdrlen2));
tid = 0;
@@ -4403,8 +4388,8 @@ iwm_mvm_add_int_sta_common(struct iwm_so
DPRINTF(("Internal station added.\n"));
return 0;
default:
- printf("%s: Add internal station failed, status=0x%x\n",
- DEVNAME(sc), status);
+ DPRINTF(("%s: Add internal station failed, status=0x%x\n",
+ DEVNAME(sc), status));
ret = EIO;
break;
}
@@ -4564,7 +4549,7 @@ iwm_mvm_scan_fill_channels(struct iwm_so
nchan++;
}
if (nchan == 0)
- printf("%s: NO CHANNEL!\n", DEVNAME(sc));
+ DPRINTF(("%s: NO CHANNEL!\n", DEVNAME(sc)));
return nchan;
}
@@ -4715,8 +4700,6 @@ iwm_mvm_scan_request(struct iwm_softc *s
* to allocate the time events. Warn on it, but maybe we
* should try to send the command again with different params.
*/
- printf("%s: Scan failed! status 0x%x ret %d\n", DEVNAME(sc),
- status, ret);
sc->sc_scanband = 0;
ret = EIO;
}
@@ -4864,8 +4847,8 @@ iwm_mvm_mac_ctxt_send_cmd(struct iwm_sof
int ret = iwm_mvm_send_cmd_pdu(sc, IWM_MAC_CONTEXT_CMD, IWM_CMD_SYNC,
sizeof(*cmd), cmd);
if (ret)
- printf("%s: Failed to send MAC context (action:%d): %d\n",
- DEVNAME(sc), le32toh(cmd->action), ret);
+ DPRINTF(("%s: Failed to send MAC context (action:%d): %d\n",
+ DEVNAME(sc), le32toh(cmd->action), ret));
return ret;
}
@@ -5102,7 +5085,7 @@ iwm_mvm_update_quotas(struct iwm_softc *
ret = iwm_mvm_send_cmd_pdu(sc, IWM_TIME_QUOTA_CMD, IWM_CMD_SYNC,
sizeof(cmd), &cmd);
if (ret)
- printf("%s: Failed to send quota: %d\n", DEVNAME(sc), ret);
+ DPRINTF(("%s: Failed to send quota: %d\n", DEVNAME(sc), ret));
return ret;
}
@@ -5129,24 +5112,24 @@ iwm_auth(struct iwm_softc *sc)
in->in_assoc = 0;
if ((error = iwm_mvm_mac_ctxt_add(sc, in)) != 0) {
- printf("%s: failed to add MAC\n", DEVNAME(sc));
+ DPRINTF(("%s: failed to add MAC\n", DEVNAME(sc)));
return error;
}
if ((error = iwm_mvm_phy_ctxt_changed(sc, &sc->sc_phyctxt[0],
in->in_ni.ni_chan, 1, 1)) != 0) {
- printf("%s: failed add phy ctxt\n", DEVNAME(sc));
+ DPRINTF(("%s: failed add phy ctxt\n", DEVNAME(sc)));
return error;
}
in->in_phyctxt = &sc->sc_phyctxt[0];
if ((error = iwm_mvm_binding_add_vif(sc, in)) != 0) {
- printf("%s: binding cmd\n", DEVNAME(sc));
+ DPRINTF(("%s: binding cmd\n", DEVNAME(sc)));
return error;
}
if ((error = iwm_mvm_add_sta(sc, in)) != 0) {
- printf("%s: failed to add MAC\n", DEVNAME(sc));
+ DPRINTF(("%s: failed to add MAC\n", DEVNAME(sc)));
return error;
}
@@ -5167,10 +5150,10 @@ iwm_auth(struct iwm_softc *sc)
* second, we have bigger problems
*/
if (sc->sc_auth_prot == 0) {
- printf("%s: missed auth window!\n", DEVNAME(sc));
+ DPRINTF(("%s: missed auth window!\n", DEVNAME(sc)));
return ETIMEDOUT;
} else if (sc->sc_auth_prot == -1) {
- printf("%s: no time event, denied!\n", DEVNAME(sc));
+ DPRINTF(("%s: no time event, denied!\n", DEVNAME(sc)));
sc->sc_auth_prot = 0;
return EAUTH;
}
@@ -5188,13 +5171,13 @@ iwm_assoc(struct iwm_softc *sc)
int error;
if ((error = iwm_mvm_update_sta(sc, in)) != 0) {
- printf("%s: failed to update STA\n", DEVNAME(sc));
+ DPRINTF(("%s: failed to update STA\n", DEVNAME(sc)));
return error;
}
in->in_assoc = 1;
if ((error = iwm_mvm_mac_ctxt_changed(sc, in)) != 0) {
- printf("%s: failed to update MAC\n", DEVNAME(sc));
+ DPRINTF(("%s: failed to update MAC\n", DEVNAME(sc)));
return error;
}
@@ -5298,8 +5281,8 @@ iwm_setrates(struct iwm_node *in)
int txant = 0;
if (nrates > __arraycount(lq->rs_table)) {
- printf("%s: node supports %d rates, driver handles only %zu\n",
- DEVNAME(sc), nrates, __arraycount(lq->rs_table));
+ DPRINTF(("%s: node supports %d rates, driver handles only "
+ "%zu\n", DEVNAME(sc), nrates, __arraycount(lq->rs_table)));
return;
}
@@ -5313,7 +5296,8 @@ iwm_setrates(struct iwm_node *in)
if (iwm_rates[ridx].rate == rate)
break;
if (ridx > IWM_RIDX_MAX)
- printf("%s: WARNING: device rate for %d not found!\n", DEVNAME(sc), rate);
+ DPRINTF(("%s: WARNING: device rate for %d not found!\n",
+ DEVNAME(sc), rate));
else
in->in_ridx[i] = ridx;
}
@@ -5456,14 +5440,8 @@ iwm_newstate_cb(void *wk)
break;
case IEEE80211_S_SCAN:
- if (sc->sc_scanband) {
- /* how does this print match the clause? */
- if (ic->ic_state != nstate)
- printf("%s: scan request(%d) "
- "while scanning(%d) ignored\n",
- DEVNAME(sc), nstate, ic->ic_state);
+ if (sc->sc_scanband)
break;
- }
if ((error = iwm_mvm_scan_request(sc, IEEE80211_CHAN_2GHZ,
ic->ic_des_esslen != 0,
@@ -5476,8 +5454,8 @@ iwm_newstate_cb(void *wk)
case IEEE80211_S_AUTH:
if ((error = iwm_auth(sc)) != 0) {
- printf("%s: could not move to auth state: %d\n",
- DEVNAME(sc), error);
+ DPRINTF(("%s: could not move to auth state: %d\n",
+ DEVNAME(sc), error));
return;
}
@@ -5485,8 +5463,8 @@ iwm_newstate_cb(void *wk)
case IEEE80211_S_ASSOC:
if ((error = iwm_assoc(sc)) != 0) {
- printf("%s: failed to associate: %d\n", DEVNAME(sc),
- error);
+ DPRINTF(("%s: failed to associate: %d\n", DEVNAME(sc),
+ error));
return;
}
break;
@@ -5506,7 +5484,7 @@ iwm_newstate_cb(void *wk)
cmd.data[0] = &in->in_lq;
if ((error = iwm_send_cmd(sc, &cmd)) != 0) {
- printf("%s: IWM_LQ_CMD failed\n", DEVNAME(sc));
+ DPRINTF(("%s: IWM_LQ_CMD failed\n", DEVNAME(sc)));
}
callout_schedule(&sc->sc_calib_to, hz/2);
@@ -5514,7 +5492,7 @@ iwm_newstate_cb(void *wk)
break; }
default:
- panic("unsupported state %d\n", nstate);
+ break;
}
sc->sc_newstate(ic, nstate, arg);
@@ -5531,7 +5509,7 @@ iwm_newstate(struct ieee80211com *ic, en
iwmns = kmem_alloc(sizeof(*iwmns), KM_NOSLEEP);
if (!iwmns) {
- printf("%s: allocating state cb mem failed\n", DEVNAME(sc));
+ DPRINTF(("%s: allocating state cb mem failed\n", DEVNAME(sc)));
return ENOMEM;
}
@@ -5555,14 +5533,13 @@ iwm_endscan_cb(void *arg)
DPRINTF(("scan ended\n"));
if (sc->sc_scanband == IEEE80211_CHAN_2GHZ) {
-#ifndef IWM_NO_5GHZ /* for quick testing, makes scan few sec faster */
+#ifndef IWM_NO_5GHZ
int error;
done = 0;
if ((error = iwm_mvm_scan_request(sc,
IEEE80211_CHAN_5GHZ, ic->ic_des_esslen != 0,
ic->ic_des_essid, ic->ic_des_esslen)) != 0) {
- printf("%s: could not initiate 5ghz scan\n",
- DEVNAME(sc));
+ printf("%s: could not initiate scan\n", DEVNAME(sc));
done = 1;
}
#else
@@ -5588,7 +5565,7 @@ iwm_init_hw(struct iwm_softc *sc)
struct ieee80211com *ic = &sc->sc_ic;
int error, i, qid;
- if ((error = iwm_prepare_card_hw(sc)) != 0)
+ if ((error = iwm_preinit(sc)) != 0)
return error;
if ((error = iwm_start_hw(sc)) != 0)
@@ -5603,14 +5580,15 @@ iwm_init_hw(struct iwm_softc *sc)
* image just loaded
*/
iwm_stop_device(sc);
- if ((error = iwm_start_hw(sc)) != 0)
+ if ((error = iwm_start_hw(sc)) != 0) {
+ printf("%s: could not initialize hardware\n", DEVNAME(sc));
return error;
+ }
/* omstart, this time with the regular firmware */
error = iwm_mvm_load_ucode_wait_alive(sc, IWM_UCODE_TYPE_REGULAR);
if (error) {
- printf("%s: Failed to start RT ucode: %d\n", DEVNAME(sc),
- error);
+ printf("%s: could not load firmware\n", DEVNAME(sc));
goto error;
}
@@ -5807,7 +5785,9 @@ iwm_watchdog(struct ifnet *ifp)
if (sc->sc_tx_timer > 0) {
if (--sc->sc_tx_timer == 0) {
printf("%s: device timeout\n", DEVNAME(sc));
+#ifdef IWM_DEBUG
iwm_nic_error(sc);
+#endif
ifp->if_flags &= ~IFF_UP;
iwm_stop(ifp, 1);
ifp->if_oerrors++;
@@ -5974,6 +5954,7 @@ iwm_desc_lookup(uint32_t num)
return advanced_lookup[i].name;
}
+#ifdef IWM_DEBUG
/*
* Support for dumping the error log seemed like a good idea ...
* but it's mostly hex junk and the only sensible thing is the
@@ -6046,6 +6027,7 @@ iwm_nic_error(struct iwm_softc *sc)
printf("%s: %08X | timestamp\n", DEVNAME(sc), table.u_timestamp);
printf("%s: %08X | flow_handler\n", DEVNAME(sc), table.flow_handler);
}
+#endif
#define SYNC_RESP_STRUCT(_var_, _pkt_) \
do { \
@@ -6203,7 +6185,7 @@ iwm_notif_intr(struct iwm_softc *sc)
struct iwm_error_resp *resp;
SYNC_RESP_STRUCT(resp, pkt);
- printf("%s: Firmware error 0x%x, cmd 0x%x\n",
+ printf("%s: firmware error 0x%x, cmd 0x%x\n",
DEVNAME(sc), le32toh(resp->error_type),
resp->cmd_id);
break; }
@@ -6336,7 +6318,7 @@ iwm_intr(void *arg)
DPRINTF((" 802.11 state %d\n", sc->sc_ic.ic_state));
#endif
- printf("%s: firmware error, stopping device\n", DEVNAME(sc));
+ printf("%s: fatal firmware error\n", DEVNAME(sc));
ifp->if_flags &= ~IFF_UP;
iwm_stop(ifp, 1);
rv = 1;
@@ -6365,8 +6347,8 @@ iwm_intr(void *arg)
if (r1 & IWM_CSR_INT_BIT_RF_KILL) {
handled |= IWM_CSR_INT_BIT_RF_KILL;
if (iwm_check_rfkill(sc) && (ifp->if_flags & IFF_UP)) {
- printf("%s: rfkill switch, disabling interface\n",
- DEVNAME(sc));
+ DPRINTF(("%s: rfkill switch, disabling interface\n",
+ DEVNAME(sc)));
ifp->if_flags &= ~IFF_UP;
iwm_stop(ifp, 1);
}
@@ -6398,7 +6380,7 @@ iwm_intr(void *arg)
}
if (__predict_false(r1 & ~handled))
- printf("%s: unhandled interrupts: %x\n", DEVNAME(sc), r1);
+ DPRINTF(("%s: unhandled interrupts: %x\n", DEVNAME(sc), r1));
rv = 1;
out_ena:
@@ -6440,18 +6422,22 @@ iwm_preinit(struct iwm_softc *sc)
{
int error;
- if ((error = iwm_prepare_card_hw(sc)) != 0)
+ if ((error = iwm_prepare_card_hw(sc)) != 0) {
+ printf("%s: could not initialize hardware\n", DEVNAME(sc));
return error;
+ }
- if ((error = iwm_start_hw(sc)) != 0)
- return error;
+ if (sc->sc_flags & IWM_FLAG_ATTACHED)
+ return 0;
- if ((error = iwm_run_init_mvm_ucode(sc, 1)) != 0) {
+ if ((error = iwm_start_hw(sc)) != 0) {
+ printf("%s: could not initialize hardware\n", DEVNAME(sc));
return error;
}
+ error = iwm_run_init_mvm_ucode(sc, 1);
iwm_stop_device(sc);
- return 0;
+ return error;
}
void
@@ -6460,80 +6446,15 @@ iwm_attach_hook(struct device *dev)
struct iwm_softc *sc = device_private(dev);
struct ieee80211com *ic = &sc->sc_ic;
struct ifnet *ifp = &sc->sc_ec.ec_if;
- int error;
- int txq_i, i;
KASSERT(!cold);
sc->sc_wantresp = -1;
- /* only one firmware possibility for now */
- sc->sc_fwname = IWM_FWNAME;
- sc->sc_fwdmasegsz = IWM_FWDMASEGSZ;
-
- /*
- * We now start fiddling with the hardware
- */
-
- sc->sc_hw_rev = IWM_READ(sc, IWM_CSR_HW_REV);
- if (iwm_prepare_card_hw(sc) != 0) {
- printf("%s: failed to init hw\n", DEVNAME(sc));
+ if (iwm_preinit(sc) != 0)
return;
- }
-
- /* Allocate DMA memory for firmware transfers. */
- if ((error = iwm_alloc_fwmem(sc)) != 0) {
- printf("%s: could not allocate memory for firmware\n",
- DEVNAME(sc));
- return;
- }
-
- /* Allocate "Keep Warm" page. */
- if ((error = iwm_alloc_kw(sc)) != 0) {
- printf("%s: could not allocate keep warm page\n", DEVNAME(sc));
- goto fail1;
- }
-
- /* We use ICT interrupts */
- if ((error = iwm_alloc_ict(sc)) != 0) {
- printf("%s: could not allocate ICT table\n", DEVNAME(sc));
- goto fail2;
- }
-
- /* Allocate TX scheduler "rings". */
- if ((error = iwm_alloc_sched(sc)) != 0) {
- printf("%s: could not allocate TX scheduler rings\n",
- DEVNAME(sc));
- goto fail3;
- }
-
- /* Allocate TX rings */
- for (txq_i = 0; txq_i < __arraycount(sc->txq); txq_i++) {
- if ((error = iwm_alloc_tx_ring(sc,
- &sc->txq[txq_i], txq_i)) != 0) {
- printf("%s: could not allocate TX ring %d\n",
- DEVNAME(sc), txq_i);
- goto fail4;
- }
- }
-
- /* Allocate RX ring. */
- if ((error = iwm_alloc_rx_ring(sc, &sc->rxq)) != 0) {
- printf("%s: could not allocate RX ring\n", DEVNAME(sc));
- goto fail4;
- }
- workqueue_create(&sc->sc_eswq, "iwmes",
- (void *)iwm_endscan_cb, sc, PRI_NONE, IPL_NET, 0);
- workqueue_create(&sc->sc_nswq, "iwmns",
- (void *)iwm_newstate_cb, sc, PRI_NONE, IPL_NET, 0);
-
- /* Clear pending interrupts. */
- IWM_WRITE(sc, IWM_CSR_INT, 0xffffffff);
-
- if ((error = iwm_preinit(sc)) != 0) {
- goto fail4;
- }
+ sc->sc_flags |= IWM_FLAG_ATTACHED;
ic->ic_ifp = ifp;
printf("%s: hw rev: 0x%x, fw ver %d.%d (API ver %d), address %s\n",
@@ -6549,15 +6470,18 @@ iwm_attach_hook(struct device *dev)
/* Set device capabilities. */
ic->ic_caps =
+ IEEE80211_C_WEP | /* WEP */
IEEE80211_C_WPA | /* 802.11i */
IEEE80211_C_SHSLOT | /* short slot time supported */
IEEE80211_C_SHPREAMBLE; /* short preamble supported */
- ic->ic_sup_rates[IEEE80211_MODE_11A] = iwm_rateset_11a;
- ic->ic_sup_rates[IEEE80211_MODE_11B] = iwm_rateset_11b;
- ic->ic_sup_rates[IEEE80211_MODE_11G] = iwm_rateset_11g;
+#ifndef IWM_NO_5GHZ
+ ic->ic_sup_rates[IEEE80211_MODE_11A] = ieee80211_std_rateset_11a;
+#endif
+ ic->ic_sup_rates[IEEE80211_MODE_11B] = ieee80211_std_rateset_11b;
+ ic->ic_sup_rates[IEEE80211_MODE_11G] = ieee80211_std_rateset_11g;
- for (i = 0; i < __arraycount(sc->sc_phyctxt); i++) {
+ for (int i = 0; i < __arraycount(sc->sc_phyctxt); i++) {
sc->sc_phyctxt[i].id = i;
}
@@ -6600,18 +6524,6 @@ iwm_attach_hook(struct device *dev)
iwm_radiotap_attach(sc);
//task_set(&sc->init_task, iwm_init_task, sc);
-
- return;
-
- /* Free allocated memory if something failed during attachment. */
-fail4: while (--txq_i >= 0)
- iwm_free_tx_ring(sc, &sc->txq[txq_i]);
- iwm_free_sched(sc);
-fail3: if (sc->ict_dma.vaddr != NULL)
- iwm_free_ict(sc);
-fail2: iwm_free_kw(sc);
-fail1: iwm_free_fwmem(sc);
- return;
}
void
@@ -6624,6 +6536,7 @@ iwm_attach(struct device *parent, struct
pcireg_t reg, memtype;
const char *intrstr;
int error;
+ int txq_i;
sc->sc_pct = pa->pa_pc;
sc->sc_pcitag = pa->pa_tag;
@@ -6684,6 +6597,70 @@ iwm_attach(struct device *parent, struct
}
printf(", %s\n", intrstr);
+ /* only one firmware possibility for now */
+ sc->sc_fwname = IWM_FWNAME;
+ sc->sc_fwdmasegsz = IWM_FWDMASEGSZ;
+
+ /*
+ * We now start fiddling with the hardware
+ */
+
+ sc->sc_hw_rev = IWM_READ(sc, IWM_CSR_HW_REV);
+ if (iwm_prepare_card_hw(sc) != 0) {
+ printf("%s: could not initialize hardware\n", DEVNAME(sc));
+ return;
+ }
+
+ /* Allocate DMA memory for firmware transfers. */
+ if ((error = iwm_alloc_fwmem(sc)) != 0) {
+ printf("%s: could not allocate memory for firmware\n",
+ DEVNAME(sc));
+ return;
+ }
+
+ /* Allocate "Keep Warm" page. */
+ if ((error = iwm_alloc_kw(sc)) != 0) {
+ printf("%s: could not allocate keep warm page\n", DEVNAME(sc));
+ goto fail1;
+ }
+
+ /* We use ICT interrupts */
+ if ((error = iwm_alloc_ict(sc)) != 0) {
+ printf("%s: could not allocate ICT table\n", DEVNAME(sc));
+ goto fail2;
+ }
+
+ /* Allocate TX scheduler "rings". */
+ if ((error = iwm_alloc_sched(sc)) != 0) {
+ printf("%s: could not allocate TX scheduler rings\n",
+ DEVNAME(sc));
+ goto fail3;
+ }
+
+ /* Allocate TX rings */
+ for (txq_i = 0; txq_i < __arraycount(sc->txq); txq_i++) {
+ if ((error = iwm_alloc_tx_ring(sc,
+ &sc->txq[txq_i], txq_i)) != 0) {
+ printf("%s: could not allocate TX ring %d\n",
+ DEVNAME(sc), txq_i);
+ goto fail4;
+ }
+ }
+
+ /* Allocate RX ring. */
+ if ((error = iwm_alloc_rx_ring(sc, &sc->rxq)) != 0) {
+ printf("%s: could not allocate RX ring\n", DEVNAME(sc));
+ goto fail4;
+ }
+
+ workqueue_create(&sc->sc_eswq, "iwmes",
+ (void *)iwm_endscan_cb, sc, PRI_NONE, IPL_NET, 0);
+ workqueue_create(&sc->sc_nswq, "iwmns",
+ (void *)iwm_newstate_cb, sc, PRI_NONE, IPL_NET, 0);
+
+ /* Clear pending interrupts. */
+ IWM_WRITE(sc, IWM_CSR_INT, 0xffffffff);
+
/*
* We can't do normal attach before the file system is mounted
* because we cannot read the MAC address without loading the
@@ -6693,6 +6670,17 @@ iwm_attach(struct device *parent, struct
* hook runs.
*/
config_mountroot(self, iwm_attach_hook);
+
+ return;
+
+ /* Free allocated memory if something failed during attachment. */
+fail4: while (--txq_i >= 0)
+ iwm_free_tx_ring(sc, &sc->txq[txq_i]);
+ iwm_free_sched(sc);
+fail3: if (sc->ict_dma.vaddr != NULL)
+ iwm_free_ict(sc);
+fail2: iwm_free_kw(sc);
+fail1: iwm_free_fwmem(sc);
}
/*
Index: src/sys/dev/pci/if_iwmvar.h
diff -u src/sys/dev/pci/if_iwmvar.h:1.1 src/sys/dev/pci/if_iwmvar.h:1.2
--- src/sys/dev/pci/if_iwmvar.h:1.1 Sat Feb 7 13:20:00 2015
+++ src/sys/dev/pci/if_iwmvar.h Fri Feb 13 17:14:06 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: if_iwmvar.h,v 1.1 2015/02/07 13:20:00 pooka Exp $ */
+/* $NetBSD: if_iwmvar.h,v 1.2 2015/02/13 17:14:06 nonaka Exp $ */
/* OpenBSD: if_iwmvar.h,v 1.3 2015/02/07 07:10:44 phessler Exp */
/*
@@ -293,6 +293,7 @@ struct iwm_rx_ring {
#define IWM_FLAG_STOPPED 0x04
#define IWM_FLAG_RFKILL 0x08
#define IWM_FLAG_BUSY 0x10
+#define IWM_FLAG_ATTACHED 0x20
struct iwm_ucode_status {
uint32_t uc_error_event_table;