提交 8b36de8c 编写于 作者: P Prameela Rani Garnepudi 提交者: Kalle Valo

rsi: Add support for configuring tx power

TX power can be configured from iwconfig, iw or from mac80211 when
regulatory changes are done. Hence support for configuring tx power
to device is added using the RADIO_PARAMS_UPDATE command frame.
Signed-off-by: NPrameela Rani Garnepudi <prameela.j04cs@gmail.com>
Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
上级 e6d64284
......@@ -410,6 +410,34 @@ static int rsi_channel_change(struct ieee80211_hw *hw)
return status;
}
/**
* rsi_config_power() - This function configures tx power to device
* @hw: Pointer to the ieee80211_hw structure.
*
* Return: 0 on success, negative error code on failure.
*/
static int rsi_config_power(struct ieee80211_hw *hw)
{
struct rsi_hw *adapter = hw->priv;
struct rsi_common *common = adapter->priv;
struct ieee80211_conf *conf = &hw->conf;
if (adapter->sc_nvifs <= 0) {
rsi_dbg(ERR_ZONE, "%s: No virtual interface found\n", __func__);
return -EINVAL;
}
rsi_dbg(INFO_ZONE,
"%s: Set tx power: %d dBM\n", __func__, conf->power_level);
if (conf->power_level == common->tx_power)
return 0;
common->tx_power = conf->power_level;
return rsi_send_radio_params_update(common);
}
/**
* rsi_mac80211_config() - This function is a handler for configuration
* requests. The stack calls this function to
......@@ -431,6 +459,12 @@ static int rsi_mac80211_config(struct ieee80211_hw *hw,
if (changed & IEEE80211_CONF_CHANGE_CHANNEL)
status = rsi_channel_change(hw);
/* tx power */
if (changed & IEEE80211_CONF_CHANGE_POWER) {
rsi_dbg(INFO_ZONE, "%s: Configuring Power\n", __func__);
status = rsi_config_power(hw);
}
mutex_unlock(&common->mutex);
return status;
......
......@@ -952,6 +952,43 @@ int rsi_set_channel(struct rsi_common *common, u16 channel)
return rsi_send_internal_mgmt_frame(common, skb);
}
/**
* rsi_send_radio_params_update() - This function sends the radio
* parameters update to device
* @common: Pointer to the driver private structure.
* @channel: Channel value to be set.
*
* Return: 0 on success, corresponding error code on failure.
*/
int rsi_send_radio_params_update(struct rsi_common *common)
{
struct rsi_mac_frame *cmd_frame;
struct sk_buff *skb = NULL;
rsi_dbg(MGMT_TX_ZONE,
"%s: Sending Radio Params update frame\n", __func__);
skb = dev_alloc_skb(FRAME_DESC_SZ);
if (!skb) {
rsi_dbg(ERR_ZONE, "%s: Failed in allocation of skb\n",
__func__);
return -ENOMEM;
}
memset(skb->data, 0, FRAME_DESC_SZ);
cmd_frame = (struct rsi_mac_frame *)skb->data;
cmd_frame->desc_word[0] = cpu_to_le16(RSI_WIFI_MGMT_Q << 12);
cmd_frame->desc_word[1] = cpu_to_le16(RADIO_PARAMS_UPDATE);
cmd_frame->desc_word[3] = cpu_to_le16(BIT(0));
cmd_frame->desc_word[3] |= cpu_to_le16(common->tx_power << 8);
skb_put(skb, FRAME_DESC_SZ);
return rsi_send_internal_mgmt_frame(common, skb);
}
/**
* rsi_compare() - This function is used to compare two integers
* @a: pointer to the first integer
......
......@@ -204,6 +204,8 @@ struct rsi_common {
struct cqm_info cqm_info;
bool hw_data_qs_blocked;
int tx_power;
};
struct rsi_hw {
......
......@@ -200,7 +200,8 @@ enum cmd_frame_type {
BG_SCAN_PARAMS,
BG_SCAN_PROBE_REQ,
CW_MODE_REQ,
PER_CMD_PKT
PER_CMD_PKT,
RADIO_PARAMS_UPDATE = 0x29
};
struct rsi_mac_frame {
......@@ -324,4 +325,5 @@ int rsi_send_mgmt_pkt(struct rsi_common *common, struct sk_buff *skb);
int rsi_send_data_pkt(struct rsi_common *common, struct sk_buff *skb);
int rsi_band_check(struct rsi_common *common);
int rsi_send_rx_filter_frame(struct rsi_common *common, u16 rx_filter_word);
int rsi_send_radio_params_update(struct rsi_common *common);
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册