View | Details | Raw Unified | Return to bug 197143 | Differences between
and this patch

Collapse All | Expand All

(-)sys/dev/wpi/if_wpi.c (-40 / +41 lines)
Lines 313-319 Link Here
313
313
314
	sc->sc_dev = dev;
314
	sc->sc_dev = dev;
315
315
316
#ifdef	WPI_DEBUG
316
#ifdef WPI_DEBUG
317
	error = resource_int_value(device_get_name(sc->sc_dev),
317
	error = resource_int_value(device_get_name(sc->sc_dev),
318
	    device_get_unit(sc->sc_dev), "debug", &(sc->sc_debug));
318
	    device_get_unit(sc->sc_dev), "debug", &(sc->sc_debug));
319
	if (error != 0)
319
	if (error != 0)
Lines 455-474 Link Here
455
		device_printf(dev, "could not read EEPROM, error %d\n",
455
		device_printf(dev, "could not read EEPROM, error %d\n",
456
		    error);
456
		    error);
457
		goto fail;
457
		goto fail;
458
        }
458
	}
459
459
460
#ifdef	WPI_DEBUG
460
#ifdef WPI_DEBUG
461
	if (bootverbose) {
461
	if (bootverbose) {
462
	    device_printf(sc->sc_dev, "Regulatory Domain: %.4s\n", sc->domain);
462
		device_printf(sc->sc_dev, "Regulatory Domain: %.4s\n",
463
	    device_printf(sc->sc_dev, "Hardware Type: %c\n",
463
		    sc->domain);
464
			  sc->type > 1 ? 'B': '?');
464
		device_printf(sc->sc_dev, "Hardware Type: %c\n",
465
	    device_printf(sc->sc_dev, "Hardware Revision: %c\n",
465
		    sc->type > 1 ? 'B': '?');
466
			  ((le16toh(sc->rev) & 0xf0) == 0xd0) ? 'D': '?');
466
		device_printf(sc->sc_dev, "Hardware Revision: %c\n",
467
	    device_printf(sc->sc_dev, "SKU %s support 802.11a\n",
467
		    ((le16toh(sc->rev) & 0xf0) == 0xd0) ? 'D': '?');
468
			  supportsa ? "does" : "does not");
468
		device_printf(sc->sc_dev, "SKU %s support 802.11a\n",
469
		    supportsa ? "does" : "does not");
469
470
470
	    /* XXX hw_config uses the PCIDEV for the Hardware rev. Must check
471
		/* XXX hw_config uses the PCIDEV for the Hardware rev. Must
471
	       what sc->rev really represents - benjsc 20070615 */
472
		   check what sc->rev really represents - benjsc 20070615 */
472
	}
473
	}
473
#endif
474
#endif
474
475
Lines 558-564 Link Here
558
static void
559
static void
559
wpi_sysctlattach(struct wpi_softc *sc)
560
wpi_sysctlattach(struct wpi_softc *sc)
560
{
561
{
561
#ifdef  WPI_DEBUG
562
#ifdef WPI_DEBUG
562
	struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
563
	struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
563
	struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
564
	struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
564
565
Lines 725-731 Link Here
725
	/* Spin until we actually get the lock. */
726
	/* Spin until we actually get the lock. */
726
	for (ntries = 0; ntries < 1000; ntries++) {
727
	for (ntries = 0; ntries < 1000; ntries++) {
727
		if ((WPI_READ(sc, WPI_GP_CNTRL) &
728
		if ((WPI_READ(sc, WPI_GP_CNTRL) &
728
		     (WPI_GP_CNTRL_MAC_ACCESS_ENA | WPI_GP_CNTRL_SLEEP)) ==
729
		    (WPI_GP_CNTRL_MAC_ACCESS_ENA | WPI_GP_CNTRL_SLEEP)) ==
729
		    WPI_GP_CNTRL_MAC_ACCESS_ENA)
730
		    WPI_GP_CNTRL_MAC_ACCESS_ENA)
730
			return 0;
731
			return 0;
731
		DELAY(10);
732
		DELAY(10);
Lines 957-972 Link Here
957
	}
958
	}
958
959
959
	/* Create RX buffer DMA tag. */
960
	/* Create RX buffer DMA tag. */
960
        error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, 
961
	error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, 
961
	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
962
	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
962
	    MJUMPAGESIZE, 1, MJUMPAGESIZE, BUS_DMA_NOWAIT, NULL, NULL,
963
	    MJUMPAGESIZE, 1, MJUMPAGESIZE, BUS_DMA_NOWAIT, NULL, NULL,
963
	    &ring->data_dmat);
964
	    &ring->data_dmat);
964
        if (error != 0) {
965
	if (error != 0) {
965
                device_printf(sc->sc_dev,
966
		device_printf(sc->sc_dev,
966
		    "%s: could not create RX buf DMA tag, error %d\n",
967
		    "%s: could not create RX buf DMA tag, error %d\n",
967
		    __func__, error);
968
		    __func__, error);
968
                goto fail;
969
		goto fail;
969
        }
970
	}
970
971
971
	/*
972
	/*
972
	 * Allocate and map RX buffers.
973
	 * Allocate and map RX buffers.
Lines 2028-2035 Link Here
2028
		}
2029
		}
2029
		case WPI_STATE_CHANGED:
2030
		case WPI_STATE_CHANGED:
2030
		{
2031
		{
2031
                        bus_dmamap_sync(sc->rxq.data_dmat, data->map,
2032
			bus_dmamap_sync(sc->rxq.data_dmat, data->map,
2032
                            BUS_DMASYNC_POSTREAD);
2033
			    BUS_DMASYNC_POSTREAD);
2033
2034
2034
			uint32_t *status = (uint32_t *)(desc + 1);
2035
			uint32_t *status = (uint32_t *)(desc + 1);
2035
2036
Lines 2083-2089 Link Here
2083
 * Process an INT_WAKEUP interrupt raised when the microcontroller wakes up
2084
 * Process an INT_WAKEUP interrupt raised when the microcontroller wakes up
2084
 * from power-down sleep mode.
2085
 * from power-down sleep mode.
2085
 */
2086
 */
2086
static void     
2087
static void
2087
wpi_wakeup_intr(struct wpi_softc *sc)
2088
wpi_wakeup_intr(struct wpi_softc *sc)
2088
{
2089
{
2089
	int qid;
2090
	int qid;
Lines 2127-2138 Link Here
2127
	    WPI_FW_DATA_BASE + WPI_FW_DATA_MAXSZ) {
2128
	    WPI_FW_DATA_BASE + WPI_FW_DATA_MAXSZ) {
2128
		printf("%s: bad firmware error log address 0x%08x\n", __func__,
2129
		printf("%s: bad firmware error log address 0x%08x\n", __func__,
2129
		    sc->errptr);
2130
		    sc->errptr);
2130
                return;
2131
		return;
2131
        }
2132
	}
2132
	if (wpi_nic_lock(sc) != 0) {
2133
	if (wpi_nic_lock(sc) != 0) {
2133
		printf("%s: could not read firmware error log\n", __func__);
2134
		printf("%s: could not read firmware error log\n", __func__);
2134
                return;
2135
		return;
2135
        }
2136
	}
2136
	/* Read number of entries in the log. */
2137
	/* Read number of entries in the log. */
2137
	count = wpi_mem_read(sc, sc->errptr);
2138
	count = wpi_mem_read(sc, sc->errptr);
2138
	if (count == 0 || count * sizeof (dump) > WPI_FW_DATA_MAXSZ) {
2139
	if (count == 0 || count * sizeof (dump) > WPI_FW_DATA_MAXSZ) {
Lines 2381-2387 Link Here
2381
	} else {
2382
	} else {
2382
		qos = 0;
2383
		qos = 0;
2383
		tid = 0;
2384
		tid = 0;
2384
        }
2385
	}
2385
	ac = M_WME_GETAC(m);
2386
	ac = M_WME_GETAC(m);
2386
2387
2387
	chan = (ni->ni_chan != IEEE80211_CHAN_ANYC) ?
2388
	chan = (ni->ni_chan != IEEE80211_CHAN_ANYC) ?
Lines 3233-3243 Link Here
3233
    struct ieee80211_channel *c, int ridx)
3234
    struct ieee80211_channel *c, int ridx)
3234
{
3235
{
3235
/* Fixed-point arithmetic division using a n-bit fractional part. */
3236
/* Fixed-point arithmetic division using a n-bit fractional part. */
3236
#define fdivround(a, b, n)      \
3237
#define fdivround(a, b, n)	\
3237
	((((1 << n) * (a)) / (b) + (1 << n) / 2) / (1 << n))
3238
	((((1 << n) * (a)) / (b) + (1 << n) / 2) / (1 << n))
3238
3239
3239
/* Linear interpolation. */
3240
/* Linear interpolation. */
3240
#define interpolate(x, x1, y1, x2, y2, n)       \
3241
#define interpolate(x, x1, y1, x2, y2, n)	\
3241
	((y1) + fdivround(((x) - (x1)) * ((y2) - (y1)), (x2) - (x1), n))
3242
	((y1) + fdivround(((x) - (x1)) * ((y2) - (y1)), (x2) - (x1), n))
3242
3243
3243
	struct ifnet *ifp = sc->sc_ifp;
3244
	struct ifnet *ifp = sc->sc_ifp;
Lines 3354-3371 Link Here
3354
	return wpi_cmd(sc, WPI_CMD_SET_POWER_MODE, &cmd, sizeof cmd, async);
3355
	return wpi_cmd(sc, WPI_CMD_SET_POWER_MODE, &cmd, sizeof cmd, async);
3355
}
3356
}
3356
3357
3357
static int      
3358
static int
3358
wpi_send_btcoex(struct wpi_softc *sc)
3359
wpi_send_btcoex(struct wpi_softc *sc)
3359
{
3360
{
3360
	struct wpi_bluetooth cmd;
3361
	struct wpi_bluetooth cmd;
3361
3362
3362
        memset(&cmd, 0, sizeof cmd);
3363
	memset(&cmd, 0, sizeof cmd);
3363
        cmd.flags = WPI_BT_COEX_MODE_4WIRE;
3364
	cmd.flags = WPI_BT_COEX_MODE_4WIRE;
3364
        cmd.lead_time = WPI_BT_LEAD_TIME_DEF;
3365
	cmd.lead_time = WPI_BT_LEAD_TIME_DEF;
3365
        cmd.max_kill = WPI_BT_MAX_KILL_DEF;
3366
	cmd.max_kill = WPI_BT_MAX_KILL_DEF;
3366
	DPRINTF(sc, WPI_DEBUG_RESET, "%s: configuring bluetooth coexistence\n",
3367
	DPRINTF(sc, WPI_DEBUG_RESET, "%s: configuring bluetooth coexistence\n",
3367
	    __func__);
3368
	    __func__);
3368
        return wpi_cmd(sc, WPI_CMD_BT_COEX, &cmd, sizeof(cmd), 0);
3369
	return wpi_cmd(sc, WPI_CMD_BT_COEX, &cmd, sizeof(cmd), 0);
3369
}
3370
}
3370
3371
3371
static int
3372
static int
Lines 3719-3725 Link Here
3719
		chan->rf_gain = 0x28;
3720
		chan->rf_gain = 0x28;
3720
3721
3721
	DPRINTF(sc, WPI_DEBUG_SCAN, "Scanning %u Passive: %d\n",
3722
	DPRINTF(sc, WPI_DEBUG_SCAN, "Scanning %u Passive: %d\n",
3722
	     chan->chan, IEEE80211_IS_CHAN_PASSIVE(c));
3723
	    chan->chan, IEEE80211_IS_CHAN_PASSIVE(c));
3723
3724
3724
	hdr->nchan++;
3725
	hdr->nchan++;
3725
	chan++;
3726
	chan++;
Lines 4112-4122 Link Here
4112
	if (ntries == 1000) {
4113
	if (ntries == 1000) {
4113
		device_printf(sc->sc_dev,
4114
		device_printf(sc->sc_dev,
4114
		    "timeout waiting for thermal sensor calibration\n");
4115
		    "timeout waiting for thermal sensor calibration\n");
4115
                return ETIMEDOUT;
4116
		return ETIMEDOUT;
4116
        }
4117
	}
4117
4118
4118
        DPRINTF(sc, WPI_DEBUG_TEMP, "temperature %d\n", sc->temp);
4119
	DPRINTF(sc, WPI_DEBUG_TEMP, "temperature %d\n", sc->temp);
4119
        return 0;
4120
	return 0;
4120
}
4121
}
4121
4122
4122
/*
4123
/*
(-)sys/dev/wpi/if_wpireg.h (-6 / +6 lines)
Lines 28-34 Link Here
28
#define WPI_NDMACHNLS		6
28
#define WPI_NDMACHNLS		6
29
29
30
/* Maximum scatter/gather. */
30
/* Maximum scatter/gather. */
31
#define WPI_MAX_SCATTER	4
31
#define WPI_MAX_SCATTER		4
32
32
33
/*
33
/*
34
 * Rings must be aligned on a 16K boundary.
34
 * Rings must be aligned on a 16K boundary.
Lines 466-472 Link Here
466
	uint16_t	lnext;
466
	uint16_t	lnext;
467
	uint32_t	flags;
467
	uint32_t	flags;
468
#define WPI_TX_NEED_RTS		(1 <<  1)
468
#define WPI_TX_NEED_RTS		(1 <<  1)
469
#define WPI_TX_NEED_CTS         (1 <<  2)
469
#define WPI_TX_NEED_CTS		(1 <<  2)
470
#define WPI_TX_NEED_ACK		(1 <<  3)
470
#define WPI_TX_NEED_ACK		(1 <<  3)
471
#define WPI_TX_FULL_TXOP	(1 <<  7)
471
#define WPI_TX_FULL_TXOP	(1 <<  7)
472
#define WPI_TX_BT_DISABLE	(1 << 12) 	/* bluetooth coexistence */
472
#define WPI_TX_BT_DISABLE	(1 << 12) 	/* bluetooth coexistence */
Lines 516-525 Link Here
516
516
517
/* Structure for notification WPI_BEACON_MISSED. */
517
/* Structure for notification WPI_BEACON_MISSED. */
518
struct wpi_beacon_missed {
518
struct wpi_beacon_missed {
519
    uint32_t consecutive;
519
	uint32_t consecutive;
520
    uint32_t total;
520
	uint32_t total;
521
    uint32_t expected;
521
	uint32_t expected;
522
    uint32_t received;
522
	uint32_t received;
523
} __packed;
523
} __packed;
524
524
525
525
(-)sys/dev/wpi/if_wpivar.h (-4 / +4 lines)
Lines 52-58 Link Here
52
52
53
struct wpi_dma_info {
53
struct wpi_dma_info {
54
	bus_dma_tag_t		tag;
54
	bus_dma_tag_t		tag;
55
	bus_dmamap_t            map;
55
	bus_dmamap_t		map;
56
	bus_addr_t		paddr;
56
	bus_addr_t		paddr;
57
	caddr_t			vaddr;
57
	caddr_t			vaddr;
58
	bus_size_t		size;
58
	bus_size_t		size;
Lines 183-189 Link Here
183
	bus_space_handle_t	sc_sh;
183
	bus_space_handle_t	sc_sh;
184
	void			*sc_ih;
184
	void			*sc_ih;
185
	bus_size_t		sc_sz;
185
	bus_size_t		sc_sz;
186
	int			sc_cap_off;     /* PCIe Capabilities. */
186
	int			sc_cap_off;	/* PCIe Capabilities. */
187
187
188
	struct wpi_rxon		rxon;
188
	struct wpi_rxon		rxon;
189
	int			temp;
189
	int			temp;
Lines 223-230 Link Here
223
223
224
#define WPI_LOCK_INIT(_sc) \
224
#define WPI_LOCK_INIT(_sc) \
225
	mtx_init(&(_sc)->sc_mtx, device_get_nameunit((_sc)->sc_dev), \
225
	mtx_init(&(_sc)->sc_mtx, device_get_nameunit((_sc)->sc_dev), \
226
            MTX_NETWORK_LOCK, MTX_DEF)
226
	    MTX_NETWORK_LOCK, MTX_DEF)
227
#define WPI_LOCK(_sc)		mtx_lock(&(_sc)->sc_mtx)
227
#define WPI_LOCK(_sc)		mtx_lock(&(_sc)->sc_mtx)
228
#define WPI_UNLOCK(_sc)		mtx_unlock(&(_sc)->sc_mtx)
228
#define WPI_UNLOCK(_sc)		mtx_unlock(&(_sc)->sc_mtx)
229
#define WPI_LOCK_ASSERT(sc)     mtx_assert(&(sc)->sc_mtx, MA_OWNED)
229
#define WPI_LOCK_ASSERT(sc)	mtx_assert(&(sc)->sc_mtx, MA_OWNED)
230
#define WPI_LOCK_DESTROY(_sc)	mtx_destroy(&(_sc)->sc_mtx)
230
#define WPI_LOCK_DESTROY(_sc)	mtx_destroy(&(_sc)->sc_mtx)

Return to bug 197143