4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
22 for iface in $SRIOV_INTERFACES
24 vf_count=$SRIOV_VF_COUNT
25 if [[ -z "$vf_count" ]]
27 if ! vf_count=$(</sys/class/net/$iface/device/sriov_totalvfs)
29 echo "Failed to get supported VF count for the interface $iface" >&2
35 echo "Creating $vf_count SR-IOV VFs for the interface $iface"
36 if ! echo $vf_count > /sys/class/net/$iface/device/sriov_numvfs
38 echo "Failed to create SR-IOV VFs for the interface $iface" >&2
51 for iface in $SRIOV_INTERFACES
53 echo "Removing SR-IOV VFs from the interface $iface"
54 if ! echo 0 > /sys/class/net/$iface/device/sriov_numvfs
56 echo "Failed to remove SR-IOV VFs from the interface $iface" >&2
66 local -r CONF_FILE="/etc/sriov/sriov.conf"
69 if [[ $# -ne 1 || ! $ACTION =~ ^(start|stop)$ ]]
71 echo "usage: $0 [start|stop]" >&2
75 [[ -r $CONF_FILE ]] && source $CONF_FILE
77 if [[ -n "$SRIOV_INTERFACES" ]]
81 echo "No SR-IOV interfaces to configure" >&2