2 #include <linux/netdevice.h>
3 #include <linux/ethtool.h>
4 #include <linux/delay.h>
13 static const char * mesh_stat_strings[]= {
14 "drop_duplicate_bcast",
24 static void libertas_ethtool_get_drvinfo(struct net_device *dev,
25 struct ethtool_drvinfo *info)
27 wlan_private *priv = (wlan_private *) dev->priv;
30 libertas_get_fwversion(priv->adapter, fwver, sizeof(fwver) - 1);
32 strcpy(info->driver, "libertas");
33 strcpy(info->version, libertas_driver_version);
34 strcpy(info->fw_version, fwver);
37 /* All 8388 parts have 16KiB EEPROM size at the time of writing.
38 * In case that changes this needs fixing.
40 #define LIBERTAS_EEPROM_LEN 16384
42 static int libertas_ethtool_get_eeprom_len(struct net_device *dev)
44 return LIBERTAS_EEPROM_LEN;
47 static int libertas_ethtool_get_eeprom(struct net_device *dev,
48 struct ethtool_eeprom *eeprom, u8 * bytes)
50 wlan_private *priv = (wlan_private *) dev->priv;
51 wlan_adapter *adapter = priv->adapter;
52 struct wlan_ioctl_regrdwr regctrl;
57 regctrl.offset = eeprom->offset;
58 regctrl.NOB = eeprom->len;
60 if (eeprom->offset + eeprom->len > LIBERTAS_EEPROM_LEN)
63 // mutex_lock(&priv->mutex);
66 (char *)kmalloc(eeprom->len+sizeof(regctrl), GFP_KERNEL);
67 if (!adapter->prdeeprom)
69 memcpy(adapter->prdeeprom, ®ctrl, sizeof(regctrl));
71 /* +14 is for action, offset, and NOB in
73 lbs_deb_ethtool("action:%d offset: %x NOB: %02x\n",
74 regctrl.action, regctrl.offset, regctrl.NOB);
76 ret = libertas_prepare_and_send_command(priv,
77 cmd_802_11_eeprom_access,
79 cmd_option_waitforrsp, 0,
83 if (adapter->prdeeprom)
84 kfree(adapter->prdeeprom);
90 ptr = (char *)adapter->prdeeprom;
92 /* skip the command header, but include the "value" u32 variable */
93 ptr = ptr + sizeof(struct wlan_ioctl_regrdwr) - 4;
96 * Return the result back to the user
98 memcpy(bytes, ptr, eeprom->len);
100 if (adapter->prdeeprom)
101 kfree(adapter->prdeeprom);
102 // mutex_unlock(&priv->mutex);
107 lbs_deb_enter_args(LBS_DEB_ETHTOOL, "ret %d", ret);
111 static void libertas_ethtool_get_stats(struct net_device * dev,
112 struct ethtool_stats * stats, u64 * data)
114 wlan_private *priv = dev->priv;
116 lbs_deb_enter(LBS_DEB_ETHTOOL);
118 stats->cmd = ETHTOOL_GSTATS;
119 BUG_ON(stats->n_stats != MESH_STATS_NUM);
121 data[0] = priv->mstats.fwd_drop_rbt;
122 data[1] = priv->mstats.fwd_drop_ttl;
123 data[2] = priv->mstats.fwd_drop_noroute;
124 data[3] = priv->mstats.fwd_drop_nobuf;
125 data[4] = priv->mstats.fwd_unicast_cnt;
126 data[5] = priv->mstats.fwd_bcast_cnt;
127 data[6] = priv->mstats.drop_blind;
128 data[7] = priv->mstats.tx_failed_cnt;
130 lbs_deb_enter(LBS_DEB_ETHTOOL);
133 static int libertas_ethtool_get_stats_count(struct net_device * dev)
136 wlan_private *priv = dev->priv;
137 struct cmd_ds_mesh_access mesh_access;
139 lbs_deb_enter(LBS_DEB_ETHTOOL);
141 /* Get Mesh Statistics */
142 ret = libertas_prepare_and_send_command(priv,
143 cmd_mesh_access, cmd_act_mesh_get_stats,
144 cmd_option_waitforrsp, 0, &mesh_access);
151 priv->mstats.fwd_drop_rbt = mesh_access.data[0];
152 priv->mstats.fwd_drop_ttl = mesh_access.data[1];
153 priv->mstats.fwd_drop_noroute = mesh_access.data[2];
154 priv->mstats.fwd_drop_nobuf = mesh_access.data[3];
155 priv->mstats.fwd_unicast_cnt = mesh_access.data[4];
156 priv->mstats.fwd_bcast_cnt = mesh_access.data[5];
157 priv->mstats.drop_blind = mesh_access.data[6];
158 priv->mstats.tx_failed_cnt = mesh_access.data[7];
160 ret = MESH_STATS_NUM;
163 lbs_deb_enter_args(LBS_DEB_ETHTOOL, "ret %d", ret);
167 static void libertas_ethtool_get_strings (struct net_device * dev,
173 lbs_deb_enter(LBS_DEB_ETHTOOL);
177 for (i=0; i < MESH_STATS_NUM; i++) {
178 memcpy(s + i * ETH_GSTRING_LEN,
179 mesh_stat_strings[i],
184 lbs_deb_enter(LBS_DEB_ETHTOOL);
187 struct ethtool_ops libertas_ethtool_ops = {
188 .get_drvinfo = libertas_ethtool_get_drvinfo,
189 .get_eeprom = libertas_ethtool_get_eeprom,
190 .get_eeprom_len = libertas_ethtool_get_eeprom_len,
191 .get_stats_count = libertas_ethtool_get_stats_count,
192 .get_ethtool_stats = libertas_ethtool_get_stats,
193 .get_strings = libertas_ethtool_get_strings,