Skip to content

Commit

Permalink
ath9k: Add data structure for supporting virtual radio/wiphy operation
Browse files Browse the repository at this point in the history
This is the initial step in allowing ath9k to register multiple
virtual radios (wiphys). The goal of virtual radios is to allow the
same radio to be shared for multiple virtual interfaces that may
operate on different channels. The mac80211 virtual interface support
is designed only for single channel operation and as such, it is not
suitable for this type of use. Anyway, it can be used on top of the
virtual radio concept, if desired (e.g., use two virtual radios to
handle two channels and then add multiple mac80211 virtual interfaces
on top of each virtual radio).

The new struct ath_wiphy is now registered as the driver data
structure for wiphy. This structure has a pointer to the shared (among
virtual wiphys of the same physical radio) struct ath_softc data. The
primary wiphy maintains the allocated memory for ath_softc. Secondary
(virtual) wiphys will only allocate the new ath_wiphy structure.

Registration of secondary wiphys is added in a separate patch.

Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Jouni Malinen authored and John W. Linville committed Mar 5, 2009
1 parent 8ca21f0 commit bce048d
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 36 deletions.
12 changes: 9 additions & 3 deletions drivers/net/wireless/ath9k/ahb.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ static int ath_ahb_probe(struct platform_device *pdev)

irq = res->start;

hw = ieee80211_alloc_hw(sizeof(struct ath_softc), &ath9k_ops);
hw = ieee80211_alloc_hw(sizeof(struct ath_wiphy) +
sizeof(struct ath_softc), &ath9k_ops);
if (hw == NULL) {
dev_err(&pdev->dev, "no memory for ieee80211_hw\n");
ret = -ENOMEM;
Expand All @@ -106,7 +107,11 @@ static int ath_ahb_probe(struct platform_device *pdev)
SET_IEEE80211_DEV(hw, &pdev->dev);
platform_set_drvdata(pdev, hw);

sc = hw->priv;
aphy = hw->priv;
sc = (struct ath_softc *) (aphy + 1);
aphy->sc = sc;
aphy->hw = hw;
sc->pri_wiphy = aphy;
sc->hw = hw;
sc->dev = &pdev->dev;
sc->mem = mem;
Expand Down Expand Up @@ -156,7 +161,8 @@ static int ath_ahb_remove(struct platform_device *pdev)
struct ieee80211_hw *hw = platform_get_drvdata(pdev);

if (hw) {
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;

ath_cleanup(sc);
platform_set_drvdata(pdev, NULL);
Expand Down
8 changes: 8 additions & 0 deletions drivers/net/wireless/ath9k/ath9k.h
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,12 @@ struct ath_bus_ops {
bool (*eeprom_read)(struct ath_hw *ah, u32 off, u16 *data);
};

struct ath_wiphy;

struct ath_softc {
struct ieee80211_hw *hw;
struct device *dev;
struct ath_wiphy *pri_wiphy;
struct tasklet_struct intr_tq;
struct tasklet_struct bcon_tasklet;
struct ath_hw *sc_ah;
Expand Down Expand Up @@ -607,6 +610,11 @@ struct ath_softc {
struct ath_bus_ops *bus_ops;
};

struct ath_wiphy {
struct ath_softc *sc; /* shared for all virtual wiphys */
struct ieee80211_hw *hw;
};

int ath_reset(struct ath_softc *sc, bool retry_tx);
int ath_get_hal_qnum(u16 queue, struct ath_softc *sc);
int ath_get_mac80211_qnum(u32 queue, struct ath_softc *sc);
Expand Down
58 changes: 38 additions & 20 deletions drivers/net/wireless/ath9k/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1934,7 +1934,8 @@ static void ath9k_update_ichannel(struct ath_softc *sc,

static int ath9k_start(struct ieee80211_hw *hw)
{
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;
struct ieee80211_channel *curchan = hw->conf.channel;
struct ath9k_channel *init_channel;
int r, pos;
Expand Down Expand Up @@ -2012,7 +2013,7 @@ static int ath9k_start(struct ieee80211_hw *hw)
sc->imask &= ~(ATH9K_INT_SWBA | ATH9K_INT_BMISS);
ath9k_hw_set_interrupts(sc->sc_ah, sc->imask);

ieee80211_wake_queues(sc->hw);
ieee80211_wake_queues(hw);

#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
r = ath_start_rfkill_poll(sc);
Expand All @@ -2028,7 +2029,8 @@ static int ath9k_tx(struct ieee80211_hw *hw,
struct sk_buff *skb)
{
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;
struct ath_tx_control txctl;
int hdrlen, padsize;

Expand Down Expand Up @@ -2078,7 +2080,8 @@ static int ath9k_tx(struct ieee80211_hw *hw,

static void ath9k_stop(struct ieee80211_hw *hw)
{
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;

if (sc->sc_flags & SC_OP_INVALID) {
DPRINTF(sc, ATH_DBG_ANY, "Device not present\n");
Expand All @@ -2087,7 +2090,7 @@ static void ath9k_stop(struct ieee80211_hw *hw)

mutex_lock(&sc->mutex);

ieee80211_stop_queues(sc->hw);
ieee80211_stop_queues(hw);

/* make sure h/w will not generate any interrupt
* before setting the invalid flag. */
Expand Down Expand Up @@ -2118,7 +2121,8 @@ static void ath9k_stop(struct ieee80211_hw *hw)
static int ath9k_add_interface(struct ieee80211_hw *hw,
struct ieee80211_if_init_conf *conf)
{
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;
struct ath_vif *avp = (void *)conf->vif->drv_priv;
enum nl80211_iftype ic_opmode = NL80211_IFTYPE_UNSPECIFIED;
int ret = 0;
Expand Down Expand Up @@ -2217,7 +2221,8 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
static void ath9k_remove_interface(struct ieee80211_hw *hw,
struct ieee80211_if_init_conf *conf)
{
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;
struct ath_vif *avp = (void *)conf->vif->drv_priv;
int i;

Expand Down Expand Up @@ -2252,7 +2257,8 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,

static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
{
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;
struct ieee80211_conf *conf = &hw->conf;

mutex_lock(&sc->mutex);
Expand Down Expand Up @@ -2319,7 +2325,8 @@ static int ath9k_config_interface(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_if_conf *conf)
{
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;
struct ath_hw *ah = sc->sc_ah;
struct ath_vif *avp = (void *)vif->drv_priv;
u32 rfilt = 0;
Expand Down Expand Up @@ -2424,7 +2431,8 @@ static void ath9k_configure_filter(struct ieee80211_hw *hw,
int mc_count,
struct dev_mc_list *mclist)
{
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;
u32 rfilt;

changed_flags &= SUPPORTED_FILTERS;
Expand All @@ -2442,7 +2450,8 @@ static void ath9k_sta_notify(struct ieee80211_hw *hw,
enum sta_notify_cmd cmd,
struct ieee80211_sta *sta)
{
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;

switch (cmd) {
case STA_NOTIFY_ADD:
Expand All @@ -2459,7 +2468,8 @@ static void ath9k_sta_notify(struct ieee80211_hw *hw,
static int ath9k_conf_tx(struct ieee80211_hw *hw, u16 queue,
const struct ieee80211_tx_queue_params *params)
{
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;
struct ath9k_tx_queue_info qi;
int ret = 0, qnum;

Expand Down Expand Up @@ -2495,7 +2505,8 @@ static int ath9k_set_key(struct ieee80211_hw *hw,
struct ieee80211_sta *sta,
struct ieee80211_key_conf *key)
{
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;
int ret = 0;

if (modparam_nohwcrypt)
Expand Down Expand Up @@ -2537,7 +2548,8 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
struct ieee80211_bss_conf *bss_conf,
u32 changed)
{
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;

mutex_lock(&sc->mutex);

Expand Down Expand Up @@ -2572,7 +2584,8 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
static u64 ath9k_get_tsf(struct ieee80211_hw *hw)
{
u64 tsf;
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;

mutex_lock(&sc->mutex);
tsf = ath9k_hw_gettsf64(sc->sc_ah);
Expand All @@ -2583,7 +2596,8 @@ static u64 ath9k_get_tsf(struct ieee80211_hw *hw)

static void ath9k_set_tsf(struct ieee80211_hw *hw, u64 tsf)
{
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;

mutex_lock(&sc->mutex);
ath9k_hw_settsf64(sc->sc_ah, tsf);
Expand All @@ -2592,7 +2606,8 @@ static void ath9k_set_tsf(struct ieee80211_hw *hw, u64 tsf)

static void ath9k_reset_tsf(struct ieee80211_hw *hw)
{
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;

mutex_lock(&sc->mutex);
ath9k_hw_reset_tsf(sc->sc_ah);
Expand All @@ -2604,7 +2619,8 @@ static int ath9k_ampdu_action(struct ieee80211_hw *hw,
struct ieee80211_sta *sta,
u16 tid, u16 *ssn)
{
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;
int ret = 0;

switch (action) {
Expand Down Expand Up @@ -2642,7 +2658,8 @@ static int ath9k_ampdu_action(struct ieee80211_hw *hw,

static void ath9k_sw_scan_start(struct ieee80211_hw *hw)
{
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;

mutex_lock(&sc->mutex);
sc->sc_flags |= SC_OP_SCANNING;
Expand All @@ -2651,7 +2668,8 @@ static void ath9k_sw_scan_start(struct ieee80211_hw *hw)

static void ath9k_sw_scan_complete(struct ieee80211_hw *hw)
{
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;

mutex_lock(&sc->mutex);
sc->sc_flags &= ~SC_OP_SCANNING;
Expand Down
19 changes: 14 additions & 5 deletions drivers/net/wireless/ath9k/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ static struct ath_bus_ops ath_pci_bus_ops = {
static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
void __iomem *mem;
struct ath_wiphy *aphy;
struct ath_softc *sc;
struct ieee80211_hw *hw;
u8 csz;
Expand Down Expand Up @@ -155,7 +156,8 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto bad1;
}

hw = ieee80211_alloc_hw(sizeof(struct ath_softc), &ath9k_ops);
hw = ieee80211_alloc_hw(sizeof(struct ath_wiphy) +
sizeof(struct ath_softc), &ath9k_ops);
if (hw == NULL) {
printk(KERN_ERR "ath_pci: no memory for ieee80211_hw\n");
goto bad2;
Expand All @@ -164,7 +166,11 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
SET_IEEE80211_DEV(hw, &pdev->dev);
pci_set_drvdata(pdev, hw);

sc = hw->priv;
aphy = hw->priv;
sc = (struct ath_softc *) (aphy + 1);
aphy->sc = sc;
aphy->hw = hw;
sc->pri_wiphy = aphy;
sc->hw = hw;
sc->dev = &pdev->dev;
sc->mem = mem;
Expand Down Expand Up @@ -214,7 +220,8 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
static void ath_pci_remove(struct pci_dev *pdev)
{
struct ieee80211_hw *hw = pci_get_drvdata(pdev);
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;

ath_cleanup(sc);
}
Expand All @@ -224,7 +231,8 @@ static void ath_pci_remove(struct pci_dev *pdev)
static int ath_pci_suspend(struct pci_dev *pdev, pm_message_t state)
{
struct ieee80211_hw *hw = pci_get_drvdata(pdev);
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;

ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 1);

Expand All @@ -243,7 +251,8 @@ static int ath_pci_suspend(struct pci_dev *pdev, pm_message_t state)
static int ath_pci_resume(struct pci_dev *pdev)
{
struct ieee80211_hw *hw = pci_get_drvdata(pdev);
struct ath_softc *sc = hw->priv;
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;
u32 val;
int err;

Expand Down
3 changes: 2 additions & 1 deletion drivers/net/wireless/ath9k/rc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1673,7 +1673,8 @@ static void ath_rate_update(void *priv, struct ieee80211_supported_band *sband,

static void *ath_rate_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
{
return hw->priv;
struct ath_wiphy *aphy = hw->priv;
return aphy->sc;
}

static void ath_rate_free(void *priv)
Expand Down
15 changes: 11 additions & 4 deletions drivers/net/wireless/ath9k/recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

#include "ath9k.h"

static struct ieee80211_hw * ath_get_virt_hw(struct ath_softc *sc,
struct ieee80211_hdr *hdr)
{
return sc->pri_wiphy->hw;
}

/*
* Setup and link descriptors.
*
Expand Down Expand Up @@ -123,10 +129,12 @@ static int ath_rx_prepare(struct sk_buff *skb, struct ath_desc *ds,
struct ieee80211_hdr *hdr;
u8 ratecode;
__le16 fc;
struct ieee80211_hw *hw;

hdr = (struct ieee80211_hdr *)skb->data;
fc = hdr->frame_control;
memset(rx_status, 0, sizeof(struct ieee80211_rx_status));
hw = ath_get_virt_hw(sc, hdr);

if (ds->ds_rxstat.rs_more) {
/*
Expand Down Expand Up @@ -186,7 +194,6 @@ static int ath_rx_prepare(struct sk_buff *skb, struct ath_desc *ds,
rx_status->rate_idx = ratecode & 0x7f;
} else {
int i = 0, cur_band, n_rates;
struct ieee80211_hw *hw = sc->hw;

cur_band = hw->conf.channel->band;
n_rates = sc->sbands[cur_band].n_bitrates;
Expand All @@ -208,8 +215,8 @@ static int ath_rx_prepare(struct sk_buff *skb, struct ath_desc *ds,
}

rx_status->mactime = ath_extend_tsf(sc, ds->ds_rxstat.rs_tstamp);
rx_status->band = sc->hw->conf.channel->band;
rx_status->freq = sc->hw->conf.channel->center_freq;
rx_status->band = hw->conf.channel->band;
rx_status->freq = hw->conf.channel->center_freq;
rx_status->noise = sc->ani.noise_floor;
rx_status->signal = rx_status->noise + ds->ds_rxstat.rs_rssi;
rx_status->antenna = ds->ds_rxstat.rs_antenna;
Expand Down Expand Up @@ -604,7 +611,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
}

/* Send the frame to mac80211 */
__ieee80211_rx(sc->hw, skb, &rx_status);
__ieee80211_rx(ath_get_virt_hw(sc, hdr), skb, &rx_status);

/* We will now give hardware our shiny new allocated skb */
bf->bf_mpdu = requeue_skb;
Expand Down
Loading

0 comments on commit bce048d

Please sign in to comment.