Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add more tests and make sure they pass, add stop() support to app
- Loading branch information
1 parent
ee2c688
commit 19b6164
Showing
4 changed files
with
85 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,44 @@ | ||
#!/bin/bash | ||
|
||
PFIDX=0 | ||
function setup(){ | ||
local pciid=$1 | ||
local mac=$2 | ||
if [ -z "$pciid" ]; then | ||
echo pciid must be defined | ||
exit -1 | ||
fi | ||
local pfdir="/sys/bus/pci/devices/$pciid" | ||
local drv=$( readlink -f $pfdir/driver) | ||
if [ -e "$drv" ]; then | ||
echo $pciid > $drv/unbind | ||
else | ||
drv=/sys/bus/pci/drivers/i40e | ||
echo "pciid" unbound trying $drv | ||
fi | ||
sleep 1 | ||
echo $pciid > $drv/bind | ||
nic=$( ls $pfdir/net ) | ||
ip link set up dev $nic | ||
echo 1 > "$pfdir/sriov_numvfs" | ||
sleep 1 | ||
local pciid=$1 | ||
local mac=$2 | ||
if [ -z "$pciid" ]; then | ||
echo pciid must be defined | ||
exit -1 | ||
fi | ||
local pfdir="/sys/bus/pci/devices/$pciid" | ||
local drv=$( readlink -f $pfdir/driver) | ||
if [ -e "$drv" ]; then | ||
echo $pciid > $drv/unbind | ||
else | ||
drv=/sys/bus/pci/drivers/i40e | ||
echo "pciid" unbound trying $drv | ||
fi | ||
sleep 1 | ||
echo $pciid > $drv/bind | ||
nic=$( ls $pfdir/net ) | ||
ip link set up dev $nic | ||
echo $(( $# - 1 )) > "$pfdir/sriov_numvfs" | ||
sleep 1 | ||
|
||
local vfdir=$( readlink -f $pfdir/virtfn0 ) | ||
local vfnic=$( ls $vfdir/net ) | ||
local loop=0 | ||
for i in ${@:2}; do | ||
local vfdir=$( readlink -f $pfdir/virtfn$loop ) | ||
local vfnic=$( ls $vfdir/net ) | ||
|
||
ip link set $nic vf 0 mac $mac | ||
local vfid=$( basename $( readlink -f $vfdir ) ) | ||
echo $vfid > $vfdir/driver/unbind | ||
echo $vfid | ||
ip link set $nic vf $loop mac $i | ||
ip link set $nic vf $loop spoofchk off | ||
ip link set $nic vf $loop trust on | ||
|
||
local vfid=$( basename $( readlink -f $vfdir ) ) | ||
echo $vfid > $vfdir/driver/unbind | ||
echo "export SNABB_AVF_PF${PFIDX}_VF${loop}=$vfid" | ||
loop=$(( loop + 1 )) | ||
done | ||
PFIDX=$(( VFIDX + 1 )) | ||
} | ||
|
||
SNABB_AVF_VF0=$(setup $SNABB_AVF_PF0 02:00:00:00:00:00) | ||
SNABB_AVF_VF1=$(setup $SNABB_AVF_PF1 02:00:00:00:00:01) | ||
sleep 3 | ||
echo export SNABB_AVF_VF0=$SNABB_AVF_VF0 | ||
echo export SNABB_AVF_VF1=$SNABB_AVF_VF1 | ||
setup $SNABB_AVF_PF0 02:00:00:00:00:00 02:00:00:00:00:01 02:00:00:00:00:02 02:00:00:00:00:03 | ||
setup $SNABB_AVF_PF1 02:00:00:00:00:10 02:00:00:00:00:11 02:00:00:00:00:12 02:00:00:00:00:13 |