@@ -3322,6 +3322,58 @@ static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch)
33223322 return 0 ;
33233323}
33243324
3325+ /**
3326+ * ice_get_wol - get current Wake on LAN configuration
3327+ * @netdev: network interface device structure
3328+ * @wol: Ethtool structure to retrieve WoL settings
3329+ */
3330+ static void ice_get_wol (struct net_device * netdev , struct ethtool_wolinfo * wol )
3331+ {
3332+ struct ice_netdev_priv * np = netdev_priv (netdev );
3333+ struct ice_pf * pf = np -> vsi -> back ;
3334+
3335+ if (np -> vsi -> type != ICE_VSI_PF )
3336+ netdev_warn (netdev , "Wake on LAN is not supported on this interface!\n" );
3337+
3338+ /* Get WoL settings based on the HW capability */
3339+ if (ice_is_wol_supported (pf )) {
3340+ wol -> supported = WAKE_MAGIC ;
3341+ wol -> wolopts = pf -> wol_ena ? WAKE_MAGIC : 0 ;
3342+ } else {
3343+ wol -> supported = 0 ;
3344+ wol -> wolopts = 0 ;
3345+ }
3346+ }
3347+
3348+ /**
3349+ * ice_set_wol - set Wake on LAN on supported device
3350+ * @netdev: network interface device structure
3351+ * @wol: Ethtool structure to set WoL
3352+ */
3353+ static int ice_set_wol (struct net_device * netdev , struct ethtool_wolinfo * wol )
3354+ {
3355+ struct ice_netdev_priv * np = netdev_priv (netdev );
3356+ struct ice_vsi * vsi = np -> vsi ;
3357+ struct ice_pf * pf = vsi -> back ;
3358+
3359+ if (vsi -> type != ICE_VSI_PF || !ice_is_wol_supported (pf ))
3360+ return - EOPNOTSUPP ;
3361+
3362+ /* only magic packet is supported */
3363+ if (wol -> wolopts && wol -> wolopts != WAKE_MAGIC )
3364+ return - EOPNOTSUPP ;
3365+
3366+ /* Set WoL only if there is a new value */
3367+ if (pf -> wol_ena != !!wol -> wolopts ) {
3368+ pf -> wol_ena = !!wol -> wolopts ;
3369+ device_set_wakeup_enable (ice_pf_to_dev (pf ), pf -> wol_ena );
3370+ netdev_dbg (netdev , "WoL magic packet %sabled\n" ,
3371+ pf -> wol_ena ? "en" : "dis" );
3372+ }
3373+
3374+ return 0 ;
3375+ }
3376+
33253377enum ice_container_type {
33263378 ICE_RX_CONTAINER ,
33273379 ICE_TX_CONTAINER ,
@@ -3805,6 +3857,8 @@ static const struct ethtool_ops ice_ethtool_ops = {
38053857 .get_drvinfo = ice_get_drvinfo ,
38063858 .get_regs_len = ice_get_regs_len ,
38073859 .get_regs = ice_get_regs ,
3860+ .get_wol = ice_get_wol ,
3861+ .set_wol = ice_set_wol ,
38083862 .get_msglevel = ice_get_msglevel ,
38093863 .set_msglevel = ice_set_msglevel ,
38103864 .self_test = ice_self_test ,
@@ -3847,6 +3901,8 @@ static const struct ethtool_ops ice_ethtool_safe_mode_ops = {
38473901 .get_drvinfo = ice_get_drvinfo ,
38483902 .get_regs_len = ice_get_regs_len ,
38493903 .get_regs = ice_get_regs ,
3904+ .get_wol = ice_get_wol ,
3905+ .set_wol = ice_set_wol ,
38503906 .get_msglevel = ice_get_msglevel ,
38513907 .set_msglevel = ice_set_msglevel ,
38523908 .get_link = ethtool_op_get_link ,
0 commit comments