From patchwork Thu Jan 25 13:00:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sander Vanheule X-Patchwork-Id: 1890849 X-Patchwork-Delegate: sander@svanheule.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=bojZFRI+; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=eK9Shzfd; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=svanheule.net header.i=@svanheule.net header.a=rsa-sha256 header.s=mail1707 header.b=BF4bQ6oG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TLNHH0BfHz1yS7 for ; Fri, 26 Jan 2024 01:19:06 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=NgHggQr5jKdXi+GsmztquexhN6GYEiF5yJLbQQOZ/R0=; b=bojZFRI+C28+sB abf6S50iuucyAkdAWVtBuvp0dY8G82Jw7ToDar93DnKZ8us6T/tes0i9OwmJv067urMyqM37IyojP G5MHTweVlwPxKO/iFtZiUGlp2KFf50GXoGvzyvQzCFyDevuAFRFOcpE6eJlTvsfrZregLA6SHBR4y 273mh4DTOALRcPe9bRN34ZfXUh9JMwIzMglq9tdqry8DUvhhj6NuxgVEL3YrZTVQczakQuW5rEsfb pALddnx56FqdIwzk+9+5SshXD6843aUInjAyOOCeP0Gv6OllRa3jE7+tzJAd4q1I/MusGgcNlIq0/ HQvmm6GOv2BRraKIwvrA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT0XF-00000000Js9-3Hn1; Thu, 25 Jan 2024 14:16:54 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT0XE-00000000Jru-0hKx for openwrt-devel@bombadil.infradead.org; Thu, 25 Jan 2024 14:16:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=8uFHr9r8nXvJkFPiTTJmmViS1pP3SNBJas5sgzTYIaE=; b=eK9ShzfdqPc3aOgCnWM+oP9Gtj wPdnXZFz3GepXNUnWGXss4/WRbHI8oANbBxXyXFCJpTF3SUTBWaY6IEFaU4rLC/IA1fMrE2e6CH90 +EqcD8gl2MSi7bOlrXOzoKfOCOQ+zaBTYY9Fa3ObHtZ5E+UH1xAh8mRqRBDKjRp8gj2awhTb3p3KU 9YUkHIr7W/LY/RwJQyLWJeogui4MPSM9DET2dWTlne2zS2UHdFMgJoqkHu4epmylvlq19ZvODldf9 h/q/n0Q42N8EM5foJntNpQhlPiffWRUvMnavQtLioP2VfB9ABk7FqO8cLR0Xq2os8NuaWVIEkys8/ GbUY0eiA==; Received: from polaris.svanheule.net ([2a00:c98:2060:a004:1::200]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rSzLk-00000005MZO-0DzC for openwrt-devel@lists.openwrt.org; Thu, 25 Jan 2024 13:01:00 +0000 Received: from mars.lan (unknown [94.110.53.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sander@svanheule.net) by polaris.svanheule.net (Postfix) with ESMTPSA id 5C4A9496A92; Thu, 25 Jan 2024 14:00:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svanheule.net; s=mail1707; t=1706187645; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=8uFHr9r8nXvJkFPiTTJmmViS1pP3SNBJas5sgzTYIaE=; b=BF4bQ6oG+e+D7e3K5RZ5bNMIHCBCMmSC+MDgdngyiEKEw/GJJbIHrNDO5mIr36ugBogYyJ ZEuUTZmISDXcUvmmOPHuPVFLQzlXAimJJNOJl1ROx+ZELs7JTxVlI72CmADdA4CSxm0Gp3 lzaWw9HEii3idfL21wjaQ5cY0kybK9BithMiceeUiKKCcFx6SRClTvd0hKy2dooBYkC7Uf M4mf/FDpwgoqPF8Xi8jO6XUVeTbK6rdOacJbNuiqEM18qVjznr1gRY/Vid1D/gmfLmE4AX SeySGGi6I9CaRIpci2etV1j+e4vHz8TcevyociFmDh44H5JUpfBidhS7y8lf3Q== From: Sander Vanheule To: openwrt-devel@lists.openwrt.org Cc: Jo-Philipp Wich , David Bauer , Alexandru Gagniuc , Martin Kennedy , Sander Vanheule Subject: [PATCH] package: add new poe-common package Date: Thu, 25 Jan 2024 14:00:33 +0100 Message-ID: <20240125130033.106260-1-sander@svanheule.net> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240125_130056_379863_CAB82076 X-CRM114-Status: GOOD ( 15.31 ) X-Spam-Score: -2.5 (--) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Create a new package to generate configuration files for devices capable of delivering power via PoE. The configuration file at /etc/config/poe can be used by PoE daemons to configure the hardware in [...] Content analysis details: (-2.5 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [2a00:c98:2060:a004:1:0:0:200 listed in] [list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Create a new package to generate configuration files for devices capable of delivering power via PoE. The configuration file at /etc/config/poe can be used by PoE daemons to configure the hardware in an implementation specific way. This is part of the core packages because it needs to be in sync with the format of board.json, from which the config file is generated. The config file structure is based on the current config file of the realtek-poe package, but should be (and remain) implementation independent. With a common basis, a common (LuCI) configuration interface also becomes possible in the future. For a device with a power budget of 130W and ports lan1-lan8 mapping to PSE outputs 8-1, /etc/config/poe could look like (lan1-lan6 omitted): config global option budget '130' config port option name 'lan8' option id '1' option enable '1' config port option name 'lan7' option id '2' option enable '1' [...] Signed-off-by: Sander Vanheule --- package/network/config/poe-common/Makefile | 37 ++++++++++++++++ .../poe-common/files/etc/uci-defaults/30_poe | 42 +++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 package/network/config/poe-common/Makefile create mode 100755 package/network/config/poe-common/files/etc/uci-defaults/30_poe diff --git a/package/network/config/poe-common/Makefile b/package/network/config/poe-common/Makefile new file mode 100644 index 000000000000..a7970b4b5b15 --- /dev/null +++ b/package/network/config/poe-common/Makefile @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +include $(TOPDIR)/rules.mk + +PKG_NAME:=poe-common +PGK_VERSION:=1 +PKG_RELEASE:=1 + +PKG_MAINTAINER:=Sander Vanheule +PKG_LICENSE:=GPL-2.0-or-later + +include $(INCLUDE_DIR)/package.mk + +define Package/poe-common + SECTION:=net + CATEGORY:=Network + TITLE:=Common base files for PoE + DEPENDS:=+libubox +libuci +endef + +define Package/poe-common/conffiles +/etc/config/poe +endef + +define Package/poe-common/description + Common base files for PoE configuration and control +endef + +define Package/poe-common/install + $(INSTALL_DIR) $(1)/etc/uci-defaults/ + $(INSTALL_CONF) ./files/etc/uci-defaults/30_poe $(1)/etc/uci-defaults/ +endef + +define Build/Compile +endef + +$(eval $(call BuildPackage,poe-common)) diff --git a/package/network/config/poe-common/files/etc/uci-defaults/30_poe b/package/network/config/poe-common/files/etc/uci-defaults/30_poe new file mode 100755 index 000000000000..3a429402c59b --- /dev/null +++ b/package/network/config/poe-common/files/etc/uci-defaults/30_poe @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +[ -e /etc/config/poe ] && exit 0 + +. /lib/functions.sh +. /usr/share/libubox/jshn.sh + +CFG=/etc/board.json + +json_init +json_load_file "${CFG}" + +json_is_a poe object || exit 0 + +umask 055 +touch /etc/config/poe + +json_select poe + json_get_vars budget + + uci add poe global + uci set poe.@global[-1].budget="$budget" + + if json_is_a ports array; then + json_get_values ports ports + id='1' + + for port in $ports; do + uci -q batch <<-EOF + add poe port + set poe.@port[-1].name='$port' + set poe.@port[-1].id='$id' + set poe.@port[-1].enable='1' + EOF + let id=id+1 + done + fi +json_select .. + +uci commit + +exit 0