Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Yoni Divinsky <yoni.divinsky@ti.com>
[cleanups, fixes, documentation]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Yoni Divinsky and committed by
Johannes Berg
de5fad81 5a32aff3

+53 -1
+10
include/net/mac80211.h
··· 1630 1630 * rekeying), it will not include a valid phase 1 key. The valid phase 1 key is 1631 1631 * provided by update_tkip_key only. The trigger that makes mac80211 call this 1632 1632 * handler is software decryption with wrap around of iv16. 1633 + * 1634 + * The set_default_unicast_key() call updates the default WEP key index 1635 + * configured to the hardware for WEP encryption type. This is required 1636 + * for devices that support offload of data packets (e.g. ARP responses). 1633 1637 */ 1634 1638 1635 1639 /** ··· 2212 2208 * After rekeying was done it should (for example during resume) notify 2213 2209 * userspace of the new replay counter using ieee80211_gtk_rekey_notify(). 2214 2210 * 2211 + * @set_default_unicast_key: Set the default (unicast) key index, useful for 2212 + * WEP when the device sends data packets autonomously, e.g. for ARP 2213 + * offloading. The index can be 0-3, or -1 for unsetting it. 2214 + * 2215 2215 * @hw_scan: Ask the hardware to service the scan request, no need to start 2216 2216 * the scan state machine in stack. The scan must honour the channel 2217 2217 * configuration done by the regulatory agent in the wiphy's ··· 2547 2539 void (*set_rekey_data)(struct ieee80211_hw *hw, 2548 2540 struct ieee80211_vif *vif, 2549 2541 struct cfg80211_gtk_rekey_data *data); 2542 + void (*set_default_unicast_key)(struct ieee80211_hw *hw, 2543 + struct ieee80211_vif *vif, int idx); 2550 2544 int (*hw_scan)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 2551 2545 struct cfg80211_scan_request *req); 2552 2546 void (*cancel_hw_scan)(struct ieee80211_hw *hw,
+16
net/mac80211/driver-ops.h
··· 1020 1020 trace_drv_return_void(local); 1021 1021 } 1022 1022 1023 + static inline void 1024 + drv_set_default_unicast_key(struct ieee80211_local *local, 1025 + struct ieee80211_sub_if_data *sdata, 1026 + int key_idx) 1027 + { 1028 + check_sdata_in_driver(sdata); 1029 + 1030 + WARN_ON_ONCE(key_idx < -1 || key_idx > 3); 1031 + 1032 + trace_drv_set_default_unicast_key(local, sdata, key_idx); 1033 + if (local->ops->set_default_unicast_key) 1034 + local->ops->set_default_unicast_key(&local->hw, &sdata->vif, 1035 + key_idx); 1036 + trace_drv_return_void(local); 1037 + } 1038 + 1023 1039 #endif /* __MAC80211_DRIVER_OPS */
+4 -1
net/mac80211/key.c
··· 204 204 if (idx >= 0 && idx < NUM_DEFAULT_KEYS) 205 205 key = key_mtx_dereference(sdata->local, sdata->keys[idx]); 206 206 207 - if (uni) 207 + if (uni) { 208 208 rcu_assign_pointer(sdata->default_unicast_key, key); 209 + drv_set_default_unicast_key(sdata->local, sdata, idx); 210 + } 211 + 209 212 if (multi) 210 213 rcu_assign_pointer(sdata->default_multicast_key, key); 211 214
+23
net/mac80211/trace.h
··· 1821 1821 ) 1822 1822 ); 1823 1823 1824 + TRACE_EVENT(drv_set_default_unicast_key, 1825 + TP_PROTO(struct ieee80211_local *local, 1826 + struct ieee80211_sub_if_data *sdata, 1827 + int key_idx), 1828 + 1829 + TP_ARGS(local, sdata, key_idx), 1830 + 1831 + TP_STRUCT__entry( 1832 + LOCAL_ENTRY 1833 + VIF_ENTRY 1834 + __field(int, key_idx) 1835 + ), 1836 + 1837 + TP_fast_assign( 1838 + LOCAL_ASSIGN; 1839 + VIF_ASSIGN; 1840 + __entry->key_idx = key_idx; 1841 + ), 1842 + 1843 + TP_printk(LOCAL_PR_FMT VIF_PR_FMT " key_idx:%d", 1844 + LOCAL_PR_ARG, VIF_PR_ARG, __entry->key_idx) 1845 + ); 1846 + 1824 1847 #ifdef CONFIG_MAC80211_MESSAGE_TRACING 1825 1848 #undef TRACE_SYSTEM 1826 1849 #define TRACE_SYSTEM mac80211_msg