From 4b06b07acf6d557e368b1599d9d5eb3320276466 Mon Sep 17 00:00:00 2001 From: Rahul Date: Mon, 25 Apr 2022 07:41:14 +0530 Subject: [PATCH] ponmngr: first drop - Most fundamental uci mapping to proposed XPON.ONU.i.ANI.i.Enable object in 2.16 - The init scripts to procd trigger relevant components --- ponmngr/files/etc/init.d/pon | 36 ---------- ponmngr/files/etc/init.d/xpon | 25 +++++++ .../files/etc/uci-defaults/60-pon-generate | 27 ------- .../files/etc/uci-defaults/60-xpon-generate | 17 +++++ ponmngr/files/lib/pon/broadcom.sh | 70 ------------------- ponmngr/files/lib/xpon/broadcom.sh | 20 ++++++ ponmngr/files/usr/libexec/rpcd/pon | 19 ----- 7 files changed, 62 insertions(+), 152 deletions(-) delete mode 100755 ponmngr/files/etc/init.d/pon create mode 100755 ponmngr/files/etc/init.d/xpon delete mode 100755 ponmngr/files/etc/uci-defaults/60-pon-generate create mode 100755 ponmngr/files/etc/uci-defaults/60-xpon-generate delete mode 100755 ponmngr/files/lib/pon/broadcom.sh create mode 100644 ponmngr/files/lib/xpon/broadcom.sh delete mode 100755 ponmngr/files/usr/libexec/rpcd/pon diff --git a/ponmngr/files/etc/init.d/pon b/ponmngr/files/etc/init.d/pon deleted file mode 100755 index 8dd62fcc8..000000000 --- a/ponmngr/files/etc/init.d/pon +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh /etc/rc.common - -START=98 -STOP=10 - -USE_PROCD=1 -NAME=ponmngr -PROG="/usr/sbin/omcid start" - -include /lib/pon - - -start_service() { - if [ -f "/etc/config/pon" ]; then - procd_open_instance $NAME - procd_set_param command ${PROG} - procd_set_param respawn - procd_close_instance - start_gpon - fi -} - -boot() { - start -} - -stop_service() { - service_stop ${PROG} - stop_gpon -} - -reload_service() { - stop - start -} - diff --git a/ponmngr/files/etc/init.d/xpon b/ponmngr/files/etc/init.d/xpon new file mode 100755 index 000000000..c9d020a57 --- /dev/null +++ b/ponmngr/files/etc/init.d/xpon @@ -0,0 +1,25 @@ +#!/bin/sh /etc/rc.common + +START=19 +STOP=10 + +USE_PROCD=1 + +. /lib/functions.sh +include /lib/xpon + +start_service() { + if [ "$(uci -q get xpon.ani.enable)" == "1" ]; then + init_xpon + fi +} + +stop_service() { + # stopping omcid does not bring down the pon link, which should happen + # if ANI is disabled or stopped (go to O1) + deinit_xpon +} + +service_triggers() { + procd_add_reload_trigger "xpon" +} diff --git a/ponmngr/files/etc/uci-defaults/60-pon-generate b/ponmngr/files/etc/uci-defaults/60-pon-generate deleted file mode 100755 index 415158d39..000000000 --- a/ponmngr/files/etc/uci-defaults/60-pon-generate +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -basemac="$(db -q get hw.board.basemac | tr -d ':')" - -if [ -s "/etc/config/pon" ]; then - if uci -q get pon.globals >/dev/null; then - # return if there is any valid content - exit - else - rm -f /etc/config/pon - fi -fi -touch /etc/config/pon - -mac='' -if [ -z "$basemac" ]; then - mac="12345678" -else - # read last 8 characters of basemac without : - mac=${basemac: -8} -fi - -uci set pon.globals=globals -uci set pon.globals.enabled="1" -uci set pon.globals.serial_number="BRCM$mac" - -uci commit pon diff --git a/ponmngr/files/etc/uci-defaults/60-xpon-generate b/ponmngr/files/etc/uci-defaults/60-xpon-generate new file mode 100755 index 000000000..037aa9715 --- /dev/null +++ b/ponmngr/files/etc/uci-defaults/60-xpon-generate @@ -0,0 +1,17 @@ +#!/bin/sh + +if [ -s "/etc/config/xpon" ]; then + if uci -q get xpon.ani >/dev/null; then + # return if there is any valid content + exit + else + rm -f /etc/config/xpon + fi +fi +touch /etc/config/xpon + + +uci set xpon.ani=ani +uci set xpon.ani.enable="1" + +uci commit xpon diff --git a/ponmngr/files/lib/pon/broadcom.sh b/ponmngr/files/lib/pon/broadcom.sh deleted file mode 100755 index 8e0208385..000000000 --- a/ponmngr/files/lib/pon/broadcom.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh -. /lib/functions.sh -. /usr/share/libubox/jshn.sh - -configure_snpwd() { - local serial_no password - serial_no="$1" - password="$2" - - # serial number comprises of 2 parts, vendor id and vendor specific, the vendor id is - # a string while the vendor specific is a hex, so split the 2 and set accordingly - local vendor_id vendor_specific - vendor_id=${serial_no:0:4} - vendor_specific=${serial_no: -8} - - # attempt to conver vendor_id from string to hex - vendor_id=$(echo $vendor_id | hexdump -e '4/1 "%02X" "\n"') - vendor_id=${vendor_id:0:8} - - bdmf_shell -c `cat /var/bdmf_sh_id` -cmd /b/configure gpon onu_sn={vendor_id=$vendor_id,vendor_specific=$vendor_specific} - if [ -n "$password" ]; then - password=$(echo $password | hexdump -n ${#password} -e '16/1 "%02X""\n"') - bdmf_shell -c `cat /var/bdmf_sh_id` -cmd /b/configure gpon password=$password - fi -} - -configure_gpon() { - local enabled serial_no password - config_load pon - config_get enabled globals "enabled" - - if [ "$enabled" == "0" ]; then - exit - fi - - config_get serial_no globals "serial_number" - config_get password globals "password" - - configure_snpwd $serial_no $password -} - -start_gpon() { - if [ -n "$(which gponctl)" ]; then - configure_gpon - gponctl start - fi -} - -stop_gpon() { - if [ -n "$(which gponctl)" ]; then - gponctl stop - fi -} - -get_gpon_status() { - json_init - status="$(gponctl getstate)" - admin_status="$(echo $status | head -n1 | awk '{print $8;}')" - json_add_string "admin_status" "$admin_status" - op_status="$(echo $status | head -n1 | awk '{print $12;}')" - case $op_status in - NUMBER) - op_status="$(echo $status | head -n1 | awk '{print $13;}')" - ;; - esac - - op_status=${op_status:1:2} - json_add_string "operational_status" "$op_status" - json_dump -} diff --git a/ponmngr/files/lib/xpon/broadcom.sh b/ponmngr/files/lib/xpon/broadcom.sh new file mode 100644 index 000000000..ddb72a5da --- /dev/null +++ b/ponmngr/files/lib/xpon/broadcom.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +USE_PROCD=1 + +. /lib/functions.sh + +init_xpon() { + procd_open_instance pon_msgd + procd_set_param command bcm_msgd -c gpon + procd_close_instance + procd_open_instance pon_daemon + procd_set_param command omcid start -n + procd_close_instance + +} + +deinit_xpon() { + gponctl stop +} + diff --git a/ponmngr/files/usr/libexec/rpcd/pon b/ponmngr/files/usr/libexec/rpcd/pon deleted file mode 100755 index 8aa83dd36..000000000 --- a/ponmngr/files/usr/libexec/rpcd/pon +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -. /usr/share/libubox/jshn.sh -. /lib/functions.sh -include /lib/pon - -case "$1" in - list) - echo '{ "status": {} }' - ;; - call) - case "$2" in - status) - get_gpon_status - ;; - esac - ;; -esac -