2007-02-10 21:25:27 +07:00
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/ethtool.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
|
|
|
|
#include "host.h"
|
|
|
|
#include "decl.h"
|
|
|
|
#include "defs.h"
|
|
|
|
#include "dev.h"
|
|
|
|
#include "wext.h"
|
2007-12-13 08:06:06 +07:00
|
|
|
#include "cmd.h"
|
|
|
|
|
2007-02-10 21:25:27 +07:00
|
|
|
static const char * mesh_stat_strings[]= {
|
|
|
|
"drop_duplicate_bcast",
|
|
|
|
"drop_ttl_zero",
|
|
|
|
"drop_no_fwd_route",
|
|
|
|
"drop_no_buffers",
|
|
|
|
"fwded_unicast_cnt",
|
|
|
|
"fwded_bcast_cnt",
|
2007-05-25 23:12:06 +07:00
|
|
|
"drop_blind_table",
|
|
|
|
"tx_failed_cnt"
|
2007-02-10 21:25:27 +07:00
|
|
|
};
|
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
static void lbs_ethtool_get_drvinfo(struct net_device *dev,
|
2007-02-10 21:25:27 +07:00
|
|
|
struct ethtool_drvinfo *info)
|
|
|
|
{
|
2009-02-20 07:32:39 +07:00
|
|
|
struct lbs_private *priv = dev->ml_priv;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2008-04-02 23:04:35 +07:00
|
|
|
snprintf(info->fw_version, 32, "%u.%u.%u.p%u",
|
|
|
|
priv->fwrelease >> 24 & 0xff,
|
|
|
|
priv->fwrelease >> 16 & 0xff,
|
|
|
|
priv->fwrelease >> 8 & 0xff,
|
|
|
|
priv->fwrelease & 0xff);
|
2007-02-10 21:25:27 +07:00
|
|
|
strcpy(info->driver, "libertas");
|
2007-11-16 06:05:47 +07:00
|
|
|
strcpy(info->version, lbs_driver_version);
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* All 8388 parts have 16KiB EEPROM size at the time of writing.
|
|
|
|
* In case that changes this needs fixing.
|
|
|
|
*/
|
2007-11-16 06:05:47 +07:00
|
|
|
#define LBS_EEPROM_LEN 16384
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
static int lbs_ethtool_get_eeprom_len(struct net_device *dev)
|
2007-02-10 21:25:27 +07:00
|
|
|
{
|
2007-11-16 06:05:47 +07:00
|
|
|
return LBS_EEPROM_LEN;
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
static int lbs_ethtool_get_eeprom(struct net_device *dev,
|
2007-02-10 21:25:27 +07:00
|
|
|
struct ethtool_eeprom *eeprom, u8 * bytes)
|
|
|
|
{
|
2009-02-20 07:32:39 +07:00
|
|
|
struct lbs_private *priv = dev->ml_priv;
|
2008-03-26 16:03:48 +07:00
|
|
|
struct cmd_ds_802_11_eeprom_access cmd;
|
2007-02-10 21:25:27 +07:00
|
|
|
int ret;
|
|
|
|
|
2008-03-26 16:03:48 +07:00
|
|
|
lbs_deb_enter(LBS_DEB_ETHTOOL);
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2008-03-26 16:03:48 +07:00
|
|
|
if (eeprom->offset + eeprom->len > LBS_EEPROM_LEN ||
|
|
|
|
eeprom->len > LBS_EEPROM_READ_LEN) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto out;
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
2008-03-26 16:03:48 +07:00
|
|
|
cmd.hdr.size = cpu_to_le16(sizeof(struct cmd_ds_802_11_eeprom_access) -
|
|
|
|
LBS_EEPROM_READ_LEN + eeprom->len);
|
|
|
|
cmd.action = cpu_to_le16(CMD_ACT_GET);
|
|
|
|
cmd.offset = cpu_to_le16(eeprom->offset);
|
|
|
|
cmd.len = cpu_to_le16(eeprom->len);
|
|
|
|
ret = lbs_cmd_with_response(priv, CMD_802_11_EEPROM_ACCESS, &cmd);
|
|
|
|
if (!ret)
|
|
|
|
memcpy(bytes, cmd.value, eeprom->len);
|
|
|
|
|
|
|
|
out:
|
|
|
|
lbs_deb_leave_args(LBS_DEB_ETHTOOL, "ret %d", ret);
|
2007-05-25 22:27:16 +07:00
|
|
|
return ret;
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
2008-05-19 22:32:02 +07:00
|
|
|
static void lbs_ethtool_get_stats(struct net_device *dev,
|
|
|
|
struct ethtool_stats *stats, uint64_t *data)
|
2007-02-10 21:25:27 +07:00
|
|
|
{
|
2009-02-20 07:32:39 +07:00
|
|
|
struct lbs_private *priv = dev->ml_priv;
|
2007-02-10 21:25:27 +07:00
|
|
|
struct cmd_ds_mesh_access mesh_access;
|
2007-10-04 08:07:32 +07:00
|
|
|
int ret;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2007-05-25 22:27:16 +07:00
|
|
|
lbs_deb_enter(LBS_DEB_ETHTOOL);
|
|
|
|
|
2007-02-10 21:25:27 +07:00
|
|
|
/* Get Mesh Statistics */
|
2008-05-19 22:32:02 +07:00
|
|
|
ret = lbs_mesh_access(priv, CMD_ACT_MESH_GET_STATS, &mesh_access);
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2008-05-19 22:32:02 +07:00
|
|
|
if (ret) {
|
|
|
|
memset(data, 0, MESH_STATS_NUM*(sizeof(uint64_t)));
|
2007-10-04 08:07:32 +07:00
|
|
|
return;
|
2008-05-19 22:32:02 +07:00
|
|
|
}
|
2007-10-04 08:07:32 +07:00
|
|
|
|
|
|
|
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;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2007-10-04 08:07:32 +07:00
|
|
|
lbs_deb_enter(LBS_DEB_ETHTOOL);
|
|
|
|
}
|
2007-05-25 22:27:16 +07:00
|
|
|
|
2008-05-19 22:32:02 +07:00
|
|
|
static int lbs_ethtool_get_sset_count(struct net_device *dev, int sset)
|
2007-10-04 08:07:32 +07:00
|
|
|
{
|
2009-02-20 07:32:39 +07:00
|
|
|
struct lbs_private *priv = dev->ml_priv;
|
2008-05-19 22:32:02 +07:00
|
|
|
|
|
|
|
if (sset == ETH_SS_STATS && dev == priv->mesh_dev)
|
2007-10-04 08:07:32 +07:00
|
|
|
return MESH_STATS_NUM;
|
2008-05-19 22:32:02 +07:00
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
static void lbs_ethtool_get_strings(struct net_device *dev,
|
2008-05-19 22:32:02 +07:00
|
|
|
uint32_t stringset, uint8_t *s)
|
2007-02-10 21:25:27 +07:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2007-05-25 22:27:16 +07:00
|
|
|
lbs_deb_enter(LBS_DEB_ETHTOOL);
|
|
|
|
|
2007-02-10 21:25:27 +07:00
|
|
|
switch (stringset) {
|
|
|
|
case ETH_SS_STATS:
|
|
|
|
for (i=0; i < MESH_STATS_NUM; i++) {
|
|
|
|
memcpy(s + i * ETH_GSTRING_LEN,
|
|
|
|
mesh_stat_strings[i],
|
|
|
|
ETH_GSTRING_LEN);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2007-05-25 22:27:16 +07:00
|
|
|
lbs_deb_enter(LBS_DEB_ETHTOOL);
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
2007-12-13 08:06:06 +07:00
|
|
|
static void lbs_ethtool_get_wol(struct net_device *dev,
|
|
|
|
struct ethtool_wolinfo *wol)
|
|
|
|
{
|
2009-02-20 07:32:39 +07:00
|
|
|
struct lbs_private *priv = dev->ml_priv;
|
2007-12-13 08:06:06 +07:00
|
|
|
|
|
|
|
if (priv->wol_criteria == 0xffffffff) {
|
|
|
|
/* Interface driver didn't configure wake */
|
|
|
|
wol->supported = wol->wolopts = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wol->supported = WAKE_UCAST|WAKE_MCAST|WAKE_BCAST|WAKE_PHY;
|
|
|
|
|
|
|
|
if (priv->wol_criteria & EHS_WAKE_ON_UNICAST_DATA)
|
|
|
|
wol->wolopts |= WAKE_UCAST;
|
|
|
|
if (priv->wol_criteria & EHS_WAKE_ON_MULTICAST_DATA)
|
|
|
|
wol->wolopts |= WAKE_MCAST;
|
|
|
|
if (priv->wol_criteria & EHS_WAKE_ON_BROADCAST_DATA)
|
|
|
|
wol->wolopts |= WAKE_BCAST;
|
|
|
|
if (priv->wol_criteria & EHS_WAKE_ON_MAC_EVENT)
|
|
|
|
wol->wolopts |= WAKE_PHY;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int lbs_ethtool_set_wol(struct net_device *dev,
|
|
|
|
struct ethtool_wolinfo *wol)
|
|
|
|
{
|
2009-02-20 07:32:39 +07:00
|
|
|
struct lbs_private *priv = dev->ml_priv;
|
2007-12-13 08:06:06 +07:00
|
|
|
uint32_t criteria = 0;
|
|
|
|
|
|
|
|
if (wol->wolopts & ~(WAKE_UCAST|WAKE_MCAST|WAKE_BCAST|WAKE_PHY))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2009-11-10 09:04:12 +07:00
|
|
|
if (wol->wolopts & WAKE_UCAST)
|
|
|
|
criteria |= EHS_WAKE_ON_UNICAST_DATA;
|
|
|
|
if (wol->wolopts & WAKE_MCAST)
|
|
|
|
criteria |= EHS_WAKE_ON_MULTICAST_DATA;
|
|
|
|
if (wol->wolopts & WAKE_BCAST)
|
|
|
|
criteria |= EHS_WAKE_ON_BROADCAST_DATA;
|
|
|
|
if (wol->wolopts & WAKE_PHY)
|
|
|
|
criteria |= EHS_WAKE_ON_MAC_EVENT;
|
2009-11-10 09:04:13 +07:00
|
|
|
if (wol->wolopts == 0)
|
|
|
|
criteria |= EHS_REMOVE_WAKEUP;
|
2007-12-13 08:06:06 +07:00
|
|
|
|
2008-10-21 06:46:56 +07:00
|
|
|
return lbs_host_sleep_cfg(priv, criteria, (struct wol_config *)NULL);
|
2007-12-13 08:06:06 +07:00
|
|
|
}
|
|
|
|
|
2009-09-02 15:03:33 +07:00
|
|
|
const struct ethtool_ops lbs_ethtool_ops = {
|
2007-11-16 06:05:47 +07:00
|
|
|
.get_drvinfo = lbs_ethtool_get_drvinfo,
|
|
|
|
.get_eeprom = lbs_ethtool_get_eeprom,
|
|
|
|
.get_eeprom_len = lbs_ethtool_get_eeprom_len,
|
|
|
|
.get_sset_count = lbs_ethtool_get_sset_count,
|
|
|
|
.get_ethtool_stats = lbs_ethtool_get_stats,
|
|
|
|
.get_strings = lbs_ethtool_get_strings,
|
2007-12-13 08:06:06 +07:00
|
|
|
.get_wol = lbs_ethtool_get_wol,
|
|
|
|
.set_wol = lbs_ethtool_set_wol,
|
2007-02-10 21:25:27 +07:00
|
|
|
};
|
|
|
|
|