debugfs_netdev.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2006   Jiri Benc <jbenc@suse.cz>
00003  * Copyright 2007       Johannes Berg <johannes@sipsolutions.net>
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 2 as
00007  * published by the Free Software Foundation.
00008  */
00009 
00010 #include <linux/kernel.h>
00011 #include <linux/device.h>
00012 #include <linux/if.h>
00013 #include <linux/interrupt.h>
00014 #include <linux/netdevice.h>
00015 #include <linux/rtnetlink.h>
00016 #include <linux/slab.h>
00017 #include <linux/notifier.h>
00018 #include <net/mac80211.h>
00019 #include <net/cfg80211.h>
00020 #include "ieee80211_i.h"
00021 #include "rate.h"
00022 #include "debugfs.h"
00023 #include "debugfs_netdev.h"
00024 #include "driver-ops.h"
00025 
00026 static ssize_t ieee80211_if_read(
00027         struct ieee80211_sub_if_data *sdata,
00028         char __user *userbuf,
00029         size_t count, loff_t *ppos,
00030         ssize_t (*format)(const struct ieee80211_sub_if_data *, char *, int))
00031 {
00032         char buf[70];
00033         ssize_t ret = -EINVAL;
00034 
00035         read_lock(&dev_base_lock);
00036         if (sdata->dev->reg_state == NETREG_REGISTERED)
00037                 ret = (*format)(sdata, buf, sizeof(buf));
00038         read_unlock(&dev_base_lock);
00039 
00040         if (ret >= 0)
00041                 ret = simple_read_from_buffer(userbuf, count, ppos, buf, ret);
00042 
00043         return ret;
00044 }
00045 
00046 static ssize_t ieee80211_if_write(
00047         struct ieee80211_sub_if_data *sdata,
00048         const char __user *userbuf,
00049         size_t count, loff_t *ppos,
00050         ssize_t (*write)(struct ieee80211_sub_if_data *, const char *, int))
00051 {
00052         u8 *buf;
00053         ssize_t ret;
00054 
00055         buf = kmalloc(count, GFP_KERNEL);
00056         if (!buf)
00057                 return -ENOMEM;
00058 
00059         ret = -EFAULT;
00060         if (copy_from_user(buf, userbuf, count))
00061                 goto freebuf;
00062 
00063         ret = -ENODEV;
00064         rtnl_lock();
00065         if (sdata->dev->reg_state == NETREG_REGISTERED)
00066                 ret = (*write)(sdata, buf, count);
00067         rtnl_unlock();
00068 
00069 freebuf:
00070         kfree(buf);
00071         return ret;
00072 }
00073 
00074 #define IEEE80211_IF_FMT(name, field, format_string)                    \
00075 static ssize_t ieee80211_if_fmt_##name(                                 \
00076         const struct ieee80211_sub_if_data *sdata, char *buf,           \
00077         int buflen)                                                     \
00078 {                                                                       \
00079         return scnprintf(buf, buflen, format_string, sdata->field);     \
00080 }
00081 #define IEEE80211_IF_FMT_DEC(name, field)                               \
00082                 IEEE80211_IF_FMT(name, field, "%d\n")
00083 #define IEEE80211_IF_FMT_HEX(name, field)                               \
00084                 IEEE80211_IF_FMT(name, field, "%#x\n")
00085 #define IEEE80211_IF_FMT_LHEX(name, field)                              \
00086                 IEEE80211_IF_FMT(name, field, "%#lx\n")
00087 #define IEEE80211_IF_FMT_SIZE(name, field)                              \
00088                 IEEE80211_IF_FMT(name, field, "%zd\n")
00089 
00090 #define IEEE80211_IF_FMT_ATOMIC(name, field)                            \
00091 static ssize_t ieee80211_if_fmt_##name(                                 \
00092         const struct ieee80211_sub_if_data *sdata,                      \
00093         char *buf, int buflen)                                          \
00094 {                                                                       \
00095         return scnprintf(buf, buflen, "%d\n", atomic_read(&sdata->field));\
00096 }
00097 
00098 #define IEEE80211_IF_FMT_MAC(name, field)                               \
00099 static ssize_t ieee80211_if_fmt_##name(                                 \
00100         const struct ieee80211_sub_if_data *sdata, char *buf,           \
00101         int buflen)                                                     \
00102 {                                                                       \
00103         return scnprintf(buf, buflen, "%pM\n", sdata->field);           \
00104 }
00105 
00106 #define IEEE80211_IF_FMT_DEC_DIV_16(name, field)                        \
00107 static ssize_t ieee80211_if_fmt_##name(                                 \
00108         const struct ieee80211_sub_if_data *sdata,                      \
00109         char *buf, int buflen)                                          \
00110 {                                                                       \
00111         return scnprintf(buf, buflen, "%d\n", sdata->field / 16);       \
00112 }
00113 
00114 #define __IEEE80211_IF_FILE(name, _write)                               \
00115 static ssize_t ieee80211_if_read_##name(struct file *file,              \
00116                                         char __user *userbuf,           \
00117                                         size_t count, loff_t *ppos)     \
00118 {                                                                       \
00119         return ieee80211_if_read(file->private_data,                    \
00120                                  userbuf, count, ppos,                  \
00121                                  ieee80211_if_fmt_##name);              \
00122 }                                                                       \
00123 static const struct file_operations name##_ops = {                      \
00124         .read = ieee80211_if_read_##name,                               \
00125         .write = (_write),                                              \
00126         .open = mac80211_open_file_generic,                             \
00127         .llseek = generic_file_llseek,                                  \
00128 }
00129 
00130 #define __IEEE80211_IF_FILE_W(name)                                     \
00131 static ssize_t ieee80211_if_write_##name(struct file *file,             \
00132                                          const char __user *userbuf,    \
00133                                          size_t count, loff_t *ppos)    \
00134 {                                                                       \
00135         return ieee80211_if_write(file->private_data, userbuf, count,   \
00136                                   ppos, ieee80211_if_parse_##name);     \
00137 }                                                                       \
00138 __IEEE80211_IF_FILE(name, ieee80211_if_write_##name)
00139 
00140 
00141 #define IEEE80211_IF_FILE(name, field, format)                          \
00142                 IEEE80211_IF_FMT_##format(name, field)                  \
00143                 __IEEE80211_IF_FILE(name, NULL)
00144 
00145 /* common attributes */
00146 IEEE80211_IF_FILE(drop_unencrypted, drop_unencrypted, DEC);
00147 IEEE80211_IF_FILE(rc_rateidx_mask_2ghz, rc_rateidx_mask[IEEE80211_BAND_2GHZ],
00148                   HEX);
00149 IEEE80211_IF_FILE(rc_rateidx_mask_5ghz, rc_rateidx_mask[IEEE80211_BAND_5GHZ],
00150                   HEX);
00151 IEEE80211_IF_FILE(flags, flags, HEX);
00152 IEEE80211_IF_FILE(state, state, LHEX);
00153 IEEE80211_IF_FILE(channel_type, vif.bss_conf.channel_type, DEC);
00154 
00155 /* STA attributes */
00156 IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC);
00157 IEEE80211_IF_FILE(aid, u.mgd.aid, DEC);
00158 IEEE80211_IF_FILE(last_beacon, u.mgd.last_beacon_signal, DEC);
00159 IEEE80211_IF_FILE(ave_beacon, u.mgd.ave_beacon_signal, DEC_DIV_16);
00160 
00161 static int ieee80211_set_smps(struct ieee80211_sub_if_data *sdata,
00162                               enum ieee80211_smps_mode smps_mode)
00163 {
00164         struct ieee80211_local *local = sdata->local;
00165         int err;
00166 
00167         if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_STATIC_SMPS) &&
00168             smps_mode == IEEE80211_SMPS_STATIC)
00169                 return -EINVAL;
00170 
00171         /* auto should be dynamic if in PS mode */
00172         if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS) &&
00173             (smps_mode == IEEE80211_SMPS_DYNAMIC ||
00174              smps_mode == IEEE80211_SMPS_AUTOMATIC))
00175                 return -EINVAL;
00176 
00177         /* supported only on managed interfaces for now */
00178         if (sdata->vif.type != NL80211_IFTYPE_STATION)
00179                 return -EOPNOTSUPP;
00180 
00181         mutex_lock(&sdata->u.mgd.mtx);
00182         err = __ieee80211_request_smps(sdata, smps_mode);
00183         mutex_unlock(&sdata->u.mgd.mtx);
00184 
00185         return err;
00186 }
00187 
00188 static const char *smps_modes[IEEE80211_SMPS_NUM_MODES] = {
00189         [IEEE80211_SMPS_AUTOMATIC] = "auto",
00190         [IEEE80211_SMPS_OFF] = "off",
00191         [IEEE80211_SMPS_STATIC] = "static",
00192         [IEEE80211_SMPS_DYNAMIC] = "dynamic",
00193 };
00194 
00195 static ssize_t ieee80211_if_fmt_smps(const struct ieee80211_sub_if_data *sdata,
00196                                      char *buf, int buflen)
00197 {
00198         if (sdata->vif.type != NL80211_IFTYPE_STATION)
00199                 return -EOPNOTSUPP;
00200 
00201         return snprintf(buf, buflen, "request: %s\nused: %s\n",
00202                         smps_modes[sdata->u.mgd.req_smps],
00203                         smps_modes[sdata->u.mgd.ap_smps]);
00204 }
00205 
00206 static ssize_t ieee80211_if_parse_smps(struct ieee80211_sub_if_data *sdata,
00207                                        const char *buf, int buflen)
00208 {
00209         enum ieee80211_smps_mode mode;
00210 
00211         for (mode = 0; mode < IEEE80211_SMPS_NUM_MODES; mode++) {
00212                 if (strncmp(buf, smps_modes[mode], buflen) == 0) {
00213                         int err = ieee80211_set_smps(sdata, mode);
00214                         if (!err)
00215                                 return buflen;
00216                         return err;
00217                 }
00218         }
00219 
00220         return -EINVAL;
00221 }
00222 
00223 __IEEE80211_IF_FILE_W(smps);
00224 
00225 static ssize_t ieee80211_if_fmt_tkip_mic_test(
00226         const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
00227 {
00228         return -EOPNOTSUPP;
00229 }
00230 
00231 static int hwaddr_aton(const char *txt, u8 *addr)
00232 {
00233         int i;
00234 
00235         for (i = 0; i < ETH_ALEN; i++) {
00236                 int a, b;
00237 
00238                 a = hex_to_bin(*txt++);
00239                 if (a < 0)
00240                         return -1;
00241                 b = hex_to_bin(*txt++);
00242                 if (b < 0)
00243                         return -1;
00244                 *addr++ = (a << 4) | b;
00245                 if (i < 5 && *txt++ != ':')
00246                         return -1;
00247         }
00248 
00249         return 0;
00250 }
00251 
00252 static ssize_t ieee80211_if_parse_tkip_mic_test(
00253         struct ieee80211_sub_if_data *sdata, const char *buf, int buflen)
00254 {
00255         struct ieee80211_local *local = sdata->local;
00256         u8 addr[ETH_ALEN];
00257         struct sk_buff *skb;
00258         struct ieee80211_hdr *hdr;
00259         __le16 fc;
00260 
00261         /*
00262          * Assume colon-delimited MAC address with possible white space
00263          * following.
00264          */
00265         if (buflen < 3 * ETH_ALEN - 1)
00266                 return -EINVAL;
00267         if (hwaddr_aton(buf, addr) < 0)
00268                 return -EINVAL;
00269 
00270         if (!ieee80211_sdata_running(sdata))
00271                 return -ENOTCONN;
00272 
00273         skb = dev_alloc_skb(local->hw.extra_tx_headroom + 24 + 100);
00274         if (!skb)
00275                 return -ENOMEM;
00276         skb_reserve(skb, local->hw.extra_tx_headroom);
00277 
00278         hdr = (struct ieee80211_hdr *) skb_put(skb, 24);
00279         memset(hdr, 0, 24);
00280         fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA);
00281 
00282         switch (sdata->vif.type) {
00283         case NL80211_IFTYPE_AP:
00284                 fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS);
00285                 /* DA BSSID SA */
00286                 memcpy(hdr->addr1, addr, ETH_ALEN);
00287                 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN);
00288                 memcpy(hdr->addr3, sdata->vif.addr, ETH_ALEN);
00289                 break;
00290         case NL80211_IFTYPE_STATION:
00291                 fc |= cpu_to_le16(IEEE80211_FCTL_TODS);
00292                 /* BSSID SA DA */
00293                 if (sdata->vif.bss_conf.bssid == NULL) {
00294                         dev_kfree_skb(skb);
00295                         return -ENOTCONN;
00296                 }
00297                 memcpy(hdr->addr1, sdata->vif.bss_conf.bssid, ETH_ALEN);
00298                 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN);
00299                 memcpy(hdr->addr3, addr, ETH_ALEN);
00300                 break;
00301         default:
00302                 dev_kfree_skb(skb);
00303                 return -EOPNOTSUPP;
00304         }
00305         hdr->frame_control = fc;
00306 
00307         /*
00308          * Add some length to the test frame to make it look bit more valid.
00309          * The exact contents does not matter since the recipient is required
00310          * to drop this because of the Michael MIC failure.
00311          */
00312         memset(skb_put(skb, 50), 0, 50);
00313 
00314         IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_TKIP_MIC_FAILURE;
00315 
00316         ieee80211_tx_skb(sdata, skb);
00317 
00318         return buflen;
00319 }
00320 
00321 __IEEE80211_IF_FILE_W(tkip_mic_test);
00322 
00323 /* AP attributes */
00324 IEEE80211_IF_FILE(num_sta_ps, u.ap.num_sta_ps, ATOMIC);
00325 IEEE80211_IF_FILE(dtim_count, u.ap.dtim_count, DEC);
00326 
00327 static ssize_t ieee80211_if_fmt_num_buffered_multicast(
00328         const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
00329 {
00330         return scnprintf(buf, buflen, "%u\n",
00331                          skb_queue_len(&sdata->u.ap.ps_bc_buf));
00332 }
00333 __IEEE80211_IF_FILE(num_buffered_multicast, NULL);
00334 
00335 /* IBSS attributes */
00336 static ssize_t ieee80211_if_fmt_tsf(
00337         const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
00338 {
00339         struct ieee80211_local *local = sdata->local;
00340         u64 tsf;
00341 
00342         tsf = drv_get_tsf(local, (struct ieee80211_sub_if_data *)sdata);
00343 
00344         return scnprintf(buf, buflen, "0x%016llx\n", (unsigned long long) tsf);
00345 }
00346 
00347 static ssize_t ieee80211_if_parse_tsf(
00348         struct ieee80211_sub_if_data *sdata, const char *buf, int buflen)
00349 {
00350         struct ieee80211_local *local = sdata->local;
00351         unsigned long long tsf;
00352         int ret;
00353 
00354         if (strncmp(buf, "reset", 5) == 0) {
00355                 if (local->ops->reset_tsf) {
00356                         drv_reset_tsf(local, sdata);
00357                         wiphy_info(local->hw.wiphy, "debugfs reset TSF\n");
00358                 }
00359         } else {
00360                 ret = kstrtoull(buf, 10, &tsf);
00361                 if (ret < 0)
00362                         return -EINVAL;
00363                 if (local->ops->set_tsf) {
00364                         drv_set_tsf(local, sdata, tsf);
00365                         wiphy_info(local->hw.wiphy,
00366                                    "debugfs set TSF to %#018llx\n", tsf);
00367                 }
00368         }
00369 
00370         return buflen;
00371 }
00372 __IEEE80211_IF_FILE_W(tsf);
00373 
00374 
00375 /* WDS attributes */
00376 IEEE80211_IF_FILE(peer, u.wds.remote_addr, MAC);
00377 
00378 #ifdef CONFIG_MAC80211_MESH
00379 /* Mesh stats attributes */
00380 IEEE80211_IF_FILE(fwded_mcast, u.mesh.mshstats.fwded_mcast, DEC);
00381 IEEE80211_IF_FILE(fwded_unicast, u.mesh.mshstats.fwded_unicast, DEC);
00382 IEEE80211_IF_FILE(fwded_frames, u.mesh.mshstats.fwded_frames, DEC);
00383 IEEE80211_IF_FILE(dropped_frames_ttl, u.mesh.mshstats.dropped_frames_ttl, DEC);
00384 IEEE80211_IF_FILE(dropped_frames_congestion,
00385                 u.mesh.mshstats.dropped_frames_congestion, DEC);
00386 IEEE80211_IF_FILE(dropped_frames_no_route,
00387                 u.mesh.mshstats.dropped_frames_no_route, DEC);
00388 IEEE80211_IF_FILE(estab_plinks, u.mesh.mshstats.estab_plinks, ATOMIC);
00389 
00390 /* Mesh parameters */
00391 IEEE80211_IF_FILE(dot11MeshMaxRetries,
00392                 u.mesh.mshcfg.dot11MeshMaxRetries, DEC);
00393 IEEE80211_IF_FILE(dot11MeshRetryTimeout,
00394                 u.mesh.mshcfg.dot11MeshRetryTimeout, DEC);
00395 IEEE80211_IF_FILE(dot11MeshConfirmTimeout,
00396                 u.mesh.mshcfg.dot11MeshConfirmTimeout, DEC);
00397 IEEE80211_IF_FILE(dot11MeshHoldingTimeout,
00398                 u.mesh.mshcfg.dot11MeshHoldingTimeout, DEC);
00399 IEEE80211_IF_FILE(dot11MeshTTL, u.mesh.mshcfg.dot11MeshTTL, DEC);
00400 IEEE80211_IF_FILE(element_ttl, u.mesh.mshcfg.element_ttl, DEC);
00401 IEEE80211_IF_FILE(auto_open_plinks, u.mesh.mshcfg.auto_open_plinks, DEC);
00402 IEEE80211_IF_FILE(dot11MeshMaxPeerLinks,
00403                 u.mesh.mshcfg.dot11MeshMaxPeerLinks, DEC);
00404 IEEE80211_IF_FILE(dot11MeshHWMPactivePathTimeout,
00405                 u.mesh.mshcfg.dot11MeshHWMPactivePathTimeout, DEC);
00406 IEEE80211_IF_FILE(dot11MeshHWMPpreqMinInterval,
00407                 u.mesh.mshcfg.dot11MeshHWMPpreqMinInterval, DEC);
00408 IEEE80211_IF_FILE(dot11MeshHWMPnetDiameterTraversalTime,
00409                 u.mesh.mshcfg.dot11MeshHWMPnetDiameterTraversalTime, DEC);
00410 IEEE80211_IF_FILE(dot11MeshHWMPmaxPREQretries,
00411                 u.mesh.mshcfg.dot11MeshHWMPmaxPREQretries, DEC);
00412 IEEE80211_IF_FILE(path_refresh_time,
00413                 u.mesh.mshcfg.path_refresh_time, DEC);
00414 IEEE80211_IF_FILE(min_discovery_timeout,
00415                 u.mesh.mshcfg.min_discovery_timeout, DEC);
00416 IEEE80211_IF_FILE(dot11MeshHWMPRootMode,
00417                 u.mesh.mshcfg.dot11MeshHWMPRootMode, DEC);
00418 IEEE80211_IF_FILE(dot11MeshGateAnnouncementProtocol,
00419                 u.mesh.mshcfg.dot11MeshGateAnnouncementProtocol, DEC);
00420 IEEE80211_IF_FILE(dot11MeshHWMPRannInterval,
00421                 u.mesh.mshcfg.dot11MeshHWMPRannInterval, DEC);
00422 #endif
00423 
00424 
00425 #define DEBUGFS_ADD(name) \
00426         debugfs_create_file(#name, 0400, sdata->debugfs.dir, \
00427                             sdata, &name##_ops);
00428 
00429 #define DEBUGFS_ADD_MODE(name, mode) \
00430         debugfs_create_file(#name, mode, sdata->debugfs.dir, \
00431                             sdata, &name##_ops);
00432 
00433 static void add_sta_files(struct ieee80211_sub_if_data *sdata)
00434 {
00435         DEBUGFS_ADD(drop_unencrypted);
00436         DEBUGFS_ADD(flags);
00437         DEBUGFS_ADD(state);
00438         DEBUGFS_ADD(channel_type);
00439         DEBUGFS_ADD(rc_rateidx_mask_2ghz);
00440         DEBUGFS_ADD(rc_rateidx_mask_5ghz);
00441 
00442         DEBUGFS_ADD(bssid);
00443         DEBUGFS_ADD(aid);
00444         DEBUGFS_ADD(last_beacon);
00445         DEBUGFS_ADD(ave_beacon);
00446         DEBUGFS_ADD_MODE(smps, 0600);
00447         DEBUGFS_ADD_MODE(tkip_mic_test, 0200);
00448 }
00449 
00450 static void add_ap_files(struct ieee80211_sub_if_data *sdata)
00451 {
00452         DEBUGFS_ADD(drop_unencrypted);
00453         DEBUGFS_ADD(flags);
00454         DEBUGFS_ADD(state);
00455         DEBUGFS_ADD(channel_type);
00456         DEBUGFS_ADD(rc_rateidx_mask_2ghz);
00457         DEBUGFS_ADD(rc_rateidx_mask_5ghz);
00458 
00459         DEBUGFS_ADD(num_sta_ps);
00460         DEBUGFS_ADD(dtim_count);
00461         DEBUGFS_ADD(num_buffered_multicast);
00462         DEBUGFS_ADD_MODE(tkip_mic_test, 0200);
00463 }
00464 
00465 static void add_ibss_files(struct ieee80211_sub_if_data *sdata)
00466 {
00467         DEBUGFS_ADD_MODE(tsf, 0600);
00468 }
00469 
00470 static void add_wds_files(struct ieee80211_sub_if_data *sdata)
00471 {
00472         DEBUGFS_ADD(drop_unencrypted);
00473         DEBUGFS_ADD(flags);
00474         DEBUGFS_ADD(state);
00475         DEBUGFS_ADD(channel_type);
00476         DEBUGFS_ADD(rc_rateidx_mask_2ghz);
00477         DEBUGFS_ADD(rc_rateidx_mask_5ghz);
00478 
00479         DEBUGFS_ADD(peer);
00480 }
00481 
00482 static void add_vlan_files(struct ieee80211_sub_if_data *sdata)
00483 {
00484         DEBUGFS_ADD(drop_unencrypted);
00485         DEBUGFS_ADD(flags);
00486         DEBUGFS_ADD(state);
00487         DEBUGFS_ADD(channel_type);
00488         DEBUGFS_ADD(rc_rateidx_mask_2ghz);
00489         DEBUGFS_ADD(rc_rateidx_mask_5ghz);
00490 }
00491 
00492 static void add_monitor_files(struct ieee80211_sub_if_data *sdata)
00493 {
00494         DEBUGFS_ADD(flags);
00495         DEBUGFS_ADD(state);
00496         DEBUGFS_ADD(channel_type);
00497 }
00498 
00499 #ifdef CONFIG_MAC80211_MESH
00500 
00501 static void add_mesh_stats(struct ieee80211_sub_if_data *sdata)
00502 {
00503         struct dentry *dir = debugfs_create_dir("mesh_stats",
00504                                                 sdata->debugfs.dir);
00505 
00506 #define MESHSTATS_ADD(name)\
00507         debugfs_create_file(#name, 0400, dir, sdata, &name##_ops);
00508 
00509         MESHSTATS_ADD(fwded_mcast);
00510         MESHSTATS_ADD(fwded_unicast);
00511         MESHSTATS_ADD(fwded_frames);
00512         MESHSTATS_ADD(dropped_frames_ttl);
00513         MESHSTATS_ADD(dropped_frames_no_route);
00514         MESHSTATS_ADD(dropped_frames_congestion);
00515         MESHSTATS_ADD(estab_plinks);
00516 #undef MESHSTATS_ADD
00517 }
00518 
00519 static void add_mesh_config(struct ieee80211_sub_if_data *sdata)
00520 {
00521         struct dentry *dir = debugfs_create_dir("mesh_config",
00522                                                 sdata->debugfs.dir);
00523 
00524 #define MESHPARAMS_ADD(name) \
00525         debugfs_create_file(#name, 0600, dir, sdata, &name##_ops);
00526 
00527         MESHPARAMS_ADD(dot11MeshMaxRetries);
00528         MESHPARAMS_ADD(dot11MeshRetryTimeout);
00529         MESHPARAMS_ADD(dot11MeshConfirmTimeout);
00530         MESHPARAMS_ADD(dot11MeshHoldingTimeout);
00531         MESHPARAMS_ADD(dot11MeshTTL);
00532         MESHPARAMS_ADD(element_ttl);
00533         MESHPARAMS_ADD(auto_open_plinks);
00534         MESHPARAMS_ADD(dot11MeshMaxPeerLinks);
00535         MESHPARAMS_ADD(dot11MeshHWMPactivePathTimeout);
00536         MESHPARAMS_ADD(dot11MeshHWMPpreqMinInterval);
00537         MESHPARAMS_ADD(dot11MeshHWMPnetDiameterTraversalTime);
00538         MESHPARAMS_ADD(dot11MeshHWMPmaxPREQretries);
00539         MESHPARAMS_ADD(path_refresh_time);
00540         MESHPARAMS_ADD(min_discovery_timeout);
00541         MESHPARAMS_ADD(dot11MeshHWMPRootMode);
00542         MESHPARAMS_ADD(dot11MeshHWMPRannInterval);
00543         MESHPARAMS_ADD(dot11MeshGateAnnouncementProtocol);
00544 #undef MESHPARAMS_ADD
00545 }
00546 #endif
00547 
00548 static void add_files(struct ieee80211_sub_if_data *sdata)
00549 {
00550         if (!sdata->debugfs.dir)
00551                 return;
00552 
00553         switch (sdata->vif.type) {
00554         case NL80211_IFTYPE_MESH_POINT:
00555 #ifdef CONFIG_MAC80211_MESH
00556                 add_mesh_stats(sdata);
00557                 add_mesh_config(sdata);
00558 #endif
00559                 break;
00560         case NL80211_IFTYPE_STATION:
00561                 add_sta_files(sdata);
00562                 break;
00563         case NL80211_IFTYPE_ADHOC:
00564                 add_ibss_files(sdata);
00565                 break;
00566         case NL80211_IFTYPE_AP:
00567                 add_ap_files(sdata);
00568                 break;
00569         case NL80211_IFTYPE_WDS:
00570                 add_wds_files(sdata);
00571                 break;
00572         case NL80211_IFTYPE_MONITOR:
00573                 add_monitor_files(sdata);
00574                 break;
00575         case NL80211_IFTYPE_AP_VLAN:
00576                 add_vlan_files(sdata);
00577                 break;
00578         default:
00579                 break;
00580         }
00581 }
00582 
00583 void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata)
00584 {
00585         char buf[10+IFNAMSIZ];
00586 
00587         sprintf(buf, "netdev:%s", sdata->name);
00588         sdata->debugfs.dir = debugfs_create_dir(buf,
00589                 sdata->local->hw.wiphy->debugfsdir);
00590         if (sdata->debugfs.dir)
00591                 sdata->debugfs.subdir_stations = debugfs_create_dir("stations",
00592                         sdata->debugfs.dir);
00593         add_files(sdata);
00594 }
00595 
00596 void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata)
00597 {
00598         if (!sdata->debugfs.dir)
00599                 return;
00600 
00601         debugfs_remove_recursive(sdata->debugfs.dir);
00602         sdata->debugfs.dir = NULL;
00603 }
00604 
00605 void ieee80211_debugfs_rename_netdev(struct ieee80211_sub_if_data *sdata)
00606 {
00607         struct dentry *dir;
00608         char buf[10 + IFNAMSIZ];
00609 
00610         dir = sdata->debugfs.dir;
00611 
00612         if (!dir)
00613                 return;
00614 
00615         sprintf(buf, "netdev:%s", sdata->name);
00616         if (!debugfs_rename(dir->d_parent, dir, dir->d_parent, buf))
00617                 printk(KERN_ERR "mac80211: debugfs: failed to rename debugfs "
00618                        "dir to %s\n", buf);
00619 }


ros_rt_wmp
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Fri Jan 3 2014 12:07:54