// SPDX-License-Identifier: GPL-2.0-only
/*
* nxpwifi: debugfs
*
* Copyright 2011-2024 NXP
*/
#include <linux/debugfs.h>
#include "main.h"
#include "cmdevt.h"
#include "11n.h"
static struct dentry *nxpwifi_dfs_dir;
static char *bss_modes[] = {
"UNSPECIFIED",
"ADHOC",
"STATION",
"AP",
"AP_VLAN",
"WDS",
"MONITOR",
"MESH_POINT",
"P2P_CLIENT",
"P2P_GO",
"P2P_DEVICE",
};
/*
* debugfs "info" read handler: dump driver name/version, interface, BSS mode,
* link state, MAC, counters; STA adds SSID/BSSID/channel/country/region and
* multicast list.
*/
static ssize_t
nxpwifi_info_read(struct file *file, char __user *ubuf,
size_t count, loff_t *ppos)
{
struct nxpwifi_private *priv =
(struct nxpwifi_private *)file->private_data;
struct net_device *netdev = priv->netdev;
struct netdev_hw_addr *ha;
struct netdev_queue *txq;
unsigned long page = get_zeroed_page(GFP_KERNEL);
char *p = (char *)page, fmt[64];
struct nxpwifi_bss_info info;
ssize_t ret;
int i = 0;
if (!p)
return -ENOMEM;
memset(&info, 0, sizeof(info));
ret = nxpwifi_get_bss_info(priv, &info);
if (ret)
goto free_and_exit;
nxpwifi_drv_get_driver_version(priv->adapter, fmt, sizeof(fmt) - 1);
nxpwifi_get_ver_ext(priv, 0);
p += sprintf(p, "driver_name = ");
p += sprintf(p, "\"nxpwifi\"\n");
p += sprintf(p, "driver_version = %s", fmt);
p += sprintf(p, "\nverext = %s", priv->version_str);
p += sprintf(p, "\ninterface_name=\"%s\"\n", netdev->name);
if (info.bss_mode >= ARRAY_SIZE(bss_modes))
p += sprintf(p, "bss_mode=\"%d\"\n", info.bss_mode);
else
p += sprintf(p, "bss_mode=\"%s\"\n", bss_modes[info.bss_mode]);
p += sprintf(p, "media_state=\"%s\"\n",
(!priv->media_connected ? "Disconnected" : "Connected"));
p += sprintf(p, "mac_address=\"%pM\"\n", netdev->dev_addr);
if (GET_BSS_ROLE(priv) == NXPWIFI_BSS_ROLE_STA) {
p += sprintf(p, "multicast_count=\"%d\"\n",
netdev_mc_count(netdev));
p += sprintf(p, "essid=\"%.*s\"\n", info.ssid.ssid_len,
info.ssid.ssid);
p += sprintf(p, "bssid=\"%pM\"\n", info.bssid);
p += sprintf(p, "channel=\"%d\"\n", (int)info.bss_chan);
p += sprintf(p, "country_code = \"%s\"\n", info.country_code);
p += sprintf(p, "region_code=\"0x%x\"\n",
priv->adapter->region_code);
netdev_for_each_mc_addr(ha, netdev)
p += sprintf(p, "multicast_address[%d]=\"%pM\"\n",
i++, ha->addr);
}
p +=