xref: /openbmc/linux/net/mac80211/debugfs_key.c (revision ddbfe860)
1e9f207f0SJiri Benc /*
2e9f207f0SJiri Benc  * Copyright 2003-2005	Devicescape Software, Inc.
3e9f207f0SJiri Benc  * Copyright (c) 2006	Jiri Benc <jbenc@suse.cz>
4e9f207f0SJiri Benc  * Copyright 2007	Johannes Berg <johannes@sipsolutions.net>
5e9f207f0SJiri Benc  *
6e9f207f0SJiri Benc  * This program is free software; you can redistribute it and/or modify
7e9f207f0SJiri Benc  * it under the terms of the GNU General Public License version 2 as
8e9f207f0SJiri Benc  * published by the Free Software Foundation.
9e9f207f0SJiri Benc  */
10e9f207f0SJiri Benc 
11e9f207f0SJiri Benc #include <linux/kobject.h>
125a0e3ad6STejun Heo #include <linux/slab.h>
13e9f207f0SJiri Benc #include "ieee80211_i.h"
142c8dccc7SJohannes Berg #include "key.h"
15e9f207f0SJiri Benc #include "debugfs.h"
16e9f207f0SJiri Benc #include "debugfs_key.h"
17e9f207f0SJiri Benc 
1807caf9d6SEliad Peller #define KEY_READ(name, prop, format_string)				\
19e9f207f0SJiri Benc static ssize_t key_##name##_read(struct file *file,			\
20e9f207f0SJiri Benc 				 char __user *userbuf,			\
21e9f207f0SJiri Benc 				 size_t count, loff_t *ppos)		\
22e9f207f0SJiri Benc {									\
23e9f207f0SJiri Benc 	struct ieee80211_key *key = file->private_data;			\
2407caf9d6SEliad Peller 	return mac80211_format_buffer(userbuf, count, ppos, 		\
2507caf9d6SEliad Peller 				      format_string, key->prop);	\
26e9f207f0SJiri Benc }
2707caf9d6SEliad Peller #define KEY_READ_D(name) KEY_READ(name, name, "%d\n")
2807caf9d6SEliad Peller #define KEY_READ_X(name) KEY_READ(name, name, "0x%x\n")
29e9f207f0SJiri Benc 
30e9f207f0SJiri Benc #define KEY_OPS(name)							\
31e9f207f0SJiri Benc static const struct file_operations key_ ##name## _ops = {		\
32e9f207f0SJiri Benc 	.read = key_##name##_read,					\
33234e3405SStephen Boyd 	.open = simple_open,						\
342b18ab36SArnd Bergmann 	.llseek = generic_file_llseek,					\
35e9f207f0SJiri Benc }
36e9f207f0SJiri Benc 
37e9f207f0SJiri Benc #define KEY_FILE(name, format)						\
38e9f207f0SJiri Benc 		 KEY_READ_##format(name)				\
39e9f207f0SJiri Benc 		 KEY_OPS(name)
40e9f207f0SJiri Benc 
4107caf9d6SEliad Peller #define KEY_CONF_READ(name, format_string)				\
4207caf9d6SEliad Peller 	KEY_READ(conf_##name, conf.name, format_string)
4307caf9d6SEliad Peller #define KEY_CONF_READ_D(name) KEY_CONF_READ(name, "%d\n")
448f20fc24SJohannes Berg 
458f20fc24SJohannes Berg #define KEY_CONF_OPS(name)						\
468f20fc24SJohannes Berg static const struct file_operations key_ ##name## _ops = {		\
478f20fc24SJohannes Berg 	.read = key_conf_##name##_read,					\
48234e3405SStephen Boyd 	.open = simple_open,						\
492b18ab36SArnd Bergmann 	.llseek = generic_file_llseek,					\
508f20fc24SJohannes Berg }
518f20fc24SJohannes Berg 
528f20fc24SJohannes Berg #define KEY_CONF_FILE(name, format)					\
538f20fc24SJohannes Berg 		 KEY_CONF_READ_##format(name)				\
548f20fc24SJohannes Berg 		 KEY_CONF_OPS(name)
558f20fc24SJohannes Berg 
568f20fc24SJohannes Berg KEY_CONF_FILE(keylen, D);
578f20fc24SJohannes Berg KEY_CONF_FILE(keyidx, D);
588f20fc24SJohannes Berg KEY_CONF_FILE(hw_key_idx, D);
5911a843b7SJohannes Berg KEY_FILE(flags, X);
60e9f207f0SJiri Benc KEY_FILE(tx_rx_count, D);
6107caf9d6SEliad Peller KEY_READ(ifindex, sdata->name, "%s\n");
62e7a64f12SJohannes Berg KEY_OPS(ifindex);
63e9f207f0SJiri Benc 
64e9f207f0SJiri Benc static ssize_t key_algorithm_read(struct file *file,
65e9f207f0SJiri Benc 				  char __user *userbuf,
66e9f207f0SJiri Benc 				  size_t count, loff_t *ppos)
67e9f207f0SJiri Benc {
6897359d12SJohannes Berg 	char buf[15];
69e9f207f0SJiri Benc 	struct ieee80211_key *key = file->private_data;
7097359d12SJohannes Berg 	u32 c = key->conf.cipher;
71e9f207f0SJiri Benc 
7297359d12SJohannes Berg 	sprintf(buf, "%.2x-%.2x-%.2x:%d\n",
7397359d12SJohannes Berg 		c >> 24, (c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff);
7497359d12SJohannes Berg 	return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
75e9f207f0SJiri Benc }
76e9f207f0SJiri Benc KEY_OPS(algorithm);
77e9f207f0SJiri Benc 
78e9f207f0SJiri Benc static ssize_t key_tx_spec_read(struct file *file, char __user *userbuf,
79e9f207f0SJiri Benc 				size_t count, loff_t *ppos)
80e9f207f0SJiri Benc {
81aba83a0bSJohannes Berg 	u64 pn;
82e9f207f0SJiri Benc 	char buf[20];
83e9f207f0SJiri Benc 	int len;
84e9f207f0SJiri Benc 	struct ieee80211_key *key = file->private_data;
85e9f207f0SJiri Benc 
8697359d12SJohannes Berg 	switch (key->conf.cipher) {
8797359d12SJohannes Berg 	case WLAN_CIPHER_SUITE_WEP40:
8897359d12SJohannes Berg 	case WLAN_CIPHER_SUITE_WEP104:
89e9f207f0SJiri Benc 		len = scnprintf(buf, sizeof(buf), "\n");
9050339a67SJohannes Berg 		break;
9197359d12SJohannes Berg 	case WLAN_CIPHER_SUITE_TKIP:
92e9f207f0SJiri Benc 		len = scnprintf(buf, sizeof(buf), "%08x %04x\n",
93b0f76b33SHarvey Harrison 				key->u.tkip.tx.iv32,
94b0f76b33SHarvey Harrison 				key->u.tkip.tx.iv16);
9550339a67SJohannes Berg 		break;
9697359d12SJohannes Berg 	case WLAN_CIPHER_SUITE_CCMP:
97aba83a0bSJohannes Berg 		pn = atomic64_read(&key->u.ccmp.tx_pn);
98e9f207f0SJiri Benc 		len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n",
99aba83a0bSJohannes Berg 				(u8)(pn >> 40), (u8)(pn >> 32), (u8)(pn >> 24),
100aba83a0bSJohannes Berg 				(u8)(pn >> 16), (u8)(pn >> 8), (u8)pn);
10150339a67SJohannes Berg 		break;
10297359d12SJohannes Berg 	case WLAN_CIPHER_SUITE_AES_CMAC:
10375396ae6SJohannes Berg 		pn = atomic64_read(&key->u.aes_cmac.tx_pn);
1043cfcf6acSJouni Malinen 		len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n",
10575396ae6SJohannes Berg 				(u8)(pn >> 40), (u8)(pn >> 32), (u8)(pn >> 24),
10675396ae6SJohannes Berg 				(u8)(pn >> 16), (u8)(pn >> 8), (u8)pn);
1073cfcf6acSJouni Malinen 		break;
108e9f207f0SJiri Benc 	default:
109e9f207f0SJiri Benc 		return 0;
110e9f207f0SJiri Benc 	}
111e9f207f0SJiri Benc 	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
112e9f207f0SJiri Benc }
113e9f207f0SJiri Benc KEY_OPS(tx_spec);
114e9f207f0SJiri Benc 
115e9f207f0SJiri Benc static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf,
116e9f207f0SJiri Benc 				size_t count, loff_t *ppos)
117e9f207f0SJiri Benc {
118e9f207f0SJiri Benc 	struct ieee80211_key *key = file->private_data;
1195a306f58SJohannes Berg 	char buf[14*IEEE80211_NUM_TIDS+1], *p = buf;
120e9f207f0SJiri Benc 	int i, len;
121e9f207f0SJiri Benc 	const u8 *rpn;
122e9f207f0SJiri Benc 
12397359d12SJohannes Berg 	switch (key->conf.cipher) {
12497359d12SJohannes Berg 	case WLAN_CIPHER_SUITE_WEP40:
12597359d12SJohannes Berg 	case WLAN_CIPHER_SUITE_WEP104:
126e9f207f0SJiri Benc 		len = scnprintf(buf, sizeof(buf), "\n");
12750339a67SJohannes Berg 		break;
12897359d12SJohannes Berg 	case WLAN_CIPHER_SUITE_TKIP:
1295a306f58SJohannes Berg 		for (i = 0; i < IEEE80211_NUM_TIDS; i++)
130e9f207f0SJiri Benc 			p += scnprintf(p, sizeof(buf)+buf-p,
131e9f207f0SJiri Benc 				       "%08x %04x\n",
132b0f76b33SHarvey Harrison 				       key->u.tkip.rx[i].iv32,
133b0f76b33SHarvey Harrison 				       key->u.tkip.rx[i].iv16);
134e9f207f0SJiri Benc 		len = p - buf;
13550339a67SJohannes Berg 		break;
13697359d12SJohannes Berg 	case WLAN_CIPHER_SUITE_CCMP:
1375a306f58SJohannes Berg 		for (i = 0; i < IEEE80211_NUM_TIDS + 1; i++) {
138e9f207f0SJiri Benc 			rpn = key->u.ccmp.rx_pn[i];
139e9f207f0SJiri Benc 			p += scnprintf(p, sizeof(buf)+buf-p,
140e9f207f0SJiri Benc 				       "%02x%02x%02x%02x%02x%02x\n",
141e9f207f0SJiri Benc 				       rpn[0], rpn[1], rpn[2],
142e9f207f0SJiri Benc 				       rpn[3], rpn[4], rpn[5]);
143e9f207f0SJiri Benc 		}
144e9f207f0SJiri Benc 		len = p - buf;
14550339a67SJohannes Berg 		break;
14697359d12SJohannes Berg 	case WLAN_CIPHER_SUITE_AES_CMAC:
1473cfcf6acSJouni Malinen 		rpn = key->u.aes_cmac.rx_pn;
1483cfcf6acSJouni Malinen 		p += scnprintf(p, sizeof(buf)+buf-p,
1493cfcf6acSJouni Malinen 			       "%02x%02x%02x%02x%02x%02x\n",
1503cfcf6acSJouni Malinen 			       rpn[0], rpn[1], rpn[2],
1513cfcf6acSJouni Malinen 			       rpn[3], rpn[4], rpn[5]);
1523cfcf6acSJouni Malinen 		len = p - buf;
1533cfcf6acSJouni Malinen 		break;
154e9f207f0SJiri Benc 	default:
155e9f207f0SJiri Benc 		return 0;
156e9f207f0SJiri Benc 	}
157e9f207f0SJiri Benc 	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
158e9f207f0SJiri Benc }
159e9f207f0SJiri Benc KEY_OPS(rx_spec);
160e9f207f0SJiri Benc 
161e9f207f0SJiri Benc static ssize_t key_replays_read(struct file *file, char __user *userbuf,
162e9f207f0SJiri Benc 				size_t count, loff_t *ppos)
163e9f207f0SJiri Benc {
164e9f207f0SJiri Benc 	struct ieee80211_key *key = file->private_data;
165e9f207f0SJiri Benc 	char buf[20];
166e9f207f0SJiri Benc 	int len;
167e9f207f0SJiri Benc 
16897359d12SJohannes Berg 	switch (key->conf.cipher) {
16997359d12SJohannes Berg 	case WLAN_CIPHER_SUITE_CCMP:
170e9f207f0SJiri Benc 		len = scnprintf(buf, sizeof(buf), "%u\n", key->u.ccmp.replays);
1713cfcf6acSJouni Malinen 		break;
17297359d12SJohannes Berg 	case WLAN_CIPHER_SUITE_AES_CMAC:
1733cfcf6acSJouni Malinen 		len = scnprintf(buf, sizeof(buf), "%u\n",
1743cfcf6acSJouni Malinen 				key->u.aes_cmac.replays);
1753cfcf6acSJouni Malinen 		break;
1763cfcf6acSJouni Malinen 	default:
1773cfcf6acSJouni Malinen 		return 0;
1783cfcf6acSJouni Malinen 	}
179e9f207f0SJiri Benc 	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
180e9f207f0SJiri Benc }
181e9f207f0SJiri Benc KEY_OPS(replays);
182e9f207f0SJiri Benc 
1833cfcf6acSJouni Malinen static ssize_t key_icverrors_read(struct file *file, char __user *userbuf,
1843cfcf6acSJouni Malinen 				  size_t count, loff_t *ppos)
1853cfcf6acSJouni Malinen {
1863cfcf6acSJouni Malinen 	struct ieee80211_key *key = file->private_data;
1873cfcf6acSJouni Malinen 	char buf[20];
1883cfcf6acSJouni Malinen 	int len;
1893cfcf6acSJouni Malinen 
19097359d12SJohannes Berg 	switch (key->conf.cipher) {
19197359d12SJohannes Berg 	case WLAN_CIPHER_SUITE_AES_CMAC:
1923cfcf6acSJouni Malinen 		len = scnprintf(buf, sizeof(buf), "%u\n",
1933cfcf6acSJouni Malinen 				key->u.aes_cmac.icverrors);
1943cfcf6acSJouni Malinen 		break;
1953cfcf6acSJouni Malinen 	default:
1963cfcf6acSJouni Malinen 		return 0;
1973cfcf6acSJouni Malinen 	}
1983cfcf6acSJouni Malinen 	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
1993cfcf6acSJouni Malinen }
2003cfcf6acSJouni Malinen KEY_OPS(icverrors);
2013cfcf6acSJouni Malinen 
202b98ea058SSaravana static ssize_t key_mic_failures_read(struct file *file, char __user *userbuf,
203b98ea058SSaravana 				     size_t count, loff_t *ppos)
204b98ea058SSaravana {
205b98ea058SSaravana 	struct ieee80211_key *key = file->private_data;
206b98ea058SSaravana 	char buf[20];
207b98ea058SSaravana 	int len;
208b98ea058SSaravana 
209b98ea058SSaravana 	if (key->conf.cipher != WLAN_CIPHER_SUITE_TKIP)
210b98ea058SSaravana 		return -EINVAL;
211b98ea058SSaravana 
212b98ea058SSaravana 	len = scnprintf(buf, sizeof(buf), "%u\n", key->u.tkip.mic_failures);
213b98ea058SSaravana 
214b98ea058SSaravana 	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
215b98ea058SSaravana }
216b98ea058SSaravana KEY_OPS(mic_failures);
217b98ea058SSaravana 
218e9f207f0SJiri Benc static ssize_t key_key_read(struct file *file, char __user *userbuf,
219e9f207f0SJiri Benc 			    size_t count, loff_t *ppos)
220e9f207f0SJiri Benc {
221e9f207f0SJiri Benc 	struct ieee80211_key *key = file->private_data;
222520efd1aSJesper Juhl 	int i, bufsize = 2 * key->conf.keylen + 2;
223e9f207f0SJiri Benc 	char *buf = kmalloc(bufsize, GFP_KERNEL);
224e9f207f0SJiri Benc 	char *p = buf;
225520efd1aSJesper Juhl 	ssize_t res;
226520efd1aSJesper Juhl 
227520efd1aSJesper Juhl 	if (!buf)
228520efd1aSJesper Juhl 		return -ENOMEM;
229e9f207f0SJiri Benc 
2308f20fc24SJohannes Berg 	for (i = 0; i < key->conf.keylen; i++)
2318f20fc24SJohannes Berg 		p += scnprintf(p, bufsize + buf - p, "%02x", key->conf.key[i]);
232e9f207f0SJiri Benc 	p += scnprintf(p, bufsize+buf-p, "\n");
233e9f207f0SJiri Benc 	res = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
234e9f207f0SJiri Benc 	kfree(buf);
235e9f207f0SJiri Benc 	return res;
236e9f207f0SJiri Benc }
237e9f207f0SJiri Benc KEY_OPS(key);
238e9f207f0SJiri Benc 
239e9f207f0SJiri Benc #define DEBUGFS_ADD(name) \
2407bcfaf2fSJohannes Berg 	debugfs_create_file(#name, 0400, key->debugfs.dir, \
2417bcfaf2fSJohannes Berg 			    key, &key_##name##_ops);
242e9f207f0SJiri Benc 
2433b96766fSJohannes Berg void ieee80211_debugfs_key_add(struct ieee80211_key *key)
244e9f207f0SJiri Benc {
24550339a67SJohannes Berg 	static int keycount;
2469446f3efSJohannes Berg 	char buf[100];
2473b96766fSJohannes Berg 	struct sta_info *sta;
248e9f207f0SJiri Benc 
2493b96766fSJohannes Berg 	if (!key->local->debugfs.keys)
250e9f207f0SJiri Benc 		return;
251e9f207f0SJiri Benc 
25250339a67SJohannes Berg 	sprintf(buf, "%d", keycount);
253d9c58f30SJohannes Berg 	key->debugfs.cnt = keycount;
25450339a67SJohannes Berg 	keycount++;
255e9f207f0SJiri Benc 	key->debugfs.dir = debugfs_create_dir(buf,
2563b96766fSJohannes Berg 					key->local->debugfs.keys);
257e9f207f0SJiri Benc 
258e9f207f0SJiri Benc 	if (!key->debugfs.dir)
259e9f207f0SJiri Benc 		return;
260e9f207f0SJiri Benc 
26140b275b6SJohannes Berg 	sta = key->sta;
26240b275b6SJohannes Berg 	if (sta) {
2639446f3efSJohannes Berg 		sprintf(buf, "../../netdev:%s/stations/%pM",
2649446f3efSJohannes Berg 			sta->sdata->name, sta->sta.addr);
2653b96766fSJohannes Berg 		key->debugfs.stalink =
2663b96766fSJohannes Berg 			debugfs_create_symlink("station", key->debugfs.dir, buf);
26740b275b6SJohannes Berg 	}
2683b96766fSJohannes Berg 
269e9f207f0SJiri Benc 	DEBUGFS_ADD(keylen);
2708f20fc24SJohannes Berg 	DEBUGFS_ADD(flags);
271e9f207f0SJiri Benc 	DEBUGFS_ADD(keyidx);
272e9f207f0SJiri Benc 	DEBUGFS_ADD(hw_key_idx);
273e9f207f0SJiri Benc 	DEBUGFS_ADD(tx_rx_count);
274e9f207f0SJiri Benc 	DEBUGFS_ADD(algorithm);
275e9f207f0SJiri Benc 	DEBUGFS_ADD(tx_spec);
276e9f207f0SJiri Benc 	DEBUGFS_ADD(rx_spec);
277e9f207f0SJiri Benc 	DEBUGFS_ADD(replays);
2783cfcf6acSJouni Malinen 	DEBUGFS_ADD(icverrors);
279b98ea058SSaravana 	DEBUGFS_ADD(mic_failures);
280e9f207f0SJiri Benc 	DEBUGFS_ADD(key);
281e7a64f12SJohannes Berg 	DEBUGFS_ADD(ifindex);
282e9f207f0SJiri Benc };
283e9f207f0SJiri Benc 
284e9f207f0SJiri Benc void ieee80211_debugfs_key_remove(struct ieee80211_key *key)
285e9f207f0SJiri Benc {
286e9f207f0SJiri Benc 	if (!key)
287e9f207f0SJiri Benc 		return;
288e9f207f0SJiri Benc 
2897bcfaf2fSJohannes Berg 	debugfs_remove_recursive(key->debugfs.dir);
290e9f207f0SJiri Benc 	key->debugfs.dir = NULL;
291e9f207f0SJiri Benc }
292f7e0104cSJohannes Berg 
293f7e0104cSJohannes Berg void ieee80211_debugfs_key_update_default(struct ieee80211_sub_if_data *sdata)
294e9f207f0SJiri Benc {
295e9f207f0SJiri Benc 	char buf[50];
29678520cadSJohannes Berg 	struct ieee80211_key *key;
297e9f207f0SJiri Benc 
298ddbfe860SStanislaw Gruszka 	if (!sdata->vif.debugfs_dir)
299e9f207f0SJiri Benc 		return;
300e9f207f0SJiri Benc 
301f7e0104cSJohannes Berg 	lockdep_assert_held(&sdata->local->key_mtx);
30278520cadSJohannes Berg 
303135792ecSJohannes Berg 	if (sdata->debugfs.default_unicast_key) {
304135792ecSJohannes Berg 		debugfs_remove(sdata->debugfs.default_unicast_key);
305135792ecSJohannes Berg 		sdata->debugfs.default_unicast_key = NULL;
306135792ecSJohannes Berg 	}
307135792ecSJohannes Berg 
308f7e0104cSJohannes Berg 	if (sdata->default_unicast_key) {
30940b275b6SJohannes Berg 		key = key_mtx_dereference(sdata->local,
31040b275b6SJohannes Berg 					  sdata->default_unicast_key);
31178520cadSJohannes Berg 		sprintf(buf, "../keys/%d", key->debugfs.cnt);
312f7e0104cSJohannes Berg 		sdata->debugfs.default_unicast_key =
313f7e0104cSJohannes Berg 			debugfs_create_symlink("default_unicast_key",
314ddbfe860SStanislaw Gruszka 					       sdata->vif.debugfs_dir, buf);
315135792ecSJohannes Berg 	}
316135792ecSJohannes Berg 
317135792ecSJohannes Berg 	if (sdata->debugfs.default_multicast_key) {
318135792ecSJohannes Berg 		debugfs_remove(sdata->debugfs.default_multicast_key);
319135792ecSJohannes Berg 		sdata->debugfs.default_multicast_key = NULL;
320e9f207f0SJiri Benc 	}
32178520cadSJohannes Berg 
322f7e0104cSJohannes Berg 	if (sdata->default_multicast_key) {
32340b275b6SJohannes Berg 		key = key_mtx_dereference(sdata->local,
32440b275b6SJohannes Berg 					  sdata->default_multicast_key);
325f7e0104cSJohannes Berg 		sprintf(buf, "../keys/%d", key->debugfs.cnt);
326f7e0104cSJohannes Berg 		sdata->debugfs.default_multicast_key =
327f7e0104cSJohannes Berg 			debugfs_create_symlink("default_multicast_key",
328ddbfe860SStanislaw Gruszka 					       sdata->vif.debugfs_dir, buf);
329f7e0104cSJohannes Berg 	}
330e9f207f0SJiri Benc }
331e9f207f0SJiri Benc 
3323cfcf6acSJouni Malinen void ieee80211_debugfs_key_add_mgmt_default(struct ieee80211_sub_if_data *sdata)
3333cfcf6acSJouni Malinen {
3343cfcf6acSJouni Malinen 	char buf[50];
3353cfcf6acSJouni Malinen 	struct ieee80211_key *key;
3363cfcf6acSJouni Malinen 
337ddbfe860SStanislaw Gruszka 	if (!sdata->vif.debugfs_dir)
3383cfcf6acSJouni Malinen 		return;
3393cfcf6acSJouni Malinen 
34040b275b6SJohannes Berg 	key = key_mtx_dereference(sdata->local,
34140b275b6SJohannes Berg 				  sdata->default_mgmt_key);
3423cfcf6acSJouni Malinen 	if (key) {
3433cfcf6acSJouni Malinen 		sprintf(buf, "../keys/%d", key->debugfs.cnt);
3447bcfaf2fSJohannes Berg 		sdata->debugfs.default_mgmt_key =
3453cfcf6acSJouni Malinen 			debugfs_create_symlink("default_mgmt_key",
346ddbfe860SStanislaw Gruszka 					       sdata->vif.debugfs_dir, buf);
3473cfcf6acSJouni Malinen 	} else
3483cfcf6acSJouni Malinen 		ieee80211_debugfs_key_remove_mgmt_default(sdata);
3493cfcf6acSJouni Malinen }
3503cfcf6acSJouni Malinen 
3513cfcf6acSJouni Malinen void ieee80211_debugfs_key_remove_mgmt_default(struct ieee80211_sub_if_data *sdata)
3523cfcf6acSJouni Malinen {
3533cfcf6acSJouni Malinen 	if (!sdata)
3543cfcf6acSJouni Malinen 		return;
3553cfcf6acSJouni Malinen 
3567bcfaf2fSJohannes Berg 	debugfs_remove(sdata->debugfs.default_mgmt_key);
3577bcfaf2fSJohannes Berg 	sdata->debugfs.default_mgmt_key = NULL;
3583cfcf6acSJouni Malinen }
3593cfcf6acSJouni Malinen 
360e9f207f0SJiri Benc void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key,
361e9f207f0SJiri Benc 				   struct sta_info *sta)
362e9f207f0SJiri Benc {
363e9f207f0SJiri Benc 	debugfs_remove(key->debugfs.stalink);
364e9f207f0SJiri Benc 	key->debugfs.stalink = NULL;
365e9f207f0SJiri Benc }
366