summaryrefslogtreecommitdiff
path: root/device.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2021-08-02 22:48:44 +0200
committerFelix Fietkau <nbd@nbd.name>2021-08-02 22:48:46 +0200
commit1eb0fafaa9865b729509a7d47ecf1f05c2c0595c (patch)
treed1c89dafedf33e0ef2ccfcf07d19c9465ba02222 /device.c
parent94170ae24bc96aa988eb901f19cce2aebdb046f5 (diff)
downloadnetifd-1eb0fafaa9865b729509a7d47ecf1f05c2c0595c.tar.gz
device: add support for configuring device link speed/duplex
The 'speed' option can be set to the speed in Mbps The 'duplex' option can be 1 or 0 for full or half duplex Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'device.c')
-rw-r--r--device.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/device.c b/device.c
index f9ec635..521d9a6 100644
--- a/device.c
+++ b/device.c
@@ -61,6 +61,8 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = {
[DEV_ATTR_DROP_UNSOLICITED_NA] = { .name = "drop_unsolicited_na", .type = BLOBMSG_TYPE_BOOL },
[DEV_ATTR_ARP_ACCEPT] = { .name = "arp_accept", .type = BLOBMSG_TYPE_BOOL },
[DEV_ATTR_AUTH] = { .name = "auth", .type = BLOBMSG_TYPE_BOOL },
+ [DEV_ATTR_SPEED] = { .name = "speed", .type = BLOBMSG_TYPE_INT32 },
+ [DEV_ATTR_DUPLEX] = { .name = "duplex", .type = BLOBMSG_TYPE_BOOL },
};
const struct uci_blob_param_list device_attr_list = {
@@ -276,6 +278,8 @@ device_merge_settings(struct device *dev, struct device_settings *n)
n->arp_accept = s->flags & DEV_OPT_ARP_ACCEPT ?
s->arp_accept : os->arp_accept;
n->auth = s->flags & DEV_OPT_AUTH ? s->auth : os->auth;
+ n->speed = s->flags & DEV_OPT_SPEED ? s->speed : os->speed;
+ n->duplex = s->flags & DEV_OPT_DUPLEX ? s->duplex : os->duplex;
n->flags = s->flags | os->flags | os->valid_flags;
}
@@ -450,6 +454,16 @@ device_init_settings(struct device *dev, struct blob_attr **tb)
s->flags |= DEV_OPT_AUTH;
}
+ if ((cur = tb[DEV_ATTR_SPEED])) {
+ s->speed = blobmsg_get_u32(cur);
+ s->flags |= DEV_OPT_SPEED;
+ }
+
+ if ((cur = tb[DEV_ATTR_DUPLEX])) {
+ s->duplex = blobmsg_get_bool(cur);
+ s->flags |= DEV_OPT_DUPLEX;
+ }
+
device_set_disabled(dev, disabled);
}