aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorAndriy Voskoboinyk <avos@FreeBSD.org>2016-01-03 10:06:10 +0000
committerAndriy Voskoboinyk <avos@FreeBSD.org>2016-01-03 10:06:10 +0000
commit612d1816a88b3c1a67762dcf7764d1e69a177eb0 (patch)
tree75178b37c55acfa181f9e60c13c5ecb4b86e5385 /sys/dev
parent0d4df0290edb1fdc1749e94dfc0edd6d11605d7d (diff)
downloadsrc-612d1816a88b3c1a67762dcf7764d1e69a177eb0.tar.gz
src-612d1816a88b3c1a67762dcf7764d1e69a177eb0.zip
iwm: reorganize if_iwmvar.h
- Change order of data in if_iwmvar.h (like it is in other drivers: defines, data structures, vap/node structures, softc struct and locks); use indentation. - Fix IWM_LOCK(_sc) / IWM_UNLOCK(_sc) macro. - Add IWM_LOCK_INIT / DESTROY(sc) + fix mtx_init() usage. - Wrap iwm_node casts into IWM_NODE() macro. - Drop some fields: * wt_hwqueue from Tx radiotap header; * macaddr[6] from iwm_vap; Approved by: adrian Differential Revision: https://reviews.freebsd.org/D4753
Notes
Notes: svn path=/head/; revision=293099
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/iwm/if_iwm.c15
-rw-r--r--sys/dev/iwm/if_iwm_mac_ctxt.c2
-rw-r--r--sys/dev/iwm/if_iwmvar.h214
3 files changed, 113 insertions, 118 deletions
diff --git a/sys/dev/iwm/if_iwm.c b/sys/dev/iwm/if_iwm.c
index ce3b603d5b5e..ede43020f51f 100644
--- a/sys/dev/iwm/if_iwm.c
+++ b/sys/dev/iwm/if_iwm.c
@@ -2649,7 +2649,7 @@ iwm_tx(struct iwm_softc *sc, struct mbuf *m, struct ieee80211_node *ni, int ac)
{
struct ieee80211com *ic = &sc->sc_ic;
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
- struct iwm_node *in = (struct iwm_node *)ni;
+ struct iwm_node *in = IWM_NODE(ni);
struct iwm_tx_ring *ring;
struct iwm_tx_data *data;
struct iwm_tfd *desc;
@@ -2706,7 +2706,6 @@ iwm_tx(struct iwm_softc *sc, struct mbuf *m, struct ieee80211_node *ni, int ac)
tap->wt_chan_freq = htole16(ni->ni_chan->ic_freq);
tap->wt_chan_flags = htole16(ni->ni_chan->ic_flags);
tap->wt_rate = rinfo->rate;
- tap->wt_hwqueue = ac;
if (k != NULL)
tap->wt_flags |= IEEE80211_RADIOTAP_F_WEP;
ieee80211_radiotap_tx(vap, m);
@@ -3182,7 +3181,7 @@ iwm_auth(struct ieee80211vap *vap, struct iwm_softc *sc)
* freed from underneath us. Grr.
*/
ni = ieee80211_ref_node(vap->iv_bss);
- in = (struct iwm_node *) ni;
+ in = IWM_NODE(ni);
IWM_DPRINTF(sc, IWM_DEBUG_RESET | IWM_DEBUG_STATE,
"%s: called; vap=%p, bss ni=%p\n",
__func__,
@@ -3289,7 +3288,7 @@ out:
static int
iwm_assoc(struct ieee80211vap *vap, struct iwm_softc *sc)
{
- struct iwm_node *in = (struct iwm_node *)vap->iv_bss;
+ struct iwm_node *in = IWM_NODE(vap->iv_bss);
int error;
if ((error = iwm_mvm_update_sta(sc, in)) != 0) {
@@ -3515,7 +3514,7 @@ iwm_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
if (vap->iv_state == IEEE80211_S_RUN && nstate != vap->iv_state) {
iwm_mvm_disable_beacon_filter(sc);
- if (((in = (void *)vap->iv_bss) != NULL))
+ if (((in = IWM_NODE(vap->iv_bss)) != NULL))
in->in_assoc = 0;
iwm_release(sc, NULL);
@@ -3591,7 +3590,7 @@ iwm_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
break;
}
- in = (struct iwm_node *)vap->iv_bss;
+ in = IWM_NODE(vap->iv_bss);
iwm_mvm_power_mac_update_mode(sc, in);
iwm_mvm_enable_beacon_filter(sc, in);
iwm_mvm_update_quotas(sc, in);
@@ -4596,7 +4595,7 @@ iwm_attach(device_t dev)
int txq_i, i;
sc->sc_dev = dev;
- mtx_init(&sc->sc_mtx, "iwm_mtx", MTX_DEF, 0);
+ IWM_LOCK_INIT(sc);
mbufq_init(&sc->sc_snd, ifqmaxlen);
callout_init_mtx(&sc->sc_watchdog_to, &sc->sc_mtx, 0);
TASK_INIT(&sc->sc_es_task, 0, iwm_endscan_cb, sc);
@@ -4985,7 +4984,7 @@ iwm_detach_local(struct iwm_softc *sc, int do_net80211)
iwm_pci_detach(dev);
mbufq_drain(&sc->sc_snd);
- mtx_destroy(&sc->sc_mtx);
+ IWM_LOCK_DESTROY(sc);
return (0);
}
diff --git a/sys/dev/iwm/if_iwm_mac_ctxt.c b/sys/dev/iwm/if_iwm_mac_ctxt.c
index edaacc9e9964..50b1b131509f 100644
--- a/sys/dev/iwm/if_iwm_mac_ctxt.c
+++ b/sys/dev/iwm/if_iwm_mac_ctxt.c
@@ -426,7 +426,7 @@ iwm_mvm_mac_ctxt_cmd_station(struct iwm_softc *sc, struct ieee80211vap *vap,
uint32_t action)
{
struct ieee80211_node *ni = vap->iv_bss;
- struct iwm_node *in = (struct iwm_node *) ni;
+ struct iwm_node *in = IWM_NODE(ni);
struct iwm_mac_ctx_cmd cmd;
IWM_DPRINTF(sc, IWM_DEBUG_RESET,
diff --git a/sys/dev/iwm/if_iwmvar.h b/sys/dev/iwm/if_iwmvar.h
index 9434b838fce1..52363c57d1b1 100644
--- a/sys/dev/iwm/if_iwmvar.h
+++ b/sys/dev/iwm/if_iwmvar.h
@@ -129,7 +129,6 @@ struct iwm_tx_radiotap_header {
uint8_t wt_rate;
uint16_t wt_chan_freq;
uint16_t wt_chan_flags;
- uint8_t wt_hwqueue;
} __packed;
#define IWM_TX_RADIOTAP_PRESENT \
@@ -152,9 +151,6 @@ struct iwm_tx_radiotap_header {
#define IWM_FW_STATUS_INPROGRESS 1
#define IWM_FW_STATUS_DONE 2
-#define IWM_LOCK(_sc) mtx_lock(&sc->sc_mtx)
-#define IWM_UNLOCK(_sc) mtx_unlock(&sc->sc_mtx)
-
enum iwm_ucode_type {
IWM_UCODE_TYPE_INIT,
IWM_UCODE_TYPE_REGULAR,
@@ -244,12 +240,12 @@ struct iwm_dma_info {
#define IWM_TX_RING_HIMARK 224
struct iwm_tx_data {
- bus_dmamap_t map;
- bus_addr_t cmd_paddr;
- bus_addr_t scratch_paddr;
- struct mbuf *m;
- struct iwm_node *in;
- int done;
+ bus_dmamap_t map;
+ bus_addr_t cmd_paddr;
+ bus_addr_t scratch_paddr;
+ struct mbuf *m;
+ struct iwm_node *in;
+ int done;
};
struct iwm_tx_ring {
@@ -295,12 +291,6 @@ struct iwm_rx_ring {
int cur;
};
-#define IWM_FLAG_USE_ICT 0x01
-#define IWM_FLAG_HW_INITED 0x02
-#define IWM_FLAG_STOPPED 0x04
-#define IWM_FLAG_RFKILL 0x08
-#define IWM_FLAG_BUSY 0x10
-
struct iwm_ucode_status {
uint32_t uc_error_event_table;
uint32_t uc_log_event_table;
@@ -371,68 +361,97 @@ struct iwm_bf_data {
};
struct iwm_vap {
- struct ieee80211vap iv_vap;
- uint8_t macaddr[IEEE80211_ADDR_LEN];
- int is_uploaded;
+ struct ieee80211vap iv_vap;
+ int is_uploaded;
- int (*iv_newstate)(struct ieee80211vap *, enum ieee80211_state, int);
+ int (*iv_newstate)(struct ieee80211vap *,
+ enum ieee80211_state, int);
};
+#define IWM_VAP(_vap) ((struct iwm_vap *)(_vap))
-#define IWM_VAP(_vap) ((struct iwm_vap *)(_vap))
+struct iwm_node {
+ struct ieee80211_node in_ni;
+ struct iwm_mvm_phy_ctxt *in_phyctxt;
+
+ /* status "bits" */
+ int in_assoc;
+
+ struct iwm_lq_cmd in_lq;
+
+ uint8_t in_ridx[IEEE80211_RATE_MAXSIZE];
+};
+#define IWM_NODE(_ni) ((struct iwm_node *)(_ni))
+
+#define IWM_STATION_ID 0
+
+#define IWM_DEFAULT_MACID 0
+#define IWM_DEFAULT_COLOR 0
+#define IWM_DEFAULT_TSFID 0
+
+#define IWM_ICT_SIZE 4096
+#define IWM_ICT_COUNT (IWM_ICT_SIZE / sizeof (uint32_t))
+#define IWM_ICT_PADDR_SHIFT 12
struct iwm_softc {
+ device_t sc_dev;
+ uint32_t sc_debug;
+
struct mtx sc_mtx;
struct mbufq sc_snd;
struct ieee80211com sc_ic;
- device_t sc_dev;
+
+ int sc_flags;
+#define IWM_FLAG_USE_ICT (1 << 0)
+#define IWM_FLAG_HW_INITED (1 << 1)
+#define IWM_FLAG_STOPPED (1 << 2)
+#define IWM_FLAG_RFKILL (1 << 3)
+#define IWM_FLAG_BUSY (1 << 4)
struct intr_config_hook sc_preinit_hook;
- struct callout sc_watchdog_to;
+ struct callout sc_watchdog_to;
struct task init_task;
- struct resource *sc_irq;
- struct resource *sc_mem;
- bus_space_tag_t sc_st;
- bus_space_handle_t sc_sh;
- bus_size_t sc_sz;
- bus_dma_tag_t sc_dmat;
- void *sc_ih;
+ struct resource *sc_irq;
+ struct resource *sc_mem;
+ bus_space_tag_t sc_st;
+ bus_space_handle_t sc_sh;
+ bus_size_t sc_sz;
+ bus_dma_tag_t sc_dmat;
+ void *sc_ih;
/* TX scheduler rings. */
- struct iwm_dma_info sched_dma;
- uint32_t sched_base;
+ struct iwm_dma_info sched_dma;
+ uint32_t sched_base;
/* TX/RX rings. */
- struct iwm_tx_ring txq[IWM_MVM_MAX_QUEUES];
- struct iwm_rx_ring rxq;
- int qfullmsk;
+ struct iwm_tx_ring txq[IWM_MVM_MAX_QUEUES];
+ struct iwm_rx_ring rxq;
+ int qfullmsk;
- int sc_sf_state;
+ int sc_sf_state;
/* ICT table. */
struct iwm_dma_info ict_dma;
int ict_cur;
- int sc_hw_rev;
- int sc_hw_id;
+ int sc_hw_rev;
+ int sc_hw_id;
- struct iwm_dma_info kw_dma;
- struct iwm_dma_info fw_dma;
+ struct iwm_dma_info kw_dma;
+ struct iwm_dma_info fw_dma;
- int sc_fw_chunk_done;
- int sc_init_complete;
+ int sc_fw_chunk_done;
+ int sc_init_complete;
- struct iwm_ucode_status sc_uc;
- enum iwm_ucode_type sc_uc_current;
- int sc_fwver;
+ struct iwm_ucode_status sc_uc;
+ enum iwm_ucode_type sc_uc_current;
+ int sc_fwver;
- int sc_capaflags;
- int sc_capa_max_probe_len;
+ int sc_capaflags;
+ int sc_capa_max_probe_len;
- int sc_intmask;
- int sc_flags;
- uint32_t sc_debug;
+ int sc_intmask;
/*
* So why do we need a separate stopped flag and a generation?
@@ -443,86 +462,63 @@ struct iwm_softc {
* the device from interrupt context when it craps out, so we
* don't have the luxury of waiting for quiescense.
*/
- int sc_generation;
+ int sc_generation;
- const char *sc_fwname;
- bus_size_t sc_fwdmasegsz;
- struct iwm_fw_info sc_fw;
- int sc_fw_phy_config;
+ const char *sc_fwname;
+ bus_size_t sc_fwdmasegsz;
+ struct iwm_fw_info sc_fw;
+ int sc_fw_phy_config;
struct iwm_tlv_calib_ctrl sc_default_calib[IWM_UCODE_TYPE_MAX];
- struct iwm_nvm_data sc_nvm;
- struct iwm_phy_db sc_phy_db;
+ struct iwm_nvm_data sc_nvm;
+ struct iwm_phy_db sc_phy_db;
- struct iwm_bf_data sc_bf;
+ struct iwm_bf_data sc_bf;
- int sc_tx_timer;
+ int sc_tx_timer;
- struct iwm_scan_cmd *sc_scan_cmd;
- size_t sc_scan_cmd_len;
- int sc_scan_last_antenna;
- int sc_scanband;
+ struct iwm_scan_cmd *sc_scan_cmd;
+ size_t sc_scan_cmd_len;
+ int sc_scan_last_antenna;
+ int sc_scanband;
- int sc_auth_prot;
+ int sc_auth_prot;
- int sc_fixed_ridx;
+ int sc_fixed_ridx;
- int sc_staid;
- int sc_nodecolor;
+ int sc_staid;
+ int sc_nodecolor;
- uint8_t sc_cmd_resp[IWM_CMD_RESP_MAX];
- int sc_wantresp;
+ uint8_t sc_cmd_resp[IWM_CMD_RESP_MAX];
+ int sc_wantresp;
- struct taskqueue *sc_tq;
- struct task sc_es_task;
+ struct taskqueue *sc_tq;
+ struct task sc_es_task;
- struct iwm_rx_phy_info sc_last_phy_info;
- int sc_ampdu_ref;
+ struct iwm_rx_phy_info sc_last_phy_info;
+ int sc_ampdu_ref;
- struct iwm_int_sta sc_aux_sta;
+ struct iwm_int_sta sc_aux_sta;
/* phy contexts. we only use the first one */
- struct iwm_mvm_phy_ctxt sc_phyctxt[IWM_NUM_PHY_CTX];
+ struct iwm_mvm_phy_ctxt sc_phyctxt[IWM_NUM_PHY_CTX];
struct iwm_notif_statistics sc_stats;
- int sc_noise;
+ int sc_noise;
- int host_interrupt_operation_mode;
+ int host_interrupt_operation_mode;
caddr_t sc_drvbpf;
- union {
- struct iwm_rx_radiotap_header th;
- uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];
- } sc_rxtapu;
-#define sc_rxtap sc_rxtapu.th
-
- union {
- struct iwm_tx_radiotap_header th;
- uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];
- } sc_txtapu;
-#define sc_txtap sc_txtapu.th
-
- int sc_max_rssi;
-};
-
-#define IWM_DEFAULT_MACID 0
-#define IWM_DEFAULT_COLOR 0
-#define IWM_DEFAULT_TSFID 0
-
-struct iwm_node {
- struct ieee80211_node in_ni;
- struct iwm_mvm_phy_ctxt *in_phyctxt;
-
- /* status "bits" */
- int in_assoc;
-
- struct iwm_lq_cmd in_lq;
+ struct iwm_rx_radiotap_header sc_rxtap;
+ struct iwm_tx_radiotap_header sc_txtap;
- uint8_t in_ridx[IEEE80211_RATE_MAXSIZE];
+ int sc_max_rssi;
};
-#define IWM_STATION_ID 0
-#define IWM_ICT_SIZE 4096
-#define IWM_ICT_COUNT (IWM_ICT_SIZE / sizeof (uint32_t))
-#define IWM_ICT_PADDR_SHIFT 12
+#define IWM_LOCK_INIT(_sc) \
+ mtx_init(&(_sc)->sc_mtx, device_get_nameunit((_sc)->sc_dev), \
+ MTX_NETWORK_LOCK, MTX_DEF);
+#define IWM_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
+#define IWM_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
+#define IWM_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_mtx)