License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2011-05-03 07:49:14 +08:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2008-05-18 12:01:24 +08:00
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/etherdevice.h>
|
2011-06-06 18:43:46 +08:00
|
|
|
#include <linux/hardirq.h>
|
2008-05-18 12:01:24 +08:00
|
|
|
#include <linux/netdevice.h>
|
2009-12-24 16:11:24 +08:00
|
|
|
#include <linux/if_ether.h>
|
2008-05-18 12:01:24 +08:00
|
|
|
#include <linux/if_arp.h>
|
|
|
|
#include <linux/kthread.h>
|
|
|
|
#include <linux/kfifo.h>
|
2010-06-15 00:31:26 +08:00
|
|
|
#include <net/cfg80211.h>
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2009-11-25 20:10:15 +08:00
|
|
|
#include "mesh.h"
|
2008-05-18 12:01:24 +08:00
|
|
|
#include "decl.h"
|
|
|
|
#include "cmd.h"
|
|
|
|
|
2009-11-25 20:10:15 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
static int lbs_add_mesh(struct lbs_private *priv);
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* Mesh command handling
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int lbs_mesh_access(struct lbs_private *priv, uint16_t cmd_action,
|
|
|
|
struct cmd_ds_mesh_access *cmd)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
cmd->hdr.command = cpu_to_le16(CMD_MESH_ACCESS);
|
|
|
|
cmd->hdr.size = cpu_to_le16(sizeof(*cmd));
|
|
|
|
cmd->hdr.result = 0;
|
|
|
|
|
|
|
|
cmd->action = cpu_to_le16(cmd_action);
|
|
|
|
|
|
|
|
ret = lbs_cmd_with_response(priv, CMD_MESH_ACCESS, cmd);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __lbs_mesh_config_send(struct lbs_private *priv,
|
|
|
|
struct cmd_ds_mesh_config *cmd,
|
|
|
|
uint16_t action, uint16_t type)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
u16 command = CMD_MESH_CONFIG_OLD;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Command id is 0xac for v10 FW along with mesh interface
|
|
|
|
* id in bits 14-13-12.
|
|
|
|
*/
|
|
|
|
if (priv->mesh_tlv == TLV_TYPE_MESH_ID)
|
|
|
|
command = CMD_MESH_CONFIG |
|
|
|
|
(MESH_IFACE_ID << MESH_IFACE_BIT_OFFSET);
|
|
|
|
|
|
|
|
cmd->hdr.command = cpu_to_le16(command);
|
|
|
|
cmd->hdr.size = cpu_to_le16(sizeof(struct cmd_ds_mesh_config));
|
|
|
|
cmd->hdr.result = 0;
|
|
|
|
|
|
|
|
cmd->type = cpu_to_le16(type);
|
|
|
|
cmd->action = cpu_to_le16(action);
|
|
|
|
|
|
|
|
ret = lbs_cmd_with_response(priv, command, cmd);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int lbs_mesh_config_send(struct lbs_private *priv,
|
|
|
|
struct cmd_ds_mesh_config *cmd,
|
|
|
|
uint16_t action, uint16_t type)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!(priv->fwcapinfo & FW_CAPINFO_PERSISTENT_CONFIG))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
ret = __lbs_mesh_config_send(priv, cmd, action, type);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This function is the CMD_MESH_CONFIG legacy function. It only handles the
|
|
|
|
* START and STOP actions. The extended actions supported by CMD_MESH_CONFIG
|
|
|
|
* are all handled by preparing a struct cmd_ds_mesh_config and passing it to
|
|
|
|
* lbs_mesh_config_send.
|
|
|
|
*/
|
|
|
|
static int lbs_mesh_config(struct lbs_private *priv, uint16_t action,
|
|
|
|
uint16_t chan)
|
|
|
|
{
|
|
|
|
struct cmd_ds_mesh_config cmd;
|
|
|
|
struct mrvl_meshie *ie;
|
|
|
|
|
|
|
|
memset(&cmd, 0, sizeof(cmd));
|
|
|
|
cmd.channel = cpu_to_le16(chan);
|
|
|
|
ie = (struct mrvl_meshie *)cmd.data;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case CMD_ACT_MESH_CONFIG_START:
|
2012-10-12 18:28:14 +08:00
|
|
|
ie->id = WLAN_EID_VENDOR_SPECIFIC;
|
2011-07-21 00:53:50 +08:00
|
|
|
ie->val.oui[0] = 0x00;
|
|
|
|
ie->val.oui[1] = 0x50;
|
|
|
|
ie->val.oui[2] = 0x43;
|
|
|
|
ie->val.type = MARVELL_MESH_IE_TYPE;
|
|
|
|
ie->val.subtype = MARVELL_MESH_IE_SUBTYPE;
|
|
|
|
ie->val.version = MARVELL_MESH_IE_VERSION;
|
|
|
|
ie->val.active_protocol_id = MARVELL_MESH_PROTO_ID_HWMP;
|
|
|
|
ie->val.active_metric_id = MARVELL_MESH_METRIC_ID;
|
|
|
|
ie->val.mesh_capability = MARVELL_MESH_CAPABILITY;
|
|
|
|
ie->val.mesh_id_len = priv->mesh_ssid_len;
|
|
|
|
memcpy(ie->val.mesh_id, priv->mesh_ssid, priv->mesh_ssid_len);
|
|
|
|
ie->len = sizeof(struct mrvl_meshie_val) -
|
|
|
|
IEEE80211_MAX_SSID_LEN + priv->mesh_ssid_len;
|
|
|
|
cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie_val));
|
|
|
|
break;
|
|
|
|
case CMD_ACT_MESH_CONFIG_STOP:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
2014-10-14 06:55:20 +08:00
|
|
|
lbs_deb_cmd("mesh config action %d type %x channel %d SSID %*pE\n",
|
|
|
|
action, priv->mesh_tlv, chan, priv->mesh_ssid_len,
|
|
|
|
priv->mesh_ssid);
|
2011-07-21 00:53:50 +08:00
|
|
|
|
|
|
|
return __lbs_mesh_config_send(priv, &cmd, action, priv->mesh_tlv);
|
|
|
|
}
|
|
|
|
|
2011-07-22 03:43:17 +08:00
|
|
|
int lbs_mesh_set_channel(struct lbs_private *priv, u8 channel)
|
|
|
|
{
|
2012-06-06 14:18:22 +08:00
|
|
|
priv->mesh_channel = channel;
|
2011-07-22 03:43:17 +08:00
|
|
|
return lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint16_t lbs_mesh_get_channel(struct lbs_private *priv)
|
|
|
|
{
|
2012-06-06 14:18:22 +08:00
|
|
|
return priv->mesh_channel ?: 1;
|
2011-07-22 03:43:17 +08:00
|
|
|
}
|
2011-07-21 00:53:50 +08:00
|
|
|
|
2009-11-25 20:10:15 +08:00
|
|
|
/***************************************************************************
|
|
|
|
* Mesh sysfs support
|
|
|
|
*/
|
|
|
|
|
2011-04-27 06:25:29 +08:00
|
|
|
/*
|
2009-11-25 20:10:15 +08:00
|
|
|
* Attributes exported through sysfs
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2011-04-27 06:25:29 +08:00
|
|
|
* lbs_anycast_get - Get function for sysfs attribute anycast_mask
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer where data will be returned
|
2009-11-25 20:10:15 +08:00
|
|
|
*/
|
|
|
|
static ssize_t lbs_anycast_get(struct device *dev,
|
|
|
|
struct device_attribute *attr, char * buf)
|
|
|
|
{
|
|
|
|
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
|
|
|
struct cmd_ds_mesh_access mesh_access;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
memset(&mesh_access, 0, sizeof(mesh_access));
|
|
|
|
|
|
|
|
ret = lbs_mesh_access(priv, CMD_ACT_MESH_GET_ANYCAST, &mesh_access);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return snprintf(buf, 12, "0x%X\n", le32_to_cpu(mesh_access.data[0]));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-04-27 06:25:29 +08:00
|
|
|
* lbs_anycast_set - Set function for sysfs attribute anycast_mask
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer that contains new attribute value
|
|
|
|
* @count: size of buffer
|
2009-11-25 20:10:15 +08:00
|
|
|
*/
|
|
|
|
static ssize_t lbs_anycast_set(struct device *dev,
|
|
|
|
struct device_attribute *attr, const char * buf, size_t count)
|
|
|
|
{
|
|
|
|
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
|
|
|
struct cmd_ds_mesh_access mesh_access;
|
|
|
|
uint32_t datum;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
memset(&mesh_access, 0, sizeof(mesh_access));
|
|
|
|
sscanf(buf, "%x", &datum);
|
|
|
|
mesh_access.data[0] = cpu_to_le32(datum);
|
|
|
|
|
|
|
|
ret = lbs_mesh_access(priv, CMD_ACT_MESH_SET_ANYCAST, &mesh_access);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return strlen(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-04-27 06:25:29 +08:00
|
|
|
* lbs_prb_rsp_limit_get - Get function for sysfs attribute prb_rsp_limit
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer where data will be returned
|
2009-11-25 20:10:15 +08:00
|
|
|
*/
|
|
|
|
static ssize_t lbs_prb_rsp_limit_get(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
|
|
|
struct cmd_ds_mesh_access mesh_access;
|
|
|
|
int ret;
|
|
|
|
u32 retry_limit;
|
|
|
|
|
|
|
|
memset(&mesh_access, 0, sizeof(mesh_access));
|
|
|
|
mesh_access.data[0] = cpu_to_le32(CMD_ACT_GET);
|
|
|
|
|
|
|
|
ret = lbs_mesh_access(priv, CMD_ACT_MESH_SET_GET_PRB_RSP_LIMIT,
|
|
|
|
&mesh_access);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
retry_limit = le32_to_cpu(mesh_access.data[1]);
|
|
|
|
return snprintf(buf, 10, "%d\n", retry_limit);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-04-27 06:25:29 +08:00
|
|
|
* lbs_prb_rsp_limit_set - Set function for sysfs attribute prb_rsp_limit
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer that contains new attribute value
|
|
|
|
* @count: size of buffer
|
2009-11-25 20:10:15 +08:00
|
|
|
*/
|
|
|
|
static ssize_t lbs_prb_rsp_limit_set(struct device *dev,
|
|
|
|
struct device_attribute *attr, const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
|
|
|
struct cmd_ds_mesh_access mesh_access;
|
|
|
|
int ret;
|
|
|
|
unsigned long retry_limit;
|
|
|
|
|
|
|
|
memset(&mesh_access, 0, sizeof(mesh_access));
|
|
|
|
mesh_access.data[0] = cpu_to_le32(CMD_ACT_SET);
|
|
|
|
|
2017-06-23 23:17:38 +08:00
|
|
|
ret = kstrtoul(buf, 10, &retry_limit);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2009-11-25 20:10:15 +08:00
|
|
|
if (retry_limit > 15)
|
|
|
|
return -ENOTSUPP;
|
|
|
|
|
|
|
|
mesh_access.data[1] = cpu_to_le32(retry_limit);
|
|
|
|
|
|
|
|
ret = lbs_mesh_access(priv, CMD_ACT_MESH_SET_GET_PRB_RSP_LIMIT,
|
|
|
|
&mesh_access);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return strlen(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-04-27 06:25:29 +08:00
|
|
|
* lbs_mesh_get - Get function for sysfs attribute mesh
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer where data will be returned
|
2009-11-25 20:10:15 +08:00
|
|
|
*/
|
|
|
|
static ssize_t lbs_mesh_get(struct device *dev,
|
|
|
|
struct device_attribute *attr, char * buf)
|
|
|
|
{
|
|
|
|
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
|
|
|
return snprintf(buf, 5, "0x%X\n", !!priv->mesh_dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-04-27 06:25:29 +08:00
|
|
|
* lbs_mesh_set - Set function for sysfs attribute mesh
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer that contains new attribute value
|
|
|
|
* @count: size of buffer
|
2009-11-25 20:10:15 +08:00
|
|
|
*/
|
|
|
|
static ssize_t lbs_mesh_set(struct device *dev,
|
|
|
|
struct device_attribute *attr, const char * buf, size_t count)
|
|
|
|
{
|
|
|
|
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
|
|
|
int enable;
|
|
|
|
|
|
|
|
sscanf(buf, "%x", &enable);
|
|
|
|
enable = !!enable;
|
|
|
|
if (enable == !!priv->mesh_dev)
|
|
|
|
return count;
|
|
|
|
|
|
|
|
if (enable)
|
|
|
|
lbs_add_mesh(priv);
|
|
|
|
else
|
|
|
|
lbs_remove_mesh(priv);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2011-04-27 06:25:29 +08:00
|
|
|
/*
|
2009-11-25 20:10:15 +08:00
|
|
|
* lbs_mesh attribute to be exported per ethX interface
|
|
|
|
* through sysfs (/sys/class/net/ethX/lbs_mesh)
|
|
|
|
*/
|
|
|
|
static DEVICE_ATTR(lbs_mesh, 0644, lbs_mesh_get, lbs_mesh_set);
|
|
|
|
|
2011-04-27 06:25:29 +08:00
|
|
|
/*
|
2009-11-25 20:10:15 +08:00
|
|
|
* anycast_mask attribute to be exported per mshX interface
|
|
|
|
* through sysfs (/sys/class/net/mshX/anycast_mask)
|
|
|
|
*/
|
|
|
|
static DEVICE_ATTR(anycast_mask, 0644, lbs_anycast_get, lbs_anycast_set);
|
|
|
|
|
2011-04-27 06:25:29 +08:00
|
|
|
/*
|
2009-11-25 20:10:15 +08:00
|
|
|
* prb_rsp_limit attribute to be exported per mshX interface
|
|
|
|
* through sysfs (/sys/class/net/mshX/prb_rsp_limit)
|
|
|
|
*/
|
|
|
|
static DEVICE_ATTR(prb_rsp_limit, 0644, lbs_prb_rsp_limit_get,
|
|
|
|
lbs_prb_rsp_limit_set);
|
|
|
|
|
|
|
|
static struct attribute *lbs_mesh_sysfs_entries[] = {
|
|
|
|
&dev_attr_anycast_mask.attr,
|
|
|
|
&dev_attr_prb_rsp_limit.attr,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
static const struct attribute_group lbs_mesh_attr_group = {
|
2009-11-25 20:10:15 +08:00
|
|
|
.attrs = lbs_mesh_sysfs_entries,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
2011-07-21 00:53:50 +08:00
|
|
|
* Persistent configuration support
|
2009-11-25 20:10:15 +08:00
|
|
|
*/
|
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
static int mesh_get_default_parameters(struct device *dev,
|
|
|
|
struct mrvl_mesh_defaults *defs)
|
2009-11-25 20:10:15 +08:00
|
|
|
{
|
2011-07-21 00:53:50 +08:00
|
|
|
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
|
|
|
struct cmd_ds_mesh_config cmd;
|
|
|
|
int ret;
|
2009-11-25 20:10:15 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
memset(&cmd, 0, sizeof(struct cmd_ds_mesh_config));
|
|
|
|
ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_GET,
|
|
|
|
CMD_TYPE_MESH_GET_DEFAULTS);
|
2009-11-25 20:10:15 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
if (ret)
|
|
|
|
return -EOPNOTSUPP;
|
2009-12-02 22:25:56 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
memcpy(defs, &cmd.data[0], sizeof(struct mrvl_mesh_defaults));
|
2009-12-02 22:25:56 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2009-12-02 22:26:00 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
/**
|
|
|
|
* bootflag_get - Get function for sysfs attribute bootflag
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer where data will be returned
|
|
|
|
*/
|
|
|
|
static ssize_t bootflag_get(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct mrvl_mesh_defaults defs;
|
|
|
|
int ret;
|
2009-11-25 20:10:15 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
ret = mesh_get_default_parameters(dev, &defs);
|
2009-11-25 20:10:15 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2009-11-25 20:10:15 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
return snprintf(buf, 12, "%d\n", le32_to_cpu(defs.bootflag));
|
2009-11-25 20:10:15 +08:00
|
|
|
}
|
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
/**
|
|
|
|
* bootflag_set - Set function for sysfs attribute bootflag
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer that contains new attribute value
|
|
|
|
* @count: size of buffer
|
|
|
|
*/
|
|
|
|
static ssize_t bootflag_set(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
2009-11-25 20:10:15 +08:00
|
|
|
{
|
2011-07-21 00:53:50 +08:00
|
|
|
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
|
|
|
struct cmd_ds_mesh_config cmd;
|
|
|
|
uint32_t datum;
|
|
|
|
int ret;
|
2009-11-25 20:10:15 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
memset(&cmd, 0, sizeof(cmd));
|
|
|
|
ret = sscanf(buf, "%d", &datum);
|
|
|
|
if ((ret != 1) || (datum > 1))
|
|
|
|
return -EINVAL;
|
2009-11-25 20:10:15 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
*((__le32 *)&cmd.data[0]) = cpu_to_le32(!!datum);
|
|
|
|
cmd.length = cpu_to_le16(sizeof(uint32_t));
|
|
|
|
ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
|
|
|
|
CMD_TYPE_MESH_SET_BOOTFLAG);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2009-11-25 20:10:15 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
return strlen(buf);
|
2009-11-25 20:10:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-07-21 00:53:50 +08:00
|
|
|
* boottime_get - Get function for sysfs attribute boottime
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer where data will be returned
|
2009-11-25 20:10:15 +08:00
|
|
|
*/
|
2011-07-21 00:53:50 +08:00
|
|
|
static ssize_t boottime_get(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2009-11-25 20:10:15 +08:00
|
|
|
{
|
2011-07-21 00:53:50 +08:00
|
|
|
struct mrvl_mesh_defaults defs;
|
|
|
|
int ret;
|
2009-11-25 20:10:15 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
ret = mesh_get_default_parameters(dev, &defs);
|
2009-11-25 20:10:15 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2008-07-17 03:15:26 +08:00
|
|
|
return snprintf(buf, 12, "%d\n", defs.boottime);
|
2008-05-18 12:01:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-04-27 06:25:29 +08:00
|
|
|
* boottime_set - Set function for sysfs attribute boottime
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer that contains new attribute value
|
|
|
|
* @count: size of buffer
|
2008-05-18 12:01:24 +08:00
|
|
|
*/
|
|
|
|
static ssize_t boottime_set(struct device *dev,
|
|
|
|
struct device_attribute *attr, const char *buf, size_t count)
|
|
|
|
{
|
2009-02-20 08:32:39 +08:00
|
|
|
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
2008-05-18 12:01:24 +08:00
|
|
|
struct cmd_ds_mesh_config cmd;
|
|
|
|
uint32_t datum;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
memset(&cmd, 0, sizeof(cmd));
|
2008-07-17 03:15:26 +08:00
|
|
|
ret = sscanf(buf, "%d", &datum);
|
|
|
|
if ((ret != 1) || (datum > 255))
|
2008-05-18 12:01:24 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* A too small boot time will result in the device booting into
|
|
|
|
* standalone (no-host) mode before the host can take control of it,
|
|
|
|
* so the change will be hard to revert. This may be a desired
|
|
|
|
* feature (e.g to configure a very fast boot time for devices that
|
|
|
|
* will not be attached to a host), but dangerous. So I'm enforcing a
|
|
|
|
* lower limit of 20 seconds: remove and recompile the driver if this
|
|
|
|
* does not work for you.
|
|
|
|
*/
|
|
|
|
datum = (datum < 20) ? 20 : datum;
|
|
|
|
cmd.data[0] = datum;
|
|
|
|
cmd.length = cpu_to_le16(sizeof(uint8_t));
|
|
|
|
ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
|
|
|
|
CMD_TYPE_MESH_SET_BOOTTIME);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return strlen(buf);
|
|
|
|
}
|
|
|
|
|
2008-05-21 06:18:49 +08:00
|
|
|
/**
|
2011-04-27 06:25:29 +08:00
|
|
|
* channel_get - Get function for sysfs attribute channel
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer where data will be returned
|
2008-05-21 06:18:49 +08:00
|
|
|
*/
|
|
|
|
static ssize_t channel_get(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct mrvl_mesh_defaults defs;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = mesh_get_default_parameters(dev, &defs);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2008-07-17 03:15:26 +08:00
|
|
|
return snprintf(buf, 12, "%d\n", le16_to_cpu(defs.channel));
|
2008-05-21 06:18:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-04-27 06:25:29 +08:00
|
|
|
* channel_set - Set function for sysfs attribute channel
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer that contains new attribute value
|
|
|
|
* @count: size of buffer
|
2008-05-21 06:18:49 +08:00
|
|
|
*/
|
|
|
|
static ssize_t channel_set(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2009-02-20 08:32:39 +08:00
|
|
|
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
2008-05-21 06:18:49 +08:00
|
|
|
struct cmd_ds_mesh_config cmd;
|
2008-07-17 03:15:26 +08:00
|
|
|
uint32_t datum;
|
2008-05-21 06:18:49 +08:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
memset(&cmd, 0, sizeof(cmd));
|
2008-07-17 03:15:26 +08:00
|
|
|
ret = sscanf(buf, "%d", &datum);
|
2008-05-21 06:18:49 +08:00
|
|
|
if (ret != 1 || datum < 1 || datum > 11)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
*((__le16 *)&cmd.data[0]) = cpu_to_le16(datum);
|
|
|
|
cmd.length = cpu_to_le16(sizeof(uint16_t));
|
|
|
|
ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
|
|
|
|
CMD_TYPE_MESH_SET_DEF_CHANNEL);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return strlen(buf);
|
|
|
|
}
|
|
|
|
|
2008-05-18 12:01:24 +08:00
|
|
|
/**
|
2011-04-27 06:25:29 +08:00
|
|
|
* mesh_id_get - Get function for sysfs attribute mesh_id
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer where data will be returned
|
2008-05-18 12:01:24 +08:00
|
|
|
*/
|
|
|
|
static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct mrvl_mesh_defaults defs;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = mesh_get_default_parameters(dev, &defs);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2009-10-22 21:30:47 +08:00
|
|
|
if (defs.meshie.val.mesh_id_len > IEEE80211_MAX_SSID_LEN) {
|
2011-05-03 07:49:15 +08:00
|
|
|
dev_err(dev, "inconsistent mesh ID length\n");
|
2009-10-22 21:30:47 +08:00
|
|
|
defs.meshie.val.mesh_id_len = IEEE80211_MAX_SSID_LEN;
|
2008-05-18 12:01:24 +08:00
|
|
|
}
|
|
|
|
|
2011-03-10 23:23:26 +08:00
|
|
|
memcpy(buf, defs.meshie.val.mesh_id, defs.meshie.val.mesh_id_len);
|
|
|
|
buf[defs.meshie.val.mesh_id_len] = '\n';
|
|
|
|
buf[defs.meshie.val.mesh_id_len + 1] = '\0';
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-03-10 23:23:26 +08:00
|
|
|
return defs.meshie.val.mesh_id_len + 1;
|
2008-05-18 12:01:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-04-27 06:25:29 +08:00
|
|
|
* mesh_id_set - Set function for sysfs attribute mesh_id
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer that contains new attribute value
|
|
|
|
* @count: size of buffer
|
2008-05-18 12:01:24 +08:00
|
|
|
*/
|
|
|
|
static ssize_t mesh_id_set(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct cmd_ds_mesh_config cmd;
|
|
|
|
struct mrvl_mesh_defaults defs;
|
|
|
|
struct mrvl_meshie *ie;
|
2009-02-20 08:32:39 +08:00
|
|
|
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
2008-05-18 12:01:24 +08:00
|
|
|
int len;
|
|
|
|
int ret;
|
|
|
|
|
2009-10-22 21:30:47 +08:00
|
|
|
if (count < 2 || count > IEEE80211_MAX_SSID_LEN + 1)
|
2008-05-18 12:01:24 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
memset(&cmd, 0, sizeof(struct cmd_ds_mesh_config));
|
|
|
|
ie = (struct mrvl_meshie *) &cmd.data[0];
|
|
|
|
|
|
|
|
/* fetch all other Information Element parameters */
|
|
|
|
ret = mesh_get_default_parameters(dev, &defs);
|
|
|
|
|
|
|
|
cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie));
|
|
|
|
|
|
|
|
/* transfer IE elements */
|
|
|
|
memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie));
|
|
|
|
|
|
|
|
len = count - 1;
|
|
|
|
memcpy(ie->val.mesh_id, buf, len);
|
|
|
|
/* SSID len */
|
|
|
|
ie->val.mesh_id_len = len;
|
|
|
|
/* IE len */
|
2009-10-22 21:30:47 +08:00
|
|
|
ie->len = sizeof(struct mrvl_meshie_val) - IEEE80211_MAX_SSID_LEN + len;
|
2008-05-18 12:01:24 +08:00
|
|
|
|
|
|
|
ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
|
|
|
|
CMD_TYPE_MESH_SET_MESH_IE);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return strlen(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-04-27 06:25:29 +08:00
|
|
|
* protocol_id_get - Get function for sysfs attribute protocol_id
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer where data will be returned
|
2008-05-18 12:01:24 +08:00
|
|
|
*/
|
|
|
|
static ssize_t protocol_id_get(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct mrvl_mesh_defaults defs;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = mesh_get_default_parameters(dev, &defs);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return snprintf(buf, 5, "%d\n", defs.meshie.val.active_protocol_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-04-27 06:25:29 +08:00
|
|
|
* protocol_id_set - Set function for sysfs attribute protocol_id
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer that contains new attribute value
|
|
|
|
* @count: size of buffer
|
2008-05-18 12:01:24 +08:00
|
|
|
*/
|
|
|
|
static ssize_t protocol_id_set(struct device *dev,
|
|
|
|
struct device_attribute *attr, const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct cmd_ds_mesh_config cmd;
|
|
|
|
struct mrvl_mesh_defaults defs;
|
|
|
|
struct mrvl_meshie *ie;
|
2009-02-20 08:32:39 +08:00
|
|
|
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
2008-05-18 12:01:24 +08:00
|
|
|
uint32_t datum;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
memset(&cmd, 0, sizeof(cmd));
|
2008-07-17 03:15:26 +08:00
|
|
|
ret = sscanf(buf, "%d", &datum);
|
|
|
|
if ((ret != 1) || (datum > 255))
|
2008-05-18 12:01:24 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* fetch all other Information Element parameters */
|
|
|
|
ret = mesh_get_default_parameters(dev, &defs);
|
|
|
|
|
|
|
|
cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie));
|
|
|
|
|
|
|
|
/* transfer IE elements */
|
|
|
|
ie = (struct mrvl_meshie *) &cmd.data[0];
|
|
|
|
memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie));
|
|
|
|
/* update protocol id */
|
|
|
|
ie->val.active_protocol_id = datum;
|
|
|
|
|
|
|
|
ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
|
|
|
|
CMD_TYPE_MESH_SET_MESH_IE);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return strlen(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-04-27 06:25:29 +08:00
|
|
|
* metric_id_get - Get function for sysfs attribute metric_id
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer where data will be returned
|
2008-05-18 12:01:24 +08:00
|
|
|
*/
|
|
|
|
static ssize_t metric_id_get(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2011-07-21 00:53:50 +08:00
|
|
|
struct mrvl_mesh_defaults defs;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = mesh_get_default_parameters(dev, &defs);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return snprintf(buf, 5, "%d\n", defs.meshie.val.active_metric_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* metric_id_set - Set function for sysfs attribute metric_id
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer that contains new attribute value
|
|
|
|
* @count: size of buffer
|
|
|
|
*/
|
|
|
|
static ssize_t metric_id_set(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct cmd_ds_mesh_config cmd;
|
|
|
|
struct mrvl_mesh_defaults defs;
|
|
|
|
struct mrvl_meshie *ie;
|
|
|
|
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
|
|
|
uint32_t datum;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
memset(&cmd, 0, sizeof(cmd));
|
|
|
|
ret = sscanf(buf, "%d", &datum);
|
|
|
|
if ((ret != 1) || (datum > 255))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* fetch all other Information Element parameters */
|
|
|
|
ret = mesh_get_default_parameters(dev, &defs);
|
|
|
|
|
|
|
|
cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie));
|
|
|
|
|
|
|
|
/* transfer IE elements */
|
|
|
|
ie = (struct mrvl_meshie *) &cmd.data[0];
|
|
|
|
memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie));
|
|
|
|
/* update metric id */
|
|
|
|
ie->val.active_metric_id = datum;
|
|
|
|
|
|
|
|
ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
|
|
|
|
CMD_TYPE_MESH_SET_MESH_IE);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return strlen(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* capability_get - Get function for sysfs attribute capability
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer where data will be returned
|
|
|
|
*/
|
|
|
|
static ssize_t capability_get(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct mrvl_mesh_defaults defs;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = mesh_get_default_parameters(dev, &defs);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return snprintf(buf, 5, "%d\n", defs.meshie.val.mesh_capability);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* capability_set - Set function for sysfs attribute capability
|
|
|
|
* @dev: the &struct device
|
|
|
|
* @attr: device attributes
|
|
|
|
* @buf: buffer that contains new attribute value
|
|
|
|
* @count: size of buffer
|
|
|
|
*/
|
|
|
|
static ssize_t capability_set(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct cmd_ds_mesh_config cmd;
|
|
|
|
struct mrvl_mesh_defaults defs;
|
|
|
|
struct mrvl_meshie *ie;
|
|
|
|
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
|
|
|
uint32_t datum;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
memset(&cmd, 0, sizeof(cmd));
|
|
|
|
ret = sscanf(buf, "%d", &datum);
|
|
|
|
if ((ret != 1) || (datum > 255))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* fetch all other Information Element parameters */
|
|
|
|
ret = mesh_get_default_parameters(dev, &defs);
|
|
|
|
|
|
|
|
cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie));
|
|
|
|
|
|
|
|
/* transfer IE elements */
|
|
|
|
ie = (struct mrvl_meshie *) &cmd.data[0];
|
|
|
|
memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie));
|
|
|
|
/* update value */
|
|
|
|
ie->val.mesh_capability = datum;
|
|
|
|
|
|
|
|
ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
|
|
|
|
CMD_TYPE_MESH_SET_MESH_IE);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return strlen(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static DEVICE_ATTR(bootflag, 0644, bootflag_get, bootflag_set);
|
|
|
|
static DEVICE_ATTR(boottime, 0644, boottime_get, boottime_set);
|
|
|
|
static DEVICE_ATTR(channel, 0644, channel_get, channel_set);
|
|
|
|
static DEVICE_ATTR(mesh_id, 0644, mesh_id_get, mesh_id_set);
|
|
|
|
static DEVICE_ATTR(protocol_id, 0644, protocol_id_get, protocol_id_set);
|
|
|
|
static DEVICE_ATTR(metric_id, 0644, metric_id_get, metric_id_set);
|
|
|
|
static DEVICE_ATTR(capability, 0644, capability_get, capability_set);
|
|
|
|
|
|
|
|
static struct attribute *boot_opts_attrs[] = {
|
|
|
|
&dev_attr_bootflag.attr,
|
|
|
|
&dev_attr_boottime.attr,
|
|
|
|
&dev_attr_channel.attr,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct attribute_group boot_opts_group = {
|
|
|
|
.name = "boot_options",
|
|
|
|
.attrs = boot_opts_attrs,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute *mesh_ie_attrs[] = {
|
|
|
|
&dev_attr_mesh_id.attr,
|
|
|
|
&dev_attr_protocol_id.attr,
|
|
|
|
&dev_attr_metric_id.attr,
|
|
|
|
&dev_attr_capability.attr,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct attribute_group mesh_ie_group = {
|
|
|
|
.name = "mesh_ie",
|
|
|
|
.attrs = mesh_ie_attrs,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void lbs_persist_config_init(struct net_device *dev)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
ret = sysfs_create_group(&(dev->dev.kobj), &boot_opts_group);
|
|
|
|
ret = sysfs_create_group(&(dev->dev.kobj), &mesh_ie_group);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void lbs_persist_config_remove(struct net_device *dev)
|
|
|
|
{
|
|
|
|
sysfs_remove_group(&(dev->dev.kobj), &boot_opts_group);
|
|
|
|
sysfs_remove_group(&(dev->dev.kobj), &mesh_ie_group);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* Initializing and starting, stopping mesh
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check mesh FW version and appropriately send the mesh start
|
|
|
|
* command
|
|
|
|
*/
|
|
|
|
int lbs_init_mesh(struct lbs_private *priv)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
/* Determine mesh_fw_ver from fwrelease and fwcapinfo */
|
|
|
|
/* 5.0.16p0 9.0.0.p0 is known to NOT support any mesh */
|
|
|
|
/* 5.110.22 have mesh command with 0xa3 command id */
|
|
|
|
/* 10.0.0.p0 FW brings in mesh config command with different id */
|
|
|
|
/* Check FW version MSB and initialize mesh_fw_ver */
|
|
|
|
if (MRVL_FW_MAJOR_REV(priv->fwrelease) == MRVL_FW_V5) {
|
|
|
|
/* Enable mesh, if supported, and work out which TLV it uses.
|
|
|
|
0x100 + 291 is an unofficial value used in 5.110.20.pXX
|
|
|
|
0x100 + 37 is the official value used in 5.110.21.pXX
|
|
|
|
but we check them in that order because 20.pXX doesn't
|
|
|
|
give an error -- it just silently fails. */
|
|
|
|
|
|
|
|
/* 5.110.20.pXX firmware will fail the command if the channel
|
|
|
|
doesn't match the existing channel. But only if the TLV
|
|
|
|
is correct. If the channel is wrong, _BOTH_ versions will
|
|
|
|
give an error to 0x100+291, and allow 0x100+37 to succeed.
|
|
|
|
It's just that 5.110.20.pXX will not have done anything
|
|
|
|
useful */
|
|
|
|
|
|
|
|
priv->mesh_tlv = TLV_TYPE_OLD_MESH_ID;
|
2011-07-22 03:43:17 +08:00
|
|
|
if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, 1)) {
|
2011-07-21 00:53:50 +08:00
|
|
|
priv->mesh_tlv = TLV_TYPE_MESH_ID;
|
2011-07-22 03:43:17 +08:00
|
|
|
if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, 1))
|
2011-07-21 00:53:50 +08:00
|
|
|
priv->mesh_tlv = 0;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
if ((MRVL_FW_MAJOR_REV(priv->fwrelease) >= MRVL_FW_V10) &&
|
|
|
|
(priv->fwcapinfo & MESH_CAPINFO_ENABLE_MASK)) {
|
|
|
|
/* 10.0.0.pXX new firmwares should succeed with TLV
|
|
|
|
* 0x100+37; Do not invoke command with old TLV.
|
|
|
|
*/
|
|
|
|
priv->mesh_tlv = TLV_TYPE_MESH_ID;
|
2011-07-22 03:43:17 +08:00
|
|
|
if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, 1))
|
2011-07-21 00:53:50 +08:00
|
|
|
priv->mesh_tlv = 0;
|
|
|
|
}
|
|
|
|
|
2011-07-21 00:53:56 +08:00
|
|
|
/* Stop meshing until interface is brought up */
|
2011-07-22 03:43:17 +08:00
|
|
|
lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_STOP, 1);
|
2011-07-21 00:53:50 +08:00
|
|
|
|
|
|
|
if (priv->mesh_tlv) {
|
|
|
|
sprintf(priv->mesh_ssid, "mesh");
|
|
|
|
priv->mesh_ssid_len = 4;
|
|
|
|
ret = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-07-22 03:43:17 +08:00
|
|
|
void lbs_start_mesh(struct lbs_private *priv)
|
|
|
|
{
|
|
|
|
lbs_add_mesh(priv);
|
|
|
|
|
|
|
|
if (device_create_file(&priv->dev->dev, &dev_attr_lbs_mesh))
|
|
|
|
netdev_err(priv->dev, "cannot register lbs_mesh attribute\n");
|
|
|
|
}
|
2011-07-21 00:53:50 +08:00
|
|
|
|
|
|
|
int lbs_deinit_mesh(struct lbs_private *priv)
|
|
|
|
{
|
|
|
|
struct net_device *dev = priv->dev;
|
|
|
|
int ret = 0;
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
if (priv->mesh_tlv) {
|
|
|
|
device_remove_file(&dev->dev, &dev_attr_lbs_mesh);
|
|
|
|
ret = 1;
|
|
|
|
}
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
return ret;
|
2008-05-18 12:01:24 +08:00
|
|
|
}
|
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
|
2008-05-18 12:01:24 +08:00
|
|
|
/**
|
2011-07-21 00:53:50 +08:00
|
|
|
* lbs_mesh_stop - close the mshX interface
|
|
|
|
*
|
|
|
|
* @dev: A pointer to &net_device structure
|
|
|
|
* returns: 0
|
2008-05-18 12:01:24 +08:00
|
|
|
*/
|
2011-07-21 00:53:50 +08:00
|
|
|
static int lbs_mesh_stop(struct net_device *dev)
|
2008-05-18 12:01:24 +08:00
|
|
|
{
|
2011-07-21 00:53:50 +08:00
|
|
|
struct lbs_private *priv = dev->ml_priv;
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-22 03:43:17 +08:00
|
|
|
lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_STOP,
|
|
|
|
lbs_mesh_get_channel(priv));
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-21 00:53:56 +08:00
|
|
|
spin_lock_irq(&priv->driver_lock);
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
netif_stop_queue(dev);
|
|
|
|
netif_carrier_off(dev);
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
spin_unlock_irq(&priv->driver_lock);
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-08-01 23:43:13 +08:00
|
|
|
lbs_update_mcast(priv);
|
|
|
|
if (!lbs_iface_active(priv))
|
|
|
|
lbs_stop_iface(priv);
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
return 0;
|
2008-05-18 12:01:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-07-21 00:53:50 +08:00
|
|
|
* lbs_mesh_dev_open - open the mshX interface
|
|
|
|
*
|
|
|
|
* @dev: A pointer to &net_device structure
|
|
|
|
* returns: 0 or -EBUSY if monitor mode active
|
2008-05-18 12:01:24 +08:00
|
|
|
*/
|
2011-07-21 00:53:50 +08:00
|
|
|
static int lbs_mesh_dev_open(struct net_device *dev)
|
2008-05-18 12:01:24 +08:00
|
|
|
{
|
2011-07-21 00:53:50 +08:00
|
|
|
struct lbs_private *priv = dev->ml_priv;
|
|
|
|
int ret = 0;
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-08-01 23:43:13 +08:00
|
|
|
if (!priv->iface_running) {
|
|
|
|
ret = lbs_start_iface(priv);
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
}
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
spin_lock_irq(&priv->driver_lock);
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
if (priv->wdev->iftype == NL80211_IFTYPE_MONITOR) {
|
|
|
|
ret = -EBUSY;
|
2011-07-21 00:53:56 +08:00
|
|
|
spin_unlock_irq(&priv->driver_lock);
|
2011-07-21 00:53:50 +08:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
netif_carrier_on(dev);
|
|
|
|
|
|
|
|
if (!priv->tx_pending_len)
|
|
|
|
netif_wake_queue(dev);
|
|
|
|
|
|
|
|
spin_unlock_irq(&priv->driver_lock);
|
2011-07-21 00:53:56 +08:00
|
|
|
|
2011-07-22 03:43:17 +08:00
|
|
|
ret = lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
|
|
|
|
lbs_mesh_get_channel(priv));
|
2011-07-21 00:53:56 +08:00
|
|
|
|
|
|
|
out:
|
2011-07-21 00:53:50 +08:00
|
|
|
return ret;
|
2008-05-18 12:01:24 +08:00
|
|
|
}
|
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
static const struct net_device_ops mesh_netdev_ops = {
|
|
|
|
.ndo_open = lbs_mesh_dev_open,
|
|
|
|
.ndo_stop = lbs_mesh_stop,
|
|
|
|
.ndo_start_xmit = lbs_hard_start_xmit,
|
|
|
|
.ndo_set_mac_address = lbs_set_mac_address,
|
2011-08-16 14:29:01 +08:00
|
|
|
.ndo_set_rx_mode = lbs_set_multicast_list,
|
2011-07-21 00:53:50 +08:00
|
|
|
};
|
|
|
|
|
2008-05-18 12:01:24 +08:00
|
|
|
/**
|
2011-07-21 00:53:50 +08:00
|
|
|
* lbs_add_mesh - add mshX interface
|
|
|
|
*
|
|
|
|
* @priv: A pointer to the &struct lbs_private structure
|
|
|
|
* returns: 0 if successful, -X otherwise
|
2008-05-18 12:01:24 +08:00
|
|
|
*/
|
2011-07-21 00:53:50 +08:00
|
|
|
static int lbs_add_mesh(struct lbs_private *priv)
|
2008-05-18 12:01:24 +08:00
|
|
|
{
|
2011-07-21 00:53:50 +08:00
|
|
|
struct net_device *mesh_dev = NULL;
|
2011-07-22 03:43:17 +08:00
|
|
|
struct wireless_dev *mesh_wdev;
|
2011-07-21 00:53:50 +08:00
|
|
|
int ret = 0;
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
/* Allocate a virtual mesh device */
|
2011-07-22 03:43:17 +08:00
|
|
|
mesh_wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
|
|
|
|
if (!mesh_wdev) {
|
|
|
|
lbs_deb_mesh("init mshX wireless device failed\n");
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
net: set name_assign_type in alloc_netdev()
Extend alloc_netdev{,_mq{,s}}() to take name_assign_type as argument, and convert
all users to pass NET_NAME_UNKNOWN.
Coccinelle patch:
@@
expression sizeof_priv, name, setup, txqs, rxqs, count;
@@
(
-alloc_netdev_mqs(sizeof_priv, name, setup, txqs, rxqs)
+alloc_netdev_mqs(sizeof_priv, name, NET_NAME_UNKNOWN, setup, txqs, rxqs)
|
-alloc_netdev_mq(sizeof_priv, name, setup, count)
+alloc_netdev_mq(sizeof_priv, name, NET_NAME_UNKNOWN, setup, count)
|
-alloc_netdev(sizeof_priv, name, setup)
+alloc_netdev(sizeof_priv, name, NET_NAME_UNKNOWN, setup)
)
v9: move comments here from the wrong commit
Signed-off-by: Tom Gundersen <teg@jklm.no>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-07-14 22:37:24 +08:00
|
|
|
mesh_dev = alloc_netdev(0, "msh%d", NET_NAME_UNKNOWN, ether_setup);
|
2011-07-21 00:53:50 +08:00
|
|
|
if (!mesh_dev) {
|
|
|
|
lbs_deb_mesh("init mshX device failed\n");
|
|
|
|
ret = -ENOMEM;
|
2011-07-22 03:43:17 +08:00
|
|
|
goto err_free_wdev;
|
2011-07-21 00:53:50 +08:00
|
|
|
}
|
2011-07-22 03:43:17 +08:00
|
|
|
|
|
|
|
mesh_wdev->iftype = NL80211_IFTYPE_MESH_POINT;
|
|
|
|
mesh_wdev->wiphy = priv->wdev->wiphy;
|
|
|
|
mesh_wdev->netdev = mesh_dev;
|
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
mesh_dev->ml_priv = priv;
|
2011-07-22 03:43:17 +08:00
|
|
|
mesh_dev->ieee80211_ptr = mesh_wdev;
|
2011-07-21 00:53:50 +08:00
|
|
|
priv->mesh_dev = mesh_dev;
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
mesh_dev->netdev_ops = &mesh_netdev_ops;
|
|
|
|
mesh_dev->ethtool_ops = &lbs_ethtool_ops;
|
2013-08-31 00:08:51 +08:00
|
|
|
eth_hw_addr_inherit(mesh_dev, priv->dev);
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
SET_NETDEV_DEV(priv->mesh_dev, priv->dev->dev.parent);
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
mesh_dev->flags |= IFF_BROADCAST | IFF_MULTICAST;
|
|
|
|
/* Register virtual mesh interface */
|
|
|
|
ret = register_netdev(mesh_dev);
|
|
|
|
if (ret) {
|
|
|
|
pr_err("cannot register mshX virtual interface\n");
|
2011-07-22 03:43:17 +08:00
|
|
|
goto err_free_netdev;
|
2011-07-21 00:53:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = sysfs_create_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group);
|
2008-05-18 12:01:24 +08:00
|
|
|
if (ret)
|
2011-07-21 00:53:50 +08:00
|
|
|
goto err_unregister;
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
lbs_persist_config_init(mesh_dev);
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
/* Everything successful */
|
|
|
|
ret = 0;
|
|
|
|
goto done;
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
err_unregister:
|
|
|
|
unregister_netdev(mesh_dev);
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-22 03:43:17 +08:00
|
|
|
err_free_netdev:
|
2011-07-21 00:53:50 +08:00
|
|
|
free_netdev(mesh_dev);
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-22 03:43:17 +08:00
|
|
|
err_free_wdev:
|
|
|
|
kfree(mesh_wdev);
|
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
done:
|
|
|
|
return ret;
|
|
|
|
}
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
void lbs_remove_mesh(struct lbs_private *priv)
|
|
|
|
{
|
|
|
|
struct net_device *mesh_dev;
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
mesh_dev = priv->mesh_dev;
|
|
|
|
if (!mesh_dev)
|
|
|
|
return;
|
2008-05-18 12:01:24 +08:00
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
netif_stop_queue(mesh_dev);
|
|
|
|
netif_carrier_off(mesh_dev);
|
|
|
|
sysfs_remove_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group);
|
|
|
|
lbs_persist_config_remove(mesh_dev);
|
|
|
|
unregister_netdev(mesh_dev);
|
|
|
|
priv->mesh_dev = NULL;
|
2011-07-22 03:43:17 +08:00
|
|
|
kfree(mesh_dev->ieee80211_ptr);
|
2011-07-21 00:53:50 +08:00
|
|
|
free_netdev(mesh_dev);
|
2008-05-18 12:01:24 +08:00
|
|
|
}
|
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* Sending and receiving
|
|
|
|
*/
|
|
|
|
struct net_device *lbs_mesh_set_dev(struct lbs_private *priv,
|
|
|
|
struct net_device *dev, struct rxpd *rxpd)
|
2008-05-18 12:01:24 +08:00
|
|
|
{
|
2011-07-21 00:53:50 +08:00
|
|
|
if (priv->mesh_dev) {
|
|
|
|
if (priv->mesh_tlv == TLV_TYPE_OLD_MESH_ID) {
|
|
|
|
if (rxpd->rx_control & RxPD_MESH_FRAME)
|
|
|
|
dev = priv->mesh_dev;
|
|
|
|
} else if (priv->mesh_tlv == TLV_TYPE_MESH_ID) {
|
|
|
|
if (rxpd->u.bss.bss_num == MESH_IFACE_ID)
|
|
|
|
dev = priv->mesh_dev;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dev;
|
2008-05-18 12:01:24 +08:00
|
|
|
}
|
2009-11-25 20:10:49 +08:00
|
|
|
|
|
|
|
|
2011-07-21 00:53:50 +08:00
|
|
|
void lbs_mesh_set_txpd(struct lbs_private *priv,
|
|
|
|
struct net_device *dev, struct txpd *txpd)
|
|
|
|
{
|
|
|
|
if (dev == priv->mesh_dev) {
|
|
|
|
if (priv->mesh_tlv == TLV_TYPE_OLD_MESH_ID)
|
|
|
|
txpd->tx_control |= cpu_to_le32(TxPD_MESH_FRAME);
|
|
|
|
else if (priv->mesh_tlv == TLV_TYPE_MESH_ID)
|
|
|
|
txpd->u.bss.bss_num = MESH_IFACE_ID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-25 20:10:49 +08:00
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* Ethtool related
|
|
|
|
*/
|
|
|
|
|
2017-05-16 05:26:40 +08:00
|
|
|
static const char mesh_stat_strings[MESH_STATS_NUM][ETH_GSTRING_LEN] = {
|
|
|
|
"drop_duplicate_bcast",
|
|
|
|
"drop_ttl_zero",
|
|
|
|
"drop_no_fwd_route",
|
|
|
|
"drop_no_buffers",
|
|
|
|
"fwded_unicast_cnt",
|
|
|
|
"fwded_bcast_cnt",
|
|
|
|
"drop_blind_table",
|
|
|
|
"tx_failed_cnt"
|
2009-11-25 20:10:49 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void lbs_mesh_ethtool_get_stats(struct net_device *dev,
|
|
|
|
struct ethtool_stats *stats, uint64_t *data)
|
|
|
|
{
|
|
|
|
struct lbs_private *priv = dev->ml_priv;
|
|
|
|
struct cmd_ds_mesh_access mesh_access;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Get Mesh Statistics */
|
|
|
|
ret = lbs_mesh_access(priv, CMD_ACT_MESH_GET_STATS, &mesh_access);
|
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
memset(data, 0, MESH_STATS_NUM*(sizeof(uint64_t)));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->mstats.fwd_drop_rbt = le32_to_cpu(mesh_access.data[0]);
|
|
|
|
priv->mstats.fwd_drop_ttl = le32_to_cpu(mesh_access.data[1]);
|
|
|
|
priv->mstats.fwd_drop_noroute = le32_to_cpu(mesh_access.data[2]);
|
|
|
|
priv->mstats.fwd_drop_nobuf = le32_to_cpu(mesh_access.data[3]);
|
|
|
|
priv->mstats.fwd_unicast_cnt = le32_to_cpu(mesh_access.data[4]);
|
|
|
|
priv->mstats.fwd_bcast_cnt = le32_to_cpu(mesh_access.data[5]);
|
|
|
|
priv->mstats.drop_blind = le32_to_cpu(mesh_access.data[6]);
|
|
|
|
priv->mstats.tx_failed_cnt = le32_to_cpu(mesh_access.data[7]);
|
|
|
|
|
|
|
|
data[0] = priv->mstats.fwd_drop_rbt;
|
|
|
|
data[1] = priv->mstats.fwd_drop_ttl;
|
|
|
|
data[2] = priv->mstats.fwd_drop_noroute;
|
|
|
|
data[3] = priv->mstats.fwd_drop_nobuf;
|
|
|
|
data[4] = priv->mstats.fwd_unicast_cnt;
|
|
|
|
data[5] = priv->mstats.fwd_bcast_cnt;
|
|
|
|
data[6] = priv->mstats.drop_blind;
|
|
|
|
data[7] = priv->mstats.tx_failed_cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
int lbs_mesh_ethtool_get_sset_count(struct net_device *dev, int sset)
|
|
|
|
{
|
|
|
|
struct lbs_private *priv = dev->ml_priv;
|
|
|
|
|
|
|
|
if (sset == ETH_SS_STATS && dev == priv->mesh_dev)
|
|
|
|
return MESH_STATS_NUM;
|
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
void lbs_mesh_ethtool_get_strings(struct net_device *dev,
|
|
|
|
uint32_t stringset, uint8_t *s)
|
|
|
|
{
|
|
|
|
switch (stringset) {
|
|
|
|
case ETH_SS_STATS:
|
2017-05-16 05:26:40 +08:00
|
|
|
memcpy(s, mesh_stat_strings, sizeof(mesh_stat_strings));
|
2009-11-25 20:10:49 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|