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

wifi: wext/libipw: move spy implementation to libipw

There's no driver left using this other than ipw2200,
so move the data bookkeeping and code into libipw.

Link: https://patch.msgid.link/20241007210254.037d864cda7d.Ib2197cb056ff05746d3521a5fba637062acb7314@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

+51 -62
-3
drivers/net/wireless/intel/ipw2x00/Kconfig
··· 7 7 tristate "Intel PRO/Wireless 2100 Network Connection" 8 8 depends on PCI && CFG80211 9 9 select WIRELESS_EXT 10 - select WEXT_SPY 11 10 select WEXT_PRIV 12 11 select FW_LOADER 13 12 select LIBIPW ··· 67 68 depends on PCI && CFG80211 68 69 select CFG80211_WEXT_EXPORT 69 70 select WIRELESS_EXT 70 - select WEXT_SPY 71 71 select WEXT_PRIV 72 72 select FW_LOADER 73 73 select LIBIPW ··· 154 156 tristate 155 157 depends on PCI && CFG80211 156 158 select WIRELESS_EXT 157 - select WEXT_SPY 158 159 select CRYPTO 159 160 select CRYPTO_MICHAEL_MIC 160 161 select CRC32
+1
drivers/net/wireless/intel/ipw2x00/Makefile
··· 13 13 libipw_rx.o \ 14 14 libipw_wx.o \ 15 15 libipw_geo.o \ 16 + libipw_spy.o \ 16 17 libipw_crypto.o \ 17 18 libipw_crypto_ccmp.o \ 18 19 libipw_crypto_tkip.o \
+5 -5
drivers/net/wireless/intel/ipw2x00/ipw2200.c
··· 9856 9856 IW_HANDLER(SIOCGIWENCODE, ipw_wx_get_encode), 9857 9857 IW_HANDLER(SIOCSIWPOWER, ipw_wx_set_power), 9858 9858 IW_HANDLER(SIOCGIWPOWER, ipw_wx_get_power), 9859 - IW_HANDLER(SIOCSIWSPY, iw_handler_set_spy), 9860 - IW_HANDLER(SIOCGIWSPY, iw_handler_get_spy), 9861 - IW_HANDLER(SIOCSIWTHRSPY, iw_handler_set_thrspy), 9862 - IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy), 9859 + IW_HANDLER(SIOCSIWSPY, ipw_wx_set_spy), 9860 + IW_HANDLER(SIOCGIWSPY, ipw_wx_get_spy), 9861 + IW_HANDLER(SIOCSIWTHRSPY, ipw_wx_set_thrspy), 9862 + IW_HANDLER(SIOCGIWTHRSPY, ipw_wx_get_thrspy), 9863 9863 IW_HANDLER(SIOCSIWGENIE, ipw_wx_set_genie), 9864 9864 IW_HANDLER(SIOCGIWGENIE, ipw_wx_get_genie), 9865 9865 IW_HANDLER(SIOCSIWMLME, ipw_wx_set_mlme), ··· 11636 11636 priv->ieee->worst_rssi = -85; 11637 11637 11638 11638 net_dev->netdev_ops = &ipw_netdev_ops; 11639 - priv->wireless_data.spy_data = &priv->ieee->spy_data; 11639 + priv->ieee->spy_enabled = true; 11640 11640 net_dev->wireless_data = &priv->wireless_data; 11641 11641 net_dev->wireless_handlers = &ipw_wx_handler_def; 11642 11642 net_dev->ethtool_ops = &ipw_ethtool_ops;
+13
drivers/net/wireless/intel/ipw2x00/libipw.h
··· 788 788 789 789 int iw_mode; /* operating mode (IW_MODE_*) */ 790 790 struct iw_spy_data spy_data; /* iwspy support */ 791 + bool spy_enabled; 791 792 792 793 spinlock_t lock; 793 794 ··· 1083 1082 void libipw_crypto_tkip_exit(void); 1084 1083 void libipw_crypto_ccmp_exit(void); 1085 1084 void libipw_crypto_exit(void); 1085 + 1086 + 1087 + int ipw_wx_set_spy(struct net_device *dev, struct iw_request_info *info, 1088 + union iwreq_data *wrqu, char *extra); 1089 + int ipw_wx_get_spy(struct net_device *dev, struct iw_request_info *info, 1090 + union iwreq_data *wrqu, char *extra); 1091 + int ipw_wx_set_thrspy(struct net_device *dev, struct iw_request_info *info, 1092 + union iwreq_data *wrqu, char *extra); 1093 + int ipw_wx_get_thrspy(struct net_device *dev, struct iw_request_info *info, 1094 + union iwreq_data *wrqu, char *extra); 1095 + void libipw_spy_update(struct net_device *dev, unsigned char *address, 1096 + struct iw_quality *wstats); 1086 1097 1087 1098 #endif /* LIBIPW_H */
+1 -1
drivers/net/wireless/intel/ipw2x00/libipw_rx.c
··· 393 393 wstats.updated |= IW_QUAL_QUAL_INVALID; 394 394 395 395 /* Update spy records */ 396 - wireless_spy_update(ieee->dev, hdr->addr2, &wstats); 396 + libipw_spy_update(ieee->dev, hdr->addr2, &wstats); 397 397 } 398 398 #endif /* IW_WIRELESS_SPY */ 399 399 #endif /* CONFIG_WIRELESS_EXT */
-18
include/net/iw_handler.h
··· 418 418 struct libipw_device; 419 419 /* The struct */ 420 420 struct iw_public_data { 421 - /* Driver enhanced spy support */ 422 - struct iw_spy_data * spy_data; 423 421 /* Legacy structure managed by the ipw2x00-specific IEEE 802.11 layer */ 424 422 struct libipw_device * libipw; 425 423 }; ··· 440 442 441 443 /* We may need a function to send a stream of events to user space. 442 444 * More on that later... */ 443 - 444 - /* Standard handler for SIOCSIWSPY */ 445 - int iw_handler_set_spy(struct net_device *dev, struct iw_request_info *info, 446 - union iwreq_data *wrqu, char *extra); 447 - /* Standard handler for SIOCGIWSPY */ 448 - int iw_handler_get_spy(struct net_device *dev, struct iw_request_info *info, 449 - union iwreq_data *wrqu, char *extra); 450 - /* Standard handler for SIOCSIWTHRSPY */ 451 - int iw_handler_set_thrspy(struct net_device *dev, struct iw_request_info *info, 452 - union iwreq_data *wrqu, char *extra); 453 - /* Standard handler for SIOCGIWTHRSPY */ 454 - int iw_handler_get_thrspy(struct net_device *dev, struct iw_request_info *info, 455 - union iwreq_data *wrqu, char *extra); 456 - /* Driver call to update spy records */ 457 - void wireless_spy_update(struct net_device *dev, unsigned char *address, 458 - struct iw_quality *wstats); 459 445 460 446 /************************* INLINE FUNCTIONS *************************/ 461 447 /*
-3
net/wireless/Kconfig
··· 11 11 depends on PROC_FS 12 12 depends on WEXT_CORE 13 13 14 - config WEXT_SPY 15 - bool 16 - 17 14 config WEXT_PRIV 18 15 bool 19 16
-1
net/wireless/Makefile
··· 4 4 5 5 obj-$(CONFIG_WEXT_CORE) += wext-core.o 6 6 obj-$(CONFIG_WEXT_PROC) += wext-proc.o 7 - obj-$(CONFIG_WEXT_SPY) += wext-spy.o 8 7 obj-$(CONFIG_WEXT_PRIV) += wext-priv.o 9 8 10 9 cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o
+31 -31
net/wireless/wext-spy.c drivers/net/wireless/intel/ipw2x00/libipw_spy.c
··· 14 14 #include <net/iw_handler.h> 15 15 #include <net/arp.h> 16 16 #include <net/wext.h> 17 + #include "libipw.h" 17 18 18 - static inline struct iw_spy_data *get_spydata(struct net_device *dev) 19 + static struct iw_spy_data *get_spydata(struct net_device *dev) 19 20 { 20 - /* This is the new way */ 21 - if (dev->wireless_data) 22 - return dev->wireless_data->spy_data; 21 + if (dev->wireless_data && dev->wireless_data->libipw && 22 + dev->wireless_data->libipw->spy_enabled) 23 + return &dev->wireless_data->libipw->spy_data; 23 24 return NULL; 24 25 } 25 26 26 - int iw_handler_set_spy(struct net_device * dev, 27 - struct iw_request_info * info, 28 - union iwreq_data * wrqu, 29 - char * extra) 27 + int ipw_wx_set_spy(struct net_device * dev, 28 + struct iw_request_info * info, 29 + union iwreq_data * wrqu, 30 + char * extra) 30 31 { 31 32 struct iw_spy_data * spydata = get_spydata(dev); 32 33 struct sockaddr * address = (struct sockaddr *) extra; ··· 37 36 return -EOPNOTSUPP; 38 37 39 38 /* Disable spy collection while we copy the addresses. 40 - * While we copy addresses, any call to wireless_spy_update() 39 + * While we copy addresses, any call to libipw_spy_update() 41 40 * will NOP. This is OK, as anyway the addresses are changing. */ 42 41 spydata->spy_number = 0; 43 42 44 - /* We want to operate without locking, because wireless_spy_update() 43 + /* We want to operate without locking, because libipw_spy_update() 45 44 * most likely will happen in the interrupt handler, and therefore 46 45 * have its own locking constraints and needs performance. 47 46 * The rtnl_lock() make sure we don't race with the other iw_handlers. 48 - * This make sure wireless_spy_update() "see" that the spy list 47 + * This make sure libipw_spy_update() "see" that the spy list 49 48 * is temporarily disabled. */ 50 49 smp_wmb(); 51 50 ··· 70 69 71 70 return 0; 72 71 } 73 - EXPORT_SYMBOL(iw_handler_set_spy); 72 + EXPORT_SYMBOL(ipw_wx_set_spy); 74 73 75 - int iw_handler_get_spy(struct net_device * dev, 76 - struct iw_request_info * info, 77 - union iwreq_data * wrqu, 78 - char * extra) 74 + int ipw_wx_get_spy(struct net_device * dev, 75 + struct iw_request_info * info, 76 + union iwreq_data * wrqu, 77 + char * extra) 79 78 { 80 79 struct iw_spy_data * spydata = get_spydata(dev); 81 80 struct sockaddr * address = (struct sockaddr *) extra; ··· 102 101 spydata->spy_stat[i].updated &= ~IW_QUAL_ALL_UPDATED; 103 102 return 0; 104 103 } 105 - EXPORT_SYMBOL(iw_handler_get_spy); 104 + EXPORT_SYMBOL(ipw_wx_get_spy); 106 105 107 106 /*------------------------------------------------------------------*/ 108 107 /* 109 108 * Standard Wireless Handler : set spy threshold 110 109 */ 111 - int iw_handler_set_thrspy(struct net_device * dev, 112 - struct iw_request_info *info, 113 - union iwreq_data * wrqu, 114 - char * extra) 110 + int ipw_wx_set_thrspy(struct net_device * dev, 111 + struct iw_request_info * info, 112 + union iwreq_data * wrqu, 113 + char * extra) 115 114 { 116 115 struct iw_spy_data * spydata = get_spydata(dev); 117 116 struct iw_thrspy * threshold = (struct iw_thrspy *) extra; ··· 129 128 130 129 return 0; 131 130 } 132 - EXPORT_SYMBOL(iw_handler_set_thrspy); 131 + EXPORT_SYMBOL(ipw_wx_set_thrspy); 133 132 134 133 /*------------------------------------------------------------------*/ 135 134 /* 136 135 * Standard Wireless Handler : get spy threshold 137 136 */ 138 - int iw_handler_get_thrspy(struct net_device * dev, 139 - struct iw_request_info *info, 140 - union iwreq_data * wrqu, 141 - char * extra) 137 + int ipw_wx_get_thrspy(struct net_device * dev, 138 + struct iw_request_info * info, 139 + union iwreq_data * wrqu, 140 + char * extra) 142 141 { 143 142 struct iw_spy_data * spydata = get_spydata(dev); 144 143 struct iw_thrspy * threshold = (struct iw_thrspy *) extra; ··· 153 152 154 153 return 0; 155 154 } 156 - EXPORT_SYMBOL(iw_handler_get_thrspy); 155 + EXPORT_SYMBOL(ipw_wx_get_thrspy); 157 156 158 157 /*------------------------------------------------------------------*/ 159 158 /* ··· 190 189 * small, this is good enough. If we wanted to support larger number of 191 190 * spy addresses, we should use something more efficient... 192 191 */ 193 - void wireless_spy_update(struct net_device * dev, 194 - unsigned char * address, 195 - struct iw_quality * wstats) 192 + void libipw_spy_update(struct net_device * dev, 193 + unsigned char * address, 194 + struct iw_quality * wstats) 196 195 { 197 196 struct iw_spy_data * spydata = get_spydata(dev); 198 197 int i; ··· 230 229 } 231 230 } 232 231 } 233 - EXPORT_SYMBOL(wireless_spy_update);