#!/bin/sh

# We need to down eth0 prior to starting runner's data path init
ifconfig eth0 down

# Initialize bdmf shell
bdmf_shell -c init | while read a b ; do echo $b ; done > /var/bdmf_sh_id
alias bs="bdmf_shell -c `cat /var/bdmf_sh_id` -cmd "

# Start history recording
bs /bdmf/hist/init 0x20000 on

# Create system object
	#script is installed when queuemanagement plugin is not present
	test -x /bin/bdmf_gbe_qos_init && /bin/bdmf_gbe_qos_init

for i in 0 1 2 3 4 5 6
do
    # Create DS egress_tm objects
    bs /bdmf/new egress_tm/dir=ds,index=${i},level=queue,mode=sp port/index=lan${i}

    # Configure DS priority queues for LAN emac ports (emac ports schedulers have been already configured)
    bs /bdmf/configure egress_tm/dir=ds,index=${i} queue_cfg[0]={queue_id=7,weight=0,drop_alg=dt,drop_threshold=128,red_high_threshold=0,red_low_threshold=0},enable=yes
    bs /bdmf/configure egress_tm/dir=ds,index=${i} queue_cfg[1]={queue_id=6,weight=0,drop_alg=dt,drop_threshold=128,red_high_threshold=0,red_low_threshold=0},enable=yes
    bs /bdmf/configure egress_tm/dir=ds,index=${i} queue_cfg[2]={queue_id=5,weight=0,drop_alg=dt,drop_threshold=128,red_high_threshold=0,red_low_threshold=0},enable=yes
    bs /bdmf/configure egress_tm/dir=ds,index=${i} queue_cfg[3]={queue_id=4,weight=0,drop_alg=dt,drop_threshold=128,red_high_threshold=0,red_low_threshold=0},enable=yes
    bs /bdmf/configure egress_tm/dir=ds,index=${i} queue_cfg[4]={queue_id=3,weight=0,drop_alg=dt,drop_threshold=128,red_high_threshold=0,red_low_threshold=0},enable=yes
    bs /bdmf/configure egress_tm/dir=ds,index=${i} queue_cfg[5]={queue_id=2,weight=0,drop_alg=dt,drop_threshold=128,red_high_threshold=0,red_low_threshold=0},enable=yes
    bs /bdmf/configure egress_tm/dir=ds,index=${i} queue_cfg[6]={queue_id=1,weight=0,drop_alg=dt,drop_threshold=128,red_high_threshold=0,red_low_threshold=0},enable=yes
    bs /bdmf/configure egress_tm/dir=ds,index=${i} queue_cfg[7]={queue_id=0,weight=0,drop_alg=dt,drop_threshold=128,red_high_threshold=0,red_low_threshold=0},enable=yes
done
