From aff22ef682999937ed2fee86b0e88b3c9816c3f1 Mon Sep 17 00:00:00 2001 From: Lu Qiuwen Date: Mon, 16 Dec 2019 15:37:40 +0800 Subject: 整理目录结构,删去原init_adc_cpu_broad的压缩包,改用普通文本文件形式存储。 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\226\346\211\213\345\206\214-20191206-v2.docx" | Bin 0 -> 249209 bytes init_mcn_network/.gitkeep | 0 ...4\226\346\211\213\345\206\214-20191206-v2.docx" | Bin 249209 -> 0 bytes init_mcn_network/crontab | 16 --- init_mcn_network/ifcfg-ens | 15 --- init_mcn_network/init_adc_cpu_broad.sh | 120 ------------------ init_mcn_network/init_adc_cpu_broad.zip | Bin 16406 -> 0 bytes init_mcn_network/init_adc_cpu_broad/.gitkeep | 0 init_mcn_network/init_adc_cpu_broad/crontab | 16 +++ init_mcn_network/init_adc_cpu_broad/ifcfg-ens | 15 +++ .../init_adc_cpu_broad/init_adc_cpu_broad.sh | 120 ++++++++++++++++++ .../tsg-env/switch_control_client_non_block | Bin 0 -> 18224 bytes .../init_adc_cpu_broad/tsg-env/tsg-env-mcn0_setup | 134 +++++++++++++++++++++ .../tsg-env/tsg-env-mcn0_tsg-env.service | 14 +++ .../tsg-env/tsg-env-mcn0_vf-setup | 15 +++ .../init_adc_cpu_broad/tsg-env/tsg-env-mcn1_setup | 117 ++++++++++++++++++ .../tsg-env/tsg-env-mcn1_tsg-env.service | 15 +++ .../tsg-env/tsg-env-mcn1_vf-setup | 11 ++ .../init_adc_cpu_broad/tsg-env/tsg-env-mcn2_setup | 117 ++++++++++++++++++ .../tsg-env/tsg-env-mcn2_tsg-env.service | 15 +++ .../tsg-env/tsg-env-mcn2_vf-setup | 11 ++ .../init_adc_cpu_broad/tsg-env/tsg-env-mcn3_setup | 117 ++++++++++++++++++ .../tsg-env/tsg-env-mcn3_tsg-env.service | 15 +++ .../tsg-env/tsg-env-mcn3_vf-setup | 11 ++ init_mcn_network/logfile.txt | 5 - init_mcn_network/tsg-env/.gitkeep | 0 .../tsg-env/switch_control_client_non_block | Bin 18224 -> 0 bytes init_mcn_network/tsg-env/tsg-env-mcn0_setup | 134 --------------------- .../tsg-env/tsg-env-mcn0_tsg-env.service | 14 --- init_mcn_network/tsg-env/tsg-env-mcn0_vf-setup | 15 --- init_mcn_network/tsg-env/tsg-env-mcn1_setup | 117 ------------------ .../tsg-env/tsg-env-mcn1_tsg-env.service | 15 --- init_mcn_network/tsg-env/tsg-env-mcn1_vf-setup | 11 -- init_mcn_network/tsg-env/tsg-env-mcn2_setup | 117 ------------------ .../tsg-env/tsg-env-mcn2_tsg-env.service | 15 --- init_mcn_network/tsg-env/tsg-env-mcn2_vf-setup | 11 -- init_mcn_network/tsg-env/tsg-env-mcn3_setup | 117 ------------------ .../tsg-env/tsg-env-mcn3_tsg-env.service | 15 --- init_mcn_network/tsg-env/tsg-env-mcn3_vf-setup | 11 -- switch_sled_startup_one_arm/saved_startup | 79 ++++++++++++ 40 files changed, 822 insertions(+), 748 deletions(-) create mode 100644 "docs/ADC\350\256\241\347\256\227\346\235\277\345\233\272\345\214\226\346\211\213\345\206\214-20191206-v2.docx" delete mode 100644 init_mcn_network/.gitkeep delete mode 100644 "init_mcn_network/ADC\350\256\241\347\256\227\346\235\277\345\233\272\345\214\226\346\211\213\345\206\214-20191206-v2.docx" delete mode 100644 init_mcn_network/crontab delete mode 100644 init_mcn_network/ifcfg-ens delete mode 100644 init_mcn_network/init_adc_cpu_broad.sh delete mode 100644 init_mcn_network/init_adc_cpu_broad.zip delete mode 100644 init_mcn_network/init_adc_cpu_broad/.gitkeep create mode 100644 init_mcn_network/init_adc_cpu_broad/crontab create mode 100644 init_mcn_network/init_adc_cpu_broad/ifcfg-ens create mode 100644 init_mcn_network/init_adc_cpu_broad/init_adc_cpu_broad.sh create mode 100644 init_mcn_network/init_adc_cpu_broad/tsg-env/switch_control_client_non_block create mode 100644 init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn0_setup create mode 100644 init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn0_tsg-env.service create mode 100644 init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn0_vf-setup create mode 100644 init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn1_setup create mode 100644 init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn1_tsg-env.service create mode 100644 init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn1_vf-setup create mode 100644 init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn2_setup create mode 100644 init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn2_tsg-env.service create mode 100644 init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn2_vf-setup create mode 100644 init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn3_setup create mode 100644 init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn3_tsg-env.service create mode 100644 init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn3_vf-setup delete mode 100644 init_mcn_network/logfile.txt delete mode 100644 init_mcn_network/tsg-env/.gitkeep delete mode 100644 init_mcn_network/tsg-env/switch_control_client_non_block delete mode 100644 init_mcn_network/tsg-env/tsg-env-mcn0_setup delete mode 100644 init_mcn_network/tsg-env/tsg-env-mcn0_tsg-env.service delete mode 100644 init_mcn_network/tsg-env/tsg-env-mcn0_vf-setup delete mode 100644 init_mcn_network/tsg-env/tsg-env-mcn1_setup delete mode 100644 init_mcn_network/tsg-env/tsg-env-mcn1_tsg-env.service delete mode 100644 init_mcn_network/tsg-env/tsg-env-mcn1_vf-setup delete mode 100644 init_mcn_network/tsg-env/tsg-env-mcn2_setup delete mode 100644 init_mcn_network/tsg-env/tsg-env-mcn2_tsg-env.service delete mode 100644 init_mcn_network/tsg-env/tsg-env-mcn2_vf-setup delete mode 100644 init_mcn_network/tsg-env/tsg-env-mcn3_setup delete mode 100644 init_mcn_network/tsg-env/tsg-env-mcn3_tsg-env.service delete mode 100644 init_mcn_network/tsg-env/tsg-env-mcn3_vf-setup diff --git "a/docs/ADC\350\256\241\347\256\227\346\235\277\345\233\272\345\214\226\346\211\213\345\206\214-20191206-v2.docx" "b/docs/ADC\350\256\241\347\256\227\346\235\277\345\233\272\345\214\226\346\211\213\345\206\214-20191206-v2.docx" new file mode 100644 index 0000000..ae31bfb Binary files /dev/null and "b/docs/ADC\350\256\241\347\256\227\346\235\277\345\233\272\345\214\226\346\211\213\345\206\214-20191206-v2.docx" differ diff --git a/init_mcn_network/.gitkeep b/init_mcn_network/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git "a/init_mcn_network/ADC\350\256\241\347\256\227\346\235\277\345\233\272\345\214\226\346\211\213\345\206\214-20191206-v2.docx" "b/init_mcn_network/ADC\350\256\241\347\256\227\346\235\277\345\233\272\345\214\226\346\211\213\345\206\214-20191206-v2.docx" deleted file mode 100644 index ae31bfb..0000000 Binary files "a/init_mcn_network/ADC\350\256\241\347\256\227\346\235\277\345\233\272\345\214\226\346\211\213\345\206\214-20191206-v2.docx" and /dev/null differ diff --git a/init_mcn_network/crontab b/init_mcn_network/crontab deleted file mode 100644 index 3f8bde4..0000000 --- a/init_mcn_network/crontab +++ /dev/null @@ -1,16 +0,0 @@ -SHELL=/bin/bash -PATH=/sbin:/bin:/usr/sbin:/usr/bin -MAILTO=root - -# For details see man 4 crontabs - -# Example of job definition: -# .---------------- minute (0 - 59) -# | .------------- hour (0 - 23) -# | | .---------- day of month (1 - 31) -# | | | .------- month (1 - 12) OR jan,feb,mar,apr ... -# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat -# | | | | | -# * * * * * user-name command to be executed - -*/5 * * * * root /home/init_adc_cpu_broad/init_adc_cpu_broad.sh run > /dev/null 2>&1 diff --git a/init_mcn_network/ifcfg-ens b/init_mcn_network/ifcfg-ens deleted file mode 100644 index bb7aa37..0000000 --- a/init_mcn_network/ifcfg-ens +++ /dev/null @@ -1,15 +0,0 @@ -TYPE=Ethernet -PROXY_METHOD=none -BROWSER_ONLY=no -BOOTPROTO=static -DEFROUTE=yes -IPV4_FAILURE_FATAL=no -IPV6INIT=yes -IPV6_AUTOCONF=yes -IPV6_DEFROUTE=yes -IPV6_FAILURE_FATAL=no -IPV6_ADDR_GEN_MODE=stable-privacy -NAME=enp8s0 -#UUID=2af69d2b-6746-489f-9e05-97a8b25e259b -DEVICE=enp8s0 -ONBOOT=yes diff --git a/init_mcn_network/init_adc_cpu_broad.sh b/init_mcn_network/init_adc_cpu_broad.sh deleted file mode 100644 index 9de450b..0000000 --- a/init_mcn_network/init_adc_cpu_broad.sh +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/bash -###################################### -# author: niuxiang -# date: 2019-11-27 -###################################### -# This script is used to configure \ -# the network according to the slot \ -# number of the board card -###################################### - -#左上(cpu02)槽位为:0x80,右上(cpu04)槽位为:0x88, -#左下(cpu01)槽位为:0x90,右下(cpu03)槽位为:0x98; -#check_command='ipmitool raw 0x2e 0x32 0x13 0x5f 0x00' - -work_dir=$(cd $(dirname $0); pwd) -net_conf_dir='/etc/sysconfig/network-scripts/' -service_dir='/opt/tsg/env/' - -# 函数作用: -# 日志记录函数 -write_log(){ - echo "[$(date +'%F %H:%M:%S')]" $@ | tee -a ${work_dir}/logfile.txt -} - -# 函数作用: -# 删除/opt/tsg/env下的配置文件,将tsg-env目录下的相应板卡配置文件拷贝到 -# tsg-env服务相应的目录,并将服务添加开机启动 -copy_tsg_env(){ - if [ ! -d ${service_dir} ];then - mkdir -p ${service_dir} - else - rm -f ${service_dir}/* - fi - rm -f /usr/lib/systemd/system/tsg-env.service - setup_file=${work_dir}/tsg-env/tsg-env-$1_setup - vf_setup_file=${work_dir}/tsg-env/tsg-env-$1_vf-setup - service_file=${work_dir}/tsg-env/tsg-env-$1_tsg-env.service - switch_file=${work_dir}/tsg-env/switch_control_client_non_block - cp -a ${setup_file} ${service_dir}/setup - cp -a ${vf_setup_file} ${service_dir}/vf-setup - cp -a ${switch_file} ${service_dir}/ - cp -a ${service_file} /usr/lib/systemd/system/tsg-env.service - systemctl daemon-reload - systemctl enable tsg-env.service - systemctl restart tsg-env.service - write_log $(echo 'Service conf updated') - write_log $(echo 'Service tsg-env enabled') -} - -# 函数作用: -# 判断ens1/ens8网卡配置文件是否存在,不存在创建配置文件 -# 函数的参数1为根据ethtool命令判断的网卡名称 -check_net_conf(){ - conf_num=$(ls ${net_conf_dir}/ifcfg-ens* | wc -l) - if [ ${conf_num} -gt 1 ];then - name_index=$(date +%H-%M-%S) - mv ${net_conf_dir}/ifcfg-ens*{,.${name_index}} - elif [ ${conf_num} -eq 0 ];then - cp ${work_dir}/ifcfg-ens ${net_conf_dir}/ifcfg-$1 - fi - conf_name=$(ls ${net_conf_dir}/ifcfg-ens* | awk -F'-' '{print $NF}') - if [ $1 == ${conf_name} ];then - write_log $(echo 'NIC name is correct') - else - sed -i "s#^NAME=.*#NAME=$1#g" ${net_conf_dir}/ifcfg-${conf_name} - sed -i "s#^DEVICE=.*#DEVICE=$1#g" ${net_conf_dir}/ifcfg-${conf_name} - mv ${net_conf_dir}/ifcfg-ens* ${net_conf_dir}/ifcfg-$1 - write_log $(echo 'NIC name changed') - fi - -} - -# 函数作用: -# 判断设备网卡是ens1或ens8 -check_ens_num(){ - ethtool ens1 > /dev/null 2>&1 - status=$? - if [ ${status} -eq 0 ];then - net_dev='ens1' - else - net_dev='ens8' - fi - write_log $(echo "pf name is ${net_dev}") -} - -# 函数作用: -# 网卡固化 -# 函数参数1为根据ipmitool判断板卡名称 -config_service(){ - write_log $(echo "this is $1") - copy_tsg_env $1 - check_ens_num - check_net_conf ${net_dev} -} - -if [ $1x != 'run'x ];then - write_log $(echo "./init_adc_cpu_broad.sh run") - exit -fi - -card_info=$(ipmitool raw 0x2e 0x32 0x13 0x5f 0x00 | awk '{print $NF}') -rm -f ${work_dir}/logfile.txt - -case ${card_info} in - 90) - config_service mcn0 - ;; - 80) - config_service mcn1 - ;; - 98) - config_service mcn2 - ;; - 88) - config_service mcn3 - ;; - *) - write_log $(echo 'check error') - ;; -esac diff --git a/init_mcn_network/init_adc_cpu_broad.zip b/init_mcn_network/init_adc_cpu_broad.zip deleted file mode 100644 index bbda2e5..0000000 Binary files a/init_mcn_network/init_adc_cpu_broad.zip and /dev/null differ diff --git a/init_mcn_network/init_adc_cpu_broad/.gitkeep b/init_mcn_network/init_adc_cpu_broad/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/init_mcn_network/init_adc_cpu_broad/crontab b/init_mcn_network/init_adc_cpu_broad/crontab new file mode 100644 index 0000000..3f8bde4 --- /dev/null +++ b/init_mcn_network/init_adc_cpu_broad/crontab @@ -0,0 +1,16 @@ +SHELL=/bin/bash +PATH=/sbin:/bin:/usr/sbin:/usr/bin +MAILTO=root + +# For details see man 4 crontabs + +# Example of job definition: +# .---------------- minute (0 - 59) +# | .------------- hour (0 - 23) +# | | .---------- day of month (1 - 31) +# | | | .------- month (1 - 12) OR jan,feb,mar,apr ... +# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat +# | | | | | +# * * * * * user-name command to be executed + +*/5 * * * * root /home/init_adc_cpu_broad/init_adc_cpu_broad.sh run > /dev/null 2>&1 diff --git a/init_mcn_network/init_adc_cpu_broad/ifcfg-ens b/init_mcn_network/init_adc_cpu_broad/ifcfg-ens new file mode 100644 index 0000000..bb7aa37 --- /dev/null +++ b/init_mcn_network/init_adc_cpu_broad/ifcfg-ens @@ -0,0 +1,15 @@ +TYPE=Ethernet +PROXY_METHOD=none +BROWSER_ONLY=no +BOOTPROTO=static +DEFROUTE=yes +IPV4_FAILURE_FATAL=no +IPV6INIT=yes +IPV6_AUTOCONF=yes +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no +IPV6_ADDR_GEN_MODE=stable-privacy +NAME=enp8s0 +#UUID=2af69d2b-6746-489f-9e05-97a8b25e259b +DEVICE=enp8s0 +ONBOOT=yes diff --git a/init_mcn_network/init_adc_cpu_broad/init_adc_cpu_broad.sh b/init_mcn_network/init_adc_cpu_broad/init_adc_cpu_broad.sh new file mode 100644 index 0000000..9de450b --- /dev/null +++ b/init_mcn_network/init_adc_cpu_broad/init_adc_cpu_broad.sh @@ -0,0 +1,120 @@ +#!/bin/bash +###################################### +# author: niuxiang +# date: 2019-11-27 +###################################### +# This script is used to configure \ +# the network according to the slot \ +# number of the board card +###################################### + +#左上(cpu02)槽位为:0x80,右上(cpu04)槽位为:0x88, +#左下(cpu01)槽位为:0x90,右下(cpu03)槽位为:0x98; +#check_command='ipmitool raw 0x2e 0x32 0x13 0x5f 0x00' + +work_dir=$(cd $(dirname $0); pwd) +net_conf_dir='/etc/sysconfig/network-scripts/' +service_dir='/opt/tsg/env/' + +# 函数作用: +# 日志记录函数 +write_log(){ + echo "[$(date +'%F %H:%M:%S')]" $@ | tee -a ${work_dir}/logfile.txt +} + +# 函数作用: +# 删除/opt/tsg/env下的配置文件,将tsg-env目录下的相应板卡配置文件拷贝到 +# tsg-env服务相应的目录,并将服务添加开机启动 +copy_tsg_env(){ + if [ ! -d ${service_dir} ];then + mkdir -p ${service_dir} + else + rm -f ${service_dir}/* + fi + rm -f /usr/lib/systemd/system/tsg-env.service + setup_file=${work_dir}/tsg-env/tsg-env-$1_setup + vf_setup_file=${work_dir}/tsg-env/tsg-env-$1_vf-setup + service_file=${work_dir}/tsg-env/tsg-env-$1_tsg-env.service + switch_file=${work_dir}/tsg-env/switch_control_client_non_block + cp -a ${setup_file} ${service_dir}/setup + cp -a ${vf_setup_file} ${service_dir}/vf-setup + cp -a ${switch_file} ${service_dir}/ + cp -a ${service_file} /usr/lib/systemd/system/tsg-env.service + systemctl daemon-reload + systemctl enable tsg-env.service + systemctl restart tsg-env.service + write_log $(echo 'Service conf updated') + write_log $(echo 'Service tsg-env enabled') +} + +# 函数作用: +# 判断ens1/ens8网卡配置文件是否存在,不存在创建配置文件 +# 函数的参数1为根据ethtool命令判断的网卡名称 +check_net_conf(){ + conf_num=$(ls ${net_conf_dir}/ifcfg-ens* | wc -l) + if [ ${conf_num} -gt 1 ];then + name_index=$(date +%H-%M-%S) + mv ${net_conf_dir}/ifcfg-ens*{,.${name_index}} + elif [ ${conf_num} -eq 0 ];then + cp ${work_dir}/ifcfg-ens ${net_conf_dir}/ifcfg-$1 + fi + conf_name=$(ls ${net_conf_dir}/ifcfg-ens* | awk -F'-' '{print $NF}') + if [ $1 == ${conf_name} ];then + write_log $(echo 'NIC name is correct') + else + sed -i "s#^NAME=.*#NAME=$1#g" ${net_conf_dir}/ifcfg-${conf_name} + sed -i "s#^DEVICE=.*#DEVICE=$1#g" ${net_conf_dir}/ifcfg-${conf_name} + mv ${net_conf_dir}/ifcfg-ens* ${net_conf_dir}/ifcfg-$1 + write_log $(echo 'NIC name changed') + fi + +} + +# 函数作用: +# 判断设备网卡是ens1或ens8 +check_ens_num(){ + ethtool ens1 > /dev/null 2>&1 + status=$? + if [ ${status} -eq 0 ];then + net_dev='ens1' + else + net_dev='ens8' + fi + write_log $(echo "pf name is ${net_dev}") +} + +# 函数作用: +# 网卡固化 +# 函数参数1为根据ipmitool判断板卡名称 +config_service(){ + write_log $(echo "this is $1") + copy_tsg_env $1 + check_ens_num + check_net_conf ${net_dev} +} + +if [ $1x != 'run'x ];then + write_log $(echo "./init_adc_cpu_broad.sh run") + exit +fi + +card_info=$(ipmitool raw 0x2e 0x32 0x13 0x5f 0x00 | awk '{print $NF}') +rm -f ${work_dir}/logfile.txt + +case ${card_info} in + 90) + config_service mcn0 + ;; + 80) + config_service mcn1 + ;; + 98) + config_service mcn2 + ;; + 88) + config_service mcn3 + ;; + *) + write_log $(echo 'check error') + ;; +esac diff --git a/init_mcn_network/init_adc_cpu_broad/tsg-env/switch_control_client_non_block b/init_mcn_network/init_adc_cpu_broad/tsg-env/switch_control_client_non_block new file mode 100644 index 0000000..5cdba48 Binary files /dev/null and b/init_mcn_network/init_adc_cpu_broad/tsg-env/switch_control_client_non_block differ diff --git a/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn0_setup b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn0_setup new file mode 100644 index 0000000..279c55b --- /dev/null +++ b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn0_setup @@ -0,0 +1,134 @@ +#!/bin/bash +# set -x + +CURRENT_PATH=`dirname $0` +TP_SVR=192.168.100.5 +TP_PORT=10000 +REMOTE_CONTROL_BIN=switch_control_client_non_block + +function get_netdev_by_pci() +{ + DEV_LIST=`ifconfig -a |grep flags |awk -F: '{print $1}'` + for i in ${DEV_LIST} + do + ethtool -i ${i} |grep bus-info |grep "$1" > /dev/null 2>&1 + if [ $? -eq 0 ];then + TARGET=${i} + break + fi + done + + echo ${TARGET} +} + +function pf_setup() +{ + ifconfig ens1 up + + modprobe 8021q + vconfig add ens1 100 + vconfig set_flag ens1.100 1 1 + ifconfig ens1.100 192.168.100.1 netmask 255.255.255.0 up + sleep 1 +} + +function vf_setup() +{ + echo 8 > /sys/class/net/ens1/device/sriov_numvfs + sleep 5 + + ifconfig ens1f3 up + ip link set ens1 vf 2 vlan 200 + ifconfig ens1f3 192.168.200.1 netmask 255.255.255.0 + + ifconfig ens1f1 up + ifconfig ens1f2 up + ifconfig ens1f3 up + ifconfig ens1f4 up + ifconfig ens1f5 up + ifconfig ens1f6 up + ifconfig ens1f7 up + ifconfig enp1s1 up + + sleep 5 +} + +function bring_down_pfvf() +{ + echo 0 > /sys/class/net/ens1/device/sriov_numvfs + ifconfig ens1 down + sleep 3 +} + + +# Main loop +while : +do + FAIL_FLAG=0 + + # Make sure PF is valid + ping ${TP_SVR} -c 1 + if [ $? -ne 0 ];then + echo "Please make sure switch board is up." + bring_down_pfvf + pf_setup + continue + fi + + # Make sure TestPoint is up. + ${CURRENT_PATH}/${REMOTE_CONTROL_BIN} -s ${TP_SVR} -n ${TP_PORT} -c "show version" + if [ $? -ne 0 ];then + echo "Cannot reach TestPoint!" + echo "Please make sure TestPoint is up and in remote-listen mode." + sleep 5 + continue + fi + + # Create VFs and get MAC addresses + #vf_setup + /usr/bin/sh /opt/tsg/env/vf-setup + sleep 5 + + PF=`get_netdev_by_pci 01:00.0` + VF1=`get_netdev_by_pci 01:00.1` + VF2=`get_netdev_by_pci 01:00.2` + VF3=`get_netdev_by_pci 01:00.3` + VF4=`get_netdev_by_pci 01:00.4` + VF5=`get_netdev_by_pci 01:00.5` + VF6=`get_netdev_by_pci 01:00.6` + VF7=`get_netdev_by_pci 01:00.7` + VF8=`get_netdev_by_pci 01:01.0` + + MAC1=`ifconfig ${VF1} |grep ether |awk -F' ' '{print $2}'` + MAC2=`ifconfig ${VF2} |grep ether |awk -F' ' '{print $2}'` + MAC3=`ifconfig ${VF3} |grep ether |awk -F' ' '{print $2}'` + MAC4=`ifconfig ${VF4} |grep ether |awk -F' ' '{print $2}'` + MAC5=`ifconfig ${VF5} |grep ether |awk -F' ' '{print $2}'` + MAC6=`ifconfig ${VF6} |grep ether |awk -F' ' '{print $2}'` + MAC7=`ifconfig ${VF7} |grep ether |awk -F' ' '{print $2}'` + MAC8=`ifconfig ${VF8} |grep ether |awk -F' ' '{print $2}'` + MAC9=`ifconfig ${PF} |grep ether |awk -F' ' '{print $2}'` + + # Make sure VFs are valid + MAC_TABLE=`${CURRENT_PATH}/${REMOTE_CONTROL_BIN} -s ${TP_SVR} -n ${TP_PORT} -c "show mac table all"` + + for i in ${MAC1} ${MAC2} ${MAC3} ${MAC4} ${MAC5} ${MAC6} ${MAC7} ${MAC8} ${MAC9} + do + echo ${MAC_TABLE} |grep ${i} > /dev/null 2>&1 + if [ $? -ne 0 ];then + echo "MAC ${i} is not in table!" + FAIL_FLAG=1 + break + fi + done + + if [ ${FAIL_FLAG} -eq 1 ];then + bring_down_pfvf + continue + fi + + echo "PF/VF setup successful." + exit 0 +done + + diff --git a/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn0_tsg-env.service b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn0_tsg-env.service new file mode 100644 index 0000000..157ff6a --- /dev/null +++ b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn0_tsg-env.service @@ -0,0 +1,14 @@ +[Unit] +Description=tsg sled-mcn0 env init +Requires=network.target +After=network.target +Before=mrenv.service + +[Service] +ExecStart=/opt/tsg/env/setup +Type=oneshot +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target +RequiredBy=mrenv.service diff --git a/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn0_vf-setup b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn0_vf-setup new file mode 100644 index 0000000..54f61ff --- /dev/null +++ b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn0_vf-setup @@ -0,0 +1,15 @@ +echo 8 > /sys/class/net/ens1/device/sriov_numvfs +sleep 5 + +ifconfig ens1f3 up +ip link set ens1 vf 2 vlan 200 +ifconfig ens1f3 192.168.200.1 netmask 255.255.255.0 + +ifconfig ens1f1 up +ifconfig ens1f2 up +ifconfig ens1f3 up +ifconfig ens1f4 up +ifconfig ens1f5 up +ifconfig ens1f6 up +ifconfig ens1f7 up +ifconfig enp1s1 up diff --git a/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn1_setup b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn1_setup new file mode 100644 index 0000000..1fd9a77 --- /dev/null +++ b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn1_setup @@ -0,0 +1,117 @@ +#!/bin/bash +# set -x + +CURRENT_PATH=`dirname $0` +TP_SVR=192.168.100.5 +TP_PORT=10000 +REMOTE_CONTROL_BIN=switch_control_client_non_block +modprobe 8021q + +function get_netdev_by_pci() +{ + DEV_LIST=`ifconfig -a |grep flags |awk -F: '{print $1}'` + for i in ${DEV_LIST} + do + ethtool -i ${i} |grep bus-info |grep "$1" > /dev/null 2>&1 + if [ $? -eq 0 ];then + TARGET=${i} + break + fi + done + + echo ${TARGET} +} + +function pf_setup() +{ + ifconfig ens1 up + vconfig add ens1 100 + vconfig set_flag ens1.100 1 1 + ifconfig ens1.100 192.168.100.2 netmask 255.255.255.0 up + sleep 1 +} + +function vf_setup() +{ + echo 4 > /sys/class/net/ens1/device/sriov_numvfs + sleep 5 + + ifconfig ens1f3 up + ip link set ens1 vf 2 vlan 200 + ifconfig ens1f3 192.168.200.2 netmask 255.255.255.0 + + ifconfig ens1f1 up + ifconfig ens1f2 up + ifconfig ens1f3 up + ifconfig ens1f4 up + sleep 5 +} + +function bring_down_pfvf() +{ + echo 0 > /sys/class/net/ens1/device/sriov_numvfs + ifconfig ens1 down + sleep 3 +} + +# Main loop +while : +do + FAIL_FLAG=0 + + # Make sure PF is valid + ping ${TP_SVR} -c 1 + if [ $? -ne 0 ];then + echo "Please make sure switch board is up." + bring_down_pfvf + pf_setup + continue + fi + + # Make sure TestPoint is up. + ${CURRENT_PATH}/${REMOTE_CONTROL_BIN} -s ${TP_SVR} -n ${TP_PORT} -c "show version" + if [ $? -ne 0 ];then + echo "Cannot reach TestPoint!" + echo "Please make sure TestPoint is up and in remote-listen mode." + sleep 5 + continue + fi + + # Create VFs and get MAC addresses + #vf_setup + /usr/bin/sh /opt/tsg/env/vf-setup + sleep 5 + + PF=`get_netdev_by_pci 01:00.0` + VF1=`get_netdev_by_pci 01:00.1` + VF2=`get_netdev_by_pci 01:00.2` + VF3=`get_netdev_by_pci 01:00.3` + VF4=`get_netdev_by_pci 01:00.4` + + MAC0=`ifconfig ${PF} |grep ether |awk -F' ' '{print $2}'` + MAC1=`ifconfig ${VF1} |grep ether |awk -F' ' '{print $2}'` + MAC2=`ifconfig ${VF2} |grep ether |awk -F' ' '{print $2}'` + MAC3=`ifconfig ${VF3} |grep ether |awk -F' ' '{print $2}'` + MAC4=`ifconfig ${VF4} |grep ether |awk -F' ' '{print $2}'` + + # Make sure VFs are valid + MAC_TABLE=`${CURRENT_PATH}/${REMOTE_CONTROL_BIN} -s ${TP_SVR} -n ${TP_PORT} -c "show mac table all"` + + for i in ${MAC0} ${MAC1} ${MAC2} ${MAC3} ${MAC4} + do + echo ${MAC_TABLE} |grep ${i} > /dev/null 2>&1 + if [ $? -ne 0 ];then + echo "MAC ${i} is not in table!" + FAIL_FLAG=1 + break + fi + done + + if [ ${FAIL_FLAG} -eq 1 ];then + bring_down_pfvf + continue + fi + + echo "PF/VF setup successful." + exit 0 +done diff --git a/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn1_tsg-env.service b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn1_tsg-env.service new file mode 100644 index 0000000..a622f69 --- /dev/null +++ b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn1_tsg-env.service @@ -0,0 +1,15 @@ +[Unit] +Description=tsg sled-mcn1 env init +Requires=network.target +After=network.target +Before=tfe-env.service mrenv.service + +[Service] +ExecStart=/opt/tsg/env/setup +ExecStop=/opt/tsg/env/stop +Type=oneshot +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target +RequiredBy=tfe-env.service mrenv.service diff --git a/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn1_vf-setup b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn1_vf-setup new file mode 100644 index 0000000..fb63776 --- /dev/null +++ b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn1_vf-setup @@ -0,0 +1,11 @@ +echo 4 > /sys/class/net/ens1/device/sriov_numvfs +sleep 5 + +ifconfig ens1f3 up +ip link set ens1 vf 2 vlan 200 +ifconfig ens1f3 192.168.200.2 netmask 255.255.255.0 + +ifconfig ens1f1 up +ifconfig ens1f2 up +ifconfig ens1f3 up +ifconfig ens1f4 up diff --git a/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn2_setup b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn2_setup new file mode 100644 index 0000000..a8542ff --- /dev/null +++ b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn2_setup @@ -0,0 +1,117 @@ +#!/bin/bash +# set -x + +CURRENT_PATH=`dirname $0` +TP_SVR=192.168.100.5 +TP_PORT=10000 +REMOTE_CONTROL_BIN=switch_control_client_non_block +modprobe 8021q + +function get_netdev_by_pci() +{ + DEV_LIST=`ifconfig -a |grep flags |awk -F: '{print $1}'` + for i in ${DEV_LIST} + do + ethtool -i ${i} |grep bus-info |grep "$1" > /dev/null 2>&1 + if [ $? -eq 0 ];then + TARGET=${i} + break + fi + done + + echo ${TARGET} +} + +function pf_setup() +{ + ifconfig ens8 up + vconfig add ens8 100 + vconfig set_flag ens8.100 1 1 + ifconfig ens8.100 192.168.100.3 netmask 255.255.255.0 up + sleep 1 +} + +function vf_setup() +{ + echo 4 > /sys/class/net/ens8/device/sriov_numvfs + sleep 5 + + ifconfig ens8f3 up + ip link set ens8 vf 2 vlan 200 + ifconfig ens8f3 192.168.200.3 netmask 255.255.255.0 + + ifconfig ens8f1 up + ifconfig ens8f2 up + ifconfig ens8f3 up + ifconfig ens8f4 up + sleep 5 +} + +function bring_down_pfvf() +{ + echo 0 > /sys/class/net/ens8/device/sriov_numvfs + ifconfig ens8 down + sleep 3 +} + +# Main loop +while : +do + FAIL_FLAG=0 + + # Make sure PF is valid + ping ${TP_SVR} -c 1 + if [ $? -ne 0 ];then + echo "Please make sure switch board is up." + bring_down_pfvf + pf_setup + continue + fi + + # Make sure TestPoint is up. + ${CURRENT_PATH}/${REMOTE_CONTROL_BIN} -s ${TP_SVR} -n ${TP_PORT} -c "show version" + if [ $? -ne 0 ];then + echo "Cannot reach TestPoint!" + echo "Please make sure TestPoint is up and in remote-listen mode." + sleep 5 + continue + fi + + # Create VFs and get MAC addresses + #vf_setup + /usr/bin/sh /opt/tsg/env/vf-setup + sleep 5 + + PF=`get_netdev_by_pci 85:00.0` + VF1=`get_netdev_by_pci 85:00.1` + VF2=`get_netdev_by_pci 85:00.2` + VF3=`get_netdev_by_pci 85:00.3` + VF4=`get_netdev_by_pci 85:00.4` + + MAC0=`ifconfig ${PF} |grep ether |awk -F' ' '{print $2}'` + MAC1=`ifconfig ${VF1} |grep ether |awk -F' ' '{print $2}'` + MAC2=`ifconfig ${VF2} |grep ether |awk -F' ' '{print $2}'` + MAC3=`ifconfig ${VF3} |grep ether |awk -F' ' '{print $2}'` + MAC4=`ifconfig ${VF4} |grep ether |awk -F' ' '{print $2}'` + + # Make sure VFs are valid + MAC_TABLE=`${CURRENT_PATH}/${REMOTE_CONTROL_BIN} -s ${TP_SVR} -n ${TP_PORT} -c "show mac table all"` + + for i in ${MAC0} ${MAC1} ${MAC2} ${MAC3} ${MAC4} + do + echo ${MAC_TABLE} |grep ${i} > /dev/null 2>&1 + if [ $? -ne 0 ];then + echo "MAC ${i} is not in table!" + FAIL_FLAG=1 + break + fi + done + + if [ ${FAIL_FLAG} -eq 1 ];then + bring_down_pfvf + continue + fi + + echo "PF/VF setup successful." + exit 0 +done diff --git a/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn2_tsg-env.service b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn2_tsg-env.service new file mode 100644 index 0000000..c78a63b --- /dev/null +++ b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn2_tsg-env.service @@ -0,0 +1,15 @@ +[Unit] +Description=tsg sled-mcn2 env init +Requires=network.target +After=network.target +Before=tfe-env.service mrenv.service + +[Service] +ExecStart=/opt/tsg/env/setup +ExecStop=/opt/tsg/env/stop +Type=oneshot +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target +RequiredBy=tfe-env.service mrenv.service diff --git a/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn2_vf-setup b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn2_vf-setup new file mode 100644 index 0000000..fdbf459 --- /dev/null +++ b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn2_vf-setup @@ -0,0 +1,11 @@ +echo 4 > /sys/class/net/ens8/device/sriov_numvfs +sleep 5 + +ifconfig ens8f3 up +ip link set ens8 vf 2 vlan 200 +ifconfig ens8f3 192.168.200.3 netmask 255.255.255.0 + +ifconfig ens8f1 up +ifconfig ens8f2 up +ifconfig ens8f3 up +ifconfig ens8f4 up diff --git a/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn3_setup b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn3_setup new file mode 100644 index 0000000..980b16b --- /dev/null +++ b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn3_setup @@ -0,0 +1,117 @@ +#!/bin/bash +# set -x + +CURRENT_PATH=`dirname $0` +TP_SVR=192.168.100.5 +TP_PORT=10000 +REMOTE_CONTROL_BIN=switch_control_client_non_block +modprobe 8021q + +function get_netdev_by_pci() +{ + DEV_LIST=`ifconfig -a |grep flags |awk -F: '{print $1}'` + for i in ${DEV_LIST} + do + ethtool -i ${i} |grep bus-info |grep "$1" > /dev/null 2>&1 + if [ $? -eq 0 ];then + TARGET=${i} + break + fi + done + + echo ${TARGET} +} + +function pf_setup() +{ + ifconfig ens8 up + vconfig add ens8 100 + vconfig set_flag ens8.100 1 1 + ifconfig ens8.100 192.168.100.4 netmask 255.255.255.0 up + sleep 1 +} + +function vf_setup() +{ + echo 4 > /sys/class/net/ens8/device/sriov_numvfs + sleep 5 + + ifconfig ens8f3 up + ip link set ens8 vf 2 vlan 200 + ifconfig ens8f3 192.168.200.4 netmask 255.255.255.0 + + ifconfig ens8f1 up + ifconfig ens8f2 up + ifconfig ens8f3 up + ifconfig ens8f4 up + sleep 5 +} + +function bring_down_pfvf() +{ + echo 0 > /sys/class/net/ens8/device/sriov_numvfs + ifconfig ens8 down + sleep 3 +} + +# Main loop +while : +do + FAIL_FLAG=0 + + # Make sure PF is valid + ping ${TP_SVR} -c 1 + if [ $? -ne 0 ];then + echo "Please make sure switch board is up." + bring_down_pfvf + pf_setup + continue + fi + + # Make sure TestPoint is up. + ${CURRENT_PATH}/${REMOTE_CONTROL_BIN} -s ${TP_SVR} -n ${TP_PORT} -c "show version" + if [ $? -ne 0 ];then + echo "Cannot reach TestPoint!" + echo "Please make sure TestPoint is up and in remote-listen mode." + sleep 5 + continue + fi + + # Create VFs and get MAC addresses + #vf_setup + /usr/bin/sh /opt/tsg/env/vf-setup + sleep 5 + + PF=`get_netdev_by_pci 85:00.0` + VF1=`get_netdev_by_pci 85:00.1` + VF2=`get_netdev_by_pci 85:00.2` + VF3=`get_netdev_by_pci 85:00.3` + VF4=`get_netdev_by_pci 85:00.4` + + MAC0=`ifconfig ${PF} |grep ether |awk -F' ' '{print $2}'` + MAC1=`ifconfig ${VF1} |grep ether |awk -F' ' '{print $2}'` + MAC2=`ifconfig ${VF2} |grep ether |awk -F' ' '{print $2}'` + MAC3=`ifconfig ${VF3} |grep ether |awk -F' ' '{print $2}'` + MAC4=`ifconfig ${VF4} |grep ether |awk -F' ' '{print $2}'` + + # Make sure VFs are valid + MAC_TABLE=`${CURRENT_PATH}/${REMOTE_CONTROL_BIN} -s ${TP_SVR} -n ${TP_PORT} -c "show mac table all"` + + for i in ${MAC0} ${MAC1} ${MAC2} ${MAC3} ${MAC4} + do + echo ${MAC_TABLE} |grep ${i} > /dev/null 2>&1 + if [ $? -ne 0 ];then + echo "MAC ${i} is not in table!" + FAIL_FLAG=1 + break + fi + done + + if [ ${FAIL_FLAG} -eq 1 ];then + bring_down_pfvf + continue + fi + + echo "PF/VF setup successful." + exit 0 +done diff --git a/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn3_tsg-env.service b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn3_tsg-env.service new file mode 100644 index 0000000..29f6319 --- /dev/null +++ b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn3_tsg-env.service @@ -0,0 +1,15 @@ +[Unit] +Description=tsg sled-mcn3 env init +Requires=network.target +After=network.target +Before=tfe-env.service mrenv.service + +[Service] +ExecStart=/opt/tsg/env/setup +ExecStop=/opt/tsg/env/stop +Type=oneshot +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target +RequiredBy=tfe-env.service mrenv.service diff --git a/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn3_vf-setup b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn3_vf-setup new file mode 100644 index 0000000..e2e7667 --- /dev/null +++ b/init_mcn_network/init_adc_cpu_broad/tsg-env/tsg-env-mcn3_vf-setup @@ -0,0 +1,11 @@ +echo 4 > /sys/class/net/ens8/device/sriov_numvfs +sleep 5 + +ifconfig ens8f3 up +ip link set ens8 vf 2 vlan 200 +ifconfig ens8f3 192.168.200.4 netmask 255.255.255.0 + +ifconfig ens8f1 up +ifconfig ens8f2 up +ifconfig ens8f3 up +ifconfig ens8f4 up diff --git a/init_mcn_network/logfile.txt b/init_mcn_network/logfile.txt deleted file mode 100644 index 257ddee..0000000 --- a/init_mcn_network/logfile.txt +++ /dev/null @@ -1,5 +0,0 @@ -[2019-12-06 11:20:01] this is mcn2 -[2019-12-06 11:20:13] Service conf updated -[2019-12-06 11:20:13] Service tsg-env enabled -[2019-12-06 11:20:13] pf name is ens8 -[2019-12-06 11:20:13] NIC name is correct diff --git a/init_mcn_network/tsg-env/.gitkeep b/init_mcn_network/tsg-env/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/init_mcn_network/tsg-env/switch_control_client_non_block b/init_mcn_network/tsg-env/switch_control_client_non_block deleted file mode 100644 index 5cdba48..0000000 Binary files a/init_mcn_network/tsg-env/switch_control_client_non_block and /dev/null differ diff --git a/init_mcn_network/tsg-env/tsg-env-mcn0_setup b/init_mcn_network/tsg-env/tsg-env-mcn0_setup deleted file mode 100644 index 279c55b..0000000 --- a/init_mcn_network/tsg-env/tsg-env-mcn0_setup +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/bash -# set -x - -CURRENT_PATH=`dirname $0` -TP_SVR=192.168.100.5 -TP_PORT=10000 -REMOTE_CONTROL_BIN=switch_control_client_non_block - -function get_netdev_by_pci() -{ - DEV_LIST=`ifconfig -a |grep flags |awk -F: '{print $1}'` - for i in ${DEV_LIST} - do - ethtool -i ${i} |grep bus-info |grep "$1" > /dev/null 2>&1 - if [ $? -eq 0 ];then - TARGET=${i} - break - fi - done - - echo ${TARGET} -} - -function pf_setup() -{ - ifconfig ens1 up - - modprobe 8021q - vconfig add ens1 100 - vconfig set_flag ens1.100 1 1 - ifconfig ens1.100 192.168.100.1 netmask 255.255.255.0 up - sleep 1 -} - -function vf_setup() -{ - echo 8 > /sys/class/net/ens1/device/sriov_numvfs - sleep 5 - - ifconfig ens1f3 up - ip link set ens1 vf 2 vlan 200 - ifconfig ens1f3 192.168.200.1 netmask 255.255.255.0 - - ifconfig ens1f1 up - ifconfig ens1f2 up - ifconfig ens1f3 up - ifconfig ens1f4 up - ifconfig ens1f5 up - ifconfig ens1f6 up - ifconfig ens1f7 up - ifconfig enp1s1 up - - sleep 5 -} - -function bring_down_pfvf() -{ - echo 0 > /sys/class/net/ens1/device/sriov_numvfs - ifconfig ens1 down - sleep 3 -} - - -# Main loop -while : -do - FAIL_FLAG=0 - - # Make sure PF is valid - ping ${TP_SVR} -c 1 - if [ $? -ne 0 ];then - echo "Please make sure switch board is up." - bring_down_pfvf - pf_setup - continue - fi - - # Make sure TestPoint is up. - ${CURRENT_PATH}/${REMOTE_CONTROL_BIN} -s ${TP_SVR} -n ${TP_PORT} -c "show version" - if [ $? -ne 0 ];then - echo "Cannot reach TestPoint!" - echo "Please make sure TestPoint is up and in remote-listen mode." - sleep 5 - continue - fi - - # Create VFs and get MAC addresses - #vf_setup - /usr/bin/sh /opt/tsg/env/vf-setup - sleep 5 - - PF=`get_netdev_by_pci 01:00.0` - VF1=`get_netdev_by_pci 01:00.1` - VF2=`get_netdev_by_pci 01:00.2` - VF3=`get_netdev_by_pci 01:00.3` - VF4=`get_netdev_by_pci 01:00.4` - VF5=`get_netdev_by_pci 01:00.5` - VF6=`get_netdev_by_pci 01:00.6` - VF7=`get_netdev_by_pci 01:00.7` - VF8=`get_netdev_by_pci 01:01.0` - - MAC1=`ifconfig ${VF1} |grep ether |awk -F' ' '{print $2}'` - MAC2=`ifconfig ${VF2} |grep ether |awk -F' ' '{print $2}'` - MAC3=`ifconfig ${VF3} |grep ether |awk -F' ' '{print $2}'` - MAC4=`ifconfig ${VF4} |grep ether |awk -F' ' '{print $2}'` - MAC5=`ifconfig ${VF5} |grep ether |awk -F' ' '{print $2}'` - MAC6=`ifconfig ${VF6} |grep ether |awk -F' ' '{print $2}'` - MAC7=`ifconfig ${VF7} |grep ether |awk -F' ' '{print $2}'` - MAC8=`ifconfig ${VF8} |grep ether |awk -F' ' '{print $2}'` - MAC9=`ifconfig ${PF} |grep ether |awk -F' ' '{print $2}'` - - # Make sure VFs are valid - MAC_TABLE=`${CURRENT_PATH}/${REMOTE_CONTROL_BIN} -s ${TP_SVR} -n ${TP_PORT} -c "show mac table all"` - - for i in ${MAC1} ${MAC2} ${MAC3} ${MAC4} ${MAC5} ${MAC6} ${MAC7} ${MAC8} ${MAC9} - do - echo ${MAC_TABLE} |grep ${i} > /dev/null 2>&1 - if [ $? -ne 0 ];then - echo "MAC ${i} is not in table!" - FAIL_FLAG=1 - break - fi - done - - if [ ${FAIL_FLAG} -eq 1 ];then - bring_down_pfvf - continue - fi - - echo "PF/VF setup successful." - exit 0 -done - - diff --git a/init_mcn_network/tsg-env/tsg-env-mcn0_tsg-env.service b/init_mcn_network/tsg-env/tsg-env-mcn0_tsg-env.service deleted file mode 100644 index 157ff6a..0000000 --- a/init_mcn_network/tsg-env/tsg-env-mcn0_tsg-env.service +++ /dev/null @@ -1,14 +0,0 @@ -[Unit] -Description=tsg sled-mcn0 env init -Requires=network.target -After=network.target -Before=mrenv.service - -[Service] -ExecStart=/opt/tsg/env/setup -Type=oneshot -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target -RequiredBy=mrenv.service diff --git a/init_mcn_network/tsg-env/tsg-env-mcn0_vf-setup b/init_mcn_network/tsg-env/tsg-env-mcn0_vf-setup deleted file mode 100644 index 54f61ff..0000000 --- a/init_mcn_network/tsg-env/tsg-env-mcn0_vf-setup +++ /dev/null @@ -1,15 +0,0 @@ -echo 8 > /sys/class/net/ens1/device/sriov_numvfs -sleep 5 - -ifconfig ens1f3 up -ip link set ens1 vf 2 vlan 200 -ifconfig ens1f3 192.168.200.1 netmask 255.255.255.0 - -ifconfig ens1f1 up -ifconfig ens1f2 up -ifconfig ens1f3 up -ifconfig ens1f4 up -ifconfig ens1f5 up -ifconfig ens1f6 up -ifconfig ens1f7 up -ifconfig enp1s1 up diff --git a/init_mcn_network/tsg-env/tsg-env-mcn1_setup b/init_mcn_network/tsg-env/tsg-env-mcn1_setup deleted file mode 100644 index 1fd9a77..0000000 --- a/init_mcn_network/tsg-env/tsg-env-mcn1_setup +++ /dev/null @@ -1,117 +0,0 @@ -#!/bin/bash -# set -x - -CURRENT_PATH=`dirname $0` -TP_SVR=192.168.100.5 -TP_PORT=10000 -REMOTE_CONTROL_BIN=switch_control_client_non_block -modprobe 8021q - -function get_netdev_by_pci() -{ - DEV_LIST=`ifconfig -a |grep flags |awk -F: '{print $1}'` - for i in ${DEV_LIST} - do - ethtool -i ${i} |grep bus-info |grep "$1" > /dev/null 2>&1 - if [ $? -eq 0 ];then - TARGET=${i} - break - fi - done - - echo ${TARGET} -} - -function pf_setup() -{ - ifconfig ens1 up - vconfig add ens1 100 - vconfig set_flag ens1.100 1 1 - ifconfig ens1.100 192.168.100.2 netmask 255.255.255.0 up - sleep 1 -} - -function vf_setup() -{ - echo 4 > /sys/class/net/ens1/device/sriov_numvfs - sleep 5 - - ifconfig ens1f3 up - ip link set ens1 vf 2 vlan 200 - ifconfig ens1f3 192.168.200.2 netmask 255.255.255.0 - - ifconfig ens1f1 up - ifconfig ens1f2 up - ifconfig ens1f3 up - ifconfig ens1f4 up - sleep 5 -} - -function bring_down_pfvf() -{ - echo 0 > /sys/class/net/ens1/device/sriov_numvfs - ifconfig ens1 down - sleep 3 -} - -# Main loop -while : -do - FAIL_FLAG=0 - - # Make sure PF is valid - ping ${TP_SVR} -c 1 - if [ $? -ne 0 ];then - echo "Please make sure switch board is up." - bring_down_pfvf - pf_setup - continue - fi - - # Make sure TestPoint is up. - ${CURRENT_PATH}/${REMOTE_CONTROL_BIN} -s ${TP_SVR} -n ${TP_PORT} -c "show version" - if [ $? -ne 0 ];then - echo "Cannot reach TestPoint!" - echo "Please make sure TestPoint is up and in remote-listen mode." - sleep 5 - continue - fi - - # Create VFs and get MAC addresses - #vf_setup - /usr/bin/sh /opt/tsg/env/vf-setup - sleep 5 - - PF=`get_netdev_by_pci 01:00.0` - VF1=`get_netdev_by_pci 01:00.1` - VF2=`get_netdev_by_pci 01:00.2` - VF3=`get_netdev_by_pci 01:00.3` - VF4=`get_netdev_by_pci 01:00.4` - - MAC0=`ifconfig ${PF} |grep ether |awk -F' ' '{print $2}'` - MAC1=`ifconfig ${VF1} |grep ether |awk -F' ' '{print $2}'` - MAC2=`ifconfig ${VF2} |grep ether |awk -F' ' '{print $2}'` - MAC3=`ifconfig ${VF3} |grep ether |awk -F' ' '{print $2}'` - MAC4=`ifconfig ${VF4} |grep ether |awk -F' ' '{print $2}'` - - # Make sure VFs are valid - MAC_TABLE=`${CURRENT_PATH}/${REMOTE_CONTROL_BIN} -s ${TP_SVR} -n ${TP_PORT} -c "show mac table all"` - - for i in ${MAC0} ${MAC1} ${MAC2} ${MAC3} ${MAC4} - do - echo ${MAC_TABLE} |grep ${i} > /dev/null 2>&1 - if [ $? -ne 0 ];then - echo "MAC ${i} is not in table!" - FAIL_FLAG=1 - break - fi - done - - if [ ${FAIL_FLAG} -eq 1 ];then - bring_down_pfvf - continue - fi - - echo "PF/VF setup successful." - exit 0 -done diff --git a/init_mcn_network/tsg-env/tsg-env-mcn1_tsg-env.service b/init_mcn_network/tsg-env/tsg-env-mcn1_tsg-env.service deleted file mode 100644 index a622f69..0000000 --- a/init_mcn_network/tsg-env/tsg-env-mcn1_tsg-env.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=tsg sled-mcn1 env init -Requires=network.target -After=network.target -Before=tfe-env.service mrenv.service - -[Service] -ExecStart=/opt/tsg/env/setup -ExecStop=/opt/tsg/env/stop -Type=oneshot -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target -RequiredBy=tfe-env.service mrenv.service diff --git a/init_mcn_network/tsg-env/tsg-env-mcn1_vf-setup b/init_mcn_network/tsg-env/tsg-env-mcn1_vf-setup deleted file mode 100644 index fb63776..0000000 --- a/init_mcn_network/tsg-env/tsg-env-mcn1_vf-setup +++ /dev/null @@ -1,11 +0,0 @@ -echo 4 > /sys/class/net/ens1/device/sriov_numvfs -sleep 5 - -ifconfig ens1f3 up -ip link set ens1 vf 2 vlan 200 -ifconfig ens1f3 192.168.200.2 netmask 255.255.255.0 - -ifconfig ens1f1 up -ifconfig ens1f2 up -ifconfig ens1f3 up -ifconfig ens1f4 up diff --git a/init_mcn_network/tsg-env/tsg-env-mcn2_setup b/init_mcn_network/tsg-env/tsg-env-mcn2_setup deleted file mode 100644 index a8542ff..0000000 --- a/init_mcn_network/tsg-env/tsg-env-mcn2_setup +++ /dev/null @@ -1,117 +0,0 @@ -#!/bin/bash -# set -x - -CURRENT_PATH=`dirname $0` -TP_SVR=192.168.100.5 -TP_PORT=10000 -REMOTE_CONTROL_BIN=switch_control_client_non_block -modprobe 8021q - -function get_netdev_by_pci() -{ - DEV_LIST=`ifconfig -a |grep flags |awk -F: '{print $1}'` - for i in ${DEV_LIST} - do - ethtool -i ${i} |grep bus-info |grep "$1" > /dev/null 2>&1 - if [ $? -eq 0 ];then - TARGET=${i} - break - fi - done - - echo ${TARGET} -} - -function pf_setup() -{ - ifconfig ens8 up - vconfig add ens8 100 - vconfig set_flag ens8.100 1 1 - ifconfig ens8.100 192.168.100.3 netmask 255.255.255.0 up - sleep 1 -} - -function vf_setup() -{ - echo 4 > /sys/class/net/ens8/device/sriov_numvfs - sleep 5 - - ifconfig ens8f3 up - ip link set ens8 vf 2 vlan 200 - ifconfig ens8f3 192.168.200.3 netmask 255.255.255.0 - - ifconfig ens8f1 up - ifconfig ens8f2 up - ifconfig ens8f3 up - ifconfig ens8f4 up - sleep 5 -} - -function bring_down_pfvf() -{ - echo 0 > /sys/class/net/ens8/device/sriov_numvfs - ifconfig ens8 down - sleep 3 -} - -# Main loop -while : -do - FAIL_FLAG=0 - - # Make sure PF is valid - ping ${TP_SVR} -c 1 - if [ $? -ne 0 ];then - echo "Please make sure switch board is up." - bring_down_pfvf - pf_setup - continue - fi - - # Make sure TestPoint is up. - ${CURRENT_PATH}/${REMOTE_CONTROL_BIN} -s ${TP_SVR} -n ${TP_PORT} -c "show version" - if [ $? -ne 0 ];then - echo "Cannot reach TestPoint!" - echo "Please make sure TestPoint is up and in remote-listen mode." - sleep 5 - continue - fi - - # Create VFs and get MAC addresses - #vf_setup - /usr/bin/sh /opt/tsg/env/vf-setup - sleep 5 - - PF=`get_netdev_by_pci 85:00.0` - VF1=`get_netdev_by_pci 85:00.1` - VF2=`get_netdev_by_pci 85:00.2` - VF3=`get_netdev_by_pci 85:00.3` - VF4=`get_netdev_by_pci 85:00.4` - - MAC0=`ifconfig ${PF} |grep ether |awk -F' ' '{print $2}'` - MAC1=`ifconfig ${VF1} |grep ether |awk -F' ' '{print $2}'` - MAC2=`ifconfig ${VF2} |grep ether |awk -F' ' '{print $2}'` - MAC3=`ifconfig ${VF3} |grep ether |awk -F' ' '{print $2}'` - MAC4=`ifconfig ${VF4} |grep ether |awk -F' ' '{print $2}'` - - # Make sure VFs are valid - MAC_TABLE=`${CURRENT_PATH}/${REMOTE_CONTROL_BIN} -s ${TP_SVR} -n ${TP_PORT} -c "show mac table all"` - - for i in ${MAC0} ${MAC1} ${MAC2} ${MAC3} ${MAC4} - do - echo ${MAC_TABLE} |grep ${i} > /dev/null 2>&1 - if [ $? -ne 0 ];then - echo "MAC ${i} is not in table!" - FAIL_FLAG=1 - break - fi - done - - if [ ${FAIL_FLAG} -eq 1 ];then - bring_down_pfvf - continue - fi - - echo "PF/VF setup successful." - exit 0 -done diff --git a/init_mcn_network/tsg-env/tsg-env-mcn2_tsg-env.service b/init_mcn_network/tsg-env/tsg-env-mcn2_tsg-env.service deleted file mode 100644 index c78a63b..0000000 --- a/init_mcn_network/tsg-env/tsg-env-mcn2_tsg-env.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=tsg sled-mcn2 env init -Requires=network.target -After=network.target -Before=tfe-env.service mrenv.service - -[Service] -ExecStart=/opt/tsg/env/setup -ExecStop=/opt/tsg/env/stop -Type=oneshot -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target -RequiredBy=tfe-env.service mrenv.service diff --git a/init_mcn_network/tsg-env/tsg-env-mcn2_vf-setup b/init_mcn_network/tsg-env/tsg-env-mcn2_vf-setup deleted file mode 100644 index fdbf459..0000000 --- a/init_mcn_network/tsg-env/tsg-env-mcn2_vf-setup +++ /dev/null @@ -1,11 +0,0 @@ -echo 4 > /sys/class/net/ens8/device/sriov_numvfs -sleep 5 - -ifconfig ens8f3 up -ip link set ens8 vf 2 vlan 200 -ifconfig ens8f3 192.168.200.3 netmask 255.255.255.0 - -ifconfig ens8f1 up -ifconfig ens8f2 up -ifconfig ens8f3 up -ifconfig ens8f4 up diff --git a/init_mcn_network/tsg-env/tsg-env-mcn3_setup b/init_mcn_network/tsg-env/tsg-env-mcn3_setup deleted file mode 100644 index 980b16b..0000000 --- a/init_mcn_network/tsg-env/tsg-env-mcn3_setup +++ /dev/null @@ -1,117 +0,0 @@ -#!/bin/bash -# set -x - -CURRENT_PATH=`dirname $0` -TP_SVR=192.168.100.5 -TP_PORT=10000 -REMOTE_CONTROL_BIN=switch_control_client_non_block -modprobe 8021q - -function get_netdev_by_pci() -{ - DEV_LIST=`ifconfig -a |grep flags |awk -F: '{print $1}'` - for i in ${DEV_LIST} - do - ethtool -i ${i} |grep bus-info |grep "$1" > /dev/null 2>&1 - if [ $? -eq 0 ];then - TARGET=${i} - break - fi - done - - echo ${TARGET} -} - -function pf_setup() -{ - ifconfig ens8 up - vconfig add ens8 100 - vconfig set_flag ens8.100 1 1 - ifconfig ens8.100 192.168.100.4 netmask 255.255.255.0 up - sleep 1 -} - -function vf_setup() -{ - echo 4 > /sys/class/net/ens8/device/sriov_numvfs - sleep 5 - - ifconfig ens8f3 up - ip link set ens8 vf 2 vlan 200 - ifconfig ens8f3 192.168.200.4 netmask 255.255.255.0 - - ifconfig ens8f1 up - ifconfig ens8f2 up - ifconfig ens8f3 up - ifconfig ens8f4 up - sleep 5 -} - -function bring_down_pfvf() -{ - echo 0 > /sys/class/net/ens8/device/sriov_numvfs - ifconfig ens8 down - sleep 3 -} - -# Main loop -while : -do - FAIL_FLAG=0 - - # Make sure PF is valid - ping ${TP_SVR} -c 1 - if [ $? -ne 0 ];then - echo "Please make sure switch board is up." - bring_down_pfvf - pf_setup - continue - fi - - # Make sure TestPoint is up. - ${CURRENT_PATH}/${REMOTE_CONTROL_BIN} -s ${TP_SVR} -n ${TP_PORT} -c "show version" - if [ $? -ne 0 ];then - echo "Cannot reach TestPoint!" - echo "Please make sure TestPoint is up and in remote-listen mode." - sleep 5 - continue - fi - - # Create VFs and get MAC addresses - #vf_setup - /usr/bin/sh /opt/tsg/env/vf-setup - sleep 5 - - PF=`get_netdev_by_pci 85:00.0` - VF1=`get_netdev_by_pci 85:00.1` - VF2=`get_netdev_by_pci 85:00.2` - VF3=`get_netdev_by_pci 85:00.3` - VF4=`get_netdev_by_pci 85:00.4` - - MAC0=`ifconfig ${PF} |grep ether |awk -F' ' '{print $2}'` - MAC1=`ifconfig ${VF1} |grep ether |awk -F' ' '{print $2}'` - MAC2=`ifconfig ${VF2} |grep ether |awk -F' ' '{print $2}'` - MAC3=`ifconfig ${VF3} |grep ether |awk -F' ' '{print $2}'` - MAC4=`ifconfig ${VF4} |grep ether |awk -F' ' '{print $2}'` - - # Make sure VFs are valid - MAC_TABLE=`${CURRENT_PATH}/${REMOTE_CONTROL_BIN} -s ${TP_SVR} -n ${TP_PORT} -c "show mac table all"` - - for i in ${MAC0} ${MAC1} ${MAC2} ${MAC3} ${MAC4} - do - echo ${MAC_TABLE} |grep ${i} > /dev/null 2>&1 - if [ $? -ne 0 ];then - echo "MAC ${i} is not in table!" - FAIL_FLAG=1 - break - fi - done - - if [ ${FAIL_FLAG} -eq 1 ];then - bring_down_pfvf - continue - fi - - echo "PF/VF setup successful." - exit 0 -done diff --git a/init_mcn_network/tsg-env/tsg-env-mcn3_tsg-env.service b/init_mcn_network/tsg-env/tsg-env-mcn3_tsg-env.service deleted file mode 100644 index 29f6319..0000000 --- a/init_mcn_network/tsg-env/tsg-env-mcn3_tsg-env.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=tsg sled-mcn3 env init -Requires=network.target -After=network.target -Before=tfe-env.service mrenv.service - -[Service] -ExecStart=/opt/tsg/env/setup -ExecStop=/opt/tsg/env/stop -Type=oneshot -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target -RequiredBy=tfe-env.service mrenv.service diff --git a/init_mcn_network/tsg-env/tsg-env-mcn3_vf-setup b/init_mcn_network/tsg-env/tsg-env-mcn3_vf-setup deleted file mode 100644 index e2e7667..0000000 --- a/init_mcn_network/tsg-env/tsg-env-mcn3_vf-setup +++ /dev/null @@ -1,11 +0,0 @@ -echo 4 > /sys/class/net/ens8/device/sriov_numvfs -sleep 5 - -ifconfig ens8f3 up -ip link set ens8 vf 2 vlan 200 -ifconfig ens8f3 192.168.200.4 netmask 255.255.255.0 - -ifconfig ens8f1 up -ifconfig ens8f2 up -ifconfig ens8f3 up -ifconfig ens8f4 up diff --git a/switch_sled_startup_one_arm/saved_startup b/switch_sled_startup_one_arm/saved_startup index c143a6e..9755c11 100644 --- a/switch_sled_startup_one_arm/saved_startup +++ b/switch_sled_startup_one_arm/saved_startup @@ -73,6 +73,85 @@ set switch config hashing l34 symmetric on set port config 9261,9293,9325 max_frame_size 15360 create acl 1 +# Redirect all ARP request to ens1f2 +create acl-rule 1 40 +add acl-rule condition 1 40 src-port 1 +add acl-rule condition 1 40 ethtype 0x0806 +add acl-rule action 1 40 redirect 7214 + +create acl-rule 1 41 +add acl-rule condition 1 41 src-port 2 +add acl-rule condition 1 41 ethtype 0x0806 +add acl-rule action 1 41 redirect 7214 + +create acl-rule 1 42 +add acl-rule condition 1 42 src-port 3 +add acl-rule condition 1 42 ethtype 0x0806 +add acl-rule action 1 42 redirect 7214 + +create acl-rule 1 43 +add acl-rule condition 1 43 src-port 4 +add acl-rule condition 1 43 ethtype 0x0806 +add acl-rule action 1 43 redirect 7214 + +# Redirect all ICMPv4 to ens1f2 -- 10.0.0.0/8 +create acl-rule 1 44 +add acl-rule condition 1 44 src-port 1 +add acl-rule condition 1 44 protocol 0x1/0xff +add acl-rule condition 1 44 sip 10.0.0.0/8 +add acl-rule condition 1 44 dip 10.0.0.0/8 +add acl-rule action 1 44 redirect 7214 + +create acl-rule 1 45 +add acl-rule condition 1 45 src-port 2 +add acl-rule condition 1 45 protocol 0x1/0xff3 +add acl-rule condition 1 45 sip 10.0.0.0/8 +add acl-rule condition 1 45 dip 10.0.0.0/8 +add acl-rule action 1 45 redirect 7214 + +create acl-rule 1 46 +add acl-rule condition 1 46 src-port 3 +add acl-rule condition 1 46 protocol 0x1/0xff +add acl-rule condition 1 46 sip 10.0.0.0/8 +add acl-rule condition 1 46 dip 10.0.0.0/8 +add acl-rule action 1 46 redirect 7214 + +create acl-rule 1 47 +add acl-rule condition 1 47 src-port 3 +add acl-rule condition 1 47 protocol 0x1/0xff +add acl-rule condition 1 47 sip 10.0.0.0/8 +add acl-rule condition 1 47 dip 10.0.0.0/8 +add acl-rule action 1 47 redirect 7214 + +# Redirect all ICMPv4 to ens1f2 -- 192.168.0.0/24 +create acl-rule 1 48 +add acl-rule condition 1 48 src-port 1 +add acl-rule condition 1 48 protocol 0x1/0xff +add acl-rule condition 1 48 sip 192.168.0.0/24 +add acl-rule condition 1 48 dip 192.168.0.0/24 +add acl-rule action 1 48 redirect 7214 + +create acl-rule 1 49 +add acl-rule condition 1 49 src-port 2 +add acl-rule condition 1 49 protocol 0x1/0xff3 +add acl-rule condition 1 49 sip 192.168.0.0/24 +add acl-rule condition 1 49 dip 192.168.0.0/24 +add acl-rule action 1 49 redirect 7214 + +create acl-rule 1 50 +add acl-rule condition 1 50 src-port 3 +add acl-rule condition 1 50 protocol 0x1/0xff +add acl-rule condition 1 50 sip 192.168.0.0/24 +add acl-rule condition 1 50 dip 192.168.0.0/24 +add acl-rule action 1 50 redirect 7214 + +create acl-rule 1 51 +add acl-rule condition 1 51 src-port 3 +add acl-rule condition 1 51 protocol 0x1/0xff +add acl-rule condition 1 51 sip 192.168.0.0/24 +add acl-rule condition 1 51 dip 192.168.0.0/24 +add acl-rule action 1 51 redirect 7214 + create acl-rule 1 61 add acl-rule condition 1 61 src-glort 0x5803 add acl-rule condition 1 61 vlan 1000 -- cgit v1.2.3