Add support for configurable EEE option i.e. energy efficient ethernet.
The option can be configured by adding the config for the device in the
network uci config. Example:
config device
option name 'eth0'
option eee '1'
Signed-off-by: Rahul Thakur <rahul.thakur@iopsys.eu>
[DEV_ATTR_AUTONEG] = { .name = "autoneg", .type = BLOBMSG_TYPE_BOOL },
[DEV_ATTR_GRO] = { .name = "gro", .type = BLOBMSG_TYPE_BOOL },
[DEV_ATTR_MASTER] = { .name = "conduit", .type = BLOBMSG_TYPE_STRING },
+ [DEV_ATTR_EEE] = { .name = "eee", .type = BLOBMSG_TYPE_BOOL },
};
const struct uci_blob_param_list device_attr_list = {
n->txpause = s->flags & DEV_OPT_TXPAUSE ? s->txpause : os->txpause;
n->autoneg = s->flags & DEV_OPT_AUTONEG ? s->autoneg : os->autoneg;
n->gro = s->flags & DEV_OPT_GRO ? s->gro : os->gro;
+ n->eee = s->flags & DEV_OPT_EEE ? s->eee : os->eee;
n->master_ifindex = s->flags & DEV_OPT_MASTER ? s->master_ifindex : os->master_ifindex;
n->flags = s->flags | os->flags | os->valid_flags;
}
s->flags |= DEV_OPT_MASTER;
}
+ if ((cur = tb[DEV_ATTR_EEE])) {
+ s->eee = blobmsg_get_bool(cur);
+ s->flags |= DEV_OPT_EEE;
+ }
+
cur = tb[DEV_ATTR_AUTH_VLAN];
free(dev->config_auth_vlans);
dev->config_auth_vlans = cur ? blob_memdup(cur) : NULL;
blobmsg_add_u8(b, "auth", st.auth);
if (st.flags & DEV_OPT_GRO)
blobmsg_add_u8(b, "gro", st.gro);
+ if (st.flags & DEV_OPT_EEE)
+ blobmsg_add_u8(b, "eee", st.eee);
}
s = blobmsg_open_table(b, "statistics");
DEV_ATTR_AUTONEG,
DEV_ATTR_GRO,
DEV_ATTR_MASTER,
+ DEV_ATTR_EEE,
__DEV_ATTR_MAX,
};
DEV_OPT_AUTONEG = (1ULL << 36),
DEV_OPT_GRO = (1ULL << 37),
DEV_OPT_MASTER = (1ULL << 38),
+ DEV_OPT_EEE = (1ULL << 39),
};
/* events broadcasted to all users of a device */
bool autoneg;
bool gro;
int master_ifindex;
+ bool eee;
};
struct device_vlan_range {
ioctl(sock_ioctl, SIOCETHTOOL, &ifr);
}
+static void
+system_set_ethtool_eee_settings(struct device *dev, struct device_settings *s)
+{
+ struct ethtool_eee eeecmd;
+ struct ifreq ifr = {
+ .ifr_data = (caddr_t)&eeecmd,
+ };
+
+ memset(&eeecmd, 0, sizeof(eeecmd));
+ eeecmd.cmd = ETHTOOL_SEEE;
+ eeecmd.eee_enabled = s->eee;
+ strncpy(ifr.ifr_name, dev->ifname, sizeof(ifr.ifr_name) - 1);
+
+ if (ioctl(sock_ioctl, SIOCETHTOOL, &ifr) != 0)
+ netifd_log_message(L_WARNING, "cannot set eee %d for device %s", s->eee, dev->ifname);
+}
+
static void
system_set_ethtool_settings(struct device *dev, struct device_settings *s)
{
system_set_ethtool_pause(dev, s);
+ if (s->flags & DEV_OPT_EEE)
+ system_set_ethtool_eee_settings(dev, s);
+
memset(&ecmd, 0, sizeof(ecmd));
ecmd.req.cmd = ETHTOOL_GLINKSETTINGS;
strncpy(ifr.ifr_name, dev->ifname, sizeof(ifr.ifr_name) - 1);