#!/pkg/bin/ksh
# -----------------------------------------------------------------------------
# show_tech_fast_ether_pd_ethernet - Show tech-support fast script for 
#                                    ethernet PD (generic PI version)
#
# October 2008, Simon Osborne
#
# Copyright (c) 2008-2016 by cisco Systems, Inc.
# All rights reserved.
#------------------------------------------------------------------------------

#
# Load the script provided by show-tech infra, which provides worker functions
#
. /pkg/bin/show_tech_main_fragment

#
# Parse the arguments to the script - card type and interface filter are the 
# only support options currently.  No need to use the default parser function,
# as this has been done by caller.
#
__cardtype="unspecified"
internal_if="unspecified"
external_if=""
ether_arg_string=""
bundle_only_arg_string=""

while [ "$#" -gt "0" ]; do
    case "$1" in
        -I) internal_if="$2"; shift 2;;
        -t) __cardtype="$2"; shift 2;;
        *) shift;;
    esac
done

if [ "$internal_if" != "unspecified" ]; then
    external_if=`convert_interface_fmt '-e' $internal_if`
fi

if [ "$__cardtype" == "unspecified" ]; then
    __cardtype=`node_type`
fi

#
# List of commands to be run.  East set must finish with a pair of empty 
# strings.  Note that it is important to use single quotes rather than double 
# quotes for the strings containing your commands.
#
# For all of these the __ksh variable is the process that will actually be 
# spawned, the _exec variable is just a string that is printed in the output to
# describe it. 
#

###############################################################################
# Commands that need to loop for all nodes within the rack.  This is used for #
# commands that require a location, don't support location all, and don't run #
# on the LCs                                                                  #
###############################################################################

rp_loc_exec[1]='show ether-ctrl Management trace location $location'
rp_loc__ksh[1]='ether_ctrl_trace_show -M -i $fq_nodeid'

rp_loc_exec[2]='show controllers mlan  port-counters  1 location $location'
rp_loc__ksh[2]='mlan_show -P 1 -L $fq_nodeid'

rp_loc_exec[3]='show controllers mlan  port-counters  2 location $location'
rp_loc__ksh[3]='mlan_show -P 2 -L $fq_nodeid'

rp_loc_exec[4]='show controllers mlan  port-counters  3 location $location'
rp_loc__ksh[4]='mlan_show -P 3 -L $fq_nodeid'

rp_loc_exec[5]='show controllers mlan   port-status  1 location $location'
rp_loc__ksh[5]='mlan_show -R 1 -L $fq_nodeid'

rp_loc_exec[6]='show controllers mlan   port-status  2 location $location'
rp_loc__ksh[6]='mlan_show -R 2 -L $fq_nodeid'

rp_loc_exec[7]='show controllers mlan   port-status  3 location $location'
rp_loc__ksh[7]='mlan_show -R 3 -L $fq_nodeid'

rp_loc_exec[8]='show controllers mlan   switch-atu  location $location'
rp_loc__ksh[8]='mlan_show -A -L $fq_nodeid'

rp_loc_exec[9]='show controllers mlan   switch-status  location $location'
rp_loc__ksh[9]='mlan_show -S -L $fq_nodeid'

rp_loc_exec[10]='---- ether_ctrl_msg show tech ----'
rp_loc__ksh[10]='ether_ctrl_msg_test show tech'

rp_loc_exec[11]='show controller vic ltrace all location $location'
rp_loc__ksh[11]='vic_show_ltrace'

rp_loc_exec[12]=''
rp_loc__ksh[12]=''



###############################################################################
# Commands that need to loop for all nodes within the rack.  This is used for #
# commands that require a location, don't support location all, and don't run #
# on the RPs                                                                  #
###############################################################################

lc_loc_exec[1]='show ether-ctrl GigabitEthernet trace location $location'
lc_loc__ksh[1]='ether_ctrl_trace_show -G'

lc_loc_exec[2]='show ether-ctrl TenGigE trace location $location'
lc_loc__ksh[2]='ether_ctrl_trace_show -T'

lc_loc_exec[3]='show controllers PhyCtrl trace location $location'
lc_loc__ksh[3]='phyctrl_show_ltrace'

lc_loc_exec[4]='show controllers PortCtrl trace location $location'
lc_loc__ksh[4]='portctrl_show_ltrace'

lc_loc_exec[5]='show controllers fca ltrace error location $location'
lc_loc__ksh[5]='fca_show_ltrace -E'

lc_loc_exec[6]='show prm server trace error location $location'
lc_loc__ksh[6]='show_prm_server_ltrace -E'

lc_loc_exec[7]='show prm server trace oir location $location'
lc_loc__ksh[7]='show_prm_server_ltrace -R'

lc_loc_exec[8]='show qoshal trace location $location'
lc_loc__ksh[8]='qoshal_show_ltrace'

lc_loc_exec[9]='show serdes trace location $location'
lc_loc__ksh[9]='serdes_show_trace'

lc_loc_exec[10]='show controller vic ltrace all location $location'
lc_loc__ksh[10]='vic_show_ltrace'

lc_loc_exec[11]='---- show tech pd lc ----'
lc_loc__ksh[11]='show_tech_pd_lc'

lc_loc_exec[12]='show controller lda trace location $location'
lc_loc__ksh[12]='lda_show_ltrace'

lc_loc_exec[13]='---- lda_test show tech bay 0 ----'
lc_loc__ksh[13]='lda_test client ep show_tech 0'

lc_loc_exec[14]='---- lda_test show tech bay 1 ----'
lc_loc__ksh[14]='lda_test client ep show_tech 1'

lc_loc_exec[15]='---- lda_test show shared memories ----'
lc_loc__ksh[15]='lda_test client shmem all'

lc_loc_exec[16]='---- lda_test show opcode profile ----'
lc_loc__ksh[16]='lda_test client opcode stats_profile'

lc_loc_exec[17]='show controller fpgalib ltrace all'
lc_loc__ksh[17]='fpgalib_show_ltrace -A'

lc_loc_exec[18]='---- fpgalib_test show tech ----'
lc_loc__ksh[18]='fpgalib_test show tech'

lc_loc_exec[19]='---- ether_ctrl_msg show tech ----'
lc_loc__ksh[19]='ether_ctrl_msg_test show tech'

lc_loc_exec[20]='---- serdes log file ----'
lc_loc__ksh[20]='cat /tmp/x120_phy.log'

lc_loc_exec[21]=''
lc_loc__ksh[21]=''

#
# The display() function is the one that does all the work - called by us as 
# this is a worker script.
#
display() {
    print_main_heading "show tech-support ether asr9k pd"
        
    if [ "$__cardtype" == "SYS" ]; then
        exec_commands sys
    else
        case "$__cardtype" in
        "RP")
            exec_commands rp_loc
            ;;
        "LC")
            exec_commands lc_loc
            ;;
        esac
    fi
    
    print_main_heading "show tech-support ether pd complete"
    if [[ -x `which show_tech_fast_ether_ea_pd 2>/dev/null` ]]; then
        run_module show_tech_fast_ether_ea_pd "$arg_string"
    fi

}

display


