[PATCH] package: add new poe-common package

Paul D newtwen at gmail.com
Thu Jan 25 15:00:46 PST 2024


So, the power budget is a global option. Do we ever envisage that parts 
of this budget can be concretely assigned to specific ports or more 
abstract <board sections>?

e.g.

  	config port
  		option name 'lan8'
  		option id '1'
  		option enable '1'
  		option budget '15'




On 2024-01-25 14:00, Sander Vanheule wrote:
> 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 <sander at svanheule.net>
> ---
>   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 <sander at svanheule.net>
> +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. at 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. at port[-1].name='$port'
> +				set poe. at port[-1].id='$id'
> +				set poe. at port[-1].enable='1'
> +			EOF
> +			let id=id+1
> +		done
> +	fi
> +json_select ..
> +
> +uci commit
> +
> +exit 0




More information about the openwrt-devel mailing list