2015-10-24 18:50:59

by Olav Haugan

[permalink] [raw]
Subject: [PATCH 1/2] mac80211: add support to set_coalesce

Add ops in mac80211 and corresponding driver calls.
Add trace event for set_coalesce.

Signed-off-by: Olav Haugan <[email protected]>
---
include/net/mac80211.h | 4 ++++
net/mac80211/cfg.c | 9 +++++++++
net/mac80211/driver-ops.h | 12 ++++++++++++
net/mac80211/trace.h | 5 +++++
4 files changed, 30 insertions(+)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index bfc5694..8bd7ccb 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -3232,6 +3232,8 @@ enum ieee80211_reconfig_type {
* the function call.
*
* @wake_tx_queue: Called when new packets have been added to the queue.
+ *
+ * @set_coalesce: Set coalesce parameters.
*/
struct ieee80211_ops {
void (*tx)(struct ieee80211_hw *hw,
@@ -3467,6 +3469,8 @@ struct ieee80211_ops {

void (*wake_tx_queue)(struct ieee80211_hw *hw,
struct ieee80211_txq *txq);
+ int (*set_coalesce)(struct ieee80211_hw *hw,
+ struct cfg80211_coalesce *coalesce);
};

/**
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 7a77a14..affd8ab 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3810,6 +3810,14 @@ static int ieee80211_del_tx_ts(struct wiphy *wiphy, struct net_device *dev,
return -ENOENT;
}

+static int ieee80211_set_coalesce(struct wiphy *wiphy,
+ struct cfg80211_coalesce *coalesce)
+{
+ struct ieee80211_local *local = wiphy_priv(wiphy);
+
+ return drv_set_coalesce(local, coalesce);
+}
+
const struct cfg80211_ops mac80211_config_ops = {
.add_virtual_intf = ieee80211_add_iface,
.del_virtual_intf = ieee80211_del_iface,
@@ -3894,4 +3902,5 @@ const struct cfg80211_ops mac80211_config_ops = {
.set_ap_chanwidth = ieee80211_set_ap_chanwidth,
.add_tx_ts = ieee80211_add_tx_ts,
.del_tx_ts = ieee80211_del_tx_ts,
+ .set_coalesce = ieee80211_set_coalesce,
};
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index 02d9133..49856e1 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -1355,4 +1355,16 @@ static inline void drv_wake_tx_queue(struct ieee80211_local *local,
local->ops->wake_tx_queue(&local->hw, &txq->txq);
}

+static inline int drv_set_coalesce(struct ieee80211_local *local,
+ struct cfg80211_coalesce *coalesce)
+{
+ u32 ret = 0;
+
+ trace_drv_set_coalesce(local);
+ if (local->ops->set_coalesce)
+ ret = local->ops->set_coalesce(&local->hw, coalesce);
+ trace_drv_return_u32(local, ret);
+ return ret;
+}
+
#endif /* __MAC80211_DRIVER_OPS */
diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h
index 6f14591..ff1173b 100644
--- a/net/mac80211/trace.h
+++ b/net/mac80211/trace.h
@@ -1655,6 +1655,11 @@ TRACE_EVENT(drv_get_expected_throughput,
)
);

+DEFINE_EVENT(local_only_evt, drv_set_coalesce,
+ TP_PROTO(struct ieee80211_local *local),
+ TP_ARGS(local)
+);
+
/*
* Tracing for API calls that drivers call.
*/
--
2.6.1



2015-10-24 18:51:04

by Olav Haugan

[permalink] [raw]
Subject: [PATCH 2/2] ath9k: implement set_coalesce callback

implement set_coalesce ieee80211_ops callback. Add default
wiphy_coalesce_support rules for 9k. These rules are not being used by 9k
since 9k can just toggle coalesce as on/off.

Signed-off-by: Olav Haugan <[email protected]>
---
drivers/net/wireless/ath/ath9k/init.c | 19 +++++++++++++++++++
drivers/net/wireless/ath/ath9k/main.c | 19 +++++++++++++++++++
2 files changed, 38 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 57f95f2..10637f5 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -86,6 +86,24 @@ static const struct ieee80211_tpt_blink ath9k_tpt_blink[] = {
};
#endif

+/* 9k coalesce is binary (on/off) the below rules are
+ * not being used. Only there to give default values to
+ * wiphy_coalesce_support struct fields
+ */
+#define ATH9K_COALESCE_MAX_RULES 1
+#define ATH9K_COALESCE_MAX_FILTERS 1
+#define ATH9K_MAX_COALESCING_DELAY 1 /* in msecs */
+#define ATH9K_MAX_PATTERN_LEN 1
+#define ATH9K_MAX_OFFSET_LEN 1
+static const struct wiphy_coalesce_support ath9k_coalesce_support = {
+ .n_rules = ATH9K_COALESCE_MAX_RULES,
+ .max_delay = ATH9K_MAX_COALESCING_DELAY,
+ .n_patterns = ATH9K_COALESCE_MAX_FILTERS,
+ .pattern_min_len = 1,
+ .pattern_max_len = ATH9K_MAX_PATTERN_LEN,
+ .max_pkt_offset = ATH9K_MAX_OFFSET_LEN,
+};
+
static void ath9k_deinit_softc(struct ath_softc *sc);

static void ath9k_op_ps_wakeup(struct ath_common *common)
@@ -898,6 +916,7 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
&common->sbands[IEEE80211_BAND_5GHZ];

+ hw->wiphy->coalesce = &ath9k_coalesce_support;
#ifdef CONFIG_ATH9K_CHANNEL_CONTEXT
ath9k_set_mcc_capab(sc, hw);
#endif
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index c27143b..7595d5d 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -2611,6 +2611,24 @@ static int ath9k_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
return 0;
}

+/* ath9k coalesce support */
+static int ath9k_set_coalesce(struct ieee80211_hw *hw,
+ struct cfg80211_coalesce *coalesce)
+{
+ struct ath_softc *sc = hw->priv;
+ struct ath_hw *ah = sc->sc_ah;
+
+ if (!coalesce) {
+ ah->config.rx_intr_mitigation = false;
+ ath9k_hw_set_interrupts(ah);
+ } else {
+ ah->config.rx_intr_mitigation = true;
+ ath9k_hw_set_interrupts(ah);
+ }
+
+ return 0;
+}
+
struct ieee80211_ops ath9k_ops = {
.tx = ath9k_tx,
.start = ath9k_start,
@@ -2639,6 +2657,7 @@ struct ieee80211_ops ath9k_ops = {
.get_stats = ath9k_get_stats,
.set_antenna = ath9k_set_antenna,
.get_antenna = ath9k_get_antenna,
+ .set_coalesce = ath9k_set_coalesce,

#ifdef CONFIG_ATH9K_WOW
.suspend = ath9k_suspend,
--
2.6.1


2015-10-30 10:00:54

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 2/2] ath9k: implement set_coalesce callback

On Sat, 2015-10-24 at 11:50 -0700, Olav Haugan wrote:
> implement set_coalesce ieee80211_ops callback. Add default
> wiphy_coalesce_support rules for 9k. These rules are not being used
> by 9k since 9k can just toggle coalesce as on/off.
>
This seems extremely strange to me - like you're trying to abuse
set_coalesce, intended for coalescing certain classes of low-importance
packets, for a completely different purpose (interrupt coalescing)?

johannes

2015-10-30 09:59:52

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 1/2] mac80211: add support to set_coalesce


> +++ b/net/mac80211/driver-ops.h
> @@ -1355,4 +1355,16 @@ static inline void drv_wake_tx_queue(struct
> ieee80211_local *local,
> local->ops->wake_tx_queue(&local->hw, &txq->txq);
> }
>
> +static inline int drv_set_coalesce(struct ieee80211_local *local,
> + struct cfg80211_coalesce
> *coalesce)
> +{
> + u32 ret = 0;
>
This doesn't seem right - now you're accepting any call even if it's
not really done by the driver?

johannes


2015-11-23 08:52:12

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 2/2] ath9k: implement set_coalesce callback

On Sun, 2015-11-22 at 20:12 -0800, Olav Haugan wrote:
> On 15-10-30 11:00:51, Johannes Berg wrote:
> > On Sat, 2015-10-24 at 11:50 -0700, Olav Haugan wrote:
> > > implement set_coalesce ieee80211_ops callback. Add default
> > > wiphy_coalesce_support rules for 9k. These rules are not being
> > > used
> > > by 9k since 9k can just toggle coalesce as on/off.
> > >
> > This seems extremely strange to me - like you're trying to abuse
> > set_coalesce, intended for coalescing certain classes of low-
> > importance
> > packets, for a completely different purpose (interrupt coalescing)?
> >
> Hmm, yes. We misunderstood how this API is used. Do you have any
> suggestion for how to accomplish what we are trying to do? We can't
> just add a new public user space API for this functionality.

ethtool usually has interrupt coalescing parameters.

johannes

2015-11-23 04:12:51

by Olav Haugan

[permalink] [raw]
Subject: Re: [PATCH 2/2] ath9k: implement set_coalesce callback

On 15-10-30 11:00:51, Johannes Berg wrote:
> On Sat, 2015-10-24 at 11:50 -0700, Olav Haugan wrote:
> > implement set_coalesce ieee80211_ops callback. Add default
> > wiphy_coalesce_support rules for 9k. These rules are not being used
> > by 9k since 9k can just toggle coalesce as on/off.
> >
> This seems extremely strange to me - like you're trying to abuse
> set_coalesce, intended for coalescing certain classes of low-importance
> packets, for a completely different purpose (interrupt coalescing)?
>
Hmm, yes. We misunderstood how this API is used. Do you have any
suggestion for how to accomplish what we are trying to do? We can't just
add a new public user space API for this functionality.

--
.Olav

The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

2015-11-23 04:02:58

by Olav Haugan

[permalink] [raw]
Subject: Re: [PATCH 1/2] mac80211: add support to set_coalesce

On 15-10-30 10:59:41, Johannes Berg wrote:
>
> > +++ b/net/mac80211/driver-ops.h
> > @@ -1355,4 +1355,16 @@ static inline void drv_wake_tx_queue(struct
> > ieee80211_local *local,
> > local->ops->wake_tx_queue(&local->hw, &txq->txq);
> > }
> >
> > +static inline int drv_set_coalesce(struct ieee80211_local *local,
> > + struct cfg80211_coalesce
> > *coalesce)
> > +{
> > + u32 ret = 0;
> >
> This doesn't seem right - now you're accepting any call even if it's
> not really done by the driver?
>

I assume you mean we need the following check:

if (!local->ops->set_coalesce)
return -EOPNOTSUPP

--
.Olav

The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project