2011-10-22 13:13:40

by Guy Eilam

[permalink] [raw]
Subject: [PATCH 1/4] nl80211: Add probe response offload attribute

Notify the userspace of the probe response offloading
support by the driver.

Signed-off-by: Guy Eilam <[email protected]>
---
include/linux/nl80211.h | 24 ++++++++++++++++++++++++
include/net/cfg80211.h | 4 ++++
net/wireless/nl80211.c | 12 ++++++++++++
3 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index 9d797f2..a436f74 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -1109,6 +1109,11 @@ enum nl80211_commands {
* %NL80211_CMD_TDLS_MGMT. Otherwise %NL80211_CMD_TDLS_OPER should be
* used for asking the driver to perform a TDLS operation.
*
+ * @NL80211_ATTR_PROBE_RESP_OFFLOAD_SUPPORT: Indicates the support
+ * of probe response offloading by the driver/firmware.
+ * In addition this attribute holds a bitmap of the supported protocols
+ * for offloading using &enum nl80211_probe_resp_offload_support_attr.
+ *
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
*/
@@ -1337,6 +1342,8 @@ enum nl80211_attrs {
NL80211_ATTR_TDLS_SUPPORT,
NL80211_ATTR_TDLS_EXTERNAL_SETUP,

+ NL80211_ATTR_PROBE_RESP_OFFLOAD_SUPPORT,
+
/* add attributes here, update the policy in nl80211.c */

__NL80211_ATTR_AFTER_LAST,
@@ -2648,4 +2655,21 @@ enum nl80211_tdls_operation {
NL80211_TDLS_DISABLE_LINK,
};

+/**
+ * enum nl80211_probe_resp_offload_support_attr - definition of optional
+ * supported protocols for probe response offloading by the driver/firmware
+ * to be used with the %NL80211_ATTR_PROBE_RESP_OFFLOAD_SUPPORT
+ * attribute. Each enum value represents a bit in the bitmap of
+ * supported protocols.
+ *
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS: Support for WPS ver. 1
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2: Support for WPS ver. 2
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P: Support for P2P
+ */
+enum nl80211_probe_resp_offload_support_attr {
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS,
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2,
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P,
+};
+
#endif /* __LINUX_NL80211_H */
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 74f4f85..b5ddd62 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1425,6 +1425,8 @@ struct cfg80211_gtk_rekey_data {
*
* @tdls_mgmt: Transmit a TDLS management frame.
* @tdls_oper: Perform a high-level TDLS operation (e.g. TDLS link setup).
+ *
+ * @get_probe_resp_offload: Get probe response offload support from driver.
*/
struct cfg80211_ops {
int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -1614,6 +1616,8 @@ struct cfg80211_ops {
u16 status_code, const u8 *buf, size_t len);
int (*tdls_oper)(struct wiphy *wiphy, struct net_device *dev,
u8 *peer, enum nl80211_tdls_operation oper);
+ int (*get_probe_resp_offload) (struct wiphy *wiphy,
+ u32 *supp_protocols);
};

/*
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index edf655a..ad90ec4 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -759,6 +759,18 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags,
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX,
dev->wiphy.available_antennas_rx);

+ if (dev->ops->get_probe_resp_offload) {
+ u32 supp_protocols = 0;
+ int res;
+ res = dev->ops->get_probe_resp_offload(&dev->wiphy,
+ &supp_protocols);
+ if (!res) {
+ NLA_PUT_U32(msg,
+ NL80211_ATTR_PROBE_RESP_OFFLOAD_SUPPORT,
+ supp_protocols);
+ }
+ }
+
if ((dev->wiphy.available_antennas_tx ||
dev->wiphy.available_antennas_rx) && dev->ops->get_antenna) {
u32 tx_ant = 0, rx_ant = 0;
--
1.7.4.1



2011-10-22 17:42:21

by Guy Eilam

[permalink] [raw]
Subject: Re: [PATCH 1/4] nl80211: Add probe response offload attribute

On Sat, Oct 22, 2011 at 7:39 PM, Johannes Berg
<[email protected]> wrote:
> On Sat, 2011-10-22 at 19:26 +0200, Guy Eilam wrote:
>
>> >> > +enum nl80211_probe_resp_offload_support_attr {
>> >> > + ? NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS,
>> >> > + ? NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2,
>> >> > + ? NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P,
>> >> > +};
>> >>
>> >> I think doing = 1<<N here would be nicer to use in drivers & userspace.
>> >
>> > Hm, also: should we call this WPS or WSC, and do we need to distinguish
>> > WPS and WPS2? My AP mode patch called it WSC in a different context but
>> > I can change, we just should be consistent.
>> >
>> >> > + * @get_probe_resp_offload: Get probe response offload support from driver.
>> >>
>> >> and this seems unnecessary -- why not just put a u32 value into struct
>> >> wiphy?
>> >
>> > Oh, and probably a regular WIPHY flag that indicates whether the
>> > attribute should be added at all so that it can also be 0 but present
>> > (presence with 0 value indicates something other than not present).
>>
>> When this is not supported a -EOPNOTSUPP should be returned.
>> A 0 return means that it is supported.
>
> Yeah but if you add a wiphy flag and the bits into struct wiphy, then
> you can save the function pointer which seems nicer?

You're absolutely right.
I'll send another version of the patch that will have a flag and
bitmap in the wiphy struct.

>
> johannes
>
>

Guy.

2011-10-22 13:13:44

by Guy Eilam

[permalink] [raw]
Subject: [PATCH 4/4] mac80211: Save probe response data for BSS

Allow setting a probe response template for an interface operating in
AP mode. Low level drivers are notified about changes in the probe
response template and are able to retrieve a copy of the current probe
response. This data can, for example, be uploaded to hardware as a
template.

Signed-off-by: Guy Eilam <[email protected]>
---
include/net/mac80211.h | 15 +++++++++++++++
net/mac80211/cfg.c | 35 +++++++++++++++++++++++++++++++++++
net/mac80211/ieee80211_i.h | 1 +
net/mac80211/iface.c | 6 +++++-
net/mac80211/tx.c | 31 +++++++++++++++++++++++++++++++
net/mac80211/util.c | 3 ++-
6 files changed, 89 insertions(+), 2 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 1c58fd7..050aa32 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -166,6 +166,7 @@ struct ieee80211_low_level_stats {
* that it is only ever disabled for station mode.
* @BSS_CHANGED_IDLE: Idle changed for this BSS/interface.
* @BSS_CHANGED_SSID: SSID changed for this BSS (AP mode)
+ * @BSS_CHANGED_AP_PROBE_RESP: Probe Response changed for this BSS (AP mode)
*/
enum ieee80211_bss_change {
BSS_CHANGED_ASSOC = 1<<0,
@@ -184,6 +185,7 @@ enum ieee80211_bss_change {
BSS_CHANGED_QOS = 1<<13,
BSS_CHANGED_IDLE = 1<<14,
BSS_CHANGED_SSID = 1<<15,
+ BSS_CHANGED_AP_PROBE_RESP = 1<<16,

/* when adding here, make sure to change ieee80211_reconfig */
};
@@ -2662,6 +2664,19 @@ static inline struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
}

/**
+ * ieee80211_proberesp_get - retrieve a Probe Response template
+ * @hw: pointer obtained from ieee80211_alloc_hw().
+ * @vif: &struct ieee80211_vif pointer from the add_interface callback.
+ *
+ * Creates a Probe Response template which can, for example, be uploaded to
+ * hardware. The destination address should be set by the caller.
+ *
+ * Can only be called in AP mode.
+ */
+struct sk_buff *ieee80211_proberesp_get(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif);
+
+/**
* ieee80211_pspoll_get - retrieve a PS Poll template
* @hw: pointer obtained from ieee80211_alloc_hw().
* @vif: &struct ieee80211_vif pointer from the add_interface callback.
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 3cdb4a9..e2ad3da 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1230,6 +1230,34 @@ static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
}
#endif

+static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
+ u8 *resp, size_t resp_len)
+{
+ struct sk_buff *new, *old;
+
+ old = sdata->u.ap.probe_resp;
+
+ if (!resp || !resp_len)
+ return -EINVAL;
+
+ new = dev_alloc_skb(resp_len);
+ if (!new) {
+ printk(KERN_DEBUG "%s: failed to allocate buffer for probe "
+ "response template\n", sdata->name);
+ return -ENOMEM;
+ }
+
+ memcpy(skb_put(new, resp_len), resp, resp_len);
+
+ rcu_assign_pointer(sdata->u.ap.probe_resp, new);
+ synchronize_rcu();
+
+ if (old)
+ dev_kfree_skb(old);
+
+ return 0;
+}
+
static int ieee80211_change_bss(struct wiphy *wiphy,
struct net_device *dev,
struct bss_parameters *params)
@@ -1292,6 +1320,13 @@ static int ieee80211_change_bss(struct wiphy *wiphy,
changed |= BSS_CHANGED_HT;
}

+ if (params->probe_resp_len > 0) {
+ int ret = ieee80211_set_probe_resp(sdata, params->probe_resp,
+ params->probe_resp_len);
+ if (!ret)
+ changed |= BSS_CHANGED_AP_PROBE_RESP;
+ }
+
ieee80211_bss_info_change_notify(sdata, changed);

return 0;
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 9fa5f8a..41f2a9a 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -230,6 +230,7 @@ struct beacon_data {

struct ieee80211_if_ap {
struct beacon_data __rcu *beacon;
+ struct sk_buff __rcu *probe_resp;

struct list_head vlans;

diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index ef741e8..74d6f79 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -450,15 +450,19 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
struct ieee80211_sub_if_data *vlan, *tmpsdata;
struct beacon_data *old_beacon =
rtnl_dereference(sdata->u.ap.beacon);
+ struct sk_buff *old_probe_resp =
+ rtnl_dereference(sdata->u.ap.probe_resp);

/* sdata_running will return false, so this will disable */
ieee80211_bss_info_change_notify(sdata,
BSS_CHANGED_BEACON_ENABLED);

- /* remove beacon */
+ /* remove beacon and probe response */
rcu_assign_pointer(sdata->u.ap.beacon, NULL);
+ rcu_assign_pointer(sdata->u.ap.probe_resp, NULL);
synchronize_rcu();
kfree(old_beacon);
+ kfree(old_probe_resp);

/* down all dependent devices, that is VLANs */
list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans,
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index ad2ee4a..1f077e2 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2414,6 +2414,37 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
}
EXPORT_SYMBOL(ieee80211_beacon_get_tim);

+struct sk_buff *ieee80211_proberesp_get(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif)
+{
+ struct ieee80211_if_ap *ap = NULL;
+ struct sk_buff *presp = NULL, *skb = NULL;
+ struct ieee80211_hdr *hdr;
+ struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
+
+ if (sdata->vif.type != NL80211_IFTYPE_AP)
+ return NULL;
+
+ rcu_read_lock();
+
+ ap = &sdata->u.ap;
+ presp = rcu_dereference(ap->probe_resp);
+ if (!presp)
+ goto out;
+
+ skb = skb_copy(presp, GFP_ATOMIC);
+ if (!skb)
+ goto out;
+
+ hdr = (struct ieee80211_hdr *) skb->data;
+ memset(hdr->addr1, 0, sizeof(hdr->addr1));
+
+out:
+ rcu_read_unlock();
+ return skb;
+}
+EXPORT_SYMBOL(ieee80211_proberesp_get);
+
struct sk_buff *ieee80211_pspoll_get(struct ieee80211_hw *hw,
struct ieee80211_vif *vif)
{
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 7439d26..d6d3ef4 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1085,7 +1085,8 @@ int ieee80211_reconfig(struct ieee80211_local *local)
changed |= BSS_CHANGED_IBSS;
/* fall through */
case NL80211_IFTYPE_AP:
- changed |= BSS_CHANGED_SSID;
+ changed |= BSS_CHANGED_SSID |
+ BSS_CHANGED_AP_PROBE_RESP;
/* fall through */
case NL80211_IFTYPE_MESH_POINT:
changed |= BSS_CHANGED_BEACON |
--
1.7.4.1


2011-10-22 13:13:44

by Guy Eilam

[permalink] [raw]
Subject: [PATCH 3/4] nl80211: Pass probe response data to drivers

Allow usermode to pass probe-response data. This data can be used as a
template probe-response offloading.

Signed-off-by: Guy Eilam <[email protected]>
---
include/linux/nl80211.h | 4 ++++
include/net/cfg80211.h | 4 ++++
net/wireless/nl80211.c | 11 +++++++++++
3 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index a436f74..6369631 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -1114,6 +1114,8 @@ enum nl80211_commands {
* In addition this attribute holds a bitmap of the supported protocols
* for offloading using &enum nl80211_probe_resp_offload_support_attr.
*
+ * @NL80211_ATTR_PROBE_RESP: Probe Response template data
+ *
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
*/
@@ -1344,6 +1346,8 @@ enum nl80211_attrs {

NL80211_ATTR_PROBE_RESP_OFFLOAD_SUPPORT,

+ NL80211_ATTR_PROBE_RESP,
+
/* add attributes here, update the policy in nl80211.c */

__NL80211_ATTR_AFTER_LAST,
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index b5ddd62..eb8b8c5 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -737,6 +737,8 @@ struct mpath_info {
* @ap_isolate: do not forward packets between connected stations
* @ht_opmode: HT Operation mode
* (u16 = opmode, -1 = do not change)
+ * @probe_resp_len: length of probe response template (@probe_resp)
+ * @probe_resp: probe response template (AP mode only)
*/
struct bss_parameters {
int use_cts_prot;
@@ -746,6 +748,8 @@ struct bss_parameters {
u8 basic_rates_len;
int ap_isolate;
int ht_opmode;
+ int probe_resp_len;
+ u8 *probe_resp;
};

/*
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index ad90ec4..aadca02 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -197,6 +197,8 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = {
[NL80211_ATTR_TDLS_OPERATION] = { .type = NLA_U8 },
[NL80211_ATTR_TDLS_SUPPORT] = { .type = NLA_FLAG },
[NL80211_ATTR_TDLS_EXTERNAL_SETUP] = { .type = NLA_FLAG },
+ [NL80211_ATTR_PROBE_RESP] = { .type = NLA_BINARY,
+ .len = IEEE80211_MAX_DATA_LEN },
};

/* policy for the key attributes */
@@ -2978,6 +2980,15 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
if (info->attrs[NL80211_ATTR_BSS_HT_OPMODE])
params.ht_opmode =
nla_get_u16(info->attrs[NL80211_ATTR_BSS_HT_OPMODE]);
+ if (info->attrs[NL80211_ATTR_PROBE_RESP]) {
+ if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP)
+ return -EOPNOTSUPP;
+
+ params.probe_resp =
+ nla_data(info->attrs[NL80211_ATTR_PROBE_RESP]);
+ params.probe_resp_len =
+ nla_len(info->attrs[NL80211_ATTR_PROBE_RESP]);
+ }

if (!rdev->ops->change_bss)
return -EOPNOTSUPP;
--
1.7.4.1


2011-10-22 17:26:58

by Guy Eilam

[permalink] [raw]
Subject: Re: [PATCH 1/4] nl80211: Add probe response offload attribute

On Sat, Oct 22, 2011 at 3:36 PM, Johannes Berg
<[email protected]> wrote:
> On Sat, 2011-10-22 at 15:34 +0200, Johannes Berg wrote:
>> On Sat, 2011-10-22 at 15:11 +0200, Guy Eilam wrote:
>>
>> > +enum nl80211_probe_resp_offload_support_attr {
>> > + ? NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS,
>> > + ? NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2,
>> > + ? NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P,
>> > +};
>>
>> I think doing = 1<<N here would be nicer to use in drivers & userspace.
>
> Hm, also: should we call this WPS or WSC, and do we need to distinguish
> WPS and WPS2? My AP mode patch called it WSC in a different context but
> I can change, we just should be consistent.
>
>> > + * @get_probe_resp_offload: Get probe response offload support from driver.
>>
>> and this seems unnecessary -- why not just put a u32 value into struct
>> wiphy?
>
> Oh, and probably a regular WIPHY flag that indicates whether the
> attribute should be added at all so that it can also be 0 but present
> (presence with 0 value indicates something other than not present).

When this is not supported a -EOPNOTSUPP should be returned.
A 0 return means that it is supported.
I now see that I have a small mistake in the patch regarding this.
The check should be (res >= 0) and not (!res).
I'll fix it.

>
> johannes
>
>

2011-10-22 17:44:22

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 1/4] nl80211: Add probe response offload attribute

On Sat, 2011-10-22 at 19:42 +0200, Guy Eilam wrote:

> > Yeah but if you add a wiphy flag and the bits into struct wiphy, then
> > you can save the function pointer which seems nicer?
>
> You're absolutely right.
> I'll send another version of the patch that will have a flag and
> bitmap in the wiphy struct.

Also I believe that means you don't need patch 2 at all so that's kinda
nice :-)

johannes


2011-10-22 13:37:00

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 1/4] nl80211: Add probe response offload attribute

On Sat, 2011-10-22 at 15:34 +0200, Johannes Berg wrote:
> On Sat, 2011-10-22 at 15:11 +0200, Guy Eilam wrote:
>
> > +enum nl80211_probe_resp_offload_support_attr {
> > + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS,
> > + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2,
> > + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P,
> > +};
>
> I think doing = 1<<N here would be nicer to use in drivers & userspace.

Hm, also: should we call this WPS or WSC, and do we need to distinguish
WPS and WPS2? My AP mode patch called it WSC in a different context but
I can change, we just should be consistent.

> > + * @get_probe_resp_offload: Get probe response offload support from driver.
>
> and this seems unnecessary -- why not just put a u32 value into struct
> wiphy?

Oh, and probably a regular WIPHY flag that indicates whether the
attribute should be added at all so that it can also be 0 but present
(presence with 0 value indicates something other than not present).

johannes


2011-10-22 13:34:20

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 1/4] nl80211: Add probe response offload attribute

On Sat, 2011-10-22 at 15:11 +0200, Guy Eilam wrote:

> +enum nl80211_probe_resp_offload_support_attr {
> + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS,
> + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2,
> + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P,
> +};

I think doing = 1<<N here would be nicer to use in drivers & userspace.

> + * @get_probe_resp_offload: Get probe response offload support from driver.

and this seems unnecessary -- why not just put a u32 value into struct
wiphy?

johannes


2011-10-22 13:13:41

by Guy Eilam

[permalink] [raw]
Subject: [PATCH 2/4] mac80211: Get the probe response offloading support from the driver

Query the driver for probe response offloading support
in order to notify the userspace on the protocols supported
by the driver for offloading.

Signed-off-by: Guy Eilam <[email protected]>
---
include/net/mac80211.h | 3 +++
net/mac80211/cfg.c | 9 +++++++++
net/mac80211/driver-ops.h | 11 +++++++++++
3 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index cd108df..1c58fd7 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -2080,6 +2080,7 @@ enum ieee80211_frame_release_type {
* The @tids parameter is a bitmap and tells the driver which TIDs the
* frames will be on; it will at most have two bits set.
* This callback must be atomic.
+ * @get_probe_resp_offload: Get probe response offload support from driver.
*/
struct ieee80211_ops {
void (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb);
@@ -2206,6 +2207,8 @@ struct ieee80211_ops {
u16 tids, int num_frames,
enum ieee80211_frame_release_type reason,
bool more_data);
+ int (*get_probe_resp_offload) (struct ieee80211_hw *hw,
+ u32 *supp_protocols);
};

/**
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 1309bb9..3cdb4a9 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2470,6 +2470,14 @@ static int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
return 0;
}

+static int ieee80211_get_probe_resp_offload(struct wiphy *wiphy,
+ u32 *supp_protocols)
+{
+ struct ieee80211_local *local = wiphy_priv(wiphy);
+
+ return drv_get_probe_resp_offload(local, supp_protocols);
+}
+
struct cfg80211_ops mac80211_config_ops = {
.add_virtual_intf = ieee80211_add_iface,
.del_virtual_intf = ieee80211_del_iface,
@@ -2535,4 +2543,5 @@ struct cfg80211_ops mac80211_config_ops = {
.set_rekey_data = ieee80211_set_rekey_data,
.tdls_oper = ieee80211_tdls_oper,
.tdls_mgmt = ieee80211_tdls_mgmt,
+ .get_probe_resp_offload = ieee80211_get_probe_resp_offload,
};
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index 5f165d7..cd8da74 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -701,4 +701,15 @@ drv_allow_buffered_frames(struct ieee80211_local *local,
more_data);
trace_drv_return_void(local);
}
+static inline int drv_get_probe_resp_offload(struct ieee80211_local *local,
+ u32 *supp_protocols)
+{
+ int ret = -EOPNOTSUPP;
+ might_sleep();
+ if (local->ops->get_probe_resp_offload)
+ ret = local->ops->get_probe_resp_offload(&local->hw,
+ supp_protocols);
+ return ret;
+}
+
#endif /* __MAC80211_DRIVER_OPS */
--
1.7.4.1


2011-10-22 17:39:51

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 1/4] nl80211: Add probe response offload attribute

On Sat, 2011-10-22 at 19:26 +0200, Guy Eilam wrote:

> >> > +enum nl80211_probe_resp_offload_support_attr {
> >> > + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS,
> >> > + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2,
> >> > + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P,
> >> > +};
> >>
> >> I think doing = 1<<N here would be nicer to use in drivers & userspace.
> >
> > Hm, also: should we call this WPS or WSC, and do we need to distinguish
> > WPS and WPS2? My AP mode patch called it WSC in a different context but
> > I can change, we just should be consistent.
> >
> >> > + * @get_probe_resp_offload: Get probe response offload support from driver.
> >>
> >> and this seems unnecessary -- why not just put a u32 value into struct
> >> wiphy?
> >
> > Oh, and probably a regular WIPHY flag that indicates whether the
> > attribute should be added at all so that it can also be 0 but present
> > (presence with 0 value indicates something other than not present).
>
> When this is not supported a -EOPNOTSUPP should be returned.
> A 0 return means that it is supported.

Yeah but if you add a wiphy flag and the bits into struct wiphy, then
you can save the function pointer which seems nicer?

johannes