[dpdk-dev] tools/dpdk_nic_bind: Fix can't bind virtio-pci issue

Message ID 1424926669-14202-1-git-send-email-changchun.ouyang@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Ouyang Changchun Feb. 26, 2015, 4:57 a.m. UTC
  In virtio test, on guest
1. Bind virtio port to igb_uio driver;
2. Remove igb_uio module;
3. Bind virtio port to virtio-pci driver, it fails and reports:
   "Error - no supported modules are loaded"

The tool should check the to-be-bound driver flag, if it is dpdk driver(igb_uio, vfio etc),
and the corresponding module is not loaded, then exit, otherwise, just report a warning,
and continue to bind the non-dpdk driver(like virtio-pci) to dev.

Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com>
---
 tools/dpdk_nic_bind.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
  

Comments

Bruce Richardson March 3, 2015, 11:43 a.m. UTC | #1
On Thu, Feb 26, 2015 at 12:57:49PM +0800, Ouyang Changchun wrote:
First off, I think the title needs to be changed. How about something like:
"dpdk_nic_bind: don't exit if an unused module is missing"

> In virtio test, on guest
> 1. Bind virtio port to igb_uio driver;
> 2. Remove igb_uio module;
> 3. Bind virtio port to virtio-pci driver, it fails and reports:
>    "Error - no supported modules are loaded"
> 
> The tool should check the to-be-bound driver flag, if it is dpdk driver(igb_uio, vfio etc),
> and the corresponding module is not loaded, then exit, otherwise, just report a warning,
> and continue to bind the non-dpdk driver(like virtio-pci) to dev.

This is a good description of the problem. Once you change the title, I think an
initial sentence is needed here by way of intro - such as:
"The dpdk_nic_bind script will not allow ports to be bound or unbound if
none of the kernel modules supported by DPDK is loaded. This patch relaxes this
restriction by checking if a DPDK module is actually requested. The example
below illustrates this problem:"

> 
> Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com>
> ---
>  tools/dpdk_nic_bind.py | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/dpdk_nic_bind.py b/tools/dpdk_nic_bind.py
> index 2483056..8523f82 100755
> --- a/tools/dpdk_nic_bind.py
> +++ b/tools/dpdk_nic_bind.py
> @@ -175,8 +175,11 @@ def check_modules():
>  
>      # check if we have at least one loaded module
>      if True not in [mod["Found"] for mod in mods] and b_flag is not None:
> -        print "Error - no supported modules are loaded"
> -        sys.exit(1)
> +        if b_flag in dpdk_drivers:
> +            print "Error - no supported modules(DPDK driver) are loaded"
> +            sys.exit(1)
> +        else:
> +            print "Warning - no supported modules(DPDK driver) are loaded"
>  
>      # change DPDK driver list to only contain drivers that are loaded
>      dpdk_drivers = [mod["Name"] for mod in mods if mod["Found"]]
> -- 
> 1.8.4.2
> 
This is a worthwhile change. However, I think it could be made better:
* If we try to bind a device to ixgbe, and ixgbe is not loaded, we get no error
from the script
* If igb_uio is loaded and we try to bind a device to vfio which is not loaded
again we get no error from the script.

If would be nice if instead of this checking explicitly for DPDK modules, we 
just check if the module to be bound is present and give an error if not.

/Bruce
  
Ouyang Changchun March 4, 2015, 2:41 a.m. UTC | #2
Hi,

> -----Original Message-----
> From: Richardson, Bruce
> Sent: Tuesday, March 3, 2015 7:44 PM
> To: Ouyang, Changchun
> Cc: dev@dpdk.org; Cao, Waterman
> Subject: Re: [PATCH] tools/dpdk_nic_bind: Fix can't bind virtio-pci issue
> 
> On Thu, Feb 26, 2015 at 12:57:49PM +0800, Ouyang Changchun wrote:
> First off, I think the title needs to be changed. How about something like:
> "dpdk_nic_bind: don't exit if an unused module is missing"
> 
> > In virtio test, on guest
> > 1. Bind virtio port to igb_uio driver; 2. Remove igb_uio module; 3.
> > Bind virtio port to virtio-pci driver, it fails and reports:
> >    "Error - no supported modules are loaded"
> >
> > The tool should check the to-be-bound driver flag, if it is dpdk
> > driver(igb_uio, vfio etc), and the corresponding module is not loaded,
> > then exit, otherwise, just report a warning, and continue to bind the non-
> dpdk driver(like virtio-pci) to dev.
> 
> This is a good description of the problem. Once you change the title, I think
> an initial sentence is needed here by way of intro - such as:
> "The dpdk_nic_bind script will not allow ports to be bound or unbound if
> none of the kernel modules supported by DPDK is loaded. This patch relaxes
> this restriction by checking if a DPDK module is actually requested. The
> example below illustrates this problem:"
> 

Will update this description in v2.
Thanks

> >
> > Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com>
> > ---
> >  tools/dpdk_nic_bind.py | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/dpdk_nic_bind.py b/tools/dpdk_nic_bind.py index
> > 2483056..8523f82 100755
> > --- a/tools/dpdk_nic_bind.py
> > +++ b/tools/dpdk_nic_bind.py
> > @@ -175,8 +175,11 @@ def check_modules():
> >
> >      # check if we have at least one loaded module
> >      if True not in [mod["Found"] for mod in mods] and b_flag is not None:
> > -        print "Error - no supported modules are loaded"
> > -        sys.exit(1)
> > +        if b_flag in dpdk_drivers:
> > +            print "Error - no supported modules(DPDK driver) are loaded"
> > +            sys.exit(1)
> > +        else:
> > +            print "Warning - no supported modules(DPDK driver) are loaded"
> >
> >      # change DPDK driver list to only contain drivers that are loaded
> >      dpdk_drivers = [mod["Name"] for mod in mods if mod["Found"]]
> > --
> > 1.8.4.2
> >
> This is a worthwhile change. However, I think it could be made better:
> * If we try to bind a device to ixgbe, and ixgbe is not loaded, we get no error
> from the script
> * If igb_uio is loaded and we try to bind a device to vfio which is not loaded
> again we get no error from the script.
> 
> If would be nice if instead of this checking explicitly for DPDK modules, we
> just check if the module to be bound is present and give an error if not.
>
 
For all these cases, they could be detected in function bind_one,
If any module exactly required can't be found/opened,  it will go to except branch and raise a error message like:
Error: bind failed ..... Cannot open.....

Thanks
Changchun
  

Patch

diff --git a/tools/dpdk_nic_bind.py b/tools/dpdk_nic_bind.py
index 2483056..8523f82 100755
--- a/tools/dpdk_nic_bind.py
+++ b/tools/dpdk_nic_bind.py
@@ -175,8 +175,11 @@  def check_modules():
 
     # check if we have at least one loaded module
     if True not in [mod["Found"] for mod in mods] and b_flag is not None:
-        print "Error - no supported modules are loaded"
-        sys.exit(1)
+        if b_flag in dpdk_drivers:
+            print "Error - no supported modules(DPDK driver) are loaded"
+            sys.exit(1)
+        else:
+            print "Warning - no supported modules(DPDK driver) are loaded"
 
     # change DPDK driver list to only contain drivers that are loaded
     dpdk_drivers = [mod["Name"] for mod in mods if mod["Found"]]