1 #include <linux/netdevice.h>
2 #include <linux/ethtool.h>
3 #include <linux/delay.h>
11 static const char * mesh_stat_strings
[]= {
12 "drop_duplicate_bcast",
22 static void lbs_ethtool_get_drvinfo(struct net_device
*dev
,
23 struct ethtool_drvinfo
*info
)
25 struct lbs_private
*priv
= (struct lbs_private
*) dev
->priv
;
28 lbs_get_fwversion(priv
, fwver
, sizeof(fwver
) - 1);
30 strcpy(info
->driver
, "libertas");
31 strcpy(info
->version
, lbs_driver_version
);
32 strcpy(info
->fw_version
, fwver
);
35 /* All 8388 parts have 16KiB EEPROM size at the time of writing.
36 * In case that changes this needs fixing.
38 #define LBS_EEPROM_LEN 16384
40 static int lbs_ethtool_get_eeprom_len(struct net_device
*dev
)
42 return LBS_EEPROM_LEN
;
45 static int lbs_ethtool_get_eeprom(struct net_device
*dev
,
46 struct ethtool_eeprom
*eeprom
, u8
* bytes
)
48 struct lbs_private
*priv
= (struct lbs_private
*) dev
->priv
;
49 struct lbs_ioctl_regrdwr regctrl
;
54 regctrl
.offset
= eeprom
->offset
;
55 regctrl
.NOB
= eeprom
->len
;
57 if (eeprom
->offset
+ eeprom
->len
> LBS_EEPROM_LEN
)
60 // mutex_lock(&priv->mutex);
62 priv
->prdeeprom
= kmalloc(eeprom
->len
+sizeof(regctrl
), GFP_KERNEL
);
65 memcpy(priv
->prdeeprom
, ®ctrl
, sizeof(regctrl
));
67 /* +14 is for action, offset, and NOB in
69 lbs_deb_ethtool("action:%d offset: %x NOB: %02x\n",
70 regctrl
.action
, regctrl
.offset
, regctrl
.NOB
);
72 ret
= lbs_prepare_and_send_command(priv
,
73 CMD_802_11_EEPROM_ACCESS
,
75 CMD_OPTION_WAITFORRSP
, 0,
80 kfree(priv
->prdeeprom
);
86 ptr
= (char *)priv
->prdeeprom
;
88 /* skip the command header, but include the "value" u32 variable */
89 ptr
= ptr
+ sizeof(struct lbs_ioctl_regrdwr
) - 4;
92 * Return the result back to the user
94 memcpy(bytes
, ptr
, eeprom
->len
);
97 kfree(priv
->prdeeprom
);
98 // mutex_unlock(&priv->mutex);
103 lbs_deb_enter_args(LBS_DEB_ETHTOOL
, "ret %d", ret
);
107 static void lbs_ethtool_get_stats(struct net_device
* dev
,
108 struct ethtool_stats
* stats
, u64
* data
)
110 struct lbs_private
*priv
= dev
->priv
;
111 struct cmd_ds_mesh_access mesh_access
;
114 lbs_deb_enter(LBS_DEB_ETHTOOL
);
116 /* Get Mesh Statistics */
117 ret
= lbs_prepare_and_send_command(priv
,
118 CMD_MESH_ACCESS
, CMD_ACT_MESH_GET_STATS
,
119 CMD_OPTION_WAITFORRSP
, 0, &mesh_access
);
124 priv
->mstats
.fwd_drop_rbt
= le32_to_cpu(mesh_access
.data
[0]);
125 priv
->mstats
.fwd_drop_ttl
= le32_to_cpu(mesh_access
.data
[1]);
126 priv
->mstats
.fwd_drop_noroute
= le32_to_cpu(mesh_access
.data
[2]);
127 priv
->mstats
.fwd_drop_nobuf
= le32_to_cpu(mesh_access
.data
[3]);
128 priv
->mstats
.fwd_unicast_cnt
= le32_to_cpu(mesh_access
.data
[4]);
129 priv
->mstats
.fwd_bcast_cnt
= le32_to_cpu(mesh_access
.data
[5]);
130 priv
->mstats
.drop_blind
= le32_to_cpu(mesh_access
.data
[6]);
131 priv
->mstats
.tx_failed_cnt
= le32_to_cpu(mesh_access
.data
[7]);
133 data
[0] = priv
->mstats
.fwd_drop_rbt
;
134 data
[1] = priv
->mstats
.fwd_drop_ttl
;
135 data
[2] = priv
->mstats
.fwd_drop_noroute
;
136 data
[3] = priv
->mstats
.fwd_drop_nobuf
;
137 data
[4] = priv
->mstats
.fwd_unicast_cnt
;
138 data
[5] = priv
->mstats
.fwd_bcast_cnt
;
139 data
[6] = priv
->mstats
.drop_blind
;
140 data
[7] = priv
->mstats
.tx_failed_cnt
;
142 lbs_deb_enter(LBS_DEB_ETHTOOL
);
145 static void lbs_ethtool_get_strings(struct net_device
*dev
,
151 lbs_deb_enter(LBS_DEB_ETHTOOL
);
155 for (i
=0; i
< MESH_STATS_NUM
; i
++) {
156 memcpy(s
+ i
* ETH_GSTRING_LEN
,
157 mesh_stat_strings
[i
],
162 lbs_deb_enter(LBS_DEB_ETHTOOL
);
165 struct ethtool_ops lbs_ethtool_ops
= {
166 .get_drvinfo
= lbs_ethtool_get_drvinfo
,
167 .get_eeprom
= lbs_ethtool_get_eeprom
,
168 .get_eeprom_len
= lbs_ethtool_get_eeprom_len
,
169 .get_ethtool_stats
= lbs_ethtool_get_stats
,
170 .get_strings
= lbs_ethtool_get_strings
,