Skip to contentSkip to conversation

cfg80211/nl80211: rename packet pattern related structures and enums

PATCH In review Bing Zhao 3 participants 5 messages Jun 26, 2013

Subsystems (4)
lore
Share & tools
lore

Bing Zhao

author
#0 lore raw

PATCH v4 1/2 cfg80211/nl80211: rename packet pattern related structures and enums

From: Amitkumar Karwar <[email protected]>

Currently packet patterns and it's enum/structures are used only for WoWLAN feature. As we intend to reuse them for new feature packet coalesce, they are renamed in this patch.

Older names are kept for backward compatibility purpose.

---
v2: more details about the renames in commit log (Luis R. Rodriguez)
don't break the API with existing applications (Johannes Berg)
v3: __NL80211_PKTPAT_INVALID (Johannes Berg)
v4: similar to wowlan, take coalesce support information out of
wiphy structure so that we don't need to allocate the space for devices which don't advertise the feature. (Johannes Berg)

 drivers/net/wireless/ath/ath9k/main.c   |  2 +-
 drivers/net/wireless/mwifiex/cfg80211.c |  3 +--
 drivers/net/wireless/ti/wlcore/main.c   | 10 ++++----
 include/net/cfg80211.h                  |  6 ++---
 include/uapi/linux/nl80211.h            | 45 ++++++++++++++++++++-------------
 net/wireless/nl80211.c                  | 34 ++++++++++++-------------
 6 files changed, 53 insertions(+), 47 deletions(-)
drivers/net/wireless/ath/ath9k/main.c +1 -1
index cc5a98b..d1ce3da 100644
@@ -2098,7 +2098,7 @@ static void ath9k_wow_add_pattern(struct ath_softc *sc,
 {
 	struct ath_hw *ah = sc->sc_ah;
 	struct ath9k_wow_pattern *wow_pattern = NULL;
-	struct cfg80211_wowlan_trig_pkt_pattern *patterns = wowlan->patterns;
+	struct cfg80211_pkt_pattern *patterns = wowlan->patterns;
 	int mask_len;
 	s8 i = 0;
 
drivers/net/wireless/mwifiex/cfg80211.c +1 -2
index 856aea2..aa7e66f 100644
@@ -2295,8 +2295,7 @@ EXPORT_SYMBOL_GPL(mwifiex_del_virtual_intf);
 
 #ifdef CONFIG_PM
 static bool
-mwifiex_is_pattern_supported(struct cfg80211_wowlan_trig_pkt_pattern *pat,
-			     s8 *byte_seq)
+mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern *pat, s8 *byte_seq)
 {
 	int j, k, valid_byte_cnt = 0;
 	bool dont_care_byte = false;
drivers/net/wireless/ti/wlcore/main.c +5 -5
index 796928b..d89d58a 100644
@@ -1328,7 +1328,7 @@ static struct sk_buff *wl12xx_alloc_dummy_packet(struct wl1271 *wl)
 
 #ifdef CONFIG_PM
 static int
-wl1271_validate_wowlan_pattern(struct cfg80211_wowlan_trig_pkt_pattern *p)
+wl1271_validate_wowlan_pattern(struct cfg80211_pkt_pattern *p)
 {
 	int num_fields = 0, in_field = 0, fields_size = 0;
 	int i, pattern_len = 0;
@@ -1471,9 +1471,9 @@ void wl1271_rx_filter_flatten_fields(struct wl12xx_rx_filter *filter,
  * Allocates an RX filter returned through f
  * which needs to be freed using rx_filter_free()
  */
-static int wl1271_convert_wowlan_pattern_to_rx_filter(
-	struct cfg80211_wowlan_trig_pkt_pattern *p,
-	struct wl12xx_rx_filter **f)
+static int
+wl1271_convert_wowlan_pattern_to_rx_filter(struct cfg80211_pkt_pattern *p,
+					   struct wl12xx_rx_filter **f)
 {
 	int i, j, ret = 0;
 	struct wl12xx_rx_filter *filter;
@@ -1575,7 +1575,7 @@ static int wl1271_configure_wowlan(struct wl1271 *wl,
 
 	/* Translate WoWLAN patterns into filters */
 	for (i = 0; i < wow->n_patterns; i++) {
-		struct cfg80211_wowlan_trig_pkt_pattern *p;
+		struct cfg80211_pkt_pattern *p;
 		struct wl12xx_rx_filter *filter = NULL;
 
 		p = &wow->patterns[i];
include/net/cfg80211.h +3 -3
index 7b0730a..207b079 100644
@@ -1698,7 +1698,7 @@ struct cfg80211_pmksa {
 };
 
 /**
- * struct cfg80211_wowlan_trig_pkt_pattern - packet pattern
+ * struct cfg80211_pkt_pattern - packet pattern
  * @mask: bitmask where to match pattern and where to ignore bytes,
  *	one bit per byte, in same format as nl80211
  * @pattern: bytes to match where bitmask is 1
@@ -1708,7 +1708,7 @@ struct cfg80211_pmksa {
  * Internal note: @mask and @pattern are allocated in one chunk of
  * memory, free @mask only!
  */
-struct cfg80211_wowlan_trig_pkt_pattern {
+struct cfg80211_pkt_pattern {
 	u8 *mask, *pattern;
 	int pattern_len;
 	int pkt_offset;
@@ -1770,7 +1770,7 @@ struct cfg80211_wowlan {
 	bool any, disconnect, magic_pkt, gtk_rekey_failure,
 	     eap_identity_req, four_way_handshake,
 	     rfkill_release;
-	struct cfg80211_wowlan_trig_pkt_pattern *patterns;
+	struct cfg80211_pkt_pattern *patterns;
 	struct cfg80211_wowlan_tcp *tcp;
 	int n_patterns;
 };
include/uapi/linux/nl80211.h +27 -18

88 lines not on this page · raw message

net/wireless/nl80211.c +16 -18
index bed6af5..785761f 100644
@@ -974,7 +974,7 @@ static int nl80211_send_wowlan(struct sk_buff *msg,
 		return -ENOBUFS;
 
 	if (dev->wiphy.wowlan->n_patterns) {
-		struct nl80211_wowlan_pattern_support pat = {
+		struct nl80211_pattern_support pat = {
 			.max_patterns = dev->wiphy.wowlan->n_patterns,
 			.min_pattern_len = dev->wiphy.wowlan->pattern_min_len,
 			.max_pattern_len = dev->wiphy.wowlan->pattern_max_len,
@@ -7591,12 +7591,11 @@ static int nl80211_send_wowlan_patterns(struct sk_buff *msg,
 		if (!nl_pat)
 			return -ENOBUFS;
 		pat_len = wowlan->patterns[i].pattern_len;
-		if (nla_put(msg, NL80211_WOWLAN_PKTPAT_MASK,
-			    DIV_ROUND_UP(pat_len, 8),
+		if (nla_put(msg, NL80211_PKTPAT_MASK, DIV_ROUND_UP(pat_len, 8),
 			    wowlan->patterns[i].mask) ||
-		    nla_put(msg, NL80211_WOWLAN_PKTPAT_PATTERN,
-			    pat_len, wowlan->patterns[i].pattern) ||
-		    nla_put_u32(msg, NL80211_WOWLAN_PKTPAT_OFFSET,
+		    nla_put(msg, NL80211_PKTPAT_PATTERN, pat_len,
+			    wowlan->patterns[i].pattern) ||
+		    nla_put_u32(msg, NL80211_PKTPAT_OFFSET,
 				wowlan->patterns[i].pkt_offset))
 			return -ENOBUFS;
 		nla_nest_end(msg, nl_pat);
@@ -7937,7 +7936,7 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
 		struct nlattr *pat;
 		int n_patterns = 0;
 		int rem, pat_len, mask_len, pkt_offset;
-		struct nlattr *pat_tb[NUM_NL80211_WOWLAN_PKTPAT];
+		struct nlattr *pat_tb[NUM_NL80211_PKTPAT];
 
 		nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
 				    rem)
@@ -7956,26 +7955,25 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
 
 		nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
 				    rem) {
-			nla_parse(pat_tb, MAX_NL80211_WOWLAN_PKTPAT,
-				  nla_data(pat), nla_len(pat), NULL);
+			nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat),
+				  nla_len(pat), NULL);
 			err = -EINVAL;
-			if (!pat_tb[NL80211_WOWLAN_PKTPAT_MASK] ||
-			    !pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN])
+			if (!pat_tb[NL80211_PKTPAT_MASK] ||
+			    !pat_tb[NL80211_PKTPAT_PATTERN])
 				goto error;
-			pat_len = nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]);
+			pat_len = nla_len(pat_tb[NL80211_PKTPAT_PATTERN]);
 			mask_len = DIV_ROUND_UP(pat_len, 8);
-			if (nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]) !=
-			    mask_len)
+			if (nla_len(pat_tb[NL80211_PKTPAT_MASK]) != mask_len)
 				goto error;
 			if (pat_len > wowlan->pattern_max_len ||
 			    pat_len < wowlan->pattern_min_len)
 				goto error;
 
-			if (!pat_tb[NL80211_WOWLAN_PKTPAT_OFFSET])
+			if (!pat_tb[NL80211_PKTPAT_OFFSET])
 				pkt_offset = 0;
 			else
 				pkt_offset = nla_get_u32(
-					pat_tb[NL80211_WOWLAN_PKTPAT_OFFSET]);
+					pat_tb[NL80211_PKTPAT_OFFSET]);
 			if (pkt_offset > wowlan->max_pkt_offset)
 				goto error;
 			new_triggers.patterns[i].pkt_offset = pkt_offset;
@@ -7989,11 +7987,11 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
 			new_triggers.patterns[i].pattern =
 				new_triggers.patterns[i].mask + mask_len;
 			memcpy(new_triggers.patterns[i].mask,
-			       nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]),
+			       nla_data(pat_tb[NL80211_PKTPAT_MASK]),
 			       mask_len);
 			new_triggers.patterns[i].pattern_len = pat_len;
 			memcpy(new_triggers.patterns[i].pattern,
-			       nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]),
+			       nla_data(pat_tb[NL80211_PKTPAT_PATTERN]),
 			       pat_len);
 			i++;
 		}
Signature · 1 line
1.8.0
author
#1 lore raw

PATCH v4 2/2 cfg80211/nl80211: Add packet coalesce support

From: Amitkumar Karwar <[email protected]>

In most cases, host that receives IPv4 and IPv6 multicast/broadcast packets does not do anything with these packets. Therefore the reception of these unwanted packets causes unnecessary processing and power consumption.

Packet coalesce feature helps to reduce number of received interrupts to host by buffering these packets in firmware/hardware for some predefined time. Received interrupt will be generated when one of the following events occur.
a) Expiration of hardware timer whose expiration time is set to maximum coalescing delay of matching coalesce rule.
b) Coalescing buffer in hardware reaches it's limit.
c) Packet doesn't match any of the configured coalesce rules.

This patch adds set/get configuration support for packet coalesce. User needs to configure following parameters for creating a coalesce rule.
a) Maximum coalescing delay
b) List of packet patterns which needs to be matched
c) Condition for coalescence. pattern 'match' or 'no match' Multiple such rules can be created.

This feature needs to be advertised during driver initialization. Drivers are supposed to do required firmware/hardware settings based on user configuration.

---
v2: add documentation in nl80211.h and elabiration of "coalesce"
in commit log (Luis R. Rodriguez)
v3: address comments (Johannes Berg):

    use enum variable for 'condition';
    remove new feature flag;
    remove spurious;
    update documentation

v4: similar to wowlan, take coalesce support information out of
wiphy structure so that we don't need to allocate the space for devices which don't advertise the feature. (Johannes Berg) set/clear coalesce rules through configuration file. (Johannes Berg)

 include/net/cfg80211.h       |  51 ++++++++
 include/uapi/linux/nl80211.h |  89 ++++++++++++-
 net/wireless/core.c          |  11 ++
 net/wireless/core.h          |   2 +
 net/wireless/nl80211.c       | 293 +++++++++++++++++++++++++++++++++++++++++++
 net/wireless/nl80211.h       |   2 +
 6 files changed, 446 insertions(+), 2 deletions(-)
include/net/cfg80211.h +51 -0
index 207b079..ad61475 100644
@@ -1776,6 +1776,35 @@ struct cfg80211_wowlan {
 };
 
 /**
+ * struct cfg80211_coalesce_rules - Coalesce rule parameters
+ *
+ * This structure defines coalesce rule for the device.
+ * @delay: maximum coalescing delay in msecs.
+ * @condition: condition for packet coalescence.
+ *	see &enum nl80211_coalesce_condition.
+ * @patterns: array of packet patterns
+ * @n_patterns: number of patterns
+ */
+struct cfg80211_coalesce_rules {
+	int delay;
+	enum nl80211_coalesce_condition condition;
+	struct cfg80211_pkt_pattern *patterns;
+	int n_patterns;
+};
+
+/**
+ * struct cfg80211_coalesce - Packet coalescing settings
+ *
+ * This structure defines coalescing settings.
+ * @rules: array of coalesce rules
+ * @n_rules: number of rules
+ */
+struct cfg80211_coalesce {
+	struct cfg80211_coalesce_rules **rules;
+	int n_rules;
+};
+
+/**
  * struct cfg80211_wowlan_wakeup - wakeup report
  * @disconnect: woke up by getting disconnected
  * @magic_pkt: woke up by receiving magic packet
@@ -2071,6 +2100,7 @@ struct cfg80211_update_ft_ies_params {
  *	driver can take the most appropriate actions.
  * @crit_proto_stop: Indicates critical protocol no longer needs increased link
  *	reliability. This operation can not fail.
+ * @set_coalesce: Set coalesce parameters.
  */
 struct cfg80211_ops {
 	int	(*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -2306,6 +2336,8 @@ struct cfg80211_ops {
 				    u16 duration);
 	void	(*crit_proto_stop)(struct wiphy *wiphy,
 				   struct wireless_dev *wdev);
+	int	(*set_coalesce)(struct wiphy *wiphy,
+				struct cfg80211_coalesce *coalesce);
 };
 
 /*
@@ -2532,6 +2564,23 @@ struct wiphy_wowlan_support {
 };
 
 /**
+ * struct wiphy_coalesce_support - coalesce support data
+ * @n_rules: maximum number of coalesce rules
+ * @n_patterns: number of supported patterns
+ *	(see nl80211.h for the pattern definition)
+ * @pattern_max_len: maximum length of each pattern
+ * @pattern_min_len: minimum length of each pattern
+ * @max_pkt_offset: maximum Rx packet offset
+ */
+struct wiphy_coalesce_support {
+	int n_rules;
+	int n_patterns;
+	int pattern_max_len;
+	int pattern_min_len;
+	int max_pkt_offset;
+};
+
+/**
  * struct wiphy - wireless hardware description
  * @reg_notifier: the driver's regulatory notification callback,
  *	note that if your driver uses wiphy_apply_custom_regulatory()
@@ -2641,6 +2690,7 @@ struct wiphy_wowlan_support {
  *	802.11-2012 8.4.2.29 for the defined fields.
  * @extended_capabilities_mask: mask of the valid values
  * @extended_capabilities_len: length of the extended capabilities
+ * @wiphy_coalesce_support coalesce: coalesce support information
  */
 struct wiphy {
 	/* assign these fields before you register the wiphy */
@@ -2750,6 +2800,7 @@ struct wiphy {
 	const struct iw_handler_def *wext;
 #endif
 
+	const struct wiphy_coalesce_support *coalesce;
 	char priv[0] __aligned(NETDEV_ALIGN);
 };
 
include/uapi/linux/nl80211.h +87 -2

131 lines not on this page · raw message

net/wireless/core.c +11 -0
index 672459b..853f754 100644
@@ -462,6 +462,14 @@ int wiphy_register(struct wiphy *wiphy)
 		return -EINVAL;
 #endif
 
+	if (WARN_ON(wiphy->coalesce &&
+		    (!wiphy->coalesce->n_rules ||
+		     !wiphy->wowlan->n_patterns) &&
+		    (!wiphy->coalesce->pattern_min_len ||
+		     wiphy->coalesce->pattern_min_len >
+			wiphy->coalesce->pattern_max_len)))
+		return -EINVAL;
+
 	if (WARN_ON(wiphy->ap_sme_capa &&
 		    !(wiphy->flags & WIPHY_FLAG_HAVE_AP_SME)))
 		return -EINVAL;
@@ -668,6 +676,9 @@ void wiphy_unregister(struct wiphy *wiphy)
 		rdev_set_wakeup(rdev, false);
 #endif
 	cfg80211_rdev_free_wowlan(rdev);
+
+	cfg80211_rdev_free_coalesce(rdev->coalesce);
+	rdev->coalesce = NULL;
 }
 EXPORT_SYMBOL(wiphy_unregister);
 
net/wireless/core.h +2 -0
index a6b45bf..9ad43c6 100644
@@ -79,6 +79,8 @@ struct cfg80211_registered_device {
 	/* netlink port which started critical protocol (0 means not started) */
 	u32 crit_proto_nlportid;
 
+	struct cfg80211_coalesce *coalesce;
+
 	/* must be last because of the way we do wiphy_priv(),
 	 * and it should at least be aligned to NETDEV_ALIGN */
 	struct wiphy wiphy __aligned(NETDEV_ALIGN);
net/wireless/nl80211.c +293 -0

323 lines not on this page · raw message

net/wireless/nl80211.h +2 -0
index a4073e8..d5ef819 100644
@@ -74,4 +74,6 @@ nl80211_radar_notify(struct cfg80211_registered_device *rdev,
 		     enum nl80211_radar_event event,
 		     struct net_device *netdev, gfp_t gfp);
 
+void cfg80211_rdev_free_coalesce(struct cfg80211_coalesce *coalesce);
+
 #endif /* __NET_WIRELESS_NL80211_H */
Signature · 1 line
1.8.0
maintainer
#2 lore raw

Re: [PATCH v4 2/2] cfg80211/nl80211: Add packet coalesce support

include/net/cfg80211.h struct cfg80211_wowlan { · line 1803

Quoted 9 lines · Bing Zhao
include/net/cfg80211.h +9 -0
+/**
+ * struct cfg80211_coalesce - Packet coalescing settings
+ *
+ * This structure defines coalescing settings.
+ * @rules: array of coalesce rules
+ * @n_rules: number of rules
+ */
+struct cfg80211_coalesce {
+	struct cfg80211_coalesce_rules **rules;

I don't really see why this should be a double pointer? The coalesce_rules struct is small enough that you could just allocate an array of that, no?

Quoted 8 lines

/**
+ * struct wiphy_coalesce_support - coalesce support data
+ * @n_rules: maximum number of coalesce rules
+ * @n_patterns: number of supported patterns
+ * (see nl80211.h for the pattern definition)
+ * @pattern_max_len: maximum length of each pattern
+ * @pattern_min_len: minimum length of each pattern
+ * @max_pkt_offset: maximum Rx packet offset

Should there be any limits on the timer? Will the firmware actually work if I set it to (useless) values like 2^32-1 msecs?

Also -- is n_patterns per rule, or global? It seems global, but in the rules you can have multiple patterns per rule?

include/uapi/linux/nl80211.h line 678

Quoted 11 lines
include/uapi/linux/nl80211.h +4 -0
+/**
  * enum nl80211_commands - supported nl80211 commands
  *
  * @NL80211_CMD_UNSPEC: unspecified command to catch errors
@@ -648,6 +673,10 @@
  * @NL80211_CMD_CRIT_PROTOCOL_STOP: Indicates the connection reliability can
  *	return back to normal.
  *
+ * @NL80211_CMD_GET_COALESCE: Get currently supported coalesce rules.
+ *
+ * @NL80211_CMD_SET_COALESCE: Configure coalesce rules or clear existing rules.

I'd prefer no space between the two :)

include/uapi/linux/nl80211.h enum nl80211_wowlan_tcp_attrs { · line 3368

Quoted 3 lines
include/uapi/linux/nl80211.h +3 -0
+struct nl80211_coalesce_rule_support {
+	__u32 max_rules;
+	struct nl80211_pattern_support pat;

(timing stuff would also go here, I suppose)

Quoted 7 lines
net/wireless/nl80211.c +7 -0
+static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev,
+				       struct nlattr *rule,
+				       struct cfg80211_coalesce_rules *new_rule)
+{
+	int err, i;
+	const struct wiphy_coalesce_support *coalesce = rdev->wiphy.coalesce;
+	struct nlattr *tb[NUM_NL80211_ATTR_COALESCE_RULE], *pat;

net/wireless/nl80211.c static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) · line 8187

Quoted 10 lines
net/wireless/nl80211.c +10 -0
+	int rem, pat_len, mask_len, pkt_offset, n_patterns = 0;
+	struct nlattr *pat_tb[NUM_NL80211_PKTPAT];
+
+	err = nla_parse(tb, NL80211_ATTR_COALESCE_RULE_MAX, nla_data(rule),
+			nla_len(rule), nl80211_coalesce_policy);
+	if (err)
+		return err;
+
+	memset(new_rule, 0, sizeof(*new_rule));
+	new_rule->delay = nla_get_u32(tb[NL80211_ATTR_COALESCE_RULE_DELAY]);

no check that it actually exists?

net/wireless/nl80211.c static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) · line 8189

Quoted 2 lines
net/wireless/nl80211.c +2 -0
+	new_rule->condition =
+		nla_get_u32(tb[NL80211_ATTR_COALESCE_RULE_CONDITION]);

ditto. easy to crash, no?

Quoted 4 lines
net/wireless/nl80211.c +4 -0
+static int nl80211_set_coalesce(struct sk_buff *skb, struct genl_info *info)
+{
+	struct cfg80211_registered_device *rdev = info->user_ptr[0];
+	const struct wiphy_coalesce_support *coalesce = rdev->wiphy.coalesce;

net/wireless/nl80211.c static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) · line 8271

Quoted 10 lines
net/wireless/nl80211.c +10 -0
+	struct cfg80211_coalesce_rules new_rule = {};
+	struct cfg80211_coalesce_rules *nrule;
+	struct cfg80211_coalesce *new_coalesce;
+	int err, rem_rule;
+	struct nlattr *rule;
+
+	if (!rdev->wiphy.coalesce)
+		return -EOPNOTSUPP;
+	if (!rdev->ops->set_coalesce)
+		return -EOPNOTSUPP;

could combine the conditions :)

net/wireless/nl80211.c static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) · line 8282

Quoted 3 lines
net/wireless/nl80211.c +3 -0
+	new_coalesce = kzalloc(sizeof(*new_coalesce), GFP_KERNEL);
+	new_coalesce->rules = kcalloc(coalesce->n_rules,
+					sizeof(void *), GFP_KERNEL);

*kaboom*

net/wireless/nl80211.c static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) · line 8307

Quoted 10 lines
net/wireless/nl80211.c +10 -0
+	cfg80211_rdev_free_coalesce(rdev->coalesce);
+	rdev->coalesce = new_coalesce;
+
+	err = rdev->ops->set_coalesce(&rdev->wiphy, rdev->coalesce);
+	if (err)
+		goto error;
+
+	return 0;
+error:
+	cfg80211_rdev_free_coalesce(new_coalesce);

*kaboom* if it ever fails, and you then do get_coalesce -- should probably assign only after setting the new value successfully?

johannes

#3 lore raw

RE: [PATCH v4 2/2] cfg80211/nl80211: Add packet coalesce support

Hi Johannes,

Thanks for your comments.

Quoted 6 lines

include/net/cfg80211.h struct cfg80211_wowlan { · line 1803

Quoted 2 lines
include/net/cfg80211.h +2 -0
+struct cfg80211_coalesce {
+     struct cfg80211_coalesce_rules **rules;

I don't really see why this should be a double pointer? The coalesce_rules struct is small enough that you could just allocate an array of that, no?

Actually it came from our previous design which used to add one rule per iw command by allocating an array of rule pointers. You are right. We will use normal pointer and allocate an array of rules in updated version.

Quoted 11 lines
Quoted 8 lines

/**
+ * struct wiphy_coalesce_support - coalesce support data
+ * @n_rules: maximum number of coalesce rules
+ * @n_patterns: number of supported patterns
+ * (see nl80211.h for the pattern definition)
+ * @pattern_max_len: maximum length of each pattern
+ * @pattern_min_len: minimum length of each pattern
+ * @max_pkt_offset: maximum Rx packet offset

Should there be any limits on the timer? Will the firmware actually work if I set it to (useless) values like 2^32-1 msecs?

Makes sense. There should be a limit for colaescing delay. We will add new parameter 'max_delay'.

Quoted 2 lines

Also -- is n_patterns per rule, or global? It seems global, but in the rules you can have multiple patterns per rule?

n_patterns is per rule. We will update description of 'n_patterns'.

Quoted 5 lines
Quoted 3 lines

+ * @NL80211_CMD_GET_COALESCE: Get currently supported coalesce rules.
+ *
+ * @NL80211_CMD_SET_COALESCE: Configure coalesce rules or clear existing rules.

I'd prefer no space between the two :)

Sure.

Quoted 5 lines

include/uapi/linux/nl80211.h enum nl80211_wowlan_tcp_attrs { · line 3368

Quoted 3 lines
include/uapi/linux/nl80211.h +3 -0
+struct nl80211_coalesce_rule_support {
+     __u32 max_rules;
+     struct nl80211_pattern_support pat;

(timing stuff would also go here, I suppose)

Yes. The new parameter will be added here.

Quoted 6 lines
Quoted 1 line

+ new_rule->delay = nla_get_u32(tb[NL80211_ATTR_COALESCE_RULE_DELAY]);

no check that it actually exists?

net/wireless/nl80211.c static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) · line 8189

Quoted 2 lines
net/wireless/nl80211.c +2 -0
+     new_rule->condition =
+             nla_get_u32(tb[NL80211_ATTR_COALESCE_RULE_CONDITION]);

ditto. easy to crash, no?

Thanks. We will add checks to see if these attributes are present.

Quoted 6 lines
net/wireless/nl80211.c +4 -0
+     if (!rdev->wiphy.coalesce)
+             return -EOPNOTSUPP;
+     if (!rdev->ops->set_coalesce)
+             return -EOPNOTSUPP;

could combine the conditions :)

Ack.

Quoted 4 lines

net/wireless/nl80211.c static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) · line 8282

Quoted 3 lines
net/wireless/nl80211.c +3 -0
+     new_coalesce = kzalloc(sizeof(*new_coalesce), GFP_KERNEL);
+     new_coalesce->rules = kcalloc(coalesce->n_rules,
+                                     sizeof(void *), GFP_KERNEL);

*kaboom*

Quoted 13 lines

net/wireless/nl80211.c static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) · line 8307

Quoted 10 lines
net/wireless/nl80211.c +10 -0
+     cfg80211_rdev_free_coalesce(rdev->coalesce);
+     rdev->coalesce = new_coalesce;
+
+     err = rdev->ops->set_coalesce(&rdev->wiphy, rdev->coalesce);
+     if (err)
+             goto error;
+
+     return 0;
+error:
+     cfg80211_rdev_free_coalesce(new_coalesce);

*kaboom* if it ever fails, and you then do get_coalesce -- should probably assign only after setting the new value successfully?

Thanks for pointing this out. We will take care of this error path.

Regards,
Amitkumar Karwar

maintainer
#4 lore raw
In reply to Bing Zhao
Quoted 5 lines · Bing Zhao

From: Amitkumar Karwar <[email protected]>

Currently packet patterns and it's enum/structures are used only for WoWLAN feature. As we intend to reuse them for new feature packet coalesce, they are renamed in this patch.

This looks good, applied.

johannes