Skip to contentSkip to conversation

mac80211: add support to set_coalesce

PATCH In review Olav Haugan 2 participants 7 messages Oct 24, 2015 – Nov 23, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mac80211: add support to set_coalesce

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

---
 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(+)
include/net/mac80211.h +4 -0
index bfc5694..8bd7ccb 100644
@@ -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);
 };
 
 /**
net/mac80211/cfg.c +9 -0
index 7a77a14..affd8ab 100644
@@ -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,
 };
net/mac80211/driver-ops.h +12 -0
index 02d9133..49856e1 100644
@@ -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 */
net/mac80211/trace.h +5 -0
index 6f14591..ff1173b 100644
@@ -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.
  */
Signature · 1 line
2.6.1
#1 lore raw

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.

---
 drivers/net/wireless/ath/ath9k/init.c | 19 +++++++++++++++++++
 drivers/net/wireless/ath/ath9k/main.c | 19 +++++++++++++++++++
 2 files changed, 38 insertions(+)
drivers/net/wireless/ath/ath9k/init.c +19 -0
index 57f95f2..10637f5 100644
@@ -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
drivers/net/wireless/ath/ath9k/main.c +19 -0
index c27143b..7595d5d 100644
@@ -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,
Signature · 1 line
2.6.1
maintainer
#5 lore raw
In reply to Olav Haugan

net/mac80211/driver-ops.h static inline void drv_wake_tx_queue(struct ieee80211_local *local, · line 1361

Quoted 13 lines

+++ b/net/mac80211/driver-ops.h

net/mac80211/driver-ops.h +2 -0
@@ -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)

net/mac80211/driver-ops.h +2 -0
+{
+	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

maintainer
#2 lore raw

Re: [PATCH 2/2] ath9k: implement set_coalesce callback

In reply to Olav Haugan
Quoted 4 lines · Olav Haugan

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

#6 lore raw
In reply to Johannes Berg
Quoted 7 lines · Johannes Berg
Quoted 7 lines

+++ b/net/mac80211/driver-ops.h

net/mac80211/driver-ops.h +0 -0
@@ -1355,4 +1355,16 @@ static inline void drv_wake_tx_queue(struct 
 ieee80211_local *local,
 	local->ops->wake_tx_queue(&local->hw, &txq->txq);
 }
 
Quoted 9 lines

net/mac80211/driver-ops.h static inline void drv_wake_tx_queue(struct ieee80211_local *local, · line 1361

Quoted 6 lines
(quoted diff) +2 -0
+static inline int drv_set_coalesce(struct ieee80211_local *local,
+				   struct cfg80211_coalesce 

*coalesce)

net/mac80211/driver-ops.h +2 -0
+{
+	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

Signature · 4 lines
.Olav

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

Re: [PATCH 2/2] ath9k: implement set_coalesce callback

In reply to Johannes Berg
Quoted 9 lines · Johannes Berg
Quoted 4 lines · Olav Haugan

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.

Signature · 4 lines
.Olav

The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
maintainer
#4 lore raw

Re: [PATCH 2/2] ath9k: implement set_coalesce callback

Quoted 7 lines · Olav Haugan
Quoted 6 lines · Johannes Berg
Quoted 5 lines · Olav Haugan

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.

Quoted 8 lines
Quoted 5 lines

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