mac80211: add op to configure default key id
PATCH v3 1/1 mac80211: add op to configure default key id
There are hardwares which support offload of data packets for example when auto ARP is enabled the hw will send the ARP response. In such cases if WEP encryption is configured the hw must know the default WEP key in order to encrypt the packets correctly.
When hw_accel is enabled and encryption type is set to WEP, the driver should get the default key index from mac80211.
---
v2 to v3:
removed the return value of set_default_key_idx op since it should not fail at this point.
include/net/mac80211.h | 7 ++++++- net/mac80211/driver-ops.h | 14 ++++++++++++++ net/mac80211/driver-trace.h | 24 ++++++++++++++++++++++++ net/mac80211/key.c | 2 ++ 4 files changed, 46 insertions(+), 1 deletions(-)
include/net/mac80211.h +6 -1
@@ -1427,6 +1427,10 @@ void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb);* rekeying), it will not include a valid phase 1 key. The valid phase 1 key is * provided by update_tkip_key only. The trigger that makes mac80211 call this * handler is software decryption with wrap around of iv16. +* +* The set_default_key_idx() call updates the default WEP key index configured +* to the hardware for WEP encryption type. This is required for hw which +* supports offload of data packets (i.e. auto ARP respones). */ /**
@@ -2361,7 +2365,6 @@ struct ieee80211_ops { u16 tids, int num_frames, enum ieee80211_frame_release_type reason, bool more_data); -int (*get_et_sset_count)(struct ieee80211_hw *hw,struct ieee80211_vif *vif,int sset); void (*get_et_stats)(struct ieee80211_hw *hw,
@@ -2370,6 +2373,8 @@ struct ieee80211_ops {void (*get_et_strings)(struct ieee80211_hw *hw,struct ieee80211_vif *vif,u32 sset,u8 *data); +void (*set_default_key_idx)(struct ieee80211_hw *hw, +struct ieee80211_vif *vif,int idx); };/**
net/mac80211/driver-ops.h +14 -0
@@ -845,4 +845,18 @@ drv_allow_buffered_frames(struct ieee80211_local *local, more_data); trace_drv_return_void(local); } + +static inline void +drv_set_default_unicast_key (struct ieee80211_local *local, +struct ieee80211_sub_if_data *sdata, +int key_idx) +{ +check_sdata_in_driver (sdata); + +trace_drv_set_default_unicast_key (local, sdata, key_idx); +if (local->ops->set_default_key_idx) + local->ops->set_default_key_idx (&local->hw, &sdata->vif, + key_idx); +trace_drv_return_void (local); +}#endif /* __MAC80211_DRIVER_OPS */
net/mac80211/driver-trace.h +24 -0
@@ -1606,6 +1606,30 @@ TRACE_EVENT(stop_queue,LOCAL_PR_ARG , __entry->queue, __entry->reason ) ); + +TRACE_EVENT (drv_set_default_unicast_key, + TP_PROTO(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + int key_idx), + +TP_ARGS (local, sdata, key_idx), + +TP_STRUCT__entry ( + LOCAL_ENTRY + VIF_ENTRY +__field (int, key_idx) + ), + +TP_fast_assign ( + LOCAL_ASSIGN; + VIF_ASSIGN; + __entry->key_idx = key_idx; + ), + + TP_printk(LOCAL_PR_FMT VIF_PR_FMT " key_idx:%d", +LOCAL_PR_ARG ,VIF_PR_ARG , __entry->key_idx) +); +#endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */ #undef TRACE_INCLUDE_PATH
net/mac80211/key.c +2 -0
@@ -237,6 +237,8 @@ void ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, int idx, {mutex_lock (&sdata->local->key_mtx);__ieee80211_set_default_key (sdata, idx, uni, multi); +if (uni) +drv_set_default_unicast_key (sdata->local, sdata, idx);mutex_unlock (&sdata->local->key_mtx); }
Signature · 1 line
1.7.0.4
Johannes Berg
maintainerQuoted 38 lines · Yoni Divinsky
There are hardwares which support offload of data packets for example when auto ARP is enabled the hw will send the ARP response. In such cases if WEP encryption is configured the hw must know the default WEP key in order to encrypt the packets correctly.
When
hw_accelis enabled and encryption type is set to WEP, the driver should get the default key index from mac80211.Signed-off-by Yoni Divinsky <[email protected]>---
v2 to v3:
removed the return value ofset_default_key_idxop since it should not fail at this point.include/net/mac80211.h | 7 ++++++- net/mac80211/driver-ops.h | 14 ++++++++++++++ net/mac80211/driver-trace.h | 24 ++++++++++++++++++++++++ net/mac80211/key.c | 2 ++ 4 files changed, 46 insertions(+), 1 deletions(-)include/net/mac80211.h +4
-0@@ -1427,6 +1427,10 @@ void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb);* rekeying), it will not include a valid phase 1 key. The valid phase 1 key is * provided by update_tkip_key only. The trigger that makes mac80211 call this * handler is software decryption with wrap around of iv16. +* +* The set_default_key_idx() call updates the default WEP key index configured +* to the hardware for WEP encryption type. This is required for hw which +* supports offload of data packets (i.e. auto ARP respones). */ /**
include/net/mac80211.h struct ieee80211_ops { · line 2370
Quoted 7 lines
include/net/mac80211.h +0
-1@@ -2361,7 +2365,6 @@ struct ieee80211_ops { u16 tids, int num_frames, enum ieee80211_frame_release_type reason, bool more_data); -int (*get_et_sset_count)(struct ieee80211_hw *hw,struct ieee80211_vif *vif,int sset); void (*get_et_stats)(struct ieee80211_hw *hw,
No need for this change
include/net/mac80211.h struct ieee80211_ops { · line 2377
Quoted 6 lines
include/net/mac80211.h +2
-0@@ -2370,6 +2373,8 @@ struct ieee80211_ops {void (*get_et_strings)(struct ieee80211_hw *hw,struct ieee80211_vif *vif,u32 sset,u8 *data); +void (*set_default_key_idx)(struct ieee80211_hw *hw, +struct ieee80211_vif *vif,int idx);
Missing kernel-doc.
johannes
Johannes Berg
maintainerQuoted 10 lines · Yoni Divinsky
There are hardwares which support offload of data packets for example when auto ARP is enabled the hw will send the ARP response. In such cases if WEP encryption is configured the hw must know the default WEP key in order to encrypt the packets correctly.
When
hw_accelis enabled and encryption type is set to WEP, the driver should get the default key index from mac80211.Signed-off-by Yoni Divinsky <[email protected]>
I applied the fixed up version below.
johannes
Quoted 1 line
From
de5fad815703b5b24bc4726cd71422929537d259Mon Sep 17 00:00:00 2001
From: Yoni Divinsky <[email protected]>
Date: Wed, 30 May 2012 11:36:39 +0300
Subject: [PATCH] mac80211: add op to configure default key id
There are hardwares which support offload of data packets for example when auto ARP is enabled the hw will send the ARP response. In such cases if WEP encryption is configured the hw must know the default WEP key in order to encrypt the packets correctly.
When hw_accel is enabled and encryption type is set to WEP, the driver should get the default key index from mac80211.
--- include/net/mac80211.h | 10 ++++++++++ net/mac80211/driver-ops.h | 16 ++++++++++++++++ net/mac80211/key.c | 5 ++++- net/mac80211/trace.h | 23 +++++++++++++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-)
include/net/mac80211.h +10 -0
@@ -1630,6 +1630,10 @@ void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb);* rekeying), it will not include a valid phase 1 key. The valid phase 1 key is * provided by update_tkip_key only. The trigger that makes mac80211 call this * handler is software decryption with wrap around of iv16. +* +* The set_default_unicast_key() call updates the default WEP key index +* configured to the hardware for WEP encryption type. This is required +* for devices that support offload of data packets (e.g. ARP responses). */ /**
@@ -2208,6 +2212,10 @@ enum ieee80211_rate_control_changed {* After rekeying was done it should (for example during resume) notify * userspace of the new replay counter using ieee80211_gtk_rekey_notify(). * +* @set_default_unicast_key: Set the default (unicast) key index, useful for +* WEP when the device sends data packets autonomously, e.g. for ARP +* offloading. The index can be 0-3, or -1 for unsetting it. +* * @hw_scan: Ask the hardware to service the scan request, no need to start * the scan state machine in stack. The scan must honour the channel * configuration done by the regulatory agent in the wiphy's
@@ -2539,6 +2547,8 @@ struct ieee80211_ops {void (*set_rekey_data)(struct ieee80211_hw *hw,struct ieee80211_vif *vif,struct cfg80211_gtk_rekey_data *data); +void (*set_default_unicast_key)(struct ieee80211_hw *hw, +struct ieee80211_vif *vif,int idx);int (*hw_scan)(struct ieee80211_hw *hw,struct ieee80211_vif *vif,struct cfg80211_scan_request *req); void (*cancel_hw_scan)(struct ieee80211_hw *hw,
net/mac80211/driver-ops.h +16 -0
@@ -1020,4 +1020,20 @@ static inline void drv_restart_complete(struct ieee80211_local *local) trace_drv_return_void(local); } +static inline void +drv_set_default_unicast_key (struct ieee80211_local *local, +struct ieee80211_sub_if_data *sdata, +int key_idx) +{ +check_sdata_in_driver (sdata); + +WARN_ON_ONCE (key_idx <-1 || key_idx >3 ); + +trace_drv_set_default_unicast_key (local, sdata, key_idx); +if (local->ops->set_default_unicast_key) + local->ops->set_default_unicast_key (&local->hw, &sdata->vif, + key_idx); +trace_drv_return_void (local); +} +#endif /* __MAC80211_DRIVER_OPS */
net/mac80211/key.c +4 -1
@@ -204,8 +204,11 @@ static void __ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata,if (idx >=0 && idx <NUM_DEFAULT_KEYS ) key =key_mtx_dereference (sdata->local, sdata->keys[idx]); -if (uni) +if (uni) {rcu_assign_pointer (sdata->default_unicast_key, key); +drv_set_default_unicast_key (sdata->local, sdata, idx); + } +if (multi)rcu_assign_pointer (sdata->default_multicast_key, key);
net/mac80211/trace.h +23 -0
@@ -1821,6 +1821,29 @@ TRACE_EVENT(stop_queue, ) ); +TRACE_EVENT (drv_set_default_unicast_key, + TP_PROTO(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + int key_idx), + +TP_ARGS (local, sdata, key_idx), + +TP_STRUCT__entry ( + LOCAL_ENTRY + VIF_ENTRY +__field (int, key_idx) + ), + +TP_fast_assign ( + LOCAL_ASSIGN; + VIF_ASSIGN; + __entry->key_idx = key_idx; + ), + + TP_printk(LOCAL_PR_FMT VIF_PR_FMT " key_idx:%d", +LOCAL_PR_ARG ,VIF_PR_ARG , __entry->key_idx) +); +#ifdef CONFIG_MAC80211_MESSAGE_TRACING #undef TRACE_SYSTEM#define TRACE_SYSTEM mac80211_msg
Signature · 1 line
1.8.0