3 # It adapts /etc/default/ovs-dpdk file
4 # generated mainly from devstack/libs/ovs-dpdk
5 # it will modify / tune variables, which are not configured directly
7 source /etc/default/ovs-dpdk
9 if [ $OVS_SOCKET_MEM == "auto" ] ; then
10 for d in /sys/devices/system/node/node? ; do
11 if [ $OVS_SOCKET_MEM == "auto" ]; then
14 OVS_SOCKET_MEM=$OVS_SOCKET_MEM,2048
19 sudo sed "s#OVS_SOCKET_MEM=.*#OVS_SOCKET_MEM=$OVS_SOCKET_MEM#" -i /etc/default/ovs-dpdk
21 # Creates an array of pci addres to interface names delimeted by # e.g. <pci_address>#<interface name>
22 PAIRS=( `ls -al /sys/class/net/* | grep pci | rev | awk '{print $1;}' | cut -d '/' -f 1,3 | rev | sed s'/\//#/'` )
23 # Populates OVS_BRIDGE_MAPPINGS if $PHYSICAL_NETWORK and $OVS_PHYSICAL_BRIDGE are used instead.
24 if [[ "$OVS_DATAPATH_TYPE" != "" ]] && [[ "$OVS_BRIDGE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then
25 OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE
28 if [[ -z "$OVS_DPDK_PORT_MAPPINGS" ]]; then
29 OVS_BRIDGES=${OVS_BRIDGE_MAPPINGS//,/ }
30 ARRAY=( $OVS_BRIDGES )
31 for net in "${ARRAY[@]}"; do
34 if [[ -z "$OVS_DPDK_PORT_MAPPINGS" ]]; then
35 OVS_DPDK_PORT_MAPPINGS=$nic:$bridge
37 OVS_DPDK_PORT_MAPPINGS=$OVS_DPDK_PORT_MAPPINGS,$nic:$bridge
42 MAPPINGS=${OVS_DPDK_PORT_MAPPINGS//,/ }
46 for net in "${ARRAY[@]}"; do
49 printf "%s in %s\n" "$KEY" "$VALUE"
50 for pair in "${PAIRS[@]}"; do
51 if [[ $nic == `echo $pair | cut -f 2 -d "#"` ]]; then
52 if [[ $NICS == "" ]]; then
60 sudo sed "s/OVS_PCI_MAPPINGS=.*/OVS_PCI_MAPPINGS=$NICS/" -i /etc/default/ovs-dpdk
61 sudo sed "s/OVS_BRIDGE_MAPPINGS=.*/OVS_BRIDGE_MAPPINGS=$OVS_BRIDGE_MAPPINGS/" -i /etc/default/ovs-dpdk
62 sudo sed "s/OVS_DPDK_PORT_MAPPINGS=.*/OVS_DPDK_PORT_MAPPINGS=$OVS_DPDK_PORT_MAPPINGS/" -i /etc/default/ovs-dpdk
64 OVS_PMD_CORE_MASK=$(echo $OVS_PMD_CORE_MASK | sed 's/^0x//')
66 if [ $OVS_PMD_CORE_MASK -eq 4 ]; then
67 #default value, check for siblings in case of hyperthreading enabled
70 FILE="/sys/devices/system/cpu/cpu3/topology/thread_siblings_list"
74 echo "warning: don't know how to check siblings"
78 for SIBLING in $(echo $SIBLINGS | sed -n 1'p' | tr ',' '\n'); do
79 SIBLING_CORE=`echo "obase=10;$((1<<($SIBLING-1)))" | bc`
80 RESULT=$(($RESULT | $SIBLING_CORE))
83 OVS_PMD_CORE_MASK=`printf "%x" $RESULT`
86 sudo sed "s#OVS_PMD_CORE_MASK=.*#OVS_PMD_CORE_MASK=$OVS_PMD_CORE_MASK#" -i /etc/default/ovs-dpdk