summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/if_ipw.c239
-rw-r--r--sys/dev/pci/if_ipwreg.h21
2 files changed, 123 insertions, 137 deletions
diff --git a/sys/dev/pci/if_ipw.c b/sys/dev/pci/if_ipw.c
index 440dc59a93b..79b5e77120d 100644
--- a/sys/dev/pci/if_ipw.c
+++ b/sys/dev/pci/if_ipw.c
@@ -1,4 +1,4 @@
-/* $Id: if_ipw.c,v 1.1 2004/10/20 12:50:48 deraadt Exp $ */
+/* $Id: if_ipw.c,v 1.2 2004/10/27 21:10:22 damien Exp $ */
/*-
* Copyright (c) 2004
@@ -29,7 +29,7 @@
/*-
* Intel(R) PRO/Wireless 2100 MiniPCI driver
- * http://www.intel.com/products/mobiletechnology/prowireless.htm
+ * www.intel.com/network/connectivity/products/wireless/prowireless_mobile.htm
*/
#include "bpfilter.h"
@@ -70,8 +70,8 @@
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h>
-#include "if_ipwreg.h"
-#include "if_ipwvar.h"
+#include <dev/pci/if_ipwreg.h>
+#include <dev/pci/if_ipwvar.h>
static int ipw_match(struct device *, void *, void *);
static void ipw_attach(struct device *, struct device *, void *);
@@ -80,7 +80,7 @@ static int ipw_media_change(struct ifnet *);
static int ipw_newstate(struct ieee80211com *, enum ieee80211_state, int);
static void ipw_command_intr(struct ipw_softc *, struct ipw_soft_buf *);
static void ipw_newstate_intr(struct ipw_softc *, struct ipw_soft_buf *);
-static void ipw_data_intr(struct ipw_softc *, struct ipw_status *,
+static void ipw_data_intr(struct ipw_softc *, struct ipw_status *,
struct ipw_soft_bd *, struct ipw_soft_buf *);
static void ipw_notification_intr(struct ipw_softc *, struct ipw_soft_buf *);
static void ipw_rx_intr(struct ipw_softc *);
@@ -109,25 +109,19 @@ static int ipw_firmware_init(struct ipw_softc *, u_char *);
static int ipw_config(struct ipw_softc *);
static int ipw_init(struct ifnet *);
static void ipw_stop(struct ifnet *, int);
-static void ipw_read_mem_1(struct ipw_softc *, bus_size_t, u_int8_t *,
+static void ipw_read_mem_1(struct ipw_softc *, bus_size_t, u_int8_t *,
bus_size_t);
-static void ipw_write_mem_1(struct ipw_softc *, bus_size_t, u_int8_t *,
+static void ipw_write_mem_1(struct ipw_softc *, bus_size_t, u_int8_t *,
bus_size_t);
static void ipw_zero_mem_4(struct ipw_softc *, bus_size_t, bus_size_t);
-static inline u_int8_t MEM_READ_1(struct ipw_softc *sc, u_int32_t addr)
+static __inline u_int8_t MEM_READ_1(struct ipw_softc *sc, u_int32_t addr)
{
CSR_WRITE_4(sc, IPW_CSR_INDIRECT_ADDR, addr);
return CSR_READ_1(sc, IPW_CSR_INDIRECT_DATA);
}
-static inline u_int16_t MEM_READ_2(struct ipw_softc *sc, u_int32_t addr)
-{
- CSR_WRITE_4(sc, IPW_CSR_INDIRECT_ADDR, addr);
- return CSR_READ_2(sc, IPW_CSR_INDIRECT_DATA);
-}
-
-static inline u_int32_t MEM_READ_4(struct ipw_softc *sc, u_int32_t addr)
+static __inline u_int32_t MEM_READ_4(struct ipw_softc *sc, u_int32_t addr)
{
CSR_WRITE_4(sc, IPW_CSR_INDIRECT_ADDR, addr);
return CSR_READ_4(sc, IPW_CSR_INDIRECT_DATA);
@@ -151,7 +145,7 @@ ipw_match(struct device *parent, void *match, void *aux)
{
struct pci_attach_args *pa = aux;
- if (PCI_VENDOR (pa->pa_id) == PCI_VENDOR_INTEL &&
+ if (PCI_VENDOR (pa->pa_id) == PCI_VENDOR_INTEL &&
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_PRO_2100_3B)
return 1;
@@ -159,7 +153,7 @@ ipw_match(struct device *parent, void *match, void *aux)
}
/* Base Address Register */
-#define IPW_PCI_BAR0 0x10
+#define IPW_PCI_BAR0 0x10
static void
ipw_attach(struct device *parent, struct device *self, void *aux)
@@ -175,7 +169,7 @@ ipw_attach(struct device *parent, struct device *self, void *aux)
bus_addr_t base;
pci_intr_handle_t ih;
u_int32_t data;
- int i, error;
+ int error, i;
sc->sc_pct = pa->pa_pc;
@@ -185,7 +179,7 @@ ipw_attach(struct device *parent, struct device *self, void *aux)
pci_conf_write(sc->sc_pct, pa->pa_tag, PCI_COMMAND_STATUS_REG, data);
/* map the register window */
- error = pci_mapreg_map(pa, IPW_PCI_BAR0, PCI_MAPREG_TYPE_MEM |
+ error = pci_mapreg_map(pa, IPW_PCI_BAR0, PCI_MAPREG_TYPE_MEM |
PCI_MAPREG_MEM_TYPE_32BIT, 0, &memt, &memh, &base, &sc->sc_sz, 0);
if (error != 0) {
printf(": could not map memory space\n");
@@ -221,10 +215,10 @@ ipw_attach(struct device *parent, struct device *self, void *aux)
ic->ic_state = IEEE80211_S_INIT;
/* set device capabilities */
- ic->ic_caps = IEEE80211_C_IBSS | IEEE80211_C_MONITOR |
+ ic->ic_caps = IEEE80211_C_IBSS | IEEE80211_C_MONITOR |
IEEE80211_C_PMGT | IEEE80211_C_TXPMGT | IEEE80211_C_WEP;
- /* set supported 11.b rates */
+ /* set supported .11b rates */
rs = &ic->ic_sup_rates[IEEE80211_MODE_11B];
rs->rs_nrates = 4;
rs->rs_rates[0] = 2; /* 1Mbps */
@@ -232,13 +226,14 @@ ipw_attach(struct device *parent, struct device *self, void *aux)
rs->rs_rates[2] = 11; /* 5.5Mbps */
rs->rs_rates[3] = 22; /* 11Mbps */
- /* set supported 11.b channels (1 through 14) */
+ /* set supported .11b channels (1 through 14) */
for (i = 1; i <= 14; i++) {
- ic->ic_channels[i].ic_freq =
+ ic->ic_channels[i].ic_freq =
ieee80211_ieee2mhz(i, IEEE80211_CHAN_B);
ic->ic_channels[i].ic_flags = IEEE80211_CHAN_B;
}
+ /* IBSS channel undefined for now */
ic->ic_ibss_chan = &ic->ic_channels[0];
ifp->if_softc = sc;
@@ -255,11 +250,10 @@ ipw_attach(struct device *parent, struct device *self, void *aux)
/* override state transition machine */
sc->sc_newstate = ic->ic_newstate;
ic->ic_newstate = ipw_newstate;
-
ieee80211_media_init(ifp, ipw_media_change, ieee80211_media_status);
#if NBPFILTER > 0
- bpfattach(&sc->sc_drvbpf, ifp, DLT_IEEE802_11_RADIO,
+ bpfattach(&sc->sc_drvbpf, ifp, DLT_IEEE802_11_RADIO,
sizeof (struct ieee80211_frame) + 64);
sc->sc_rxtap_len = sizeof sc->sc_rxtapu;
@@ -314,15 +308,11 @@ ipw_media_change(struct ifnet *ifp)
static int
ipw_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
{
- struct ifnet *ifp = &ic->ic_if;
- struct ipw_softc *sc = ifp->if_softc;
+ struct ipw_softc *sc = ic->ic_softc;
struct ieee80211_node *ni = ic->ic_bss;
u_int32_t val, len;
switch (nstate) {
- case IEEE80211_S_INIT:
- break;
-
case IEEE80211_S_RUN:
len = IEEE80211_NWID_LEN;
ipw_read_table2(sc, IPW_INFO_CURRENT_SSID, ni->ni_essid, &len);
@@ -337,6 +327,7 @@ ipw_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
ipw_read_table2(sc, IPW_INFO_CURRENT_BSSID, ni->ni_bssid, &len);
break;
+ case IEEE80211_S_INIT:
case IEEE80211_S_SCAN:
case IEEE80211_S_AUTH:
case IEEE80211_S_ASSOC:
@@ -357,12 +348,12 @@ ipw_command_intr(struct ipw_softc *sc, struct ipw_soft_buf *sbuf)
cmd = mtod(sbuf->m, struct ipw_cmd *);
- DPRINTFN(2, ("RX!CMD!%u!%u!%u!%u!%u\n",
+ DPRINTFN(2, ("RX!CMD!%u!%u!%u!%u!%u\n",
letoh32(cmd->type), letoh32(cmd->subtype), letoh32(cmd->seq),
letoh32(cmd->len), letoh32(cmd->status)));
- /*
- * Wake up processes waiting for command ack. In the case of the
+ /*
+ * Wake up processes waiting for command ack. In the case of the
* IPW_CMD_DISABLE command, wake up the process only when the adapter
* enters the IPW_STATE_DISABLED state. This is notified in
* ipw_newstate_intr().
@@ -408,7 +399,7 @@ ipw_newstate_intr(struct ipw_softc *sc, struct ipw_soft_buf *sbuf)
}
static void
-ipw_data_intr(struct ipw_softc *sc, struct ipw_status *status,
+ipw_data_intr(struct ipw_softc *sc, struct ipw_status *status,
struct ipw_soft_bd *sbd, struct ipw_soft_buf *sbuf)
{
struct ieee80211com *ic = &sc->sc_ic;
@@ -454,7 +445,7 @@ ipw_data_intr(struct ipw_softc *sc, struct ipw_status *status,
ni = ieee80211_find_rxnode(ic, wh);
/* Send it up to the upper layer */
- ieee80211_input(ifp, m, ni, status->rssi, 0/*rstamp*/);
+ ieee80211_input(ifp, m, ni, status->rssi, 0);
if (ni == ic->ic_bss)
ieee80211_unref_node(&ni);
@@ -463,22 +454,22 @@ ipw_data_intr(struct ipw_softc *sc, struct ipw_status *status,
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL) {
- printf("%s: could not allocate rx mbuf\n",
+ printf("%s: could not allocate rx mbuf\n",
sc->sc_dev.dv_xname);
return;
}
MCLGET(m, M_DONTWAIT);
if (!(m->m_flags & M_EXT)) {
m_freem(m);
- printf("%s: could not allocate rx mbuf cluster\n",
+ printf("%s: could not allocate rx mbuf cluster\n",
sc->sc_dev.dv_xname);
return;
}
- error = bus_dmamap_load(sc->sc_dmat, sbuf->map, mtod(m, void *),
+ error = bus_dmamap_load(sc->sc_dmat, sbuf->map, mtod(m, void *),
MCLBYTES, NULL, BUS_DMA_NOWAIT);
if (error != 0) {
- printf("%s: could not map rxbuf dma memory\n",
+ printf("%s: could not map rxbuf dma memory\n",
sc->sc_dev.dv_xname);
m_freem(m);
return;
@@ -506,12 +497,12 @@ ipw_rx_intr(struct ipw_softc *sc)
for (i = (sc->rxcur + 1) % IPW_NRBD; i != r; i = (i + 1) % IPW_NRBD) {
- bus_dmamap_sync(sc->sc_dmat, sc->rbd_map,
- i * sizeof (struct ipw_bd), sizeof (struct ipw_bd),
+ bus_dmamap_sync(sc->sc_dmat, sc->rbd_map,
+ i * sizeof (struct ipw_bd), sizeof (struct ipw_bd),
BUS_DMASYNC_POSTREAD);
- bus_dmamap_sync(sc->sc_dmat, sc->status_map,
- i * sizeof (struct ipw_status), sizeof (struct ipw_status),
+ bus_dmamap_sync(sc->sc_dmat, sc->status_map,
+ i * sizeof (struct ipw_status), sizeof (struct ipw_status),
BUS_DMASYNC_POSTREAD);
status = &sc->status_list[i];
@@ -537,13 +528,13 @@ ipw_rx_intr(struct ipw_softc *sc)
break;
default:
- printf("%s: unknown status code %u\n",
+ printf("%s: unknown status code %u\n",
sc->sc_dev.dv_xname, letoh16(status->code));
}
sbd->bd->flags = 0;
- bus_dmamap_sync(sc->sc_dmat, sc->rbd_map,
- i * sizeof (struct ipw_bd), sizeof (struct ipw_bd),
+ bus_dmamap_sync(sc->sc_dmat, sc->rbd_map,
+ i * sizeof (struct ipw_bd), sizeof (struct ipw_bd),
BUS_DMASYNC_PREWRITE);
}
@@ -646,10 +637,10 @@ ipw_cmd(struct ipw_softc *sc, u_int32_t type, void *data, u_int32_t len)
sbd = &sc->stbd_list[sc->txcur];
- error = bus_dmamap_load(sc->sc_dmat, sc->cmd_map, sc->cmd,
+ error = bus_dmamap_load(sc->sc_dmat, sc->cmd_map, sc->cmd,
sizeof (struct ipw_cmd), NULL, BUS_DMA_NOWAIT);
if (error != 0) {
- printf("%s: could not map cmd dma memory\n",
+ printf("%s: could not map cmd dma memory\n",
sc->sc_dev.dv_xname);
return error;
}
@@ -665,13 +656,13 @@ ipw_cmd(struct ipw_softc *sc, u_int32_t type, void *data, u_int32_t len)
sbd->bd->physaddr = htole32(sc->cmd_map->dm_segs[0].ds_addr);
sbd->bd->len = htole32(sizeof (struct ipw_cmd));
sbd->bd->nfrag = 1;
- sbd->bd->flags = IPW_BD_FLAG_TX_FRAME_COMMAND |
+ sbd->bd->flags = IPW_BD_FLAG_TX_FRAME_COMMAND |
IPW_BD_FLAG_TX_LAST_FRAGMENT;
bus_dmamap_sync(sc->sc_dmat, sc->cmd_map, 0, sizeof (struct ipw_cmd),
BUS_DMASYNC_PREWRITE);
- bus_dmamap_sync(sc->sc_dmat, sc->tbd_map,
+ bus_dmamap_sync(sc->sc_dmat, sc->tbd_map,
sc->txcur * sizeof (struct ipw_bd), sizeof (struct ipw_bd),
BUS_DMASYNC_PREWRITE);
@@ -741,12 +732,12 @@ ipw_tx_start(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni)
m_adj(m, sizeof (struct ieee80211_frame));
/*
- * We need to map the mbuf first to know how many buffer descriptors
+ * We need to map the mbuf first to know how many buffer descriptors
* are needed for this transfer.
*/
error = bus_dmamap_load_mbuf(sc->sc_dmat, sbuf->map, m, BUS_DMA_NOWAIT);
if (error != 0) {
- printf("%s: could not map mbuf (error %d)\n",
+ printf("%s: could not map mbuf (error %d)\n",
sc->sc_dev.dv_xname, error);
m_freem(m);
return error;
@@ -755,7 +746,7 @@ ipw_tx_start(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni)
error = bus_dmamap_load(sc->sc_dmat, shdr->map, &shdr->hdr,
sizeof (struct ipw_hdr), NULL, BUS_DMA_NOWAIT);
if (error != 0) {
- printf("%s: could not map header (error %d)\n",
+ printf("%s: could not map header (error %d)\n",
sc->sc_dev.dv_xname, error);
bus_dmamap_unload(sc->sc_dmat, sbuf->map);
m_freem(m);
@@ -774,13 +765,13 @@ ipw_tx_start(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni)
sbd->bd->flags = IPW_BD_FLAG_TX_FRAME_802_3 |
IPW_BD_FLAG_TX_NOT_LAST_FRAGMENT;
- DPRINTFN(5, ("TX!HDR!%u!%u!%u!%u\n", shdr->hdr.type, shdr->hdr.subtype,
- shdr->hdr.encrypted, shdr->hdr.encrypt));
- DPRINTFN(5, ("!%s", ether_sprintf(shdr->hdr.src_addr)));
+ DPRINTFN(5, ("TX!HDR!%u!%u!%u!%u", shdr->hdr.type, shdr->hdr.subtype,
+ shdr->hdr.encrypted, shdr->hdr.encrypt));
+ DPRINTFN(5, ("!%s", ether_sprintf(shdr->hdr.src_addr)));
DPRINTFN(5, ("!%s\n", ether_sprintf(shdr->hdr.dst_addr)));
- bus_dmamap_sync(sc->sc_dmat, sc->tbd_map,
- sc->txcur * sizeof (struct ipw_bd),
+ bus_dmamap_sync(sc->sc_dmat, sc->tbd_map,
+ sc->txcur * sizeof (struct ipw_bd),
sizeof (struct ipw_bd), BUS_DMASYNC_PREWRITE);
sc->txcur = (sc->txcur + 1) % IPW_NTBD;
@@ -803,20 +794,20 @@ ipw_tx_start(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni)
sbd->bd->flags |= IPW_BD_FLAG_TX_NOT_LAST_FRAGMENT;
}
- DPRINTFN(5, ("TX!FRAG!%d!%d\n", i,
+ DPRINTFN(5, ("TX!FRAG!%d!%d\n", i,
sbuf->map->dm_segs[i].ds_len));
- bus_dmamap_sync(sc->sc_dmat, sc->tbd_map,
- sc->txcur * sizeof (struct ipw_bd),
+ bus_dmamap_sync(sc->sc_dmat, sc->tbd_map,
+ sc->txcur * sizeof (struct ipw_bd),
sizeof (struct ipw_bd), BUS_DMASYNC_PREWRITE);
sc->txcur = (sc->txcur + 1) % IPW_NTBD;
}
- bus_dmamap_sync(sc->sc_dmat, shdr->map, 0, sizeof (struct ipw_hdr),
+ bus_dmamap_sync(sc->sc_dmat, shdr->map, 0, sizeof (struct ipw_hdr),
BUS_DMASYNC_PREWRITE);
- bus_dmamap_sync(sc->sc_dmat, sbuf->map, 0, MCLBYTES,
+ bus_dmamap_sync(sc->sc_dmat, sbuf->map, 0, MCLBYTES,
BUS_DMASYNC_PREWRITE);
/* Inform firmware about this new packet */
@@ -1002,7 +993,7 @@ ipw_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
if (error != ENETRESET)
break;
- if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) ==
+ if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) ==
(IFF_UP | IFF_RUNNING))
ipw_init(ifp);
error = 0;
@@ -1061,35 +1052,35 @@ ipw_tx_init(struct ipw_softc *sc)
int error, i, nsegs;
/* Allocate transmission buffer descriptors */
- error = bus_dmamap_create(sc->sc_dmat, IPW_TBD_SZ, 1, IPW_TBD_SZ, 0,
+ error = bus_dmamap_create(sc->sc_dmat, IPW_TBD_SZ, 1, IPW_TBD_SZ, 0,
BUS_DMA_NOWAIT, &sc->tbd_map);
if (error != 0) {
errmsg = "could not create tbd dma map";
goto fail;
}
- error = bus_dmamem_alloc(sc->sc_dmat, IPW_TBD_SZ, PAGE_SIZE, 0,
+ error = bus_dmamem_alloc(sc->sc_dmat, IPW_TBD_SZ, PAGE_SIZE, 0,
&sc->tbd_seg, 1, &nsegs, BUS_DMA_NOWAIT);
if (error != 0) {
errmsg = "could not allocate tbd dma memory";
goto fail;
}
- error = bus_dmamem_map(sc->sc_dmat, &sc->tbd_seg, nsegs, IPW_TBD_SZ,
+ error = bus_dmamem_map(sc->sc_dmat, &sc->tbd_seg, nsegs, IPW_TBD_SZ,
(caddr_t *)&sc->tbd_list, BUS_DMA_NOWAIT);
if (error != 0) {
errmsg = "could not map tbd dma memory";
goto fail;
}
- error = bus_dmamap_load(sc->sc_dmat, sc->tbd_map, sc->tbd_list,
+ error = bus_dmamap_load(sc->sc_dmat, sc->tbd_map, sc->tbd_list,
IPW_TBD_SZ, NULL, BUS_DMA_NOWAIT);
if (error != 0) {
errmsg = "could not load tbd dma memory";
goto fail;
}
- sc->stbd_list = malloc(IPW_NTBD * sizeof (struct ipw_soft_bd),
+ sc->stbd_list = malloc(IPW_NTBD * sizeof (struct ipw_soft_bd),
M_DEVBUF, M_NOWAIT);
if (sc->stbd_list == NULL) {
errmsg = "could not allocate soft tbd";
@@ -1111,21 +1102,21 @@ ipw_tx_init(struct ipw_softc *sc)
sc->txcur = 0; /* bd index to write to */
/* Allocate a DMA-able command */
- error = bus_dmamap_create(sc->sc_dmat, sizeof (struct ipw_cmd), 1,
+ error = bus_dmamap_create(sc->sc_dmat, sizeof (struct ipw_cmd), 1,
sizeof (struct ipw_cmd), 0, BUS_DMA_NOWAIT, &sc->cmd_map);
if (error != 0) {
errmsg = "could not create cmd dma map";
goto fail;
}
- error = bus_dmamem_alloc(sc->sc_dmat, sizeof (struct ipw_cmd),
+ error = bus_dmamem_alloc(sc->sc_dmat, sizeof (struct ipw_cmd),
PAGE_SIZE, 0, &sc->cmd_seg, 1, &nsegs, BUS_DMA_NOWAIT);
if (error != 0) {
errmsg = "could not allocate cmd dma memory";
goto fail;
}
- error = bus_dmamem_map(sc->sc_dmat, &sc->cmd_seg, nsegs,
+ error = bus_dmamem_map(sc->sc_dmat, &sc->cmd_seg, nsegs,
sizeof (struct ipw_cmd), (caddr_t *)&sc->cmd, BUS_DMA_NOWAIT);
if (error != 0) {
errmsg = "could not map cmd dma memory";
@@ -1142,9 +1133,9 @@ ipw_tx_init(struct ipw_softc *sc)
}
TAILQ_INIT(&sc->sc_free_shdr);
for (i = 0, shdr = sc->shdr_list; i < IPW_NDATA; i++, shdr++) {
- error = bus_dmamap_create(sc->sc_dmat,
- sizeof (struct ipw_soft_hdr), 1,
- sizeof (struct ipw_soft_hdr), 0, BUS_DMA_NOWAIT,
+ error = bus_dmamap_create(sc->sc_dmat,
+ sizeof (struct ipw_soft_hdr), 1,
+ sizeof (struct ipw_soft_hdr), 0, BUS_DMA_NOWAIT,
&shdr->map);
if (error != 0) {
errmsg = "could not create hdr dma map";
@@ -1163,7 +1154,7 @@ ipw_tx_init(struct ipw_softc *sc)
}
TAILQ_INIT(&sc->sc_free_sbuf);
for (i = 0, sbuf = sc->tx_sbuf_list; i < IPW_NDATA; i++, sbuf++) {
- error = bus_dmamap_create(sc->sc_dmat, IPW_NDATA * MCLBYTES,
+ error = bus_dmamap_create(sc->sc_dmat, IPW_NDATA * MCLBYTES,
IPW_NDATA, MCLBYTES, 0, BUS_DMA_NOWAIT, &sbuf->map);
if (error != 0) {
errmsg = "could not create txbuf dma map";
@@ -1190,7 +1181,7 @@ ipw_tx_stop(struct ipw_softc *sc)
if (sc->tbd_map != NULL) {
if (sc->tbd_list != NULL) {
bus_dmamap_unload(sc->sc_dmat, sc->tbd_map);
- bus_dmamem_unmap(sc->sc_dmat, (caddr_t)sc->tbd_list,
+ bus_dmamem_unmap(sc->sc_dmat, (caddr_t)sc->tbd_list,
IPW_TBD_SZ);
bus_dmamem_free(sc->sc_dmat, &sc->tbd_seg, 1);
sc->tbd_list = NULL;
@@ -1208,7 +1199,7 @@ ipw_tx_stop(struct ipw_softc *sc)
if (sc->cmd_map != NULL) {
if (sc->cmd != NULL) {
- bus_dmamem_unmap(sc->sc_dmat, (caddr_t)sc->cmd,
+ bus_dmamem_unmap(sc->sc_dmat, (caddr_t)sc->cmd,
sizeof (struct ipw_cmd));
bus_dmamem_free(sc->sc_dmat, &sc->cmd_seg, 1);
sc->cmd = NULL;
@@ -1243,35 +1234,35 @@ ipw_rx_init(struct ipw_softc *sc)
int error, i, nsegs;
/* Allocate reception buffer descriptors */
- error = bus_dmamap_create(sc->sc_dmat, IPW_RBD_SZ, 1, IPW_RBD_SZ, 0,
+ error = bus_dmamap_create(sc->sc_dmat, IPW_RBD_SZ, 1, IPW_RBD_SZ, 0,
BUS_DMA_NOWAIT, &sc->rbd_map);
if (error != 0) {
errmsg = "could not create rbd dma map";
goto fail;
}
- error = bus_dmamem_alloc(sc->sc_dmat, IPW_RBD_SZ, PAGE_SIZE, 0,
+ error = bus_dmamem_alloc(sc->sc_dmat, IPW_RBD_SZ, PAGE_SIZE, 0,
&sc->rbd_seg, 1, &nsegs, BUS_DMA_NOWAIT);
if (error != 0) {
errmsg = "could not allocate rbd dma memory";
goto fail;
}
- error = bus_dmamem_map(sc->sc_dmat, &sc->rbd_seg, nsegs, IPW_RBD_SZ,
+ error = bus_dmamem_map(sc->sc_dmat, &sc->rbd_seg, nsegs, IPW_RBD_SZ,
(caddr_t *)&sc->rbd_list, BUS_DMA_NOWAIT);
if (error != 0) {
errmsg = "could not map rbd dma memory";
goto fail;
}
- error = bus_dmamap_load(sc->sc_dmat, sc->rbd_map, sc->rbd_list,
+ error = bus_dmamap_load(sc->sc_dmat, sc->rbd_map, sc->rbd_list,
IPW_RBD_SZ, NULL, BUS_DMA_NOWAIT);
if (error != 0) {
errmsg = "could not load rbd dma memory";
goto fail;
}
- sc->srbd_list = malloc(IPW_NRBD * sizeof (struct ipw_soft_bd),
+ sc->srbd_list = malloc(IPW_NRBD * sizeof (struct ipw_soft_bd),
M_DEVBUF, M_NOWAIT);
if (sc->srbd_list == NULL) {
errmsg = "could not allocate soft rbd";
@@ -1292,35 +1283,35 @@ ipw_rx_init(struct ipw_softc *sc)
sc->rxcur = IPW_NRBD - 1; /* latest bd index I've read */
/* Allocate status descriptors */
- error = bus_dmamap_create(sc->sc_dmat, IPW_STATUS_SZ, 1, IPW_STATUS_SZ,
+ error = bus_dmamap_create(sc->sc_dmat, IPW_STATUS_SZ, 1, IPW_STATUS_SZ,
0, BUS_DMA_NOWAIT, &sc->status_map);
if (error != 0) {
errmsg = "could not create status dma map";
goto fail;
}
- error = bus_dmamem_alloc(sc->sc_dmat, IPW_STATUS_SZ, PAGE_SIZE, 0,
+ error = bus_dmamem_alloc(sc->sc_dmat, IPW_STATUS_SZ, PAGE_SIZE, 0,
&sc->status_seg, 1, &nsegs, BUS_DMA_NOWAIT);
if (error != 0) {
errmsg = "could not allocate status dma memory";
goto fail;
}
- error = bus_dmamem_map(sc->sc_dmat, &sc->status_seg, nsegs,
+ error = bus_dmamem_map(sc->sc_dmat, &sc->status_seg, nsegs,
IPW_STATUS_SZ, (caddr_t *)&sc->status_list, BUS_DMA_NOWAIT);
if (error != 0) {
errmsg = "could not map status dma memory";
goto fail;
}
- error = bus_dmamap_load(sc->sc_dmat, sc->status_map, sc->status_list,
+ error = bus_dmamap_load(sc->sc_dmat, sc->status_map, sc->status_list,
IPW_STATUS_SZ, NULL, BUS_DMA_NOWAIT);
if (error != 0) {
errmsg = "could not load status dma memory";
goto fail;
}
- CSR_WRITE_4(sc, IPW_CSR_RX_STATUS_BASE,
+ CSR_WRITE_4(sc, IPW_CSR_RX_STATUS_BASE,
sc->status_map->dm_segs[0].ds_addr);
sc->rx_sbuf_list = malloc(IPW_NRBD * sizeof (struct ipw_soft_buf),
@@ -1349,14 +1340,14 @@ ipw_rx_init(struct ipw_softc *sc)
goto fail;
}
- error = bus_dmamap_create(sc->sc_dmat, IPW_NRBD * MCLBYTES,
+ error = bus_dmamap_create(sc->sc_dmat, IPW_NRBD * MCLBYTES,
IPW_NRBD, MCLBYTES, 0, BUS_DMA_NOWAIT, &sbuf->map);
if (error != 0) {
m_freem(sbuf->m);
errmsg = "could not create rxbuf dma map";
goto fail;
}
- error = bus_dmamap_load(sc->sc_dmat, sbuf->map,
+ error = bus_dmamap_load(sc->sc_dmat, sbuf->map,
mtod(sbuf->m, void *), MCLBYTES, NULL, BUS_DMA_NOWAIT);
if (error != 0) {
bus_dmamap_destroy(sc->sc_dmat, sbuf->map);
@@ -1388,7 +1379,7 @@ ipw_rx_stop(struct ipw_softc *sc)
if (sc->rbd_map != NULL) {
if (sc->rbd_list != NULL) {
bus_dmamap_unload(sc->sc_dmat, sc->rbd_map);
- bus_dmamem_unmap(sc->sc_dmat, (caddr_t)sc->rbd_list,
+ bus_dmamem_unmap(sc->sc_dmat, (caddr_t)sc->rbd_list,
IPW_RBD_SZ);
bus_dmamem_free(sc->sc_dmat, &sc->rbd_seg, 1);
sc->rbd_list = NULL;
@@ -1400,7 +1391,7 @@ ipw_rx_stop(struct ipw_softc *sc)
if (sc->status_map != NULL) {
if (sc->status_list != NULL) {
bus_dmamap_unload(sc->sc_dmat, sc->status_map);
- bus_dmamem_unmap(sc->sc_dmat, (caddr_t)sc->status_list,
+ bus_dmamem_unmap(sc->sc_dmat, (caddr_t)sc->status_list,
IPW_STATUS_SZ);
bus_dmamem_free(sc->sc_dmat, &sc->status_seg, 1);
sc->status_list = NULL;
@@ -1477,7 +1468,7 @@ ipw_clock_sync(struct ipw_softc *sc)
if (ntries == 1000)
return EIO;
- CSR_WRITE_4(sc, IPW_CSR_CTL, IPW_CTL_INIT_DONE);
+ CSR_WRITE_4(sc, IPW_CSR_CTL, IPW_CTL_INIT);
for (ntries = 0; ntries < 1000; ntries++) {
if ((r = CSR_READ_4(sc, IPW_CSR_CTL)) & IPW_CTL_CLOCK_READY)
break;
@@ -1539,7 +1530,7 @@ static int
ipw_load_firmware(struct ipw_softc *sc, u_char *fw, int size)
{
u_char *p, *end;
- u_int32_t addr;
+ u_int32_t dst;
u_int16_t len;
p = fw;
@@ -1548,15 +1539,13 @@ ipw_load_firmware(struct ipw_softc *sc, u_char *fw, int size)
if (p + 6 > end)
return EINVAL;
- addr = GETLE32(p);
- p += 4;
- len = GETLE16(p);
- p += 2;
+ dst = GETLE32(p); p += 4;
+ len = GETLE16(p); p += 2;
if (p + len > end)
return EINVAL;
- ipw_write_mem_1(sc, addr, p, len);
+ ipw_write_mem_1(sc, dst, p, len);
p += len;
}
return 0;
@@ -1600,7 +1589,7 @@ ipw_firmware_init(struct ipw_softc *sc, u_char *data)
goto fail3;
if ((error = ipw_clock_sync(sc)) != 0) {
- printf("%s: clock synchronization failed\n",
+ printf("%s: clock synchronization failed\n",
sc->sc_dev.dv_xname);
goto fail3;
}
@@ -1617,7 +1606,7 @@ ipw_firmware_init(struct ipw_softc *sc, u_char *data)
MEM_WRITE_4(sc, 0x003000e0, 0);
if ((error = ipw_clock_sync(sc)) != 0) {
- printf("%s: clock synchronization failed\n",
+ printf("%s: clock synchronization failed\n",
sc->sc_dev.dv_xname);
goto fail3;
}
@@ -1634,7 +1623,7 @@ ipw_firmware_init(struct ipw_softc *sc, u_char *data)
ipw_zero_mem_4(sc, 0x0002ff80, 32);
if ((error = ipw_rx_init(sc)) != 0) {
- printf("%s: could not initialize rx queue\n",
+ printf("%s: could not initialize rx queue\n",
sc->sc_dev.dv_xname);
goto fail3;
}
@@ -1645,13 +1634,13 @@ ipw_firmware_init(struct ipw_softc *sc, u_char *data)
goto fail3;
}
- CSR_WRITE_4(sc, IPW_CSR_IO, IPW_IO_GPIO1_ENABLE | IPW_IO_GPIO3_MASK |
+ CSR_WRITE_4(sc, IPW_CSR_IO, IPW_IO_GPIO1_ENABLE | IPW_IO_GPIO3_MASK |
IPW_IO_LED_OFF);
- /* Enable interrupts */
+ /* Allow interrupts so we know when the firmware is inited */
CSR_WRITE_4(sc, IPW_CSR_INTR_MASK, IPW_INTR_MASK);
- /* Let's go! */
+ /* Tell the adapter to initialize the firmware */
CSR_WRITE_4(sc, IPW_CSR_RST, 0);
/* Wait at most 5 seconds for firmware initialization to complete */
@@ -1724,7 +1713,7 @@ ipw_config(struct ipw_softc *sc)
if (error != 0)
return error;
- if (ic->ic_opmode == IEEE80211_M_IBSS ||
+ if (ic->ic_opmode == IEEE80211_M_IBSS ||
ic->ic_opmode == IEEE80211_M_MONITOR) {
data = htole32(ieee80211_chan2ieee(ic, ic->ic_ibss_chan));
DPRINTF(("Setting adapter channel to %u\n", data));
@@ -1741,12 +1730,12 @@ ipw_config(struct ipw_softc *sc)
DPRINTF(("Setting adapter MAC to %s\n", ether_sprintf(ic->ic_myaddr)));
IEEE80211_ADDR_COPY(((struct arpcom *)ifp)->ac_enaddr, ic->ic_myaddr);
IEEE80211_ADDR_COPY(LLADDR(ifp->if_sadl), ic->ic_myaddr);
- error = ipw_cmd(sc, IPW_CMD_SET_MAC_ADDRESS, ic->ic_myaddr,
+ error = ipw_cmd(sc, IPW_CMD_SET_MAC_ADDRESS, ic->ic_myaddr,
IEEE80211_ADDR_LEN);
if (error != 0)
return error;
- config.flags = htole32(IPW_CFG_BSS_MASK | IPW_CFG_IBSS_MASK |
+ config.flags = htole32(IPW_CFG_BSS_MASK | IPW_CFG_IBSS_MASK |
IPW_CFG_PREAMBLE_LEN | IPW_CFG_802_1x_ENABLE);
if (ic->ic_opmode == IEEE80211_M_IBSS)
config.flags |= htole32(IPW_CFG_IBSS_AUTO_START);
@@ -1780,7 +1769,7 @@ ipw_config(struct ipw_softc *sc)
if (ic->ic_opmode == IEEE80211_M_IBSS) {
data = htole32(ic->ic_txpower);
DPRINTF(("Setting adapter tx power index to %u\n", data));
- error = ipw_cmd(sc, IPW_CMD_SET_TX_POWER_INDEX, &data,
+ error = ipw_cmd(sc, IPW_CMD_SET_TX_POWER_INDEX, &data,
sizeof data);
if (error != 0)
return error;
@@ -1805,7 +1794,7 @@ ipw_config(struct ipw_softc *sc)
printf("\n");
}
#endif
- error = ipw_cmd(sc, IPW_CMD_SET_ESSID, ic->ic_des_essid,
+ error = ipw_cmd(sc, IPW_CMD_SET_ESSID, ic->ic_des_essid,
ic->ic_des_esslen);
if (error != 0)
return error;
@@ -1816,9 +1805,9 @@ ipw_config(struct ipw_softc *sc)
return error;
if (ic->ic_flags & IEEE80211_F_DESBSSID) {
- DPRINTF(("Setting adapter desired BSSID to %s\n",
+ DPRINTF(("Setting adapter desired BSSID to %s\n",
ether_sprintf(ic->ic_des_bssid)));
- error = ipw_cmd(sc, IPW_CMD_SET_DESIRED_BSSID,
+ error = ipw_cmd(sc, IPW_CMD_SET_DESIRED_BSSID,
ic->ic_des_bssid, IEEE80211_ADDR_LEN);
if (error != 0)
return error;
@@ -1830,7 +1819,7 @@ ipw_config(struct ipw_softc *sc)
security.replay_counters_number = 0;
security.unicast_using_group = 0;
DPRINTF(("Setting adapter authmode to %u\n", security.authmode));
- error = ipw_cmd(sc, IPW_CMD_SET_SECURITY_INFORMATION, &security,
+ error = ipw_cmd(sc, IPW_CMD_SET_SECURITY_INFORMATION, &security,
sizeof security);
if (error != 0)
return error;
@@ -1845,9 +1834,9 @@ ipw_config(struct ipw_softc *sc)
wepkey.len = k->wk_len;
bzero(wepkey.key, sizeof wepkey.key);
bcopy(k->wk_key, wepkey.key, k->wk_len);
- DPRINTF(("Setting wep key index %d len %d\n",
+ DPRINTF(("Setting wep key index %d len %d\n",
wepkey.idx, wepkey.len));
- error = ipw_cmd(sc, IPW_CMD_SET_WEP_KEY, &wepkey,
+ error = ipw_cmd(sc, IPW_CMD_SET_WEP_KEY, &wepkey,
sizeof wepkey);
if (error != 0)
return error;
@@ -1855,7 +1844,7 @@ ipw_config(struct ipw_softc *sc)
data = htole32(ic->ic_wep_txkey);
DPRINTF(("Setting adapter tx key index to %u\n", data));
- error = ipw_cmd(sc, IPW_CMD_SET_WEP_KEY_INDEX, &data,
+ error = ipw_cmd(sc, IPW_CMD_SET_WEP_KEY_INDEX, &data,
sizeof data);
if (error != 0)
return error;
@@ -1867,11 +1856,11 @@ ipw_config(struct ipw_softc *sc)
if (error != 0)
return error;
- if (ic->ic_opmode == IEEE80211_M_IBSS ||
+ if (ic->ic_opmode == IEEE80211_M_IBSS ||
ic->ic_opmode == IEEE80211_M_HOSTAP) {
data = htole32(ic->ic_lintval);
DPRINTF(("Setting adapter beacon interval to %u\n", data));
- error = ipw_cmd(sc, IPW_CMD_SET_BEACON_INTERVAL, &data,
+ error = ipw_cmd(sc, IPW_CMD_SET_BEACON_INTERVAL, &data,
sizeof data);
if (error != 0)
return error;
@@ -1885,14 +1874,10 @@ ipw_config(struct ipw_softc *sc)
/* finally, enable adapter (start scanning for an access point) */
DPRINTF(("Enabling adapter\n"));
- error = ipw_cmd(sc, IPW_CMD_ENABLE, NULL, 0);
- if (error != 0)
- return error;
-
- return 0;
+ return ipw_cmd(sc, IPW_CMD_ENABLE, NULL, 0);
}
-static int
+static int
ipw_init(struct ifnet *ifp)
{
struct ipw_softc *sc = ifp->if_softc;
@@ -1907,7 +1892,7 @@ ipw_init(struct ifnet *ifp)
ipw_stop(ifp, 0);
if (ipw_config(sc) != 0) {
- printf("%s: device configuration failed\n",
+ printf("%s: device configuration failed\n",
sc->sc_dev.dv_xname);
goto fail;
}
@@ -1942,7 +1927,7 @@ ipw_stop(struct ifnet *ifp, int disable)
}
static void
-ipw_read_mem_1(struct ipw_softc *sc, bus_size_t offset, u_int8_t *datap,
+ipw_read_mem_1(struct ipw_softc *sc, bus_size_t offset, u_int8_t *datap,
bus_size_t count)
{
for (; count > 0; offset++, datap++, count--) {
@@ -1952,7 +1937,7 @@ ipw_read_mem_1(struct ipw_softc *sc, bus_size_t offset, u_int8_t *datap,
}
static void
-ipw_write_mem_1(struct ipw_softc *sc, bus_size_t offset, u_int8_t *datap,
+ipw_write_mem_1(struct ipw_softc *sc, bus_size_t offset, u_int8_t *datap,
bus_size_t count)
{
for (; count > 0; offset++, datap++, count--) {
diff --git a/sys/dev/pci/if_ipwreg.h b/sys/dev/pci/if_ipwreg.h
index 5e344bffa9c..8f08f0fb337 100644
--- a/sys/dev/pci/if_ipwreg.h
+++ b/sys/dev/pci/if_ipwreg.h
@@ -1,4 +1,4 @@
-/* $Id: if_ipwreg.h,v 1.1 2004/10/20 12:50:48 deraadt Exp $ */
+/* $Id: if_ipwreg.h,v 1.2 2004/10/27 21:10:22 damien Exp $ */
/*-
* Copyright (c) 2004
@@ -43,18 +43,19 @@
#define IPW_CSR_RST 0x0020
#define IPW_CSR_CTL 0x0024
#define IPW_CSR_IO 0x0030
-#define IPW_CSR_TABLE1_BASE 0x0380
-#define IPW_CSR_TABLE2_BASE 0x0384
+#define IPW_CSR_TX_BD_BASE 0x0200
+#define IPW_CSR_TX_BD_SIZE 0x0204
#define IPW_CSR_RX_BD_BASE 0x0240
#define IPW_CSR_RX_STATUS_BASE 0x0244
#define IPW_CSR_RX_BD_SIZE 0x0248
-#define IPW_CSR_RX_READ_INDEX 0x02a0
-#define IPW_CSR_RX_WRITE_INDEX 0x0fa0
-#define IPW_CSR_TX_BD_BASE 0x0200
-#define IPW_CSR_TX_BD_SIZE 0x0204
#define IPW_CSR_TX_READ_INDEX 0x0280
+#define IPW_CSR_RX_READ_INDEX 0x02a0
+#define IPW_CSR_TABLE1_BASE 0x0380
+#define IPW_CSR_TABLE2_BASE 0x0384
#define IPW_CSR_TX_WRITE_INDEX 0x0f80
+#define IPW_CSR_RX_WRITE_INDEX 0x0fa0
+/* possible flags for register IPW_CSR_INTR */
#define IPW_INTR_TX_TRANSFER 0x00000001
#define IPW_INTR_RX_TRANSFER 0x00000002
#define IPW_INTR_STATUS_CHANGE 0x00000010
@@ -78,7 +79,7 @@
/* possible flags for register IPW_CSR_CTL */
#define IPW_CTL_CLOCK_READY 0x00000001
#define IPW_CTL_ALLOW_STANDBY 0x00000002
-#define IPW_CTL_INIT_DONE 0x00000004
+#define IPW_CTL_INIT 0x00000004
/* possible flags for register IPW_CSR_IO */
#define IPW_IO_GPIO1_ENABLE 0x00000008
@@ -268,12 +269,11 @@ struct ipw_configuration {
#define CSR_WRITE_MULTI_1(sc, reg, buf, len) \
bus_space_write_multi_1((sc)->sc_st, (sc)->sc_sh, (reg), \
- (buf), (len));
+ (buf), (len))
/*
* indirect memory space access macros
*/
-
#define MEM_WRITE_1(sc, addr, val) do { \
CSR_WRITE_4((sc), IPW_CSR_INDIRECT_ADDR, (addr)); \
CSR_WRITE_1((sc), IPW_CSR_INDIRECT_DATA, (val)); \
@@ -293,3 +293,4 @@ struct ipw_configuration {
CSR_WRITE_4((sc), IPW_CSR_INDIRECT_ADDR, (addr)); \
CSR_WRITE_MULTI_1((sc), IPW_CSR_INDIRECT_DATA, (buf), (len)); \
} while (/* CONSTCOND */0)
+