Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Prameela Rani Garnepudi <prameela.j04cs@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>

authored by

Prameela Rani Garnepudi and committed by
Kalle Valo
8b36de8c e6d64284

+76 -1
+34
drivers/net/wireless/rsi/rsi_91x_mac80211.c
··· 411 411 } 412 412 413 413 /** 414 + * rsi_config_power() - This function configures tx power to device 415 + * @hw: Pointer to the ieee80211_hw structure. 416 + * 417 + * Return: 0 on success, negative error code on failure. 418 + */ 419 + static int rsi_config_power(struct ieee80211_hw *hw) 420 + { 421 + struct rsi_hw *adapter = hw->priv; 422 + struct rsi_common *common = adapter->priv; 423 + struct ieee80211_conf *conf = &hw->conf; 424 + 425 + if (adapter->sc_nvifs <= 0) { 426 + rsi_dbg(ERR_ZONE, "%s: No virtual interface found\n", __func__); 427 + return -EINVAL; 428 + } 429 + 430 + rsi_dbg(INFO_ZONE, 431 + "%s: Set tx power: %d dBM\n", __func__, conf->power_level); 432 + 433 + if (conf->power_level == common->tx_power) 434 + return 0; 435 + 436 + common->tx_power = conf->power_level; 437 + 438 + return rsi_send_radio_params_update(common); 439 + } 440 + 441 + /** 414 442 * rsi_mac80211_config() - This function is a handler for configuration 415 443 * requests. The stack calls this function to 416 444 * change hardware configuration, e.g., channel. ··· 458 430 459 431 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) 460 432 status = rsi_channel_change(hw); 433 + 434 + /* tx power */ 435 + if (changed & IEEE80211_CONF_CHANGE_POWER) { 436 + rsi_dbg(INFO_ZONE, "%s: Configuring Power\n", __func__); 437 + status = rsi_config_power(hw); 438 + } 461 439 462 440 mutex_unlock(&common->mutex); 463 441
+37
drivers/net/wireless/rsi/rsi_91x_mgmt.c
··· 953 953 } 954 954 955 955 /** 956 + * rsi_send_radio_params_update() - This function sends the radio 957 + * parameters update to device 958 + * @common: Pointer to the driver private structure. 959 + * @channel: Channel value to be set. 960 + * 961 + * Return: 0 on success, corresponding error code on failure. 962 + */ 963 + int rsi_send_radio_params_update(struct rsi_common *common) 964 + { 965 + struct rsi_mac_frame *cmd_frame; 966 + struct sk_buff *skb = NULL; 967 + 968 + rsi_dbg(MGMT_TX_ZONE, 969 + "%s: Sending Radio Params update frame\n", __func__); 970 + 971 + skb = dev_alloc_skb(FRAME_DESC_SZ); 972 + if (!skb) { 973 + rsi_dbg(ERR_ZONE, "%s: Failed in allocation of skb\n", 974 + __func__); 975 + return -ENOMEM; 976 + } 977 + 978 + memset(skb->data, 0, FRAME_DESC_SZ); 979 + cmd_frame = (struct rsi_mac_frame *)skb->data; 980 + 981 + cmd_frame->desc_word[0] = cpu_to_le16(RSI_WIFI_MGMT_Q << 12); 982 + cmd_frame->desc_word[1] = cpu_to_le16(RADIO_PARAMS_UPDATE); 983 + cmd_frame->desc_word[3] = cpu_to_le16(BIT(0)); 984 + 985 + cmd_frame->desc_word[3] |= cpu_to_le16(common->tx_power << 8); 986 + 987 + skb_put(skb, FRAME_DESC_SZ); 988 + 989 + return rsi_send_internal_mgmt_frame(common, skb); 990 + } 991 + 992 + /** 956 993 * rsi_compare() - This function is used to compare two integers 957 994 * @a: pointer to the first integer 958 995 * @b: pointer to the second integer
+2
drivers/net/wireless/rsi/rsi_main.h
··· 204 204 struct cqm_info cqm_info; 205 205 206 206 bool hw_data_qs_blocked; 207 + 208 + int tx_power; 207 209 }; 208 210 209 211 struct rsi_hw {
+3 -1
drivers/net/wireless/rsi/rsi_mgmt.h
··· 200 200 BG_SCAN_PARAMS, 201 201 BG_SCAN_PROBE_REQ, 202 202 CW_MODE_REQ, 203 - PER_CMD_PKT 203 + PER_CMD_PKT, 204 + RADIO_PARAMS_UPDATE = 0x29 204 205 }; 205 206 206 207 struct rsi_mac_frame { ··· 325 324 int rsi_send_data_pkt(struct rsi_common *common, struct sk_buff *skb); 326 325 int rsi_band_check(struct rsi_common *common); 327 326 int rsi_send_rx_filter_frame(struct rsi_common *common, u16 rx_filter_word); 327 + int rsi_send_radio_params_update(struct rsi_common *common); 328 328 #endif