lkml.org 
[lkml]   [2015]   [Mar]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC] mac80211-hwsim: Pass rate-ctrl flags and tx-power to user-space
Date
From: Ben Greear <greearb@candelatech.com>

The flags field allows user-space to properly decode what the
rate->idx really means. The tx-power field is useful as well,
in case user-space is interested in doing something clever with
path-loss calculations.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
drivers/net/wireless/mac80211_hwsim.c | 21 ++++++++++++++++++++-
drivers/net/wireless/mac80211_hwsim.h | 8 ++++++++
2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 6603d08..300826e 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -504,6 +504,9 @@ static const struct nla_policy hwsim_genl_policy[HWSIM_ATTR_MAX + 1] = {
[HWSIM_ATTR_REG_CUSTOM_REG] = { .type = NLA_U32 },
[HWSIM_ATTR_REG_STRICT_REG] = { .type = NLA_FLAG },
[HWSIM_ATTR_SUPPORT_P2P_DEVICE] = { .type = NLA_FLAG },
+ [HWSIM_ATTR_TX_INFO2] = { .type = NLA_UNSPEC,
+ .len = IEEE80211_TX_MAX_RATES *
+ sizeof(struct hwsim_tx_rate2)},
};

static void mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
@@ -909,6 +912,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
unsigned int hwsim_flags = 0;
int i;
struct hwsim_tx_rate tx_attempts[IEEE80211_TX_MAX_RATES];
+ struct hwsim_tx_rate2 tx_attempts2[IEEE80211_TX_MAX_RATES];

if (data->ps != PS_DISABLED)
hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
@@ -960,6 +964,8 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
tx_attempts[i].idx = info->status.rates[i].idx;
tx_attempts[i].count = info->status.rates[i].count;
+ tx_attempts2[i].rc_flags = info->status.rates[i].flags;
+ tx_attempts2[i].power_level = data->power_level;
}

if (nla_put(skb, HWSIM_ATTR_TX_INFO,
@@ -967,6 +973,11 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
tx_attempts))
goto nla_put_failure;

+ if (nla_put(skb, HWSIM_ATTR_TX_INFO2,
+ sizeof(struct hwsim_tx_rate2)*IEEE80211_TX_MAX_RATES,
+ tx_attempts2))
+ goto nla_put_failure;
+
/* We create a cookie to identify this skb */
if (nla_put_u64(skb, HWSIM_ATTR_COOKIE, (unsigned long) my_skb))
goto nla_put_failure;
@@ -2395,6 +2406,7 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2,
struct mac80211_hwsim_data *data2;
struct ieee80211_tx_info *txi;
struct hwsim_tx_rate *tx_attempts;
+ struct hwsim_tx_rate2 *tx_attempts2;
unsigned long ret_skb_ptr;
struct sk_buff *skb, *tmp;
const u8 *src;
@@ -2438,6 +2450,12 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2,
tx_attempts = (struct hwsim_tx_rate *)nla_data(
info->attrs[HWSIM_ATTR_TX_INFO]);

+ if (info->attrs[HWSIM_ATTR_TX_INFO2])
+ tx_attempts2 = (struct hwsim_tx_rate2 *)nla_data(
+ info->attrs[HWSIM_ATTR_TX_INFO2]);
+ else
+ tx_attempts2 = NULL;
+
/* now send back TX status */
txi = IEEE80211_SKB_CB(skb);

@@ -2446,7 +2464,8 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2,
for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
txi->status.rates[i].idx = tx_attempts[i].idx;
txi->status.rates[i].count = tx_attempts[i].count;
- /*txi->status.rates[i].flags = 0;*/
+ if (tx_attempts2)
+ txi->status.rates[i].flags = tx_attempts2[i].rc_flags;
}

txi->status.ack_signal = nla_get_u32(info->attrs[HWSIM_ATTR_SIGNAL]);
diff --git a/drivers/net/wireless/mac80211_hwsim.h b/drivers/net/wireless/mac80211_hwsim.h
index 6ca9fd5..d0fee89 100644
--- a/drivers/net/wireless/mac80211_hwsim.h
+++ b/drivers/net/wireless/mac80211_hwsim.h
@@ -121,6 +121,7 @@ enum {
* @HWSIM_ATTR_RADIO_NAME: Name of radio, e.g. phy666
* @HWSIM_ATTR_NO_VIF: Do not create vif (wlanX) when creating radio.
* @HWSIM_ATTR_FREQ: Frequency at which packet is transmitted or received.
+ * @HWSIM_ATTR_TX_INFO2: hwsim_tx_rate2 array
* @__HWSIM_ATTR_MAX: enum limit
*/

@@ -146,6 +147,7 @@ enum {
HWSIM_ATTR_RADIO_NAME,
HWSIM_ATTR_NO_VIF,
HWSIM_ATTR_FREQ,
+ HWSIM_ATTR_TX_INFO2,
__HWSIM_ATTR_MAX,
};
#define HWSIM_ATTR_MAX (__HWSIM_ATTR_MAX - 1)
@@ -168,4 +170,10 @@ struct hwsim_tx_rate {
u8 count;
} __packed;

+/* Auxilary info to allow user-space to better understand the rate */
+struct hwsim_tx_rate2 {
+ u16 rc_flags; /* rate-ctrl flags (see mac80211_rate_control_flags) */
+ s16 power_level;
+} __packed;
+
#endif /* __MAC80211_HWSIM_H */
--
1.7.11.7


\
 
 \ /
  Last update: 2015-03-12 19:21    [W:0.037 / U:0.392 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site