Commit e556ceae authored by wangyongshou's avatar wangyongshou

add netcard.conf

parent 3e69b6db
......@@ -73,7 +73,7 @@ function close_upf()
{
pid=$(pidof $VPP_PRO)
if test -z "$pid"; then
echo "vpp $pid is not startup"
echo "vpp $pid is not start up"
else
echo "kill vpp $pid"
kill -9 ${pid}
......@@ -81,7 +81,7 @@ function close_upf()
pid=$(pidof $N4_PRO)
if test -z "$pid"; then
echo "n4 $pid is not startup"
echo "n4 $pid is not start up"
else
echo "kill n4 $pid"
kill -9 ${pid}
......
......@@ -43,16 +43,7 @@ UPF_INTER_PCI=""
function start_vppe()
{
#cmd="$VPPCMD"
install_dpdk_kmod
#$base/tools/interreput -i $CPUNUMBER
echo Y | sudo tee /sys/module/vfio/parameters/enable_unsafe_noiommu_mode
#$cmd >/dev/null 2>&1 &
$base/bin/vpp -c $base/etc/vppe.conf >/dev/null 2>&1 ;
sleep 1s
pid=$(pidof $VPPPROCESS)
......@@ -65,9 +56,6 @@ function start_vppe()
function start_n4()
{
#$N4PATH/main -c /opt/5gc/n4_config.yaml >/dev/null 2>&1 &
$base/bin/main -c $base/etc/n4_config.yaml & >/dev/null 2>&1 ;
sleep 1s
......@@ -85,7 +73,7 @@ function close_upf()
{
pid=$(pidof $VPPPROCESS)
if test -z "$pid"; then
echo "vpp $pid is not startup"
echo "vpp $pid is not startup"
else
echo "kill vpp $pid"
kill -9 ${pid}
......@@ -93,7 +81,7 @@ function close_upf()
pid=$(pidof $N4PROCESS)
if test -z "$pid"; then
echo "n4 $pid is not startup"
echo "n4 $pid is not startup"
else
echo "kill n4 $pid"
kill -9 ${pid}
......@@ -102,10 +90,9 @@ function close_upf()
function close_vppe()
{
pid=$(pidof $VPPPROCESS)
if test -z "$pid"; then
echo "vpp $pid is not startup"
echo "vpp $pid is not startup"
else
echo "kill vpp $pid"
kill -9 ${pid}
......@@ -114,10 +101,9 @@ function close_vppe()
function close_n4()
{
pid=$(pidof $N4PROCESS)
if test -z "$pid"; then
echo "n4 $pid is not startup"
echo "n4 $pid is not startup"
else
echo "kill n4 $pid"
kill -9 ${pid}
......@@ -125,14 +111,18 @@ function close_n4()
exit 0
}
function install_dpdk_kmod()
function install_driver()
{
sudo modprobe vfio-pci;
insmod_result=$?
exec_result $insmod_result
echo Y | sudo tee /sys/module/vfio/parameters/enable_unsafe_noiommu_mode
#$base/tools/interreput -i $CPUNUMBER
return 0;
}
......@@ -142,32 +132,28 @@ function exec_result()
echo "insmod vfio-pci.ko false"
fi
echo "insmod vfio-pci.ko success!!!"
echo "insmod vfio-pci.ko success"
}
function install_deps()
{
echo "install deps"
}
function unbind()
function net_state()
{
if [ ! -f $base/etc/netcard.conf ] ; then
echo "ERROR not exist $/base/etc/netcard.conf "
exit 0
fi
python3 $current/dpdk-devbind.py -u 0000:$DPDK_EXPORT_PCI ;
python3 $current/dpdk-devbind.py -u 0000:$DPDK_EXPORT_PCI;
python3 $current/dpdk-devbind.py -b $DRIVE $DPDK_EXPORT_PCI
sleep 1
python3 $current/dpdk-devbind.py -b $DRIVE $DPDK_EXPORT_PCI
sleep 1
while read line
do
eval "$line"
done < $base/etc/netcard.conf
ifconfig $upf_n3_name down;
ifconfig $upf_n6_name down;
ifconfig $DPDK_EXPORT down;
sleep 1
ifconfig $DPDK_ENTRY down;
sleep 1
python3 $base/scripts/dpdk-devbind.py -b vfio-pci $upf_n3_pci
python3 $base/scripts/dpdk-devbind.py -b vfio-pci $upf_n6_pci
return 0
}
function get_inter_ip()
......@@ -183,10 +169,22 @@ function get_inter_pci()
UPF_INTER_PCI=$(echo `$base/tools/ethtool -i ${INTER_NAME} | grep "bus-info" | awk '{print $2}'`)
#UPF_INTER_PCI=$(echo ` ./dpdk-devbind.py --status | grep "if=${INTER_NAME}" | awk '{print $1}'`)
}
function is_configured(){
result=$(echo `grep -n "@N3_GW@" $base/etc/vppe.conf | grep "@N3_GW@"`)
echo $result
if [[ $result != "" ]]; then
echo "not config"
return 0
else
echo "configured"
return 1
fi
}
function generate_instance()
{
{
CPUCORES=$(echo `cat /proc/cpuinfo| grep "processor"| wc -l`)
UPF_MAINCORE=`expr $CPUCORES - 3`
......@@ -195,7 +193,7 @@ function generate_instance()
UPF_WORKERCORE="$workerc1,$workerc2"
#vpp config
#vppe config
sed -i s/@MAINCORE@/${UPF_MAINCORE}/ $VPP_CONFIG > /dev/null 2>&1;
sed -i s/@WORKERCORE@/${UPF_WORKERCORE}/ $VPP_CONFIG > /dev/null 2>&1;
......@@ -212,12 +210,73 @@ function generate_instance()
sed -i s/@upf@/${UPF_N4_UPF}/ $VPP_N4 > /dev/null 2>&1;
sed -i s/@logSize@/${UPF_N4_LOGSIZE}/ $VPP_N4 > /dev/null 2>&1;
echo ""
echo "/opt/5gc/vppe.conf"
echo "/opt/5gc/n4_config.yaml"
echo "config finished"
}
function get_bus()
{
UPF_N3_DRIVER=$(echo `$base/tools/ethtool -i $UPF_N3_NAME | grep "driver" | awk '{print $2}'`)
if [[ $UPF_N3_DRIVER == "" ]]; then
echo "ERROR N3 $UPF_N3_NAME cat not bus"
exit 0
else
echo "$UPF_N3_NAME pci $UPF_N3_DRIVER"
fi
UPF_N6_DRIVER=$(echo `$base/tools/ethtool -i $UPF_N6_NAME | grep "driver" | awk '{print $2}'`)
if [[ $UPF_N6_DRIVER == "" ]]; then
echo "ERROR N6 $UPF_N6_NAME cat not bus"
exit 0
else
echo "$UPF_N6_NAME pci $UPF_N6_DRIVER"
fi
}
function get_pci()
{
UPF_N3_PCI=$(echo `$base/tools/ethtool -i $UPF_N3_NAME | grep "bus-info" | awk '{print $2}'`)
if [[ $UPF_N3_PCI == "" ]]; then
echo "ERROR N3 $UPF_N3_NAME cat not pci"
exit 0
else
echo "$UPF_N3_NAME pci $UPF_N3_PCI"
fi
UPF_N6_PCI=$(echo `$base/tools/ethtool -i $UPF_N6_NAME | grep "bus-info" | awk '{print $2}'`)
if [[ $UPF_N6_PCI == "" ]]; then
echo "ERROR N6 $UPF_N6_NAME cat not pci"
exit 0
else
echo "$UPF_N6_NAME pci $UPF_N6_PCI"
fi
}
function get_inter_info()
{
if [ -f $base/etc/netcard.conf ] ; then
return 0
fi
get_pci
get_bus
#netcard.conf
cd $base/etc
touch netcard.conf
chmod a+x netcard.conf
echo "upf_n3_name=$UPF_N3_NAME" >> netcard.conf
echo "upf_n6_name=$UPF_N6_NAME" >> netcard.conf
echo "upf_n3_pci=$UPF_N3_PCI" >> netcard.conf
echo "upf_n6_pci=$UPF_N6_PCI" >> netcard.conf
echo "upf_n3_driver=$UPF_N3_DRIVER" >> netcard.conf
echo "upf_n6_driver=$UPF_N6_DRIVER" >> netcard.conf
cd ..
}
#read upf.txt
function read_config() {
......@@ -248,15 +307,7 @@ function read_config() {
UPF_CPU=$vpp_cpu
echo "vpp_cpu:$UPF_CPU"
get_inter_pci $UPF_N3_NAME
UPF_N3_PCI=$UPF_INTER_PCI
echo "UPF_N3_PCI:$UPF_N3_PCI"
UPF_INTER_PCI=""
get_inter_pci $UPF_N6_NAME
UPF_N6_PCI=$UPF_INTER_PCI
echo "UPF_N6_PCI:$UPF_N6_PCI"
get_inter_info
echo ""
echo "n4 config"
......@@ -276,8 +327,16 @@ function read_config() {
function config_upf()
{
install_driver
read_config
generate_instance
is_configured
result=$?
if [ $result -eq 0 ] ; then
generate_instance
fi
net_state
}
function help()
......@@ -288,43 +347,34 @@ function help()
echo "--close-upf close UPF(n4 and vppe)"
}
function main()
{
if [ ! -f $UPF_CONFIG ] ; then
echo "no exist $UPF_CONFIG"
return
fi
install_deps
if [ $# -eq 0 ];
then
help
exit
fi
if [ ! -f $UPF_CONFIG ] ; then
echo "no exist $UPF_CONFIG"
return
fi
until [ -z "$1" ]; do
case "$1" in
--start-upf)
config_upf
#close vppe, n4 process
close_upf
#start vppe, n4 process
start_vppe
sleep 20s
start_n4
shift
;;
--close-upf)
#close vppe, n4 process
close_vppe
close_n4
shift
;;
*)
help
exit 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment