Skip to content

Commit

Permalink
Added code to support get_survey() of mac80211.
Browse files Browse the repository at this point in the history
ACS can work now.

Signed-off-by: David Lin <dlin@marvell.com>
  • Loading branch information
yuhhaurlin committed Nov 23, 2016
1 parent fb68d69 commit ab05f99
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 31 deletions.
14 changes: 11 additions & 3 deletions dev.h
Expand Up @@ -29,6 +29,13 @@
#define MWL_DRV_NAME KBUILD_MODNAME
#define MWL_DRV_VERSION "10.3.2.0-20161123"

#define MAC_REG_ADDR(offset) (offset)
#define MAC_REG_ADDR_PCI(offset) ((priv->iobase1 + 0xA000) + offset)

#define MCU_CCA_CNT MAC_REG_ADDR(0x06A0)
#define MCU_TXPE_CNT MAC_REG_ADDR(0x06A4)
#define MCU_LAST_READ MAC_REG_ADDR(0x06A8)

/* Map to 0x80000000 (Bus control) on BAR0 */
#define MACREG_REG_H2A_INTERRUPT_EVENTS 0x00000C18 /* (From host to ARM) */
#define MACREG_REG_H2A_INTERRUPT_CAUSE 0x00000C1C /* (From host to ARM) */
Expand Down Expand Up @@ -273,8 +280,6 @@ struct mwl_ampdu_stream {
};

#ifdef CONFIG_DEBUG_FS
#define MAC_REG_ADDR_PCI(offset) ((priv->iobase1 + 0xA000) + offset)

#define MWL_ACCESS_MAC 1
#define MWL_ACCESS_RF 2
#define MWL_ACCESS_BBP 3
Expand Down Expand Up @@ -347,7 +352,10 @@ struct mwl_priv {

struct timer_list period_timer;

s8 noise; /* Most recently reported noise in dBm */
/* keep survey information */
u32 time_period;
u32 time_busy;
u32 time_tx;
struct ieee80211_supported_band band_24;
struct ieee80211_channel channels_24[BAND_24_CHANNEL_NUM];
struct ieee80211_rate rates_24[BAND_24_RATE_NUM];
Expand Down
40 changes: 17 additions & 23 deletions fwcmd.c
Expand Up @@ -883,6 +883,11 @@ static int mwl_fwcmd_encryption_set_cmd_info(struct hostcmd_cmd_set_key *cmd,
return 0;
}

static u32 pci_read_mac_reg(struct mwl_priv *priv, u32 offset)
{
return le32_to_cpu(*(volatile unsigned long *)(MAC_REG_ADDR_PCI(offset)));
}

void mwl_fwcmd_reset(struct ieee80211_hw *hw)
{
struct mwl_priv *priv = hw->priv;
Expand Down Expand Up @@ -1457,6 +1462,8 @@ int mwl_fwcmd_set_rf_channel(struct ieee80211_hw *hw,

mutex_unlock(&priv->fwcmd_mutex);

mwl_fwcmd_get_survey(hw, true);

return 0;
}

Expand Down Expand Up @@ -2982,30 +2989,17 @@ int mwl_fwcmd_quiet_mode(struct ieee80211_hw *hw, bool enable, u32 period,
return 0;
}

int mwl_fwcmd_send_mfg_cmd(struct mwl_priv *priv, char *mfgcmd)
void mwl_fwcmd_get_survey(struct ieee80211_hw *hw, bool clean)
{
struct hostcmd_header *pcmd;
struct cmd_header *cmd_hd = (struct cmd_header *)(mfgcmd + 4);
u16 len;
u16 cmd;

pcmd = (struct hostcmd_header *)&priv->pcmd_buf[0];
struct mwl_priv *priv = hw->priv;

mutex_lock(&priv->fwcmd_mutex);
priv->time_period += pci_read_mac_reg(priv, MCU_LAST_READ);
priv->time_busy += pci_read_mac_reg(priv, MCU_CCA_CNT);
priv->time_tx += pci_read_mac_reg(priv, MCU_TXPE_CNT);

len = le16_to_cpu(cmd_hd->len);
memset(pcmd, 0x00, len + 4);
memcpy((char *)pcmd, mfgcmd, len + 4);
cmd = le16_to_cpu(cmd_hd->command);
if (mwl_fwcmd_exec_cmd(priv, cmd)) {
mutex_unlock(&priv->fwcmd_mutex);
wiphy_err(priv->hw->wiphy, "failed execution");
return -EIO;
if (clean) {
priv->time_period = 0;
priv->time_busy = 0;
priv->time_tx = 0;
}
cmd_hd = (struct cmd_header *)&priv->pcmd_buf[2];
len = le16_to_cpu(cmd_hd->len);
memcpy(mfgcmd, (char *)&priv->pcmd_buf[2], len);
mutex_unlock(&priv->fwcmd_mutex);

return 0;
}
}
2 changes: 1 addition & 1 deletion fwcmd.h
Expand Up @@ -227,6 +227,6 @@ int mwl_fwcmd_get_device_pwr_tbl_sc4(struct ieee80211_hw *hw,
int mwl_fwcmd_quiet_mode(struct ieee80211_hw *hw, bool enable, u32 period,
u32 duration, u32 next_offset);

int mwl_fwcmd_send_mfg_cmd(struct mwl_priv *priv, char *mfgcmd);
void mwl_fwcmd_get_survey(struct ieee80211_hw *hw, bool clean);

#endif /* _FWCMD_H_ */
12 changes: 10 additions & 2 deletions mac80211.c
Expand Up @@ -569,8 +569,16 @@ static int mwl_mac80211_get_survey(struct ieee80211_hw *hw,
return -ENOENT;

survey->channel = conf->chandef.chan;
survey->filled = SURVEY_INFO_NOISE_DBM;
survey->noise = priv->noise;
mwl_fwcmd_get_survey(hw, false);
survey->filled = SURVEY_INFO_TIME |
SURVEY_INFO_TIME_BUSY |
SURVEY_INFO_TIME_TX;
survey->time = priv->time_period / 1000;
survey->time_busy = priv->time_busy / 1000;
survey->time_tx = priv->time_tx / 1000;

if (!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL))
survey->filled |= SURVEY_INFO_IN_USE;

return 0;
}
Expand Down
2 changes: 0 additions & 2 deletions rx.c
Expand Up @@ -439,8 +439,6 @@ void mwl_rx_recv(unsigned long data)

mwl_rx_prepare_status(curr_hndl->pdesc, &status);

priv->noise = -curr_hndl->pdesc->noise_floor;

wh = &((struct mwl_dma_data *)prx_skb->data)->wh;

if (ieee80211_has_protected(wh->frame_control)) {
Expand Down

0 comments on commit ab05f99

Please sign in to comment.