[PATCH] base-files: add support for heartbeat led trigger

2022-01-03 Thread Alexey Smirnov
This patch adds support for creation heartbeat led trigger with,
for example, this command:

ucidef_set_led_heartbeat "..." "..." "..."

from /etc/board.d/01_leds.

Signed-off-by: Alexey Smirnov 
---
 package/base-files/files/lib/functions/uci-defaults.sh | 9 +
 1 file changed, 9 insertions(+)

diff --git a/package/base-files/files/lib/functions/uci-defaults.sh 
b/package/base-files/files/lib/functions/uci-defaults.sh
index 02882f43ca..f96e645e73 100644
--- a/package/base-files/files/lib/functions/uci-defaults.sh
+++ b/package/base-files/files/lib/functions/uci-defaults.sh
@@ -418,6 +418,15 @@ ucidef_set_led_default() {
json_select ..
 }
 
+ucidef_set_led_heartbeat() {
+   _ucidef_set_led_common "$1" "$2" "$3"
+
+   json_add_string trigger heartbeat
+   json_select ..
+
+   json_select ..
+}
+
 ucidef_set_led_gpio() {
local gpio="$4"
local inverted="$5"
-- 
2.25.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] omap: add support for the TRNG Hardware Accelerator

2022-01-10 Thread Alexey Smirnov
According to TI docs (Processor SDK Linux Getting Started Guide)
the Random Number Generator hardware is found on
OMAP16xx, OMAP2/3/4/5, AM33xx/AM43xx boards. It already
defined in device tree files. Let's enable it.

Some tests:

root@RTS1_OI:~# rngtest -c 1000 
---
 target/linux/omap/config-5.10 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/target/linux/omap/config-5.10 b/target/linux/omap/config-5.10
index 3daa6c0921..05ebd5f860 100644
--- a/target/linux/omap/config-5.10
+++ b/target/linux/omap/config-5.10
@@ -265,6 +265,8 @@ CONFIG_HSI=y
 CONFIG_HSI_BOARDINFO=y
 # CONFIG_HSI_CHAR is not set
 CONFIG_HWMON=y
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_OMAP=y
 CONFIG_HZ_FIXED=0
 CONFIG_I2C=y
 CONFIG_I2C_ALGOBIT=y
-- 
2.25.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] x86: geode: use kernel [hwrng] to provide randomness

2022-01-24 Thread Alexey Smirnov
I wonder, does it applicable for all targets with HW RNG support?
Is it necessary to have quality of HW RNG not less than 1000 for kernel
to use /dev/hwrng directly without user space tools like rng-tools? 

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 1/1] netifd: device: add ipvlan support

2022-11-14 Thread Alexey Smirnov
This almost copy-paste from macvlan device with corresponding changes.

Signed-off-by: Alexey Smirnov 
---
 CMakeLists.txt |   2 +-
 ipvlan.c   | 263 +
 system-dummy.c |  10 ++
 system-linux.c |  76 ++
 system.h   |   8 ++
 5 files changed, 358 insertions(+), 1 deletion(-)
 create mode 100644 ipvlan.c

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b3bf411..0af7af5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,7 +20,7 @@ SET(SOURCES
interface.c interface-ip.c interface-event.c
iprule.c proto.c proto-static.c proto-shell.c
config.c device.c bridge.c veth.c vlan.c alias.c
-   macvlan.c ubus.c vlandev.c wireless.c
+   ipvlan.c macvlan.c ubus.c vlandev.c wireless.c
extdev.c bonding.c)
 
 
diff --git a/ipvlan.c b/ipvlan.c
new file mode 100644
index 000..af597cb
--- /dev/null
+++ b/ipvlan.c
@@ -0,0 +1,263 @@
+/*
+ * netifd - network interface daemon
+ * Copyright (C) 2012 Felix Fietkau 
+ * Copyright (C) 2013 Jo-Philipp Wich 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "netifd.h"
+#include "device.h"
+#include "interface.h"
+#include "system.h"
+
+enum {
+   IPVLAN_ATTR_IFNAME,
+   IPVLAN_ATTR_MODE,
+   IPVLAN_ATTR_FLAG,
+   __IPVLAN_ATTR_MAX
+};
+
+static const struct blobmsg_policy ipvlan_attrs[__IPVLAN_ATTR_MAX] = {
+   [IPVLAN_ATTR_IFNAME]  = { "ifname", BLOBMSG_TYPE_STRING },
+   [IPVLAN_ATTR_MODE] = { "mode", BLOBMSG_TYPE_STRING },
+   [IPVLAN_ATTR_FLAG] = { "flag", BLOBMSG_TYPE_STRING },
+};
+
+static const struct uci_blob_param_list ipvlan_attr_list = {
+   .n_params = __IPVLAN_ATTR_MAX,
+   .params = ipvlan_attrs,
+
+   .n_next = 1,
+   .next = { &device_attr_list },
+};
+
+struct ipvlan_device {
+   struct device dev;
+   struct device_user parent;
+
+   device_state_cb set_state;
+
+   struct blob_attr *config_data;
+   struct blob_attr *ifname;
+   struct ipvlan_config config;
+};
+
+static void
+ipvlan_base_cb(struct device_user *dev, enum device_event ev)
+{
+   struct ipvlan_device *mvdev = container_of(dev, struct ipvlan_device, 
parent);
+
+   switch (ev) {
+   case DEV_EVENT_ADD:
+   device_set_present(&mvdev->dev, true);
+   break;
+   case DEV_EVENT_REMOVE:
+   device_set_present(&mvdev->dev, false);
+   break;
+   default:
+   return;
+   }
+}
+
+static int
+ipvlan_set_down(struct ipvlan_device *mvdev)
+{
+   mvdev->set_state(&mvdev->dev, false);
+   system_ipvlan_del(&mvdev->dev);
+   device_release(&mvdev->parent);
+
+   return 0;
+}
+
+static int
+ipvlan_set_up(struct ipvlan_device *mvdev)
+{
+   int ret;
+
+   ret = device_claim(&mvdev->parent);
+   if (ret < 0)
+   return ret;
+
+   ret = system_ipvlan_add(&mvdev->dev, mvdev->parent.dev, &mvdev->config);
+   if (ret < 0)
+   goto release;
+
+   ret = mvdev->set_state(&mvdev->dev, true);
+   if (ret)
+   goto delete;
+
+   return 0;
+
+delete:
+   system_ipvlan_del(&mvdev->dev);
+release:
+   device_release(&mvdev->parent);
+   return ret;
+}
+
+static int
+ipvlan_set_state(struct device *dev, bool up)
+{
+   struct ipvlan_device *mvdev;
+
+   D(SYSTEM, "ipvlan_set_state(%s, %u)\n", dev->ifname, up);
+
+   mvdev = container_of(dev, struct ipvlan_device, dev);
+   if (up)
+   return ipvlan_set_up(mvdev);
+   else
+   return ipvlan_set_down(mvdev);
+}
+
+static void
+ipvlan_free(struct device *dev)
+{
+   struct ipvlan_device *mvdev;
+
+   mvdev = container_of(dev, struct ipvlan_device, dev);
+   device_remove_user(&mvdev->parent);
+   free(mvdev->config_data);
+   free(mvdev);
+}
+
+static void
+ipvlan_dump_info(struct device *dev, struct blob_buf *b)
+{
+   struct ipvlan_device *mvdev;
+
+   mvdev = container_of(dev, struct ipvlan_device, dev);
+   blobmsg_add_string(b, "parent", mvdev->parent.dev->ifname);
+   system_if_dump_info(dev, b);
+}
+
+static void
+ipvlan_config_init(struct device *dev)
+{
+   struct ipvlan_device *mvdev;
+   struct device *basedev = NULL;
+
+   mvdev = container_of(dev, struct ipvlan_d

[PATCH 1/1] netifd: device: add ipvlan support

2022-12-14 Thread Alexey Smirnov
Please, any review?

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 1/1] netifd: device: add ipvlan support

2022-12-14 Thread Alexey Smirnov
Please, any review?

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel