libertas: convert getscantable from wlanconfig to debugfs
Marcelo Tosatti
mtosatti at redhat.unroutablecom
Tue Nov 28 02:56:39 EST 2006
Commit: 5933cb03edfdfdb503afdab8ccef09ce6efc255a
Parent: 2cc736bd55520232338fd64a23ff5f6368590cbb
commit 5933cb03edfdfdb503afdab8ccef09ce6efc255a
Author: Marcelo Tosatti <mtosatti at redhat.com>
AuthorDate: Thu Nov 16 03:04:07 2006 -0200
Commit: Marcelo Tosatti <mtosatti at redhat.com>
CommitDate: Thu Nov 16 03:04:07 2006 -0200
libertas: convert getscantable from wlanconfig to debugfs
Subject says it all.
Signed-off-by: Marcelo Tosatti <mtosatti at redhat.com>
---
drivers/net/wireless/libertas/wlan_debugfs.c | 65 +++++++++
drivers/net/wireless/libertas/wlan_dev.h | 2
drivers/net/wireless/libertas/wlan_ioctl.c | 4 -
drivers/net/wireless/libertas/wlan_scan.c | 198 --------------------------
drivers/net/wireless/libertas/wlan_scan.h | 76 ----------
drivers/net/wireless/libertas/wlan_wext.c | 5 -
drivers/net/wireless/libertas/wlan_wext.h | 1
7 files changed, 67 insertions(+), 284 deletions(-)
diff --git a/drivers/net/wireless/libertas/wlan_debugfs.c b/drivers/net/wireless/libertas/wlan_debugfs.c
index 9d5079e..b16df4b 100644
--- a/drivers/net/wireless/libertas/wlan_debugfs.c
+++ b/drivers/net/wireless/libertas/wlan_debugfs.c
@@ -52,6 +52,59 @@ static ssize_t libertas_dev_info(struct
return res;
}
+
+static ssize_t libertas_getscantable(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ wlan_private *priv = file->private_data;
+ size_t pos = 0;
+ const size_t len = big_buffer_len;
+ char *buf = big_buffer;
+ int numScansDone = 0, res;
+
+ down(&big_buffer_sem);
+
+ pos += snprintf(buf+pos, len-pos,
+ "---------------------------------------");
+ pos += snprintf(buf+pos, len-pos,
+ "---------------------------------------\n");
+ pos += snprintf(buf+pos, len-pos,
+ "# | ch | ss | bssid | cap | TSF | SSID\n");
+ pos += snprintf(buf+pos, len-pos,
+ "---------------------------------------");
+ pos += snprintf(buf+pos, len-pos,
+ "---------------------------------------\n");
+
+ while (numScansDone < priv->adapter->NumInScanTable) {
+ struct bss_descriptor *pbssinfo;
+ u16 cap;
+
+ pbssinfo = &priv->adapter->ScanTable[numScansDone];
+ memcpy(&cap, &pbssinfo->Cap, sizeof(cap));
+ pos += snprintf(buf+pos, len-pos,
+ "%02u| %03d | %03ld | %02x:%02x:%02x:%02x:%02x:%02x |",
+ numScansDone, pbssinfo->Channel, pbssinfo->Rssi,
+ pbssinfo->MacAddress[0], pbssinfo->MacAddress[1],
+ pbssinfo->MacAddress[2], pbssinfo->MacAddress[3],
+ pbssinfo->MacAddress[4], pbssinfo->MacAddress[5]);
+ pos += snprintf(buf+pos, len-pos, " %04x-", cap);
+ pos += snprintf(buf+pos, len-pos, "%c%c%c |",
+ pbssinfo->Cap.Ibss ? 'A' : 'I',
+ pbssinfo->Cap.Privacy ? 'P' : ' ',
+ pbssinfo->Cap.SpectrumMgmt ? 'S' : ' ');
+ pos += snprintf(buf+pos, len-pos, " %08llx |", pbssinfo->networkTSF);
+ pos += snprintf(buf+pos, len-pos, " %s\n", pbssinfo->Ssid.Ssid);
+ numScansDone++;
+ }
+
+ res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+
+ up(&big_buffer_sem);
+
+ return res;
+}
+
+
static struct file_operations libertas_devinfo_fops = {
.owner = THIS_MODULE,
.open = open_file_generic,
@@ -59,6 +112,13 @@ static struct file_operations libertas_d
.read = libertas_dev_info,
};
+static struct file_operations libertas_getscantable_fops = {
+ .owner = THIS_MODULE,
+ .open = open_file_generic,
+ .write = write_file_dummy,
+ .read = libertas_getscantable,
+};
+
void libertas_debugfs_init(void)
{
if (!libertas_dir)
@@ -91,6 +151,11 @@ void libertas_debugfs_init_one(wlan_priv
if (!priv->debugfs_devinfo)
goto exit;
+ priv->debugfs_getscantable = debugfs_create_file("getscantable", 0444,
+ priv->debugfs_dir,
+ priv,
+ &libertas_getscantable_fops);
+
#ifdef PROC_DEBUG
libertas_debug_init(priv, dev);
#endif
diff --git a/drivers/net/wireless/libertas/wlan_dev.h b/drivers/net/wireless/libertas/wlan_dev.h
index 8732520..d7f3920 100644
--- a/drivers/net/wireless/libertas/wlan_dev.h
+++ b/drivers/net/wireless/libertas/wlan_dev.h
@@ -172,6 +172,8 @@ struct _wlan_private {
struct dentry *debugfs_dir;
struct dentry *debugfs_devinfo;
struct dentry *debugfs_debug;
+ struct dentry *debugfs_getscantable;
+
const struct firmware *firmware;
struct device *hotplug_device;
diff --git a/drivers/net/wireless/libertas/wlan_ioctl.c b/drivers/net/wireless/libertas/wlan_ioctl.c
index 601f03f..4e79171 100644
--- a/drivers/net/wireless/libertas/wlan_ioctl.c
+++ b/drivers/net/wireless/libertas/wlan_ioctl.c
@@ -2713,10 +2713,6 @@ #define MAX_U16_VAL 65535
case WLAN_SET_USER_SCAN:
ret = libertas_set_user_scan_ioctl(priv, wrq);
break;
- case WLAN_GET_SCAN_TABLE:
- ret = libertas_get_scan_table_ioctl(priv, wrq);
- break;
-
default:
ret = -EOPNOTSUPP;
}
diff --git a/drivers/net/wireless/libertas/wlan_scan.c b/drivers/net/wireless/libertas/wlan_scan.c
index 9568724..91de20f 100644
--- a/drivers/net/wireless/libertas/wlan_scan.c
+++ b/drivers/net/wireless/libertas/wlan_scan.c
@@ -872,63 +872,6 @@ out:
}
/**
- * @brief Create a brief scan resp to relay basic BSS info to the app layer
- *
- * When the beacon/probe response has not been buffered, use the fixed field
- * information available to provide a minimum response for the application
- * ioctl retrieval routines.
- *
- * @param ppBuffer Output parameter: Buffer used to create basic scan rsp
- * @param pBssDesc Pointer to a BSS entry in the scan table to create
- * scan response from for delivery to the application layer
- *
- * @return void
- */
-static void wlan_scan_create_brief_scan_table(u8 ** ppBuffer,
- struct bss_descriptor * pBssDesc)
-{
- u8 *pTmpBuf = *ppBuffer;
- u8 tmpSSIDHdr[2];
-
- if (copy_to_user
- (pTmpBuf, pBssDesc->TimeStamp, sizeof(pBssDesc->TimeStamp))) {
- dprintk(1, "Copy to user failed\n");
- return;
- }
- pTmpBuf += sizeof(pBssDesc->TimeStamp);
-
- if (copy_to_user(pTmpBuf, &pBssDesc->BeaconPeriod,
- sizeof(pBssDesc->BeaconPeriod))) {
- dprintk(1, "Copy to user failed\n");
- return;
- }
- pTmpBuf += sizeof(pBssDesc->BeaconPeriod);
-
- if (copy_to_user(pTmpBuf, &pBssDesc->Cap, sizeof(pBssDesc->Cap))) {
- dprintk(1, "Copy to user failed\n");
- return;
- }
- pTmpBuf += sizeof(pBssDesc->Cap);
-
- tmpSSIDHdr[0] = 0; /* Element ID for SSID is zero */
- tmpSSIDHdr[1] = pBssDesc->Ssid.SsidLength;
- if (copy_to_user(pTmpBuf, tmpSSIDHdr, sizeof(tmpSSIDHdr))) {
- dprintk(1, "Copy to user failed\n");
- return;
- }
- pTmpBuf += sizeof(tmpSSIDHdr);
-
- if (copy_to_user(pTmpBuf, pBssDesc->Ssid.Ssid,
- pBssDesc->Ssid.SsidLength)) {
- dprintk(1, "Copy to user failed\n");
- return;
- }
- pTmpBuf += pBssDesc->Ssid.SsidLength;
-
- *ppBuffer = pTmpBuf;
-}
-
-/**
* @brief Inspect the scan response buffer for pointers to expected TLVs
*
* TLVs can be included at the end of the scan response BSS information.
@@ -1894,147 +1837,6 @@ #define RSSI_DIFF ((u8)(PERFECT_RSSI
}
/**
- * @brief Retrieve the scan response/beacon table
- *
- * @param priv A pointer to wlan_private structure
- * @param wrq A pointer to iwreq structure
- *
- * @return WLAN_STATUS_SUCCESS --success, otherwise fail
- */
-int libertas_get_scan_table_ioctl(wlan_private * priv, struct iwreq *wrq)
-{
- wlan_adapter *Adapter;
- struct bss_descriptor *pBssInfo;
- struct wlan_ioctl_get_scan_table_info *pRspInfo;
- struct wlan_ioctl_get_scan_table_entry *pRspEntry;
- struct wlan_ioctl_get_scan_table_entry tmpRspEntry;
- int retcode;
- int retlen;
- int spaceNeeded;
- int spaceLeft;
- u8 *pCurrent;
- u8 *pBufferEnd;
- u32 scanStart;
- u32 numScansDone;
- int variableSize;
-
- const int fixedSize = (sizeof(tmpRspEntry.fixedFieldLength)
- + sizeof(tmpRspEntry.fixedFields)
- + sizeof(tmpRspEntry.bssInfoLength));
-
- retlen = 0;
-
- if (copy_from_user(&scanStart,
- wrq->u.data.pointer, sizeof(scanStart)) != 0) {
- /* copy_from_user failed */
- dprintk(1, "GetScanTable: copy from user failed\n");
- retcode = -EFAULT;
-
- } else {
-
- dprintk(1, "GetScanTable: scanStart req = %d\n", scanStart);
- dprintk(1, "GetScanTable: length avail = %d\n",
- wrq->u.data.length);
-
- Adapter = priv->adapter;
-
- numScansDone = 0;
-
- pRspInfo =
- (struct wlan_ioctl_get_scan_table_info *) wrq->u.data.pointer;
- pCurrent = pRspInfo->scan_table_entry_buffer;
- pBufferEnd = wrq->u.data.pointer + wrq->u.data.length - 1;
- spaceLeft = pBufferEnd - pCurrent;
-
- while (spaceLeft &&
- scanStart + numScansDone < Adapter->NumInScanTable) {
-
- pBssInfo =
- &Adapter->ScanTable[scanStart + numScansDone];
-
- /* No beacon stored, variable size set to 0 */
- variableSize = 0;
-
- /* If we stored a beacon and its size was zero, set the variable
- * size return value to the size of the brief scan response
- * wlan_scan_create_brief_scan_table creates. Also used if
- * we are not configured to store beacons in the first place
- */
- if (variableSize == 0) {
- variableSize = pBssInfo->Ssid.SsidLength + 2;
- variableSize += (sizeof(pBssInfo->BeaconPeriod)
- + sizeof(pBssInfo->TimeStamp)
- + sizeof(pBssInfo->Cap));
- }
-
- spaceNeeded = fixedSize + variableSize;
- spaceLeft = pBufferEnd - pCurrent;
-
- dprintk(1,
- "GetScanTable: bss[%d], need(%d), left(%d)\n",
- scanStart + numScansDone, spaceNeeded,
- spaceLeft);
-
- if (spaceNeeded >= spaceLeft) {
- spaceLeft = 0;
- } else {
-
- dprintk(1, "GetScanTable: bss[%d] = "
- "%02x:%02x:%02x:%02x:%02x:%02x\n",
- scanStart + numScansDone,
- pBssInfo->MacAddress[0],
- pBssInfo->MacAddress[1],
- pBssInfo->MacAddress[2],
- pBssInfo->MacAddress[3],
- pBssInfo->MacAddress[4],
- pBssInfo->MacAddress[5]);
-
- tmpRspEntry.fixedFieldLength
- = sizeof(pRspEntry->fixedFields);
-
- memcpy(tmpRspEntry.fixedFields.bssid,
- pBssInfo->MacAddress,
- sizeof(pRspEntry->fixedFields.bssid));
-
- tmpRspEntry.fixedFields.rssi = pBssInfo->Rssi;
- tmpRspEntry.fixedFields.channel =
- pBssInfo->Channel;
- tmpRspEntry.fixedFields.networkTSF =
- pBssInfo->networkTSF;
- tmpRspEntry.bssInfoLength = variableSize;
-
- /*
- * Copy fixed fields to user space
- */
- if (copy_to_user
- (pCurrent, &tmpRspEntry, fixedSize)) {
- dprintk(1, "Copy to user failed\n");
- return -EFAULT;
- }
-
- pCurrent += fixedSize;
-
- wlan_scan_create_brief_scan_table(&pCurrent,
- pBssInfo);
-
- numScansDone++;
-
- } /* else */
-
- } /* while (spaceLeft && ... ) */
-
- pRspInfo->scanNumber = numScansDone;
- retlen = pCurrent - (u8 *) wrq->u.data.pointer;
-
- retcode = WLAN_STATUS_SUCCESS;
- }
-
- wrq->u.data.length = retlen;
-
- return retcode;
-}
-
-/**
* @brief Private IOCTL entry to perform an app configured immediate scan
*
* @param priv A pointer to wlan_private structure
diff --git a/drivers/net/wireless/libertas/wlan_scan.h b/drivers/net/wireless/libertas/wlan_scan.h
index 820743c..f77ae91 100644
--- a/drivers/net/wireless/libertas/wlan_scan.h
+++ b/drivers/net/wireless/libertas/wlan_scan.h
@@ -162,81 +162,6 @@ struct wlan_ioctl_user_scan_cfg {
} __attribute__ ((packed));
/**
- * @brief Sub-structure passed in wlan_ioctl_get_scan_table_entry for each BSS
- *
- * Fixed field information returned for the scan response in the IOCTL
- * response.
- */
-struct wlan_ioctl_get_scan_table_fixed {
- u8 bssid[6]; //!< BSSID of this network
- u8 channel; //!< Channel this beacon/probe response was detected
- u8 rssi; //!< RSSI for the received packet
- u64 networkTSF; //!< TSF value from the firmware at packet reception
-} __attribute__ ((packed));
-
-/**
- * @brief Structure passed in the wlan_ioctl_get_scan_table_info for each
- * BSS returned in the WLAN_GET_SCAN_RESP IOCTL
- *
- * @sa libertas_get_scan_table_ioctl
- */
-struct wlan_ioctl_get_scan_table_entry {
-
- /**
- * @brief Fixed field length included in the response.
- *
- * Length value is included so future fixed fields can be added to the
- * response without breaking backwards compatibility. Use the length
- * to find the offset for the bssInfoLength field, not a sizeof() calc.
- */
- u32 fixedFieldLength;
-
- /**
- * @brief Always present, fixed length data fields for the BSS
- */
- struct wlan_ioctl_get_scan_table_fixed fixedFields;
-
- /**
- * @brief Length of the BSS Information (probe resp or beacon) that
- * follows starting at bssInfoBuffer
- */
- u32 bssInfoLength;
-
- /**
- * @brief Probe response or beacon scanned for the BSS.
- *
- * Field layout:
- * - TSF 8 octets
- * - Beacon Interval 2 octets
- * - Capability Info 2 octets
- *
- * - IEEE Infomation Elements; variable number & length per 802.11 spec
- */
- u8 bssInfoBuffer[1];
-} __attribute__ ((packed));
-
-/**
- * @brief WLAN_GET_SCAN_RESP private IOCTL struct to retrieve the scan table
- *
- * @sa libertas_get_scan_table_ioctl
- */
-struct wlan_ioctl_get_scan_table_info {
-
- /**
- * - Zero based scan entry to start retrieval in command request
- * - Number of scans entires returned in command response
- */
- u32 scanNumber;
-
- /**
- * Buffer marker for multiple wlan_ioctl_get_scan_table_entry structures.
- * Each struct is padded to the nearest 32 bit boundary.
- */
- u8 scan_table_entry_buffer[1];
-
-} __attribute__ ((packed));
-
-/**
* @brief Structure used to store information for each beacon/probe response
*/
struct bss_descriptor {
@@ -295,7 +220,6 @@ extern int libertas_send_specific_SSID_s
extern int libertas_send_specific_BSSID_scan(wlan_private * priv,
u8 * bssid, u8 keepPreviousScan);
-extern int libertas_get_scan_table_ioctl(wlan_private * priv, struct iwreq *wrq);
extern int libertas_set_user_scan_ioctl(wlan_private * priv, struct iwreq *wrq);
extern int libertas_cmd_80211_scan(wlan_private * priv,
diff --git a/drivers/net/wireless/libertas/wlan_wext.c b/drivers/net/wireless/libertas/wlan_wext.c
index 5e1389c..227f8fa 100644
--- a/drivers/net/wireless/libertas/wlan_wext.c
+++ b/drivers/net/wireless/libertas/wlan_wext.c
@@ -1685,11 +1685,6 @@ #endif /* REASSOCIATION */
IW_PRIV_TYPE_BYTE | 2000,
IW_PRIV_TYPE_BYTE | 2000,
"setuserscan"},
- {
- WLAN_GET_SCAN_TABLE,
- IW_PRIV_TYPE_BYTE | 2000,
- IW_PRIV_TYPE_BYTE | 2000,
- "getscantable"},
};
/**
diff --git a/drivers/net/wireless/libertas/wlan_wext.h b/drivers/net/wireless/libertas/wlan_wext.h
index 291928a..f991dc8 100644
--- a/drivers/net/wireless/libertas/wlan_wext.h
+++ b/drivers/net/wireless/libertas/wlan_wext.h
@@ -76,7 +76,6 @@ #define WLANSCAN_TYPE (WLANIOCTL + 11)
#define WLAN_SET_GET_2K (WLANIOCTL + 13)
#define WLAN_SET_USER_SCAN 1
-#define WLAN_GET_SCAN_TABLE 2
#define WLAN_SETNONE_GETONEINT (WLANIOCTL + 15)
#define WLANGETREGION 1
More information about the Commits-kernel
mailing list