1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-11 14:10:34 +00:00

Big wpi(4) overhaul! Not by me!

This is a sync against iwn(4) and openbsd.

- Add power management support;
- Add background scanning support;
- Fix few LORs;
- Handle rfkill switch state changes properly;
- Fix recovering after firmware failure;
- Add more error checking;
- Cleanup & disable by default debug output;
- Update macroses names;
- Other various fixes;
- Add IBSS support:
  - don't set data_ntries field for management frames;
- Add AHDEMO support:
    - fix padding;
- Sync eeprom functions;
- Use CMD_RXON_ASSOC where possible;
- Enable HW CCMP encryption/decryption for pairwise keys;
- Fix filter flags for CMD_RXON.

Tested (by submitter) - iwn 3945 NIC.  I have one somewhere; I'll
validate this later on and revert it if it's a problem.

Thanks!

PR:		197143
Submitted by:	Andriy Voskoboinyk <s3erios@gmail.com>
This commit is contained in:
Adrian Chadd 2015-02-07 23:11:38 +00:00
parent 84ac51d883
commit 692ad7ca94
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=278366
4 changed files with 4600 additions and 3031 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,98 @@
/*-
* Copyright (c) 2006,2007
* Damien Bergamini <damien.bergamini@free.fr>
* Benjamin Close <Benjamin.Close@clearchain.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD$
*/
#ifndef __IF_WPI_DEBUG_H__
#define __IF_WPI_DEBUG_H__
#ifdef WPI_DEBUG
enum {
WPI_DEBUG_XMIT = 0x00000001, /* basic xmit operation */
WPI_DEBUG_RECV = 0x00000002, /* basic recv operation */
WPI_DEBUG_STATE = 0x00000004, /* 802.11 state transitions */
WPI_DEBUG_HW = 0x00000008, /* Stage 1 (eeprom) debugging */
WPI_DEBUG_RESET = 0x00000010, /* reset processing */
WPI_DEBUG_FIRMWARE = 0x00000020, /* firmware(9) loading debug */
WPI_DEBUG_BEACON = 0x00000040, /* beacon handling */
WPI_DEBUG_WATCHDOG = 0x00000080, /* watchdog timeout */
WPI_DEBUG_INTR = 0x00000100, /* ISR */
WPI_DEBUG_SCAN = 0x00000200, /* Scan related operations */
WPI_DEBUG_NOTIFY = 0x00000400, /* State 2 Notif intr debug */
WPI_DEBUG_TEMP = 0x00000800, /* TXPower/Temp Calibration */
WPI_DEBUG_CMD = 0x00001000, /* cmd submission */
WPI_DEBUG_TRACE = 0x00002000, /* Print begin and start driver function */
WPI_DEBUG_PWRSAVE = 0x00004000, /* Power save operations */
WPI_DEBUG_EEPROM = 0x00008000, /* EEPROM info */
WPI_DEBUG_KEY = 0x00010000, /* node key management */
WPI_DEBUG_EDCA = 0x00020000, /* WME info */
WPI_DEBUG_ANY = 0xffffffff
};
#define DPRINTF(sc, m, ...) do { \
if (sc->sc_debug & (m)) \
printf(__VA_ARGS__); \
} while (0)
#define TRACE_STR_BEGIN "->%s: begin\n"
#define TRACE_STR_DOING "->Doing %s\n"
#define TRACE_STR_END "->%s: end\n"
#define TRACE_STR_END_ERR "->%s: end in error\n"
static const char *wpi_cmd_str(int cmd)
{
switch (cmd) {
/* Notifications */
case WPI_UC_READY: return "UC_READY";
case WPI_RX_DONE: return "RX_DONE";
case WPI_START_SCAN: return "START_SCAN";
case WPI_SCAN_RESULTS: return "SCAN_RESULTS";
case WPI_STOP_SCAN: return "STOP_SCAN";
case WPI_BEACON_SENT: return "BEACON_SENT";
case WPI_RX_STATISTICS: return "RX_STATS";
case WPI_BEACON_STATISTICS: return "BEACON_STATS";
case WPI_STATE_CHANGED: return "STATE_CHANGED";
case WPI_BEACON_MISSED: return "BEACON_MISSED";
/* Command notifications */
case WPI_CMD_RXON: return "WPI_CMD_RXON";
case WPI_CMD_RXON_ASSOC: return "WPI_CMD_RXON_ASSOC";
case WPI_CMD_EDCA_PARAMS: return "WPI_CMD_EDCA_PARAMS";
case WPI_CMD_TIMING: return "WPI_CMD_TIMING";
case WPI_CMD_ADD_NODE: return "WPI_CMD_ADD_NODE";
case WPI_CMD_DEL_NODE: return "WPI_CMD_DEL_NODE";
case WPI_CMD_TX_DATA: return "WPI_CMD_TX_DATA";
case WPI_CMD_MRR_SETUP: return "WPI_CMD_MRR_SETUP";
case WPI_CMD_SET_LED: return "WPI_CMD_SET_LED";
case WPI_CMD_SET_POWER_MODE: return "WPI_CMD_SET_POWER_MODE";
case WPI_CMD_SCAN: return "WPI_CMD_SCAN";
case WPI_CMD_SET_BEACON: return "WPI_CMD_SET_BEACON";
case WPI_CMD_TXPOWER: return "WPI_CMD_TXPOWER";
case WPI_CMD_BT_COEX: return "WPI_CMD_BT_COEX";
default:
KASSERT(1, ("Unknown Command: %d\n", cmd));
return "UNKNOWN CMD";
}
}
#else
#define DPRINTF(sc, m, ...) do { (void) sc; } while (0)
#endif
#endif /* __IF_WPI_DEBUG_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -16,8 +16,6 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <net80211/ieee80211_amrr.h>
struct wpi_rx_radiotap_header {
struct ieee80211_radiotap_header wr_ihdr;
uint64_t wr_tsft;
@ -28,7 +26,7 @@ struct wpi_rx_radiotap_header {
int8_t wr_dbm_antsignal;
int8_t wr_dbm_antnoise;
uint8_t wr_antenna;
};
} __packed;
#define WPI_RX_RADIOTAP_PRESENT \
((1 << IEEE80211_RADIOTAP_TSFT) | \
@ -45,8 +43,7 @@ struct wpi_tx_radiotap_header {
uint8_t wt_rate;
uint16_t wt_chan_freq;
uint16_t wt_chan_flags;
uint8_t wt_hwqueue;
};
} __packed;
#define WPI_TX_RADIOTAP_PRESENT \
((1 << IEEE80211_RADIOTAP_FLAGS) | \
@ -56,15 +53,14 @@ struct wpi_tx_radiotap_header {
struct wpi_dma_info {
bus_dma_tag_t tag;
bus_dmamap_t map;
bus_addr_t paddr; /* aligned p address */
bus_addr_t paddr_start; /* possibly unaligned p start*/
caddr_t vaddr; /* aligned v address */
caddr_t vaddr_start; /* possibly unaligned v start */
bus_addr_t paddr;
caddr_t vaddr;
bus_size_t size;
};
struct wpi_tx_data {
bus_dmamap_t map;
bus_addr_t cmd_paddr;
struct mbuf *m;
struct ieee80211_node *ni;
};
@ -74,19 +70,17 @@ struct wpi_tx_ring {
struct wpi_dma_info cmd_dma;
struct wpi_tx_desc *desc;
struct wpi_tx_cmd *cmd;
struct wpi_tx_data *data;
struct wpi_tx_data data[WPI_TX_RING_COUNT];
bus_dma_tag_t data_dmat;
int qid;
int count;
int queued;
int cur;
int update;
};
#define WPI_RBUF_COUNT ( WPI_RX_RING_COUNT + 16 )
struct wpi_rx_data {
bus_dmamap_t map;
struct mbuf *m;
struct mbuf *m;
bus_dmamap_t map;
};
struct wpi_rx_ring {
@ -95,15 +89,12 @@ struct wpi_rx_ring {
struct wpi_rx_data data[WPI_RX_RING_COUNT];
bus_dma_tag_t data_dmat;
int cur;
int update;
};
struct wpi_amrr {
struct ieee80211_node ni; /* must be the first */
int txcnt;
int retrycnt;
int success;
int success_threshold;
int recovery;
struct wpi_node {
struct ieee80211_node ni; /* must be the first */
uint8_t id;
};
struct wpi_power_sample {
@ -119,80 +110,117 @@ struct wpi_power_group {
int16_t temp;
};
struct wpi_buf {
void *data;
struct ieee80211_node *ni;
struct mbuf *m;
size_t size;
int code;
int ac;
};
struct wpi_vap {
struct ieee80211vap vap;
struct wpi_buf wv_bcbuf;
int (*newstate)(struct ieee80211vap *,
enum ieee80211_state, int);
};
#define WPI_VAP(vap) ((struct wpi_vap *)(vap))
struct wpi_fw_part {
const uint8_t *text;
uint32_t textsz;
const uint8_t *data;
uint32_t datasz;
};
struct wpi_fw_info {
const uint8_t *data;
size_t size;
struct wpi_fw_part init;
struct wpi_fw_part main;
struct wpi_fw_part boot;
};
struct wpi_softc {
device_t sc_dev;
struct ifnet *sc_ifp;
int sc_debug;
struct mtx sc_mtx;
struct unrhdr *sc_unr;
/* Flags indicating the current state the driver
* expects the hardware to be in
*/
uint32_t flags;
#define WPI_FLAG_HW_RADIO_OFF (1 << 0)
#define WPI_FLAG_BUSY (1 << 1)
#define WPI_FLAG_AUTH (1 << 2)
#define WPI_FLAG_BUSY (1 << 0)
/* shared area */
/* Shared area. */
struct wpi_dma_info shared_dma;
struct wpi_shared *shared;
struct wpi_tx_ring txq[WME_NUM_AC];
struct wpi_tx_ring cmdq;
struct wpi_tx_ring txq[WPI_NTXQUEUES];
struct wpi_rx_ring rxq;
/* TX Thermal Callibration */
/* TX Thermal Callibration. */
struct callout calib_to;
int calib_cnt;
/* Watch dog timer */
/* Watch dog timers. */
struct callout watchdog_to;
/* Hardware switch polling timer */
struct callout hwswitch_to;
struct callout watchdog_rfkill;
/* Firmware image. */
struct wpi_fw_info fw;
uint32_t errptr;
struct resource *irq;
struct resource *mem;
bus_space_tag_t sc_st;
bus_space_handle_t sc_sh;
void *sc_ih;
bus_size_t sc_sz;
int sc_cap_off; /* PCIe Capabilities. */
struct wpi_config config;
struct wpi_rxon rxon;
int temp;
uint32_t qfullmsk;
int sc_tx_timer;
int sc_scan_timer;
struct bpf_if *sc_drvbpf;
void (*sc_node_free)(struct ieee80211_node *);
void (*sc_scan_curchan)(struct ieee80211_scan_state *,
unsigned long);
struct wpi_rx_radiotap_header sc_rxtap;
struct wpi_tx_radiotap_header sc_txtap;
/* firmware image */
/* Firmware image. */
const struct firmware *fw_fp;
/* firmware DMA transfer */
/* Firmware DMA transfer. */
struct wpi_dma_info fw_dma;
/* Tasks used by the driver */
struct task sc_restarttask; /* reset firmware task */
struct task sc_radiotask; /* reset rf task */
/* Tasks used by the driver. */
struct task sc_reinittask;
struct task sc_radiooff_task;
struct task sc_radioon_task;
/* Eeprom info */
/* Eeprom info. */
uint8_t cap;
uint16_t rev;
uint8_t type;
struct wpi_eeprom_chan
eeprom_channels[WPI_CHAN_BANDS_COUNT][WPI_MAX_CHAN_PER_BAND];
struct wpi_power_group groups[WPI_POWER_GROUPS_COUNT];
int8_t maxpwr[IEEE80211_CHAN_MAX];
char domain[4]; /*reglatory domain XXX */
char domain[4]; /* Regulatory domain. */
};
#define WPI_LOCK_INIT(_sc) \
mtx_init(&(_sc)->sc_mtx, device_get_nameunit((_sc)->sc_dev), \
MTX_NETWORK_LOCK, MTX_DEF)