cfg80211/nl80211: Add packet coalesce support
PATCH v5 1/1 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 documentationv4: 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)
v5: Add new variable 'max_delay' to advertise max coalescing delay
supported by a driver. (Johannes Berg)
Use array of 'struct coalesce_rules' instead of array of coalesce_rules pointers ("**rules" -> "*rule"). (Johannes Berg)
Add NULL checks while doing nla_get_*(). (Johannes Berg) Add one missing memory allocation error check. (Johannes Berg)
include/net/cfg80211.h | 53 ++++++++ include/uapi/linux/nl80211.h | 90 ++++++++++++- net/wireless/core.c | 11 ++ net/wireless/core.h | 2 + net/wireless/nl80211.c | 307 +++++++++++++++++++++++++++++++++++++++++++ net/wireless/nl80211.h | 2 + 6 files changed, 463 insertions(+), 2 deletions(-)
include/net/cfg80211.h +53 -0
@@ -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,25 @@ struct wiphy_wowlan_support { };/** +* struct wiphy_coalesce_support - coalesce support data +* @n_rules: maximum number of coalesce rules +* @max_delay: maximum supported coalescing delay in msecs +* @n_patterns: number of supported patterns in a rule +* (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 max_delay; +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 +2692,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 +2802,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 +88 -2
132 lines not on this page · raw message
net/wireless/core.c +11 -0
@@ -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
@@ -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 +307 -0
337 lines not on this page · raw message
net/wireless/nl80211.h +2 -0
@@ -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
Quoted 24 lines · Bing Zhao
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/hardwarefor 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.
Quoted 3 lines
This feature needs to be advertised during driver initialization. Drivers are supposed to do required
firmware/hardwaresettings based on user configuration.
Applied.
johannes