Commit ae2c3152 authored by Jim Harris's avatar Jim Harris
Browse files

Add unbind_nvme.sh script.



This will rmmod nvme on Linux, and use the DPDK nic_uio driver
to unbind nvme devices from the nvme driver on FreeBSD.

"nic_uio" is actually a misnomer - it is not NIC driver specific,
and can safely be used to bind NVMe devices to an effectively
null driver.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I8b964a070586166d762d79696385b82eeb2e88bd
parent ae09ffb7
Loading
Loading
Loading
Loading

scripts/unbind_nvme.sh

0 → 100755
+25 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash

set -e

function configure_linux {
	lsmod | grep nvme && rmmod nvme
}

function configure_freebsd {
	TMP=`mktemp`
	AWK_PROG="{if (count > 0) printf \",\"; printf \"%s:%s:%s\",\$2,\$3,\$4; count++}"
	echo $AWK_PROG > $TMP
	NVME_PCICONF=`pciconf -l | grep class=0x010802`
	BDFS=`echo $NVME_PCICONF | awk -F: -f $TMP`
	kenv hw.nic_uio.bdfs=$BDFS
	kldload `find . -name nic_uio.ko | head -1`
	rm $TMP
}

if [ `uname` = Linux ]; then
	configure_linux
else
	configure_freebsd
fi