2016-06-14 17:45:14

by Ashok Raj Nagarajan

[permalink] [raw]
Subject: [PATCH 2/2] mac80211: store tx power value from user to station

This patch introduce a new driver callback drv_sta_set_txpwr. This API will
copy the transmit power value passed from user space and call the driver
callback to set the tx power for the station.

Signed-off-by: Ashok Raj Nagarajan <[email protected]>
---
include/net/mac80211.h | 6 ++++++
net/mac80211/cfg.c | 7 +++++++
net/mac80211/driver-ops.c | 21 +++++++++++++++++++++
net/mac80211/driver-ops.h | 5 +++++
net/mac80211/trace.h | 27 +++++++++++++++++++++++++++
5 files changed, 66 insertions(+)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index be30b05..70c02d7 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1755,6 +1755,8 @@ struct ieee80211_sta_rates {
* This is defined by the spec (IEEE 802.11-2012 section 8.3.2.2 NOTE 2).
* @support_p2p_ps: indicates whether the STA supports P2P PS mechanism or not.
* @max_rc_amsdu_len: Maximum A-MSDU size in bytes recommended by rate control.
+ * @txpwr: indicates the tx power, in dBm, to be used when sending data frames
+ * to the STA. Value of 0 means, automatic (default) tx power.
* @txq: per-TID data TX queues (if driver uses the TXQ abstraction)
*/
struct ieee80211_sta {
@@ -1777,6 +1779,7 @@ struct ieee80211_sta {
u16 max_amsdu_len;
bool support_p2p_ps;
u16 max_rc_amsdu_len;
+ u8 txpwr;

struct ieee80211_txq *txq[IEEE80211_NUM_TIDS];

@@ -3484,6 +3487,9 @@ struct ieee80211_ops {
#endif
void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
enum sta_notify_cmd, struct ieee80211_sta *sta);
+ int (*sta_set_txpwr)(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta);
int (*sta_state)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct ieee80211_sta *sta,
enum ieee80211_sta_state old_state,
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 0c12e40..d439854 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1181,6 +1181,13 @@ static int sta_apply_parameters(struct ieee80211_local *local,
if (params->listen_interval >= 0)
sta->listen_interval = params->listen_interval;

+ if (params->txpwr >= 0) {
+ sta->sta.txpwr = MBM_TO_DBM(params->txpwr);
+ ret = drv_sta_set_txpwr(local, sdata, sta);
+ if (ret)
+ return ret;
+ }
+
if (params->supported_rates) {
ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef,
sband, params->supported_rates,
diff --git a/net/mac80211/driver-ops.c b/net/mac80211/driver-ops.c
index c258f10..638480c 100644
--- a/net/mac80211/driver-ops.c
+++ b/net/mac80211/driver-ops.c
@@ -138,6 +138,27 @@ int drv_sta_state(struct ieee80211_local *local,
return ret;
}

+__must_check
+int drv_sta_set_txpwr(struct ieee80211_local *local,
+ struct ieee80211_sub_if_data *sdata,
+ struct sta_info *sta)
+{
+ int ret = -EOPNOTSUPP;
+
+ might_sleep();
+
+ sdata = get_bss_sdata(sdata);
+ if (!check_sdata_in_driver(sdata))
+ return -EIO;
+
+ trace_drv_sta_set_txpwr(local, sdata, &sta->sta);
+ if (local->ops->sta_set_txpwr)
+ ret = local->ops->sta_set_txpwr(&local->hw, &sdata->vif,
+ &sta->sta);
+ trace_drv_return_int(local, ret);
+ return ret;
+}
+
void drv_sta_rc_update(struct ieee80211_local *local,
struct ieee80211_sub_if_data *sdata,
struct ieee80211_sta *sta, u32 changed)
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index 184473c..59b2f28 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -539,6 +539,11 @@ int drv_sta_state(struct ieee80211_local *local,
enum ieee80211_sta_state old_state,
enum ieee80211_sta_state new_state);

+__must_check
+int drv_sta_set_txpwr(struct ieee80211_local *local,
+ struct ieee80211_sub_if_data *sdata,
+ struct sta_info *sta);
+
void drv_sta_rc_update(struct ieee80211_local *local,
struct ieee80211_sub_if_data *sdata,
struct ieee80211_sta *sta, u32 changed);
diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h
index 77e4c53..78c37e9 100644
--- a/net/mac80211/trace.h
+++ b/net/mac80211/trace.h
@@ -823,6 +823,33 @@ TRACE_EVENT(drv_sta_state,
)
);

+TRACE_EVENT(drv_sta_set_txpwr,
+ TP_PROTO(struct ieee80211_local *local,
+ struct ieee80211_sub_if_data *sdata,
+ struct ieee80211_sta *sta),
+
+ TP_ARGS(local, sdata, sta),
+
+ TP_STRUCT__entry(
+ LOCAL_ENTRY
+ VIF_ENTRY
+ STA_ENTRY
+ __field(u8, txpwr)
+ ),
+
+ TP_fast_assign(
+ LOCAL_ASSIGN;
+ VIF_ASSIGN;
+ STA_ASSIGN;
+ __entry->txpwr = sta->txpwr;
+ ),
+
+ TP_printk(
+ LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT " txpwr: %d",
+ LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, __entry->txpwr
+ )
+);
+
TRACE_EVENT(drv_sta_rc_update,
TP_PROTO(struct ieee80211_local *local,
struct ieee80211_sub_if_data *sdata,
--
1.9.1



2016-06-14 18:50:36

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 2/2] mac80211: store tx power value from user to station

Hi,

[auto build test WARNING on mac80211/master]
[also build test WARNING on v4.7-rc3]
[cannot apply to mac80211-next/master next-20160614]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Ashok-Raj-Nagarajan/cfg80211-Add-support-to-set-tx-power-for-a-station-associated/20160615-014826
base: https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211.git master
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'
>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'
>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'
>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'
>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'
>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'
>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'
>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'
>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'
>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'
>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'
>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'
>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'
>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'
>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'
>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'
>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'
>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'
>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'
>> include/net/mac80211.h:3640: warning: No description found for parameter 'sta_set_txpwr'

vim +/sta_set_txpwr +3640 include/net/mac80211.h

a7a6bdd0 Arik Nemtsov 2014-11-09 3624
a7a6bdd0 Arik Nemtsov 2014-11-09 3625 int (*tdls_channel_switch)(struct ieee80211_hw *hw,
a7a6bdd0 Arik Nemtsov 2014-11-09 3626 struct ieee80211_vif *vif,
a7a6bdd0 Arik Nemtsov 2014-11-09 3627 struct ieee80211_sta *sta, u8 oper_class,
a7a6bdd0 Arik Nemtsov 2014-11-09 3628 struct cfg80211_chan_def *chandef,
8a4d32f3 Arik Nemtsov 2014-11-09 3629 struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie);
a7a6bdd0 Arik Nemtsov 2014-11-09 3630 void (*tdls_cancel_channel_switch)(struct ieee80211_hw *hw,
a7a6bdd0 Arik Nemtsov 2014-11-09 3631 struct ieee80211_vif *vif,
a7a6bdd0 Arik Nemtsov 2014-11-09 3632 struct ieee80211_sta *sta);
8a4d32f3 Arik Nemtsov 2014-11-09 3633 void (*tdls_recv_channel_switch)(struct ieee80211_hw *hw,
8a4d32f3 Arik Nemtsov 2014-11-09 3634 struct ieee80211_vif *vif,
8a4d32f3 Arik Nemtsov 2014-11-09 3635 struct ieee80211_tdls_ch_sw_params *params);
ba8c3d6f Felix Fietkau 2015-03-27 3636
ba8c3d6f Felix Fietkau 2015-03-27 3637 void (*wake_tx_queue)(struct ieee80211_hw *hw,
ba8c3d6f Felix Fietkau 2015-03-27 3638 struct ieee80211_txq *txq);
f59374eb Sara Sharon 2016-03-02 3639 void (*sync_rx_queues)(struct ieee80211_hw *hw);
f0706e82 Jiri Benc 2007-05-05 @3640 };
f0706e82 Jiri Benc 2007-05-05 3641
75a5f0cc Johannes Berg 2007-09-18 3642 /**
ad28757e Ben Greear 2014-10-22 3643 * ieee80211_alloc_hw_nm - Allocate a new hardware device
ad28757e Ben Greear 2014-10-22 3644 *
ad28757e Ben Greear 2014-10-22 3645 * This must be called once for each hardware device. The returned pointer
ad28757e Ben Greear 2014-10-22 3646 * must be used to refer to this device when calling other functions.
ad28757e Ben Greear 2014-10-22 3647 * mac80211 allocates a private data area for the driver pointed to by
ad28757e Ben Greear 2014-10-22 3648 * @priv in &struct ieee80211_hw, the size of this area is given as

:::::: The code at line 3640 was first introduced by commit
:::::: f0706e828e96d0fa4e80c0d25aa98523f6d589a0 [MAC80211]: Add mac80211 wireless stack.

:::::: TO: Jiri Benc <[email protected]>
:::::: CC: David S. Miller <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (4.73 kB)
.config.gz (6.19 kB)
Download all attachments