1 #include <linux/hardirq.h>
2 #include <linux/netdevice.h>
3 #include <linux/ethtool.h>
4 #include <linux/delay.h>
11 static void lbs_ethtool_get_drvinfo(struct net_device
*dev
,
12 struct ethtool_drvinfo
*info
)
14 struct lbs_private
*priv
= dev
->ml_priv
;
16 snprintf(info
->fw_version
, 32, "%u.%u.%u.p%u",
17 priv
->fwrelease
>> 24 & 0xff,
18 priv
->fwrelease
>> 16 & 0xff,
19 priv
->fwrelease
>> 8 & 0xff,
20 priv
->fwrelease
& 0xff);
21 strcpy(info
->driver
, "libertas");
22 strcpy(info
->version
, lbs_driver_version
);
26 * All 8388 parts have 16KiB EEPROM size at the time of writing.
27 * In case that changes this needs fixing.
29 #define LBS_EEPROM_LEN 16384
31 static int lbs_ethtool_get_eeprom_len(struct net_device
*dev
)
33 return LBS_EEPROM_LEN
;
36 static int lbs_ethtool_get_eeprom(struct net_device
*dev
,
37 struct ethtool_eeprom
*eeprom
, u8
* bytes
)
39 struct lbs_private
*priv
= dev
->ml_priv
;
40 struct cmd_ds_802_11_eeprom_access cmd
;
43 lbs_deb_enter(LBS_DEB_ETHTOOL
);
45 if (eeprom
->offset
+ eeprom
->len
> LBS_EEPROM_LEN
||
46 eeprom
->len
> LBS_EEPROM_READ_LEN
) {
51 cmd
.hdr
.size
= cpu_to_le16(sizeof(struct cmd_ds_802_11_eeprom_access
) -
52 LBS_EEPROM_READ_LEN
+ eeprom
->len
);
53 cmd
.action
= cpu_to_le16(CMD_ACT_GET
);
54 cmd
.offset
= cpu_to_le16(eeprom
->offset
);
55 cmd
.len
= cpu_to_le16(eeprom
->len
);
56 ret
= lbs_cmd_with_response(priv
, CMD_802_11_EEPROM_ACCESS
, &cmd
);
58 memcpy(bytes
, cmd
.value
, eeprom
->len
);
61 lbs_deb_leave_args(LBS_DEB_ETHTOOL
, "ret %d", ret
);
65 static void lbs_ethtool_get_wol(struct net_device
*dev
,
66 struct ethtool_wolinfo
*wol
)
68 struct lbs_private
*priv
= dev
->ml_priv
;
70 wol
->supported
= WAKE_UCAST
|WAKE_MCAST
|WAKE_BCAST
|WAKE_PHY
;
72 if (priv
->wol_criteria
== EHS_REMOVE_WAKEUP
)
75 if (priv
->wol_criteria
& EHS_WAKE_ON_UNICAST_DATA
)
76 wol
->wolopts
|= WAKE_UCAST
;
77 if (priv
->wol_criteria
& EHS_WAKE_ON_MULTICAST_DATA
)
78 wol
->wolopts
|= WAKE_MCAST
;
79 if (priv
->wol_criteria
& EHS_WAKE_ON_BROADCAST_DATA
)
80 wol
->wolopts
|= WAKE_BCAST
;
81 if (priv
->wol_criteria
& EHS_WAKE_ON_MAC_EVENT
)
82 wol
->wolopts
|= WAKE_PHY
;
85 static int lbs_ethtool_set_wol(struct net_device
*dev
,
86 struct ethtool_wolinfo
*wol
)
88 struct lbs_private
*priv
= dev
->ml_priv
;
90 if (wol
->wolopts
& ~(WAKE_UCAST
|WAKE_MCAST
|WAKE_BCAST
|WAKE_PHY
))
93 priv
->wol_criteria
= 0;
94 if (wol
->wolopts
& WAKE_UCAST
)
95 priv
->wol_criteria
|= EHS_WAKE_ON_UNICAST_DATA
;
96 if (wol
->wolopts
& WAKE_MCAST
)
97 priv
->wol_criteria
|= EHS_WAKE_ON_MULTICAST_DATA
;
98 if (wol
->wolopts
& WAKE_BCAST
)
99 priv
->wol_criteria
|= EHS_WAKE_ON_BROADCAST_DATA
;
100 if (wol
->wolopts
& WAKE_PHY
)
101 priv
->wol_criteria
|= EHS_WAKE_ON_MAC_EVENT
;
102 if (wol
->wolopts
== 0)
103 priv
->wol_criteria
|= EHS_REMOVE_WAKEUP
;
107 const struct ethtool_ops lbs_ethtool_ops
= {
108 .get_drvinfo
= lbs_ethtool_get_drvinfo
,
109 .get_eeprom
= lbs_ethtool_get_eeprom
,
110 .get_eeprom_len
= lbs_ethtool_get_eeprom_len
,
111 #ifdef CONFIG_LIBERTAS_MESH
112 .get_sset_count
= lbs_mesh_ethtool_get_sset_count
,
113 .get_ethtool_stats
= lbs_mesh_ethtool_get_stats
,
114 .get_strings
= lbs_mesh_ethtool_get_strings
,
116 .get_wol
= lbs_ethtool_get_wol
,
117 .set_wol
= lbs_ethtool_set_wol
,