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
This commit is contained in:
Rahul 2022-04-25 07:41:14 +05:30 committed by Rahul Thakur
parent 6636e7ff47
commit 4b06b07acf
7 changed files with 62 additions and 152 deletions

View file

@ -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
}

25
ponmngr/files/etc/init.d/xpon Executable file
View file

@ -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"
}

View file

@ -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

View file

@ -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

View file

@ -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
}

View file

@ -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
}

View file

@ -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