Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci update from OpenBSD by msaitoh. Tested on amd64.
details: https://anonhg.NetBSD.org/src/rev/7d4dc6c70e58
branches: trunk
changeset: 764990:7d4dc6c70e58
user: christos <christos%NetBSD.org@localhost>
date: Sun May 15 13:56:20 2011 +0000
description:
update from OpenBSD by msaitoh. Tested on amd64.
diffstat:
sys/dev/pci/if_iwn.c | 551 +++++++++++++++++++++--------------------------
sys/dev/pci/if_iwnreg.h | 56 ++++-
sys/dev/pci/if_iwnvar.h | 28 +-
3 files changed, 311 insertions(+), 324 deletions(-)
diffs (truncated from 1591 to 300 lines):
diff -r e3ac8f343dbe -r 7d4dc6c70e58 sys/dev/pci/if_iwn.c
--- a/sys/dev/pci/if_iwn.c Sun May 15 13:55:21 2011 +0000
+++ b/sys/dev/pci/if_iwn.c Sun May 15 13:56:20 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_iwn.c,v 1.52 2010/12/30 19:27:27 jruoho Exp $ */
+/* $NetBSD: if_iwn.c,v 1.53 2011/05/15 13:56:20 christos Exp $ */
/* $OpenBSD: if_iwn.c,v 1.96 2010/05/13 09:25:03 damien Exp $ */
/*-
@@ -22,14 +22,11 @@
* adapters.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_iwn.c,v 1.52 2010/12/30 19:27:27 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwn.c,v 1.53 2011/05/15 13:56:20 christos Exp $");
#define IWN_USE_RBUF /* Use local storage for RX */
#undef IWN_HWCRYPTO /* XXX does not even compile yet */
-/* XXX Avoid sensor code (correct option for NetBSD too?) */
-#undef SMALL_KERNEL
-
#include <sys/param.h>
#include <sys/sockio.h>
#include <sys/proc.h>
@@ -125,10 +122,8 @@
static int iwn_match(device_t , struct cfdata *, void *);
static void iwn_attach(device_t , device_t , void *);
-const struct iwn_hal *iwn_hal_attach(struct iwn_softc *, pci_product_id_t pid);
-#ifndef SMALL_KERNEL
-static void iwn_sensor_attach(struct iwn_softc *);
-#endif
+static int iwn4965_attach(struct iwn_softc *, pci_product_id_t);
+static int iwn5000_attach(struct iwn_softc *, pci_product_id_t);
static void iwn_radiotap_attach(struct iwn_softc *);
static int iwn_detach(device_t , int);
#if 0
@@ -160,6 +155,8 @@
static void iwn5000_ict_reset(struct iwn_softc *);
static int iwn_read_eeprom(struct iwn_softc *);
static void iwn4965_read_eeprom(struct iwn_softc *);
+
+#define IWN_DEBUG 1
#ifdef IWN_DEBUG
static void iwn4965_print_power_group(struct iwn_softc *, int);
#endif
@@ -276,11 +273,11 @@
static int iwn4965_load_firmware(struct iwn_softc *);
static int iwn5000_load_firmware_section(struct iwn_softc *, uint32_t,
const uint8_t *, int);
+static int iwn5000_load_firmware(struct iwn_softc *);
static int iwn_read_firmware_leg(struct iwn_softc *,
struct iwn_fw_info *);
static int iwn_read_firmware_tlv(struct iwn_softc *,
struct iwn_fw_info *, uint16_t);
-static int iwn5000_load_firmware(struct iwn_softc *);
static int iwn_read_firmware(struct iwn_softc *);
static int iwn_clock_wait(struct iwn_softc *);
static int iwn_apm_init(struct iwn_softc *);
@@ -322,62 +319,6 @@
#define DPRINTFN(n, x)
#endif
-static const struct iwn_hal iwn4965_hal = {
- iwn4965_load_firmware,
- iwn4965_read_eeprom,
- iwn4965_post_alive,
- iwn4965_nic_config,
- iwn4965_update_sched,
- iwn4965_get_temperature,
- iwn4965_get_rssi,
- iwn4965_set_txpower,
- iwn4965_init_gains,
- iwn4965_set_gains,
- iwn4965_add_node,
- iwn4965_tx_done,
-#ifndef IEEE80211_NO_HT
- iwn4965_ampdu_tx_start,
- iwn4965_ampdu_tx_stop,
-#endif
- IWN4965_NTXQUEUES,
- IWN4965_NDMACHNLS,
- IWN4965_ID_BROADCAST,
- IWN4965_RXONSZ,
- IWN4965_SCHEDSZ,
- IWN4965_FW_TEXT_MAXSZ,
- IWN4965_FW_DATA_MAXSZ,
- IWN4965_FWSZ,
- IWN4965_SCHED_TXFACT
-};
-
-static const struct iwn_hal iwn5000_hal = {
- iwn5000_load_firmware,
- iwn5000_read_eeprom,
- iwn5000_post_alive,
- iwn5000_nic_config,
- iwn5000_update_sched,
- iwn5000_get_temperature,
- iwn5000_get_rssi,
- iwn5000_set_txpower,
- iwn5000_init_gains,
- iwn5000_set_gains,
- iwn5000_add_node,
- iwn5000_tx_done,
-#ifndef IEEE80211_NO_HT
- iwn5000_ampdu_tx_start,
- iwn5000_ampdu_tx_stop,
-#endif
- IWN5000_NTXQUEUES,
- IWN5000_NDMACHNLS,
- IWN5000_ID_BROADCAST,
- IWN5000_RXONSZ,
- IWN5000_SCHEDSZ,
- IWN5000_FW_TEXT_MAXSZ,
- IWN5000_FW_DATA_MAXSZ,
- IWN5000_FWSZ,
- IWN5000_SCHED_TXFACT
-};
-
CFATTACH_DECL_NEW(iwn, sizeof(struct iwn_softc), iwn_match, iwn_attach,
iwn_detach, NULL);
@@ -404,7 +345,6 @@
struct ieee80211com *ic = &sc->sc_ic;
struct ifnet *ifp = &sc->sc_ec.ec_if;
struct pci_attach_args *pa = aux;
- const struct iwn_hal *hal;
const char *intrstr;
char devinfo[256];
pci_intr_handle_t ih;
@@ -438,8 +378,8 @@
/* Clear device-specific "PCI retry timeout" register (41h). */
reg = pci_conf_read(sc->sc_pct, sc->sc_pcitag, 0x40);
- reg &= ~0xff00;
- pci_conf_write(sc->sc_pct, sc->sc_pcitag, 0x40, reg);
+ if (reg & 0xff00)
+ pci_conf_write(sc->sc_pct, sc->sc_pcitag, 0x40, reg & ~0xff00);
/* Enable bus-mastering and hardware bug workaround. */
/* XXX verify the bus-mastering is really needed (not in OpenBSD) */
@@ -475,10 +415,16 @@
}
aprint_normal_dev(self, "interrupting at %s\n", intrstr);
- /* Attach Hardware Abstraction Layer. */
- hal = iwn_hal_attach(sc, PCI_PRODUCT(pa->pa_id));
- if (hal == NULL)
+ /* Read hardware revision and attach. */
+ sc->hw_type = (IWN_READ(sc, IWN_HW_REV) >> 4) & 0xf;
+ if (sc->hw_type == IWN_HW_REV_TYPE_4965)
+ error = iwn4965_attach(sc, PCI_PRODUCT(pa->pa_id));
+ else
+ error = iwn5000_attach(sc, PCI_PRODUCT(pa->pa_id));
+ if (error != 0) {
+ aprint_error(": could not attach device\n");
return;
+ }
if ((error = iwn_hw_prepare(sc)) != 0) {
aprint_error(": hardware not ready\n");
@@ -524,8 +470,8 @@
}
#endif
- /* Allocate TX rings (16 on 4965AGN, 20 on 5000.) */
- for (i = 0; i < hal->ntxqs; i++) {
+ /* Allocate TX rings (16 on 4965AGN, 20 on >=5000). */
+ for (i = 0; i < sc->ntxqs; i++) {
if ((error = iwn_alloc_tx_ring(sc, &sc->txq[i], i)) != 0) {
aprint_error(": could not allocate TX ring %d\n", i);
goto fail4;
@@ -572,20 +518,22 @@
IEEE80211_C_WME; /* 802.11e */
#ifndef IEEE80211_NO_HT
- /* Set HT capabilities. */
- ic->ic_htcaps =
+ if (sc->sc_flags & IWN_FLAG_HAS_11N) {
+ /* Set HT capabilities. */
+ ic->ic_htcaps =
#if IWN_RBUF_SIZE == 8192
- IEEE80211_HTCAP_AMSDU7935 |
+ IEEE80211_HTCAP_AMSDU7935 |
#endif
- IEEE80211_HTCAP_CBW20_40 |
- IEEE80211_HTCAP_SGI20 |
- IEEE80211_HTCAP_SGI40;
- if (sc->hw_type != IWN_HW_REV_TYPE_4965)
- ic->ic_htcaps |= IEEE80211_HTCAP_GF;
- if (sc->hw_type == IWN_HW_REV_TYPE_6050)
- ic->ic_htcaps |= IEEE80211_HTCAP_SMPS_DYN;
- else
- ic->ic_htcaps |= IEEE80211_HTCAP_SMPS_DIS;
+ IEEE80211_HTCAP_CBW20_40 |
+ IEEE80211_HTCAP_SGI20 |
+ IEEE80211_HTCAP_SGI40;
+ if (sc->hw_type != IWN_HW_REV_TYPE_4965)
+ ic->ic_htcaps |= IEEE80211_HTCAP_GF;
+ if (sc->hw_type == IWN_HW_REV_TYPE_6050)
+ ic->ic_htcaps |= IEEE80211_HTCAP_SMPS_DYN;
+ else
+ ic->ic_htcaps |= IEEE80211_HTCAP_SMPS_DIS;
+ }
#endif /* !IEEE80211_NO_HT */
/* Set supported legacy rates. */
@@ -595,12 +543,14 @@
ic->ic_sup_rates[IEEE80211_MODE_11A] = iwn_rateset_11a;
}
#ifndef IEEE80211_NO_HT
- /* Set supported HT rates. */
- ic->ic_sup_mcs[0] = 0xff;
- if (sc->nrxchains > 1) /* MCS 0-7 */
- ic->ic_sup_mcs[1] = 0xff; /* MCS 7-15 */
- if (sc->nrxchains > 2)
- ic->ic_sup_mcs[2] = 0xff; /* MCS 16-23 */
+ if (sc->sc_flags & IWN_FLAG_HAS_11N) {
+ /* Set supported HT rates. */
+ ic->ic_sup_mcs[0] = 0xff; /* MCS 0-7 */
+ if (sc->nrxchains > 1)
+ ic->ic_sup_mcs[1] = 0xff; /* MCS 7-15 */
+ if (sc->nrxchains > 2)
+ ic->ic_sup_mcs[2] = 0xff; /* MCS 16-23 */
+ }
#endif
/* IBSS channel undefined for now. */
@@ -640,9 +590,6 @@
sc->amrr.amrr_min_success_threshold = 1;
sc->amrr.amrr_max_success_threshold = 15;
-#ifndef SMALL_KERNEL
- iwn_sensor_attach(sc);
-#endif
iwn_radiotap_attach(sc);
/*
@@ -673,131 +620,123 @@
fail1: iwn_free_fwmem(sc);
}
-const struct iwn_hal *
-iwn_hal_attach(struct iwn_softc *sc, pci_product_id_t pid)
+int
+iwn4965_attach(struct iwn_softc *sc, pci_product_id_t pid)
{
- sc->hw_type = (IWN_READ(sc, IWN_HW_REV) >> 4) & 0xf;
+ struct iwn_ops *ops = &sc->ops;
+
+ ops->load_firmware = iwn4965_load_firmware;
+ ops->read_eeprom = iwn4965_read_eeprom;
+ ops->post_alive = iwn4965_post_alive;
+ ops->nic_config = iwn4965_nic_config;
+ ops->update_sched = iwn4965_update_sched;
+ ops->get_temperature = iwn4965_get_temperature;
+ ops->get_rssi = iwn4965_get_rssi;
+ ops->set_txpower = iwn4965_set_txpower;
+ ops->init_gains = iwn4965_init_gains;
+ ops->set_gains = iwn4965_set_gains;
+ ops->add_node = iwn4965_add_node;
+ ops->tx_done = iwn4965_tx_done;
+#ifndef IEEE80211_NO_HT
+ ops->ampdu_tx_start = iwn4965_ampdu_tx_start;
+ ops->ampdu_tx_stop = iwn4965_ampdu_tx_stop;
+#endif
+ sc->ntxqs = IWN4965_NTXQUEUES;
+ sc->ndmachnls = IWN4965_NDMACHNLS;
+ sc->broadcast_id = IWN4965_ID_BROADCAST;
+ sc->rxonsz = IWN4965_RXONSZ;
+ sc->schedsz = IWN4965_SCHEDSZ;
+ sc->fw_text_maxsz = IWN4965_FW_TEXT_MAXSZ;
+ sc->fw_data_maxsz = IWN4965_FW_DATA_MAXSZ;
+ sc->fwsz = IWN4965_FWSZ;
+ sc->sched_txfact_addr = IWN4965_SCHED_TXFACT;
+ sc->limits = &iwn4965_sensitivity_limits;
+ sc->fwname = "iwlwifi-4965-2.ucode";
+ /* Override chains masks, ROM is known to be broken. */
+ sc->txchainmask = IWN_ANT_AB;
+ sc->rxchainmask = IWN_ANT_ABC;
+
+ return 0;
+}
+
+int
+iwn5000_attach(struct iwn_softc *sc, pci_product_id_t pid)
+{
+ struct iwn_ops *ops = &sc->ops;
+
+ ops->load_firmware = iwn5000_load_firmware;
+ ops->read_eeprom = iwn5000_read_eeprom;
+ ops->post_alive = iwn5000_post_alive;
+ ops->nic_config = iwn5000_nic_config;
+ ops->update_sched = iwn5000_update_sched;
+ ops->get_temperature = iwn5000_get_temperature;
+ ops->get_rssi = iwn5000_get_rssi;
+ ops->set_txpower = iwn5000_set_txpower;
+ ops->init_gains = iwn5000_init_gains;
+ ops->set_gains = iwn5000_set_gains;
Home |
Main Index |
Thread Index |
Old Index