1 #include <linux/netdevice.h>
2 #include <linux/ethtool.h>
3 #include <linux/delay.h>
9 static void lbs_ethtool_get_drvinfo(struct net_device
*dev
,
10 struct ethtool_drvinfo
*info
)
12 struct lbs_private
*priv
= dev
->ml_priv
;
14 snprintf(info
->fw_version
, 32, "%u.%u.%u.p%u",
15 priv
->fwrelease
>> 24 & 0xff,
16 priv
->fwrelease
>> 16 & 0xff,
17 priv
->fwrelease
>> 8 & 0xff,
18 priv
->fwrelease
& 0xff);
19 strcpy(info
->driver
, "libertas");
20 strcpy(info
->version
, lbs_driver_version
);
24 * All 8388 parts have 16KiB EEPROM size at the time of writing.
25 * In case that changes this needs fixing.
27 #define LBS_EEPROM_LEN 16384
29 static int lbs_ethtool_get_eeprom_len(struct net_device
*dev
)
31 return LBS_EEPROM_LEN
;
34 static int lbs_ethtool_get_eeprom(struct net_device
*dev
,
35 struct ethtool_eeprom
*eeprom
, u8
* bytes
)
37 struct lbs_private
*priv
= dev
->ml_priv
;
38 struct cmd_ds_802_11_eeprom_access cmd
;
41 lbs_deb_enter(LBS_DEB_ETHTOOL
);
43 if (eeprom
->offset
+ eeprom
->len
> LBS_EEPROM_LEN
||
44 eeprom
->len
> LBS_EEPROM_READ_LEN
) {
49 cmd
.hdr
.size
= cpu_to_le16(sizeof(struct cmd_ds_802_11_eeprom_access
) -
50 LBS_EEPROM_READ_LEN
+ eeprom
->len
);
51 cmd
.action
= cpu_to_le16(CMD_ACT_GET
);
52 cmd
.offset
= cpu_to_le16(eeprom
->offset
);
53 cmd
.len
= cpu_to_le16(eeprom
->len
);
54 ret
= lbs_cmd_with_response(priv
, CMD_802_11_EEPROM_ACCESS
, &cmd
);
56 memcpy(bytes
, cmd
.value
, eeprom
->len
);
59 lbs_deb_leave_args(LBS_DEB_ETHTOOL
, "ret %d", ret
);
63 static void lbs_ethtool_get_wol(struct net_device
*dev
,
64 struct ethtool_wolinfo
*wol
)
66 struct lbs_private
*priv
= dev
->ml_priv
;
68 wol
->supported
= WAKE_UCAST
|WAKE_MCAST
|WAKE_BCAST
|WAKE_PHY
;
70 if (priv
->wol_criteria
== EHS_REMOVE_WAKEUP
)
73 if (priv
->wol_criteria
& EHS_WAKE_ON_UNICAST_DATA
)
74 wol
->wolopts
|= WAKE_UCAST
;
75 if (priv
->wol_criteria
& EHS_WAKE_ON_MULTICAST_DATA
)
76 wol
->wolopts
|= WAKE_MCAST
;
77 if (priv
->wol_criteria
& EHS_WAKE_ON_BROADCAST_DATA
)
78 wol
->wolopts
|= WAKE_BCAST
;
79 if (priv
->wol_criteria
& EHS_WAKE_ON_MAC_EVENT
)
80 wol
->wolopts
|= WAKE_PHY
;
83 static int lbs_ethtool_set_wol(struct net_device
*dev
,
84 struct ethtool_wolinfo
*wol
)
86 struct lbs_private
*priv
= dev
->ml_priv
;
88 if (wol
->wolopts
& ~(WAKE_UCAST
|WAKE_MCAST
|WAKE_BCAST
|WAKE_PHY
))
91 priv
->wol_criteria
= 0;
92 if (wol
->wolopts
& WAKE_UCAST
)
93 priv
->wol_criteria
|= EHS_WAKE_ON_UNICAST_DATA
;
94 if (wol
->wolopts
& WAKE_MCAST
)
95 priv
->wol_criteria
|= EHS_WAKE_ON_MULTICAST_DATA
;
96 if (wol
->wolopts
& WAKE_BCAST
)
97 priv
->wol_criteria
|= EHS_WAKE_ON_BROADCAST_DATA
;
98 if (wol
->wolopts
& WAKE_PHY
)
99 priv
->wol_criteria
|= EHS_WAKE_ON_MAC_EVENT
;
100 if (wol
->wolopts
== 0)
101 priv
->wol_criteria
|= EHS_REMOVE_WAKEUP
;
105 const struct ethtool_ops lbs_ethtool_ops
= {
106 .get_drvinfo
= lbs_ethtool_get_drvinfo
,
107 .get_eeprom
= lbs_ethtool_get_eeprom
,
108 .get_eeprom_len
= lbs_ethtool_get_eeprom_len
,
109 #ifdef CONFIG_LIBERTAS_MESH
110 .get_sset_count
= lbs_mesh_ethtool_get_sset_count
,
111 .get_ethtool_stats
= lbs_mesh_ethtool_get_stats
,
112 .get_strings
= lbs_mesh_ethtool_get_strings
,
114 .get_wol
= lbs_ethtool_get_wol
,
115 .set_wol
= lbs_ethtool_set_wol
,