3 # Copyright (c) 2016 Open Platform for NFV Project, Inc. and its contributors
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # It adapts /etc/default/ovs-dpdk file
18 # generated mainly from devstack/libs/ovs-dpdk
19 # it will modify / tune variables, which are not configured directly
21 source /etc/default/ovs-dpdk
23 if [ $OVS_SOCKET_MEM == "auto" ] ; then
24 for d in /sys/devices/system/node/node? ; do
25 if [ $OVS_SOCKET_MEM == "auto" ]; then
28 OVS_SOCKET_MEM=$OVS_SOCKET_MEM,2048
33 sudo sed "s#OVS_SOCKET_MEM=.*#OVS_SOCKET_MEM=$OVS_SOCKET_MEM#" -i /etc/default/ovs-dpdk
35 # Creates an array of pci addres to interface names delimeted by # e.g. <pci_address>#<interface name>
36 PAIRS=( `ls -al /sys/class/net/* | grep pci | rev | awk '{print $1;}' | cut -d '/' -f 1,3 | rev | sed s'/\//#/'` )
37 # Populates OVS_BRIDGE_MAPPINGS if $PHYSICAL_NETWORK and $OVS_PHYSICAL_BRIDGE are used instead.
38 if [[ "$OVS_DATAPATH_TYPE" != "" ]] && [[ "$OVS_BRIDGE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then
39 OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE
42 if [[ -z "$OVS_DPDK_PORT_MAPPINGS" ]]; then
43 OVS_BRIDGES=${OVS_BRIDGE_MAPPINGS//,/ }
44 ARRAY=( $OVS_BRIDGES )
45 for net in "${ARRAY[@]}"; do
48 if [[ -z "$OVS_DPDK_PORT_MAPPINGS" ]]; then
49 OVS_DPDK_PORT_MAPPINGS=$nic:$bridge
51 OVS_DPDK_PORT_MAPPINGS=$OVS_DPDK_PORT_MAPPINGS,$nic:$bridge
56 MAPPINGS=${OVS_DPDK_PORT_MAPPINGS//,/ }
60 for net in "${ARRAY[@]}"; do
63 printf "%s in %s\n" "$KEY" "$VALUE"
64 for pair in "${PAIRS[@]}"; do
65 if [[ $nic == `echo $pair | cut -f 2 -d "#"` ]]; then
66 if [[ $NICS == "" ]]; then
74 sudo sed "s/OVS_PCI_MAPPINGS=.*/OVS_PCI_MAPPINGS=$NICS/" -i /etc/default/ovs-dpdk
75 sudo sed "s/OVS_BRIDGE_MAPPINGS=.*/OVS_BRIDGE_MAPPINGS=$OVS_BRIDGE_MAPPINGS/" -i /etc/default/ovs-dpdk
76 sudo sed "s/OVS_DPDK_PORT_MAPPINGS=.*/OVS_DPDK_PORT_MAPPINGS=$OVS_DPDK_PORT_MAPPINGS/" -i /etc/default/ovs-dpdk
78 OVS_PMD_CORE_MASK=$(echo $OVS_PMD_CORE_MASK | sed 's/^0x//')
80 if [ $OVS_PMD_CORE_MASK -eq 4 ]; then
81 #default value, check for siblings in case of hyperthreading enabled
84 FILE="/sys/devices/system/cpu/cpu3/topology/thread_siblings_list"
88 echo "warning: don't know how to check siblings"
92 for SIBLING in $(echo $SIBLINGS | sed -n 1'p' | tr ',' '\n'); do
93 SIBLING_CORE=`echo "obase=10;$((1<<($SIBLING-1)))" | bc`
94 RESULT=$(($RESULT | $SIBLING_CORE))
97 OVS_PMD_CORE_MASK=`printf "%x" $RESULT`
100 sudo sed "s#OVS_PMD_CORE_MASK=.*#OVS_PMD_CORE_MASK=$OVS_PMD_CORE_MASK#" -i /etc/default/ovs-dpdk